Reading from VRAM
-----------------
1) Write upper address byte into $2006
2) Write lower address byte into $2006
3) Read data from $2007. The first read from $2007 is invalid, and
therefore should be taken care of before actual data is read.
4) Read data from $2007. From here on, after each read, the address will
auto-increment by 1, or 32 (if Bit #2 of $2000 is 1).
The first read through $ 2007 after setting $ 2006 is always invalid. Only the next one is correct. But why if I set $ 2006 TWO times, the second time the FIRST reading through 2007 is correct?
Code: Select all
lda addrHI
sta 2006
lda addrLO
sta 2006
lda 2007 ; junk read
lda 2007 ; correct read
sta variable
Code: Select all
lda addrHI
sta 2006
lda addrLO
sta 2006
lda 2007 ; junk read
sta variable
lda addrHI
sta 2006
lda addrLO
sta 2006
lda 2007 ; correct read (This is the first reading of 2007 after the address has been set so it should be incorrect)
sta variable