Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2011-04-24 09:18:44

Miksy91
Member
Registered: 2010-10-16
Post 332/2,311

A bug in Dark Future...

I have somehow succeeded in making my game work so that when codes 0F 19 00, 0F 21 00 or 0F 56 00 are used, the game freezes.
With each of these codes (name rating, move deleting and magikarp contest), the game gives this error report: Unknown opcode fd at c3f9.

I was wondering if anyone knew what's the problem and how I could possibly fix it.

Last edited by Miksy91 (2011-04-24 09:19:29)

Offline

#2 2011-04-24 10:07:31

Sawakita
Administrator
Registered: 2010-10-16
Post 105/364

Re: A bug in Dark Future...

This kind of error usually occurs when some calls/jumps in the code are unconsciously modified in a wrong way, so that the normal code process is changed and it ends for executing pseudo-code read from wrong parts of gameboy's memory map (also from RAM, since bytes can be interpreted both as data and code) until it finds an invalid opcode (= operation code, the binary correspondence to an ASM command); in this case in RAM:C3F9 (as you can notice by the error message), where normally code would never be executed (in fact that RAM location is inside an area that GSC uses as buffer for screen's tile arrangement).

Does any of those scripts (involved in the error) require some pointer? It may be possible that you gave them a wrong pointer.
Otherwise your best bet is to use a debugger to follow the routine starting at the point where those three scripts are processed and find where the root of the problem is.

Offline

#3 2011-04-24 10:24:47

Miksy91
Member
Registered: 2010-10-16
Post 333/2,311

Re: A bug in Dark Future...

Thanks for the help :D
Actually, I figured out how to fix this the "noobish" way.

This far, I've happened to make more than 100 copies of the rom I'm modifying and happened to find out that the error occurs in copy Dark 0.33 but not in Dark 0.32. There was some script change between those two and I tried if I they will turn out the same if I copied that script from version 0.33 to 0.32. Well, mostly but by checking their differences by making a patch file with Lunar IPS (by putting Dark 0.33 (buggy) as un-modified file and Dark 0.32 as new modified file, the patch file turned out to be the size of 37 bytes).

I patched it to the current version of the game and the bug actually disappeared :D
But yeah, it would be good if I learned ASM in case another bugs appear and I'll have hard time fixing them.


By the way, this is what the ips-file looks like.
Does anyone understand this structure and what did the patching do ?

50 41 54 43 48 04 FF FE 00 18 00 00 CD 93 2F AF EA 3E D0 CD 49 34 CD 3F 40 CD 4C 34 CD 46 35 CD 2E 03 45 4F 46

Last edited by Miksy91 (2011-04-24 10:27:54)

Offline

#4 2011-04-24 18:02:03

Cheestendo
Member
Registered: 2011-03-30
Post 48/319

Re: A bug in Dark Future...

Lol, that error always shows up to me when i map with Johtomap , i think the editor bugs up the events/

Offline

#5 2011-04-24 18:53:46

Sawakita
Administrator
Registered: 2010-10-16
Post 106/364

Re: A bug in Dark Future...

Miksy91 wrote:

By the way, this is what the ips-file looks like.
Does anyone understand this structure and what did the patching do ?

50 41 54 43 48 04 FF FE 00 18 00 00 CD 93 2F AF EA 3E D0 CD 49 34 CD 3F 40 CD 4C 34 CD 46 35 CD 2E 03 45 4F 46

If I'm not wrong it should be something like this:

[ 50 41 54 43 48 (= string "PATCH" in ASCII code) ]
[ address (3 bytes, big-endian) ]  [ length of data (2 bytes, big-endian) ]  [ data to patch ]
[ address (3 bytes, big-endian) ]  [ length of data (2 bytes, big-endian) ]  [ data to patch ]
[ address (3 bytes, big-endian) ]  [ length of data (2 bytes, big-endian) ]  [ data to patch ]
...

Offline

#6 2011-04-24 18:58:02

186/700

Re: A bug in Dark Future...

Sawakita wrote:
Miksy91 wrote:

By the way, this is what the ips-file looks like.
Does anyone understand this structure and what did the patching do ?

50 41 54 43 48 04 FF FE 00 18 00 00 CD 93 2F AF EA 3E D0 CD 49 34 CD 3F 40 CD 4C 34 CD 46 35 CD 2E 03 45 4F 46

If I'm not wrong it should be something like this:

[ 50 41 54 43 48 (= string "PATCH" in ASCII code) ]
[ address (3 bytes, big-endian) ]  [ length of data (2 bytes, big-endian) ]  [ data to patch ]
[ address (3 bytes, big-endian) ]  [ length of data (2 bytes, big-endian) ]  [ data to patch ]
[ address (3 bytes, big-endian) ]  [ length of data (2 bytes, big-endian) ]  [ data to patch ]
...

Yes, and the last three bytes of the file are “EOF” in ASCII as well.

#7 2011-04-24 19:50:07

Miksy91
Member
Registered: 2010-10-16
Post 334/2,311

Re: A bug in Dark Future...

Okay so basically, you can't even use ips-files to modify data outside of rom area where a 3-byte pointer couldn't point to ?
Also, "data to patch" doesn't say anything but it's no big deal :)

Offline

#8 2011-04-24 20:17:37

Sawakita
Administrator
Registered: 2010-10-16
Post 107/364

Re: A bug in Dark Future...

Miksy91 wrote:

Okay so basically, you can't even use ips-files to modify data outside of rom area where a 3-byte pointer couldn't point to ?

In fact that's the reason why LunarIPS can't create patches for files that are more than 0xFFFFFF bytes large, I guess. Also, when you say 3-bytes pointer you have not to confuse it with the normal GB/C pointer ([bank, 1 byte][pointer, 2 bytes]), which is a different thing.

Miksy91 wrote:

Also, "data to patch" doesn't say anything but it's no big deal :)

Sorry, my english is often awful; 'data to patch' means "the actual bytes that differ between the two compared files". So, for example in your IPS, it would be:
[ 50 41 54 43 48 ] = 'PATCH' in ASCII
[ 04 FF FE ] = 3-byte address
[ 00 18 ] = length of data
[ 00 00 CD 93 2F AF EA 3E D0 CD 49 34 CD 3F 40 CD 4C 34 CD 46 35 CD 2E 03 ] = actual data to patch
[ 45 4F 46 ] = 'EOF' in ASCII

Offline

#9 2011-04-24 20:24:12

Miksy91
Member
Registered: 2010-10-16
Post 335/2,311

Re: A bug in Dark Future...

Yeah, I confused it alright (great thinking as for example snes pointers are way different but I still use lunar ips to patch to snes roms too)...
It makes sense now though.

Last edited by Miksy91 (2011-04-24 20:25:40)

Offline

#10 2011-04-26 03:49:57

188/700

Re: A bug in Dark Future...

Miksy91 wrote:

Okay so basically, you can't even use ips-files to modify data outside of rom area where a 3-byte pointer couldn't point to ?

Yes, that’s a limitation of the IPS format. Another is that you can’t write data that starts at offset 0x454F46, because it thinks that’s the end of the patch since it’s the same as “EOF” in ASCII.

Out of curiosity, what did those 0x18 bytes starting at offset 0x4FFFE look like in the buggy 0.33 version of your ROM? If we know what they are, we might be able to figure out how they got there. (Or we might not. But it can’t hurt to have a look.) 0x4FFFE seems like a strange location, because it means the data crosses a bank boundary.

#11 2011-04-26 09:30:40

Sawakita
Administrator
Registered: 2010-10-16
Post 108/364

Re: A bug in Dark Future...

IIMarckus wrote:

Out of curiosity, what did those 0x18 bytes starting at offset 0x4FFFE look like in the buggy 0.33 version of your ROM? If we know what they are, we might be able to figure out how they got there. (Or we might not. But it can’t hurt to have a look.) 0x4FFFE seems like a strange location, because it means the data crosses a bank boundary.

My guess is that Miksy may just have cut a couple of 'nop' bytes from the end of bank 0x13 and pasted them 0x18 bytes ahead, thus causing those 0x18 bytes to be shifted back of 2 bytes. Or vice-versa, since the IPS-patch was made using the newer version(v33) as original file and the previous version (v32) as modified file.

Offline

#12 2011-04-29 21:09:22

Miksy91
Member
Registered: 2010-10-16
Post 342/2,311

Re: A bug in Dark Future...

I don't really understand how this happened but somehow bytes "CD CC" were multiplied in offset 0x50016 and the data in bank 0x14 before that offset, was moved backwards.

Pokemon Silver ROM
0x4FFFE
00 00 CD 93 2F AF EA 3E D0 CD 49 34 CD 3F 40 CD 4C 34 CD 46 35 CD 2E 03 CD CC 43...

Buggy Hack ROM
0x4FFFE
CD 93 2F AF EA 3E D0 CD 49 34 CD 3F 40 CD 4C 34 CD 46 35 CD 2E 03 CD CC CD CC 43...

Last edited by Miksy91 (2011-04-29 21:09:54)

Offline

Board footer

Powered by FluxBB