amiga-re-kit 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. amiga_re_kit-0.2.0/LICENSE +21 -0
  2. amiga_re_kit-0.2.0/PKG-INFO +163 -0
  3. amiga_re_kit-0.2.0/README.md +135 -0
  4. amiga_re_kit-0.2.0/THIRD-PARTY.md +26 -0
  5. amiga_re_kit-0.2.0/pyproject.toml +44 -0
  6. amiga_re_kit-0.2.0/setup.cfg +4 -0
  7. amiga_re_kit-0.2.0/src/amiga_re_kit.egg-info/PKG-INFO +163 -0
  8. amiga_re_kit-0.2.0/src/amiga_re_kit.egg-info/SOURCES.txt +46 -0
  9. amiga_re_kit-0.2.0/src/amiga_re_kit.egg-info/dependency_links.txt +1 -0
  10. amiga_re_kit-0.2.0/src/amiga_re_kit.egg-info/entry_points.txt +3 -0
  11. amiga_re_kit-0.2.0/src/amiga_re_kit.egg-info/requires.txt +11 -0
  12. amiga_re_kit-0.2.0/src/amiga_re_kit.egg-info/top_level.txt +1 -0
  13. amiga_re_kit-0.2.0/src/arek/__init__.py +25 -0
  14. amiga_re_kit-0.2.0/src/arek/adf.py +165 -0
  15. amiga_re_kit-0.2.0/src/arek/amigados.py +359 -0
  16. amiga_re_kit-0.2.0/src/arek/cli.py +440 -0
  17. amiga_re_kit-0.2.0/src/arek/contract.py +83 -0
  18. amiga_re_kit-0.2.0/src/arek/copper.py +80 -0
  19. amiga_re_kit-0.2.0/src/arek/headless/__init__.py +7 -0
  20. amiga_re_kit-0.2.0/src/arek/headless/bpstate.py +125 -0
  21. amiga_re_kit-0.2.0/src/arek/headless/config.py +65 -0
  22. amiga_re_kit-0.2.0/src/arek/headless/patches/vamiga-headless-899da5d.patch +126 -0
  23. amiga_re_kit-0.2.0/src/arek/headless/patches/vamiga-headless-c59425d.patch +131 -0
  24. amiga_re_kit-0.2.0/src/arek/headless/patches/vamiga-regtrace.patch +49 -0
  25. amiga_re_kit-0.2.0/src/arek/headless/patches/vamiga-trace.patch +36 -0
  26. amiga_re_kit-0.2.0/src/arek/headless/patches/vamiga-wasm.patch +80 -0
  27. amiga_re_kit-0.2.0/src/arek/headless/shot.py +90 -0
  28. amiga_re_kit-0.2.0/src/arek/hunk.py +179 -0
  29. amiga_re_kit-0.2.0/src/arek/m68k/__init__.py +3 -0
  30. amiga_re_kit-0.2.0/src/arek/m68k/audit.py +123 -0
  31. amiga_re_kit-0.2.0/src/arek/m68k/decoder.py +432 -0
  32. amiga_re_kit-0.2.0/src/arek/m68k/disasm.py +49 -0
  33. amiga_re_kit-0.2.0/src/arek/m68k/hwscan.py +302 -0
  34. amiga_re_kit-0.2.0/src/arek/m68k/recomp.py +702 -0
  35. amiga_re_kit-0.2.0/src/arek/m68k/xref.py +95 -0
  36. amiga_re_kit-0.2.0/src/arek/mcp_server.py +308 -0
  37. amiga_re_kit-0.2.0/src/arek/packers/__init__.py +9 -0
  38. amiga_re_kit-0.2.0/src/arek/packers/atomik.py +373 -0
  39. amiga_re_kit-0.2.0/src/arek/packers/bytekiller.py +279 -0
  40. amiga_re_kit-0.2.0/src/arek/packers/pp20.py +146 -0
  41. amiga_re_kit-0.2.0/src/arek/packers/scan.py +207 -0
  42. amiga_re_kit-0.2.0/src/arek/packers/turrican2.py +239 -0
  43. amiga_re_kit-0.2.0/tests/test_amigados.py +136 -0
  44. amiga_re_kit-0.2.0/tests/test_cli_mcp.py +76 -0
  45. amiga_re_kit-0.2.0/tests/test_headless_contract.py +74 -0
  46. amiga_re_kit-0.2.0/tests/test_hunk_adf_copper.py +81 -0
  47. amiga_re_kit-0.2.0/tests/test_m68k.py +225 -0
  48. amiga_re_kit-0.2.0/tests/test_packers.py +141 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 smikes75
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.4
2
+ Name: amiga-re-kit
3
+ Version: 0.2.0
4
+ Summary: Measured reverse engineering of Amiga floppy games: ADF/HUNK/packers, a strict 68000 decoder and static recompiler, headless vAmiga capture, and an MCP server so coding agents can use all of it.
5
+ Author: Štěpán Mikeš
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/smikes75/amiga-re-kit
8
+ Project-URL: SWIV (reference project), https://github.com/smikes75/swiv-amiga-re
9
+ Keywords: amiga,68000,reverse-engineering,adf,powerpacker,bytekiller,vamiga,mcp,recompiler
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Software Development :: Disassemblers
14
+ Classifier: Topic :: System :: Emulators
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ License-File: THIRD-PARTY.md
19
+ Provides-Extra: png
20
+ Requires-Dist: Pillow>=10; extra == "png"
21
+ Provides-Extra: mcp
22
+ Requires-Dist: mcp>=1.2; extra == "mcp"
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=8; extra == "dev"
25
+ Requires-Dist: Pillow>=10; extra == "dev"
26
+ Requires-Dist: mcp>=1.2; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # amiga-re-kit
30
+
31
+ Tools for reverse-engineering Commodore Amiga games from a disk image —
32
+ extracted from three complete game projects
33
+ ([S.W.I.V.](https://github.com/smikes75/swiv-amiga-re),
34
+ [Turrican II](https://github.com/smikes75/turrican2-amiga-re-claude),
35
+ [Superfrog](https://github.com/smikes75/superfrog-amiga-re)) and made
36
+ game-agnostic. One Python package (`arek`), one command line (`arek`), and an
37
+ **MCP server** (`arek-mcp`) so an AI assistant can drive the same instruments
38
+ you do.
39
+
40
+ The method is the point: **first a complete, *measured* description of the
41
+ original — only then anything else.** Nothing here guesses. The decoder
42
+ refuses instructions it does not model, the walker reports every indirect
43
+ jump it cannot follow, the packers verify with the checksums the originals
44
+ carry, and the emulator captures are compared byte for byte.
45
+
46
+ **No game data is included or needed to run the kit.** The tests use a
47
+ hand-assembled 20-byte program and random buffers. Your disk image and
48
+ Kickstart ROM stay on your machine, referenced from a git-ignored
49
+ `local.conf`.
50
+
51
+ ## Install
52
+
53
+ ```sh
54
+ pip install -e ".[mcp,png,dev]" # or without extras: pip install -e .
55
+ python -m pytest # 75 tests, synthetic data only
56
+ arek --help
57
+ ```
58
+
59
+ Optional: a patched headless [vAmiga](https://github.com/dirkwhoffmann/vAmiga)
60
+ for anything that runs the original (`arek shot`, `arek bpstate`) — see
61
+ [docs/HEADLESS.md](docs/HEADLESS.md). Optional: `m68k-elf-objdump` for
62
+ `arek xref`.
63
+
64
+ ## The workflow in commands
65
+
66
+ ```sh
67
+ arek init myproject && cd myproject # skeleton + local.conf (edit the paths)
68
+
69
+ # 1. measure the disk
70
+ arek adf info disk.adf # size, sha256, boot block, checksum
71
+ arek adf map disk.adf # entropy picture, one char per sector
72
+ arek adf regions disk.adf # where code / data / packed blocks sit
73
+ arek scan disk.adf # packer signatures, verified Bytekiller blocks
74
+
75
+ # 2. unpack what the loader unpacks
76
+ arek adf track disk.adf -n 1 -o trk1.bin
77
+ arek adf ls disk.adf # AmigaDOS files, if the disk has a filesystem
78
+ arek adf cat disk.adf -p LEVELS/L1 -o l1.atn # one file, data blocks verified
79
+ arek pp20 file.pp -o file.bin # PowerPacker 2.0
80
+ arek bytekiller trk1.bin --offset 0x200 -o main.bin
81
+ arek t2 INTR -o intr.bin # Turrican II three-stage
82
+ arek atn BLOCK -o out.bin --offset 0x1234 # Atomik (ATN!), block inside an image
83
+ arek hunk info prog && arek hunk load prog --base 0x20000 -o h # AmigaDOS executables
84
+
85
+ # 3. read the code - flow graph, not linear
86
+ arek dis main.bin --base 0x20700 --walk 0x20700 # only reachable code
87
+ arek walk main.bin --base 0x20700 --start 0x20700 # call tree + frontiers
88
+ arek hwscan main.bin --base 0x20700 --roots 0x20700 # the hardware boundary
89
+ arek copper ram.bin --base 0x0 --limit 200 # a copper list from a RAM dump
90
+ arek xref prog.txt --syms syms.json # from an objdump listing
91
+
92
+ # 4. translate and verify
93
+ arek recomp main.bin --base 0x20700 --auto 0x21234 --main -o draw.c
94
+ arek bpstate --address 0x21234 --end 20 --out cap/before
95
+ arek bpstate --address 0x21300 --end 20 --out cap/after
96
+ arek diff cap/before cap/after --range 0x60000 0x70000
97
+ arek shot build/shots/title 5 10 --at 3 "joystick 1 press fire"
98
+ ```
99
+
100
+ Every command prints what it measured and nothing else. `arek audit
101
+ profile.json` produces the JSON inventory + reachability record the method
102
+ asks for (see `examples/profile.example.json`).
103
+
104
+ ## What is inside
105
+
106
+ | module | what it does | origin |
107
+ |---|---|---|
108
+ | `arek.adf` | geometry, boot block checksum, entropy map / regions, inventory | new |
109
+ | `arek.amigados` | AmigaDOS OFS/FFS reader (directories, files, extension blocks, checksums) + synthetic image builder for tests | new |
110
+ | `arek.packers.pp20` | PowerPacker 2.0 decruncher (+ literal-only encoder for tests) | Turrican II / Superfrog |
111
+ | `arek.packers.bytekiller` | Bytekiller format B (XOR checksum) and the SWIV word-stream format A | S.W.I.V. |
112
+ | `arek.packers.turrican2` | Huffman → backwards LZ → RLE three-stage decruncher | Turrican II |
113
+ | `arek.packers.atomik` | Atomik (`ATN!`) decruncher with exact block extent (+ greedy LZ test encoder) | Superfrog |
114
+ | `arek.packers.scan` | brute-force scan: signatures (PP20, RNC, ATN!, IMP!, …) + verified blocks | S.W.I.V. |
115
+ | `arek.hunk` | bounded HUNK reader: CODE/DATA/BSS, RELOC32, split streams; `build()` for probes | Superfrog |
116
+ | `arek.copper` | copper list disassembler with custom register names | S.W.I.V. |
117
+ | `arek.m68k.decoder` | strict 68000 decoder: raises `Unsupported` instead of guessing | Superfrog (fixed ADDA/SUBA/CMPA) |
118
+ | `arek.m68k.disasm` | linear and flow-walk listings straight from the decoder | new |
119
+ | `arek.m68k.hwscan` | which routines are pure RAM and which touch custom chips / CIA / ROM | Turrican II |
120
+ | `arek.m68k.recomp` | static 68k → C recompiler with a verification driver (`MEM[]`, write log, minimal blitter model) | Superfrog |
121
+ | `arek.m68k.xref` | call / data cross references from `m68k-elf-objdump` text | Superfrog |
122
+ | `arek.m68k.audit` | profile-driven inventory + conservative reachability, JSON in / JSON out | Superfrog |
123
+ | `arek.headless` | `local.conf`, RetroShell scripts, screenshots, breakpoint captures | Turrican II / Superfrog |
124
+ | `arek.contract` | byte-level comparison of captures, register diffs, "untouched" assertions | Superfrog |
125
+ | `arek.cli` / `arek.mcp_server` | the command line and the MCP server | new |
126
+
127
+ Each module's docstring explains the format or the measurement it
128
+ implements; [docs/METHOD.md](docs/METHOD.md) explains how they fit together.
129
+
130
+ ## MCP: let an assistant hold the instruments
131
+
132
+ ```sh
133
+ pip install -e ".[mcp]"
134
+ ```
135
+
136
+ Claude Code (`.mcp.json` in your project, or `claude mcp add arek -- arek-mcp`):
137
+
138
+ ```json
139
+ {"mcpServers": {"arek": {"command": "arek-mcp"}}}
140
+ ```
141
+
142
+ The server exposes 20 tools (`adf_info`, `adf_map`, `adf_ls`, `adf_file`, `scan_packed`, `unpack`,
143
+ `hunk_load`, `disassemble`, `walk`, `hwscan`, `recomp`, `xref`, `copper`,
144
+ `headless_shot`, `headless_bpstate`, `diff_captures`, `ram_at`, …). All of them
145
+ take paths on the local machine; the server never fetches anything, never
146
+ writes outside the paths it is given, and only returns measurements — the
147
+ assistant sees entropy maps, listings and diffs, not your disk image.
148
+
149
+ A working session looks like: *"map the disk" → "scan for packed blocks" →
150
+ "unpack the block at 0x1f40 and walk it from its entry" → "which of these
151
+ routines touch hardware?" → "recompile 0x21234 and compare its RAM writes with
152
+ a capture of the original"*. Every answer is backed by a tool result.
153
+
154
+ ## Legal
155
+
156
+ The kit is MIT (see [LICENSE](LICENSE)). It ships no game data, no ROM, and
157
+ no game-specific knowledge — the "engine without data" model: you supply the
158
+ image you own. The vAmiga patches are modifications of MPL-2.0 sources and
159
+ are published as required; see [THIRD-PARTY.md](THIRD-PARTY.md).
160
+
161
+ Code comments inside the transplanted modules are partly in Czech (the
162
+ projects' working language); public docstrings, the CLI and the docs are
163
+ English.
@@ -0,0 +1,135 @@
1
+ # amiga-re-kit
2
+
3
+ Tools for reverse-engineering Commodore Amiga games from a disk image —
4
+ extracted from three complete game projects
5
+ ([S.W.I.V.](https://github.com/smikes75/swiv-amiga-re),
6
+ [Turrican II](https://github.com/smikes75/turrican2-amiga-re-claude),
7
+ [Superfrog](https://github.com/smikes75/superfrog-amiga-re)) and made
8
+ game-agnostic. One Python package (`arek`), one command line (`arek`), and an
9
+ **MCP server** (`arek-mcp`) so an AI assistant can drive the same instruments
10
+ you do.
11
+
12
+ The method is the point: **first a complete, *measured* description of the
13
+ original — only then anything else.** Nothing here guesses. The decoder
14
+ refuses instructions it does not model, the walker reports every indirect
15
+ jump it cannot follow, the packers verify with the checksums the originals
16
+ carry, and the emulator captures are compared byte for byte.
17
+
18
+ **No game data is included or needed to run the kit.** The tests use a
19
+ hand-assembled 20-byte program and random buffers. Your disk image and
20
+ Kickstart ROM stay on your machine, referenced from a git-ignored
21
+ `local.conf`.
22
+
23
+ ## Install
24
+
25
+ ```sh
26
+ pip install -e ".[mcp,png,dev]" # or without extras: pip install -e .
27
+ python -m pytest # 75 tests, synthetic data only
28
+ arek --help
29
+ ```
30
+
31
+ Optional: a patched headless [vAmiga](https://github.com/dirkwhoffmann/vAmiga)
32
+ for anything that runs the original (`arek shot`, `arek bpstate`) — see
33
+ [docs/HEADLESS.md](docs/HEADLESS.md). Optional: `m68k-elf-objdump` for
34
+ `arek xref`.
35
+
36
+ ## The workflow in commands
37
+
38
+ ```sh
39
+ arek init myproject && cd myproject # skeleton + local.conf (edit the paths)
40
+
41
+ # 1. measure the disk
42
+ arek adf info disk.adf # size, sha256, boot block, checksum
43
+ arek adf map disk.adf # entropy picture, one char per sector
44
+ arek adf regions disk.adf # where code / data / packed blocks sit
45
+ arek scan disk.adf # packer signatures, verified Bytekiller blocks
46
+
47
+ # 2. unpack what the loader unpacks
48
+ arek adf track disk.adf -n 1 -o trk1.bin
49
+ arek adf ls disk.adf # AmigaDOS files, if the disk has a filesystem
50
+ arek adf cat disk.adf -p LEVELS/L1 -o l1.atn # one file, data blocks verified
51
+ arek pp20 file.pp -o file.bin # PowerPacker 2.0
52
+ arek bytekiller trk1.bin --offset 0x200 -o main.bin
53
+ arek t2 INTR -o intr.bin # Turrican II three-stage
54
+ arek atn BLOCK -o out.bin --offset 0x1234 # Atomik (ATN!), block inside an image
55
+ arek hunk info prog && arek hunk load prog --base 0x20000 -o h # AmigaDOS executables
56
+
57
+ # 3. read the code - flow graph, not linear
58
+ arek dis main.bin --base 0x20700 --walk 0x20700 # only reachable code
59
+ arek walk main.bin --base 0x20700 --start 0x20700 # call tree + frontiers
60
+ arek hwscan main.bin --base 0x20700 --roots 0x20700 # the hardware boundary
61
+ arek copper ram.bin --base 0x0 --limit 200 # a copper list from a RAM dump
62
+ arek xref prog.txt --syms syms.json # from an objdump listing
63
+
64
+ # 4. translate and verify
65
+ arek recomp main.bin --base 0x20700 --auto 0x21234 --main -o draw.c
66
+ arek bpstate --address 0x21234 --end 20 --out cap/before
67
+ arek bpstate --address 0x21300 --end 20 --out cap/after
68
+ arek diff cap/before cap/after --range 0x60000 0x70000
69
+ arek shot build/shots/title 5 10 --at 3 "joystick 1 press fire"
70
+ ```
71
+
72
+ Every command prints what it measured and nothing else. `arek audit
73
+ profile.json` produces the JSON inventory + reachability record the method
74
+ asks for (see `examples/profile.example.json`).
75
+
76
+ ## What is inside
77
+
78
+ | module | what it does | origin |
79
+ |---|---|---|
80
+ | `arek.adf` | geometry, boot block checksum, entropy map / regions, inventory | new |
81
+ | `arek.amigados` | AmigaDOS OFS/FFS reader (directories, files, extension blocks, checksums) + synthetic image builder for tests | new |
82
+ | `arek.packers.pp20` | PowerPacker 2.0 decruncher (+ literal-only encoder for tests) | Turrican II / Superfrog |
83
+ | `arek.packers.bytekiller` | Bytekiller format B (XOR checksum) and the SWIV word-stream format A | S.W.I.V. |
84
+ | `arek.packers.turrican2` | Huffman → backwards LZ → RLE three-stage decruncher | Turrican II |
85
+ | `arek.packers.atomik` | Atomik (`ATN!`) decruncher with exact block extent (+ greedy LZ test encoder) | Superfrog |
86
+ | `arek.packers.scan` | brute-force scan: signatures (PP20, RNC, ATN!, IMP!, …) + verified blocks | S.W.I.V. |
87
+ | `arek.hunk` | bounded HUNK reader: CODE/DATA/BSS, RELOC32, split streams; `build()` for probes | Superfrog |
88
+ | `arek.copper` | copper list disassembler with custom register names | S.W.I.V. |
89
+ | `arek.m68k.decoder` | strict 68000 decoder: raises `Unsupported` instead of guessing | Superfrog (fixed ADDA/SUBA/CMPA) |
90
+ | `arek.m68k.disasm` | linear and flow-walk listings straight from the decoder | new |
91
+ | `arek.m68k.hwscan` | which routines are pure RAM and which touch custom chips / CIA / ROM | Turrican II |
92
+ | `arek.m68k.recomp` | static 68k → C recompiler with a verification driver (`MEM[]`, write log, minimal blitter model) | Superfrog |
93
+ | `arek.m68k.xref` | call / data cross references from `m68k-elf-objdump` text | Superfrog |
94
+ | `arek.m68k.audit` | profile-driven inventory + conservative reachability, JSON in / JSON out | Superfrog |
95
+ | `arek.headless` | `local.conf`, RetroShell scripts, screenshots, breakpoint captures | Turrican II / Superfrog |
96
+ | `arek.contract` | byte-level comparison of captures, register diffs, "untouched" assertions | Superfrog |
97
+ | `arek.cli` / `arek.mcp_server` | the command line and the MCP server | new |
98
+
99
+ Each module's docstring explains the format or the measurement it
100
+ implements; [docs/METHOD.md](docs/METHOD.md) explains how they fit together.
101
+
102
+ ## MCP: let an assistant hold the instruments
103
+
104
+ ```sh
105
+ pip install -e ".[mcp]"
106
+ ```
107
+
108
+ Claude Code (`.mcp.json` in your project, or `claude mcp add arek -- arek-mcp`):
109
+
110
+ ```json
111
+ {"mcpServers": {"arek": {"command": "arek-mcp"}}}
112
+ ```
113
+
114
+ The server exposes 20 tools (`adf_info`, `adf_map`, `adf_ls`, `adf_file`, `scan_packed`, `unpack`,
115
+ `hunk_load`, `disassemble`, `walk`, `hwscan`, `recomp`, `xref`, `copper`,
116
+ `headless_shot`, `headless_bpstate`, `diff_captures`, `ram_at`, …). All of them
117
+ take paths on the local machine; the server never fetches anything, never
118
+ writes outside the paths it is given, and only returns measurements — the
119
+ assistant sees entropy maps, listings and diffs, not your disk image.
120
+
121
+ A working session looks like: *"map the disk" → "scan for packed blocks" →
122
+ "unpack the block at 0x1f40 and walk it from its entry" → "which of these
123
+ routines touch hardware?" → "recompile 0x21234 and compare its RAM writes with
124
+ a capture of the original"*. Every answer is backed by a tool result.
125
+
126
+ ## Legal
127
+
128
+ The kit is MIT (see [LICENSE](LICENSE)). It ships no game data, no ROM, and
129
+ no game-specific knowledge — the "engine without data" model: you supply the
130
+ image you own. The vAmiga patches are modifications of MPL-2.0 sources and
131
+ are published as required; see [THIRD-PARTY.md](THIRD-PARTY.md).
132
+
133
+ Code comments inside the transplanted modules are partly in Czech (the
134
+ projects' working language); public docstrings, the CLI and the docs are
135
+ English.
@@ -0,0 +1,26 @@
1
+ # Third-party components and legal notes
2
+
3
+ The kit's own code (`src/arek`, `tests`, `docs`) is MIT (see `LICENSE`).
4
+
5
+ | component | licence | how it is used |
6
+ |---|---|---|
7
+ | [vAmiga](https://github.com/dirkwhoffmann/vAmiga) emulator core (`Core/`), Dirk W. Hoffmann | MPL-2.0 | **not included**. `src/arek/headless/patches/*.patch` are modifications of its source files; MPL-2.0 requires the modified sources to be made available, which these patch files do. You build `VAHeadless` yourself (see `docs/HEADLESS.md`). |
8
+ | vAmiga CPU core Moira (`Core/CPU/Moira`) | MIT | part of the core, not included |
9
+ | vAmiga macOS application | GPL-3.0 | not used |
10
+ | [mcp](https://pypi.org/project/mcp/) Python SDK | MIT | optional dependency (`arek-mcp`) |
11
+ | Pillow | MIT-CMU | optional dependency (PNG screenshots) |
12
+
13
+ ## What is deliberately absent
14
+
15
+ * No disk image, no Kickstart ROM, no byte of any game. The tests run on
16
+ synthetic data only (a hand-assembled 20-byte program, random buffers,
17
+ a generated boot block).
18
+ * No game-specific knowledge: addresses, catalogue layouts, level formats
19
+ live in the per-game projects, not here. The decoder, packers and
20
+ emulator driver are generic.
21
+ * The packers implemented (PowerPacker 2.0, Bytekiller family, Turrican II
22
+ three-stage) are documented formats re-implemented from the decrunch
23
+ routines; the compressors are not included and not needed.
24
+
25
+ Paths to copyrighted material go into `local.conf`, which `.gitignore`
26
+ excludes. Keep it that way in every project built on the kit.
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "amiga-re-kit"
7
+ version = "0.2.0"
8
+ description = "Measured reverse engineering of Amiga floppy games: ADF/HUNK/packers, a strict 68000 decoder and static recompiler, headless vAmiga capture, and an MCP server so coding agents can use all of it."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ license-files = ["LICENSE", "THIRD-PARTY.md"]
13
+ authors = [{ name = "Štěpán Mikeš" }]
14
+ keywords = ["amiga", "68000", "reverse-engineering", "adf", "powerpacker", "bytekiller", "vamiga", "mcp", "recompiler"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Programming Language :: Python :: 3",
19
+ "Topic :: Software Development :: Disassemblers",
20
+ "Topic :: System :: Emulators",
21
+ ]
22
+ dependencies = []
23
+
24
+ [project.optional-dependencies]
25
+ png = ["Pillow>=10"]
26
+ mcp = ["mcp>=1.2"]
27
+ dev = ["pytest>=8", "Pillow>=10", "mcp>=1.2"]
28
+
29
+ [project.scripts]
30
+ arek = "arek.cli:main"
31
+ arek-mcp = "arek.mcp_server:main"
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/smikes75/amiga-re-kit"
35
+ "SWIV (reference project)" = "https://github.com/smikes75/swiv-amiga-re"
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
39
+
40
+ [tool.setuptools.package-data]
41
+ "arek.headless" = ["patches/*.patch"]
42
+
43
+ [tool.pytest.ini_options]
44
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.4
2
+ Name: amiga-re-kit
3
+ Version: 0.2.0
4
+ Summary: Measured reverse engineering of Amiga floppy games: ADF/HUNK/packers, a strict 68000 decoder and static recompiler, headless vAmiga capture, and an MCP server so coding agents can use all of it.
5
+ Author: Štěpán Mikeš
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/smikes75/amiga-re-kit
8
+ Project-URL: SWIV (reference project), https://github.com/smikes75/swiv-amiga-re
9
+ Keywords: amiga,68000,reverse-engineering,adf,powerpacker,bytekiller,vamiga,mcp,recompiler
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Software Development :: Disassemblers
14
+ Classifier: Topic :: System :: Emulators
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ License-File: THIRD-PARTY.md
19
+ Provides-Extra: png
20
+ Requires-Dist: Pillow>=10; extra == "png"
21
+ Provides-Extra: mcp
22
+ Requires-Dist: mcp>=1.2; extra == "mcp"
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=8; extra == "dev"
25
+ Requires-Dist: Pillow>=10; extra == "dev"
26
+ Requires-Dist: mcp>=1.2; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # amiga-re-kit
30
+
31
+ Tools for reverse-engineering Commodore Amiga games from a disk image —
32
+ extracted from three complete game projects
33
+ ([S.W.I.V.](https://github.com/smikes75/swiv-amiga-re),
34
+ [Turrican II](https://github.com/smikes75/turrican2-amiga-re-claude),
35
+ [Superfrog](https://github.com/smikes75/superfrog-amiga-re)) and made
36
+ game-agnostic. One Python package (`arek`), one command line (`arek`), and an
37
+ **MCP server** (`arek-mcp`) so an AI assistant can drive the same instruments
38
+ you do.
39
+
40
+ The method is the point: **first a complete, *measured* description of the
41
+ original — only then anything else.** Nothing here guesses. The decoder
42
+ refuses instructions it does not model, the walker reports every indirect
43
+ jump it cannot follow, the packers verify with the checksums the originals
44
+ carry, and the emulator captures are compared byte for byte.
45
+
46
+ **No game data is included or needed to run the kit.** The tests use a
47
+ hand-assembled 20-byte program and random buffers. Your disk image and
48
+ Kickstart ROM stay on your machine, referenced from a git-ignored
49
+ `local.conf`.
50
+
51
+ ## Install
52
+
53
+ ```sh
54
+ pip install -e ".[mcp,png,dev]" # or without extras: pip install -e .
55
+ python -m pytest # 75 tests, synthetic data only
56
+ arek --help
57
+ ```
58
+
59
+ Optional: a patched headless [vAmiga](https://github.com/dirkwhoffmann/vAmiga)
60
+ for anything that runs the original (`arek shot`, `arek bpstate`) — see
61
+ [docs/HEADLESS.md](docs/HEADLESS.md). Optional: `m68k-elf-objdump` for
62
+ `arek xref`.
63
+
64
+ ## The workflow in commands
65
+
66
+ ```sh
67
+ arek init myproject && cd myproject # skeleton + local.conf (edit the paths)
68
+
69
+ # 1. measure the disk
70
+ arek adf info disk.adf # size, sha256, boot block, checksum
71
+ arek adf map disk.adf # entropy picture, one char per sector
72
+ arek adf regions disk.adf # where code / data / packed blocks sit
73
+ arek scan disk.adf # packer signatures, verified Bytekiller blocks
74
+
75
+ # 2. unpack what the loader unpacks
76
+ arek adf track disk.adf -n 1 -o trk1.bin
77
+ arek adf ls disk.adf # AmigaDOS files, if the disk has a filesystem
78
+ arek adf cat disk.adf -p LEVELS/L1 -o l1.atn # one file, data blocks verified
79
+ arek pp20 file.pp -o file.bin # PowerPacker 2.0
80
+ arek bytekiller trk1.bin --offset 0x200 -o main.bin
81
+ arek t2 INTR -o intr.bin # Turrican II three-stage
82
+ arek atn BLOCK -o out.bin --offset 0x1234 # Atomik (ATN!), block inside an image
83
+ arek hunk info prog && arek hunk load prog --base 0x20000 -o h # AmigaDOS executables
84
+
85
+ # 3. read the code - flow graph, not linear
86
+ arek dis main.bin --base 0x20700 --walk 0x20700 # only reachable code
87
+ arek walk main.bin --base 0x20700 --start 0x20700 # call tree + frontiers
88
+ arek hwscan main.bin --base 0x20700 --roots 0x20700 # the hardware boundary
89
+ arek copper ram.bin --base 0x0 --limit 200 # a copper list from a RAM dump
90
+ arek xref prog.txt --syms syms.json # from an objdump listing
91
+
92
+ # 4. translate and verify
93
+ arek recomp main.bin --base 0x20700 --auto 0x21234 --main -o draw.c
94
+ arek bpstate --address 0x21234 --end 20 --out cap/before
95
+ arek bpstate --address 0x21300 --end 20 --out cap/after
96
+ arek diff cap/before cap/after --range 0x60000 0x70000
97
+ arek shot build/shots/title 5 10 --at 3 "joystick 1 press fire"
98
+ ```
99
+
100
+ Every command prints what it measured and nothing else. `arek audit
101
+ profile.json` produces the JSON inventory + reachability record the method
102
+ asks for (see `examples/profile.example.json`).
103
+
104
+ ## What is inside
105
+
106
+ | module | what it does | origin |
107
+ |---|---|---|
108
+ | `arek.adf` | geometry, boot block checksum, entropy map / regions, inventory | new |
109
+ | `arek.amigados` | AmigaDOS OFS/FFS reader (directories, files, extension blocks, checksums) + synthetic image builder for tests | new |
110
+ | `arek.packers.pp20` | PowerPacker 2.0 decruncher (+ literal-only encoder for tests) | Turrican II / Superfrog |
111
+ | `arek.packers.bytekiller` | Bytekiller format B (XOR checksum) and the SWIV word-stream format A | S.W.I.V. |
112
+ | `arek.packers.turrican2` | Huffman → backwards LZ → RLE three-stage decruncher | Turrican II |
113
+ | `arek.packers.atomik` | Atomik (`ATN!`) decruncher with exact block extent (+ greedy LZ test encoder) | Superfrog |
114
+ | `arek.packers.scan` | brute-force scan: signatures (PP20, RNC, ATN!, IMP!, …) + verified blocks | S.W.I.V. |
115
+ | `arek.hunk` | bounded HUNK reader: CODE/DATA/BSS, RELOC32, split streams; `build()` for probes | Superfrog |
116
+ | `arek.copper` | copper list disassembler with custom register names | S.W.I.V. |
117
+ | `arek.m68k.decoder` | strict 68000 decoder: raises `Unsupported` instead of guessing | Superfrog (fixed ADDA/SUBA/CMPA) |
118
+ | `arek.m68k.disasm` | linear and flow-walk listings straight from the decoder | new |
119
+ | `arek.m68k.hwscan` | which routines are pure RAM and which touch custom chips / CIA / ROM | Turrican II |
120
+ | `arek.m68k.recomp` | static 68k → C recompiler with a verification driver (`MEM[]`, write log, minimal blitter model) | Superfrog |
121
+ | `arek.m68k.xref` | call / data cross references from `m68k-elf-objdump` text | Superfrog |
122
+ | `arek.m68k.audit` | profile-driven inventory + conservative reachability, JSON in / JSON out | Superfrog |
123
+ | `arek.headless` | `local.conf`, RetroShell scripts, screenshots, breakpoint captures | Turrican II / Superfrog |
124
+ | `arek.contract` | byte-level comparison of captures, register diffs, "untouched" assertions | Superfrog |
125
+ | `arek.cli` / `arek.mcp_server` | the command line and the MCP server | new |
126
+
127
+ Each module's docstring explains the format or the measurement it
128
+ implements; [docs/METHOD.md](docs/METHOD.md) explains how they fit together.
129
+
130
+ ## MCP: let an assistant hold the instruments
131
+
132
+ ```sh
133
+ pip install -e ".[mcp]"
134
+ ```
135
+
136
+ Claude Code (`.mcp.json` in your project, or `claude mcp add arek -- arek-mcp`):
137
+
138
+ ```json
139
+ {"mcpServers": {"arek": {"command": "arek-mcp"}}}
140
+ ```
141
+
142
+ The server exposes 20 tools (`adf_info`, `adf_map`, `adf_ls`, `adf_file`, `scan_packed`, `unpack`,
143
+ `hunk_load`, `disassemble`, `walk`, `hwscan`, `recomp`, `xref`, `copper`,
144
+ `headless_shot`, `headless_bpstate`, `diff_captures`, `ram_at`, …). All of them
145
+ take paths on the local machine; the server never fetches anything, never
146
+ writes outside the paths it is given, and only returns measurements — the
147
+ assistant sees entropy maps, listings and diffs, not your disk image.
148
+
149
+ A working session looks like: *"map the disk" → "scan for packed blocks" →
150
+ "unpack the block at 0x1f40 and walk it from its entry" → "which of these
151
+ routines touch hardware?" → "recompile 0x21234 and compare its RAM writes with
152
+ a capture of the original"*. Every answer is backed by a tool result.
153
+
154
+ ## Legal
155
+
156
+ The kit is MIT (see [LICENSE](LICENSE)). It ships no game data, no ROM, and
157
+ no game-specific knowledge — the "engine without data" model: you supply the
158
+ image you own. The vAmiga patches are modifications of MPL-2.0 sources and
159
+ are published as required; see [THIRD-PARTY.md](THIRD-PARTY.md).
160
+
161
+ Code comments inside the transplanted modules are partly in Czech (the
162
+ projects' working language); public docstrings, the CLI and the docs are
163
+ English.
@@ -0,0 +1,46 @@
1
+ LICENSE
2
+ README.md
3
+ THIRD-PARTY.md
4
+ pyproject.toml
5
+ src/amiga_re_kit.egg-info/PKG-INFO
6
+ src/amiga_re_kit.egg-info/SOURCES.txt
7
+ src/amiga_re_kit.egg-info/dependency_links.txt
8
+ src/amiga_re_kit.egg-info/entry_points.txt
9
+ src/amiga_re_kit.egg-info/requires.txt
10
+ src/amiga_re_kit.egg-info/top_level.txt
11
+ src/arek/__init__.py
12
+ src/arek/adf.py
13
+ src/arek/amigados.py
14
+ src/arek/cli.py
15
+ src/arek/contract.py
16
+ src/arek/copper.py
17
+ src/arek/hunk.py
18
+ src/arek/mcp_server.py
19
+ src/arek/headless/__init__.py
20
+ src/arek/headless/bpstate.py
21
+ src/arek/headless/config.py
22
+ src/arek/headless/shot.py
23
+ src/arek/headless/patches/vamiga-headless-899da5d.patch
24
+ src/arek/headless/patches/vamiga-headless-c59425d.patch
25
+ src/arek/headless/patches/vamiga-regtrace.patch
26
+ src/arek/headless/patches/vamiga-trace.patch
27
+ src/arek/headless/patches/vamiga-wasm.patch
28
+ src/arek/m68k/__init__.py
29
+ src/arek/m68k/audit.py
30
+ src/arek/m68k/decoder.py
31
+ src/arek/m68k/disasm.py
32
+ src/arek/m68k/hwscan.py
33
+ src/arek/m68k/recomp.py
34
+ src/arek/m68k/xref.py
35
+ src/arek/packers/__init__.py
36
+ src/arek/packers/atomik.py
37
+ src/arek/packers/bytekiller.py
38
+ src/arek/packers/pp20.py
39
+ src/arek/packers/scan.py
40
+ src/arek/packers/turrican2.py
41
+ tests/test_amigados.py
42
+ tests/test_cli_mcp.py
43
+ tests/test_headless_contract.py
44
+ tests/test_hunk_adf_copper.py
45
+ tests/test_m68k.py
46
+ tests/test_packers.py
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ arek = arek.cli:main
3
+ arek-mcp = arek.mcp_server:main
@@ -0,0 +1,11 @@
1
+
2
+ [dev]
3
+ pytest>=8
4
+ Pillow>=10
5
+ mcp>=1.2
6
+
7
+ [mcp]
8
+ mcp>=1.2
9
+
10
+ [png]
11
+ Pillow>=10
@@ -0,0 +1,25 @@
1
+ """amiga-re-kit (``arek``) - tools for *measured* reverse engineering of Amiga games.
2
+
3
+ The package grew out of three game projects (S.W.I.V., Turrican II, Superfrog)
4
+ where the same scripts kept being copied around. Everything here is game
5
+ agnostic; game knowledge (addresses, catalogue layouts, packer variants)
6
+ lives in the per-game projects or in a *profile* JSON passed at run time.
7
+
8
+ Modules
9
+ -------
10
+ adf ADF floppy images: bootblock checksum, DOS type, tracks, entropy map,
11
+ packer signature scan
12
+ hunk strict Amiga HUNK executable loader (fails on anything unknown)
13
+ packers PowerPacker 2.0, Bytekiller (+ the SWIV "A" variant), Turrican II
14
+ three-stage packer, brute-force scan for packed blocks
15
+ m68k strict 68000 decoder, flow-graph walker, hardware-boundary scan,
16
+ static recompiler to C, objdump cross references, reachability audit
17
+ copper Copper list disassembler
18
+ headless scripted headless vAmiga (screenshots, RAM + register capture at a
19
+ breakpoint), plus the patches the headless build needs
20
+ contract tiny framework for "verification contract" scripts
21
+ cli ``arek`` command line
22
+ mcp_server ``arek-mcp`` Model Context Protocol server
23
+ """
24
+
25
+ __version__ = "0.1.0"