Page 1 of 1

Enable / Disable vertical interrupts in Mode Register 2

Posted: Thu Nov 03, 2022 6:42 pm
by siudym
Are there any restrictions on disabling and re-enabling vertical interrupts - i.e. BIT5 in Mode Register 2?

In the code, I had to turn off VBLANK IRQ and then turn it on - everything worked fine on emulators, but the code running on real hardware did not do correctly set bit5 on register 2 ... (generally it did not allow the VBL IRG to be re-enabled).

Re: Enable / Disable vertical interrupts in Mode Register 2

Posted: Fri Nov 04, 2022 1:14 am
by Mask of Destiny
The only real restriction is that setting VDP registers also messes with the configured address/destination for writes/reads/DMA. The other thing to keep in mind is that disabling vertical interrupts this way is that it doesn't clear the interrupt pending state. So let's say you had vertical interrupts enabled on the VDP, but masked on the 68K. An interrupt becomes pending, but is not taken because it's' masked on the CPU. You then disable the vertical interrupt on the VDP. Some time later, you unmask the interrupt on the 68K and re-enable the interrupt on the VDP. The interrupt will then fire immediately.

What emulators did you test in?

Re: Enable / Disable vertical interrupts in Mode Register 2

Posted: Fri Nov 04, 2022 10:56 am
by siudym
Thanks, I need to analyze this.

Here is an example in the attachment, the game does not work on a real console, but it works on any emulator. Before loading the gameplay screen of the game, I have to disable VBLANK (update function of collected items on the screen - I turned off VBL "for safety" so that it would not be executed when there are other writes to VRAM in cpu loop), and then I turned on the interrupt again.

I have already corrected the code (disabling VBL IRQ was unnecessary), but I wonder why it works on emulators (fusion, exodus, kgen) and not on the console.

EDIT...
Eh ... I already know what is wrong, instead of writing $ 8114 under mode set register #2 I wrote $ 8120 ... :(

Re: Enable / Disable vertical interrupts in Mode Register 2

Posted: Tue Nov 08, 2022 5:38 am
by Mask of Destiny
siudym wrote:
Fri Nov 04, 2022 10:56 am
I have already corrected the code (disabling VBL IRQ was unnecessary), but I wonder why it works on emulators (fusion, exodus, kgen) and not on the console.

EDIT...
Eh ... I already know what is wrong, instead of writing $ 8114 under mode set register #2 I wrote $ 8120 ... :(
So you inadvertently switched to Mode 4 which not many emulators support since no games actually use it on the Genesis. FWIW, the broken version does correctly fail in my emulator, BlastEm.