Bluemsx debugger problem with JR instruction on konami megaroms.

Страница 1/2
| 2

By nikodr

Paladin (750)

Аватар пользователя nikodr

08-10-2007, 23:09

Hello!When i dissasemble konami megaroms and use the built in debugger of bluemsx there is this problem.

Let's assume that i take a konami megarom such as metal gear 1.

There is not way i can understand this area.

Metal gear area from location 4241 to 424f

4241: xor a
4242: ld (#f3db),a
4245: Ei
4246: jr #4246 <--------------------this is the instruction that causes me problems.
4248: di
4249: push af
424a: ld a,#01
424c: jr #4252
424e: di
424f: push af

Now i know that jr makes a jump in a area of 127 bytes forward or backwards.

Whenever i go to this instruction bluemsx step into instruction does not work.What happens is that R register always goes up by one till it is 0 again and so on.I cant make it move to next instruction.It stays to that one forever.If i press continue it goes one well,but if i pause (and i noticed that this instruction is often the one that the debugger stops in konami games),then the same thing.Step into does not work.

I noticed that almost all konami megaroms have a jr instruction in the sense like that

in metal gear 2 for example we have
40e6: xor a
40e7: ld (#f3db),a
40ea: call #013e
40ed: Ei
40ee: Jr #40ee <---problematic instruction that makes the debugger stay where it is
40f0: push af
40f1: ld a,#01
40f3: di
40f4: push hl

in nemesis 3 the same.I noticed that all these megaroms have a jr instruction pointing at the instruction memory location
eg 4040: jr #4040
or 4067: jr #4067 and so on.

What is wrong here?Shouldn't the debugger point me somewhere else?What i am doing wrong?

How is this instruction supposed to work?Making a jr #address where address is the same address as the pc?

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By ARTRAG

Enlighted (6935)

Аватар пользователя ARTRAG

08-10-2007, 23:20

All konami games u pointed are purely and wholly based on INTERRUPTS
this means that the main is just one line like this:

         ei
loop:   jp loop

so if u want to disassemble the game, look for the interrupt routine
Wink

By nikodr

Paladin (750)

Аватар пользователя nikodr

08-10-2007, 23:44

So if i check H.KEYI ($FD9A) and H.TIMI ($FD9F) i find the custom interrupt handler?I did this on #fd9f and found (for metal gear 1) a Jp #41ac.

Is this where the custom interrupt handler of the game is kept?

By Metalion

Paragon (1625)

Аватар пользователя Metalion

09-10-2007, 07:17

So if i check H.KEYI ($FD9A) and H.TIMI ($FD9F) i find the custom interrupt handler?I did this on #fd9f and found (for metal gear 1) a Jp #41ac.

Is this where the custom interrupt handler of the game is kept?

Yes, those hooks are used to store the interrupt handler routine's address.
You should try to disassemble the source starting at $41AC.

BTW, that is an interesting information that you gave here, Artrag.
Does that mean that ALL events in those Konami games are handled only thru the interrupt routine ?
Can you give us more info ?

By ARTRAG

Enlighted (6935)

Аватар пользователя ARTRAG

09-10-2007, 08:49

yes the whole game is in the interrupt routine
I do not have other info as i didn't study personally
the asm of konami games by myself, sorry.

I guess that this is a way to guarantee frame
synchronization independently of the PAL/NTSC issue.

By nikodr

Paladin (750)

Аватар пользователя nikodr

09-10-2007, 13:52

I checked there and found the interrupt handler.And found it for most konami games.

The interrupt handler is done 50 times/sec or 60/sec when it is ntsc?

What is the proper way to dissasemble a konami megarom?How can i find stuff such as vdp handling inside the interrupt?

By the way i found a way to bypas that jr #4246 instruction on location 4246,i place a watchpoint there or i pause the emulator there,then i place a watchpoint at &h0038 that's where it goes next,then i remove the watch point from jr 4246 and continue,it goes to &h0038.

Has anyone from here done a dissasembly of konami megaroms?I think i will go and dissasemble a smaller game like frogger where it is only 8kbytes.It is very easy now to find the interrupt handler,i noticed that in smaller roms it is the same way to find the interrupt.

By nikodr

Paladin (750)

Аватар пользователя nikodr

09-10-2007, 18:03

Is anyone interested to start and make dissasembled listing of konami megaroms?I have made some progress regarding the interrupt handler in these games,and it would be very good for all programers or people wanting to study how these games were made to have a commented listing with everything in it.
Wouldn't it be good?

By yakumo

Expert (75)

Аватар пользователя yakumo

09-10-2007, 19:32

I knew that Konami's game code occurred inside interrupts, but every time think about it my body shivers...

I not only think it is not a good programming style, but also that it is not necessary. But obviously it worked for them 8)

By Metalion

Paragon (1625)

Аватар пользователя Metalion

09-10-2007, 20:49

I not only think it is not a good programming style, but also that it is not necessary. But obviously it worked for them

I totally agree with you CoolCoolCool

By nikodr

Paladin (750)

Аватар пользователя nikodr

12-10-2007, 13:42

I would like to request a new feature for the debbuger of Bluemsx.

Lately i started to dissasemble small konami roms like the video hustler which is 8kbytes.

In order to comment the debugging source and find out how the game is designed i did this.

I placed hundreds (really!) of consecutive watchpoints.So many and i started to remove them so that the game runs and is waiting for me to press space and hit the balls.

If i do this then watchpoints stop the program everywhere (eg has space been pressed ?is game over?Is there sprite collision ?Is highscore ?Has keyboard been used or joystick?)

So slowly with those literraly hundreds of watchpoints i started to have the debbuging source commented.

Problem is that bluemsx does not save the watchpoints when i exit.If i have 500 watchpoints in memory it is very tedious to have to insert them again.And next time i may have some i dont want from the previous one.

So is it possible that in next releases of bluemsx there can be a selection to save those watchpoints that i inserted so i can resume my work without having to insert all of them when i load them back?

By ARTRAG

Enlighted (6935)

Аватар пользователя ARTRAG

12-10-2007, 14:08

Actually another request about watch point is
CONDITIONAL HALT

i.e. insert a watch point that stops the code at that point
ONLY if some register or memory location has a given value

This would help a lot in the debug/development
Add this feature too please!!!!
CryingCryingCryingCryingCryingCryingCrying

Wink

Страница 1/2
| 2