* Reduced PROGMEM / DRAM usage slightly (Using defaults w/HW5: Before -> 214,668 bytes / 5,757 bytes; After -> 213,414 bytes / 5,751 bytes)
* Optimized some menu options and calls
* Added more string constants and implemented them where found.
* Fixed some stylization
* Constants should always be uppercase.
* Features should use the `ENABLE_<feature name>` format.
* Options for features should use the `OPTION_<feature name>_<option name>` format.
* Added ENUMs for more clarity and better type checking.
* Moved some defines over to `constexpr` and `const` types. These are preferred over preprocessor constants when not intended for use with `#if` and other preprocessor language.
The `setVoltage()` function should be called even when `ENABLE_VSELECT` is disabled because `ENABLE_3V3FIX` also uses it. There is no resource cost to do this as when both options are disabled the compiler will optimize this function out. This just "future proofs" the code so if that function ever does more it doesn't need updated everywhere. This applies to `setup_FlashVoltage()` as well.
The changes to OSCR.cpp are just for code formatting and additional comments to clarify this.
Also, make print_FatalError(*) independent from print_Error(*).
Also, factorise common parts of print_Error(*).
Frees 2336 bytes of program space and 5 bytes of global ram space.
flashid (almost) always contains the hexadecimal representation of two
bytes, which then means it gets compares with strcmp, which in turn need
another string argument. Instead, make it an integer, removing the need to
call strcmp.
Add a separate string representation for printing purposes (maybe this can be
avoided by having the print function format it when needed ?).
The only apparent case where flashid is not an hexadecimal representation
of a pair of bytes is when N64 clears it to "CONF". Set flashid to zero
this case.
This saves about 500 bytes of program space and 200 bytes of ram.
- LoRom (P0) will write up to 8MB starting from file 0x0 to flashrom 0x0.
- HiRom (P0) will write up to 4MB starting from file 0x0 to flashrom 0x0.
- ExLoRom (P1) will write the first 4MB starting from file 0x0 to flashrom 0x400000. And then a second block up to 4MB from file 0x400000 to flashrom 0x0.
- ExHiRom (P1) will write the first 4MB starting from file 0x0 to flashrom 0x400000. And then a second block up to 4MB from file 0x400000 to flashrom 0x0.
Thanks to skaman.
The code does a deeper sanity check of the header data when initializing the cart. It avoids having to constantly press buttons to reinit the cart. Carts can still not initialize the MBC properly but that's normal for the WonderSwan. Clean the pins on the cart and check that the cart and adapter are seated properly. If the cart doesn't unlock immediately, then let the sketch run for a bit. For stubborn carts, a power cycle might be necessary.
The sketch fixes a few typos, removes some trailing spaces, and adds another ROM size (used by Benesse Pocket Challenge V2 carts).
If you're still using the old 16bit adapter(the one with the additional pins left and right on the snes cart edge) you can enable the menu again by changing one line in Cart_Reader.ino:
// Enable 16bit flash adapter menu
#define enable_flash16
These two new entries just forward the user to the flashrom functions inside of flash.ino.
I have only tested custom-made 29F033 repros using original SHVC-1J3M-20 and SHVC-1A3M-30 PCBs as shown here: https://github.com/sanni/cartreader/wiki/Reflashing-SNES-Repros
Apparently the step-up converter needs a little delay before it can provide the 12V VPP.
The verify function still does not work though, I have no clue why.
The first 10 words still do not get written though, not sure if I need something like a setup delay or if my eprom is broken.
Too enable the eprom menu for testing 27C322 flashing change the following lines in Flash.ino:
// create menu with title and 3 options to choose from
unsigned char flashSlot;
// Copy menuOptions out of progmem
convertPgm(menuOptionsFlash, 3);
flashSlot = question_box("Select flashrom slot", menuOptions, 3, 0);