Using interrupts legally inside MSXDOS2 ?

Page 1/3
| 2 | 3

By WORP3

Paladin (864)

WORP3's picture

05-01-2013, 22:04

Is there an official way to reroute/rehook the IRQ to your own program, i will need it to generate a stable timing ?
Or is it only possible by banging my routine on address 38h and jump to the original INT38 routine afterwards Wink ?

Login or register to post comments

By Daemos

Paragon (2044)

Daemos's picture

06-01-2013, 00:16

The ISR is always executed from address $38

You cannot change this address. So you just have to write a small program on that adress and do your thing from there. Remember that when the ISR starts from that adress the interrupts are disabled. If you enable them before you return from this adress expect a major system hang.

You must return from the ISR at some point as the CPU does this jump to $38 as a call.

So yes your method is in a good sense correct Wink

By WORP3

Paladin (864)

WORP3's picture

06-01-2013, 00:28

Yea, i know my way will work but it's not really nice,that's why i'm asking for a proper legal way Wink
Maybe there is some hook in the upper address that can be rerouted, you will never know, the MSX is full of such hooks like solutions Big smile
If there isn't any I must reroute the int38 handler and place my own inside it.
I'm already used to do a lot of illegal stuff on the msx so this shouldn't be a problem, but thanks for the warning on disabling those irq anyway !

By anonymous

incognito ergo sum (116)

anonymous's picture

06-01-2013, 00:38

FD9A
FD9F

By sd_snatcher

Prophet (3642)

sd_snatcher's picture

06-01-2013, 03:55

@WORP3

The hook HKEYI (FD9Ah) is called on every interrupt received by the processor.

The hook HTIMI (FD9Fh) is also called when the interrupt is a VBLANK one.

By Huey

Prophet (2694)

Huey's picture

06-01-2013, 08:38

The hooks are the best way.

P.S. IIRC page0 $0100-$3fff is 'paged out' during the ISR. So don't place code or data that you need during ISR in page0 if you need them on your hook.

By WORP3

Paladin (864)

WORP3's picture

06-01-2013, 19:44

@GuyveR800 & sd_snatcher: Neat, they kept those two hooks inside the MSX-DOS, or probably it's still the MSX bios handling those both hooks but nevertheless they are still available Wink

@Huey: I guess that because it's the bios that is handling those hooks ?
But it could be a problem as I want to use those hooks I now need to program some routine in the first or second page and keep an eye on it when my base program is getting larger Sad
It's almost easier to just reroute the INT handler on address 38h, at least this way I don't need to switch some additional banks to get it working.

By WORP3

Paladin (864)

WORP3's picture

06-01-2013, 22:14

I did a quick disasm, just to see what's on the IRQ address 38h, the only instruction there is a jump to address F1E5h

0x0038-0xC3-JP 0xF1E5
0x0039-0xE5-E5
0x003A-0xF1-F1

Searching for that address only popped up the following info:

F1E5 Jumps to interrupt handler (only when processing BDOS functions)

By Edwin

Paragon (1182)

Edwin's picture

06-01-2013, 22:27

It's the handler DOS puts there. It needs to put BIOS back in its place to start the real handler. And restore it afterwards.

By ARTRAG

Enlighted (6923)

ARTRAG's picture

06-01-2013, 22:30

If you follow the interrupt under msxdos using a debugger (e.g. bluemsx debugger) you will see that the hooks are called by the ROM BIOS in page 0 (0x0000-0x3FFF) after that the RAM page has been swapped away.

By WORP3

Paladin (864)

WORP3's picture

07-01-2013, 14:00

Does anyone of you know if the ram bank settings are changed when one of both hooks are called and the bios is in page 0 ?
In other words, would it be sufficient to only reprogram the page settings ?

-So read and store I/O register A8h and Address FFFFh while starting my .com program
-Place some code just below address 8000h (in page 1) and set the FD9Fh hook to this routine.
-When a HTIMI call comes in, just store current A8h and FFFFh settings (with bios in page 0) and replace it with the stored one (without bios in page 0).
-Call my own IRQ handler.
-After exiting my IRQ handler, replace the A8h and FFFFh settings and return the hook.

It's almost easier to just wait for the next vertical retrace inside the main loop Tongue

Page 1/3
| 2 | 3