-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
874e219
commit 49fd86c
Showing
6 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
|
||
|
||
from . import detect_cic as detect_cic | ||
from . import sum as sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-FileCopyrightText: © 2023 Decompollaborate | ||
# SPDX-License-Identifier: MIT | ||
|
||
from __future__ import annotations | ||
|
||
import argparse | ||
from pathlib import Path | ||
|
||
import ipl3checksum | ||
|
||
def doChecksumize(romBytes: bytes) -> int: | ||
kind = ipl3checksum.detectCIC(romBytes) | ||
|
||
if kind is None: | ||
print(f"Unable to detect CIC kind") | ||
return 1 | ||
|
||
print(f"Detected kind is '{kind.name}'") | ||
|
||
checksum = ipl3checksum.calculateChecksum(romBytes, kind) | ||
if checksum is None: | ||
print(f"Unable to calculate checksum") | ||
return 1 | ||
|
||
chk0, chk1 = checksum | ||
print(f"Calculated checksum: {chk0:08X} {chk1:08X}") | ||
|
||
return 0 | ||
|
||
|
||
def processArguments(args: argparse.Namespace): | ||
romPath: Path = args.rom_path | ||
|
||
romBytes = romPath.read_bytes() | ||
|
||
exit(doChecksumize(romBytes)) | ||
|
||
def addSubparser(subparser: argparse._SubParsersAction[argparse.ArgumentParser]): | ||
parser = subparser.add_parser("sum", help="Calculates the ipl3 checksum of a big endian ROM.") | ||
|
||
parser.add_argument("rom_path", help="Path to a big endian ROM file", type=Path) | ||
|
||
parser.set_defaults(func=processArguments) |