Implement state saving and loading for CPU and Bus, add tests for various functionalities

- Added `state.c` to handle saving and loading the state of the CPU and Bus.
- Implemented CRC32 checksum for data integrity verification during state operations.
- Enhanced `README.md` in tests/roms to document new test commands for decimal, interrupt, Apple I, and nestest.
- Created new test files: `run_apple1.c`, `run_decimal.c`, `run_interrupt.c`, `run_nestest.c`, and `run_vectors.c` to validate the new features.
- Updated `run_tests.c` to include tests for state saving/loading and other functionalities.
- Introduced `test_vectors.py` to facilitate downloading and running JSON test vectors for opcode verification.
This commit is contained in:
2026-07-20 13:55:48 +03:00
parent c6e1c5b3b5
commit 0dcd2ed687
29 changed files with 827 additions and 58 deletions
+21 -11
View File
@@ -7,23 +7,33 @@
- Binary and NMOS decimal ADC/SBC, status flags, stack, BRK/RTI, IRQ and NMI.
- All official addressing modes, zero-page wrap, page penalties and indirect-JMP bug.
- Instruction-level cycle accounting and deterministic illegal-opcode errors.
- Stable undocumented NMOS opcode families and multi-byte NOP encodings.
- Safe flat-binary loader, headless runner, optional SDL2 frontend.
- Versioned, endian-defined, CRC32-protected portable save states.
- Extensible bus device hooks and an Apple I terminal/PIA target.
- NES Ricoh 2A03 mode, iNES mappers 0/2/3, PPU register/timing model, controller,
scrolling, masks, 8x8/8x16 sprites, sprite status, pulse/triangle/noise audio,
SDL frontend, and full 8,991-line nestest match.
- Original ca65 Snake game with pause, persistent high score, and a reproducible `make snake` target.
- Strict debug, sanitizer and dependency-free test targets.
## Remaining hardening
## Validation
1. Run the Klaus Dormann decimal suite and fix any discovered edge cases.
2. Expand table-driven tests to cover every official opcode/address-mode pairing.
3. Add a trace/disassembler runner for diagnosing external ROM failures.
- 2,360,000 independent SingleStepTests cases cover every implemented official
and stable undocumented opcode, final CPU/RAM state, and instruction cycles.
- The interactive debugger supports stepping, continue, breakpoints, register and
memory inspection/editing, disassembly, and portable save/load.
The official Klaus Dormann functional suite passes at `$3469` after 30,646,176
instructions. Linux CI covers strict, sanitizer, functional-ROM, Snake, and SDL
UI builds.
instructions. Linux CI covers strict, sanitizer, all external CPU/platform suites,
the complete single-step corpus, Snake, and SDL UI builds.
## Future platforms
Bruce Clark's exhaustive NMOS decimal suite passes all 131,072 operand/carry
combinations, including invalid BCD digits. Klaus Dormann's interrupt suite
passes IRQ, NMI, BRK, vector, flag, and concurrent-interrupt checks.
- Undocumented NMOS opcodes.
- Audio, save states and an interactive debugger.
- A real historical machine such as Apple I or NES. NES support is a separate major
project requiring the PPU, APU, controllers, cartridge parsing/mappers and tighter timing.
## Explicit compatibility boundary
The NES frontend is a useful first-generation NES subsystem, not a claim of full
commercial-library compatibility. Mappers other than 0, 2, and 3, DMC audio,
cycle-by-cycle PPU bus effects, and mapper IRQs remain outside its stated scope.