Undestanding H.KEYI and H.TIMI

By Metalion

Paragon (1215)

Metalion's picture

25-05-2020, 11:49

Hello everyone,

From what I understand from the BIOS, the ISR process @38h is the following :

- push all registers
- call H.KEYI
- read S#0
- if S#0 is positive (bit 7=0) then exit ISR (there's a JP P,xxxx condition branch)
- call H.TIMI
- do the rest of ISR stuff
- ...

Which means that :
- H.KEYI is called before any action is taken
- H.TIMI is called when the VBLANK has been confirmed (S#0 bit 7=1)

BUT ... There's a test of S#0 bit 5 just after H.TIMI to check for a sprite collision. Which would mean that the sprite collision is only tested on VBLANK ? It does not make sense because I thought you could do a screensplit on MSX1 using the interruption generated by a sprite collision.

Questions:
- Is the S#0 bit 7 ("F") only set by VBLANK ?
- Could it be set by another interrupt generated by the VDP (on V9938) ?

I'm trying to make a screensplit work on HBLANK, so I need to know which hook is best suited to read S#1. I read on some books that H.TIMI was the hook to use, but it does not make sense, since it is logically only called at VBLANK ...

Login or register to post comments

By Sandy Brand

Master (197)

Sandy Brand's picture

25-05-2020, 14:52

The VDP has no support for generating interrupts when sprite collisions are detected.

As far as I know the sprite collision detection is only done while drawing the sprites during scanline conversion, and the VDP stores the collision information in register S0.

So the BIOS has to regularly manually 'poll' this information from the VDP in the V-blank interrupt handler.

If you want to do this to 'generate line interrupts manually' you will have to do something similar whereby you need to poll the contents of VDP register S0 constantly to see the C flag (bit 5) go up and then react to it. This is of course very time consuming as you need to do this outside of the normal interrupt handler hooks.

By Metalion

Paragon (1215)

Metalion's picture

25-05-2020, 18:47

Thanks, if the sprite collision is only read by BIOS at VBLANK then it makes sense.

Back to my main question then : what's the best hook to handle a line interrupt on V9938 ?
If the H.TIMI is only called on VBLANK, I'm guessing the only one to handle it is H.KEYI.

By Grauw

Ascended (9391)

Grauw's picture

25-05-2020, 18:49

That’s correct.

By Metalion

Paragon (1215)

Metalion's picture

25-05-2020, 19:03

So I should insert some code like this one at H.KEYI :

	ld	a,1
	vdp	15,a (that's a macro)
	nop
	in	a,(v9938.reg)
	rra
	call	c,split.hblank

Correct ?

By Grauw

Ascended (9391)

Grauw's picture

25-05-2020, 19:15

And change back so s#0 afterwards.

Also the nop is unnecessary. Register access speed is unlimited. Only VRAM access has a speed limit.

By Metalion

Paragon (1215)

Metalion's picture

26-05-2020, 11:39

Thanks, it works.