Fixing ROMs for EMS 64 GB Smart Card USB

Discussion of programming and development for the original Game Boy and Game Boy Color.
User avatar
MottZilla
Posts: 2832
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Sun Feb 14, 2010 10:10 pm

Well we are talking about a GB/GBC card, not GBA.

tepples
Posts: 21709
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Mon Feb 15, 2010 5:56 am

I guess my post was unclear. I should have added the following: "I am not aware of whether this feature existed on the GBC carts or was new to the GBA carts."

User avatar
MottZilla
Posts: 2832
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Mon Feb 15, 2010 12:18 pm

I see what you mean. Personally I never found such features useful. And with this GB/GBC flash cartridge, trashing the master registers seems to be uncommon but does happen. Thankfully the BGB emulator and the debugger can usually spot the source of these writes so you can make a fix.

Great Hierophant
Posts: 743
Joined: Tue Nov 23, 2004 9:35 pm

Post by Great Hierophant » Mon Feb 15, 2010 11:15 pm

This device was apparently marketed towards the 8-bit portable music crowd; game compatibility was not among the highest concerns. In order to assure that every game worked with the device, you have to play through them all it would seem.

Great Hierophant
Posts: 743
Joined: Tue Nov 23, 2004 9:35 pm

Post by Great Hierophant » Sat Feb 20, 2010 10:29 am

The most compatible flash carts are those that are custom made from a donor cart and replace a game ROM with some kind of rewritable memory.

Apparently there seems to be more issues with carts writing, whether intentionally or not, in areas of the memory map that will crash the flash cart than in a mismatched MBC emulation.

mugenmidget
Posts: 2
Joined: Mon Jan 03, 2011 6:40 pm

Post by mugenmidget » Mon Jan 03, 2011 6:42 pm

Are your IPS patches still available anywhere, Hierophant? The Mediafire link appears to be dead. Thanks in advance and best wishes.

User avatar
MottZilla
Posts: 2832
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Sat Mar 19, 2011 10:31 am

I was notified my fixes were offline, I didn't realize it. I uploaded them to a mirror and they also include some or all of GH's that were available.

mugenmidget
Posts: 2
Joined: Mon Jan 03, 2011 6:40 pm

Post by mugenmidget » Sat Mar 26, 2011 5:47 pm

Awesome! :) Thank you so much, MottZilla.

adam_smasher
Posts: 271
Joined: Sun Mar 27, 2011 10:49 am
Location: Seattle

Post by adam_smasher » Sun Mar 27, 2011 11:45 am

Hi,

I've patched Link's Awakening so that it no longer crashes when saving on an MBC5 (i.e. on these USB carts). Untested on a real GB, but it fixes the crash on emulators, anyway.

DOWNLOAD

Apply to a Link's Awakening 1.0 [!] ROM.

Technical details, for the curious:
The game maintains a "current bank" variable in RAM at $DBAF. At $07C0 is a procedure that writes this variable to $2100, switching the bank. Normally when switching to the first bank, LA is always a good little game and writes $01. However, during the reset procedure that the save routine calls, RAM is zeroed out - including $DBAF, the current bank variable. One of the programmer's thought they were being clever, I'm sure, by not setting it to $01 before switching banks afterwards, relying on the zeroing out and the behaviour of the MBC1. This of course causes a crash when running on an MBC5, which actually switches bank 0 in.

This patch replaces the write in the bank switch procedure with a call to a new procedure at $29A1. This procedure verifies that the bank to be written isn't 0 and adjusts it accordingly if it is. The code is basically the same as that suggested earlier in this thread by tokumaru/Dwedit, although I don't bother pushing/popping A (because the routine at $07C0 does this anyway - 2 bytes saved!). The area at $29A1 appeared to be unused space - hopefully it wasn't anything important.

I realize this probably isn't all that helpful for most people, since the DX version apparently works fine. Mostly a curiosity/practice thing.

User avatar
MottZilla
Posts: 2832
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Sun Mar 27, 2011 7:50 pm

It's always good to have another fix available.

Great Hierophant
Posts: 743
Joined: Tue Nov 23, 2004 9:35 pm

Post by Great Hierophant » Tue Mar 29, 2011 12:40 pm

MottZilla wrote:I was notified my fixes were offline, I didn't realize it. I uploaded them to a mirror and they also include some or all of GH's that were available.


I lost all my fixes, could someone upload mine and MottZilla's?

adam_smasher wrote:Hi,

I've patched Link's Awakening so that it no longer crashes when saving on an MBC5 (i.e. on these USB carts). Untested on a real GB, but it fixes the crash on emulators, anyway.

DOWNLOAD

Apply to a Link's Awakening 1.0 [!] ROM.

Technical details, for the curious:
The game maintains a "current bank" variable in RAM at $DBAF. At $07C0 is a procedure that writes this variable to $2100, switching the bank. Normally when switching to the first bank, LA is always a good little game and writes $01. However, during the reset procedure that the save routine calls, RAM is zeroed out - including $DBAF, the current bank variable. One of the programmer's thought they were being clever, I'm sure, by not setting it to $01 before switching banks afterwards, relying on the zeroing out and the behaviour of the MBC1. This of course causes a crash when running on an MBC5, which actually switches bank 0 in.

This patch replaces the write in the bank switch procedure with a call to a new procedure at $29A1. This procedure verifies that the bank to be written isn't 0 and adjusts it accordingly if it is. The code is basically the same as that suggested earlier in this thread by tokumaru/Dwedit, although I don't bother pushing/popping A (because the routine at $07C0 does this anyway - 2 bytes saved!). The area at $29A1 appeared to be unused space - hopefully it wasn't anything important.

I realize this probably isn't all that helpful for most people, since the DX version apparently works fine. Mostly a curiosity/practice thing.


Awesome, I always wanted to play straight Link's Awakening again on a real DMG.

User avatar
MottZilla
Posts: 2832
Joined: Wed Dec 06, 2006 8:18 pm

Post by MottZilla » Tue Mar 29, 2011 2:20 pm

They are here. h..p://www.megaupload.com/?d=2FV7QTGY

Both of ours though I don't know that they are all there.
Last edited by MottZilla on Sat Feb 18, 2012 2:07 am, edited 3 times in total.

praedo
Posts: 14
Joined: Wed May 04, 2011 1:42 pm

Post by praedo » Wed May 04, 2011 5:41 pm

I tested on real GB and I can confirm it works fine. Thanks a lot, adam_smasher for your good job! :)

Would you be able to do the same for Mario Land 2? Map is garbled, you know. In that case, what are the technical details of the reason why it happens?

Regards,
Josep M.


adam_smasher wrote:Hi,

I've patched Link's Awakening so that it no longer crashes when saving on an MBC5 (i.e. on these USB carts). Untested on a real GB, but it fixes the crash on emulators, anyway.

DOWNLOAD

Apply to a Link's Awakening 1.0 [!] ROM.

Technical details, for the curious:
The game maintains a "current bank" variable in RAM at $DBAF. At $07C0 is a procedure that writes this variable to $2100, switching the bank. Normally when switching to the first bank, LA is always a good little game and writes $01. However, during the reset procedure that the save routine calls, RAM is zeroed out - including $DBAF, the current bank variable. One of the programmer's thought they were being clever, I'm sure, by not setting it to $01 before switching banks afterwards, relying on the zeroing out and the behaviour of the MBC1. This of course causes a crash when running on an MBC5, which actually switches bank 0 in.

This patch replaces the write in the bank switch procedure with a call to a new procedure at $29A1. This procedure verifies that the bank to be written isn't 0 and adjusts it accordingly if it is. The code is basically the same as that suggested earlier in this thread by tokumaru/Dwedit, although I don't bother pushing/popping A (because the routine at $07C0 does this anyway - 2 bytes saved!). The area at $29A1 appeared to be unused space - hopefully it wasn't anything important.

I realize this probably isn't all that helpful for most people, since the DX version apparently works fine. Mostly a curiosity/practice thing.

adam_smasher
Posts: 271
Joined: Sun Mar 27, 2011 10:49 am
Location: Seattle

Post by adam_smasher » Thu May 05, 2011 9:19 am

According to the first post in this thread, the "Bung Fix" solves the garbled map.

Great Hierophant wrote:The Bung Fixes solve the Super Mario Land 2 problem (garbled map screen)


Great Hierophant wrote:...there are three instances where the problem can occur:
1. Game writes to 3000-3FFF to perform a bankswitch
[...]
The Bung Fixes are supposed to address #1


Presuming GH is correct (and I see no reason to believe he isn't), there's the problem. Mario Land 2 apparently writes to $3000-$3FFF to bankswitch (curiously, only when fetching the map screen graphics?), which, according to this document, on a Bung cart will not switch the bank at all, and on an MBC5, like in the EMS carts, will use the lo-bit of the write as the hi-bit of the bank number.

praedo
Posts: 14
Joined: Wed May 04, 2011 1:42 pm

Post by praedo » Thu May 05, 2011 5:43 pm

Thanks for your reply, adam_smasher. I did read the 1st post where you mention "Bung Fixes" but I didn't understand if "fixes" is a verb or not. At first I understood it as a name and I thought there were some bung fixes available somewhere. I search bung gameboy fixes and I didn't find anything. So now with your new post I understand that you meant that Bung fixes (verb) this problem with their carts sold. Unfortunately I don't have any of those (only the GB Smart Card).
Best regards,
Josep M.
Last edited by praedo on Thu May 05, 2011 9:13 pm, edited 1 time in total.

Post Reply