Hi good afternoon.
How do these two addresses work together?
I want to fill memory with data0 by counting up.
Thanks.
greeting
----------------------
$9F22
$9F23 DATA0
----------------------
how to work $9f22 and $9f23 ( data0)?
Re: how to work $9f22 and $9f23 ( data0)?
First, configure bit 0 of $9F25:
0 = $9F20..$9F22 will update $9F23.
1 = $9F20..$9F22 will update $9F24.
$9F22 is multiple things:
Bit 0 = bit 16 of VRAM address.
Bits 4..7 = "Address Increment" (amount to increase the VRAM address when a byte is written)
Bit 3 is "DECR" (short for "decrement"; decrease instead of increase)
Do not worry about bits 1 and 2.
Value of "Address Increment": (from here)
$0 = 0 bytes
$1 = 1 byte
$2 = 2 bytes
$3 = 4 bytes
$4 = 8 bytes
$5 = 16 bytes
$6 = 32 bytes
$7 = 64 bytes
$8 = 128 bytes
$9 = 256 bytes
$A = 512 bytes
$B = 40 bytes
$C = 80 bytes
$D = 160 bytes
$E = 320 bytes
$F = 640 bytes
For example, to set DATA0 to VRAM address $01234, and to increase by 1 byte when writing to DATA0:
$00 -> $9F25 (select DATA0 for update)
$34 -> $9F20 (update bits 0..7 of VRAM address)
$12 -> $9F21 (update bits 8..15 of VRAM address)
$10 -> $9F22 (update bit 16 of VRAM address, select "1 byte" increment)
0 = $9F20..$9F22 will update $9F23.
1 = $9F20..$9F22 will update $9F24.
$9F22 is multiple things:
Bit 0 = bit 16 of VRAM address.
Bits 4..7 = "Address Increment" (amount to increase the VRAM address when a byte is written)
Bit 3 is "DECR" (short for "decrement"; decrease instead of increase)
Do not worry about bits 1 and 2.
Value of "Address Increment": (from here)
$0 = 0 bytes
$1 = 1 byte
$2 = 2 bytes
$3 = 4 bytes
$4 = 8 bytes
$5 = 16 bytes
$6 = 32 bytes
$7 = 64 bytes
$8 = 128 bytes
$9 = 256 bytes
$A = 512 bytes
$B = 40 bytes
$C = 80 bytes
$D = 160 bytes
$E = 320 bytes
$F = 640 bytes
For example, to set DATA0 to VRAM address $01234, and to increase by 1 byte when writing to DATA0:
$00 -> $9F25 (select DATA0 for update)
$34 -> $9F20 (update bits 0..7 of VRAM address)
$12 -> $9F21 (update bits 8..15 of VRAM address)
$10 -> $9F22 (update bit 16 of VRAM address, select "1 byte" increment)
Re: how to work $9f22 and $9f23 ( data0)?
Hello, thank you.
that works great.
Your example is great.
greeting
that works great.
Your example is great.
greeting
Re: how to work $9f22 and $9f23 ( data0)?
Hello,
The dual data ports and auto-increment function can be a bit much at times... so just in case you find this useful or the next chap that happens on this thread needs to know..
The kernal actually uses both data ports when copying the text tiles into VRAM -
it sets bit 0 $9F25 to 1 and configures $9f22, $9f23, and $9f24 to increment 1 Byte at a time starting at the second half of the tile set..
then sets but 0 of $9F25 to 0 and configures $9f22,$9f23 and $9f24 to increment 1 at a time starting at the beginning of the tile set.
Then it loops through the data like this -
read 1 byte from ROM into accumulator
write DATA0 ( Data0 increments after being read or written to by 1 because of setting )
EOR #$FF ( to invert the graphic data )
write DATA1 (Data1 increments after being read or written to by 1 because of setting )
_most_ of the time, you are likely only going to need 1 of the DATA0 or DATA1 ... if you are just writing to VRAM or copying from RAM..
Those times where you want to maintain 2 addresses into VRAM can be helpful though... maybe the way your game updates things you want DATA0 pointing at a tile map so you can write out text , while DATA1 is pointing to a bitmap you are drawing at the same time... I don't know.. the functionality is there if you need it...
further - say you have 128x64 tilemap ... you could write a _column_ down the screen by setting the auto-increment to 256... so
A
B
C
D
E
F
G
just by doing
write A to DATA0
write B to DATA0
...
and so forth... this makes things like Wolfenstein 3D rendering a lot faster and simpler to sort out...
The dual data ports and auto-increment function can be a bit much at times... so just in case you find this useful or the next chap that happens on this thread needs to know..
The kernal actually uses both data ports when copying the text tiles into VRAM -
it sets bit 0 $9F25 to 1 and configures $9f22, $9f23, and $9f24 to increment 1 Byte at a time starting at the second half of the tile set..
then sets but 0 of $9F25 to 0 and configures $9f22,$9f23 and $9f24 to increment 1 at a time starting at the beginning of the tile set.
Then it loops through the data like this -
read 1 byte from ROM into accumulator
write DATA0 ( Data0 increments after being read or written to by 1 because of setting )
EOR #$FF ( to invert the graphic data )
write DATA1 (Data1 increments after being read or written to by 1 because of setting )
_most_ of the time, you are likely only going to need 1 of the DATA0 or DATA1 ... if you are just writing to VRAM or copying from RAM..
Those times where you want to maintain 2 addresses into VRAM can be helpful though... maybe the way your game updates things you want DATA0 pointing at a tile map so you can write out text , while DATA1 is pointing to a bitmap you are drawing at the same time... I don't know.. the functionality is there if you need it...
further - say you have 128x64 tilemap ... you could write a _column_ down the screen by setting the auto-increment to 256... so
A
B
C
D
E
F
G
just by doing
write A to DATA0
write B to DATA0
...
and so forth... this makes things like Wolfenstein 3D rendering a lot faster and simpler to sort out...
Re: how to work $9f22 and $9f23 ( data0)?
hello thanks for the infor.
thanks
greeting
thanks
greeting