FlashGBX 4.3__py3-none-any.whl → 4.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
FlashGBX/FlashGBX.py CHANGED
@@ -135,7 +135,7 @@ def main(portableMode=False):
135
135
  ap_cli2 = parser.add_argument_group('optional command line interface arguments')
136
136
  ap_cli2.add_argument("--dmg-romsize", choices=["auto", "32kb", "64kb", "128kb", "256kb", "512kb", "1mb", "2mb", "4mb", "8mb", "16mb", "32mb", "64mb", "128mb"], type=str.lower, default="auto", help="set size of Game Boy cartridge ROM data")
137
137
  ap_cli2.add_argument("--dmg-mbc", type=str.lower, default="auto", help="set memory bank controller type of Game Boy cartridge")
138
- ap_cli2.add_argument("--dmg-savesize", choices=["auto", "4k", "16k", "64k", "256k", "512k", "1m", "eeprom2k", "eeprom4k", "tama5", "4m"], type=str.lower, default="auto", help="set size of Game Boy cartridge save data")
138
+ ap_cli2.add_argument("--dmg-savetype", choices=["auto", "4k", "16k", "64k", "256k", "512k", "1m", "mbc6", "mbc7_2k", "mbc7_4k", "tama5", "sram4m", "eeprom1m", "photo"], type=str.lower, default="auto", help="set type of Game Boy cartridge save data")
139
139
  ap_cli2.add_argument("--agb-romsize", choices=["auto", "32kb", "64kb", "128kb", "256kb", "512kb", "1mb", "2mb", "4mb", "8mb", "16mb", "32mb", "64mb", "128mb", "256mb", "512mb"], type=str.lower, default="auto", help="set size of Game Boy Advance cartridge ROM data")
140
140
  ap_cli2.add_argument("--agb-savetype", choices=["auto", "eeprom4k", "eeprom64k", "sram256k", "flash512k", "flash1m", "dacs8m", "sram512k", "sram1m"], type=str.lower, default="auto", help="set type of Game Boy Advance cartridge save data")
141
141
  ap_cli2.add_argument("--store-rtc", action="store_true", default=False, help="store RTC register values if supported")
FlashGBX/FlashGBX_CLI.py CHANGED
@@ -371,11 +371,21 @@ class FlashGBX_CLI():
371
371
 
372
372
  elif self.CONN.INFO["last_action"] == 2: # Backup RAM
373
373
  self.CONN.INFO["last_action"] = 0
374
- if not "debug" in self.ARGS and self.CONN.GetMode() == "DMG" and self.CONN.INFO["mapper_raw"] == 252 and self.CONN.INFO["transferred"] == 131072: # Pocket Camera / 128 KiB: # 128 KiB
374
+ if not "debug" in self.ARGS and self.CONN.GetMode() == "DMG" and self.CONN.INFO["mapper_raw"] == 252 and self.CONN.INFO["transferred"] == 0x20000 or (self.CONN.INFO["transferred"] == 0x100000 and self.CONN.INFO["dump_info"]["header"]["ram_size_raw"] == 0x204):
375
375
  answer = input("Would you like to extract Game Boy Camera pictures to “{:s}” now? [Y/n]: ".format(Util.formatPathOS(os.path.abspath(os.path.splitext(self.CONN.INFO["last_path"])[0]), end_sep=True) + "IMG_PC**.{:s}".format(self.ARGS["argparsed"].gbcamera_outfile_format))).strip().lower()
376
376
  if answer != "n":
377
+ if self.CONN.INFO["transferred"] == 0x100000:
378
+ answer = int(input("A Photo! save file was detected. Please select the roll of pictures that you would like to load.\n- 1: Current Save Data\n- 2-8: Flash Directory Slots\nLoad Roll [1-8]: "))
379
+ if answer == 0:
380
+ return
381
+ with open(self.CONN.INFO["last_path"], "rb") as f:
382
+ f.seek(0x20000 * (answer - 1))
383
+ file = bytearray(f.read(0x20000))
384
+ else:
385
+ file = self.CONN.INFO["last_path"]
386
+
377
387
  pc = PocketCamera()
378
- if pc.LoadFile(self.CONN.INFO["last_path"]) != False:
388
+ if pc.LoadFile(file) != False:
379
389
  palettes = [ "grayscale", "dmg", "sgb", "cgb1", "cgb2", "cgb3" ]
380
390
  pc.SetPalette(palettes.index(self.ARGS["argparsed"].gbcamera_palette))
381
391
  file = os.path.splitext(self.CONN.INFO["last_path"])[0] + "/IMG_PC00.png"
@@ -571,12 +581,10 @@ class FlashGBX_CLI():
571
581
  bad_read = True
572
582
 
573
583
  s += "ROM Checksum: "
574
- #Util.AGB_Global_CRC32 = 0
575
584
  db_agb_entry = data["db"]
576
585
  if db_agb_entry != None:
577
586
  if data["rom_size_calc"] < 0x400000:
578
587
  s += "In database (0x{:06X})\n".format(db_agb_entry['rc'])
579
- #Util.AGB_Global_CRC32 = db_agb_entry['rc']
580
588
  s += "ROM Size: {:d} MiB\n".format(int(db_agb_entry['rs']/1024/1024))
581
589
  data['rom_size'] = db_agb_entry['rs']
582
590
  elif data["rom_size"] != 0:
@@ -606,10 +614,6 @@ class FlashGBX_CLI():
606
614
 
607
615
  if data['logo_correct'] and isinstance(db_agb_entry, dict) and "rs" in db_agb_entry and db_agb_entry['rs'] == 0x4000000 and not self.CONN.IsSupported3dMemory():
608
616
  print("{:s}\nWARNING: This cartridge uses a Memory Bank Controller that may not be completely supported yet. A future version of the {:s} device firmware may add support for it.{:s}".format(ANSI.YELLOW, self.CONN.GetFullName(), ANSI.RESET))
609
-
610
- # if "has_rtc" in data and data["has_rtc"] is not True and "no_rtc_reason" in data:
611
- # if data["no_rtc_reason"] == 1:
612
- # print("{:s}NOTE: It seems that this cartridge’s Real Time Clock battery may no longer be functional and needs to be replaced.{:s}".format(ANSI.YELLOW, ANSI.RESET))
613
617
 
614
618
  return (bad_read, s, data)
615
619
 
@@ -903,7 +907,6 @@ class FlashGBX_CLI():
903
907
  elif os.path.getsize(path) < 0x400:
904
908
  print("{:s}ROM files smaller than 1 KiB are not supported.{:s}".format(ANSI.RED, ANSI.RESET))
905
909
  return
906
- #with open(path, "rb") as file: buffer = bytearray(file.read())
907
910
 
908
911
  with open(path, "rb") as file:
909
912
  ext = os.path.splitext(path)[1]
@@ -1032,6 +1035,7 @@ class FlashGBX_CLI():
1032
1035
  def BackupRestoreRAM(self, args, header):
1033
1036
  add_date_time = args.save_filename_add_datetime is True
1034
1037
  rtc = args.store_rtc is True
1038
+ cart_type = 0
1035
1039
 
1036
1040
  path_datetime = ""
1037
1041
  if add_date_time:
@@ -1064,7 +1068,7 @@ class FlashGBX_CLI():
1064
1068
  else:
1065
1069
  mbc = 0x19
1066
1070
 
1067
- if args.dmg_savesize == "auto":
1071
+ if args.dmg_savetype == "auto":
1068
1072
  try:
1069
1073
  if header['mapper_raw'] == 0x06: # MBC2
1070
1074
  save_type = 1
@@ -1074,19 +1078,22 @@ class FlashGBX_CLI():
1074
1078
  save_type = 0x102
1075
1079
  elif header['mapper_raw'] == 0xFD: # TAMA5
1076
1080
  save_type = 0x103
1077
- elif header['mapper_raw'] == 0x20: # TAMA5
1081
+ elif header['mapper_raw'] == 0x20: # MBC6
1078
1082
  save_type = 0x104
1079
1083
  else:
1080
1084
  save_type = header['ram_size_raw']
1081
1085
  except:
1082
- save_type = 0x20000
1086
+ save_type = 0
1083
1087
  else:
1084
- sizes = [ "auto", "4k", "16k", "64k", "256k", "512k", "1m", "eeprom2k", "eeprom4k", "tama5", "4m" ]
1085
- save_type = args.dmg_savesize
1088
+ sizes = [ "auto", "4k", "16k", "64k", "256k", "512k", "1m", "mbc6", "mbc7_2k", "mbc7_4k", "tama5", "sram4m", "eeprom1m", "photo" ]
1089
+ save_type = Util.DMG_Header_RAM_Sizes_Map[sizes.index(args.dmg_savetype)]
1086
1090
 
1087
1091
  if save_type == 0:
1088
- print("{:s}Unable to auto-detect the save size. Please use the “--dmg-savesize” command line switch to manually select it.{:s}".format(ANSI.RED, ANSI.RESET))
1092
+ print("{:s}Unable to auto-detect the save size. Please use the “--dmg-savetype” command line switch to manually select it.{:s}".format(ANSI.RED, ANSI.RESET))
1089
1093
  return
1094
+
1095
+ if save_type == 0x204:
1096
+ cart_type = self.DetectCartridge()
1090
1097
 
1091
1098
  elif self.CONN.GetMode() == "AGB":
1092
1099
  if args.agb_savetype == "auto":
@@ -1185,13 +1192,13 @@ class FlashGBX_CLI():
1185
1192
  self.CONN.TransferData(args={ 'mode':2, 'path':path, 'mbc':mbc, 'save_type':save_type, 'rtc':rtc }, signal=self.PROGRESS.SetProgress)
1186
1193
  elif args.action == "restore-save":
1187
1194
  verify_write = args.no_verify_write is False
1188
- targs = { 'mode':3, 'path':path, 'mbc':mbc, 'save_type':save_type, 'erase':False, 'rtc':rtc, 'verify_write':verify_write }
1195
+ targs = { 'mode':3, 'path':path, 'mbc':mbc, 'save_type':save_type, 'erase':False, 'rtc':rtc, 'verify_write':verify_write, 'cart_type':cart_type }
1189
1196
  if buffer is not None:
1190
1197
  targs["buffer"] = buffer
1191
1198
  targs["path"] = None
1192
1199
  self.CONN.TransferData(args=targs, signal=self.PROGRESS.SetProgress)
1193
1200
  elif args.action == "erase-save":
1194
- self.CONN.TransferData(args={ 'mode':3, 'path':path, 'mbc':mbc, 'save_type':save_type, 'erase':True, 'rtc':rtc }, signal=self.PROGRESS.SetProgress)
1201
+ self.CONN.TransferData(args={ 'mode':3, 'path':path, 'mbc':mbc, 'save_type':save_type, 'erase':True, 'rtc':rtc, 'cart_type':cart_type }, signal=self.PROGRESS.SetProgress)
1195
1202
  elif args.action == "debug-test-save": # debug
1196
1203
  self.ARGS["debug"] = True
1197
1204