Skip to content

Commit

Permalink
Add psp platform (#366)
Browse files Browse the repository at this point in the history
* hacky hack

* Add psp platform

* versions stuff

* bleh
  • Loading branch information
AngheloAlf authored Apr 22, 2024
1 parent 6bc689f commit 8935828
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# splat Release Notes

### 0.24.0

* Added PSP as a new platform.
* `spimdisasm` 1.25.0 or above is now required
* `rabbitizer` 1.10.0 or above is now required

### 0.23.2

* Fixed a bug where auto segments insertion may not respect the proper ordering if there are linker_offset segments present.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A binary splitting tool to assist with decompilation and modding projects

Currently, only N64, PSX, and PS2 binaries are supported. More platforms may come in the future.
Currently, only N64, PSX, PS2 and PSP binaries are supported. More platforms may come in the future.

Please check out the [wiki](https://github.com/ethteck/splat/wiki) for more information including [examples](https://github.com/ethteck/splat/wiki/Examples) of projects that use splat.

Expand All @@ -21,12 +21,12 @@ The brackets corresponds to the optional dependencies to install while installin
If you use a `requirements.txt` file in your repository, then you can add this library with the following line:

```txt
splat64[mips]>=0.23.2,<1.0.0
splat64[mips]>=0.24.0,<1.0.0
```

### Optional dependencies

- `mips`: Required when using the N64, PSX or PS2 platforms.
- `mips`: Required when using the N64, PSX, PS2 or PSp platforms.
- `dev`: Installs all the available dependencies groups and other packages for development.

### Gamecube / Wii
Expand Down
1 change: 1 addition & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The target platform for the binary. Options are:
- `n64` (Nintendo 64)
- `psx` (PlayStation 1)
- `ps2` (PlayStation 2)
- `psp` (PlayStation Portable)

#### Usage
```yaml
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "splat64"
# Should be synced with src/splat/__init__.py
version = "0.23.2"
version = "0.24.0"
description = "A binary splitting tool to assist with decompilation and modding projects"
readme = "README.md"
license = {file = "LICENSE"}
Expand All @@ -20,8 +20,8 @@ dependencies = [

[project.optional-dependencies]
mips = [
"spimdisasm>=1.24.2,<2.0.0", # This value should be keep in sync with the version listed on disassembler/spimdisasm_disassembler.py
"rabbitizer>=1.8.0,<2.0.0",
"spimdisasm>=1.25.0,<2.0.0", # This value should be keep in sync with the version listed on disassembler/spimdisasm_disassembler.py
"rabbitizer>=1.10.0,<2.0.0",
"pygfxd",
"n64img>=0.1.4",
"crunch64>=0.2.0,<1.0.0",
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ tqdm
intervaltree
colorama
# This value should be keep in sync with the version listed on disassembler/spimdisasm_disassembler.py and pyproject.toml
spimdisasm>=1.24.2
rabbitizer>=1.8.0
spimdisasm>=1.25.0
rabbitizer>=1.10.0
pygfxd
n64img>=0.1.4
crunch64>=0.2.0
crunch64>=0.2.0
2 changes: 1 addition & 1 deletion src/splat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__package_name__ = __name__

# Should be synced with pyproject.toml
__version__ = "0.23.2"
__version__ = "0.24.0"
__author__ = "ethteck"

from . import util as util
Expand Down
2 changes: 1 addition & 1 deletion src/splat/disassembler/disassembler_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def create_disassembler_instance(skip_version_check: bool, splat_version: str):
global __instance
global __initialized
if options.opts.platform in ["n64", "psx", "ps2"]:
if options.opts.platform in ["n64", "psx", "ps2", "psp"]:
__instance = SpimdisasmDisassembler()
__initialized = True

Expand Down
2 changes: 1 addition & 1 deletion src/splat/disassembler/disassembler_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def make_text_section(


def make_disassembler_section() -> Optional[SpimdisasmDisassemberSection]:
if options.opts.platform in ["n64", "psx", "ps2"]:
if options.opts.platform in ["n64", "psx", "ps2", "psp"]:
return SpimdisasmDisassemberSection()

raise NotImplementedError("No disassembler section for requested platform")
Expand Down
2 changes: 1 addition & 1 deletion src/splat/disassembler/spimdisasm_disassembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class SpimdisasmDisassembler(disassembler.Disassembler):
# This value should be kept in sync with the version listed on requirements.txt and pyproject.toml
SPIMDISASM_MIN = (1, 24, 2)
SPIMDISASM_MIN = (1, 25, 0)

def configure(self):
# Configure spimdisasm
Expand Down
1 change: 1 addition & 0 deletions src/splat/platforms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import n64 as n64
from . import ps2 as ps2
from . import psx as psx
from . import psp as psp
2 changes: 2 additions & 0 deletions src/splat/platforms/psp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def init(target_bytes: bytes):
pass
1 change: 1 addition & 0 deletions src/splat/segtypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from . import n64 as n64
from . import ps2 as ps2
from . import psx as psx
from . import psp as psp
2 changes: 2 additions & 0 deletions src/splat/segtypes/common/codesubsegment.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def __init__(self, *args, **kwargs):
self.instr_category = rabbitizer.InstrCategory.R5900
elif options.opts.platform == "psx":
self.instr_category = rabbitizer.InstrCategory.R3000GTE
elif options.opts.platform == "psp":
self.instr_category = rabbitizer.InstrCategory.R4000ALLEGREX

self.detect_redundant_function_end: Optional[bool] = (
self.yaml.get("detect_redundant_function_end", None)
Expand Down
1 change: 1 addition & 0 deletions src/splat/segtypes/psp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import segment as segment
5 changes: 5 additions & 0 deletions src/splat/segtypes/psp/segment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from ..segment import Segment


class PspSegment(Segment):
pass
4 changes: 2 additions & 2 deletions src/splat/util/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def _parse_yaml(
p = OptParser(yaml)

basename = p.parse_opt("basename", str)
platform = p.parse_opt_within("platform", str, ["n64", "psx", "ps2"])
platform = p.parse_opt_within("platform", str, ["n64", "psx", "ps2", "psp"])
comp = compiler.for_name(p.parse_opt("compiler", str, "IDO"))

base_path = Path(
Expand All @@ -352,7 +352,7 @@ def parse_endianness() -> Literal["big", "little"]:
"endianness",
str,
["big", "little"],
"little" if platform in ["psx", "ps2"] else "big",
"little" if platform in ["psx", "ps2", "psp"] else "big",
)

if endianness == "big":
Expand Down

0 comments on commit 8935828

Please sign in to comment.