Do you always use di/ei for VDP access ?

By Metalion

Paragon (1089)

Metalion's picture

06-01-2020, 13:40

Hi everyone,

Do you use di/ei for every case of VDP access ?
It seems to me it can be avoided when it's a port where ISR will not access.

For example, loading the palette colors on the V9938:

	ld	hl,palette
	ld	bc,16*2:9Ah
	xor	a
	di
	out	(99h),a
	ld	a,128+16
	out	(99h),a
	otir
	ei

As we know the ISR will never access the palette port, I'm feeling we can write:

	ld	hl,palette
	ld	bc,16*2:9Ah
	xor	a
	di
	out	(99h),a
	ld	a,128+16
	out	(99h),a
	ei
	otir

And the same goes for the sequential port (9Bh), while sending a VDP command, for example.
What do you think ?

Login or register to post comments

By ARTRAG

Enlighted (6330)

ARTRAG's picture

06-01-2020, 13:51

no, I avoid it in the ISR and every time I can be sure of the timing of the ISR (e.g. after an halt)

By Metalion

Paragon (1089)

Metalion's picture

06-01-2020, 14:06

No, I mean outside the ISR.

By ARTRAG

Enlighted (6330)

ARTRAG's picture

06-01-2020, 14:27

Than after an halt

By Juan Luis

Expert (100)

Juan Luis's picture

06-01-2020, 15:15

But working without di / ei instructions in your code requires a very good knowledge of ISR services. Do you know all VDP port usages of MSX ISR?

By ARTRAG

Enlighted (6330)

ARTRAG's picture

06-01-2020, 15:31

I reset the hooks and often even the bios itself

By Metalion

Paragon (1089)

Metalion's picture

06-01-2020, 15:55

Well, if the hooks are not used, we know for sure that the BIOS ISR will only check VDP for status register during ISR. Therefore, I think we can safely access the other ports (98h,9Ah and 9Bh) without DI/EI.

By NYYRIKKI

Enlighted (5441)

NYYRIKKI's picture

06-01-2020, 17:04

I many times change the DI/EI problem to EI/DI problem. Smile

Naturally it depends of the case, but especially if the interrupt is doing just keyboard scan, some time counting & music playing, it really does not matter even if it comes few ms late.

When I know I'm going to do much VDP stuff, I put DI and do what ever I was planning to do. If the routine takes a lot of time, I may add some EI, [instruction], DI to select where the interrupt may drop, if it needs to.

By Grauw

Ascended (8682)

Grauw's picture

06-01-2020, 17:54

The palette port uses the same internal buffer as register writes, so it must also have di / ei around every pair of writes. This is because the palette entries are 16 bits and the LSB is stored in the temporary buffer until the MSB is written. Also an in a,(99H) resets the buffer afaik so a custom ISR will not help you (only luck will Wink). If you must have the interrupts enabled as much as possible (e.g. because you have line splits), you can do 16x di outi ei outi at the expense of some speed.

This does not apply to indirect register access (port 9BH), they are 8 bit writes and you can do them with interrupts enabled.

By ro

Guardian (4150)

ro's picture

06-01-2020, 18:41

No, I keep ints on in general. Now, on the interrupt routine I make sure to save keep regs. There are times I DI/EI when doing VDP stuff external to interrupt routines. If itsa timing thing (like in demos), almost al critical stuff is ON the interrupt Smile
Or I don't use ints at all. depends.

You'll use DI/EI only to save keep stuff like regs, vdp or other stuff that might also be on int routines.

well, that wasn't helpfull..