DI EI

Página 1/2
| 2

Por norakomi

Paragon (1123)

imagem de norakomi

22-09-2005, 11:42

intterupts !!! bah !!

Ok. at VBLANK int. I allways DI and EI when writing to VRAMregisters.
Now at VBLANK I make all my copies (for the background scroll)

I set the Videoprocessor to work, and the game moves on.
When y=24 is reached there is a pagesplit.

Is it necessary to use DI and EI here as well????

Entrar ou registrar-se para comentar

Por ARTRAG

Enlighted (6843)

imagem de ARTRAG

22-09-2005, 12:20

DI means that the z80 will ignore any interrupt from VDP
EI means that the z80 will jump to 38h when the VDP signals the interrupt

If you are in a interrupt routine at VBLANK and you are sure that your task
will finish before the next VBLANK interrupt, (that is normal otherwise your
system crashes as you get stack overflow), you DO NOT NEED any DI-EI becouse
you are sure that none is going to interrupt your I/O towards the VDP.

Por BiFi

Enlighted (4348)

imagem de BiFi

22-09-2005, 12:50

This is a memorable post... it's my 2525th Tongue

DI means that the z80 will ignore any interrupt from VDP
EI means that the z80 will jump to 38h when the VDP signals the interrupt
correction: DI means the Z80 will ignore any interrupt requests, period. Not just the VDP one(s)... EI means interrupt requests are accepted again. It depends on the Interrupt Mode which address is used to jump to:
IM 0 (not used on MSX): $38
IM 1 (generally on MSX): $38
IM 2 (device dependent): interrupt vector is derived from the I register and some device data

Even though the MSX only uses IM 1, it is of course possible to set IM 0 or IM 2.

Por NYYRIKKI

Enlighted (5918)

imagem de NYYRIKKI

22-09-2005, 13:22

As there can be MIDI interrupts etc. I suggest you to execute DI in start of interrupt handler and EI in the end. This is anyway just to be safe, normally this has no effect.

If you are interested about other interrupt modes, here is pretty weird program, that "records" value from Z80 databus:
http://www.msx.org/forumtopic3816.html

Por ro

Scribe (4698)

imagem de ro

22-09-2005, 18:04

It don't even matter if your routine will exceed the time that's between 2 interrupts. As long as those interrupts are withing 1 screen refresh.
I use that all the time. For example

LNI on 100, do a big VDP copy (will take about 100 lines in screen length)
EI after the copy instruction and do some more stuff I don't care about.

LNIon 140, do more stuff BUT VDP action. (the copy from LNI100 will still be active)

You see, overlapping INTs is no prob. (not really the INTs r overlapping, it's just the huge copy instruction)
just calculate and check. No need to DI and EI. Btw. DI is already done while on BIOS interrupt, so no need to use that one.

EI and DI are only necessary in NON interrupt routines (where ya don't know when another int will come while doing some bizar VDP zapping). Again, check and calculate. I always keep my INTs on as much as possible. But then again, I'm an idiot.

Interrupts.... aaah the sweet topic returns

Por ro

Scribe (4698)

imagem de ro

22-09-2005, 18:07

sometimes I even DO use *real* int overlapping Smile

for example: having some piece of WOLF music (you know those BIG anthems with lotsa channels and stuff) playing on your VBL will suck up some major CPU. Why not EI before starting that replayer? Hell, it's just data.. no VDP shizl. If another INT is present (LNI for example) it just interrupts the previous interrupt (the music replayer) and when it ends, it returns to playing them pieces of muzak. get it? again, check whaz really happening, what is that INT doing and calculate it's length. just fiddle with it dude!

cheerio.

Por brawaga

Resident (55)

imagem de brawaga

07-01-2022, 18:15

Actually, IM0 has no jump address, it just makes Z80 put IORQ and M1 into the active state and execute a command from the databus after that. So since you cannot rely there is FF on databus for IM2 and expect it'll jump on vector at I×256+255, you also can't rely on it for IM0 that RST 38h will be received and expect jumping at all, not saying 38h.

P.S. Necroposting, I know Smile

Por gdx

Enlighted (5482)

imagem de gdx

08-01-2022, 09:05

The mode 0 and 2 requires an external device to works.

NYYRIKKI wrote:

As there can be MIDI interrupts etc. I suggest you to execute DI in start of interrupt handler and EI in the end.

Interrupts are auto-disabled when one occurs so DI is not need, only EI before the end of interrupt handler is necessary. Note that EI is used well before the end in the BIOS and many programs. At last because calls to several BIOS routines re-establishes the interruptions (PSG and VDP routines for example).

BIFI wrote:

IM 1 (generally on MSX): $38

IM 1 is just to set the interrupt mode 1. This mode is always used on MSX and the called address is always $38 because the /NMI pin of the Z80 is connected to the VCC. So there is not non-maskable interrupt on MSX, except maybe on MSX Turbo R with which it seems usable but I do not know how. It seems controlled by the S1990.

PS: I know you know this but I am specifying it for those who are interested.

Por pgimeno

Champion (317)

imagem de pgimeno

10-01-2022, 11:28

gdx wrote:

The mode 0 and 2 requires an external device to works.

This is not quite exact in the case of mode 2. Mode 2 can be (and is) used in MSX regardless of the value of the bus. All you need is a 257-byte buffer aligned to a 256-byte boundary, and an interrupt service routine that starts at an address multiple of 257. You fill the 257-byte buffer with 257 repetitions of the address of the ISR divided by 257 and set the I register to the high byte of this buffer.

For mode 0, I agree, it's not safe to use unless you have guarantees that an external device places a valid instruction on the bus (typically an RST instruction). I guess it's safe-ish to use in MSX because there are no known devices designed to use IM 0 or IM 2, and therefore no one changes the default $FF.

Por Grauw

Ascended (10578)

imagem de Grauw

10-01-2022, 12:44

pgimeno wrote:

For mode 0, I agree, it's not safe to use unless you have guarantees that an external device places a valid instruction on the bus (typically an RST instruction). I guess it's safe-ish to use in MSX because there are no known devices designed to use IM 0 or IM 2, and therefore no one changes the default $FF.

A small further precision: It’s not safe on MSX to use IM0 because FFH is only the “default” if pull-up resistors are present on the data bus, and this is not the case on all MSX machines. Similarly for IM2 you must fill the complete jump table, because although on most machines it will hit the last vector, this is not always the case.

OpenMSX currently does not emulate this yet, so until it is addressed you must test your IM2 ISR on specific real machines to confirm the correct implementation. (It would be nice to have an overview somewhere of whether and in which direction all machines pull the bus.)

Por pgimeno

Champion (317)

imagem de pgimeno

10-01-2022, 23:37

Fair point.

I've made a test program to check the value of the bus during an interrupt, using IM 2. A de Bruijn sequence of order 2 and length 256 requires an alphabet of size 16, so that's what I've used. With some Python-Fu I have sorted and numbered the entries appropriately. There's a lot of wasted space that I didn't figure out how to avoid.

The test program has the following requirements:
- It needs at least 16K RAM.
- It uses addresses up to 0xEDF0, so care needs to be taken that these addresses are not used (disabling one floppy drive might suffice, not sure).
- In a 16K machine, there are only 192 bytes available to BASIC, so there's only room for short commands and no variables or BASIC program.

Run it with:

BLOAD"intbus"
DEFUSR=&HC201
?USR(0)

The last statement prints the value of the bus at interrupt time. Preferably run ?USR(0) several times so that there's no doubt. In OpenMSX it prints 255 as expected.

This zip includes the source, an intbus binary for floppy and an intbus.cas file for cassette.
http://www.formauri.es/personal/pgimeno/temp/intbus.zip

Página 1/2
| 2