Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2.0 #7

Merged
merged 19 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ jobs:

- name: Update tests outputs
run: python3 tests/check_correct_sum.py

- name: Test exceptions
run: python3 tests/exception_test.py
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.0] - 2024-01-11

### Added

- `CICKind.get_entrypoint`: Returns the entrypoint address that would be used
on runtime.
- `CICKind.calculate_checksum`: Convinience method that wraps
`checksum::calculate_checksum`.
- Python bindings:
- Expose `Ipl3ChecksumError` to Python as a new exception for each error of
the enum. Refer to `ipl3checksum.exceptions`.

### Changed

- Rewrite the checksum algorithm for readability and simplicity.

## [1.1.1] - 2023-12-23

### Fixed

- Python bindings:
- Fix `detectCIC` and `detect_cic_raw` functions not accepting `bytearray`
objects.
- Fix some typos
- Fix some typos.

## [1.1.0] - 2023-12-22

Expand Down Expand Up @@ -62,6 +78,7 @@ version of the library.
- Initial relase

[unreleased]: https://github.com/Decompollaborate/ipl3checksum/compare/main...develop
[1.2.0]: https://github.com/Decompollaborate/ipl3checksum/compare/1.1.1...1.2.0
[1.1.1]: https://github.com/Decompollaborate/ipl3checksum/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/Decompollaborate/ipl3checksum/compare/1.0.1...1.1.0
[1.0.1]: https://github.com/Decompollaborate/ipl3checksum/compare/1.0.0...1.0.1
Expand Down
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# SPDX-FileCopyrightText: © 2023 Decompollaborate
# SPDX-FileCopyrightText: © 2023-2024 Decompollaborate
# SPDX-License-Identifier: MIT

[package]
name = "ipl3checksum"
# Version should be synced with src/ipl3checksum/__init__.py, pyproject.toml and src/rs/version.rs
version = "1.1.1"
version = "1.2.0"
edition = "2021"
description = "Library to calculate the IPL3 checksum for N64 ROMs"
repository = "https://github.com/decompollaborate/ipl3checksum"
Expand All @@ -17,8 +17,8 @@ crate-type = ["lib", "staticlib", "cdylib"]

[dependencies]
md5 = "0.7.0"
pyo3 = { version="0.20.0", features = ["extension-module"], optional = true }
thiserror = "1.0.51"
pyo3 = { version="0.20.2", features = ["extension-module"], optional = true }
thiserror = "1.0.56"

[features]
c_bindings = []
Expand Down
2 changes: 2 additions & 0 deletions bindings/c/include/ipl3checksum/cickinds.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ uint32_t ipl3checksum_cickind_get_seed(Ipl3Checksum_CICKind self);

uint32_t ipl3checksum_cickind_get_magic(Ipl3Checksum_CICKind self);

uint32_t ipl3checksum_cickind_get_entrypoint(Ipl3Checksum_CICKind self, uint32_t header_entrypoint);

/**
* Returns the md5 hash for the specified CIC kind.
*
Expand Down
2 changes: 1 addition & 1 deletion bindings/c/tests/test_checksum.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-FileCopyrightText: © 2023 Decompollaborate */
/* SPDX-FileCopyrightText: © 2023-2024 Decompollaborate */
/* SPDX-License-Identifier: MIT */

#include "ipl3checksum.h"
Expand Down
2 changes: 1 addition & 1 deletion bindings/c/tests/test_checksum_autodetect.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-FileCopyrightText: © 2023 Decompollaborate */
/* SPDX-FileCopyrightText: © 2023-2024 Decompollaborate */
/* SPDX-License-Identifier: MIT */

#include "ipl3checksum.h"
Expand Down
2 changes: 1 addition & 1 deletion bindings/c/tests/test_detect.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-FileCopyrightText: © 2023 Decompollaborate */
/* SPDX-FileCopyrightText: © 2023-2024 Decompollaborate */
/* SPDX-License-Identifier: MIT */

#include "ipl3checksum.h"
Expand Down
2 changes: 1 addition & 1 deletion bindings/c/tests/utils.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-FileCopyrightText: © 2023 Decompollaborate */
/* SPDX-FileCopyrightText: © 2023-2024 Decompollaborate */
/* SPDX-License-Identifier: MIT */

#include "utils.h"
Expand Down
2 changes: 1 addition & 1 deletion bindings/c/tests/utils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* SPDX-FileCopyrightText: © 2023 Decompollaborate */
/* SPDX-FileCopyrightText: © 2023-2024 Decompollaborate */
/* SPDX-License-Identifier: MIT */

#ifndef TESTS_UTILS_H
Expand Down
29 changes: 23 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
# SPDX-FileCopyrightText: © 2023 Decompollaborate
# SPDX-FileCopyrightText: © 2023-2024 Decompollaborate
# SPDX-License-Identifier: MIT

[project]
name = "ipl3checksum"
# Version should be synced with src/ipl3checksum/__init__.py, Cargo.toml and src/rs/version.rs
version = "1.1.1"
version = "1.2.0"
description = "Library to calculate the IPL3 checksum for N64 ROMs"
readme = "README.md"
requires-python = ">=3.7"
license = {file = "LICENSE"}
keywords = ["IPL3", "CIC", "checksum", "N64", "Nintendo 64"]
authors = [
{ name="Anghelo Carvajal", email="[email protected]" },
]
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Programming Language :: Python :: 3",

"Development Status :: 5 - Production/Stable",

"Intended Audience :: Developers",

"License :: OSI Approved :: MIT License",

"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Operating System :: MacOS",

"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",

"Typing :: Typed",
]

[project.urls]
"Homepage" = "https://github.com/decompollaborate/ipl3checksum"
"Bug Tracker" = "https://github.com/decompollaborate/ipl3checksum/issues"
Repository = "https://github.com/Decompollaborate/ipl3checksum"
Issues = "https://github.com/Decompollaborate/ipl3checksum/issues"
Changelog = "https://github.com/Decompollaborate/ipl3checksum/blob/master/CHANGELOG.md"

[build-system]
requires = ["maturin>=1.2,<2.0"]
Expand Down
4 changes: 2 additions & 2 deletions src/ipl3checksum/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: © 2023 Decompollaborate
# SPDX-FileCopyrightText: © 2023-2024 Decompollaborate
# SPDX-License-Identifier: MIT

from __future__ import annotations

# Version should be synced with pyproject.toml, Cargo.toml and src/rs/version.rs
__version_info__: tuple[int, int, int] = (1, 1, 1)
__version_info__: tuple[int, int, int] = (1, 2, 0)
__version__ = ".".join(map(str, __version_info__))
__author__ = "Decompollaborate"

Expand Down
2 changes: 1 addition & 1 deletion src/ipl3checksum/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: © 2023 Decompollaborate
# SPDX-FileCopyrightText: © 2023-2024 Decompollaborate
# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion src/ipl3checksum/checksum.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: © 2023 Decompollaborate
# SPDX-FileCopyrightText: © 2023-2024 Decompollaborate
# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down
21 changes: 20 additions & 1 deletion src/ipl3checksum/cickinds.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: © 2023 Decompollaborate
# SPDX-FileCopyrightText: © 2023-2024 Decompollaborate
# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand All @@ -20,6 +20,7 @@ class CICKind():
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
"""

Expand All @@ -28,6 +29,13 @@ class CICKind():
Magic value hardcoded inside the IPL3 itself
"""

def getEntrypoint(self, header_entrypoint: int) -> int:
"""
Calculates the actual entrypoint address based on the entrypoint specified on the header.

CIC 7102 is a notable case since its IPL3 hardcodes it, ignoring the entrypoint from the header.
"""

def getHashMd5(self) -> str:
"""
Expected md5 hash of the IPL3 blob
Expand All @@ -52,3 +60,14 @@ class CICKind():
@staticmethod
def fromValue(value: int) -> CICKind|None:
...

def calculateChecksum(self, romBytes: bytes) -> tuple[int, int]:
"""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.

Returns:
tuple[int, int]: If no error happens then the calculated checksum is returned, stored as a tuple
containing two 32-bits words. If an errors occurs an exception will be raised (see ipl3checksum.exceptions).
"""
2 changes: 1 addition & 1 deletion src/ipl3checksum/detect.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: © 2023 Decompollaborate
# SPDX-FileCopyrightText: © 2023-2024 Decompollaborate
# SPDX-License-Identifier: MIT

from __future__ import annotations
Expand Down
Loading
Loading