.bin games on ezflash 4 and saves?

Discussion in 'GBA - Console and Game Discussions, Help and Tips' started by Aekx, Aug 20, 2010.

  1. Aekx
    OP

    Aekx Member

    Newcomer
    2
    May 28, 2010
    United States
    New Jersey
    im a big fan of roguelikes, but the gba is rather lacking in them apart from powder.
    fortunately, i found some homebrew ports of rogue and hack, but unfortunately they're .bin and im not quite sure what to do with them to make my ezflash 4 write saves and such.
    how do i go about making my ezflash, well, save my saves?
     
  2. kuwanger

    kuwanger GBAtemp Advanced Fan

    Member
    5
    Jul 26, 2006
    Download EZ4-64-2 by cory1492 from this thread to patch any homebrew that uses 64KB of SRAM for saves (ie, most emulators and most homebrew with saves). You'll have to run EZ4-64.exe from the command line, I think (ie, "ez4-64 foo.bin"). The result will be "foo.bin.gba" and "foo.bin.sav". Unfortunately, I don't think EZ4-64 does proper patching of the header checksum. So, you'll need to download gbata7 from no-intro's tools section to fix foo.bin.gba's rom header.

    Or, if you have python installed, you can save this to a file (like ez4_64kb_save.py) and run it to patch the game (ie, "ez4_64kb_save.py foo.bin foo.gba") and you'll have a patched game and save (foo.gba and foo.sav).

    CODE#!/usr/bin/python

    import os, sys, struct
    from sys import argv

    romheader_bin = \
    "\x00\x00\x00\x00\x24\xff\xae\x51\x69\x9a\xa2\x21\x3d\x84\x82\x0a" \
    "\x84\xe4\x09\xad\x11\x24\x8b\x98\xc0\x81\x7f\x21\xa3\x52\xbe\x19" \
    "\x93\x09\xce\x20\x10\x46\x4a\x4a\xf8\x27\x31\xec\x58\xc7\xe8\x33" \
    "\x82\xe3\xce\xbf\x85\xf4\xdf\x94\xce\x4b\x09\xc1\x94\x56\x8a\xc0" \
    "\x13\x72\xa7\xfc\x9f\x84\x4d\x73\xa3\xca\x9a\x61\x58\x97\xa3\x27" \
    "\xfc\x03\x98\x76\x23\x1d\xc7\x61\x03\x04\xae\x56\xbf\x38\x84\x00" \
    "\x40\xa7\x0e\xfd\xff\x52\xfe\x03\x6f\x95\x30\xf1\x97\xfb\xc0\x85" \
    "\x60\xd6\x80\x25\xa9\x63\xbe\x03\x01\x4e\x38\xe2\xf9\xa2\x34\xff" \
    "\xbb\x3e\x03\x44\x78\x00\x90\xcb\x88\x11\x3a\x94\x65\xc0\x7c\x63" \
    "\x87\xf0\x3c\xaf\xd6\x25\xe4\x8b\x38\x0a\xac\x72\x21\xd4\xf8\x07" \
    "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
    "\x00\x00\x96\x00\x80\x00\x00\x00\x00\x00\x00\x00\x00\xd1\x00\x00"

    def readfile(name):
    ÂÂÂÂtry:
    ÂÂÂÂÂÂÂÂfd = open(name, "rb")
    ÂÂÂÂÂÂÂÂcontents = fd.read()
    ÂÂÂÂÂÂÂÂfd.close()
    ÂÂÂÂexcept IOError:
    ÂÂÂÂÂÂÂÂprint "Error reading", name
    ÂÂÂÂÂÂÂÂsys.exit(1)
    ÂÂÂÂreturn contents

    def writefile(name, contents):
    ÂÂÂÂtry:
    ÂÂÂÂÂÂÂÂfd = open(name, "wb")
    ÂÂÂÂÂÂÂÂfd.write(contents)
    ÂÂÂÂÂÂÂÂfd.close()
    ÂÂÂÂexcept IOError:
    ÂÂÂÂÂÂÂÂprint "Error writing", name
    ÂÂÂÂÂÂÂÂsys.exit(1)

    def usage(name):
    ÂÂÂÂprint "Usage: %s input.gba [output.gba]" % name
    ÂÂÂÂsys.exit(0)

    if __name__ == "__main__":

    ÂÂÂÂif len(argv) < 2 or len(argv) > 3:
    ÂÂÂÂÂÂÂÂusage(argv[0])

    ÂÂÂÂinput = argv[1]

    ÂÂÂÂif len(argv) == 3:
    ÂÂÂÂÂÂÂÂoutput = argv[2]
    ÂÂÂÂelse:
    ÂÂÂÂÂÂÂÂoutput = argv[1]

    ÂÂÂÂromfile = readfile(input)

    ÂÂÂÂ#fix romheader
    ÂÂÂÂ#copy nintendo logo in and fixed value 96h and device type
    ÂÂÂÂÂÂÂÂ
    ÂÂÂÂromfile = romfile[0:0x4] + romheader_bin[0x4:0xa0] + romfile[0xa0:0xb2] + "\x96" + romfile[0xb3] + "\x80" + "\x00\x00\x00\x00\x01\x10\x00" + romfile[0xbc:]
    ÂÂÂÂ#compute checksum
    ÂÂÂÂchk = 0
    ÂÂÂÂfor i in range(0xa0, 0xbd):
    ÂÂÂÂÂÂÂÂchk += struct.unpack("B", romfile)[0]
    ÂÂÂÂchk = (0x100 - ((chk + 0x19) & 0xff)) & 0xff
    ÂÂÂÂromfile = romfile[0:0xbd] + struct.pack("B", chk) + romfile[0xbe:]

    ÂÂÂÂwritefile(output, romfile)
    ÂÂÂÂwritefile(os.path.splitext(output)[0] + ".sav", "\xff" * 65536)
     
  3. Aekx
    OP

    Aekx Member

    Newcomer
    2
    May 28, 2010
    United States
    New Jersey
    i dont think im doing it right
    i patch the file correctly(i think), try to run it on my flashcard(agb_rogue gets stuck on the gba logo, and agb_hack still doesnt save), so i try to use the second program, except it wont let me sram patch(the patch button is greyed out)
     
  4. kuwanger

    kuwanger GBAtemp Advanced Fan

    Member
    5
    Jul 26, 2006
    As I said, EZ-64 will turn agb_rogue.bin into agb_rogue.bin.gba (and an agb_rogue.bin.sav). You'll need to then use gbata7 to fix the header of agb_rogue.bin.gba. Doing just one or the other won't work. gbata7's sram patching feature has nothing to do with why you can't save on the ezflash4 and hence why I didn't mention it.
     
  5. Aekx
    OP

    Aekx Member

    Newcomer
    2
    May 28, 2010
    United States
    New Jersey
    works well,i thank you.

    and so does my game boy
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice