#define A_CD_EVENTS 0xb9b8
#define A_EXC_GP 0xf450
+#define A_A0_DUMMY 0x1010
+#define A_B0_DUMMY 0x2010
+#define A_C0_DUMMY 0x3010
+#define A_B0_5B_DUMMY 0x43d0
+
#define HLEOP(n) SWAPu32((0x3b << 26) | (n));
static u32 loadRam32(u32 addr)
static void psxBios_printf_psxout() { // 0x3f
char tmp[1024];
char tmp2[1024];
- u32 save[4];
+ u32 save[4] = { 0, };
char *ptmp = tmp;
int n=1, i=0, j;
void *psp;
SPU_writeRegister(0x1f801d80 + i*2, spu_config[i], psxRegs.cycle);
}
+static void hleExc0_0_1();
+static void hleExc0_0_2();
+static void hleExc0_1_1();
+static void hleExc0_1_2();
+
#include "sjisfont.h"
void psxBiosInit() {
// (or rather the funcs listed there)
ptr = (u32 *)&psxM[A_A0_TABLE];
for (i = 0; i < 256; i++)
- ptr[i] = SWAP32(0x1000);
+ ptr[i] = SWAP32(A_A0_DUMMY);
ptr = (u32 *)&psxM[A_B0_TABLE];
for (i = 0; i < 256; i++)
- ptr[i] = SWAP32(0x2000);
+ ptr[i] = SWAP32(A_B0_DUMMY);
// B(5b) is special because games patch (sometimes even jump to)
// code at fixed offsets from it, nocash lists offsets:
// patch: +3d8, +4dc, +594, +62c, +9c8, +1988
// call: +7a0=4b70, +884=4c54, +894=4c64
- ptr[0x5b] = SWAP32(0x43d0);
+ ptr[0x5b] = SWAP32(A_B0_5B_DUMMY); // 0x43d0
ram32[0x4b70/4] = SWAP32(0x03e00008); // jr $ra // setPadOutputBuf
ram32[0x4c54/4] = SWAP32(0x240e0001); // mov $t6, 1
ptr = (u32 *)&psxM[A_C0_TABLE];
for (i = 0; i < 256/2; i++)
- ptr[i] = SWAP32(0x3000);
+ ptr[i] = SWAP32(A_C0_DUMMY);
ptr[6] = SWAP32(A_EXCEPTION);
// more HLE traps
- ram32[0x1000/4] = HLEOP(hleop_dummy);
- ram32[0x2000/4] = HLEOP(hleop_dummy);
- ram32[0x3000/4] = HLEOP(hleop_dummy);
+ ram32[A_A0_DUMMY/4] = HLEOP(hleop_dummy);
+ ram32[A_B0_DUMMY/4] = HLEOP(hleop_dummy);
+ ram32[A_C0_DUMMY/4] = HLEOP(hleop_dummy);
+ ram32[A_B0_5B_DUMMY/4] = HLEOP(hleop_dummy);
ram32[0x8000/4] = HLEOP(hleop_execret);
ram32[A_EEXIT_PTR/4] = SWAP32(A_EEXIT_DEF);
// hleExc0_{0,1}* are usually removed by A(56)/A(72) on the game's startup,
// so this is only partially implemented
-void hleExc0_0_1() // A(93h) - CdromDmaIrqFunc2
+static void hleExc0_0_1() // A(93h) - CdromDmaIrqFunc2
{
u32 cdrom_dma_ack_enable = 1; // a000b93c
handle_chain_x_x_1(cdrom_dma_ack_enable, 3); // IRQ3 DMA
}
-void hleExc0_0_2() // A(91h) - CdromDmaIrqFunc1
+static void hleExc0_0_2() // A(91h) - CdromDmaIrqFunc1
{
u32 ret = 0;
//PSXBIOS_LOG("%s\n", __func__);
mips_return_c(ret, 20);
}
-void hleExc0_1_1() // A(92h) - CdromIoIrqFunc2
+static void hleExc0_1_1() // A(92h) - CdromIoIrqFunc2
{
u32 cdrom_irq_ack_enable = 1; // a000b938
handle_chain_x_x_1(cdrom_irq_ack_enable, 2); // IRQ2 cdrom
}
-void hleExc0_1_2() // A(90h) - CdromIoIrqFunc1
+static void hleExc0_1_2() // A(90h) - CdromIoIrqFunc1
{
u32 ret = 0;
if (psxHu32(0x1074) & psxHu32(0x1070) & 4) { // IRQ2 cdrom
mips_return_c(ret, 20);
}
-void hleExc0_2_2_syscall() // not in any A/B/C table
+static void hleExc0_2_2_syscall() // not in any A/B/C table
{
u32 tcbPtr = loadRam32(A_TT_PCB);
TCB *tcb = loadRam32ptr(tcbPtr);
psxBios_ReturnFromException();
}
-void hleExc1_0_1(void)
+static void hleExc1_0_1(void)
{
u32 vbl_irq_ack_enable = loadRam32(A_RCNT_VBL_ACK + 0x0c); // 860c
handle_chain_x_x_1(vbl_irq_ack_enable, 0); // IRQ0 vblank
mips_return_c(ret, 22);
}
-void hleExc1_0_2(void)
+static void hleExc1_0_2(void)
{
handle_chain_1_x_2(3, 0); // IRQ0 vblank
}
-void hleExc1_1_1(void)
+static void hleExc1_1_1(void)
{
u32 rcnt_irq_ack_enable = loadRam32(A_RCNT_VBL_ACK + 0x08); // 8608
handle_chain_x_x_1(rcnt_irq_ack_enable, 6); // IRQ6 rcnt2
}
-void hleExc1_1_2(void)
+static void hleExc1_1_2(void)
{
handle_chain_1_x_2(2, 6); // IRQ6 rcnt2
}
-void hleExc1_2_1(void)
+static void hleExc1_2_1(void)
{
u32 rcnt_irq_ack_enable = loadRam32(A_RCNT_VBL_ACK + 0x04); // 8604
handle_chain_x_x_1(rcnt_irq_ack_enable, 5); // IRQ5 rcnt1
}
-void hleExc1_2_2(void)
+static void hleExc1_2_2(void)
{
handle_chain_1_x_2(1, 5); // IRQ5 rcnt1
}
-void hleExc1_3_1(void)
+static void hleExc1_3_1(void)
{
u32 rcnt_irq_ack_enable = loadRam32(A_RCNT_VBL_ACK + 0x00); // 8600
handle_chain_x_x_1(rcnt_irq_ack_enable, 4); // IRQ4 rcnt0
}
-void hleExc1_3_2(void)
+static void hleExc1_3_2(void)
{
handle_chain_1_x_2(0, 4); // IRQ4 rcnt0
}
-void hleExc3_0_2_defint(void)
+static void hleExc3_0_2_defint(void)
{
static const struct {
u8 ev, irqbit;
mips_return_c(0, 11 + 7*11 + 7*11 + 12);
}
-void hleExcPadCard1(void)
+static void hleExcPadCard1(void)
{
if (loadRam32(A_PAD_IRQR_ENA)) {
u8 *pad_buf1 = loadRam8ptr(A_PAD_INBUF + 0);
mips_return_c(0, 18);
}
-void hleExcPadCard2(void)
+static void hleExcPadCard2(void)
{
u32 ret = psxHu32(0x1074) & psxHu32(0x1070) & 1;
mips_return_c(ret, 15);
psxBios_ReturnFromException();
}
+/* HLE */
+static void hleDummy() {
+ log_unhandled("hleDummy called @%08x ra=%08x\n", psxRegs.pc - 4, ra);
+ psxRegs.pc = ra;
+ psxRegs.cycle += 1000;
+
+ psxBranchTest();
+}
+
+static void hleA0() {
+ u32 call = t1 & 0xff;
+ u32 entry = loadRam32(A_A0_TABLE + call * 4);
+
+ if (call < 192 && entry != A_A0_DUMMY) {
+ PSXBIOS_LOG("custom A%02x %s(0x%x, ) addr=%08x ra=%08x\n",
+ call, biosA0n[call], a0, entry, ra);
+ softCall(entry);
+ pc0 = ra;
+ PSXBIOS_LOG(" -> %08x\n", v0);
+ }
+ else if (biosA0[call])
+ biosA0[call]();
+
+ psxBranchTest();
+}
+
+static void hleB0() {
+ u32 call = t1 & 0xff;
+ u32 entry = loadRam32(A_B0_TABLE + call * 4);
+ int is_custom = 0;
+
+ if (call == 0x5b)
+ is_custom = entry != A_B0_5B_DUMMY;
+ else
+ is_custom = entry != A_B0_DUMMY;
+ if (is_custom) {
+ PSXBIOS_LOG("custom B%02x %s(0x%x, ) addr=%08x ra=%08x\n",
+ call, biosB0n[call], a0, entry, ra);
+ softCall(entry);
+ pc0 = ra;
+ PSXBIOS_LOG(" -> %08x\n", v0);
+ }
+ else if (biosB0[call])
+ biosB0[call]();
+
+ psxBranchTest();
+}
+
+static void hleC0() {
+ u32 call = t1 & 0xff;
+ u32 entry = loadRam32(A_C0_TABLE + call * 4);
+
+ if (call < 128 && entry != A_C0_DUMMY) {
+ PSXBIOS_LOG("custom C%02x %s(0x%x, ) addr=%08x ra=%08x\n",
+ call, biosC0n[call], a0, entry, ra);
+ softCall(entry);
+ pc0 = ra;
+ PSXBIOS_LOG(" -> %08x\n", v0);
+ }
+ else if (biosC0[call])
+ biosC0[call]();
+
+ psxBranchTest();
+}
+
+// currently not used
+static void hleBootstrap() {
+ CheckCdrom();
+ LoadCdrom();
+}
+
+static void hleExecRet() {
+ const EXEC *header = (EXEC *)PSXM(s0);
+
+ PSXBIOS_LOG("ExecRet %x: %x\n", s0, header->ret);
+
+ ra = SWAP32(header->ret);
+ sp = SWAP32(header->_sp);
+ fp = SWAP32(header->_fp);
+ gp = SWAP32(header->_gp);
+ s0 = SWAP32(header->base);
+
+ v0 = 1;
+ psxRegs.pc = ra;
+}
+
+void (* const psxHLEt[24])() = {
+ hleDummy, hleA0, hleB0, hleC0,
+ hleBootstrap, hleExecRet, psxBiosException, hleDummy,
+ hleExc0_0_1, hleExc0_0_2,
+ hleExc0_1_1, hleExc0_1_2, hleExc0_2_2_syscall,
+ hleExc1_0_1, hleExc1_0_2,
+ hleExc1_1_1, hleExc1_1_2,
+ hleExc1_2_1, hleExc1_2_2,
+ hleExc1_3_1, hleExc1_3_2,
+ hleExc3_0_2_defint,
+ hleExcPadCard1, hleExcPadCard2,
+};
+
+
#define bfreeze(ptr, size) { \
if (Mode == 1) memcpy(&psxR[base], ptr, size); \
if (Mode == 0) memcpy(ptr, &psxR[base], size); \
+++ /dev/null
-/***************************************************************************
- * Copyright (C) 2007 Ryan Schultz, PCSX-df Team, PCSX team *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA. *
- ***************************************************************************/
-
-/*
-* Internal PSX HLE functions.
-*/
-
-#include "psxhle.h"
-
-#if 0
-#define PSXHLE_LOG SysPrintf
-#else
-#define PSXHLE_LOG(...)
-#endif
-
-static void hleDummy() {
- log_unhandled("hleDummy called @%08x ra=%08x\n",
- psxRegs.pc - 4, psxRegs.GPR.n.ra);
- psxRegs.pc = psxRegs.GPR.n.ra;
- psxRegs.cycle += 1000;
-
- psxBranchTest();
-}
-
-static void hleA0() {
- u32 call = psxRegs.GPR.n.t1 & 0xff;
-
- if (biosA0[call]) biosA0[call]();
-
- psxBranchTest();
-}
-
-static void hleB0() {
- u32 call = psxRegs.GPR.n.t1 & 0xff;
-
- if (biosB0[call]) biosB0[call]();
-
- psxBranchTest();
-}
-
-static void hleC0() {
- u32 call = psxRegs.GPR.n.t1 & 0xff;
-
- if (biosC0[call]) biosC0[call]();
-
- psxBranchTest();
-}
-
-static void hleBootstrap() { // 0xbfc00000
- PSXHLE_LOG("hleBootstrap\n");
- CheckCdrom();
- LoadCdrom();
- PSXHLE_LOG("CdromLabel: \"%s\": PC = %8.8lx (SP = %8.8lx)\n", CdromLabel, psxRegs.pc, psxRegs.GPR.n.sp);
-}
-
-typedef struct {
- u32 _pc0;
- u32 gp0;
- u32 t_addr;
- u32 t_size;
- u32 d_addr;
- u32 d_size;
- u32 b_addr;
- u32 b_size;
- u32 S_addr;
- u32 s_size;
- u32 _sp,_fp,_gp,ret,base;
-} EXEC;
-
-static void hleExecRet() {
- EXEC *header = (EXEC*)PSXM(psxRegs.GPR.n.s0);
-
- PSXHLE_LOG("ExecRet %x: %x\n", psxRegs.GPR.n.s0, header->ret);
-
- psxRegs.GPR.n.ra = SWAP32(header->ret);
- psxRegs.GPR.n.sp = SWAP32(header->_sp);
- psxRegs.GPR.n.fp = SWAP32(header->_fp);
- psxRegs.GPR.n.gp = SWAP32(header->_gp);
- psxRegs.GPR.n.s0 = SWAP32(header->base);
-
- psxRegs.GPR.n.v0 = 1;
- psxRegs.pc = psxRegs.GPR.n.ra;
-}
-
-void (* const psxHLEt[24])() = {
- hleDummy, hleA0, hleB0, hleC0,
- hleBootstrap, hleExecRet, psxBiosException, hleDummy,
- hleExc0_0_1, hleExc0_0_2,
- hleExc0_1_1, hleExc0_1_2, hleExc0_2_2_syscall,
- hleExc1_0_1, hleExc1_0_2,
- hleExc1_1_1, hleExc1_1_2,
- hleExc1_2_1, hleExc1_2_2,
- hleExc1_3_1, hleExc1_3_2,
- hleExc3_0_2_defint,
- hleExcPadCard1, hleExcPadCard2,
-};