News:

11 March 2016 - Forum Rules

Main Menu

ASM Code in comparison

Started by Romsstar, February 14, 2011, 06:56:44 PM

Previous topic - Next topic

Romsstar

I tried to dissasemble the Digimon World Ogremon Fortress Scene by using the references in the Memory.

Which got me for the NTSC this:

001ba32c: 8f827882 lw r2,0x7882(r28)
001ba330: 40819582 mtc0 r1,gtecr01_r13r21
001ba334: 92828182 lbu r2,-0x7e7e(r20)
001ba338: 40818582 mtc0 r1,cop0cr16_erreg
001ba33c: 8e828182 lw r2,-0x7e7e(r20)
001ba340: 6e824081 illegal
001ba344: 92828782 lbu r2,-0x787e(r20)
001ba348: 8d828582 lw r2,-0x7a7e(r12)
001ba34c: 8e828f82 lw r2,-0x707e(r20)
001ba350: 82824081 lb r2,0x4081(r20)
001ba354: 8e828182 lw r2,-0x7e7e(r20)
001ba358: 89828482 lwl r2,-0x7b7e(r12)
001ba35c: 49819482 illegal
001ba360: 7382000d illegal
001ba364: 89828882 lwl r2,-0x777e(r12)
001ba368: 40819382 mtc0 r1,gtecr01_r13r21
001ba36c: 93828982 lbu r2,-0x767e(r28)
001ba370: 99824081 lwr r2,0x4081(r12)
001ba374: 95828f82 lhu r2,-0x707e(r12)
001ba378: 40819282 mtc0 r1,gtecr01_r13r21
001ba37c: 89828882 lwl r2,-0x777e(r12)
001ba380: 85828482 lh r2,-0x7b7e(r12)
001ba384: 95828f82 lhu r2,-0x707e(r12)
001ba388: 49819482 illegal
001ba38c: 0000000d break 0x00000000
001ba390: 001a051b divu r0,r26
001ba394: 88827682 lwl r2,0x7682(r4)
001ba398: 94828182 lhu r2,-0x7e7e(r4)
001ba39c: 81824081 lb r2,0x4081(r12)
001ba3a0: 85829282 lh r2,-0x6d7e(r12)
001ba3a4: 99824081 lwr r2,0x4081(r12)
001ba3a8: 95828f82 lhu r2,-0x707e(r12)
001ba3ac: 94824081 lhu r2,0x4081(r4)
001ba3b0: 8c828182 lw r2,-0x7e7e(r4)
001ba3b4: 89828b82 lwl r2,-0x747e(r12)
001ba3b8: 87828e82 lh r2,-0x717e(r28)
001ba3bc: 81824081 lb r2,0x4081(r12)
001ba3c0: 8f828282 lw r2,-0x7d7e(r28)
001ba3c4: 94829582 lhu r2,-0x6a7e(r4)
001ba3c8: 000d4881 illegal
001ba3cc: 00560000 sll r0,r22,0x00
001ba3d0: 006707fd illegal
001ba3d4: fd1b000f illegal
001ba3d8: 7882001a illegal
001ba3dc: 95828f82 lhu r2,-0x707e(r12)
001ba3e0: 97824081 lhu r2,0x4081(r28)
001ba3e4: 92828582 lbu r2,-0x7a7e(r20)
001ba3e8: 40818582 mtc0 r1,cop0cr16_erreg
001ba3ec: 95828c82 lhu r2,-0x737e(r12)
001ba3f0: 8b828382 lwl r2,-0x7c7e(r28)
001ba3f4: 40819982 mtc0 r1,gtecr02_r22r23
001ba3f8: 81828c82 lb r2,-0x737e(r12)
001ba3fc: 94829382 lhu r2,-0x6c7e(r4)
001ba400: 94824081 lhu r2,0x4081(r4)
001ba404: 8d828982 lw r2,-0x767e(r12)
001ba408: 49818582 illegal
001ba40c: 6682000d illegal
001ba410: 96828982 lhu r2,-0x767e(r20)
001ba414: 40818582 mtc0 r1,cop0cr16_erreg
001ba418: 90829582 lbu r2,-0x6a7e(r4)
001ba41c: 000d4981 illegal
001ba420: 00560000 sll r0,r22,0x00
001ba424: 001600fd illegal
001ba428: 051b0552 illegal
001ba42c: 7682001a illegal
001ba430: 97828f82 lhu r2,-0x707e(r28)
001ba434: 000d4981 illegal
001ba438: 054e0000 illegal
001ba43c: fbdefe9c illegal
001ba440: 00670001 illegal
001ba444: fd4e0028 illegal
001ba448: faa1fea3 illegal
001ba44c: fc4e0001 illegal
001ba450: f91ffe9d illegal
001ba454: fd4a0001 illegal
001ba458: 004cfc4a illegal
001ba45c: 004c05fd illegal
001ba460: 054e05fc illegal


The VERY SAME scene written for the Pal Version:

0015b1a0: 001afd1b divu r0,r26
0015b1a4: 95826382 lhu r2,0x6382(r12)
0015b1a8: 82824081 lb r2,0x4081(r20)
0015b1ac: 93828982 lbu r2,-0x767e(r28)
0015b1b0: 40819482 mtc0 r1,gtecr01_r13r21
0015b1b4: 89828582 lwl r2,-0x7a7e(r12)
0015b1b8: 40818e82 mtc0 r1,gtecr00_r11r12
0015b1bc: 87826e82 lh r2,0x6e82(r28)
0015b1c0: 85829282 lh r2,-0x6d7e(r12)
0015b1c4: 8f828d82 lw r2,-0x727e(r28)
0015b1c8: 7c818e82 illegal
0015b1cc: 81826182 lb r2,0x6182(r12)
0015b1d0: 84828e82 lh r2,-0x717e(r4)
0015b1d4: 94828982 lhu r2,-0x767e(r4)
0015b1d8: 000d4981 illegal
0015b1dc: 81826382 lb r2,0x6382(r12)
0015b1e0: 40819382 mtc0 r1,gtecr01_r13r21
0015b1e4: 93828982 lbu r2,-0x767e(r28)
0015b1e8: 40819482 mtc0 r1,gtecr01_r13r21
0015b1ec: 95828582 lhu r2,-0x7a7e(r12)
0015b1f0: 92828582 lbu r2,-0x7a7e(r20)
0015b1f4: 75824081 illegal
0015b1f8: 92828582 lbu r2,-0x7a7e(r20)
0015b1fc: 94829382 lhu r2,-0x6c7e(r4)
0015b200: 83828582 lb r2,-0x7a7e(r28)
0015b204: 49818b82 illegal
0015b208: 0000000d break 0x00000000
0015b20c: 001a051b divu r0,r26
0015b210: 81827682 lb r2,0x7682(r12)
0015b214: 40819382 mtc0 r1,gtecr01_r13r21
0015b218: 85829282 lh r2,-0x6d7e(r12)
0015b21c: 85828482 lh r2,-0x7b7e(r12)
0015b220: 94829382 lhu r2,-0x6c7e(r4)
0015b224: 84824081 lh r2,0x4081(r4)
0015b228: 40819582 mtc0 r1,gtecr01_r13r21
0015b22c: 81828482 lb r2,-0x7b7e(r12)
0015b230: 000d4881 illegal
0015b234: 00560000 sll r0,r22,0x00
0015b238: 006707fd illegal
0015b23c: fd1b000f illegal
0015b240: 6b82001a illegal
0015b244: 94828582 lhu r2,-0x7a7e(r4)
0015b248: 94829a82 lhu r2,-0x657e(r4)
0015b24c: 93828582 lbu r2,-0x7a7e(r28)
0015b250: 6c824081 illegal
0015b254: 8c828182 lw r2,-0x7e7e(r4)
0015b258: 88824081 lwl r2,0x4081(r4)
0015b25c: 94828182 lhu r2,-0x7e7e(r4)
0015b260: 85829482 lh r2,-0x6b7e(r12)
0015b264: 94829382 lhu r2,-0x6c7e(r4)
0015b268: 84824081 lh r2,0x4081(r4)
0015b26c: 000d9582 srl r18,r13,0x16
0015b270: 8c826682 lw r2,0x6682(r4)
0015b274: 83825883 lb r2,0x5883(r28)
0015b278: 44818b82 illegal
0015b27c: 64824081 illegal
0015b280: 87829282 lh r2,-0x6d7e(r28)
0015b284: 82828982 lb r2,-0x767e(r20)
0015b288: 84824081 lh r2,0x4081(r4)
0015b28c: 83828982 lb r2,-0x767e(r28)
0015b290: 49818882 illegal
0015b294: 0000000d break 0x00000000
0015b298: 00fd0056 illegal
0015b29c: 051c0016 illegal
0015b2a0: 001a051b divu r0,r26
0015b2a4: 86827482 lh r2,0x7482(r20)
0015b2a8: 49818682 illegal
0015b2ac: 0000000d break 0x00000000
0015b2b0: fe9c054e illegal
0015b2b4: 0001fbde illegal
0015b2b8: 00280067 nor r0,r1,r8
0015b2bc: fea3fd4e illegal
0015b2c0: 0001faa1 addu r31,r0,r1
0015b2c4: fe9dfc4e illegal
0015b2c8: 0001f91f illegal
0015b2cc: fc4afd4a illegal
0015b2d0: 05fd004c illegal
0015b2d4: 05fc004c illegal


Now even for my eyes the programmers seemed to have screwed up at the Pal as we have the famous "Pal Bug".
Now my knowledge to ASM is nearly 0 so if anyone can tell me anything useful that would be really appreciated.

With Best Regads.

RedComet

Quote from: Romsstar on February 14, 2011, 06:56:44 PM
Now even for my eyes the programmers seemed to have screwed up at the Pal as we have the famous "Pal Bug".
Now my knowledge to ASM is nearly 0 so if anyone can tell me anything useful that would be really appreciated.

Devoid of any context of what all those memory addresses are and what the variables are, there's nothing useful you're gonna be able to glean from that.
Twilight Translations - More than just Dragonball Z. :P

Romsstar

This might hold true for me but what might seem like odd adresses and variables might be actually for others something they can read like letters.
Anyways I thought I'd post it and hope that someone could tell me anything helpful.

Ryusui

#3
It's just code. It's useless without context.

Does copying the NTSC version's code into the PAL version fix the bug?

EDIT: Come to think of it, are you sure that is code and not data?
In the event of a firestorm, the salad bar will remain open.

Romsstar

Quote from: Ryusui on February 14, 2011, 07:50:03 PM
It's just code. It's useless without context.

Does copying the NTSC version's code into the PAL version fix the bug?

EDIT: Come to think of it, are you sure that is code and not data?

This is what gave me the dissasembler of PsX.
And I don't know how I'm supposed to cope the code into the Pal Version.
If I replace the Pal Script with NTSC the error is fixed but I don't know how to copy only the particular code part.

I would try if I knew how.

Ryusui

Have you traced through it, perhaps? See what it does?

If the game never actually executes this "code", there's a good chance it's actually data. I'm seeing a lot of "illegal instructions" in there suggesting this might be the case.
In the event of a firestorm, the salad bar will remain open.

Romsstar

Quote from: Ryusui on February 14, 2011, 09:14:52 PM
Have you traced through it, perhaps? See what it does?

If the game never actually executes this "code", there's a good chance it's actually data. I'm seeing a lot of "illegal instructions" in there suggesting this might be the case.

Could you briefly outline how I would do that or link me to a guide?
Also I've read somewhere that "tracing is something you don't do for PSX hacking" that's why this thought never occured to me.
Gemini wrote something similar to that.

RedComet

Quote from: Romsstar on February 14, 2011, 09:38:34 PM
Quote from: Ryusui on February 14, 2011, 09:14:52 PM
Have you traced through it, perhaps? See what it does?

If the game never actually executes this "code", there's a good chance it's actually data. I'm seeing a lot of "illegal instructions" in there suggesting this might be the case.

Could you briefly outline how I would do that or link me to a guide?
Also I've read somewhere that "tracing is something you don't do for PSX hacking" that's why this thought never occured to me.
Gemini wrote something similar to that.

He's said it's not practical.
Twilight Translations - More than just Dragonball Z. :P

esperknight

For PSX tracing you can use any of the ones listed that have tracing here : PSX Utils

I believe I've used Klarths version for when I last did any tracing.  Possibly the reason why it's a bad idea is those files get huge really fast.  I still find it useful though once in a while when I'm in the mood for PSX hacking as I find it easier to sift through a file than on screen sometimes.

For some reason though on Windows 7 I cannot get any of the keyboard/joystick plugins to work.  No idea why... so if you're on Windows 7 good luck.

Romsstar

#9
Quote from: esperknight on February 14, 2011, 10:13:44 PM
For PSX tracing you can use any of the ones listed that have tracing here : PSX Utils

I believe I've used Klarths version for when I last did any tracing.  Possibly the reason why it's a bad idea is those files get huge really fast.  I still find it useful though once in a while when I'm in the mood for PSX hacking as I find it easier to sift through a file than on screen sometimes.

For some reason though on Windows 7 I cannot get any of the keyboard/joystick plugins to work.  No idea why... so if you're on Windows 7 good luck.

The files get WAY too huge. I traced like 2 text boxes and got 1.5 MB. No way I could understand 1.5 MB of ASM code.

Also a question: When I found a line in the memory but can't find in the image itself why would that be the case?

Ryusui

Do you mean a line of ASCII text in memory that isn't being displayed on screen, or an actual dialogue box image that's not being displayed?
In the event of a firestorm, the salad bar will remain open.

messiaen

All I know is MIPS R4300, however I'm 100% sure this is not code, it's data.

esperknight

1.5 MB is nothing :)  I tend to sift through 100 mb files if need be and I remember for the PSX some of them got into the 1.5 to 2gb range.  You're not suppose to understand the whole thing but be able to pinpoint the code you need and isolate it from the rest and understand that enough to figure out what your after.

I'm curious as I'm not finding much on it but what is the Digimon World 1 PAL bug?

And if your talking about why you see a line in memory and why it's not on the ISO, most likely it's compressed or it could be stored differently on the CD (the bytes are reversed on the CD but read in the write way into memory or something.  I recall seeing a game store SJIS backwards on the CD but when reading it into memory it was stored correctly).

Romsstar

Quote from: esperknight on February 16, 2011, 03:03:47 AM
1.5 MB is nothing :)  I tend to sift through 100 mb files if need be and I remember for the PSX some of them got into the 1.5 to 2gb range.  You're not suppose to understand the whole thing but be able to pinpoint the code you need and isolate it from the rest and understand that enough to figure out what your after.

I'm curious as I'm not finding much on it but what is the Digimon World 1 PAL bug?

And if your talking about why you see a line in memory and why it's not on the ISO, most likely it's compressed or it could be stored differently on the CD (the bytes are reversed on the CD but read in the write way into memory or something.  I recall seeing a game store SJIS backwards on the CD but when reading it into memory it was stored correctly).

The Pal Bug is a bug in the European version of the game. When you would talk to a NPC instead of loading his lines and text, nothing happens.
Although the text it is supposed to say is indeed in the script. This bug seems so small but in fact it makes for European players impossible to play the whole game and you end stuck at 65% because of the Bug.

I try to figure out why it is so in the European Version and of course I would love to fix it but it seems that it's out of my skills:(

Things I found out already:

All the Dialogue is stored in one single 788 KB File called DG2.SCN in the PAL Version.
Funny enough in the UK Version the Bug is NOT present which is also on the CD so if you would try to replace DG2.SCN with DG0.SCN actually the bug would be gone.

Now you could take the effort and retranslate the whole game from UK to German but then you run into the issue that the DG0.SCN is of course smaller and so are the pointers (which I haven't figured out yet either). And I believe there must be an easier way to fix only this particular scene than rewriting the whole game script.

And yeah you were right about that esperknight the bytes were indeed reserved. This was true for stats only though. The problem is that a stat like 800 (0320 in hex and reserved 2003) occurs to often in the script to find out WHICH one actually it is.

To test If I was right I just made an "replace all" and indeed the stat is SOMEWHERE in there but how would I find out which one it actually is?

It is load  different in memory than it is on CD.

Because on CD it loads it as initial stats while in game you have current HP, current MP for e.g.
You could try to for the AT/DE stats but again then numbers like 80 or 70 occur way to often...

Anyone an idea? I just think this is a great game and it deserves to be figured out how it works....

Ryusui

If copying DG0.SCN over DG2.SCN fixes the problem, then the issue isn't in the game's code at all. You should be looking at these files and comparing them to one another.
In the event of a firestorm, the salad bar will remain open.

Romsstar

#15
Quote from: Ryusui on February 16, 2011, 07:20:42 AM
If copying DG0.SCN over DG2.SCN fixes the problem, then the issue isn't in the game's code at all. You should be looking at these files and comparing them to one another.

That's what I thought at first.
And believe me I tried but here is the issue:

DG0(UK) has a sice of 784 KB while DG2 (GERMAN) has a sice of 788 either way there is already this difference which I guess results in the fact that in the translating process the translation just takes more space (can't find another reason since they use the same font)

Now while browsing through differences I found 134487 differences. Obviously since one is english and the other is german that bytes are different.lol

Now see, without finding the pointer to that particular scene I can't find out why it is going wrong in the first place.
The Table File helps to differenciate between text and what is believed to be pointers and such but still there are too many differences.
I tried replacing data before and after the scene but the issue seems to be stored somewhere different.

I believe that a reference is just missing because the text is there but the part where text is parsed to NPC (or something l ike that) isn't happening in the PAl Version.

That's why I thought browsing through the code at that scene and finding the differences might help to understand why it's working in NTSC and even UK and not in the PAL.

That was my plan but according to your post I should try a different approach?


Ryusui

Well, yeah, they won't be the same size. I think you'll find the Japanese version of the SCN file will take up much less space, in fact.

Do the files actually contain script pointers? I suspect you'll find that they do, if you look closely. They'll probably be relative to the start of the file, or the address it gets loaded to in memory.

What I'm saying here is this: your first priority should be to work out the pointer block, then use a tool like Cartographer (preferably Cartographer) to extract the script from both. As long as the pointers are in the same order, you'll end up with two script files you can compare pointer-by-pointer. If there's non-text data (i.e. event code) in there, it'll dump that to the files, too. This is a good thing.

Also, I'd like a bit more clarification. You say you figured out a (kludgy) way to fix the PAL bug; does copying DG0.SCN over DG2.SCN fix it, or was it something else?
In the event of a firestorm, the salad bar will remain open.

Romsstar

Quote from: Ryusui on February 16, 2011, 05:23:02 PM
Well, yeah, they won't be the same size. I think you'll find the Japanese version of the SCN file will take up much less space, in fact.

Do the files actually contain script pointers? I suspect you'll find that they do, if you look closely. They'll probably be relative to the start of the file, or the address it gets loaded to in memory.

What I'm saying here is this: your first priority should be to work out the pointer block, then use a tool like Cartographer (preferably Cartographer) to extract the script from both. As long as the pointers are in the same order, you'll end up with two script files you can compare pointer-by-pointer. If there's non-text data (i.e. event code) in there, it'll dump that to the files, too. This is a good thing.

Also, I'd like a bit more clarification. You say you figured out a (kludgy) way to fix the PAL bug; does copying DG0.SCN over DG2.SCN fix it, or was it something else?

I just don't know how to figure out the pointers. Every time I try to set breakpoints in PsX the game just freezes but nothing else happens.
Can you give me a small instruction how I would figure out the pointers? I tried according to a doccumentary here but it didn't work out.

Also: Yeah copying DG0.SCN over DG2.SCN does fix the bug.
Since DG0 is a bit smaller you end up with 4 KB 0s but other than that the game seems to work just fine and also the bug is gone then. So yes.

Ryusui

You shouldn't be worried about the file size so much as the contents.

Now, I'm assuming you've opened the file in a hex editor and can see the text, but there's a lot of stuff mixed in that's not text, right? Those are control codes, event codes and such. They are something completely different from ASM code. The short version is, they should be identical between the English and German versions, except for the messed-up event code responsible for the PAL bug.

There should also be pointers in there. Odds are they're file-relative, and the start or end of the file should be pretty much dedicated to them. A sequence of 32-bit little-endian numbers, I imagine.

Random idea: can you provide me the file and let me have a look? (Does the game use non-ASCII encoding, BTW? 'Cause if it doesn't use ASCII, then I'm gonna need your table, too.)
In the event of a firestorm, the salad bar will remain open.

Romsstar

Here as requested the files and the table.
http://www.sendspace.com/file/l5z4hf

Oh and I see I didn't know that they are completely different from ASM code.
For the pointers as I said I'm pretty sure they must be in there too (If they weren't replacing the file would mess things upp wouldn't it?)
But no clue how to find them.

Thanks in advance.