I've done some investigations, and finally found that is possible.
1) changing r18 while i vblank DOES NOT WORK, there is a glitch
2) to change r18 safely one must be in HBLANK
this dirty code works on a plain msx2:
ld a,2 ; read S#2 out (0x99),a ld a,128+15 out (0x99),a ; ld b, 3 3: in a,(0x99) ;wait until start of HBLANK and 0x20 jp z,3b 1: in a,(0x99) ;wait until start of HBLANK and 0x20 jp nz,1b 2: in a,(0x99) ;wait until end of HBLANK and 0x20 jp z,2b djnz 3b ; i loop three times, but i think it's not needed ld b, 11 4: ; this delay help to adjust when to update the register djnz 4b ld a, 240 ; visual indication out (0x99),a ld a, 7+128 out (0x99),a ld a, (_r18Value) ; do the job inc a and 15 out (0x99), a ld a,128+18 out (0x99), a ld a, 0 out (0x99),a ld a, 7+128 out (0x99),a
the code is only to demostrate that can be done.
this code is running while a cmd LMMV with xor logical operation is running in a infinite loop. There is no glitch
I've shared this because i think can be useful to know how the vdp works. But this code need to be refined a lot.
Most probably the vdp does a R18 sync at every scanline, regardless of VBLANK or not.
Anyway this command run in VBLANK.
Login or register to post comments