Files
psxrecomp/runtime/src/iso_reader_c.cpp
T
Matthew Stanley ec7e482691 Ape Escape support: framework WIP snapshot (safe haven)
Uncommitted framework work on codex/ape-escape-support reaching the
post-boot DualShock-required screen. Recompiler codegen (code_generator,
full_function_emitter, function_analysis, config_loader) + runtime
(cdrom, sio, dirty_ram_interp, dma, iso_reader, mdec, gpu, memory,
traps, debug_server, fntrace, freeze_heartbeat, psx_cycles) and headers.

Committed as a restore point before rebuilding Tomba against this
framework. Build dirs (recompiler/build-codex*) intentionally excluded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 12:48:38 -07:00

48 lines
1.2 KiB
C++

/*
* 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;
}
int iso_read_raw_sector(void* handle, uint32_t lba, uint8_t* buffer, int size) {
if (!handle || size < 2352) return 0;
auto* reader = static_cast<PS1::ISOReader*>(handle);
return reader->ReadRawSector(lba, buffer) ? 1 : 0;
}
uint32_t iso_sector_count(void* handle) {
if (!handle) return 0;
auto* reader = static_cast<PS1::ISOReader*>(handle);
return reader->GetSectorCount();
}
void iso_close(void* handle) {
if (!handle) return;
auto* reader = static_cast<PS1::ISOReader*>(handle);
reader->Close();
delete reader;
}
} /* extern "C" */