diff --git a/.gitignore b/.gitignore index 71d5c38..8d34c8d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,10 @@ -# Ghidra project files -/.ghidra/ -*.rep/ -*.gpr - # Ghidra caches and temporary files -ghidra_* +ghidra_* *.bak *.tmp *.swp +*.lock +*.lock~ # IDE and OS files .vscode/ diff --git a/Crusader.gpr b/Crusader.gpr new file mode 100644 index 0000000..e69de29 diff --git a/Crusader.rep/idata/00/00000000.prp b/Crusader.rep/idata/00/00000000.prp new file mode 100644 index 0000000..5e02b46 --- /dev/null +++ b/Crusader.rep/idata/00/00000000.prp @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Crusader.rep/idata/00/00000001.prp b/Crusader.rep/idata/00/00000001.prp new file mode 100644 index 0000000..7ae736e --- /dev/null +++ b/Crusader.rep/idata/00/00000001.prp @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Crusader.rep/idata/00/00000002.prp b/Crusader.rep/idata/00/00000002.prp new file mode 100644 index 0000000..c11da2b --- /dev/null +++ b/Crusader.rep/idata/00/00000002.prp @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Crusader.rep/idata/00/00000003.prp b/Crusader.rep/idata/00/00000003.prp new file mode 100644 index 0000000..d42ec16 --- /dev/null +++ b/Crusader.rep/idata/00/00000003.prp @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Crusader.rep/idata/00/00000004.prp b/Crusader.rep/idata/00/00000004.prp new file mode 100644 index 0000000..472eae3 --- /dev/null +++ b/Crusader.rep/idata/00/00000004.prp @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Crusader.rep/idata/00/00000005.prp b/Crusader.rep/idata/00/00000005.prp new file mode 100644 index 0000000..88c4187 --- /dev/null +++ b/Crusader.rep/idata/00/00000005.prp @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Crusader.rep/idata/00/00000006.prp b/Crusader.rep/idata/00/00000006.prp new file mode 100644 index 0000000..f8ed4a6 --- /dev/null +++ b/Crusader.rep/idata/00/00000006.prp @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Crusader.rep/idata/00/~00000000.db/db.3.gbf b/Crusader.rep/idata/00/~00000000.db/db.3.gbf new file mode 100644 index 0000000..389d7d4 Binary files /dev/null and b/Crusader.rep/idata/00/~00000000.db/db.3.gbf differ diff --git a/Crusader.rep/idata/00/~00000000.db/db.4.gbf b/Crusader.rep/idata/00/~00000000.db/db.4.gbf new file mode 100644 index 0000000..cc6c42a Binary files /dev/null and b/Crusader.rep/idata/00/~00000000.db/db.4.gbf differ diff --git a/Crusader.rep/idata/00/~00000000.db/tmp9285499915757176405.ps b/Crusader.rep/idata/00/~00000000.db/tmp9285499915757176405.ps new file mode 100644 index 0000000..570058d Binary files /dev/null and b/Crusader.rep/idata/00/~00000000.db/tmp9285499915757176405.ps differ diff --git a/Crusader.rep/idata/00/~00000001.db/db.1.gbf b/Crusader.rep/idata/00/~00000001.db/db.1.gbf new file mode 100644 index 0000000..071901b Binary files /dev/null and b/Crusader.rep/idata/00/~00000001.db/db.1.gbf differ diff --git a/Crusader.rep/idata/00/~00000001.db/db.2.gbf b/Crusader.rep/idata/00/~00000001.db/db.2.gbf new file mode 100644 index 0000000..b0b3e2d Binary files /dev/null and b/Crusader.rep/idata/00/~00000001.db/db.2.gbf differ diff --git a/Crusader.rep/idata/00/~00000002.db/db.3.gbf b/Crusader.rep/idata/00/~00000002.db/db.3.gbf new file mode 100644 index 0000000..bacbee1 Binary files /dev/null and b/Crusader.rep/idata/00/~00000002.db/db.3.gbf differ diff --git a/Crusader.rep/idata/00/~00000002.db/db.4.gbf b/Crusader.rep/idata/00/~00000002.db/db.4.gbf new file mode 100644 index 0000000..c3368f7 Binary files /dev/null and b/Crusader.rep/idata/00/~00000002.db/db.4.gbf differ diff --git a/Crusader.rep/idata/00/~00000002.db/tmp4806045532435408105.ps b/Crusader.rep/idata/00/~00000002.db/tmp4806045532435408105.ps new file mode 100644 index 0000000..c70c0c6 Binary files /dev/null and b/Crusader.rep/idata/00/~00000002.db/tmp4806045532435408105.ps differ diff --git a/Crusader.rep/idata/00/~00000003.db/db.2.gbf b/Crusader.rep/idata/00/~00000003.db/db.2.gbf new file mode 100644 index 0000000..1b7d4c3 Binary files /dev/null and b/Crusader.rep/idata/00/~00000003.db/db.2.gbf differ diff --git a/Crusader.rep/idata/00/~00000003.db/db.3.gbf b/Crusader.rep/idata/00/~00000003.db/db.3.gbf new file mode 100644 index 0000000..e1c93d2 Binary files /dev/null and b/Crusader.rep/idata/00/~00000003.db/db.3.gbf differ diff --git a/Crusader.rep/idata/00/~00000003.db/tmp10014618038985014557.ps b/Crusader.rep/idata/00/~00000003.db/tmp10014618038985014557.ps new file mode 100644 index 0000000..c2b197f Binary files /dev/null and b/Crusader.rep/idata/00/~00000003.db/tmp10014618038985014557.ps differ diff --git a/Crusader.rep/idata/00/~00000004.db/db.1.gbf b/Crusader.rep/idata/00/~00000004.db/db.1.gbf new file mode 100644 index 0000000..ace66f9 Binary files /dev/null and b/Crusader.rep/idata/00/~00000004.db/db.1.gbf differ diff --git a/Crusader.rep/idata/00/~00000004.db/db.2.gbf b/Crusader.rep/idata/00/~00000004.db/db.2.gbf new file mode 100644 index 0000000..9821d1e Binary files /dev/null and b/Crusader.rep/idata/00/~00000004.db/db.2.gbf differ diff --git a/Crusader.rep/idata/00/~00000004.db/tmp1857712473912079246.ps b/Crusader.rep/idata/00/~00000004.db/tmp1857712473912079246.ps new file mode 100644 index 0000000..e3a2c3c Binary files /dev/null and b/Crusader.rep/idata/00/~00000004.db/tmp1857712473912079246.ps differ diff --git a/Crusader.rep/idata/00/~00000005.db/db.1.gbf b/Crusader.rep/idata/00/~00000005.db/db.1.gbf new file mode 100644 index 0000000..6e5e383 Binary files /dev/null and b/Crusader.rep/idata/00/~00000005.db/db.1.gbf differ diff --git a/Crusader.rep/idata/00/~00000005.db/db.2.gbf b/Crusader.rep/idata/00/~00000005.db/db.2.gbf new file mode 100644 index 0000000..3d21315 Binary files /dev/null and b/Crusader.rep/idata/00/~00000005.db/db.2.gbf differ diff --git a/Crusader.rep/idata/00/~00000005.db/tmp9749653166654237275.ps b/Crusader.rep/idata/00/~00000005.db/tmp9749653166654237275.ps new file mode 100644 index 0000000..b2e4363 Binary files /dev/null and b/Crusader.rep/idata/00/~00000005.db/tmp9749653166654237275.ps differ diff --git a/Crusader.rep/idata/00/~00000006.db/changeB.grf b/Crusader.rep/idata/00/~00000006.db/changeB.grf new file mode 100644 index 0000000..b832b52 Binary files /dev/null and b/Crusader.rep/idata/00/~00000006.db/changeB.grf differ diff --git a/Crusader.rep/idata/00/~00000006.db/db.10.gbf b/Crusader.rep/idata/00/~00000006.db/db.10.gbf new file mode 100644 index 0000000..fe40b1c Binary files /dev/null and b/Crusader.rep/idata/00/~00000006.db/db.10.gbf differ diff --git a/Crusader.rep/idata/00/~00000006.db/db.11.gbf b/Crusader.rep/idata/00/~00000006.db/db.11.gbf new file mode 100644 index 0000000..bd15647 Binary files /dev/null and b/Crusader.rep/idata/00/~00000006.db/db.11.gbf differ diff --git a/Crusader.rep/idata/00/~00000006.db/snapshotB.grf b/Crusader.rep/idata/00/~00000006.db/snapshotB.grf new file mode 100644 index 0000000..09b2acb Binary files /dev/null and b/Crusader.rep/idata/00/~00000006.db/snapshotB.grf differ diff --git a/Crusader.rep/idata/00/~00000006.db/tmp6011628954267328177.ps b/Crusader.rep/idata/00/~00000006.db/tmp6011628954267328177.ps new file mode 100644 index 0000000..e69de29 diff --git a/Crusader.rep/idata/~index.dat b/Crusader.rep/idata/~index.dat new file mode 100644 index 0000000..70462f3 --- /dev/null +++ b/Crusader.rep/idata/~index.dat @@ -0,0 +1,11 @@ +VERSION=1 +/ + 00000006:CRUSADER-RAW.EXE:c0a8647bdba516037949612600 + 00000000:CRUSADER.EXE:c0a8647bf0178892741854800 + 00000001:CRUSADER_NE_WRAPPED.EXE:c0a8647beb3812826386895600 + 00000002:seg001_code_off_37600_len_8400.bin:c0a8647bf4b212984786819600 + 00000003:seg021_code_off_50200_len_4486.bin:c0a8647bd82013090643707800 + 00000004:seg030_code_off_5E000_len_5071.bin:c0a8647bfe7615910786193500 + 00000005:seg059_code_off_86A00_len_4288.bin:c0a8647bdaf715949048416300 +NEXT-ID:7 +MD5:d41d8cd98f00b204e9800998ecf8427e diff --git a/Crusader.rep/project.prp b/Crusader.rep/project.prp new file mode 100644 index 0000000..d7d126d --- /dev/null +++ b/Crusader.rep/project.prp @@ -0,0 +1,6 @@ + + + + + + diff --git a/Crusader.rep/user/~index.dat b/Crusader.rep/user/~index.dat new file mode 100644 index 0000000..b1e697f --- /dev/null +++ b/Crusader.rep/user/~index.dat @@ -0,0 +1,4 @@ +VERSION=1 +/ +NEXT-ID:0 +MD5:d41d8cd98f00b204e9800998ecf8427e diff --git a/Crusader.rep/versioned/~index.dat b/Crusader.rep/versioned/~index.dat new file mode 100644 index 0000000..b1e697f --- /dev/null +++ b/Crusader.rep/versioned/~index.dat @@ -0,0 +1,4 @@ +VERSION=1 +/ +NEXT-ID:0 +MD5:d41d8cd98f00b204e9800998ecf8427e diff --git a/crusader_decompilation_notes.md b/crusader_decompilation_notes.md index 7f2991f..79d7b5f 100644 --- a/crusader_decompilation_notes.md +++ b/crusader_decompilation_notes.md @@ -48,6 +48,26 @@ - `entity_fire_weapon` currently decompiles as a thin wrapper that calls `projectile_init_vector`. - `fire_weapon_from_cursor` still decompiles poorly in the raw import, but disassembly shows it begins by pushing cursor sprite/state data from the `0x27d6` area, consistent with the existing seg001 notes. +### Raw 0007 Gameplay Helper Batch (entity/tile aux state) + +- New conservative gameplay-side helper renames (direct analysis from field writes and call structure): + - `0007:85f6` = `entity_sync_tile_aux_state` + - `0007:8865` = `entity_sync_tile_aux_if_linked` + - `0007:8709` = `entity_mark_dirty_and_sync_tile_aux` +- Current verified behavior: + - `entity_sync_tile_aux_state` reads entity tile index at `+0x4`, toggles bit `0x04` in tile record `+0x59` based on entity byte `+0x54`, and copies entity word `+0x55` into tile record `+0x0d`. + - `entity_sync_tile_aux_if_linked` only performs the sync when entity link/pointer `+0x50/+0x52` is non-null. + - `entity_mark_dirty_and_sync_tile_aux` calls the linked-sync helper, sets entity flag bit `0x04` at `+0x42`, then enters the existing unresolved thunk path (`0000:ffff`). + +### Raw 0007 Gameplay Helper Batch (facing/direction) + +- New gameplay helper rename (direct analysis): + - `0007:8bd9` = `entity_set_facing_direction` +- Current verified behavior: + - Updates entity facing byte `+0x38` using incoming direction/event code values (notably `0x10/0x11/0x12`) with parity-aware adjustment. + - Uses entity flags at `+0x4d` to select increment/decrement behavior for clockwise/counterclockwise facing updates. + - Called from the large gameplay update state machine at `0007:5b9a` inside `FUN_0007_5b6f`. + ### Raw 000e Parser Helper Cluster - A small helper cluster in the raw `000e:` area now appears to implement a fixed-size CRLF record parser/table builder, likely used by startup/config or script-ish text data. @@ -59,12 +79,13 @@ - `000e:3639` = `record_table_parse_buffer` - `000e:3798` = `record_parser_read_line` - `000e:38f8` = `record_parser_find_marker` + - `000e:39cc` = `record_parser_dispatch_at_directive` - Current behavior read from raw-import decompilation/disassembly: - `record_table_init` clears the table header and zeroes 300 words of inline storage. - `record_table_parse_buffer` walks a CRLF-separated text buffer, captures each line, splits around a marker helper path, and stores parsed entry state into 0x0c-byte records. - `record_parser_read_line` advances to the next CRLF-delimited line, rejects lines that start with `@` or with non-identifier punctuation, and terminates the line in-place with `0`. - `record_parser_find_marker` scans forward until an `@` marker or end-of-data; optionally consumes the remaining length from the parser state. - - Helper at `000e:39cc` remains intentionally unnamed for now; disassembly shows it only activates when the current substring begins with `@`, then skips 7 bytes and dispatches through a thunk. + - `record_parser_dispatch_at_directive` returns `0` unless the current substring begins with `@`; in the `@` case, it advances by 7 bytes and dispatches through a FAR thunk (`0000:ffff`). ### Raw 000e RIFF/Animation Cluster @@ -99,9 +120,10 @@ The `000e:` segment contains a RIFF/AVI streaming animation subsystem. Animation | `000e:12f4` | `animation_advance_frame` | Fixed-point `0x1000` timer arithmetic; checks `+0xe4` (paused), advances ring buffer `+0x11b`/`+0x11f`/`+0x117`/`+0x123`; calls advance thunk | | `000e:103f` | `animation_tick` | Guard wrapper: checks `param_1+0xd4 != -1`, then calls `animation_advance_frame(param_1, 0)` | | `000e:06f7` | `anim_load_audio_frame` | Checks chunk tag == `0x62773130` (`"01wb"` = audio stream 1); computes ring buffer free space; copies chunk payload via `0x0000:ffff` thunk; increments subframe index at `+0xeef`; resets at subframe count `+0x1b3` | +| `000e:053d` | `anim_load_video_frame_wrapper` | Called once per subframe in `animation_start` immediately after `anim_load_audio_frame`; thin wrapper that forwards to `000e:ffb0` | **Unresolved callee:** -- `000e:053d` → `000e:ffb0` (thin wrapper, ffb0 decompiles garbled due to overlapping instructions at `000f:0085`/`000f:0086`). Likely handles video frame loading to pair with `anim_load_audio_frame`. Not renamed. +- `000e:ffb0` remains unresolved (decompiles garbled due to overlapping instructions at `000f:0085`/`000f:0086`). Current evidence from `animation_start` loop suggests this path is the video-side subframe loader paired with `anim_load_audio_frame`. **Constructor pattern (`000e:2777`, `000e:2860`, `000e:2969`):** All three follow the same layout: