mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 10:19:47 -04:00
cf05a0ab1f
Recompiler — `recompiler/src/function_analysis.cpp` now stops a function's end_addr at its mapped `jr $ra` + delay slot instead of stretching through trailing data. Fixes Tomba's 0x80076DB0, a real 136-byte function that was being emitted as a psx_unknown_dispatch stub because data after it poisoned the boundary heuristic. `code_generator.cpp` emits `func_<next>(cpu); return;` as a tail call when a mid-function seed split leaves the physical fall-through in a different C function, plus a `debug_server_log_call_entry` at every function entry. `full_function_emitter.cpp` splits dispatch into `psx_dispatch_impl(cpu, addr, stop_addr)` with public `psx_dispatch` and new `psx_dispatch_call(cpu, addr, return_addr)` so JAL/JALR into RAM stubs can return cleanly without growing the native stack. Runtime — `runtime/src/dma.c`/`include/dma.h`/`src/memory.c` now expose `dma_write_masked()`; the 16-bit and 8-bit mmio paths route DICR/DPCR/CHCR partial writes through it so a partial DICR write no longer accidentally clears unrelated channels' pending IRQ flags, and CHCR only triggers DMA when the written mask actually includes the start bit. Unified `complete_transfer(ch)` across all channels, removed `prev_master_flag` edge detection. MDEC (`runtime/src/mdec.c`, `include/mdec.h`) gains a full debug surface: `MDECDebugState` snapshot, an always-on 4096-entry `MDECDebugEvent` ring with 11 event kinds (reset, ctrl_write, cmd_begin/done, decode_done, dma_in/out start/end, output_drained, read_underflow), and `mdec_state` / `mdec_trace` / `mdec_trace_clear` debug-server commands. DMA ch0/1 emit start/end events around MDEC transfers. CDROM (`runtime/src/cdrom.c`, `include/cdrom.h`) — read stream separated from one-shot pending state (`read_cmd`, `read_delay`, `start_read_stream`, `stop_read_stream`, `deliver_read_sector`); `cdrom_state`/`cdrom_trace` report the new fields. Thread/fiber tracing — `traps.c`'s Win32-fiber TCB save/restore now emits 12 thread-event kinds; new `ThreadTraceEntry` ring (64 K) plus `thread_trace` / `thread_trace_clear` debug-server commands report both live CPU regs and the target TCB's full saved register block. wtrace / mmio rings — `WriteTraceEntry` grew (cpu_pc, sp, v0/v1/a0-a3/ t0/t1); capacity 1 M -> 4 M. `MmioTraceEntry` grew (pc, cpu_pc, sp, a0-a3, sr, epc, i_stat, i_mask). Both dump commands accept `count`/`newest=1` for reverse iteration. `restore_trace` and `dirty_block_log` emit extended register fields (a2/a3/sp). Misc — `interrupts.c` polls debug-server every 16K checks so it stays responsive without a separate thread. `psx_runtime.h`'s `call_by_address` routes through `psx_dispatch_call`. Dirty-RAM interp JAL/JALR consult `psx_dispatch_game_compiled` when the game is wired in. iso_reader gains the entry points needed by the game disc path. New `tools/_tomba_probe.py` for port-4470 health checks. Generated — regenerated `SCPH1001_dispatch.c` against the new `psx_dispatch_impl` shape. ISSUES.md — opened Issue #3 (BIOS PS-logo glyph missing on the disc-detected screen, cosmetic). .gitignore — added `recompiler/build-asan*/`, `build-checked/`, `__pycache__/`. Validated end-to-end: BIOS boots, disc detected, Whoopee Camp FMV plays with audio. Frame count advances through ~40K frames without freezes. `unknown_dispatch_log.total = 0`. Remaining FMV cluster issues (1/4-size render, FMV-2 audio missing, no skip) tracked under TombaRecomp/ISSUES.md. Co-Authored-By: Codex (OpenAI) <noreply@openai.com>
42 lines
1.0 KiB
C++
42 lines
1.0 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;
|
|
}
|
|
|
|
void iso_close(void* handle) {
|
|
if (!handle) return;
|
|
auto* reader = static_cast<PS1::ISOReader*>(handle);
|
|
reader->Close();
|
|
delete reader;
|
|
}
|
|
|
|
} /* extern "C" */
|