# SFIII 4th Strike — Instruction Table (sfiii4s.tab) Instruction table for Street Fighter III: 4th Strike (4S), required to use in a dead-cart encrypted version of SIMMs 1-2 that runs on real CPS3 hardware with a custom SH-2. ## Background Street Fighter III: 4th Strike is a third-party arrange of 3rd Strike (3B) built on the same CPS3 engine. No custom (dead-cart encrypted) version of 4S has ever been released — the game was distributed as plaintext SIMMs only to use with standard SH-2. The CPS3 dead-cart cipher (key=0, key2=0) XORs instruction words with an address-derived mask and leaves data words unchanged. To encrypt the SIMMs correctly, every word must be classified as instruction or data. That classification is `sfiii4s.tab`. ## How the table was built **Phase 1 — Ground truth from 3rd Strike** 4S is built directly on top of 3B. Both the plaintext (`SFIII3B_10`) and dead-cart encrypted (`SFIII3B_10_custom`) versions of 3B are available. Comparing them word by word gives the instruction table for 3B directly: a word that differs was encrypted (instruction); a word that is identical was left unchanged (data). Result: 563,251 instruction bits across 8,388,608 words (6.7% of SIMMs 1-2). **Phase 2 — Seeding by word coincidence** Comparing `SFIII3B_10` and `sfiii4s_prg` word by word: | Zone | Words | % | |---|---|---| | Identical (3B = 4S) | 8,225,710 | 98.1% | | Gray zone (3B ≠ 4S) | 162,898 | 1.9% | For every identical position where `sfiii3b.tab=1`, the instruction bit is inherited into the 4S table directly. This recovers 563,238 instruction bits (99.998% of the 3B instruction set) without any static analysis. The 162,898 differing positions are predominantly data: 97.7% are positions where 3B was zero-padded and 4S wrote new content (palettes, animation tables, hitbox data for the new character). Only 13 of these positions held instructions in 3B — all of them are modified instructions in 4S code. **Phase 3 — Static analysis (Ghidra)** The 4S SIMM was loaded in Ghidra with the full CPS3 memory map. The SH-2 vector table was defined and all reachable code was traced from entry points. The seed was OR-merged over the Ghidra result to recover any positions Ghidra did not reach. A false-positive cleanup pass removed Ghidra misclassifications in the identical zone using `sfiii4s.seedclear` (7,662,472 confirmed-data positions derived from the 3B comparison). **Phase 4 — Gray zone coverage** The 13 modified instruction positions in the gray zone were identified by tracing the functions that contained them. All 12 recoverable ones belong to the input buffer and sprite mapping cluster that 4S modified over 3B: | Function | Modified instructions | |---|---| | `ClearSpriteMappings` | `ADD #-1,R0 → NOP` (table reindexed base-0) | | `SetSpriteEntryBytes` | `ADD #-1,R0 → NOP` | | `FilterMoveIndices` | `ADD #-1,R0 → NOP` | | `IncrementInputCount` | 4 words (new comparison logic) | | `DecrementInputCount` | 3 words (branch targets adjusted) | | `AdvanceInputCycle` | `BT/S → BRA` (unconditional) | | `RewindInputCycle` | `BT/S → BRA` (unconditional) | The remaining position (`0x067FEE06`, isolated `SETT` in zero-padded region) is irrecoverable without hardware — it has no enclosing function and no external reference. Its cipher mask is non-zero so the classification has encryption impact, but the surrounding context (continuous zeros) makes it almost certainly an artifact. **Key finding** The 4S engine is identical to 3B. The new character, moves, and selectable roster are entirely data — new tables written over zero-padded space in 3B. The 12 code modifications are minor adjustments to read the new data layout (index base change, updated constants, simplified branch conditions). ## Final table metrics | Metric | Value | |---|---| | Total SIMMs 1-2 words | 8,388,608 | | Instructions | 563,252 (6.7%) | | Data | 7,825,356 (93.3%) | | Seed coverage (3B reference) | 563,238 / 563,238 (100%) | | False positives in confirmed-data zone | 0 | | Gray zone instructions identified | 14 | | Unresolvable positions | 1 | ## Producing sfiii4s_prg_custom Requirements: - `sfiii4s_prg` — plaintext SIMMs 1-2 (16 MB) - `sfiii4s.tab` — this file (1 MB) - Python 3.x Encrypt: ``` python3 apply_instr_table.py encrypt sfiii4s_prg sfiii4s.tab sfiii4s_prg_custom ``` Decrypt (roundtrip verification): ``` python3 apply_instr_table.py decrypt sfiii4s_prg_custom sfiii4s.tab sfiii4s_prg.verify ``` The decrypt output must be byte-identical to `sfiii4s_prg`. The cipher is symmetric — encrypt and decrypt are the same XOR operation. ## File reference | File | Size | Description | |---|---|---| | `sfiii4s.tab` | 1,048,576 bytes | Instruction table (1 bit per word, 1 byte = 8 words) | | `apply_instr_table.py` | — | Encrypt/decrypt SIMMs 1-2 using the table | | `sfiii4s_prg_custom` | 16,777,216 bytes | Output — dead-cart encrypted SIMMs 1-2 | ## Table format 1 MB binary file. Each bit corresponds to one 2-byte word in the SIMM: ## Building unified ISOs (build_iso.py) `build_iso.py` assembles two unified CPS3 UltraBIOS ISOs — one for standard SH-2, one for custom (dead-cart) SH-2 — each bundling the base UltraBIOS release alongside the MakotoFix and 4th Strike variants as sub-directories. This script only merges and repackages ISOs that already exist, applying the 4S dead-cart encryption (via `sfiii4s.tab`) to fold 4th Strike into the custom-SH2 build. All of the UltraBIOS engineering, the MakotoFix patch, and the 4th Strike ISO itself are the work of their original author(s); full credit belongs to them. ### Requirements The five source UltraBIOS ISOs are **not included in this repository** and must be obtained separately before running the script. They are expected in the repository root with these exact filenames: | Label | Filename | |---|---| | V4 | `UniCD-CPS3_for_standard_SH2_V4_Unmodified.iso` | | V4MF | `UniCD-CPS3_for_standard_SH2_V4_Unmodified_MakotoFix.iso` | | 4S | `UniCD-CPS3_for_standard_SH2_V4th Strike.iso` | | V5 | `UniCD-CPS3_for_custom_SH2_V5_Unmodified.iso` | | V6MF | `UniCD-CPS3_for_custom_SH2_V6_Unmodified_MakotoFix.iso` | Also required: - `sfiii4s.tab` (this repository) — used to dead-cart encrypt the 4S SIMM when building the custom-SH2 ISO - Python 3.x with [`pycdlib`](https://pypi.org/project/pycdlib/) ### Usage ``` python3 build_iso.py ``` Produces `cps3-standard.iso` and `cps3-custom.iso` in the repository root.