mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-27 18:52:11 -04:00
feat: add masked-u16 widescreen cull sites
Add a shared native/interpreter helper for sltiu classifiers operating on ANDI-masked 16-bit screen X values, preserving MIPS immediate sign extension and overlay linkage. Co-authored-by: Opok <novelasevilliousesp@gmail.com>
This commit is contained in:
@@ -834,6 +834,20 @@ std::string CodeGenerator::translate_instruction(uint32_t addr, uint32_t instr)
|
||||
}
|
||||
// overlay variant: addr is different code here — fall through to vanilla.
|
||||
}
|
||||
if (config_.ws_cull_vxrange_sites.count(addr)) {
|
||||
if (opcode == 0x0B) { // sltiu
|
||||
uint32_t rs = get_rs(instr), rt = get_rt(instr);
|
||||
uint16_t imm = get_imm16_u(instr);
|
||||
return fmt::format("{} = psx_ws_cull_vxrange({}, {});"
|
||||
" /* ws cull masked-u16 X window */{}",
|
||||
reg_name(rt), reg_name(rs), (unsigned)imm, comment);
|
||||
} else if (!config_.overlay_mode) {
|
||||
fmt::print(stderr, "ERROR: [widescreen.cull] vxrange site 0x{:08X} is not "
|
||||
"sltiu (opcode 0x{:02X})\n", addr, opcode);
|
||||
std::exit(1);
|
||||
}
|
||||
// Overlay variant at the same address: leave nonmatching code unchanged.
|
||||
}
|
||||
if (config_.ws_cull_range_sites.count(addr)) {
|
||||
if (opcode == 0x0B) { // sltiu
|
||||
uint32_t rs = get_rs(instr), rt = get_rt(instr);
|
||||
@@ -2603,6 +2617,7 @@ void CodeGenerator::emit_runtime_externs(std::ostream& ss) const {
|
||||
ss << "extern int psx_ws_cull_sltiu(uint32_t sx, uint32_t imm); /* ws auto screen-x cull (gpu.c) */\n";
|
||||
ss << "extern int psx_ws_cull_slti(uint32_t sx, uint32_t imm); /* ws cull signed right edge (gpu.c) */\n";
|
||||
ss << "extern int psx_ws_cull_bltz(uint32_t v); /* ws cull signed left edge (gpu.c) */\n";
|
||||
ss << "extern int psx_ws_cull_vxrange(uint32_t x, uint32_t imm); /* ws masked-u16 X window */\n";
|
||||
ss << "extern int psx_ws_backdrop_x(int x); /* widescreen backdrop screenX squash (gpu.c) */\n";
|
||||
ss << "extern int psx_ws_bg2d_cols(int base); /* ws 2D bg tile-loop widen: col count (gpu.c) */\n";
|
||||
ss << "extern int psx_ws_bg2d_startcol(int col, unsigned mask); /* ws 2D bg tile-loop widen: start tile col (gpu.c) */\n";
|
||||
|
||||
Reference in New Issue
Block a user