mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
FAME integration finished, some adjustments of CPU core stuff
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@278 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
9112b6ce9f
commit
3aa1e148a2
18 changed files with 398 additions and 8706 deletions
98
Pico/Sek.c
98
Pico/Sek.c
|
@ -18,15 +18,15 @@ unsigned int SekCycleCntT=0;
|
|||
/* context */
|
||||
// Cyclone 68000
|
||||
#ifdef EMU_C68K
|
||||
struct Cyclone PicoCpu;
|
||||
struct Cyclone PicoCpuCM68k;
|
||||
#endif
|
||||
// MUSASHI 68000
|
||||
#ifdef EMU_M68K
|
||||
m68ki_cpu_core PicoM68kCPU;
|
||||
m68ki_cpu_core PicoCpuMM68k;
|
||||
#endif
|
||||
// FAME 68000
|
||||
#ifdef EMU_F68K
|
||||
M68K_CONTEXT PicoCpuM68k;
|
||||
M68K_CONTEXT PicoCpuFM68k;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -38,7 +38,7 @@ static int SekIntAck(int level)
|
|||
// try to emulate VDP's reaction to 68000 int ack
|
||||
if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); }
|
||||
else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); }
|
||||
PicoCpu.irq = 0;
|
||||
PicoCpuCM68k.irq = 0;
|
||||
return CYCLONE_INT_ACK_AUTOVECTOR;
|
||||
}
|
||||
|
||||
|
@ -51,12 +51,12 @@ static int SekUnrecognizedOpcode()
|
|||
{
|
||||
unsigned int pc, op;
|
||||
pc = SekPc;
|
||||
op = PicoCpu.read16(pc);
|
||||
op = PicoCpuCM68k.read16(pc);
|
||||
elprintf(EL_ANOMALY, "Unrecognized Opcode %04x @ %06x", op, pc);
|
||||
// see if we are not executing trash
|
||||
if (pc < 0x200 || (pc > Pico.romsize+4 && (pc&0xe00000)!=0xe00000)) {
|
||||
PicoCpu.cycles = 0;
|
||||
PicoCpu.state_flags |= 1;
|
||||
PicoCpuCM68k.cycles = 0;
|
||||
PicoCpuCM68k.state_flags |= 1;
|
||||
return 1;
|
||||
}
|
||||
#ifdef EMU_M68K // debugging cyclone
|
||||
|
@ -87,31 +87,11 @@ static int SekTasCallback(void)
|
|||
|
||||
|
||||
#ifdef EMU_F68K
|
||||
static void setup_fame_fetchmap(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
// be default, point everything to fitst 64k of ROM
|
||||
for (i = 0; i < M68K_FETCHBANK1; i++)
|
||||
PicoCpuM68k.Fetch[i] = (unsigned int)Pico.rom - (i<<(24-FAMEC_FETCHBITS));
|
||||
// now real ROM
|
||||
for (i = 0; i < M68K_FETCHBANK1 && (i<<(24-FAMEC_FETCHBITS)) < Pico.romsize; i++)
|
||||
PicoCpuM68k.Fetch[i] = (unsigned int)Pico.rom;
|
||||
elprintf(EL_ANOMALY, "ROM end @ #%i %06x", i, (i<<(24-FAMEC_FETCHBITS)));
|
||||
// .. and RAM (TODO)
|
||||
for (i = M68K_FETCHBANK1*14/16; i < M68K_FETCHBANK1; i++)
|
||||
PicoCpuM68k.Fetch[i] = (unsigned int)Pico.ram - (i<<(24-FAMEC_FETCHBITS));
|
||||
|
||||
elprintf(EL_ANOMALY, "rom = %p, ram = %p", Pico.rom, Pico.ram);
|
||||
for (i = 0; i < M68K_FETCHBANK1; i++)
|
||||
elprintf(EL_ANOMALY, "Fetch[%i] = %p", i, PicoCpuM68k.Fetch[i]);
|
||||
}
|
||||
|
||||
void SekIntAckF68K(unsigned level)
|
||||
static void SekIntAckF68K(unsigned level)
|
||||
{
|
||||
if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); }
|
||||
else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); }
|
||||
PicoCpuM68k.interrupts[0] = 0;
|
||||
PicoCpuFM68k.interrupts[0] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -120,15 +100,15 @@ PICO_INTERNAL int SekInit()
|
|||
{
|
||||
#ifdef EMU_C68K
|
||||
CycloneInit();
|
||||
memset(&PicoCpu,0,sizeof(PicoCpu));
|
||||
PicoCpu.IrqCallback=SekIntAck;
|
||||
PicoCpu.ResetCallback=SekResetAck;
|
||||
PicoCpu.UnrecognizedCallback=SekUnrecognizedOpcode;
|
||||
memset(&PicoCpuCM68k,0,sizeof(PicoCpuCM68k));
|
||||
PicoCpuCM68k.IrqCallback=SekIntAck;
|
||||
PicoCpuCM68k.ResetCallback=SekResetAck;
|
||||
PicoCpuCM68k.UnrecognizedCallback=SekUnrecognizedOpcode;
|
||||
#endif
|
||||
#ifdef EMU_M68K
|
||||
{
|
||||
void *oldcontext = m68ki_cpu_p;
|
||||
m68k_set_context(&PicoM68kCPU);
|
||||
m68k_set_context(&PicoCpuMM68k);
|
||||
m68k_set_cpu_type(M68K_CPU_TYPE_68000);
|
||||
m68k_init();
|
||||
m68k_set_int_ack_callback(SekIntAckM68K);
|
||||
|
@ -140,10 +120,10 @@ PICO_INTERNAL int SekInit()
|
|||
#ifdef EMU_F68K
|
||||
{
|
||||
void *oldcontext = g_m68kcontext;
|
||||
g_m68kcontext = &PicoCpuM68k;
|
||||
memset(&PicoCpuM68k, 0, sizeof(PicoCpuM68k));
|
||||
g_m68kcontext = &PicoCpuFM68k;
|
||||
memset(&PicoCpuFM68k, 0, sizeof(PicoCpuFM68k));
|
||||
m68k_init();
|
||||
PicoCpuM68k.iack_handler = SekIntAckF68K;
|
||||
PicoCpuFM68k.iack_handler = SekIntAckF68K;
|
||||
g_m68kcontext = oldcontext;
|
||||
}
|
||||
#endif
|
||||
|
@ -158,28 +138,25 @@ PICO_INTERNAL int SekReset()
|
|||
if (Pico.rom==NULL) return 1;
|
||||
|
||||
#ifdef EMU_C68K
|
||||
PicoCpu.state_flags=0;
|
||||
PicoCpu.osp=0;
|
||||
PicoCpu.srh =0x27; // Supervisor mode
|
||||
PicoCpu.flags=4; // Z set
|
||||
PicoCpu.irq=0;
|
||||
PicoCpu.a[7]=PicoCpu.read32(0); // Stack Pointer
|
||||
PicoCpu.membase=0;
|
||||
PicoCpu.pc=PicoCpu.checkpc(PicoCpu.read32(4)); // Program Counter
|
||||
PicoCpuCM68k.state_flags=0;
|
||||
PicoCpuCM68k.osp=0;
|
||||
PicoCpuCM68k.srh =0x27; // Supervisor mode
|
||||
PicoCpuCM68k.flags=4; // Z set
|
||||
PicoCpuCM68k.irq=0;
|
||||
PicoCpuCM68k.a[7]=PicoCpuCM68k.read32(0); // Stack Pointer
|
||||
PicoCpuCM68k.membase=0;
|
||||
PicoCpuCM68k.pc=PicoCpuCM68k.checkpc(PicoCpuCM68k.read32(4)); // Program Counter
|
||||
#endif
|
||||
#ifdef EMU_M68K
|
||||
m68k_set_context(&PicoM68kCPU); // if we ever reset m68k, we always need it's context to be set
|
||||
m68k_set_context(&PicoCpuMM68k); // if we ever reset m68k, we always need it's context to be set
|
||||
m68ki_cpu.sp[0]=0;
|
||||
m68k_set_irq(0);
|
||||
m68k_pulse_reset();
|
||||
#endif
|
||||
#ifdef EMU_F68K
|
||||
{
|
||||
unsigned ret;
|
||||
g_m68kcontext = &PicoCpuM68k;
|
||||
setup_fame_fetchmap();
|
||||
ret = m68k_reset();
|
||||
/*if (ret)*/ elprintf(EL_ANOMALY, "m68k_reset returned %u", ret);
|
||||
g_m68kcontext = &PicoCpuFM68k;
|
||||
m68k_reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -197,33 +174,34 @@ PICO_INTERNAL int SekInterrupt(int irq)
|
|||
}
|
||||
#endif
|
||||
#ifdef EMU_C68K
|
||||
PicoCpu.irq=irq;
|
||||
PicoCpuCM68k.irq=irq;
|
||||
#endif
|
||||
#ifdef EMU_M68K
|
||||
{
|
||||
void *oldcontext = m68ki_cpu_p;
|
||||
m68k_set_context(&PicoM68kCPU);
|
||||
m68k_set_context(&PicoCpuMM68k);
|
||||
m68k_set_irq(irq); // raise irq (gets lowered after taken or must be done in ack)
|
||||
m68k_set_context(oldcontext);
|
||||
}
|
||||
#endif
|
||||
#ifdef EMU_F68K
|
||||
PicoCpuM68k.interrupts[0]=irq;
|
||||
PicoCpuFM68k.interrupts[0]=irq;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PICO_INTERNAL void SekState(unsigned char *data)
|
||||
// data must be word aligned
|
||||
PICO_INTERNAL void SekState(int *data)
|
||||
{
|
||||
#ifdef EMU_C68K
|
||||
memcpy(data,PicoCpu.d,0x44);
|
||||
memcpy32(data,PicoCpuCM68k.d,0x44/4);
|
||||
#elif defined(EMU_M68K)
|
||||
memcpy(data, PicoM68kCPU.dar, 0x40);
|
||||
*(int *)(data+0x40) = PicoM68kCPU.pc;
|
||||
memcpy32(data, PicoCpuMM68k.dar, 0x40/4);
|
||||
data[0x10] = PicoCpuMM68k.pc;
|
||||
#elif defined(EMU_F68K)
|
||||
memcpy(data, PicoCpuM68k.dreg, 0x40);
|
||||
*(int *)(data+0x40) = PicoCpuM68k.pc;
|
||||
memcpy32(data, (int *)PicoCpuFM68k.dreg, 0x40/4);
|
||||
data[0x10] = PicoCpuFM68k.pc;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue