aoineko-fr / MSXgl

The MSX Game Library in C language
113 stars 9 forks source link

VDP_Poke_16K problem #17

Closed jbikker closed 11 months ago

jbikker commented 2 years ago

VDP_Poke_16K sometimes writes to the wrong memory address in VRAM. It's rare, but it happens. I am using the 128K version as a workaround for now. Can provide example code if needed.

jbikker commented 2 years ago

I think the problem is in vdp.c, line 676, which restricts a dummy inc hl to graphics modes G1 and G2 while the same delay seems to be needed in text modes (which is what I'm operating in).

aoineko-fr commented 2 years ago

Hi jbikker.

What VDP_ISR_SAFE_MODE are you using? If you don't use VDP_ISR_SAFE_NONE (that remove the EI instruction in the VDP_Poke_16K function), you have 22 t-states (z80 cycles) between the 2 out instructions. That should be enough even in the worse-case scenario in text-modes (worst case is 12 t-states on MSX1 and 20 on MSX2). If you use VDP_ISR_SAFE_NONE, there is only 17 t-states between the out instructions… which is actually a problem. Feel free to come to the MSXgl Discord server ; it's more convenient to discuss issues.

I am interested in your example code so that I can make some testing.