Use of interrupt handlers in konami games

ページ 1/2
| 2

By nikodr

Paladin (748)

nikodr さんの画像

12-08-2007, 14:59

Can somebody point me to articles regarding the use of interrup handlers on konami megarom games?

I am just dissasembling the roms of those games and i would really like to learn more about the use of interrupt handlers

What i know is that z80 works in im1.There is a bios routine at 38h.From what i read in the msx reference manual that has a disassembly of the bios,It reads the vdp status,scans and read the keyboard,psg handling and music and etc.

Now i have a question regarding the use in those games.I suppose they reject the default 38h call with a custom one,and maybe put the status of z80 from im1 to im2 ?Isn't im2 the only way to have your custom interrupt handler to any memory address the programer wants?

Did konami ever used im2 in their games?Or they do something else?

ログイン/登録して投稿

By Edwin

Paragon (1182)

Edwin さんの画像

12-08-2007, 15:31

They don't install a custom handler because most roms are expected to run with 16KB RAM. Which means there is no ram at $38 to install a custom handler. IM 2 would be possible, but cumbersome since it needs a 257 byte jump table to get it to work. Which I don't think they ever did.

I think they use regular hooks. Nothing fancy. But it should be trivial to check.

By PingPong

Prophet (4093)

PingPong さんの画像

12-08-2007, 15:49

What is the advantage of having a IM2 mode on msx? There is no byte supplied on the databus at interrupt time.
So what is the gain?

In my work i also replace the 38h but in a more brutally way... simply i turn on ram at 38h and write my custom routine, bypassing at all all bios managements.

By Sonic_aka_T

Enlighted (4130)

Sonic_aka_T さんの画像

12-08-2007, 16:34

That is brutal! I usually disable interrupts first! Tongue

By AuroraMSX

Paragon (1902)

AuroraMSX さんの画像

12-08-2007, 17:12

Now i have a question regarding the use in those games.I suppose they reject the default 38h call with a custom one,and maybe put the status of z80 from im1 to im2 ?Nothing like that.
The MSX standard defines the so-called hook mechanism for this. The standard BIOS routines, including the interrupt handler, call a hook at a designated address somewhere in the top memory area ($F380 - $FFFE), before (or during) their normal operation. Such a hook is a 5 byte sized area, usually filled with RETs. Now, if a developer wants to change or extend the default behaviour of a BIOS routine, he just needs to put a CALL or JP to his own routine in place of the hook. The BIOS routine calls the hook, the hook jumps or calls the custom routine.

For the interrupt handler, two hooks are defined: H.KEYI ($FD9A) and H.TIMI ($FD9F). H.KEYI is called on every interrupt, H.TIMI on the VBLANK interrupt of the VDP.

So, if you want to do something on the VDP VBLANK interrupt, your code could look like this:

start:
    ; first save the old hook
    ld      hl.$FD9F
    ld      de,oldhk
    ld      bc,5
    ldir

    ; now set the new hook
    di
    ld      hl,newhk
    ld      de,$FD9F
    ld      bc,5
    ldir
    ei

; -- spectacular main loop
loop:
    jr      loop

newhk:
    jp      myinthdlr
    ret     ; 2x ret to fill up 5 bytes
    ret

; -- here your custom int handler
;    I have to admit that this one is not very inspiring :-)
myinthdlr:
    nop

; -- programming etiquett dictates that you execute
;    the old hook after doing your own custom stuff
oldhk:
    ret
    ret
    ret
    ret
    ret

[edit] Oh, and don't forget to restore the old hook when your program finishes... [/edit]

By PingPong

Prophet (4093)

PingPong さんの画像

12-08-2007, 19:45

That is brutal! I usually disable interrupts first! Tongue

Yes, also i disable (and save the needed info) interrupts.

Anyway, i could not see any advantage in working in im2 or im0????

By Sonic_aka_T

Enlighted (4130)

Sonic_aka_T さんの画像

12-08-2007, 20:52

Anyway, i could not see any advantage in working in im2 or im0????Indeed, IM2 is quite useless on MSX... It's a real pity, had 'they' fully implemented this system it could've meant very easy (and fast) reaction to hardware interrupts...

By Manuel

Ascended (19270)

Manuel さんの画像

12-08-2007, 21:17

Note that IM2 is used in the Yamaha SFG-05 software.

By Edwin

Paragon (1182)

Edwin さんの画像

12-08-2007, 22:52

There is some practical use for IM2 when you want to install your own handler on a machine with less than 64KB of ram. Or desperately need BIOS visible in page 0. And then you'd only need it in cases where you desperately need fast reaction time on interrupts. Otherwise the hooks should be plenty.

By Vincent van Dam

Hero (513)

Vincent van Dam さんの画像

26-08-2007, 21:39

Though in both cases you can hook to fd9a and read the vdp status register; than you have a low footprint int handler too, it will skip the fd9f hook and will just do some pushes on the stack, and another read of the vdp status register (iirc); konami did this too with their msx1 games (again iirc).

By Edwin

Paragon (1182)

Edwin さんの画像

26-08-2007, 21:58

Low, but not always low enough. Especially when you're trying to be line accurate on both z80 and r800.

ページ 1/2
| 2