cyclone_debug improvements pt. 2

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@185 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-07-05 20:34:02 +00:00
parent 55ca4154a2
commit 2d0b15bb2c
7 changed files with 95 additions and 28 deletions

View file

@ -7,7 +7,7 @@
// For commercial use, separate licencing terms must be obtained. // For commercial use, separate licencing terms must be obtained.
//#define __debug_io #define __debug_io
#include "PicoInt.h" #include "PicoInt.h"
@ -307,7 +307,7 @@ u8 CPU_CALL PicoRead8(u32 a)
dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc); dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
#endif #endif
#if defined(EMU_C68K) && defined(EMU_M68K) #if defined(EMU_C68K) && defined(EMU_M68K)
if(a>=Pico.romsize&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b) { if(a>=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) {
lastread_a = a; lastread_a = a;
lastread_d[lrp_cyc++&15] = (u8)d; lastread_d[lrp_cyc++&15] = (u8)d;
} }
@ -343,7 +343,7 @@ u16 CPU_CALL PicoRead16(u32 a)
dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
#endif #endif
#if defined(EMU_C68K) && defined(EMU_M68K) #if defined(EMU_C68K) && defined(EMU_M68K)
if(a>=Pico.romsize&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b) { if(a>=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) {
lastread_a = a; lastread_a = a;
lastread_d[lrp_cyc++&15] = d; lastread_d[lrp_cyc++&15] = d;
} }
@ -374,7 +374,7 @@ u32 CPU_CALL PicoRead32(u32 a)
dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc); dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);
#endif #endif
#if defined(EMU_C68K) && defined(EMU_M68K) #if defined(EMU_C68K) && defined(EMU_M68K)
if(a>=Pico.romsize&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b) { if(a>=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) {
lastread_a = a; lastread_a = a;
lastread_d[lrp_cyc++&15] = d; lastread_d[lrp_cyc++&15] = d;
} }
@ -500,39 +500,72 @@ unsigned int m68k_read_pcrelative_CD16(unsigned int a);
unsigned int m68k_read_pcrelative_CD32(unsigned int a); unsigned int m68k_read_pcrelative_CD32(unsigned int a);
// these are allowed to access RAM // these are allowed to access RAM
unsigned int m68k_read_pcrelative_8 (unsigned int a) { static unsigned int m68k_read_8 (unsigned int a, int do_fake) {
a&=0xffffff; a&=0xffffff;
if(PicoMCD&1) return m68k_read_pcrelative_CD8(a); if(PicoMCD&1) return m68k_read_pcrelative_CD8(a);
if(a<Pico.romsize) return *(u8 *)(Pico.rom+(a^1)); // Rom if(a<Pico.romsize) return *(u8 *)(Pico.rom+(a^1)); // Rom
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram
return 0;//(u8) lastread_d; return 0;
} }
unsigned int m68k_read_pcrelative_16(unsigned int a) { static unsigned int m68k_read_16(unsigned int a, int do_fake) {
a&=0xffffff; a&=0xffffff;
if(PicoMCD&1) return m68k_read_pcrelative_CD16(a); if(PicoMCD&1) return m68k_read_pcrelative_CD16(a);
if(a<Pico.romsize) return *(u16 *)(Pico.rom+(a&~1)); // Rom if(a<Pico.romsize) return *(u16 *)(Pico.rom+(a&~1)); // Rom
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram
return 0;//(u16) lastread_d; return 0;
} }
unsigned int m68k_read_pcrelative_32(unsigned int a) { static unsigned int m68k_read_32(unsigned int a, int do_fake) {
a&=0xffffff; a&=0xffffff;
if(PicoMCD&1) return m68k_read_pcrelative_CD32(a); if(PicoMCD&1) return m68k_read_pcrelative_CD32(a);
if(a<Pico.romsize) { u16 *pm=(u16 *)(Pico.rom+(a&~1)); return (pm[0]<<16)|pm[1]; } if(a<Pico.romsize) { u16 *pm=(u16 *)(Pico.rom+(a&~1)); return (pm[0]<<16)|pm[1]; }
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
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
return 0;//lastread_d; return 0;
} }
unsigned int m68k_read_immediate_16(unsigned int a) { return m68k_read_pcrelative_16(a); } unsigned int m68k_read_pcrelative_8 (unsigned int a) { return m68k_read_8 (a, 1); }
unsigned int m68k_read_immediate_32(unsigned int a) { return m68k_read_pcrelative_32(a); } unsigned int m68k_read_pcrelative_16(unsigned int a) { return m68k_read_16(a, 1); }
unsigned int m68k_read_disassembler_8 (unsigned int a) { return m68k_read_pcrelative_8 (a); } unsigned int m68k_read_pcrelative_32(unsigned int a) { return m68k_read_32(a, 1); }
unsigned int m68k_read_disassembler_16(unsigned int a) { return m68k_read_pcrelative_16(a); } unsigned int m68k_read_immediate_16(unsigned int a) { return m68k_read_16(a, 0); }
unsigned int m68k_read_disassembler_32(unsigned int a) { return m68k_read_pcrelative_32(a); } unsigned int m68k_read_immediate_32(unsigned int a) { return m68k_read_32(a, 0); }
unsigned int m68k_read_disassembler_8 (unsigned int a) { return m68k_read_8 (a, 0); }
unsigned int m68k_read_disassembler_16(unsigned int a) { return m68k_read_16(a, 0); }
unsigned int m68k_read_disassembler_32(unsigned int a) { return m68k_read_32(a, 0); }
#ifdef EMU_C68K #ifdef EMU_C68K
// ROM only // ROM only
unsigned int m68k_read_memory_8(unsigned int a) { if(a<Pico.romsize) return *(u8 *) (Pico.rom+(a^1)); return (u8) lastread_d[lrp_mus++&15]; } unsigned int m68k_read_memory_8(unsigned int a)
unsigned int m68k_read_memory_16(unsigned int a) { if(a<Pico.romsize) return *(u16 *)(Pico.rom+(a&~1));return (u16) lastread_d[lrp_mus++&15]; } {
unsigned int m68k_read_memory_32(unsigned int a) { if(a<Pico.romsize) {u16 *pm=(u16 *)(Pico.rom+(a&~1));return (pm[0]<<16)|pm[1];} return lastread_d[lrp_mus++&15]; } u8 d;
if(a<Pico.romsize) d = *(u8 *) (Pico.rom+(a^1));
else d = (u8) lastread_d[lrp_mus++&15];
#ifdef __debug_io
dprintf("r8_mu : %06x, %02x @%06x", a&0xffffff, d, SekPc);
#endif
return d;
}
unsigned int m68k_read_memory_16(unsigned int a)
{
u16 d;
if(a<Pico.romsize) d = *(u16 *)(Pico.rom+(a&~1));
else d = (u16) lastread_d[lrp_mus++&15];
#ifdef __debug_io
dprintf("r16_mu: %06x, %04x @%06x", a&0xffffff, d, SekPc);
#endif
return d;
}
unsigned int m68k_read_memory_32(unsigned int a)
{
u32 d;
if(a<Pico.romsize) {u16 *pm=(u16 *)(Pico.rom+(a&~1));d=(pm[0]<<16)|pm[1];}
else d = lastread_d[lrp_mus++&15];
#ifdef __debug_io
dprintf("r32_mu: %06x, %08x @%06x", a&0xffffff, d, SekPc);
#endif
return d;
}
// ignore writes, Cyclone already done that // ignore writes, Cyclone already done that
void m68k_write_memory_8(unsigned int address, unsigned int value) { lastwrite_mus_d[lwp_mus++&15] = value; } void m68k_write_memory_8(unsigned int address, unsigned int value) { lastwrite_mus_d[lwp_mus++&15] = value; }

View file

@ -431,7 +431,7 @@ static int PicoFrameHints(void)
getSamples(y); getSamples(y);
// Run scanline: // Run scanline:
if (Pico.m.dma_bytes) SekCycleCnt+=CheckDMA(); if (Pico.m.dma_bytes) SekCyclesBurn(CheckDMA());
SekRun(cycles_68k); SekRun(cycles_68k);
if ((PicoOpt&4) && Pico.m.z80Run) { if ((PicoOpt&4) && Pico.m.z80Run) {
if (Pico.m.z80Run & 2) z80CycleAim+=cycles_z80; if (Pico.m.z80Run & 2) z80CycleAim+=cycles_z80;

View file

@ -110,8 +110,17 @@ extern int SekCycleAimS68k;
#define SekCyclesResetS68k() {SekCycleCntS68k=SekCycleAimS68k=0;} #define SekCyclesResetS68k() {SekCycleCntS68k=SekCycleAimS68k=0;}
#define SekCyclesDoneS68k() (SekCycleAimS68k-SekCyclesLeftS68k) #define SekCyclesDoneS68k() (SekCycleAimS68k-SekCyclesLeftS68k)
// does not work as expected // debug cyclone
//extern int z80ExtraCycles; // extra z80 cycles, used when z80 is [en|dis]abled #if defined(EMU_C68K) && defined(EMU_M68K)
#undef SekSetCyclesLeftNoMCD
#undef SekSetCyclesLeft
#undef SekCyclesBurn
#undef SekEndRun
#define SekSetCyclesLeftNoMCD(c)
#define SekSetCyclesLeft(c)
#define SekCyclesBurn(c)
#define SekEndRun(c)
#endif
extern int PicoMCD; extern int PicoMCD;

View file

@ -72,6 +72,12 @@ static int SekUnrecognizedOpcode()
PicoCpu.stopped = 1; PicoCpu.stopped = 1;
return 1; return 1;
} }
#ifdef EMU_M68K // debugging cyclone
{
extern int have_illegal;
have_illegal = 1;
}
#endif
//exit(1); //exit(1);
return 0; return 0;
} }
@ -144,6 +150,8 @@ int SekReset()
#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 m68k_set_context(&PicoM68kCPU); // 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(); m68k_pulse_reset();
#endif #endif

View file

@ -89,7 +89,7 @@ static void DmaSlow(int len)
if(Pico.m.scanline != -1) { if(Pico.m.scanline != -1) {
Pico.m.dma_bytes += len; Pico.m.dma_bytes += len;
if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt+=CheckDMA(); if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCyclesBurn(CheckDMA());
else SekSetCyclesLeftNoMCD(SekCyclesLeftNoMCD - CheckDMA()); else SekSetCyclesLeftNoMCD(SekCyclesLeftNoMCD - CheckDMA());
} else { } else {
// be approximate in non-accurate mode // be approximate in non-accurate mode

View file

@ -29,7 +29,7 @@ static int new_irq_level(int level)
} }
#ifdef EMU_M68K #ifdef EMU_M68K
static int SekIntAckS68k(int level) static int SekIntAckS68kM(int level)
{ {
int level_new = new_irq_level(level); int level_new = new_irq_level(level);
dprintf("s68kACK %i -> %i", level, level_new); dprintf("s68kACK %i -> %i", level, level_new);
@ -82,7 +82,7 @@ int SekInitS68k()
m68k_set_context(&PicoS68kCPU); m68k_set_context(&PicoS68kCPU);
m68k_set_cpu_type(M68K_CPU_TYPE_68000); m68k_set_cpu_type(M68K_CPU_TYPE_68000);
m68k_init(); m68k_init();
m68k_set_int_ack_callback(SekIntAckS68k); m68k_set_int_ack_callback(SekIntAckS68kM);
// m68k_pulse_reset(); // not yet, memmap is not set up // m68k_pulse_reset(); // not yet, memmap is not set up
m68k_set_context(oldcontext); m68k_set_context(oldcontext);
} }
@ -111,6 +111,8 @@ int SekResetS68k()
void *oldcontext = m68ki_cpu_p; void *oldcontext = m68ki_cpu_p;
m68k_set_context(&PicoS68kCPU); m68k_set_context(&PicoS68kCPU);
m68ki_cpu.sp[0]=0;
m68k_set_irq(0);
m68k_pulse_reset(); m68k_pulse_reset();
m68k_set_context(oldcontext); m68k_set_context(oldcontext);
} }

View file

@ -5,9 +5,8 @@ CROSS = arm-linux-
#CROSS = $(devkit_path)bin/arm-linux- #CROSS = $(devkit_path)bin/arm-linux-
# settings # settings
dprint = 1
#mz80 = 1 #mz80 = 1
#debug_cyclone = 1 debug_cyclone = 0
asm_memory = 1 asm_memory = 1
asm_render = 1 asm_render = 1
asm_ym2612 = 1 asm_ym2612 = 1
@ -18,8 +17,19 @@ asm_cdmemory = 1
#use_musashi = 1 #use_musashi = 1
#up = 1 #up = 1
ifeq "$(debug_cyclone)" "1"
use_cyclone = 1
use_musashi = 1
asm_memory = 0
asm_cdmemory = 0
endif
ifneq "$(use_musashi)" "1"
use_cyclone = 1
endif
DEFINC = -I../.. -I. -DARM -D__GP2X__ -D_UNZIP_SUPPORT # -DBENCHMARK DEFINC = -I../.. -I. -DARM -D__GP2X__ -D_UNZIP_SUPPORT # -DBENCHMARK
COPT_COMMON = -static -O3 -ftracer -fstrength-reduce -Wall -funroll-loops -fomit-frame-pointer -fstrict-aliasing -ffast-math # -s COPT_COMMON = -static -Wall -O3 -ftracer -fstrength-reduce -funroll-loops -fomit-frame-pointer -fstrict-aliasing -ffast-math # -s
ifeq "$(profile)" "1" ifeq "$(profile)" "1"
COPT_COMMON += -fprofile-generate COPT_COMMON += -fprofile-generate
endif endif
@ -82,12 +92,17 @@ OBJS += ../../zlib/gzio.o ../../zlib/inffast.o ../../zlib/inflate.o ../../zlib/i
OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o OBJS += ../../unzip/unzip.o ../../unzip/unzip_stream.o
# mp3 # mp3
OBJS += mp3.o OBJS += mp3.o
# debug
ifeq "$(debug_cyclone)" "1"
OBJS += ../../Pico/_cyclone_debug.o ../../cpu/musashi/m68kdasm.o
endif
# CPU cores # CPU cores
ifeq "$(use_musashi)" "1" ifeq "$(use_musashi)" "1"
DEFINC += -DEMU_M68K DEFINC += -DEMU_M68K
OBJS += ../../cpu/musashi/m68kcpu.o ../../cpu/musashi/m68kopac.o ../../cpu/musashi/m68kopdm.o OBJS += ../../cpu/musashi/m68kcpu.o ../../cpu/musashi/m68kopac.o ../../cpu/musashi/m68kopdm.o
OBJS += ../../cpu/musashi/m68kopnz.o ../../cpu/musashi/m68kops.o OBJS += ../../cpu/musashi/m68kopnz.o ../../cpu/musashi/m68kops.o
else endif
ifeq "$(use_cyclone)" "1"
DEFINC += -DEMU_C68K DEFINC += -DEMU_C68K
OBJS += ../../cpu/Cyclone/proj/Cyclone.o OBJS += ../../cpu/Cyclone/proj/Cyclone.o
endif endif