Skip to content

Commit 2c20be7

Browse files
committed
Update CLAUDE.md with C89 rules, testing, and CD docs
Add C Language Standard section documenting the C89/GNU89 requirement and local lint command. Update stale "no test suite" line, add Jaguar CD, Testing, and expanded Key Directories sections. Made-with: Cursor
1 parent 8e63cd1 commit 2c20be7

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

CLAUDE.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,28 @@ Output binary name varies by platform:
2020
- Linux: `virtualjaguar_libretro.so`
2121
- Windows: `virtualjaguar_libretro.dll`
2222

23-
There is no test suite. CI runs `make -j4` on Ubuntu (GCC) and macOS (Clang).
23+
CI runs `make -j4` on Ubuntu (GCC) and macOS (Clang), plus screenshot regression tests via `test/regression_test.sh`. See `docs/test-infrastructure.md` for the full test harness inventory.
2424

2525
## Architecture
2626

27+
### C Language Standard — C89/GNU89
28+
29+
This codebase **must** compile as C89 (GNU89 dialect). The libretro buildbot uses MSVC on Windows, which enforces C89 strictly. CI includes a `c89-lint` job that catches violations.
30+
31+
**Rules:**
32+
- **No mid-block variable declarations.** All variables must be declared at the top of their enclosing block (function or `{}`), before any statements. This is the most common violation.
33+
- `//` comments are allowed (GNU89 extension), but `/* */` is preferred for new code.
34+
- No C99 features: no `for (int i = ...)`, no compound literals, no designated initializers, no VLAs.
35+
- SIMD files (`src/blitter_simd_sse2.c`, `src/blitter_simd_neon.c`) are exempt from the lint check since they require platform-specific headers.
36+
- Machine-generated files (`src/m68000/*`) are also exempt.
37+
38+
**Local check before pushing:**
39+
```bash
40+
gcc -fsyntax-only -std=gnu89 -Werror=declaration-after-statement \
41+
-I. -Isrc -Isrc/m68000 -Ilibretro-common/include \
42+
-D__LIBRETRO__ -DINLINE="inline" src/YOURFILE.c
43+
```
44+
2745
### Atari Jaguar Hardware Emulation
2846

2947
The Jaguar has four processors sharing a unified memory-mapped address space:
@@ -56,12 +74,30 @@ Core options defined in `libretro_core_options.h` control blitter mode, BIOS usa
5674
- `src/` — emulator core (hardware chips, CPU, I/O, BIOS ROMs as C arrays)
5775
- `src/m68000/` — UAE-derived 68K CPU emulation
5876
- `libretro-common/` — shared libretro utility library (string, file, VFS)
59-
- `docs/` — original Virtual Jaguar documentation, changelog, known issues
77+
- `docs/` — documentation: changelog, known issues, BUTCH register map, CD data flow, test infrastructure
78+
- `test/tools` — test scripts and headless front-ends
79+
- `test/roms` — test ROMs; `private/` subdirectory has commercial ROMs and BIOSes
6080

6181
### Build System
6282

6383
`Makefile` handles 30+ platform targets with auto-detection. `Makefile.common` lists all source files. Platform is selected via `platform=` variable or auto-detected from `uname`. Key flags: `-D__LIBRETRO__`, `-DMSB_FIRST` for big-endian platforms.
6484

85+
### Jaguar CD Emulation
86+
87+
CD support is implemented across `src/cdrom.c` (BUTCH chip / FIFO / DSA commands), `src/cdintf.c` (disc image loading: CUE/BIN, CHD, CDI), and hooks in `src/jaguar.c` (BIOS auth bypass, boot stub injection).
88+
89+
Key docs:
90+
- `docs/butch-registers.md` — full BUTCH register map ($DFFF00-$DFFF2F) with bit definitions
91+
- `docs/cd-data-flow.md` — how CD data moves from disc to RAM (I2S -> FIFO -> GPU ISR -> RAM), BIOS code map, boot stub layout
92+
93+
### Testing
94+
95+
See `docs/test-infrastructure.md` for all test harnesses:
96+
- `test/headless.py` — Python headless runner via libretro.py (screenshots, frame control)
97+
- `test/regression_test.sh` — screenshot regression suite with baseline comparison
98+
- `test/test_cd_boot.c` — low-level C harness with dlsym access to 68K registers and RAM
99+
- `test/sram_test.sh` — SRAM interface round-trip testing
100+
65101
### Known Limitations
66102

67103
- Blitter not fully cycle-accurate (some games need fast blitter mode)

0 commit comments

Comments
 (0)