sdm wrote: ↑Mon Nov 07, 2022 2:28 am
Is reading VRAM also autoincrement?
VMDATAREAD does autoincrement (depending on the state of
VMAIN), however the autoincrement (and VRAM-chip read by the PPU) occurs after
VMDATAREAD outputs the vram_latch value.
In practice this requires you to preform a dummy read if you are preforming multiple
VMDATAREAD reads. Otherwise first two
VMDATAREAD reads will contain the same value (and there is an off-by-one or off-by-two in the read data).
Code: Select all
VMMAIN = 0x80
VMADD = 0x6000
word0 = VMDATAREAD // word0 = data at VRAM word address 0x6000
word1 = VMDATAREAD // word1 = data at VRAM word address 0x6000
word2 = VMDATAREAD // word2 = data at VRAM word address 0x6001
word3 = VMDATAREAD // word3 = data at VRAM word address 0x6002
Secondly,
VMADD,
VMDATAREAD and
VMDATA will only preform the VRAM-chip reads/writes if the PPU is in force-blank (screen-disabled) or vertical-blank.
VMDATAREAD will output invalid values if read outside of the force-blank/vertical-vblank[1]
(untested code).
Code: Select all
; 8 bit A
; 16 bit Index
; DB access registers
; DP = 0
; force blank
lda #INIDISP.force
sta INIDISP
lda #VMAIN.incrementMode.high | VMAIN.increment.by1
sta VMAIN
; vram word address
ldx #$6000
stx VMADD
; dummy read
ldx VMDATAREAD
rep #$30
; a16
; i16
; x = destination address
; y = number of words remaining
ldx #$0000
ldy #2048 / 2
Loop:
lda VMDATAREAD
sta $7e0000,x
inx
inx
dey
bne Loop
sep #20
; a8
---
[1]: I can't remember what the invalid value is. Higan says it always outputs 0, but I don't have a source for it and haven't written a test rom for
VMDATAREAD yet.