Salvage clean hardware sim from v2/v3: GTE, SW renderer, ISO reader, CRC32

Audited psxrecomp-v3 and psxrecomp-v2 hardware simulation files.
Carried forward only pure hardware simulation with zero HLE/BIOS
contamination. Each file was read in full and checked for:
- event_deliver / bios_ / interpreter_ references (none found)
- printf/fprintf (removed from GTE, none in others)
- stubs (return 0, TODO, FIXME) (none found)
- v3-specific state dependencies (removed psx_runtime.h, automation.h)

Added files:
- gte.cpp/h: COP2 coprocessor (876 lines, all GTE commands)
- gpu_sw_renderer.c/h: Software rasterizer with texture support (723 lines)
- crc32.c/h: CRC32 utility (27 lines)
- iso_reader.cpp/h + iso_reader_c.cpp: ISO 9660 reader (490 lines)

Modified:
- cpu_state.h: Added gte_data[32] and gte_ctrl[32] arrays
- CMakeLists.txt: Added new source files

Explicitly rejected (per CLAUDE.md rule 7):
- bios.c, events.c, threads.c, interpreter.c (HLE/kernel state)
- bios_trace.c, func_logger.c, main_runner.cpp (interpreter era)
- cdrom.c (has event_deliver + hard-coded RAM writes, needs surgery)
- spu.cpp from v2 (WinMM-only, needs SDL port)

Build verified: clean compile and link.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matthew Stanley
2026-04-12 20:57:41 -07:00
parent fba58d76b3
commit adaea3d8bf
11 changed files with 2514 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
/*
* iso_reader_c.cpp — C wrapper for the C++ ISOReader class
*
* Provides iso_open() / iso_read_sector() / iso_close() for use by cdrom.c
*/
#include "iso_reader.h"
#include <cstdio>
extern "C" {
void* iso_open(const char* path) {
auto* reader = new PS1::ISOReader();
if (!reader->Open(path)) {
delete reader;
return nullptr;
}
return reader;
}
int iso_read_sector(void* handle, uint32_t lba, uint8_t* buffer, int size) {
if (!handle) return 0;
auto* reader = static_cast<PS1::ISOReader*>(handle);
(void)size; /* ReadSector always reads 2048 bytes */
return reader->ReadSector(lba, buffer) ? 1 : 0;
}
void iso_close(void* handle) {
if (!handle) return;
auto* reader = static_cast<PS1::ISOReader*>(handle);
reader->Close();
delete reader;
}
} /* extern "C" */