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
|
@ -319,14 +319,16 @@ static void OtherWrite8(u32 a,u32 d,int realsize)
|
||||||
//int lineCycles=(488-SekCyclesLeft)&0x1ff;
|
//int lineCycles=(488-SekCyclesLeft)&0x1ff;
|
||||||
d&=1; d^=1;
|
d&=1; d^=1;
|
||||||
if(!d) {
|
if(!d) {
|
||||||
// hack: detect a nasty situation where Z80 was enabled and disabled in the same 68k timeslice (Golden Axe III)
|
// this is for a nasty situation where Z80 was enabled and disabled in the same 68k timeslice (Golden Axe III)
|
||||||
// if((PicoOpt&4) && Pico.m.z80Run==1) z80_run(20); // FIXME: movies
|
if (Pico.m.z80Run) {
|
||||||
z80stopCycle = SekCyclesDone();
|
int lineCycles=(488-SekCyclesLeft)&0x1ff;
|
||||||
//z80ExtraCycles += (lineCycles>>1)-(lineCycles>>5); // only meaningful in PicoFrameHints()
|
z80stopCycle = SekCyclesDone();
|
||||||
|
lineCycles=(lineCycles>>1)-(lineCycles>>5);
|
||||||
|
z80_run(lineCycles);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
z80startCycle = SekCyclesDone();
|
z80startCycle = SekCyclesDone();
|
||||||
//if(Pico.m.scanline != -1)
|
//if(Pico.m.scanline != -1)
|
||||||
//z80ExtraCycles -= (lineCycles>>1)-(lineCycles>>5)+16;
|
|
||||||
}
|
}
|
||||||
dprintf("set_zrun: %02x [%i|%i] @%06x", d, Pico.m.scanline, SekCyclesDone(), /*mz80GetRegisterValue(NULL, 0),*/ SekPc);
|
dprintf("set_zrun: %02x [%i|%i] @%06x", d, Pico.m.scanline, SekCyclesDone(), /*mz80GetRegisterValue(NULL, 0),*/ SekPc);
|
||||||
Pico.m.z80Run=(u8)d; return;
|
Pico.m.z80Run=(u8)d; return;
|
||||||
|
@ -621,7 +623,7 @@ static void CPU_CALL PicoWrite32(u32 a,u32 d)
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
int PicoMemInit()
|
void PicoMemSetup()
|
||||||
{
|
{
|
||||||
#ifdef EMU_C68K
|
#ifdef EMU_C68K
|
||||||
// Setup memory callbacks:
|
// Setup memory callbacks:
|
||||||
|
@ -633,7 +635,6 @@ int PicoMemInit()
|
||||||
PicoCpu.write16=PicoWrite16;
|
PicoCpu.write16=PicoWrite16;
|
||||||
PicoCpu.write32=PicoWrite32;
|
PicoCpu.write32=PicoWrite32;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EMU_A68K
|
#ifdef EMU_A68K
|
||||||
|
|
34
Pico/Pico.c
34
Pico/Pico.c
|
@ -11,7 +11,7 @@
|
||||||
#include "sound/sound.h"
|
#include "sound/sound.h"
|
||||||
#include "sound/ym2612.h"
|
#include "sound/ym2612.h"
|
||||||
|
|
||||||
int PicoVer=0x0080;
|
int PicoVer=0x0110;
|
||||||
struct Pico Pico;
|
struct Pico Pico;
|
||||||
int PicoOpt=0; // disable everything by default
|
int PicoOpt=0; // disable everything by default
|
||||||
int PicoSkipFrame=0; // skip rendering frame?
|
int PicoSkipFrame=0; // skip rendering frame?
|
||||||
|
@ -36,9 +36,6 @@ int PicoInit(void)
|
||||||
SekInit();
|
SekInit();
|
||||||
z80_init(); // init even if we aren't going to use it
|
z80_init(); // init even if we aren't going to use it
|
||||||
|
|
||||||
// Setup memory callbacks:
|
|
||||||
PicoMemInit();
|
|
||||||
|
|
||||||
PicoInitMCD();
|
PicoInitMCD();
|
||||||
|
|
||||||
// notaz: sram
|
// notaz: sram
|
||||||
|
@ -66,6 +63,10 @@ int PicoReset(int hard)
|
||||||
|
|
||||||
if (Pico.romsize<=0) return 1;
|
if (Pico.romsize<=0) return 1;
|
||||||
|
|
||||||
|
// setup correct memory map
|
||||||
|
if (PicoMCD & 1)
|
||||||
|
PicoMemSetupCD();
|
||||||
|
else PicoMemSetup();
|
||||||
PicoMemReset();
|
PicoMemReset();
|
||||||
SekReset();
|
SekReset();
|
||||||
SekCycleCntT=0;
|
SekCycleCntT=0;
|
||||||
|
@ -237,31 +238,6 @@ static __inline void SekRun(int cyc)
|
||||||
{
|
{
|
||||||
int cyc_do;
|
int cyc_do;
|
||||||
SekCycleAim+=cyc;
|
SekCycleAim+=cyc;
|
||||||
#if 0
|
|
||||||
if(Pico.m.dma_bytes) {
|
|
||||||
int burn=0;
|
|
||||||
if((Pico.video.status&8)||!(Pico.video.reg[1]&0x40)) { // vblank?
|
|
||||||
if(Pico.m.dma_bytes < 205) {
|
|
||||||
burn = Pico.m.dma_bytes*(((488<<8)/205))>>8;
|
|
||||||
Pico.m.dma_bytes = 0;
|
|
||||||
} else {
|
|
||||||
burn += 488;
|
|
||||||
Pico.m.dma_bytes -= 205;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(Pico.m.dma_bytes < 18) {
|
|
||||||
burn = Pico.m.dma_bytes*(((488<<8)/18))>>8;
|
|
||||||
Pico.m.dma_bytes = 0;
|
|
||||||
} else {
|
|
||||||
burn += 488;
|
|
||||||
Pico.m.dma_bytes -= 18;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SekCycleCnt+=burn;
|
|
||||||
dprintf("~DmaSlow %i burn=%i do=%i [%i|%i]", Pico.m.dma_bytes, burn, SekCycleAim-SekCycleCnt,
|
|
||||||
Pico.m.scanline, SekCyclesDone());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
//dprintf("aim: %i, cnt: %i", SekCycleAim, SekCycleCnt);
|
//dprintf("aim: %i, cnt: %i", SekCycleAim, SekCycleCnt);
|
||||||
if((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return;
|
if((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return;
|
||||||
//dprintf("cyc_do: %i", cyc_do);
|
//dprintf("cyc_do: %i", cyc_do);
|
||||||
|
|
|
@ -23,10 +23,11 @@ extern "C" {
|
||||||
// ----------------------- 68000 CPU -----------------------
|
// ----------------------- 68000 CPU -----------------------
|
||||||
#ifdef EMU_C68K
|
#ifdef EMU_C68K
|
||||||
#include "../cpu/Cyclone/Cyclone.h"
|
#include "../cpu/Cyclone/Cyclone.h"
|
||||||
extern struct Cyclone PicoCpu;
|
extern struct Cyclone PicoCpu, PicoCpuS68k;
|
||||||
#define SekCyclesLeft PicoCpu.cycles // cycles left for this run
|
#define SekCyclesLeft PicoCpu.cycles // cycles left for this run
|
||||||
#define SekSetCyclesLeft(c) PicoCpu.cycles=c
|
#define SekSetCyclesLeft(c) PicoCpu.cycles=c
|
||||||
#define SekPc (PicoCpu.pc-PicoCpu.membase)
|
#define SekPc (PicoCpu.pc-PicoCpu.membase)
|
||||||
|
#define SekPcS68k (PicoCpuS68k.pc-PicoCpuS68k.membase)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EMU_A68K
|
#ifdef EMU_A68K
|
||||||
|
@ -201,15 +202,16 @@ void PicoFrameFull();
|
||||||
// Memory.c
|
// Memory.c
|
||||||
int PicoInitPc(unsigned int pc);
|
int PicoInitPc(unsigned int pc);
|
||||||
unsigned int CPU_CALL PicoRead32(unsigned int a);
|
unsigned int CPU_CALL PicoRead32(unsigned int a);
|
||||||
int PicoMemInit();
|
void PicoMemSetup();
|
||||||
void PicoMemReset();
|
void PicoMemReset();
|
||||||
void PicoDasm(int start,int len);
|
//void PicoDasm(int start,int len);
|
||||||
unsigned char z80_read(unsigned short a);
|
unsigned char z80_read(unsigned short a);
|
||||||
unsigned short z80_read16(unsigned short a);
|
unsigned short z80_read16(unsigned short a);
|
||||||
void z80_write(unsigned char data, unsigned short a);
|
void z80_write(unsigned char data, unsigned short a);
|
||||||
void z80_write16(unsigned short data, unsigned short a);
|
void z80_write16(unsigned short data, unsigned short a);
|
||||||
|
|
||||||
// cd/Memory.c
|
// cd/Memory.c
|
||||||
|
void PicoMemSetupCD();
|
||||||
unsigned char PicoReadCD8 (unsigned int a);
|
unsigned char PicoReadCD8 (unsigned int a);
|
||||||
unsigned short PicoReadCD16(unsigned int a);
|
unsigned short PicoReadCD16(unsigned int a);
|
||||||
unsigned int PicoReadCD32(unsigned int a);
|
unsigned int PicoReadCD32(unsigned int a);
|
||||||
|
|
10
Pico/Sek.c
10
Pico/Sek.c
|
@ -41,8 +41,8 @@ static int (*ResetCallback)()=DoReset;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// interrupt acknowledgment
|
|
||||||
#ifdef EMU_C68K
|
#ifdef EMU_C68K
|
||||||
|
// interrupt acknowledgment
|
||||||
static void SekIntAck(int level)
|
static void SekIntAck(int level)
|
||||||
{
|
{
|
||||||
// try to emulate VDP's reaction to 68000 int ack
|
// try to emulate VDP's reaction to 68000 int ack
|
||||||
|
@ -143,12 +143,8 @@ int SekReset()
|
||||||
PicoInitPc(M68000_regs.pc);
|
PicoInitPc(M68000_regs.pc);
|
||||||
#endif
|
#endif
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
{
|
m68k_set_context(&PicoM68kCPU); // if we ever reset m68k, we always need it's context to be set
|
||||||
void *oldcontext = m68ki_cpu_p;
|
m68k_pulse_reset();
|
||||||
m68k_set_context(&PicoM68kCPU);
|
|
||||||
m68k_pulse_reset();
|
|
||||||
m68k_set_context(oldcontext);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
150
Pico/cd/Memory.c
150
Pico/cd/Memory.c
|
@ -1,7 +1,7 @@
|
||||||
// This is part of Pico Library
|
// This is part of Pico Library
|
||||||
|
|
||||||
// (c) Copyright 2004 Dave, All rights reserved.
|
// (c) Copyright 2004 Dave, All rights reserved.
|
||||||
// (c) Copyright 2006 notaz, All rights reserved.
|
// (c) Copyright 2007 notaz, All rights reserved.
|
||||||
// Free for non-commercial use.
|
// Free for non-commercial use.
|
||||||
|
|
||||||
// For commercial use, separate licencing terms must be obtained.
|
// For commercial use, separate licencing terms must be obtained.
|
||||||
|
@ -474,6 +474,22 @@ u8 PicoReadM68k8(u32 a)
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if (a == 0x200000 && SekPc == 0xff0b66 && Pico.m.frame_count > 1000)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
FILE *ff;
|
||||||
|
unsigned short *ram = (unsigned short *) Pico.ram;
|
||||||
|
// unswap and dump RAM
|
||||||
|
for (i = 0; i < 0x10000/2; i++)
|
||||||
|
ram[i] = (ram[i]>>8) | (ram[i]<<8);
|
||||||
|
ff = fopen("ram.bin", "wb");
|
||||||
|
fwrite(ram, 1, 0x10000, ff);
|
||||||
|
fclose(ff);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// word RAM
|
// word RAM
|
||||||
if ((a&0xfc0000)==0x200000) {
|
if ((a&0xfc0000)==0x200000) {
|
||||||
dprintf("m68k_wram r8: [%06x] @%06x", a, SekPc);
|
dprintf("m68k_wram r8: [%06x] @%06x", a, SekPc);
|
||||||
|
@ -764,22 +780,6 @@ void PicoWriteM68k32(u32 a,u32 d)
|
||||||
if ((a&0xffffc0)==0xa12000)
|
if ((a&0xffffc0)==0xa12000)
|
||||||
rdprintf("m68k_regs w32: [%02x] %08x @%06x", a&0x3f, d, SekPc);
|
rdprintf("m68k_regs w32: [%02x] %08x @%06x", a&0x3f, d, SekPc);
|
||||||
|
|
||||||
#if 0
|
|
||||||
if ((a&0x3f) == 0x1c && SekPc == 0xffff05ba)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
FILE *ff;
|
|
||||||
unsigned short *ram = (unsigned short *) Pico.ram;
|
|
||||||
// unswap and dump RAM
|
|
||||||
for (i = 0; i < 0x10000/2; i++)
|
|
||||||
ram[i] = (ram[i]>>8) | (ram[i]<<8);
|
|
||||||
ff = fopen("ram.bin", "wb");
|
|
||||||
fwrite(ram, 1, 0x10000, ff);
|
|
||||||
fclose(ff);
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
OtherWrite16(a, (u16)(d>>16));
|
OtherWrite16(a, (u16)(d>>16));
|
||||||
OtherWrite16(a+2,(u16)d);
|
OtherWrite16(a+2,(u16)d);
|
||||||
}
|
}
|
||||||
|
@ -1196,6 +1196,97 @@ void PicoWriteS68k32(u32 a,u32 d)
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(EMU_C68K)
|
||||||
|
static __inline int PicoMemBaseM68k(u32 pc)
|
||||||
|
{
|
||||||
|
int membase=0;
|
||||||
|
|
||||||
|
if (pc < 0x20000)
|
||||||
|
{
|
||||||
|
membase=(int)Pico_mcd->bios; // Program Counter in BIOS
|
||||||
|
}
|
||||||
|
else if ((pc&0xe00000)==0xe00000)
|
||||||
|
{
|
||||||
|
membase=(int)Pico.ram-(pc&0xff0000); // Program Counter in Ram
|
||||||
|
}
|
||||||
|
else if ((pc&0xfc0000)==0x200000 && !(Pico_mcd->s68k_regs[3]&4))
|
||||||
|
{
|
||||||
|
membase=(int)Pico_mcd->word_ram-0x200000; // Program Counter in Word Ram
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Error - Program Counter is invalid
|
||||||
|
dprintf("m68k: unhandled jump to %06x", pc);
|
||||||
|
membase=(int)Pico.rom;
|
||||||
|
}
|
||||||
|
|
||||||
|
return membase;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static u32 PicoCheckPcM68k(u32 pc)
|
||||||
|
{
|
||||||
|
pc-=PicoCpu.membase; // Get real pc
|
||||||
|
pc&=0xfffffe;
|
||||||
|
|
||||||
|
PicoCpu.membase=PicoMemBaseM68k(pc);
|
||||||
|
|
||||||
|
return PicoCpu.membase+pc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static __inline int PicoMemBaseS68k(u32 pc)
|
||||||
|
{
|
||||||
|
int membase;
|
||||||
|
|
||||||
|
membase=(int)Pico_mcd->prg_ram; // Program Counter in Prg RAM
|
||||||
|
if (pc >= 0x80000)
|
||||||
|
{
|
||||||
|
// Error - Program Counter is invalid
|
||||||
|
dprintf("s68k: unhandled jump to %06x", pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return membase;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static u32 PicoCheckPcS68k(u32 pc)
|
||||||
|
{
|
||||||
|
pc-=PicoCpuS68k.membase; // Get real pc
|
||||||
|
pc&=0xfffffe;
|
||||||
|
|
||||||
|
PicoCpuS68k.membase=PicoMemBaseS68k(pc);
|
||||||
|
|
||||||
|
return PicoCpuS68k.membase+pc;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void PicoMemSetupCD()
|
||||||
|
{
|
||||||
|
dprintf("PicoMemSetupCD()");
|
||||||
|
#ifdef EMU_C68K
|
||||||
|
// Setup m68k memory callbacks:
|
||||||
|
PicoCpu.checkpc=PicoCheckPcM68k;
|
||||||
|
PicoCpu.fetch8 =PicoCpu.read8 =PicoReadM68k8;
|
||||||
|
PicoCpu.fetch16=PicoCpu.read16=PicoReadM68k16;
|
||||||
|
PicoCpu.fetch32=PicoCpu.read32=PicoReadM68k32;
|
||||||
|
PicoCpu.write8 =PicoWriteM68k8;
|
||||||
|
PicoCpu.write16=PicoWriteM68k16;
|
||||||
|
PicoCpu.write32=PicoWriteM68k32;
|
||||||
|
// s68k
|
||||||
|
PicoCpuS68k.checkpc=PicoCheckPcS68k;
|
||||||
|
PicoCpuS68k.fetch8 =PicoCpuS68k.read8 =PicoReadS68k8;
|
||||||
|
PicoCpuS68k.fetch16=PicoCpuS68k.read16=PicoReadS68k16;
|
||||||
|
PicoCpuS68k.fetch32=PicoCpuS68k.read32=PicoReadS68k32;
|
||||||
|
PicoCpuS68k.write8 =PicoWriteS68k8;
|
||||||
|
PicoCpuS68k.write16=PicoWriteS68k16;
|
||||||
|
PicoCpuS68k.write32=PicoWriteS68k32;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
unsigned char PicoReadCD8w (unsigned int a) {
|
unsigned char PicoReadCD8w (unsigned int a) {
|
||||||
return m68ki_cpu_p == &PicoS68kCPU ? PicoReadS68k8(a) : PicoReadM68k8(a);
|
return m68ki_cpu_p == &PicoS68kCPU ? PicoReadS68k8(a) : PicoReadM68k8(a);
|
||||||
|
@ -1221,10 +1312,13 @@ unsigned int m68k_read_pcrelative_CD8 (unsigned int a) {
|
||||||
a&=0xffffff;
|
a&=0xffffff;
|
||||||
if(m68ki_cpu_p == &PicoS68kCPU) {
|
if(m68ki_cpu_p == &PicoS68kCPU) {
|
||||||
if (a < 0x80000) return *(u8 *)(Pico_mcd->prg_ram+(a^1)); // PRG Ram
|
if (a < 0x80000) return *(u8 *)(Pico_mcd->prg_ram+(a^1)); // PRG Ram
|
||||||
else dprintf("s68k read_pcrel8 @ %06x", a);
|
dprintf("s68k_read_pcrelative_CD8: can't handle %06x", a);
|
||||||
} else {
|
} else {
|
||||||
if(a<Pico.romsize) return *(u8 *)(Pico.rom+(a^1)); // Rom
|
if(a<0x20000) return *(u8 *)(Pico.rom+(a^1)); // Bios
|
||||||
if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram
|
if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram
|
||||||
|
if(!(Pico_mcd->s68k_regs[3]&4) && (a&0xfc0000)==0x200000)
|
||||||
|
return Pico_mcd->word_ram[(a^1)&0x3fffe];
|
||||||
|
dprintf("m68k_read_pcrelative_CD8: can't handle %06x", a);
|
||||||
}
|
}
|
||||||
return 0;//(u8) lastread_d;
|
return 0;//(u8) lastread_d;
|
||||||
}
|
}
|
||||||
|
@ -1232,23 +1326,29 @@ unsigned int m68k_read_pcrelative_CD16(unsigned int a) {
|
||||||
a&=0xffffff;
|
a&=0xffffff;
|
||||||
if(m68ki_cpu_p == &PicoS68kCPU) {
|
if(m68ki_cpu_p == &PicoS68kCPU) {
|
||||||
if (a < 0x80000) return *(u16 *)(Pico_mcd->prg_ram+(a&~1)); // PRG Ram
|
if (a < 0x80000) return *(u16 *)(Pico_mcd->prg_ram+(a&~1)); // PRG Ram
|
||||||
else dprintf("s68k read_pcrel16 @ %06x", a);
|
dprintf("s68k_read_pcrelative_CD16: can't handle %06x", a);
|
||||||
} else {
|
} else {
|
||||||
if(a<Pico.romsize) return *(u16 *)(Pico.rom+(a&~1)); // Rom
|
if(a<0x20000) return *(u16 *)(Pico.rom+(a&~1)); // Bios
|
||||||
if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram
|
if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram
|
||||||
|
if(!(Pico_mcd->s68k_regs[3]&4) && (a&0xfc0000)==0x200000)
|
||||||
|
return *(u16 *)(Pico_mcd->word_ram+(a&0x3fffe));
|
||||||
|
dprintf("m68k_read_pcrelative_CD16: can't handle %06x", a);
|
||||||
}
|
}
|
||||||
return 0;//(u16) lastread_d;
|
return 0;
|
||||||
}
|
}
|
||||||
unsigned int m68k_read_pcrelative_CD32(unsigned int a) {
|
unsigned int m68k_read_pcrelative_CD32(unsigned int a) {
|
||||||
a&=0xffffff;
|
a&=0xffffff;
|
||||||
if(m68ki_cpu_p == &PicoS68kCPU) {
|
if(m68ki_cpu_p == &PicoS68kCPU) {
|
||||||
if (a < 0x80000) { u16 *pm=(u16 *)(Pico_mcd->prg_ram+(a&~1)); return (pm[0]<<16)|pm[1]; } // PRG Ram
|
if (a < 0x80000) { u16 *pm=(u16 *)(Pico_mcd->prg_ram+(a&~1)); return (pm[0]<<16)|pm[1]; } // PRG Ram
|
||||||
else dprintf("s68k read_pcrel32 @ %06x", a);
|
dprintf("s68k_read_pcrelative_CD32: can't handle %06x", a);
|
||||||
} else {
|
} else {
|
||||||
if(a<Pico.romsize) { u16 *pm=(u16 *)(Pico.rom+(a&~1)); return (pm[0]<<16)|pm[1]; }
|
if(a<0x20000) { u16 *pm=(u16 *)(Pico.rom+(a&~1)); return (pm[0]<<16)|pm[1]; }
|
||||||
if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram
|
if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram
|
||||||
|
if(!(Pico_mcd->s68k_regs[3]&4) && (a&0xfc0000)==0x200000)
|
||||||
|
{ u16 *pm=(u16 *)(Pico_mcd->word_ram+(a&0x3fffe)); return (pm[0]<<16)|pm[1]; }
|
||||||
|
dprintf("m68k_read_pcrelative_CD32: can't handle %06x", a);
|
||||||
}
|
}
|
||||||
return 0; //lastread_d;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif // EMU_M68K
|
#endif // EMU_M68K
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ int PicoResetMCD(int hard)
|
||||||
// clear everything except BIOS
|
// clear everything except BIOS
|
||||||
memset(Pico_mcd->prg_ram, 0, sizeof(mcd_state) - sizeof(Pico_mcd->bios));
|
memset(Pico_mcd->prg_ram, 0, sizeof(mcd_state) - sizeof(Pico_mcd->bios));
|
||||||
*(unsigned int *)(Pico_mcd->bios + 0x70) = 0xffffffff; // reset hint vector (simplest way to implement reg6)
|
*(unsigned int *)(Pico_mcd->bios + 0x70) = 0xffffffff; // reset hint vector (simplest way to implement reg6)
|
||||||
PicoMCD |= 2; // s68k reset pending
|
PicoMCD |= 2; // s68k reset pending. TODO: move
|
||||||
Pico_mcd->s68k_regs[3] = 1; // 2M word RAM mode with m68k access after reset
|
Pico_mcd->s68k_regs[3] = 1; // 2M word RAM mode with m68k access after reset
|
||||||
counter75hz = 0;
|
counter75hz = 0;
|
||||||
|
|
||||||
|
@ -48,7 +48,11 @@ static __inline void SekRun(int cyc)
|
||||||
int cyc_do;
|
int cyc_do;
|
||||||
SekCycleAim+=cyc;
|
SekCycleAim+=cyc;
|
||||||
if((cyc_do=SekCycleAim-SekCycleCnt) < 0) return;
|
if((cyc_do=SekCycleAim-SekCycleCnt) < 0) return;
|
||||||
#if defined(EMU_M68K)
|
#if defined(EMU_C68K)
|
||||||
|
PicoCpu.cycles=cyc_do;
|
||||||
|
CycloneRun(&PicoCpu);
|
||||||
|
SekCycleCnt+=cyc_do-PicoCpu.cycles;
|
||||||
|
#elif defined(EMU_M68K)
|
||||||
m68k_set_context(&PicoM68kCPU);
|
m68k_set_context(&PicoM68kCPU);
|
||||||
SekCycleCnt+=m68k_execute(cyc_do);
|
SekCycleCnt+=m68k_execute(cyc_do);
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,7 +63,11 @@ static __inline void SekRunS68k(int cyc)
|
||||||
int cyc_do;
|
int cyc_do;
|
||||||
SekCycleAimS68k+=cyc;
|
SekCycleAimS68k+=cyc;
|
||||||
if((cyc_do=SekCycleAimS68k-SekCycleCntS68k) < 0) return;
|
if((cyc_do=SekCycleAimS68k-SekCycleCntS68k) < 0) return;
|
||||||
#if defined(EMU_M68K)
|
#if defined(EMU_C68K)
|
||||||
|
PicoCpuS68k.cycles=cyc_do;
|
||||||
|
CycloneRun(&PicoCpuS68k);
|
||||||
|
SekCycleCntS68k+=cyc_do-PicoCpuS68k.cycles;
|
||||||
|
#elif defined(EMU_M68K)
|
||||||
m68k_set_context(&PicoS68kCPU);
|
m68k_set_context(&PicoS68kCPU);
|
||||||
SekCycleCntS68k+=m68k_execute(cyc_do);
|
SekCycleCntS68k+=m68k_execute(cyc_do);
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,6 +90,27 @@ static __inline void check_cd_dma(void)
|
||||||
Update_CDC_TRansfer(ddx); // now go and do the actual transfer
|
Update_CDC_TRansfer(ddx); // now go and do the actual transfer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// to be called on 224 or line_sample scanlines only
|
||||||
|
static __inline void getSamples(int y)
|
||||||
|
{
|
||||||
|
if(y == 224) {
|
||||||
|
//dprintf("sta%i: %i [%i]", (emustatus & 2), emustatus, y);
|
||||||
|
if(emustatus & 2)
|
||||||
|
sound_render(PsndLen/2, PsndLen-PsndLen/2);
|
||||||
|
else sound_render(0, PsndLen);
|
||||||
|
if (emustatus&1) emustatus|=2; else emustatus&=~2;
|
||||||
|
if (PicoWriteSound) PicoWriteSound();
|
||||||
|
// clear sound buffer
|
||||||
|
memset(PsndOut, 0, (PicoOpt & 8) ? (PsndLen<<2) : (PsndLen<<1));
|
||||||
|
}
|
||||||
|
else if(emustatus & 3) {
|
||||||
|
emustatus|= 2;
|
||||||
|
emustatus&=~1;
|
||||||
|
sound_render(0, PsndLen/2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Accurate but slower frame which does hints
|
// Accurate but slower frame which does hints
|
||||||
static int PicoFrameHintsMCD(void)
|
static int PicoFrameHintsMCD(void)
|
||||||
|
@ -176,7 +205,7 @@ static int PicoFrameHintsMCD(void)
|
||||||
if(y == 32 && PsndOut)
|
if(y == 32 && PsndOut)
|
||||||
emustatus &= ~1;
|
emustatus &= ~1;
|
||||||
else if((y == 224 || y == line_sample) && PsndOut)
|
else if((y == 224 || y == line_sample) && PsndOut)
|
||||||
;//getSamples(y);
|
getSamples(y);
|
||||||
|
|
||||||
// Run scanline:
|
// Run scanline:
|
||||||
//dprintf("m68k starting exec @ %06x", SekPc);
|
//dprintf("m68k starting exec @ %06x", SekPc);
|
||||||
|
|
|
@ -13,24 +13,79 @@
|
||||||
int SekCycleCntS68k=0; // cycles done in this frame
|
int SekCycleCntS68k=0; // cycles done in this frame
|
||||||
int SekCycleAimS68k=0; // cycle aim
|
int SekCycleAimS68k=0; // cycle aim
|
||||||
|
|
||||||
|
#ifdef EMU_C68K
|
||||||
|
// ---------------------- Cyclone 68000 ----------------------
|
||||||
|
struct Cyclone PicoCpuS68k;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
// ---------------------- MUSASHI 68000 ----------------------
|
// ---------------------- MUSASHI 68000 ----------------------
|
||||||
m68ki_cpu_core PicoS68kCPU; // Mega CD's CPU
|
m68ki_cpu_core PicoS68kCPU; // Mega CD's CPU
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int irqs = 0; // TODO: 2 context
|
||||||
|
|
||||||
|
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
int SekIntAckS68k(int level)
|
static int SekIntAckS68k(int level)
|
||||||
{
|
{
|
||||||
dprintf("s68kACK %i", level);
|
int level_new = 0;
|
||||||
CPU_INT_LEVEL = 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;
|
return M68K_INT_ACK_AUTOVECTOR;
|
||||||
}
|
}
|
||||||
#endif
|
#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()
|
int SekInitS68k()
|
||||||
{
|
{
|
||||||
|
#ifdef EMU_C68K
|
||||||
|
// CycloneInit();
|
||||||
|
memset(&PicoCpuS68k,0,sizeof(PicoCpuS68k));
|
||||||
|
PicoCpuS68k.IrqCallback=SekIntAck;
|
||||||
|
PicoCpuS68k.ResetCallback=SekResetAck;
|
||||||
|
PicoCpuS68k.UnrecognizedCallback=SekUnrecognizedOpcode;
|
||||||
|
#endif
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
{
|
{
|
||||||
// Musashi is not very context friendly..
|
// Musashi is not very context friendly..
|
||||||
|
@ -52,6 +107,16 @@ int SekResetS68k()
|
||||||
{
|
{
|
||||||
if (Pico.rom==NULL) return 1;
|
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
|
#ifdef EMU_M68K
|
||||||
{
|
{
|
||||||
void *oldcontext = m68ki_cpu_p;
|
void *oldcontext = m68ki_cpu_p;
|
||||||
|
@ -67,6 +132,10 @@ int SekResetS68k()
|
||||||
|
|
||||||
int SekInterruptS68k(int irq)
|
int SekInterruptS68k(int irq)
|
||||||
{
|
{
|
||||||
|
irqs |= 1 << irq;
|
||||||
|
#ifdef EMU_C68K
|
||||||
|
PicoCpuS68k.irq=irq;
|
||||||
|
#endif
|
||||||
#ifdef EMU_M68K
|
#ifdef EMU_M68K
|
||||||
void *oldcontext = m68ki_cpu_p;
|
void *oldcontext = m68ki_cpu_p;
|
||||||
m68k_set_context(&PicoS68kCPU);
|
m68k_set_context(&PicoS68kCPU);
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
#include "940shared.h"
|
#include "940shared.h"
|
||||||
|
|
||||||
/* this code assumes that we live @ 0x3000000 bank */
|
|
||||||
//static volatile unsigned short *gp2x_memregs = (void *) 0x0xbd000000;
|
|
||||||
//static volatile unsigned long *gp2x_memregl = (void *) 0x0xbd000000;
|
|
||||||
|
|
||||||
static _940_data_t *shared_data = (_940_data_t *) 0x100000;
|
static _940_data_t *shared_data = (_940_data_t *) 0x100000;
|
||||||
static _940_ctl_t *shared_ctl = (_940_ctl_t *) 0x200000;
|
static _940_ctl_t *shared_ctl = (_940_ctl_t *) 0x200000;
|
||||||
YM2612 *ym2612_940;
|
YM2612 *ym2612_940;
|
||||||
|
@ -28,10 +24,10 @@ void Main940(int startvector)
|
||||||
shared_ctl->vstarts[startvector]++;
|
shared_ctl->vstarts[startvector]++;
|
||||||
asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0");
|
asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0");
|
||||||
|
|
||||||
/* unmask IRQs */
|
|
||||||
|
|
||||||
for (;; shared_ctl->loopc++)
|
for (;; shared_ctl->loopc++)
|
||||||
{
|
{
|
||||||
|
int job_num;
|
||||||
/*
|
/*
|
||||||
while (!shared_ctl->busy)
|
while (!shared_ctl->busy)
|
||||||
{
|
{
|
||||||
|
@ -44,50 +40,54 @@ void Main940(int startvector)
|
||||||
wait_irq();
|
wait_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (shared_ctl->job)
|
for (job_num = 0; job_num < MAX_940JOBS; job_num++)
|
||||||
{
|
{
|
||||||
case JOB940_YM2612INIT:
|
switch (shared_ctl->jobs[job_num])
|
||||||
shared_ctl->writebuff0[0] = shared_ctl->writebuff1[0] = 0xffff;
|
{
|
||||||
YM2612Init_(shared_ctl->baseclock, shared_ctl->rate);
|
case JOB940_YM2612INIT:
|
||||||
break;
|
shared_ctl->writebuff0[0] = shared_ctl->writebuff1[0] = 0xffff;
|
||||||
|
YM2612Init_(shared_ctl->baseclock, shared_ctl->rate);
|
||||||
|
break;
|
||||||
|
|
||||||
case JOB940_YM2612RESETCHIP:
|
case JOB940_YM2612RESETCHIP:
|
||||||
YM2612ResetChip_();
|
YM2612ResetChip_();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JOB940_PICOSTATELOAD:
|
case JOB940_PICOSTATELOAD:
|
||||||
YM2612PicoStateLoad_();
|
YM2612PicoStateLoad_();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JOB940_YM2612UPDATEONE: {
|
case JOB940_YM2612UPDATEONE: {
|
||||||
int i, dw, *wbuff;
|
int i, dw, *wbuff;
|
||||||
if (shared_ctl->writebuffsel == 1) {
|
if (shared_ctl->writebuffsel == 1) {
|
||||||
wbuff = (int *) shared_ctl->writebuff1;
|
wbuff = (int *) shared_ctl->writebuff1;
|
||||||
} else {
|
} else {
|
||||||
wbuff = (int *) shared_ctl->writebuff0;
|
wbuff = (int *) shared_ctl->writebuff0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* playback all writes */
|
||||||
|
for (i = 2048/2; i > 0; i--) {
|
||||||
|
UINT16 d;
|
||||||
|
dw = *wbuff++;
|
||||||
|
d = dw;
|
||||||
|
if (d == 0xffff) break;
|
||||||
|
YM2612Write_(d >> 8, d);
|
||||||
|
d = (dw>>16);
|
||||||
|
if (d == 0xffff) break;
|
||||||
|
YM2612Write_(d >> 8, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
YM2612UpdateOne_(0, shared_ctl->length, shared_ctl->stereo);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* playback all writes */
|
|
||||||
for (i = 2048/2; i > 0; i--) {
|
|
||||||
UINT16 d;
|
|
||||||
dw = *wbuff++;
|
|
||||||
d = dw;
|
|
||||||
if (d == 0xffff) break;
|
|
||||||
YM2612Write_(d >> 8, d);
|
|
||||||
d = (dw>>16);
|
|
||||||
if (d == 0xffff) break;
|
|
||||||
YM2612Write_(d >> 8, d);
|
|
||||||
}
|
|
||||||
|
|
||||||
YM2612UpdateOne_(0, shared_ctl->length, shared_ctl->stereo);
|
|
||||||
// cache_clean_flush();
|
|
||||||
cache_clean();
|
|
||||||
// asm volatile ("mov r0, #0" ::: "r0");
|
|
||||||
// asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0"); /* drain write buffer, should be done on nonbuffered write */
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ctl->busy = 0;
|
shared_ctl->busy = 0;
|
||||||
|
// cache_clean_flush();
|
||||||
|
cache_clean();
|
||||||
|
// asm volatile ("mov r0, #0" ::: "r0");
|
||||||
|
// asm volatile ("mcr p15, 0, r0, c7, c10, 4" ::: "r0"); /* drain write buffer, should be done on nonbuffered write */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,9 +250,10 @@ static void wait_busy_940(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void add_job_940(int job)
|
static void add_job_940(int job0, int job1)
|
||||||
{
|
{
|
||||||
shared_ctl->job = job;
|
shared_ctl->jobs[0] = job0;
|
||||||
|
shared_ctl->jobs[1] = job1;
|
||||||
shared_ctl->busy = 1;
|
shared_ctl->busy = 1;
|
||||||
gp2x_memregs[0x3B3E>>1] = 0xffff; // cause an IRQ for 940
|
gp2x_memregs[0x3B3E>>1] = 0xffff; // cause an IRQ for 940
|
||||||
}
|
}
|
||||||
|
@ -276,7 +277,7 @@ void YM2612PicoStateLoad_940(void)
|
||||||
|
|
||||||
addr_A1 = old_A1;
|
addr_A1 = old_A1;
|
||||||
|
|
||||||
add_job_940(JOB940_PICOSTATELOAD);
|
add_job_940(JOB940_PICOSTATELOAD, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,10 +300,9 @@ extern char **g_argv;
|
||||||
void YM2612Init_940(int baseclock, int rate)
|
void YM2612Init_940(int baseclock, int rate)
|
||||||
{
|
{
|
||||||
printf("YM2612Init_940()\n");
|
printf("YM2612Init_940()\n");
|
||||||
//printf("sizeof(*shared_data): %i (%x)\n", sizeof(*shared_data), sizeof(*shared_data));
|
printf("Mem usage: shared_data: %i, shared_ctl: %i\n", sizeof(*shared_data), sizeof(*shared_ctl));
|
||||||
//printf("sizeof(*shared_ctl): %i (%x)\n", sizeof(*shared_ctl), sizeof(*shared_ctl));
|
|
||||||
|
|
||||||
Reset940(1);
|
Reset940(1, 2);
|
||||||
Pause940(1);
|
Pause940(1);
|
||||||
|
|
||||||
gp2x_memregs[0x3B46>>1] = 0xffff; // clear pending DUALCPU interrupts for 940
|
gp2x_memregs[0x3B46>>1] = 0xffff; // clear pending DUALCPU interrupts for 940
|
||||||
|
@ -312,7 +312,7 @@ void YM2612Init_940(int baseclock, int rate)
|
||||||
|
|
||||||
if (shared_mem == NULL)
|
if (shared_mem == NULL)
|
||||||
{
|
{
|
||||||
shared_mem = (unsigned char *) mmap(0, 0x210000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x3000000);
|
shared_mem = (unsigned char *) mmap(0, 0x210000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0x2000000);
|
||||||
if(shared_mem == MAP_FAILED)
|
if(shared_mem == MAP_FAILED)
|
||||||
{
|
{
|
||||||
printf("mmap(shared_data) failed with %i\n", errno);
|
printf("mmap(shared_data) failed with %i\n", errno);
|
||||||
|
@ -373,11 +373,12 @@ void YM2612Init_940(int baseclock, int rate)
|
||||||
/* now cause 940 to init it's ym2612 stuff */
|
/* now cause 940 to init it's ym2612 stuff */
|
||||||
shared_ctl->baseclock = baseclock;
|
shared_ctl->baseclock = baseclock;
|
||||||
shared_ctl->rate = rate;
|
shared_ctl->rate = rate;
|
||||||
shared_ctl->job = JOB940_YM2612INIT;
|
shared_ctl->jobs[0] = JOB940_YM2612INIT;
|
||||||
|
shared_ctl->jobs[1] = 0;
|
||||||
shared_ctl->busy = 1;
|
shared_ctl->busy = 1;
|
||||||
|
|
||||||
/* start the 940 */
|
/* start the 940 */
|
||||||
Reset940(0);
|
Reset940(0, 2);
|
||||||
Pause940(0);
|
Pause940(0);
|
||||||
|
|
||||||
// YM2612ResetChip_940(); // will be done on JOB940_YM2612INIT
|
// YM2612ResetChip_940(); // will be done on JOB940_YM2612INIT
|
||||||
|
@ -396,7 +397,7 @@ void YM2612ResetChip_940(void)
|
||||||
|
|
||||||
internal_reset();
|
internal_reset();
|
||||||
|
|
||||||
add_job_940(JOB940_YM2612RESETCHIP);
|
add_job_940(JOB940_YM2612RESETCHIP, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -444,7 +445,7 @@ void YM2612UpdateOne_940(short *buffer, int length, int stereo)
|
||||||
shared_ctl->writebuffsel ^= 1;
|
shared_ctl->writebuffsel ^= 1;
|
||||||
shared_ctl->length = length;
|
shared_ctl->length = length;
|
||||||
shared_ctl->stereo = stereo;
|
shared_ctl->stereo = stereo;
|
||||||
add_job_940(JOB940_YM2612UPDATEONE);
|
add_job_940(JOB940_YM2612UPDATEONE, 0);
|
||||||
//spend_cycles(512);
|
//spend_cycles(512);
|
||||||
//printf("SRCPND: %08lx, INTMODE: %08lx, INTMASK: %08lx, INTPEND: %08lx\n",
|
//printf("SRCPND: %08lx, INTMODE: %08lx, INTMASK: %08lx, INTPEND: %08lx\n",
|
||||||
// gp2x_memregl[0x4500>>2], gp2x_memregl[0x4504>>2], gp2x_memregl[0x4508>>2], gp2x_memregl[0x4510>>2]);
|
// gp2x_memregl[0x4500>>2], gp2x_memregl[0x4504>>2], gp2x_memregl[0x4508>>2], gp2x_memregl[0x4510>>2]);
|
||||||
|
|
|
@ -31,9 +31,9 @@ code940: @ interrupt table:
|
||||||
b .Begin
|
b .Begin
|
||||||
.b_irq:
|
.b_irq:
|
||||||
mov r12, #6
|
mov r12, #6
|
||||||
mov sp, #0x100000 @ reset stack
|
mov sp, #0x100000 @ reset stack
|
||||||
sub sp, sp, #4
|
sub sp, sp, #4
|
||||||
mov r1, #0xbd000000 @ assume we live @ 0x3000000 bank
|
mov r1, #0xbe000000 @ assume we live @ 0x2000000 bank
|
||||||
orr r2, r1, #0x3B00
|
orr r2, r1, #0x3B00
|
||||||
orr r2, r2, #0x0046
|
orr r2, r2, #0x0046
|
||||||
mvn r3, #0
|
mvn r3, #0
|
||||||
|
@ -48,51 +48,51 @@ code940: @ interrupt table:
|
||||||
b .Begin
|
b .Begin
|
||||||
|
|
||||||
.Begin:
|
.Begin:
|
||||||
mov sp, #0x100000 @ set the stack top (1M)
|
mov sp, #0x100000 @ set the stack top (1M)
|
||||||
sub sp, sp, #4 @ minus 4
|
sub sp, sp, #4 @ minus 4
|
||||||
|
|
||||||
@ set up memory region 0 -- the whole 4GB address space
|
@ set up memory region 0 -- the whole 4GB address space
|
||||||
mov r0, #(0x1f<<1)|1 @ region data
|
mov r0, #(0x1f<<1)|1 @ region data
|
||||||
mcr p15, 0, r0, c6, c0, 0 @ opcode2 ~ data/instr
|
mcr p15, 0, r0, c6, c0, 0 @ opcode2 ~ data/instr
|
||||||
mcr p15, 0, r0, c6, c0, 1
|
mcr p15, 0, r0, c6, c0, 1
|
||||||
|
|
||||||
@ set up region 1 which is the first 2 megabytes.
|
@ set up region 1 which is the first 2 megabytes.
|
||||||
mov r0, #(0x14<<1)|1 @ region data
|
mov r0, #(0x14<<1)|1 @ region data
|
||||||
mcr p15, 0, r0, c6, c1, 0
|
mcr p15, 0, r0, c6, c1, 0
|
||||||
mcr p15, 0, r0, c6, c1, 1
|
mcr p15, 0, r0, c6, c1, 1
|
||||||
|
|
||||||
@ set up region 2: 64k 0x200000-0x210000
|
@ set up region 2: 64k 0x200000-0x210000
|
||||||
mov r0, #(0x0f<<1)|1
|
mov r0, #(0x0f<<1)|1
|
||||||
orr r0, r0, #0x200000
|
orr r0, r0, #0x200000
|
||||||
mcr p15, 0, r0, c6, c2, 0
|
mcr p15, 0, r0, c6, c2, 0
|
||||||
mcr p15, 0, r0, c6, c2, 1
|
mcr p15, 0, r0, c6, c2, 1
|
||||||
|
|
||||||
@ set up region 3: 64k 0xbd000000-0xbd010000 (hw control registers)
|
@ set up region 3: 64k 0xbe000000-0xbe010000 (hw control registers)
|
||||||
mov r0, #(0x0f<<1)|1
|
mov r0, #(0x0f<<1)|1
|
||||||
orr r0, r0, #0xbd000000
|
orr r0, r0, #0xbe000000
|
||||||
mcr p15, 0, r0, c6, c3, 0
|
mcr p15, 0, r0, c6, c3, 0
|
||||||
mcr p15, 0, r0, c6, c3, 1
|
mcr p15, 0, r0, c6, c3, 1
|
||||||
|
|
||||||
@ set region 1 to be cacheable (so the first 2M will be cacheable)
|
@ set region 1 to be cacheable (so the first 2M will be cacheable)
|
||||||
mov r0, #2
|
mov r0, #2
|
||||||
mcr p15, 0, r0, c2, c0, 0
|
mcr p15, 0, r0, c2, c0, 0
|
||||||
mcr p15, 0, r0, c2, c0, 1
|
mcr p15, 0, r0, c2, c0, 1
|
||||||
|
|
||||||
@ set region 1 to be bufferable too (only data)
|
@ set region 1 to be bufferable too (only data)
|
||||||
mcr p15, 0, r0, c3, c0, 0
|
mcr p15, 0, r0, c3, c0, 0
|
||||||
|
|
||||||
@ set protection, allow accsess only to regions 1 and 2
|
@ set protection, allow accsess only to regions 1 and 2
|
||||||
mov r0, #(3<<6)|(3<<4)|(3<<2)|(0) @ data: [full, full, full, no access] for regions [3 2 1 0]
|
mov r0, #(3<<6)|(3<<4)|(3<<2)|(0) @ data: [full, full, full, no access] for regions [3 2 1 0]
|
||||||
mcr p15, 0, r0, c5, c0, 0
|
mcr p15, 0, r0, c5, c0, 0
|
||||||
mov r0, #(0<<6)|(0<<4)|(3<<2)|(0) @ instructions: [no access, no, full, no]
|
mov r0, #(0<<6)|(0<<4)|(3<<2)|(0) @ instructions: [no access, no, full, no]
|
||||||
mcr p15, 0, r0, c5, c0, 1
|
mcr p15, 0, r0, c5, c0, 1
|
||||||
|
|
||||||
mrc p15, 0, r0, c1, c0, 0 @ fetch current control reg
|
mrc p15, 0, r0, c1, c0, 0 @ fetch current control reg
|
||||||
orr r0, r0, #1 @ 0x00000001: enable protection unit
|
orr r0, r0, #1 @ 0x00000001: enable protection unit
|
||||||
orr r0, r0, #4 @ 0x00000004: enable D cache
|
orr r0, r0, #4 @ 0x00000004: enable D cache
|
||||||
orr r0, r0, #0x1000 @ 0x00001000: enable I cache
|
orr r0, r0, #0x1000 @ 0x00001000: enable I cache
|
||||||
orr r0, r0, #0xC0000000 @ 0xC0000000: async+fastbus
|
orr r0, r0, #0xC0000000 @ 0xC0000000: async+fastbus
|
||||||
mcr p15, 0, r0, c1, c0, 0 @ set control reg
|
mcr p15, 0, r0, c1, c0, 0 @ set control reg
|
||||||
|
|
||||||
@ flush (invalidate) the cache (just in case)
|
@ flush (invalidate) the cache (just in case)
|
||||||
mov r0, #0
|
mov r0, #0
|
||||||
|
@ -172,3 +172,5 @@ wait_irq:
|
||||||
b .b_reserved
|
b .b_reserved
|
||||||
|
|
||||||
.pool
|
.pool
|
||||||
|
|
||||||
|
@ vim:filetype=ignored:
|
||||||
|
|
|
@ -8,24 +8,26 @@ enum _940_job_t {
|
||||||
JOB940_NUMJOBS
|
JOB940_NUMJOBS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MAX_940JOBS 2
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
YM2612 ym2612; /* current state of the emulated YM2612 */
|
YM2612 ym2612; /* current state of the emulated YM2612 */
|
||||||
int mix_buffer[44100/50*2]; /* this is where the YM2612 samples will be mixed to */
|
int mix_buffer[44100/50*2]; /* this is where the YM2612 samples will be mixed to */
|
||||||
|
short mp3_buffer[2][1152*2]; /* buffer for mp3 decoder's output */
|
||||||
} _940_data_t;
|
} _940_data_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int job; /* a job for second core */
|
int jobs[MAX_940JOBS]; /* jobs for second core */
|
||||||
int busy; /* busy status of the 940 core */
|
int busy; /* busy status of the 940 core */
|
||||||
int length; /* number of samples to mix (882 max) */
|
int length; /* number of samples to mix (882 max) */
|
||||||
int stereo; /* mix samples as stereo, doubles sample count automatically */
|
int stereo; /* mix samples as stereo, doubles sample count automatically */
|
||||||
int baseclock; /* ym2612 settings */
|
int baseclock; /* ym2612 settings */
|
||||||
int rate;
|
int rate;
|
||||||
int writebuffsel; /* which write buffer to use (from 940 side) */
|
int writebuffsel; /* which write buffer to use (from 940 side) */
|
||||||
UINT16 writebuff0[2048]; /* 1024 for savestates, 1024 extra */
|
UINT16 writebuff0[2048]; /* list of writes to ym2612, 1024 for savestates, 1024 extra */
|
||||||
UINT16 writebuff1[2048];
|
UINT16 writebuff1[2048];
|
||||||
int vstarts[8]; /* debug: number of starts from each of 8 vectors */
|
int vstarts[8]; /* debug: number of starts from each of 8 vectors */
|
||||||
int loopc; /* debug: main loop counter */
|
int loopc; /* debug: main loop counter */
|
||||||
|
|
|
@ -10,7 +10,7 @@ CROSS = arm-linux-
|
||||||
dprint = 1
|
dprint = 1
|
||||||
#mz80 = 1
|
#mz80 = 1
|
||||||
#debug_cyclone = 1
|
#debug_cyclone = 1
|
||||||
asm_memory = 1
|
asm_memory = 0 # TODO
|
||||||
asm_render = 1
|
asm_render = 1
|
||||||
asm_ym2612 = 1
|
asm_ym2612 = 1
|
||||||
#profile = 1
|
#profile = 1
|
||||||
|
@ -42,7 +42,7 @@ OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory
|
||||||
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o
|
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o
|
||||||
# Pico - CD
|
# Pico - CD
|
||||||
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
|
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
|
||||||
../../Pico/cd/cd_sys.o
|
../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o
|
||||||
# asm stuff
|
# asm stuff
|
||||||
ifeq "$(asm_render)" "1"
|
ifeq "$(asm_render)" "1"
|
||||||
DEFINC += -D_ASM_DRAW_C
|
DEFINC += -D_ASM_DRAW_C
|
||||||
|
|
|
@ -374,7 +374,7 @@ int emu_ReloadRom(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gettimeofday(¬iceMsgTime, 0);
|
gettimeofday(¬iceMsgTime, 0);
|
||||||
|
printf("PicoMCD: %x\n", PicoMCD);
|
||||||
// load SRAM for this ROM
|
// load SRAM for this ROM
|
||||||
if(currentConfig.EmuOpt & 1)
|
if(currentConfig.EmuOpt & 1)
|
||||||
emu_SaveLoadGame(1, 1);
|
emu_SaveLoadGame(1, 1);
|
||||||
|
@ -586,8 +586,10 @@ void osd_text(int x, int y, char *text)
|
||||||
|
|
||||||
static void cd_leds(void)
|
static void cd_leds(void)
|
||||||
{
|
{
|
||||||
static int old_reg = 0;
|
// mmu problems?
|
||||||
if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change
|
// static
|
||||||
|
int old_reg;
|
||||||
|
// if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change
|
||||||
old_reg = Pico_mcd->s68k_regs[0];
|
old_reg = Pico_mcd->s68k_regs[0];
|
||||||
|
|
||||||
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {
|
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {
|
||||||
|
@ -1021,7 +1023,7 @@ void emu_Loop(void)
|
||||||
if(PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old || crashed_940) {
|
if(PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old || crashed_940) {
|
||||||
/* if 940 is turned off, we need it to be put back to sleep */
|
/* if 940 is turned off, we need it to be put back to sleep */
|
||||||
if (!(PicoOpt&0x200) && ((PicoOpt^PicoOpt_old)&0x200)) {
|
if (!(PicoOpt&0x200) && ((PicoOpt^PicoOpt_old)&0x200)) {
|
||||||
Reset940(1);
|
Reset940(1, 2);
|
||||||
Pause940(1);
|
Pause940(1);
|
||||||
}
|
}
|
||||||
sound_rerate();
|
sound_rerate();
|
||||||
|
|
|
@ -223,9 +223,9 @@ void Pause940(int yes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Reset940(int yes)
|
void Reset940(int yes, int bank)
|
||||||
{
|
{
|
||||||
gp2x_memregs[0x3B48>>1] = ((yes&1) << 7) | (0x03); /* bank=3 */
|
gp2x_memregs[0x3B48>>1] = ((yes&1) << 7) | (bank & 0x03); /* bank=3 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ char *ext_menu = 0, *ext_state = 0;
|
||||||
|
|
||||||
void gp2x_deinit(void)
|
void gp2x_deinit(void)
|
||||||
{
|
{
|
||||||
Reset940(1);
|
Reset940(1, 3);
|
||||||
Pause940(1);
|
Pause940(1);
|
||||||
|
|
||||||
gp2x_video_changemode(15);
|
gp2x_video_changemode(15);
|
||||||
|
|
|
@ -25,7 +25,7 @@ unsigned long gp2x_joystick_read(int allow_usb_joy);
|
||||||
|
|
||||||
/* 940 core */
|
/* 940 core */
|
||||||
void Pause940(int yes);
|
void Pause940(int yes);
|
||||||
void Reset940(int yes);
|
void Reset940(int yes, int bank);
|
||||||
|
|
||||||
|
|
||||||
extern void *gp2x_screen;
|
extern void *gp2x_screen;
|
||||||
|
|
|
@ -86,8 +86,8 @@ int main(int argc, char *argv[])
|
||||||
mmuhack_status = ret;
|
mmuhack_status = ret;
|
||||||
}
|
}
|
||||||
cpuctrl_init();
|
cpuctrl_init();
|
||||||
Reset940(1);
|
// Reset940(1);
|
||||||
Pause940(1);
|
// Pause940(1);
|
||||||
if (currentConfig.EmuOpt&0x100) {
|
if (currentConfig.EmuOpt&0x100) {
|
||||||
printf("setting RAM timings.. "); fflush(stdout);
|
printf("setting RAM timings.. "); fflush(stdout);
|
||||||
// craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2
|
// craigix: --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2
|
||||||
|
|
|
@ -959,7 +959,7 @@ static void draw_menu_root(int menu_sel)
|
||||||
} else {
|
} else {
|
||||||
y += 30;
|
y += 30;
|
||||||
}
|
}
|
||||||
gp2x_text_out8(tl_x, (y+=10), "Load new ROM");
|
gp2x_text_out8(tl_x, (y+=10), "Load new ROM/ISO");
|
||||||
gp2x_text_out8(tl_x, (y+=10), "Change options");
|
gp2x_text_out8(tl_x, (y+=10), "Change options");
|
||||||
gp2x_text_out8(tl_x, (y+=10), "Configure controls");
|
gp2x_text_out8(tl_x, (y+=10), "Configure controls");
|
||||||
gp2x_text_out8(tl_x, (y+=10), "Credits");
|
gp2x_text_out8(tl_x, (y+=10), "Credits");
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// pico.c
|
// pico.c
|
||||||
#define CAN_HANDLE_240_LINES 1
|
#define CAN_HANDLE_240_LINES 1
|
||||||
|
|
||||||
//#define dprintf(f,...) printf(f"\n",##__VA_ARGS__)
|
//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)
|
||||||
#define dprintf(x...)
|
#define dprintf(x...)
|
||||||
|
|
||||||
#endif //PORT_CONFIG_H
|
#endif //PORT_CONFIG_H
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
#define VERSION "0.965"
|
#define VERSION "1.10"
|
||||||
|
|
||||||
|
|
|
@ -327,7 +327,7 @@ void Pause940(int yes)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Reset940(int yes)
|
void Reset940(int yes, int bank)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue