papermario/tools/splat/util/gc/gcinfo.py
Ethan Roseman 29c3ffa2e0
Misc decomp 3: Oh baby a triple (#882)
* clean

* git subrepo pull --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "901241040d"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "901241040d"
git-subrepo:
  version:  "0.4.5"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "aa416e4"

* splat update

* more matches after nop hack

* git subrepo pull --force tools/splat

subrepo:
  subdir:   "tools/splat"
  merged:   "715ee0ad55"
upstream:
  origin:   "https://github.com/ethteck/splat.git"
  branch:   "master"
  commit:   "715ee0ad55"
git-subrepo:
  version:  "0.4.5"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "aa416e4"

* Renames, match boot_idle

* one mo

* wips

* fish func

Co-authored-by: @JaThePlayer

* sushie dun

* warnings

* clean

* match a nok func

* nok_02 stuff

* nok_04 party image

* func_802BD5D8_3174F8

* LoadPartyImage & stuff

* warnings
2022-12-11 16:43:29 +09:00

89 lines
2.0 KiB
Python

#! /usr/bin/env python3
import argparse
import hashlib
from pathlib import Path
from typing import Optional
parser = argparse.ArgumentParser(
description="Gives information on GameCube disc images"
)
parser.add_argument("iso", help="path to a GameCube disc image")
system_codes = {
"D": "GameCube Demo",
"G": "GameCube",
"P": "GameCube Promotional",
"R": "Early Wii",
"S": "Later Wii",
}
region_codes = {"E": "NTSC-U", "J": "NTSC-J", "P": "PAL"}
publisher_codes = {"01": "Nintendo", "08": "Capcom", "8P": "Sega", "E9": "Natsume"}
def get_info(iso_path: Path, iso_bytes: Optional[bytes] = None):
if iso_bytes is None:
iso_bytes = iso_path.read_bytes()
return get_info_bytes(iso_bytes)
def get_info_bytes(iso_bytes: bytes):
system_code = chr(iso_bytes[0x00])
game_code = iso_bytes[0x01:0x03].decode("utf-8")
region_code = chr(iso_bytes[0x03])
publisher_code = iso_bytes[0x04:0x06].decode("utf-8")
name = str(iso_bytes[0x20:0x400], "utf-8").strip("\x00")
root = "filesystem"
compiler = "mwcc"
sha1 = hashlib.sha1(iso_bytes).hexdigest()
return GCIso(
name,
root,
system_code,
game_code,
region_code,
publisher_code,
compiler,
sha1,
)
class GCIso:
def __init__(
self,
name: str,
root: str,
system_code,
game_code,
region_code,
publisher_code,
compiler,
sha1,
):
self.name = name
self.root = root
self.system_code = system_code
self.game_code = game_code
self.region_code = region_code
self.publisher_code = publisher_code
self.compiler = compiler
self.sha1 = sha1
def get_system_name(self):
return system_codes[self.system_code]
def get_publisher_name(self):
return publisher_codes[self.publisher_code]
def get_region_name(self):
return region_codes[self.region_code]