mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
32x: interpreter-wrap drc works (demos only). SVP drc refactoring.
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@812 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
98da48e418
commit
679af8a3f4
19 changed files with 1505 additions and 46 deletions
|
@ -38,6 +38,7 @@ void Pico32xStartup(void)
|
|||
{
|
||||
elprintf(EL_STATUS|EL_32X, "32X startup");
|
||||
|
||||
// TODO: OOM handling
|
||||
PicoAHW |= PAHW_32X;
|
||||
sh2_init(&msh2, 0);
|
||||
msh2.irq_callback = sh2_irq_cb;
|
||||
|
|
|
@ -7,7 +7,13 @@
|
|||
#include "../../../cpu/drc/cmn.h"
|
||||
#include "compiler.h"
|
||||
|
||||
#define u32 unsigned int
|
||||
// FIXME: asm has these hardcoded
|
||||
#define SSP_BLOCKTAB_ENTS (0x5090/2)
|
||||
#define SSP_BLOCKTAB_IRAM_ONE (0x800/2) // table entries
|
||||
#define SSP_BLOCKTAB_IRAM_ENTS (15*SSP_BLOCKTAB_IRAM_ONE)
|
||||
|
||||
static u32 **ssp_block_table; // [0x5090/2];
|
||||
static u32 **ssp_block_table_iram; // [15][0x800/2];
|
||||
|
||||
static u32 *tcache_ptr = NULL;
|
||||
|
||||
|
@ -23,7 +29,7 @@ extern ssp1601_t *ssp;
|
|||
#define SSP_FLAG_N (1<<0xf)
|
||||
|
||||
#ifndef ARM
|
||||
#define DUMP_BLOCK 0x0c9a
|
||||
//#define DUMP_BLOCK 0x0c9a
|
||||
void ssp_drc_next(void){}
|
||||
void ssp_drc_next_patch(void){}
|
||||
void ssp_drc_end(void){}
|
||||
|
@ -1677,7 +1683,9 @@ static void emit_block_epilogue(int cycles, int cond, int pc, int end_pc)
|
|||
emit_jump(A_COND_AL, ssp_drc_next);
|
||||
}
|
||||
else if (cond == A_COND_AL) {
|
||||
u32 *target = (pc < 0x400) ? ssp_block_table_iram[ssp->drc.iram_context][pc] : ssp_block_table[pc];
|
||||
u32 *target = (pc < 0x400) ?
|
||||
ssp_block_table_iram[ssp->drc.iram_context * SSP_BLOCKTAB_IRAM_ONE + pc] :
|
||||
ssp_block_table[pc];
|
||||
if (target != NULL)
|
||||
emit_jump(A_COND_AL, target);
|
||||
else {
|
||||
|
@ -1687,8 +1695,12 @@ static void emit_block_epilogue(int cycles, int cond, int pc, int end_pc)
|
|||
}
|
||||
}
|
||||
else {
|
||||
u32 *target1 = (pc < 0x400) ? ssp_block_table_iram[ssp->drc.iram_context][pc] : ssp_block_table[pc];
|
||||
u32 *target2 = (end_pc < 0x400) ? ssp_block_table_iram[ssp->drc.iram_context][end_pc] : ssp_block_table[end_pc];
|
||||
u32 *target1 = (pc < 0x400) ?
|
||||
ssp_block_table_iram[ssp->drc.iram_context * SSP_BLOCKTAB_IRAM_ONE + pc] :
|
||||
ssp_block_table[pc];
|
||||
u32 *target2 = (end_pc < 0x400) ?
|
||||
ssp_block_table_iram[ssp->drc.iram_context * SSP_BLOCKTAB_IRAM_ONE + end_pc] :
|
||||
ssp_block_table[end_pc];
|
||||
if (target1 != NULL)
|
||||
emit_jump(cond, target1);
|
||||
if (target2 != NULL)
|
||||
|
@ -1754,7 +1766,7 @@ void *ssp_translate_block(int pc)
|
|||
tr_flush_dirty_pmcrs();
|
||||
emit_block_epilogue(ccount, end_cond, jump_pc, pc);
|
||||
|
||||
if (tcache_ptr - tcache > SSP_TCACHE_SIZE/4) {
|
||||
if (tcache_ptr - tcache > DRC_TCACHE_SIZE/4) {
|
||||
elprintf(EL_ANOMALY|EL_STATUS|EL_SVP, "tcache overflow!\n");
|
||||
fflush(stdout);
|
||||
exit(1);
|
||||
|
@ -1790,13 +1802,29 @@ static void ssp1601_state_load(void)
|
|||
ssp->drc.iram_context = 0;
|
||||
}
|
||||
|
||||
void ssp1601_dyn_exit(void)
|
||||
{
|
||||
free(ssp_block_table);
|
||||
free(ssp_block_table_iram);
|
||||
ssp_block_table = ssp_block_table_iram = NULL;
|
||||
|
||||
drc_cmn_cleanup();
|
||||
}
|
||||
|
||||
int ssp1601_dyn_startup(void)
|
||||
{
|
||||
drc_cmn_init();
|
||||
|
||||
memset(tcache, 0, SSP_TCACHE_SIZE);
|
||||
memset(ssp_block_table, 0, sizeof(ssp_block_table));
|
||||
memset(ssp_block_table_iram, 0, sizeof(ssp_block_table_iram));
|
||||
ssp_block_table = calloc(sizeof(ssp_block_table[0]), SSP_BLOCKTAB_ENTS);
|
||||
if (ssp_block_table == NULL)
|
||||
return -1;
|
||||
ssp_block_table_iram = calloc(sizeof(ssp_block_table_iram[0]), SSP_BLOCKTAB_IRAM_ENTS);
|
||||
if (ssp_block_table_iram == NULL) {
|
||||
free(ssp_block_table);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(tcache, 0, DRC_TCACHE_SIZE);
|
||||
tcache_ptr = tcache;
|
||||
|
||||
PicoLoadStateHook = ssp1601_state_load;
|
||||
|
@ -1806,12 +1834,12 @@ int ssp1601_dyn_startup(void)
|
|||
// hle'd blocks
|
||||
ssp_block_table[0x800/2] = (void *) ssp_hle_800;
|
||||
ssp_block_table[0x902/2] = (void *) ssp_hle_902;
|
||||
ssp_block_table_iram[ 7][0x030/2] = (void *) ssp_hle_07_030;
|
||||
ssp_block_table_iram[ 7][0x036/2] = (void *) ssp_hle_07_036;
|
||||
ssp_block_table_iram[ 7][0x6d6/2] = (void *) ssp_hle_07_6d6;
|
||||
ssp_block_table_iram[11][0x12c/2] = (void *) ssp_hle_11_12c;
|
||||
ssp_block_table_iram[11][0x384/2] = (void *) ssp_hle_11_384;
|
||||
ssp_block_table_iram[11][0x38a/2] = (void *) ssp_hle_11_38a;
|
||||
ssp_block_table_iram[ 7 * SSP_BLOCKTAB_IRAM_ENTS + 0x030/2] = (void *) ssp_hle_07_030;
|
||||
ssp_block_table_iram[ 7 * SSP_BLOCKTAB_IRAM_ENTS + 0x036/2] = (void *) ssp_hle_07_036;
|
||||
ssp_block_table_iram[ 7 * SSP_BLOCKTAB_IRAM_ENTS + 0x6d6/2] = (void *) ssp_hle_07_6d6;
|
||||
ssp_block_table_iram[11 * SSP_BLOCKTAB_IRAM_ENTS + 0x12c/2] = (void *) ssp_hle_11_12c;
|
||||
ssp_block_table_iram[11 * SSP_BLOCKTAB_IRAM_ENTS + 0x384/2] = (void *) ssp_hle_11_384;
|
||||
ssp_block_table_iram[11 * SSP_BLOCKTAB_IRAM_ENTS + 0x38a/2] = (void *) ssp_hle_11_38a;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -13,6 +13,7 @@ void ssp_hle_11_384(void);
|
|||
void ssp_hle_11_38a(void);
|
||||
|
||||
int ssp1601_dyn_startup(void);
|
||||
void ssp1601_dyn_exit(void);
|
||||
void ssp1601_dyn_reset(ssp1601_t *ssp);
|
||||
void ssp1601_dyn_run(int cycles);
|
||||
|
||||
|
|
|
@ -99,6 +99,13 @@ void PicoSVPInit(void)
|
|||
{
|
||||
}
|
||||
|
||||
static void PicoSVPExit(void)
|
||||
{
|
||||
#ifndef PSP
|
||||
ssp1601_dyn_exit();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PicoSVPStartup(void)
|
||||
{
|
||||
|
@ -133,6 +140,7 @@ void PicoSVPStartup(void)
|
|||
PicoDmaHook = PicoSVPDma;
|
||||
PicoResetHook = PicoSVPReset;
|
||||
PicoLineHook = PicoSVPLine;
|
||||
PicoCartUnloadHook = PicoSVPExit;
|
||||
|
||||
// save state stuff
|
||||
svp_states[0].ptr = svp->iram_rom;
|
||||
|
|
|
@ -243,10 +243,19 @@ extern SH2 sh2s[2];
|
|||
#define msh2 sh2s[0]
|
||||
#define ssh2 sh2s[1]
|
||||
|
||||
#define ash2_end_run(after) if (sh2->icount > (after)) sh2->icount = after
|
||||
#define ash2_cycles_done() (sh2->cycles_aim - sh2->icount)
|
||||
#ifndef DRC_SH2
|
||||
# define ash2_end_run(after) if (sh2->icount > (after)) sh2->icount = after
|
||||
# define ash2_cycles_done() (sh2->cycles_aim - sh2->icount)
|
||||
#else
|
||||
# define ash2_end_run(after) { \
|
||||
if ((sh2->sr >> 12) > (after)) \
|
||||
{ sh2->sr &= 0xfff; sh2->sr |= (after) << 12; } \
|
||||
}
|
||||
# define ash2_cycles_done() (sh2->cycles_aim - (sh2->sr >> 12))
|
||||
#endif
|
||||
|
||||
#define sh2_pc(c) (c) ? ssh2.ppc : msh2.ppc
|
||||
//#define sh2_pc(c) (c) ? ssh2.ppc : msh2.ppc
|
||||
#define sh2_pc(c) (c) ? ssh2.pc : msh2.pc
|
||||
#define sh2_reg(c, x) (c) ? ssh2.r[x] : msh2.r[x]
|
||||
#define sh2_gbr(c) (c) ? ssh2.gbr : msh2.gbr
|
||||
#define sh2_vbr(c) (c) ? ssh2.vbr : msh2.vbr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue