Recap:
Covered the TIA (Television Interface Adaptor) and its relationship to the 6502 processor.
The TIA has three "color" cycles to the 6502's one programmatic cycle.
The TIA has 228 cycles consisting of 160 drawn to the screen and 68 invisible cycles used by the horizontal blank.
Unless, the programmer changes the TIA every scanline will look identical.
Since the TIA is independent from the 6502 it is possible to just send 160 scanlines to the TIA and wait 76 scanlines and the TIA will take care of the rest.
No. Since the TIA has an internal state and draws data to the TV based on this state, it is possible to draw a single line simply by waiting 76 cycles of 6502 time (228 TIA colour clocks). It is possible to draw an entire frame by waiting for 262 lines (NTSC) or 312 lines (PAL). -- AD
The TIA is so closely tied to the 6502 that it has the ability to stop and start the 6502 at will. In fact the 6502 can tell the TIA to halt the 6502.
If you are unsure of the position of the TIA just ask the TIA to halt the 6502 and since the TIA restarts at the beginning of each scanline the 6502 and the TIA will be back in synch. The best thing is that the 6502 will be unaware that anything happened at all.
[No. It is not the TIA which restarts at the beginning of each scanline. It is the TIA which restarts the 6502 at the beginning of each scanline, if it has been halted (through WSYNC writes). -- AD[/b]
The CPU-Halt is called by writing any value to the TIA's Register called
WSYNC.
Notes on Assembly
Binary numbers are represented by a "%" prefix
Hexadecimal numbers are represented by a "$" prefix
A base 10 number is represented by a "#" prefix
";" precedes any comments in the code
Not quite. Base 10 numbers have NO prefix. the "#" symbol tells the assembler to treat the follwing value as a number, not a number representing a memory location.
Example:
lda #$80 ; load the number 128 into the accumulator
sta $80 ; store the contents of the accumulator into memory location %10000000
lda 128 ; load the contents of memory location 128 (=$80) back into the accumulator
sta #128 ; totally illegal instruction format - won't assemble. You can't store to a number, you can only store to a location!
--AD
nop = no operation (two 6502 cycles to execute) if you executed 38 nops starting at the beginning of the scanline the TIA would finish drawing the last pixel the same time the 6502 finished executing the last nop command.
Introduction to the 6502
The 6502 is an 8-bit processor which means it works with 8 binary-bits at a time.
Eight binary numbers can represent 0 to 255
8 binary bits can represent a number from 0 to 255 (decimal) or from -128 to 127, or whatever range or representation you want to conceptually give to it. The important point is that there are 256 unique values. -- AD
You read binary numbers from right to left.
They are no different to any other number we're used to -- it's just the base which is different. -- AD
Here is an example of a binary number %01100101
This number equals = 101 and this is how:
| 128| 64 | 32 | 16 | 8 | 4 | 2 | 1 |
-----------------------------------------
| 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 |
-----------------------------------------
64 + 32 + 4 + 1 = 101
Ok, I have no math skills and to be honest until last week I had no idea
how to count hex or binary or convert between them.
This tutorial was crucial for me
http://mathforum.org...view/54311.html
The 6502 is able to shift 8-bit numbers to and from various locations in memory (referred to as addresses).
A memory address is a unique location in RAM or ROM like a home address or an post office box number. The 6502 processor is able to get numbers from and in some cases store numbers to these addresses.
The 6502 has just six
registers but only the first three are covered here. Registers are internal memory/storage locations. The three registers are (X,Y,A)