mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 18:25:35 -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>
61 lines
1.3 KiB
C
61 lines
1.3 KiB
C
/* dma.h — PS1 DMA controller simulation (Phase 3).
|
|
*
|
|
* 7 DMA channels:
|
|
* Ch0: MDEC in 0x1F801080
|
|
* Ch1: MDEC out 0x1F801090
|
|
* Ch2: GPU 0x1F8010A0
|
|
* Ch3: CDROM 0x1F8010B0
|
|
* Ch4: SPU 0x1F8010C0
|
|
* Ch5: PIO 0x1F8010D0
|
|
* Ch6: OTC 0x1F8010E0
|
|
*
|
|
* Global:
|
|
* DPCR: 0x1F8010F0 (DMA control — enable bits per channel)
|
|
* DICR: 0x1F8010F4 (DMA interrupt control)
|
|
*/
|
|
|
|
#ifndef PSXRECOMP_V4_DMA_H
|
|
#define PSXRECOMP_V4_DMA_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
void dma_init(void);
|
|
uint32_t dma_read(uint32_t addr);
|
|
void dma_write(uint32_t addr, uint32_t val);
|
|
void dma_write_masked(uint32_t addr, uint32_t val, uint32_t mask);
|
|
uint32_t dma_get_dicr(void);
|
|
uint32_t dma_get_dpcr(void);
|
|
|
|
typedef struct DMATraceEntry {
|
|
uint64_t seq;
|
|
uint32_t frame;
|
|
uint32_t kind;
|
|
uint32_t channel;
|
|
uint32_t total_words;
|
|
uint32_t madr;
|
|
uint32_t bcr;
|
|
uint32_t chcr;
|
|
uint32_t dpcr;
|
|
uint32_t dicr_before;
|
|
uint32_t dicr_after;
|
|
uint32_t i_stat_before;
|
|
uint32_t i_stat_after;
|
|
uint32_t func;
|
|
uint32_t pc;
|
|
} DMATraceEntry;
|
|
|
|
#define DMA_TRACE_CAP (1 << 14)
|
|
|
|
uint64_t dma_debug_get_trace(const DMATraceEntry** out_entries);
|
|
void dma_debug_clear_trace(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* PSXRECOMP_V4_DMA_H */
|