Welcome Guest [Log In] [Register]
Add Reply
Multi-bug fix patch in Pokémon Diamond; Can load save files, call secret Denjuu, and more!
Topic Started: Feb 23 2011, 05:30 PM (4,576 Views)
Blaziken257
Member Avatar
In severe illness!
No, I'm not making this up. You see, in an attempt to figure out why the game crashes upon calling secret Denjuu, I ended up finding out why it does, and came up with a fix for not only this, but a few other bugs as well (see below). First, here is the patch:

http://www.mediafire.com/?dteh0833hif084z

Now let me explain it. The reason why the bug occurs has to do with the way the bootleg prints English (er... Engrish) text on the D-Shot menu. The bootleggers apparently had a hard time figuring out how the tiles are compressed (something that Malias accomplished single-handedly), so they rewrote the code to print the tiles, using uncompressed tiles, not to mention up to 6 letters instead of 4. This rewritten code and uncompressed tiles are in a different ROM bank from the original code -- in ROM bank 1E (that is, in offsets 0x78000-0x7BFFF), instead of ROM bank 04 (in offsets 0x10000-0x13FFF). (A ROM bank is 0x4000 bytes long, so to find an offset from a ROM bank, just take it and multiply it by 0x4000. ROM banks are loaded into RAM when they are needed to be used.) In the original Japanese version, ROM bank 1E is completely empty and therefore is not used at all.

The way that Diamond handles the D-shot menu is strange. If you look here (Diamond is on the left, Power is on the right), you'll see that the code is completely different. For Diamond, you'll see lots of ld a,1E in the code. This is what eventually causes the crash when calling a secret Denjuu, because it causes the game to switch to ROM bank 1E. The reason why it does that in the first place is because, as explained before, the game needs to in order to print the text. This would normally be OK, but just after calling a secret Denjuu, Diamond goes to this same line of code, switches ROM bank to 1E, but never switches it back to 04, which it needs to do in order to load the D-Shot menu in the first place. Therefore, when it tries to load the menu, it looks in the wrong place.

As you can see here, both games eventually go to RAM address 0x7C0A, but the ROM banks are different. Power/Speed go to ROM bank 04, which corresponds to (0x04-1)*0x4000+0x7C0A, or 0x13C0A, but Diamond goes to ROM bank 1E due to the sloppily rewritten code, which corresponds to (0x1E-1)*0x4000+0x7C0A, or 0x7BC0A. Whoops! In Diamond, it goes through a long sequence of no-ops (that is, instructions that do nothing) until it eventually hits VRAM in RAM offset 0x8000, where it crashes and VBA generates an "unknown opcode" message. Uh-oh!

Since the problematic, sloppily rewritten code is in offsets 0x10000-0x13FFF, I figured that I would try taking this data from Power and replacing the data in Diamond with this. This way, it would use the original code to write text, although it would write gibberish, but if this were to work, you could call secret Denjuu and not have it crash.

Well, guess what... it does work. You can call Musa, Amaranth, and more without fear of crashing. Not only that, but using Power/Speed's original code unexpectedly fixed other bugs too. You can now load a saved game, you can view your items while you have none, and you can create custom tunes. Yep, four of Diamond's glitches are a result of the way it outputs text on the D-Shot menu. Embarrassing.
EDIT (Mar. 18, 2016): Actually, it turns out that some of these glitches appear to be unrelated to one another, and simply exist within the same ROM bank (0x04). The secret Denjuu glitch is definitely related to the rewritten text printing routine, but the save "bug" is not (I need to make another thread explaining this issue sometime). It is unknown if the other glitches (viewing your items when you have none, or creating custom tunes) is related to the text printing routine.

Posted Image

Of course, this patch isn't perfect. Besides the fact that it doesn't fix every bug (the intro still has color palette problems, for example), this one adds a bug. Nearly all the text on the D-Shot menu screen is garbled:

Posted Image

This is a result of using the original Japanese code with Diamond's text strings. Even stranger, when I used Malias's decompression/recompression tools to use the English font, it still had problems. If you can get around that, then you will like this patch.

I'm also curious to see if you can't throw vases here. That would be interesting. I know that there are still some bugs: for example, pressing A+B+Select+Start still causes a crash, and the title screen is still glitched in monochrome. I do not know if the game still crashes after the Game Over screen, but I wouldn't be surprised if it did.

One final thing is that the clock works weird after applying this patch. The clock on the status bar on the map screen is still not in real time (and probably still operates at 50fps), but the one in the D-Shot is separate and does work in real time. I have no explanation for this... but oh well.

This is not meant to replace the English translation in progress, by the way. This is just for people who simply prefer Diamond over the original thing for whatever reason.
Edited by Blaziken257, Mar 18 2016, 06:54 AM.
Offline Profile Quote Post Goto Top
 
andwhyisit
Member Avatar
Telefreak
Bootlegger Boss: I don't care if it has bugs, I don't care if it's a brick, just release it.
Bootlegger Hacker: (Why do I bother anymore?)
Bootlegger Hacker: Here it is.
Bootlegger Boss: Wheee! Money.
Bootleg Cart Company CEO: Wheee! Money.
Person who bought the game: WTF?!
If I say that I am going to do something and I don't get around to it then please remind me.
Offline Profile Quote Post Goto Top
 
RacieB
Member Avatar
very good
Hahaha, shameful. Although, it is nice to have an explanation on why it's so damn breaky! Though now I'm wondering, what did they do in the case of the copies that already have the ability to save? Do those ones not still have the other issues, or are they jimmy-rigged to just save and still crash during secret calls, etc?
Posted Image
Posted Image Avatar by Criminal Crow
Offline Profile Quote Post Goto Top
 
MefistaCenobica
Member Avatar
Long Timer
interesting
how to install it?
Posted Image
Offline Profile Quote Post Goto Top
 
SougonNaTakumi
Member Avatar
Regular
Use an ips patching program like LIPS. They're not too hard to find.
Quote:
 
I mean, can you imagine a Pokémon trainer ever saying "Pampas, I choose you"? XD
Offline Profile Quote Post Goto Top
 
genocidekyuubi
Newbie
Will this patch work for Jade version ?
Offline Profile Quote Post Goto Top
 
andwhyisit
Member Avatar
Telefreak
I would imagine not. This fixes the save bug as well, which isn't present in Jade. In fact I think the secret Denjuu bug is the only issue in Jade.
Edited by andwhyisit, Feb 26 2018, 06:28 PM.
If I say that I am going to do something and I don't get around to it then please remind me.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Telefang - Hacking · Next Topic »
Add Reply