mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
Sonic CD runs on GP2X
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@21 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
d1df87866b
commit
b837b69b3f
20 changed files with 364 additions and 184 deletions
|
@ -13,24 +13,79 @@
|
|||
int SekCycleCntS68k=0; // cycles done in this frame
|
||||
int SekCycleAimS68k=0; // cycle aim
|
||||
|
||||
#ifdef EMU_C68K
|
||||
// ---------------------- Cyclone 68000 ----------------------
|
||||
struct Cyclone PicoCpuS68k;
|
||||
#endif
|
||||
|
||||
#ifdef EMU_M68K
|
||||
// ---------------------- MUSASHI 68000 ----------------------
|
||||
m68ki_cpu_core PicoS68kCPU; // Mega CD's CPU
|
||||
#endif
|
||||
|
||||
static int irqs = 0; // TODO: 2 context
|
||||
|
||||
|
||||
#ifdef EMU_M68K
|
||||
int SekIntAckS68k(int level)
|
||||
static int SekIntAckS68k(int level)
|
||||
{
|
||||
dprintf("s68kACK %i", level);
|
||||
CPU_INT_LEVEL = 0;
|
||||
int level_new = 0;
|
||||
irqs &= ~(1 << level);
|
||||
irqs &= Pico_mcd->s68k_regs[0x33];
|
||||
if (irqs) {
|
||||
level_new = 6;
|
||||
while (level_new > 0) { if (irqs & (1 << level_new)) break; level_new--; }
|
||||
}
|
||||
|
||||
dprintf("s68kACK %i -> %i", level, level_new);
|
||||
CPU_INT_LEVEL = level_new << 8;
|
||||
return M68K_INT_ACK_AUTOVECTOR;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef EMU_C68K
|
||||
// interrupt acknowledgment
|
||||
static void SekIntAck(int level)
|
||||
{
|
||||
int level_new = 0;
|
||||
irqs &= ~(1 << level);
|
||||
irqs &= Pico_mcd->s68k_regs[0x33];
|
||||
if (irqs) {
|
||||
level_new = 6;
|
||||
while (level_new > 0) { if (irqs & (1 << level_new)) break; level_new--; }
|
||||
}
|
||||
|
||||
dprintf("s68kACK %i -> %i", level, level_new);
|
||||
PicoCpuS68k.irq = level_new;
|
||||
}
|
||||
|
||||
static void SekResetAck()
|
||||
{
|
||||
dprintf("s68k: Reset encountered @ %06x", SekPcS68k);
|
||||
}
|
||||
|
||||
static int SekUnrecognizedOpcode()
|
||||
{
|
||||
unsigned int pc, op;
|
||||
pc = SekPcS68k;
|
||||
op = PicoCpuS68k.read16(pc);
|
||||
dprintf("Unrecognized Opcode %04x @ %06x", op, pc);
|
||||
//exit(1);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int SekInitS68k()
|
||||
{
|
||||
#ifdef EMU_C68K
|
||||
// CycloneInit();
|
||||
memset(&PicoCpuS68k,0,sizeof(PicoCpuS68k));
|
||||
PicoCpuS68k.IrqCallback=SekIntAck;
|
||||
PicoCpuS68k.ResetCallback=SekResetAck;
|
||||
PicoCpuS68k.UnrecognizedCallback=SekUnrecognizedOpcode;
|
||||
#endif
|
||||
#ifdef EMU_M68K
|
||||
{
|
||||
// Musashi is not very context friendly..
|
||||
|
@ -52,6 +107,16 @@ int SekResetS68k()
|
|||
{
|
||||
if (Pico.rom==NULL) return 1;
|
||||
|
||||
#ifdef EMU_C68K
|
||||
PicoCpuS68k.stopped=0;
|
||||
PicoCpuS68k.osp=0;
|
||||
PicoCpuS68k.srh =0x27; // Supervisor mode
|
||||
PicoCpuS68k.flags=4; // Z set
|
||||
PicoCpuS68k.irq=0;
|
||||
PicoCpuS68k.a[7]=PicoCpuS68k.read32(0); // Stack Pointer
|
||||
PicoCpuS68k.membase=0;
|
||||
PicoCpuS68k.pc=PicoCpuS68k.checkpc(PicoCpuS68k.read32(4)); // Program Counter
|
||||
#endif
|
||||
#ifdef EMU_M68K
|
||||
{
|
||||
void *oldcontext = m68ki_cpu_p;
|
||||
|
@ -67,6 +132,10 @@ int SekResetS68k()
|
|||
|
||||
int SekInterruptS68k(int irq)
|
||||
{
|
||||
irqs |= 1 << irq;
|
||||
#ifdef EMU_C68K
|
||||
PicoCpuS68k.irq=irq;
|
||||
#endif
|
||||
#ifdef EMU_M68K
|
||||
void *oldcontext = m68ki_cpu_p;
|
||||
m68k_set_context(&PicoS68kCPU);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue