Question about interrupts

Page 1/3
| 2 | 3

By DarkSchneider

Paladin (941)

DarkSchneider's picture

05-05-2016, 11:04

Hi, it is time to handle interrupts, and I'd like to know all the options. So I have some questions about them:

1) What could be better, overwrite H.TIMI or simply use the ON INTERVAL GOSUB (FC7FH) on TRAPTBL (FC4CH)?. And how it could be used? I am confused, they are supposed to use 3 bytes, then why the book talks about (3 * 10 bytes) and things like that?

Quote:

TRAPTBL (FC4CH, 78)
contents: trap table used to handle interrupt; one table consists of
three bytes, where first byte indicates ON/OFF/STOP status
and the rest indicate the text address to be jumped to

FC4CH to FC69H (3 * 10 bytes) used in ON KEY GOSUB
FC6AH to FC6CH (3 * 1 byte) used in ON STOP GOSUB
FC6DH to FC6FH (3 * 1 byte) used in ON SPRITE GOSUB
FC70H to FC7EH (3 * 5 bytes) used in ON STRIG GOSUB
FC7FH to FC81H (3 * 1 byte) used in ON INTERVAL GOSUB
FC82H to FC99H for expansion

2) I suppose using the RST 0038h is not recommended at all.

3) Line interrupts: in this case it should be better to use other like H.KEYI (FD9AH)? How can I identify if the interrupt comes from the line interrupt and not others like RS-232? How can I know the line the interrupt was executed, if I have various line interrupts?

4) Could someone talks about non-maskable interrupts?

Thanks.

Login or register to post comments

By Metalion

Paragon (1428)

Metalion's picture

05-05-2016, 11:55

Lots of things here.

First, forget about the TRAPTBL, it's meant for handling of the BASIC pseudo-interrupts.
Then, forget also about NMI interrupts, they're not used on the MSX.

Calling directly RST 38h will do not much, apart from calling the different hooks associated with it.
So it won't help you.

The common solution is to use the hook at H.TIMI, writing there a simple JP xxxx that will transfer the handling to your routine. The call to H.TIMI is actually done from within the RST 38h routine, which is called whenever the VBLANK interrupt is received (every 50th or 60th of a second).

By ricbit

Champion (438)

ricbit's picture

05-05-2016, 17:29

For line interrupts you don't want to use the bios. Switch to ram and write your own handler at 38h. The call to H.KEYI will take precious cycles that may corrupt the raster effect you're looking for.

By DarkSchneider

Paladin (941)

DarkSchneider's picture

05-05-2016, 19:31

ricbit wrote:

For line interrupts you don't want to use the bios. Switch to ram and write your own handler at 38h. The call to H.KEYI will take precious cycles that may corrupt the raster effect you're looking for.

But then the system may crash. Disk handling, peripherals, input updates, also want have both VBLANK and line but overwriting 38h I think, unless I am mistaken, kills all of them.

By ricbit

Champion (438)

ricbit's picture

05-05-2016, 20:23

DarkSchneider wrote:

But then the system may crash. Disk handling, peripherals, input updates, also want have both VBLANK and line but overwriting 38h I think, unless I am mistaken, kills all of them.

After you handle the line interrupt, you can safely return control to bios, to avoid these problems. This trick is just to reduce latency.

By NYYRIKKI

Enlighted (5842)

NYYRIKKI's picture

05-05-2016, 21:11

Well... always the latency is not that important. It is important that you know it exists. If you are not in huge hurry, other quite a common method is to ask line interrupt ~8 lines "too early" and then poll the exact moment you want to do your thing. Yes, it wastes time, but it depends of what you are doing, is that important or not.

Please note also that H.KEYI might be already used ie. by disk stop counter. Standard way of using the hook is to copy 5 bytes from there to end of your routine, so that the previous bytes there will be executed after your code is done. This way all the routines can live happily together.

Here is one video of line interrupts, you might want to take a look.

By Manuel

Ascended (18086)

Manuel's picture

06-05-2016, 00:21

It's so great that you can edit the routine and data while it's running!

By DarkSchneider

Paladin (941)

DarkSchneider's picture

06-05-2016, 09:14

NYYRIKKI wrote:

Well... always the latency is not that important. It is important that you know it exists. If you are not in huge hurry, other quite a common method is to ask line interrupt ~8 lines "too early" and then poll the exact moment you want to do your thing. Yes, it wastes time, but it depends of what you are doing, is that important or not.

Please note also that H.KEYI might be already used ie. by disk stop counter. Standard way of using the hook is to copy 5 bytes from there to end of your routine, so that the previous bytes there will be executed after your code is done. This way all the routines can live happily together.

Here is one video of line interrupts, you might want to take a look.

Good video, it clarifies some things like the S#1 and S#0, good to know. About hook, yes I know that the correct way is to save the old one and call it in your routine. In this way we have a stack of routines, if all did the same.

In my case latency is no very important I think. I want it only to write some VDP registers, to modify scroll, screen mode, and change the sprite and pattern layout base address registers. Need to test but I am sure it will have time.

By Grauw

Ascended (10015)

Grauw's picture

06-05-2016, 16:05

By DarkSchneider

Paladin (941)

DarkSchneider's picture

06-05-2016, 17:24

Yes, I have read it. A question, how could I identify if the interrupt that calls H.KEYI is my line interrupt or is any other one?.

By hit9918

Prophet (2904)

hit9918's picture

06-05-2016, 23:00

look in 9938 manual
vdp has multiple status registers
that get toggeled by some other register
flip to the one of line interrupt and then do the IN 0x99.
then flip back to 0 because so the IN 0x99 of bios goes like expected.

well but the bios hook will make line interrupt endless late.
nicest is to have an IM2 mode server in page 3 0xc000 and no ado with slotflips.
needs a 257 bytes table with all the same bytes, needed for MSXes with dirty databuses.

Page 1/3
| 2 | 3