Hacking EZ-FLASH Junior TestFlight

Ninoh-FOX

Otaku Gamer!!
Member
Joined
Jan 22, 2015
Messages
535
Trophies
0
Age
44
Location
Military base.
Website
colorslive.com
XP
650
Country
Spain
The last firmware (1.05e that is update in the ezflash web) work fine to my in GBC and GBP with IPS screen in the two consoles, saves works too, you need wait that finish to make the save file (1~3 min) in the first reboot.
 

kerobscure

Well-Known Member
Newcomer
Joined
Oct 28, 2015
Messages
88
Trophies
0
Age
30
XP
534
Country
Here is the FW5 SGB test firmware. use it with the kernel 1.05RC.

This is a test firmware only been tested with a few tester. It may not suit with your equipment. It may brick your card. If you are not sure what is this and its risk, Please wait for the final release.

If you don't own a SGB, you have no need to update this firmware.

Usage:

You still have to enter the kernel by press RESET on card(why this, it is a another looooooooooong story which I have no time to explain). I suppose all of you SGB guys know how to operate it.

Launch the SGB enhanced GB games as normal.

SGB enhanced function which we tested is ok. needs more reports from you guys.

In case of brick, is easy to fix? I want to test it with my SGB, but no to expend again 40$ ^^'
 

DrunkenMonk

Well-Known Member
Member
Joined
Sep 30, 2007
Messages
523
Trophies
1
Age
31
XP
1,751
Country
United Kingdom
In case of brick, is easy to fix? I want to test it with my SGB, but no to expend again 40$ ^^'
Definitely not, when mine hard bricked (bricked during restore update) and stopped even showing Nintendo logo, I had to desolder the chip, wire it up to my universal programmer, dump it and verify, and get a custom made recovery file from ezflash developer to recover it, flash that file and resolder the chip. Don't risk it if you don't have the means to recover
 

RAHelllord

Literally the wurst.
Member
Joined
Jul 1, 2018
Messages
707
Trophies
1
XP
2,731
Country
Germany
Here is the FW5 SGB test firmware. use it with the kernel 1.05RC.

This is a test firmware only been tested with a few tester. It may not suit with your equipment. It may brick your card. If you are not sure what is this and its risk, Please wait for the final release.

If you don't own a SGB, you have no need to update this firmware.

Usage:

You still have to enter the kernel by press RESET on card(why this, it is a another looooooooooong story which I have no time to explain). I suppose all of you SGB guys know how to operate it.

Launch the SGB enhanced GB games as normal.

SGB enhanced function which we tested is ok. needs more reports from you guys.

The SGB enhanced games with borders I have all work fine (Pokemon Yellow, Zelda Link's Awakening DX, Mole Mania, Pocket Bomberman, Kirby's Dreamland 2). They load fine, they play fine, they save fine.

However, apparently games that have custom palettes but no SGB borders like Zelda Link's Awakening, Metroid 2, and Super Mario Land 2: 6 Golden Coins do not have their custom colors enabled, but instead show the default color palette.

Also of note, resetting or turning off the SNES does not allow the EZ-Flash to boot again in the SGB until it has been started in a regular GameBoy. Resetting via the EZ-Flash button works just fine.
In addition to that resetting via EZ-Flash button does keep the border and last colors intact, and possible let them persist into the next started game. I reset Kirby's Dream Land 2 and started Metroid 2, and I could neither jump nor shoot properly, and one sound effect was still able to be heard. Might be something that the SGB doesn't clear properly?
 
D

Deleted User

Guest
A savestate is a file that contains the entire state of the device, so that it can be restored in order to resume gameplay. An emulator can handle this easily, since it controls (and thus knows and can overwrite) the entire state — its own state, really. But a flash cart has to play by the rules of the hardware, and it only has the Game Pak bus to interact with it. Let's break down what this device state entails, and how it could be accessed:

  • ROM, banking state and save data. This is the easiest by far, because the flash cart already controls it.
  • General-purpose RAM (WRAM, HRAM). This (and every item below this) requires running code in the device to access.
  • Display RAM (VRAM, OAM). This has the additional complication of timing restrictions.
  • CPU registers. These are easy to access if you can run code in the device, but hard to preserve, because any attempt at doing so will destroy something else, and attempting to preserve something else first will destroy them.
  • I/O and interrupt registers. These are the hardest part of the state by far. Many of them aren't readable at all (e.g., interrupt master enable). Many of them are completely inaccessible (e.g., internal halves of timers). Most of them can't simply be restored to their old state (e.g., audio registers: writing back the old values would restart the current sound). And some of them can't be restored at all (e.g., serial transfers).

There's a lot of special cases I'm not going over in that last category because just about everything is a special case. But one particular area of complexity is timing: many games (either accidentally or on purpose) rely on the internal synchronization of components, and thus the timing of every component must be identical when the game is resumed as it was when it was stopped. For instance, it would have to be resumed rendering the same exact part of the screen it was rendering when it was stopped.

But none of this matters when you can't get past the first hurdle: getting CPU access. The Game Pak bus is mostly one-way, where the CPU requests an operation (a read or a write) and the cart fulfills it. This is pretty standard: there's no reason for the cart itself to have any control of the system (that's why you put a program in it that gets loaded by the console), and giving the cart control of the device would require an immensely more complex interface. (This is not an "old consoles" thing; modern consoles work the exact same way.) In principle, the game's code could be executing from anywhere — it's perfectly legitimate to write code to RAM and run entirely from there, and if a game does this, the cart would no longer have any control of the code being run. A truly generic solution would meet a complete showstopper here; there is no way around this problem. But since (as far as I know) commercial games don't usually do this, let's imagine a more realistic scenario.

All data from ROM (or SRAM) is delivered to the CPU pretty much in real time. (Technically, one or two cycles in advance, but that doesn't make a difference here.) That means that if the game is executing code from ROM, as games normally do, the cart could just feed the CPU any code it wants to instead of the original. However, it's virtually impossible to determine (externally and in real time) if a given access corresponds to code or data, and feeding the CPU altered data could have disastrous consequences, so this technique can't be used without care. Some instructions are also two or three bytes wide, and these bytes are fetched one at a time, so the cart cannot know in advance whether it's returning the beginning of an instruction or some follow-up byte for it — meaning it can't blindly replace code even after knowing it really is code.

There is some hope, though. Most CPUs have something called interrupts — events that the CPU will detect that will interrupt the current flow of code and cause some special handler code (called an ISR (interrupt service routine), or more commonly an interrupt handler) to run instead. The Game Boy has five of them, and the handlers are at fixed addresses, starting at $0040. All of these addresses are in ROM! If the cart could know that an interrupt handler is about to execute, it could replace the handler's code with its own, and thus gain CPU access.

User programs (I'm not calling them "games" because there's no requirement for a cart to actually contain a game, after all) can choose what interrupts they use, though. And they'll almost never contain interrupt handlers for interrupts they never enable in the first place. If they don't use a particular interrupt, they may use that area of ROM for anything else (and this isn't as uncommon as it would seem), and we would be back to square one. Fortunately, one of the interrupts, the very first one (the VBlank interrupt), is very common.

CRT screens render images by shooting electrons at the screen in a pretty mechanical way: there is an electron beam that moves across the screen and renders each pixel. When it reaches the end of the line, it has to stop rendering pixels while it moves back to the beginning of the next line; this short render pause is known as the horizontal blanking period, or HBlank for short. Likewise, when the beam reaches the end of the screen (typically the bottom right corner), it has to move all the way up to the opposite corner to render the next frame; this significantly longer pause is the vertical blanking period, or VBlank. The Game Boy doesn't have a CRT screen, of course. But while the PPU (the component that does the actual screen rendering) is rendering pixels to the LCD, the CPU cannot access display memory at all; therefore, it needs some rendering pauses so that the CPU can access display memory and thus actually put data there. Nintendo chose to emulate the HBlank/VBlank model, already familiar to developers of CRT-screen-based devices, where these pauses are merely PPU delays so that the CPU will get a chance. VBlank takes up 10% of the time spent in every frame, and thus it is the moment where games will do almost all of their rendering to screen. Since this interval is so important, there is a dedicated interrupt that fires at the beginning of VBlank, letting user programs place their rendering code in the interrupt handler instead of having to manually track each frame's timing. And this interrupt is nearly universally used. So this particular interrupt is the best hope of getting the cart to run its own code on the Game Boy's CPU.

Hooking the VBlank interrupt also has two advantages. One, when an interrupt fires, the return address is pushed to the stack, so the stack must be usable — which makes it easier to be able to preserve CPU registers. And two, the PPU state is known, so there are no frame timing issues. This, of course, is assuming that the VBlank interrupt fires on time (which may not happen; interrupts may be enabled when there's a VBlank interrupt pending), that the handler isn't simply called, and so on. But we're talking about the optimistic scenario here.

So, let's assume we get all the conditions right. The game uses the VBlank interrupt, the interrupt is enabled, and nothing else reads from the handler's address. The user hits the savestate button on the cart (for the sake of the example we'll assume it's a physical button on the cart; using a key combination is much more complex), the cart waits, and a read for address $0040 is requested. The cart starts sending its own code to the CPU (instead of the actual ROM contents at $0040) and the code runs fine. The cart's replacement handler begins by pushing the CPU registers to the stack to save them, and this works just fine: there is enough room on the stack and no useful data is overwritten. So far, this scenario isn't particularly unlikely, so if this works out, we might have a solution that works for many games, if not most.

Except that this was just the first hurdle. The music playing will often rely on timers, which are hard to preserve and restore. RNGs often depend on the divider register, which is another internal timer that is very hard to preserve and restore. Audio registers themselves are mostly unreadable. On-going DMA transfers would be very hard to resume.

And finally, there's the problem of how to trigger a savestate in the first place. I mentioned a hypothetical savestate button on the cart. But these carts don't have a button, and no firmware update will manufacture a button out of nowhere. The only option is to trigger them based on some key combination. But this goes back to the "no access to the CPU" problem, because CPU access is needed to detect key combinations in the first place. There is a joypad interrupt, but this is unreliable in most contexts and rarely used; most games do their own joypad reading using code that could be anywhere in the ROM. Working around this would require per-game patches to even get going. These are on top of the per-game patches that would be needed to solve all of the problems mentioned in the previous paragraph (by restoring the state each game expects). All of these patches would be very custom and would have to be developed independently for every single game that could support the feature.

And if you're going to make complex edits to games to support savestates, why not just edit the games to allow you to save at any time instead without relying on a flash cart?
Thanks
That was a nice read
 

ilchymis7

Active Member
Newcomer
Joined
Sep 25, 2020
Messages
30
Trophies
0
Age
38
XP
71
Country
United States
From that long treatise about savestates, it sounds like its something that would have to be implemented in a new unit. I'm assuming the Everdrive has extra chips and such to accomplish this tricky feat.

Still, very greatful for what this card can do, and how well it seems to do it! Only issue has been the dead battery it came with, which is bizarre, but an easy fix, thankfully!
 

cabbage_

New Member
Newbie
Joined
Sep 3, 2020
Messages
2
Trophies
0
XP
66
Country
Korea, South
Here is the FW5 SGB test firmware. use it with the kernel 1.05RC.

This is a test firmware only been tested with a few tester. It may not suit with your equipment. It may brick your card. If you are not sure what is this and its risk, Please wait for the final release.

If you don't own a SGB, you have no need to update this firmware.

Usage:

You still have to enter the kernel by press RESET on card(why this, it is a another looooooooooong story which I have no time to explain). I suppose all of you SGB guys know how to operate it.

Launch the SGB enhanced GB games as normal.

SGB enhanced function which we tested is ok. needs more reports from you guys.

I just tested Donkey Kong and it seems to work fine with SGB functions (borders, palettes, etc.)

While the game is still playing, pushing cart-button reset 1 time returns to the EZ Flash menu and allows save file update as normal. But all the SGB palettes and border remain visible.

When using the SFC reset button or power on/off, then pushing the cart reset button two times, the BACKUPSAVE menu does not appear. That can cause the save data progress to be lost. Is there is some way to force the EZ Flash to copy the save data from SRAM to SD? An option in the menu for that would be nice..

Edit: And thanks for adding SGB support, EZ Flash team !!
 
Last edited by cabbage_,

DrunkenMonk

Well-Known Member
Member
Joined
Sep 30, 2007
Messages
523
Trophies
1
Age
31
XP
1,751
Country
United Kingdom
@aaaaaa123456789 @EZ-Flash2

After 6 days of correcting my timer on FW5 1.05e release candidate my RTC in the EZFlashjr has deviated exactly 30 seconds. Which follows the 5 second every day that I noticed after the first 24 hours after testing the timer. It seems a little too specific to be exactly 5seconds, so I'm going to try play around with the date and time to see if I can track down where the 5 seconds actually goes... Though honestly 5 seconds each day isn't super monumental in the menu clock, prism still exhibits weirder behaviour when saving. Really wish it would've been simple
 

aaaaaa123456789

Well-Known Member
Newcomer
Joined
Apr 16, 2020
Messages
63
Trophies
0
Age
32
XP
365
Country
Argentina
prism still exhibits weirder behaviour when saving

This is mostly a result of how writes behave, which is definitely very different than how they work on a real RTC. The reason why Prism doesn't work while Crystal mostly does is that Crystal never actually writes to the RTC (except to the day counter).
 

ilchymis7

Active Member
Newcomer
Joined
Sep 25, 2020
Messages
30
Trophies
0
Age
38
XP
71
Country
United States
Anyone know of a way to trade pokemon without a second GBC and cart? Can you meddle with the save filea or something? I have a GBA, but the Omega plays goomba in Advance mode, so I dont think that'll work :/

Can make a new post but I'm using a Junior, so maybe someone knows?
 

aaaaaa123456789

Well-Known Member
Newcomer
Joined
Apr 16, 2020
Messages
63
Trophies
0
Age
32
XP
365
Country
Argentina
Anyone know of a way to trade pokemon without a second GBC and cart? Can you meddle with the save filea or something? I have a GBA, but the Omega plays goomba in Advance mode, so I dont think that'll work :/

Can make a new post but I'm using a Junior, so maybe someone knows?

Messing with savefiles won't trigger a trade, of course! (But you can clearly create any data you want in your savefile.)
 

DrunkenMonk

Well-Known Member
Member
Joined
Sep 30, 2007
Messages
523
Trophies
1
Age
31
XP
1,751
Country
United Kingdom
prism just doesnt work with the RTC, they might still be trying to fix it but i don't think they are anymore.
Yeah it turns out their whole usage of the RTC is wrong and it just happens to work with gold/silver/crystal but it does actually still lose 5 seconds every day, so every 12 days you will lose 1 minute on pokemon gold/silver/crystal too
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: https://youtu.be/MddR6PTmGKg?si=mU2EO5hoE7XXSbSr