-
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
39aa352
commit acda9bf
Showing
8 changed files
with
92 additions
and
305 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 was deleted.
Oops, something went wrong.
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,36 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-FileCopyrightText: © 2023 Decompollaborate | ||
# SPDX-License-Identifier: MIT | ||
|
||
from __future__ import annotations | ||
|
||
from .cickinds import CICKind | ||
|
||
def calculateChecksum(romBytes: bytes, kind: CICKind) -> tuple[int, int]|None: | ||
"""Calculates the checksum required by an official CIC of a N64 ROM. | ||
Args: | ||
romBytes (bytes): The bytes of the N64 ROM in big endian format. It must have a minimum size of 0x101000 bytes. | ||
kind (CICKind): The CIC kind variation used to calculate the checksum. | ||
Returns: | ||
tuple[int, int]|None: If no error happens then the calculated checksum is returned, stored as a tuple | ||
containing two 32-bits words. Otherwise, `None` is returned. Possible errors: | ||
- `romBytes` not being big enough | ||
""" | ||
|
||
def calculateChecksumAutodetect(romBytes: bytes) -> tuple[int, int]|None: | ||
"""Calculates the checksum required by an official CIC of a N64 ROM. | ||
This function will try to autodetect the CIC kind automatically. If it fails to detect it then it will return `None`. | ||
Args: | ||
romBytes (bytes): The bytes of the N64 ROM in big endian format. It must have a minimum size of 0x101000 bytes. | ||
Returns: | ||
tuple[int, int]|None: If no error happens then the calculated checksum is returned, stored as a tuple | ||
containing two 32-bits words. Otherwise, `None` is returned. Possible errors: | ||
- `romBytes` not being big enough | ||
- Not able to detect the CIC kind | ||
""" |
This file was deleted.
Oops, something went wrong.
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,41 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# SPDX-FileCopyrightText: © 2023 Decompollaborate | ||
# SPDX-License-Identifier: MIT | ||
|
||
from __future__ import annotations | ||
|
||
class CICKind(): | ||
CIC_6101: CICKind | ||
CIC_6102_7101: CICKind | ||
CIC_7102: CICKind | ||
CIC_X103: CICKind # Both 6103 and 7103 | ||
# 6104/7104 does not exist | ||
CIC_X105: CICKind # Both 6105 and 7105 | ||
CIC_X106: CICKind # Both 6106 and 7106 | ||
|
||
|
||
def getSeed(self) -> int: | ||
""" | ||
Seed value set by the PIF ROM before the CPU (and the IPL3) is executed. | ||
https://n64brew.dev/wiki/PIF-NUS#IPL3_checksum_algorithm | ||
""" | ||
|
||
def getMagic(self) -> int: | ||
""" | ||
Magic value hardcoded inside the IPL3 itself | ||
""" | ||
|
||
def getHashMd5(self) -> str: | ||
""" | ||
Expected md5 hash of the IPL3 blob | ||
""" | ||
|
||
@staticmethod | ||
def fromHashMd5(hash_str: str) -> CICKind|None: | ||
... | ||
|
||
@staticmethod | ||
def fromValue(value: int) -> CICKind|None: | ||
... | ||
|
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
Oops, something went wrong.