Hello
How to READ or WRITE a word (two bytes) in an address in the VRAM ?
For example:
For READ in VRAM's address $A11C (bytes A11C & A11D) ?
For WRITE 17 35 in VRAM's address $A11C ?
Thank you
Read/Write in VRAM
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
Read/Write in VRAM
Last edited by gigi5 on Fri Mar 26, 2021 4:50 pm, edited 1 time in total.
Re: Read/Write in VRAM
The SNES makes reading-then-rewriting VRAM expensive, so it'd be best to not do that.
To literally answer the question:
Set VMADDL,H ($2116,7) to the address you want to read
Possibly set VMAIN ($2115) to the correct mode
Read two bytes via RDVRAML,H ($2139,A)
Re-set VMADDL,H ($2116,7)
Write two different bytes to VMDATAL,H ($2118,9)
To literally answer the question:
Set VMADDL,H ($2116,7) to the address you want to read
Possibly set VMAIN ($2115) to the correct mode
Read two bytes via RDVRAML,H ($2139,A)
Re-set VMADDL,H ($2116,7)
Write two different bytes to VMDATAL,H ($2118,9)
Re: Read/Write in VRAM
VRAM uses word addresses. Byte $A11C isn't at $A11C; it's at $508E.
There are only 64 KB of VRAM in the SNES, so $A11C doesn't exist/will wrap to $211C.
There are only 64 KB of VRAM in the SNES, so $A11C doesn't exist/will wrap to $211C.
Re: Read/Write in VRAM
Thank youlidnariq wrote: ↑Fri Mar 26, 2021 3:17 pm The SNES makes reading-then-rewriting VRAM expensive, so it'd be best to not do that.
To literally answer the question:
Set VMADDL,H ($2116,7) to the address you want to read
Possibly set VMAIN ($2115) to the correct mode
Read two bytes via RDVRAML,H ($2139,A)
Re-set VMADDL,H ($2116,7)
Write two different bytes to VMDATAL,H ($2118,9)
But I do not all understand
The easiest (for me) is to look at the hex code (machine language), could you give me this 2 examples in hex code (machine language) ?
Ok I take note , thank you
-
- Posts: 1565
- Joined: Tue Feb 07, 2017 2:03 am
Re: Read/Write in VRAM
Code: Select all
;AY 16
LDA #$0080
STA $2115
LDX #$50BE
STX $2116
LDA $2139
; do what ever you want to it, Don't change X
STX $2116
STA $2118
Re: Read/Write in VRAM
Oziphantom wrote: ↑Fri Mar 26, 2021 10:07 pmCode: Select all
;AY 16 LDA #$0080 STA $2115 LDX #$50BE STX $2116 LDA $2139 ; do what ever you want to it, Don't change X STX $2116 STA $2118
Thank you Oziphantom , I will see this
Re: Read/Write in VRAM
LDA #$0080
STA $2115
LDX #$508E
STX $2116
LDA $2139
So if I understood correctly: now index A has the same value as the vram at 508E (A11C/2)
And the method for write "#$1735" in VRAM at 508E if I understood correctly it's :
LDA #$0080
STA $2115
LDX #$508E
LDA #$1735
STX $2116
STA $2118
STA $2115
LDX #$508E
STX $2116
LDA $2139
So if I understood correctly: now index A has the same value as the vram at 508E (A11C/2)
And the method for write "#$1735" in VRAM at 508E if I understood correctly it's :
LDA #$0080
STA $2115
LDX #$508E
LDA #$1735
STX $2116
STA $2118