int PicoRegionOverride = 0; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe\r
int PicoAutoRgnOrder = 0;\r
int emustatus = 0;\r
-void (*PicoWriteSound)(void) = 0; // called once per frame at the best time to send sound buffer (PsndOut) to hardware\r
+void (*PicoWriteSound)(int len) = 0; // called once per frame at the best time to send sound buffer (PsndOut) to hardware\r
\r
struct PicoSRAM SRam;\r
int z80startCycle = 0, z80stopCycle = 0; // in 68k cycles\r
// to be called once on emu exit\r
void PicoExit(void)\r
{\r
- PicoExitMCD();\r
+ if (PicoMCD&1)\r
+ PicoExitMCD();\r
z80_exit();\r
\r
// notaz: sram\r
// reset VDP state, VRAM and PicoMisc\r
//memset(&Pico.video,0,sizeof(Pico.video));\r
//memset(&Pico.vram,0,sizeof(Pico.vram));\r
+ memset(Pico.ioports,0,sizeof(Pico.ioports)); // needed for MCD to reset properly\r
memset(&Pico.m,0,sizeof(Pico.m));\r
Pico.video.pending_ints=0;\r
emustatus = 0;\r
// to be called on 224 or line_sample scanlines only\r
static __inline void getSamples(int y)\r
{\r
+ static int curr_pos = 0;\r
+\r
if(y == 224) {\r
//dprintf("sta%i: %i [%i]", (emustatus & 2), emustatus, y);\r
if(emustatus & 2)\r
- sound_render(PsndLen/2, PsndLen-PsndLen/2);\r
- else sound_render(0, PsndLen);\r
+ curr_pos += sound_render(curr_pos, PsndLen-PsndLen/2);\r
+ else curr_pos = sound_render(0, PsndLen);\r
if (emustatus&1) emustatus|=2; else emustatus&=~2;\r
- if (PicoWriteSound) PicoWriteSound();\r
+ if (PicoWriteSound) PicoWriteSound(curr_pos);\r
// clear sound buffer\r
- memset(PsndOut, 0, (PicoOpt & 8) ? (PsndLen<<2) : (PsndLen<<1));\r
+ sound_clear();\r
}\r
else if(emustatus & 3) {\r
emustatus|= 2;\r
emustatus&=~1;\r
- sound_render(0, PsndLen/2);\r
+ curr_pos = sound_render(0, PsndLen/2);\r
}\r
}\r
\r
\r
// here we render sound if ym2612 is disabled\r
if(!(PicoOpt&1) && PsndOut) {\r
- sound_render(0, PsndLen);\r
- if(PicoWriteSound) PicoWriteSound();\r
+ int len = sound_render(0, PsndLen);\r
+ if(PicoWriteSound) PicoWriteSound(len);\r
// clear sound buffer\r
- memset(PsndOut, 0, (PicoOpt & 8) ? (PsndLen<<2) : (PsndLen<<1));\r
+ sound_clear();\r
}\r
\r
// render screen\r
return 0;\r
}\r
\r
-static int DefaultCram(int cram)\r
-{\r
- int high=0x0841;\r
- // Convert 0000bbbb ggggrrrr\r
- // to rrrr1ggg g10bbbb1\r
- high|=(cram&0x00f)<<12; // Red\r
- high|=(cram&0x0f0)<< 3; // Green\r
- high|=(cram&0xf00)>> 7; // Blue\r
- return high;\r
-}\r
-\r
-// Function to convert Megadrive Cram into a native colour:\r
-int (*PicoCram)(int cram)=DefaultCram;\r
+// callback to output message from emu\r
+void (*PicoMessage)(const char *msg)=NULL;\r
\r
#if defined(__DEBUG_PRINT) || defined(WIN32)\r
// tmp debug: dump some stuff\r