// This is part of Pico Library\r
\r
// (c) Copyright 2004 Dave, All rights reserved.\r
-// (c) Copyright 2006 notaz, All rights reserved.\r
+// (c) Copyright 2006,2007 notaz, All rights reserved.\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
\r
\r
-//#define __debug_io\r
-\r
#include "PicoInt.h"\r
\r
#include "sound/ym2612.h"\r
if ((a&1)==0) d>>=8;\r
\r
end:\r
-#ifdef __debug_io\r
- dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);\r
#ifdef EMU_CORE_DEBUG\r
if (a>=Pico.romsize) {\r
lastread_a = a;\r
else d = OtherRead16(a, 16);\r
\r
end:\r
-#ifdef __debug_io\r
- dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);\r
#ifdef EMU_CORE_DEBUG\r
if (a>=Pico.romsize) {\r
lastread_a = a;\r
else d = (OtherRead16(a, 32)<<16)|OtherRead16(a+2, 32);\r
\r
end:\r
-#ifdef __debug_io\r
- dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);\r
#ifdef EMU_CORE_DEBUG\r
if (a>=Pico.romsize) {\r
lastread_a = a;\r
#if !defined(_ASM_MEMORY_C) || defined(_ASM_MEMORY_C_AMIPS)\r
PICO_INTERNAL_ASM void PicoWrite8(u32 a,u8 d)\r
{\r
-#ifdef __debug_io\r
- dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);\r
#ifdef EMU_CORE_DEBUG\r
lastwrite_cyc_d[lwp_cyc++&15] = d;\r
#endif\r
\r
void PicoWrite16(u32 a,u16 d)\r
{\r
-#ifdef __debug_io\r
- dprintf("w16: %06x, %04x", a&0xffffff, d);\r
-#endif\r
+ elprintf(EL_IO, "w16: %06x, %04x", a&0xffffff, d);\r
#ifdef EMU_CORE_DEBUG\r
lastwrite_cyc_d[lwp_cyc++&15] = d;\r
#endif\r
\r
static void PicoWrite32(u32 a,u32 d)\r
{\r
-#ifdef __debug_io\r
- dprintf("w32: %06x, %08x", a&0xffffff, d);\r
-#endif\r
+ elprintf(EL_IO, "w32: %06x, %08x", a&0xffffff, d);\r
#ifdef EMU_CORE_DEBUG\r
lastwrite_cyc_d[lwp_cyc++&15] = d;\r
#endif\r
if (a<Pico.romsize && m68ki_cpu_p==&PicoCpuMM68k)\r
d = *(u8 *) (Pico.rom+(a^1));\r
else d = (u8) lastread_d[lrp_mus++&15];\r
-#ifdef __debug_io\r
- dprintf("r8_mu : %06x, %02x @%06x", a&0xffffff, d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "r8_mu : %06x, %02x @%06x", a&0xffffff, d, SekPc);\r
return d;\r
}\r
unsigned int m68k_read_memory_16(unsigned int a)\r
if (a<Pico.romsize && m68ki_cpu_p==&PicoCpuMM68k)\r
d = *(u16 *)(Pico.rom+(a&~1));\r
else d = (u16) lastread_d[lrp_mus++&15];\r
-#ifdef __debug_io\r
- dprintf("r16_mu: %06x, %04x @%06x", a&0xffffff, d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "r16_mu: %06x, %04x @%06x", a&0xffffff, d, SekPc);\r
return d;\r
}\r
unsigned int m68k_read_memory_32(unsigned int a)\r
{ u16 *pm=(u16 *)(Pico.rom+(a&~1));d=(pm[0]<<16)|pm[1]; }\r
else if (a <= 0x78) d = m68k_read_32(a, 0);\r
else d = lastread_d[lrp_mus++&15];\r
-#ifdef __debug_io\r
- dprintf("r32_mu: %06x, %08x @%06x", a&0xffffff, d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "r32_mu: %06x, %08x @%06x", a&0xffffff, d, SekPc);\r
return d;\r
}\r
\r
// (c) Copyright 2007, Grazvydas "notaz" Ignotas\r
\r
\r
-//#define __debug_io\r
-\r
#include "../PicoInt.h"\r
\r
#include "../sound/ym2612.h"\r
#define UTYPES_DEFINED\r
#endif\r
\r
-//#define __debug_io\r
-//#define __debug_io2\r
-\r
//#define rdprintf dprintf\r
#define rdprintf(...)\r
//#define wrdprintf dprintf\r
#define wrdprintf(...)\r
-#define plprintf dprintf\r
-//#define plprintf(...)\r
\r
#ifdef EMU_CORE_DEBUG\r
extern u32 lastread_a, lastread_d[16], lastwrite_cyc_d[16];\r
d = Read_CDC_Host(0);\r
goto end;\r
case 0xA:\r
- dprintf("m68k FIXME: reserved read");\r
+ elprintf(EL_UIO, "m68k FIXME: reserved read");\r
goto end;\r
case 0xC:\r
d = Pico_mcd->m.timer_stopwatch >> 16;\r
goto end;\r
}\r
\r
- dprintf("m68k_regs FIXME invalid read @ %02x", a);\r
+ elprintf(EL_UIO, "m68k_regs FIXME invalid read @ %02x", a);\r
\r
end:\r
\r
- // dprintf("ret = %04x", d);\r
return d;\r
}\r
#endif\r
switch (a) {\r
case 0:\r
d &= 1;\r
- if ((d&1) && (Pico_mcd->s68k_regs[0x33]&(1<<2))) { dprintf("m68k: s68k irq 2"); SekInterruptS68k(2); }\r
+ if ((d&1) && (Pico_mcd->s68k_regs[0x33]&(1<<2))) { elprintf(EL_INTS, "m68k: s68k irq 2"); SekInterruptS68k(2); }\r
return;\r
case 1:\r
d &= 3;\r
#ifdef USE_POLL_DETECT\r
if ((s68k_poll_adclk&0xfe) == 2 && s68k_poll_cnt > POLL_LIMIT) {\r
SekSetStopS68k(0); s68k_poll_adclk = 0;\r
- plprintf("s68k poll release, a=%02x\n", a);\r
+ elprintf(EL_CDPOLL, "s68k poll release, a=%02x\n", a);\r
}\r
#endif\r
return;\r
#ifdef USE_POLL_DETECT\r
if ((s68k_poll_adclk&0xfe) == 0xe && s68k_poll_cnt > POLL_LIMIT) {\r
SekSetStopS68k(0); s68k_poll_adclk = 0;\r
- plprintf("s68k poll release, a=%02x\n", a);\r
+ elprintf(EL_CDPOLL, "s68k poll release, a=%02x\n", a);\r
}\r
#endif\r
return;\r
#ifdef USE_POLL_DETECT\r
if ((a&0xfe) == (s68k_poll_adclk&0xfe) && s68k_poll_cnt > POLL_LIMIT) {\r
SekSetStopS68k(0); s68k_poll_adclk = 0;\r
- plprintf("s68k poll release, a=%02x\n", a);\r
+ elprintf(EL_CDPOLL, "s68k poll release, a=%02x\n", a);\r
}\r
#endif\r
return;\r
}\r
\r
- dprintf("m68k FIXME: invalid write? [%02x] %02x", a, d);\r
+ elprintf(EL_UIO, "m68k FIXME: invalid write? [%02x] %02x", a, d);\r
}\r
\r
#ifndef _ASM_CD_MEMORY_C\r
u32 s68k_poll_detect(u32 a, u32 d)\r
{\r
#ifdef USE_POLL_DETECT\r
+ // needed mostly for Cyclone, which doesn't always check it's cycle counter\r
+ if (SekIsStoppedS68k()) return d;\r
// polling detection\r
if (a == (s68k_poll_adclk&0xff)) {\r
unsigned int clkdiff = SekCyclesDoneS68k() - (s68k_poll_adclk>>8);\r
//printf("-- diff: %u, cnt = %i\n", clkdiff, s68k_poll_cnt);\r
if (s68k_poll_cnt > POLL_LIMIT) {\r
SekSetStopS68k(1);\r
- plprintf("s68k poll detected @ %06x, a=%02x\n", SekPcS68k, a);\r
+ elprintf(EL_CDPOLL, "s68k poll detected @ %06x, a=%02x\n", SekPcS68k, a);\r
}\r
s68k_poll_adclk = (SekCyclesDoneS68k() << 8) | a;\r
return d;\r
\r
if ((a&0x1f0) == 0x10 || (a >= 0x38 && a < 0x42))\r
{\r
- dprintf("s68k FIXME: invalid write @ %02x?", a);\r
+ elprintf(EL_UIO, "s68k FIXME: invalid write @ %02x?", a);\r
return;\r
}\r
\r
goto end;\r
}\r
\r
- dprintf("m68k FIXME: unusual r%i: %06x @%06x", realsize&~1, (a&0xfffffe)+(realsize&1), SekPc);\r
+ elprintf(EL_UIO, "m68k FIXME: unusual r%i: %06x @%06x", realsize&~1, (a&0xfffffe)+(realsize&1), SekPc);\r
\r
end:\r
return d;\r
return;\r
}\r
\r
- dprintf("m68k FIXME: strange w%i: [%06x], %08x @%06x", realsize, a&0xffffff, d, SekPc);\r
+ elprintf(EL_UIO, "m68k FIXME: strange w%i: [%06x], %08x @%06x", realsize, a&0xffffff, d, SekPc);\r
}\r
\r
#define _CD_MEMORY_C\r
}\r
\r
\r
-#ifdef __debug_io\r
- dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);\r
#ifdef EMU_CORE_DEBUG\r
if (a>=Pico.romsize) {\r
lastread_a = a;\r
}\r
\r
\r
-#ifdef __debug_io\r
- dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);\r
#ifdef EMU_CORE_DEBUG\r
if (a>=Pico.romsize) {\r
lastread_a = a;\r
}\r
\r
\r
-#ifdef __debug_io\r
- dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);\r
#ifdef EMU_CORE_DEBUG\r
if (a>=Pico.romsize) {\r
lastread_a = a;\r
#else\r
void PicoWriteM68k8(u32 a,u8 d)\r
{\r
-#ifdef __debug_io\r
- dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);\r
-#endif\r
+ elprintf(EL_IO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);\r
#ifdef EMU_CORE_DEBUG\r
lastwrite_cyc_d[lwp_cyc++&15] = d;\r
#endif\r
#else\r
static void PicoWriteM68k16(u32 a,u16 d)\r
{\r
-#ifdef __debug_io\r
- dprintf("w16: %06x, %04x", a&0xffffff, d);\r
-#endif\r
+ elprintf(EL_IO, "w16: %06x, %04x", a&0xffffff, d);\r
#ifdef EMU_CORE_DEBUG\r
lastwrite_cyc_d[lwp_cyc++&15] = d;\r
#endif\r
#ifdef USE_POLL_DETECT\r
if ((s68k_poll_adclk&0xfe) == 0xe && s68k_poll_cnt > POLL_LIMIT) {\r
SekSetStopS68k(0); s68k_poll_adclk = 0;\r
- plprintf("s68k poll release, a=%02x\n", a);\r
+ elprintf(EL_CDPOLL, "s68k poll release, a=%02x\n", a);\r
}\r
#endif\r
return;\r
#else\r
static void PicoWriteM68k32(u32 a,u32 d)\r
{\r
-#ifdef __debug_io\r
- dprintf("w32: %06x, %08x", a&0xffffff, d);\r
-#endif\r
+ elprintf(EL_IO, "w32: %06x, %08x", a&0xffffff, d);\r
#ifdef EMU_CORE_DEBUG\r
lastwrite_cyc_d[lwp_cyc++&15] = d;\r
#endif\r
d = Pico_mcd->word_ram1M[bank][((a>>1)^1)&0x1ffff];\r
if (a&1) d &= 0x0f;\r
else d >>= 4;\r
- dprintf("FIXME: decode");\r
} else {\r
// allow access in any mode, like Gens does\r
d = Pico_mcd->word_ram2M[(a^1)&0x3ffff];\r
\r
// PCM\r
if ((a&0xff8000)==0xff0000) {\r
- dprintf("s68k_pcm r8: [%06x] @%06x", a, SekPcS68k);\r
+ elprintf(EL_IO, "s68k_pcm r8: [%06x] @%06x", a, SekPcS68k);\r
a &= 0x7fff;\r
if (a >= 0x2000)\r
d = Pico_mcd->pcm_ram_b[Pico_mcd->pcm.bank][(a>>1)&0xfff];\r
d = Pico_mcd->pcm.ch[a>>2].addr >> PCM_STEP_SHIFT;\r
if (a & 2) d >>= 8;\r
}\r
- dprintf("ret = %02x", (u8)d);\r
+ elprintf(EL_IO, "ret = %02x", (u8)d);\r
goto end;\r
}\r
\r
goto end;\r
}\r
\r
- dprintf("s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k);\r
+ elprintf(EL_UIO, "s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k);\r
\r
end:\r
\r
-#ifdef __debug_io2\r
- dprintf("s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k);\r
-#endif\r
+ elprintf(EL_IO, "s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k);\r
#ifdef EMU_CORE_DEBUG\r
lastread_a = ab;\r
lastread_d[lrp_cyc++&15] = d;\r
int bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
d = Pico_mcd->word_ram1M[bank][((a>>1)^1)&0x1ffff];\r
d |= d << 4; d &= ~0xf0;\r
- dprintf("FIXME: decode");\r
} else {\r
// allow access in any mode, like Gens does\r
d = *(u16 *)(Pico_mcd->word_ram2M+(a&0x3fffe));\r
goto end;\r
}\r
\r
- dprintf("s68k r16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k);\r
+ elprintf(EL_UIO, "s68k r16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k);\r
\r
end:\r
\r
-#ifdef __debug_io2\r
- dprintf("s68k r16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k);\r
-#endif\r
+ elprintf(EL_IO, "s68k r16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k);\r
#ifdef EMU_CORE_DEBUG\r
lastread_a = ab;\r
lastread_d[lrp_cyc++&15] = d;\r
goto end;\r
}\r
\r
- dprintf("s68k r32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);\r
+ elprintf(EL_UIO, "s68k r32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);\r
\r
end:\r
\r
-#ifdef __debug_io2\r
- dprintf("s68k r32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);\r
-#endif\r
+ elprintf(EL_IO, "s68k r32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);\r
#ifdef EMU_CORE_DEBUG\r
if (ab > 0x78) { // not vectors and stuff\r
lastread_a = ab;\r
#else\r
static void PicoWriteS68k8(u32 a,u8 d)\r
{\r
-#ifdef __debug_io2\r
- dprintf("s68k w8 : %06x, %02x @%06x", a&0xffffff, d, SekPcS68k);\r
-#endif\r
+ elprintf(EL_IO, "s68k w8 : %06x, %02x @%06x", a&0xffffff, d, SekPcS68k);\r
\r
a&=0xffffff;\r
\r
return;\r
}\r
\r
- dprintf("s68k w8 : %06x, %02x @%06x", a&0xffffff, d, SekPcS68k);\r
+ elprintf(EL_UIO, "s68k w8 : %06x, %02x @%06x", a&0xffffff, d, SekPcS68k);\r
}\r
#endif\r
\r
#else\r
static void PicoWriteS68k16(u32 a,u16 d)\r
{\r
-#ifdef __debug_io2\r
- dprintf("s68k w16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k);\r
-#endif\r
+ elprintf(EL_IO, "s68k w16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k);\r
\r
a&=0xfffffe;\r
\r
return;\r
}\r
\r
- dprintf("s68k w16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k);\r
+ elprintf(EL_UIO, "s68k w16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k);\r
}\r
#endif\r
\r
#else\r
static void PicoWriteS68k32(u32 a,u32 d)\r
{\r
-#ifdef __debug_io2\r
- dprintf("s68k w32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);\r
-#endif\r
+ elprintf(EL_IO, "s68k w32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);\r
\r
a&=0xfffffe;\r
\r
return;\r
}\r
\r
- dprintf("s68k w32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);\r
+ elprintf(EL_UIO, "s68k w32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);\r
}\r
#endif\r
\r
}\r
\r
// Error - Program Counter is invalid\r
- dprintf("m68k FIXME: unhandled jump to %06x", pc);\r
+ elprintf(EL_ANOMALY, "m68k FIXME: unhandled jump to %06x", pc);\r
\r
return (int)Pico_mcd->bios;\r
}\r
}\r
\r
// Error - Program Counter is invalid\r
- dprintf("s68k FIXME: unhandled jump to %06x", pc);\r
+ elprintf(EL_ANOMALY, "s68k FIXME: unhandled jump to %06x", pc);\r
\r
return (int)Pico_mcd->prg_ram;\r
}\r
\r
PICO_INTERNAL void PicoMemSetupCD(void)\r
{\r
- dprintf("PicoMemSetupCD()");\r
#ifdef EMU_C68K\r
// Setup m68k memory callbacks:\r
PicoCpuCM68k.checkpc=PicoCheckPcM68k;\r
int bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
return *(u8 *)(Pico_mcd->word_ram1M[bank]+((a^1)&0x1ffff));\r
}\r
- dprintf("s68k_read_pcrelative_CD8 FIXME: can't handle %06x", a);\r
+ elprintf(EL_ANOMALY, "s68k_read_pcrelative_CD8 FIXME: can't handle %06x", a);\r
} else {\r
if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram\r
if(a<0x20000) return *(u8 *)(Pico.rom+(a^1)); // Bios\r
return *(u8 *)(Pico_mcd->word_ram1M[bank]+((a^1)&0x1ffff));\r
}\r
}\r
- dprintf("m68k_read_pcrelative_CD8 FIXME: can't handle %06x", a);\r
+ elprintf(EL_ANOMALY, "m68k_read_pcrelative_CD8 FIXME: can't handle %06x", a);\r
}\r
return 0;//(u8) lastread_d;\r
}\r
int bank = (Pico_mcd->s68k_regs[3]&1)^1;\r
return *(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe));\r
}\r
- dprintf("s68k_read_pcrelative_CD16 FIXME: can't handle %06x", a);\r
+ elprintf(EL_ANOMALY, "s68k_read_pcrelative_CD16 FIXME: can't handle %06x", a);\r
} else {\r
if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram\r
if(a<0x20000) return *(u16 *)(Pico.rom+(a&~1)); // Bios\r
return *(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe));\r
}\r
}\r
- dprintf("m68k_read_pcrelative_CD16 FIXME: can't handle %06x", a);\r
+ elprintf(EL_ANOMALY, "m68k_read_pcrelative_CD16 FIXME: can't handle %06x", a);\r
}\r
return 0;\r
}\r
pm=(u16 *)(Pico_mcd->word_ram1M[bank]+(a&0x1fffe));\r
return (pm[0]<<16)|pm[1];\r
}\r
- dprintf("s68k_read_pcrelative_CD32 FIXME: can't handle %06x", a);\r
+ elprintf(EL_ANOMALY, "s68k_read_pcrelative_CD32 FIXME: can't handle %06x", a);\r
} else {\r
if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram\r
if(a<0x20000) { u16 *pm=(u16 *)(Pico.rom+(a&~1)); return (pm[0]<<16)|pm[1]; }\r
return (pm[0]<<16)|pm[1];\r
}\r
}\r
- dprintf("m68k_read_pcrelative_CD32 FIXME: can't handle %06x", a);\r
+ elprintf(EL_ANOMALY, "m68k_read_pcrelative_CD32 FIXME: can't handle %06x", a);\r
}\r
return 0;\r
}\r