MCPcopy Create free account
hub / github.com/JRickey/BattleShip / cmd_dump

Function cmd_dump

tools/save_editor.py:600–645  ·  view source on GitHub ↗
(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

598# ---------------------------------------------------------------------------
599
600def cmd_dump(args: argparse.Namespace) -> int:
601 path = Path(args.file) if args.file else default_save_path()
602 data = read_save(path)
603 if data is None:
604 print(f"No save file at: {path}")
605 return 1
606 print(f"Save file: {path}")
607 print(f" signature : 0x{data.signature:X} (expected 0x{SIGNATURE:X})")
608 print(f" stored checksum : {data.checksum}")
609 body = data.pack()[:CHECKSUM_OFFSET]
610 expected = compute_checksum(body)
611 print(f" computed checksum: {expected} ({'OK' if expected == data.checksum else 'BAD'})")
612 print(f" boot count : {data.boot}")
613 print(f" unlock_mask : 0x{data.unlock_mask:02X}")
614 for name, bit in UNLOCK_BITS.items():
615 on = "✓" if data.unlock_mask & (1 << bit) else " "
616 print(f" [{on}] {name}")
617 print(f" fighter_mask : 0x{data.fighter_mask:04X}")
618 for i, name in enumerate(FIGHTERS):
619 on = "✓" if data.fighter_mask & (1 << i) else (
620 "·" if name in {"Mario", "Fox", "DonkeyKong", "Samus", "Link",
621 "Yoshi", "Kirby", "Pikachu"} else " ")
622 print(f" [{on}] {name}")
623 print(f" ground_mask : 0x{data.ground_mask:04X}")
624 for i, name in enumerate(STAGES):
625 on = "✓" if data.ground_mask & (1 << i) else " "
626 print(f" [{on}] {name}")
627 print(f" vs_total_battles : {data.vs_total_battles}")
628 print(f" vs_itemswitch : {data.vs_itemswitch_battles}")
629 print(f" spgame_difficulty: {data.spgame_difficulty}")
630 print(f" spgame_stocks : {data.spgame_stock_count}")
631 print(f" sound mode : {'stereo' if data.sound_mono_or_stereo else 'mono'}")
632 print(f" screen flash on : {bool(data.is_allow_screenflash)}")
633 print(f" screen offset : ({data.screen_adjust_h}, {data.screen_adjust_v})")
634 print(f" error_flags : 0x{data.error_flags:02X}")
635 print(f" characters_fkind : {data.characters_fkind} ({FIGHTERS[data.characters_fkind] if data.characters_fkind < NUM_FIGHTERS else '?'})")
636 print()
637 print(" 1P records:")
638 print(f" {'fighter':<14} {'cleared':>7} {'best-diff':>9} {'hiscore':>8} "
639 f"{'BTT(tics)':>9} {'BTT-tasks':>9} {'BTP(tics)':>9} {'BTP-tasks':>9}")
640 for i, r in enumerate(data.spgame_records):
641 print(f" {FIGHTERS[i]:<14} {r.is_spgame_complete:>7} "
642 f"{r.spgame_best_difficulty:>9} {r.spgame_hiscore:>8} "
643 f"{r.bonus1_time:>9} {r.bonus1_task_count:>9} "
644 f"{r.bonus2_time:>9} {r.bonus2_task_count:>9}")
645 return 0
646
647
648def cmd_write(args: argparse.Namespace) -> int:

Callers

nothing calls this directly

Calls 4

default_save_pathFunction · 0.85
read_saveFunction · 0.85
compute_checksumFunction · 0.85
packMethod · 0.45

Tested by

no test coverage detected