v9990 interrupt handler

Por Metalion

Paragon (1628)

imagem de Metalion

09-05-2022, 21:05

Hi everyone,

Is this interrupt handler correct for the v9990 ?
It would be called on the H_KEYI hook.
IEH and IEV are set up in R#9, and the HBLANK line is specified in R#10 and R#11.

; VBLANK or HBLANK ?
	in	a,(v9990.interrupt)
	bit	0,a
	jp	nz,.vblank
	bit	1,a
	jp	nz,.hblank
	ret

.vblank	push	af
	call	handles_vblank
	pop	af
	out	(v9990.interrupt),a	; resets flag
	ret	

.hblank	push	af
	call	handles_hblank
	pop	af
	out	(v9990.interrupt),a	; resets flag
	ret
Entrar ou registrar-se para comentar

Por Metalion

Paragon (1628)

imagem de Metalion

10-05-2022, 14:44

To answer myself (and for future references), this is a correct v9990 interrupt handler, to be called from H_KEYI:

; VBLANK or HBLANK ?
	in	a,(v9990.interrupt)
	and	3
	out	(v9990.interrupt),a	; resets flags
	rra
	jp	c,handles_vblank
	rra
	jp	c,handles_hblank
	ret

Por PingPong

Enlighted (4156)

imagem de PingPong

10-05-2022, 21:11

what a beautiful device is the v9990. How it's easy, linear and clean to interact with it.
Handle the interrupt with only one register with flags, the out does sw acknowledge without the risk of missing the int as happens with the tms-crappy-vdps descendants.

Por Metalion

Paragon (1628)

imagem de Metalion

11-05-2022, 19:55

Yeah, well, all is not so rosy after all ...

I disabled completely the standard VDP in my code (by writing 0 in R#0 and R#1) before switching to v9990, and as a result, the interruption does not work anymore. Looks like the H_KEYI hook is not called, which does not make any sense.

oO

EDIT: Problem solved. It was just a matter of disabling the H_TIMI hook, which was somehow messing with my interruption, because the S#0 register still contains a value, even if the standard VDP is disabled.

Por Grauw

Ascended (10821)

imagem de Grauw

11-05-2022, 19:57

Indeed, that does not make sense.

https://sourceforge.net/p/msxsyssrc/git/ci/master/tree/base3...

KEYINT:
J0C3C:  PUSH    HL
        PUSH    DE
        PUSH    BC
        PUSH    AF
        EXX
        EX      AF,AF'
        PUSH    HL
        PUSH    DE
        PUSH    BC
        PUSH    AF
        PUSH    IY
        PUSH    IX
	CALL    H.KEYI

Edit: Never mind! :)

Por aoineko

Paragon (1138)

imagem de aoineko

24-09-2022, 15:45

Metalion wrote:

To answer myself (and for future references), this is a correct v9990 interrupt handler, to be called from H_KEYI:

; VBLANK or HBLANK ?
	in	a,(v9990.interrupt)
	and	3
	out	(v9990.interrupt),a	; resets flags
	rra
	jp	c,handles_vblank
	rra
	jp	c,handles_hblank
	ret

Any reason for the and 3?

My use case is a little different since I'm directly replacing the ISR at 0038h (and therefore need to back up the registers), but I have 2 questions:
- I have an EI just before my replacement ISR return for standard VDPs (TMS9918~V9958). I can't find why I added it, but more importantly, if it is present in the ISR for V9990, the interrupt seems to be called repeatedly even if I reset the bits of P#6. Any idea why?
- Also, I think someone had already answered me somewhere, but what is the reason why you can do a RET from an ISR on MSX when the Z80 doc asks to use RETI? Is this still the case with the V9990? (according to my tests, it seems to be the case)

Por aoineko

Paragon (1138)

imagem de aoineko

25-09-2022, 01:07

As usual, I found my answers on Grauw's site. Smile
EI is definitely needed before the return of the ISR (here I had a bug with VDP interruption).
For RET vs RETI it still unclear but RETI should be used because it can notify the device that the interrupt has been handled.

Now v-blank and h-blank interrupt works fine with my custom ISR.

Por bore

Master (182)

imagem de bore

25-09-2022, 02:10

The Z80 doesn't do any different signalling with RETI, it's just that there exists peripheral devices that monitors the bus for when the Z80 fetches the RETI instruction to allow for nested interrupts.
Unless your ISR handles an interrupt from one of the devices that supports RETI you should end it with a regular RET.

Por Metalion

Paragon (1628)

imagem de Metalion

25-09-2022, 20:41

aoineko wrote:

For RET vs RETI it still unclear but RETI should be used because it can notify the device that the interrupt has been handled.

You already asked the question, and you had already an answer here : https://msxvillage.fr/forum/topic-3823-2+interruptions-sur-m...
RETI is not needed.
And if you need proof: the BIOS ISR does not use it.