+++ /dev/null
-#include "app.h"\r
-//#include "FileMenu.h"\r
-\r
-char LoopQuit=0,LoopWait=0,LoopWaiting=0;\r
-static FILE *DebugFile=NULL;\r
-int LoopMode=0;\r
-static void UpdateSound(int len);\r
-\r
-int LoopInit()\r
-{\r
- int ret=0;\r
-\r
- // bits LSb->MSb:\r
- // enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound;\r
- // alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites\r
- PicoOpt=0xbccf;\r
- PsndRate=44100;\r
-\r
- // Init Direct3D:\r
- ret=DirectInit(); if (ret) { error("DirectX video init failed"); return 1; }\r
- InputInit();\r
-\r
- // Init DirectSound:\r
- //DSoundInit();\r
-\r
- ret=EmuInit(); if (ret) return 1;\r
-\r
- LoopMode=8;\r
- PicoWriteSound = UpdateSound;\r
- PicoAutoRgnOrder = 0x184;\r
-\r
- return 0;\r
-}\r
-\r
-extern "C" char *debugString();\r
-\r
-void LoopExit()\r
-{\r
- dprintf(debugString());\r
-\r
- EmuExit();\r
- InputExit();\r
- DirectExit();\r
-\r
- if (DebugFile) fclose(DebugFile);\r
- DebugFile=NULL;\r
-}\r
-\r
-// ----------------------------------------------------------------\r
-\r
-static void UpdateSound(int len)\r
-{\r
- while (DSoundUpdate() > 0) { Sleep(1); }\r
- //while (DSoundUpdate()== 0) { }\r
-}\r
-\r
-static void PostProcess()\r
-{\r
- static int lock_to_1_1_prev = 0, is_40_prev = -1;\r
- int is_40;\r
- PicoGetInternal(PI_IS40_CELL, (pint_ret_t *)&is_40);\r
- if (lock_to_1_1)\r
- {\r
- if (is_40 != is_40_prev || !lock_to_1_1_prev)\r
- PostMessage(FrameWnd, WM_COMMAND, 0x20000 | (is_40 ? 1100 : 1101), 0);\r
- }\r
- if (is_40 != is_40_prev)\r
- {\r
- EmuScreenRect.left = is_40 ? 0 : 32;\r
- EmuScreenRect.right = is_40 ? 320 : 256+32;\r
- }\r
- lock_to_1_1_prev = lock_to_1_1;\r
- is_40_prev = is_40;\r
-}\r
-\r
-int LoopCode()\r
-{\r
-\r
- // Main loop:\r
- while (!LoopQuit)\r
- {\r
- if (LoopWait)\r
- {\r
- DSoundExit();\r
- while (!LoopQuit && LoopWait) { LoopWaiting=1; Sleep(100); }\r
- if (LoopQuit) break;\r
- DSoundInit();\r
- }\r
- InputUpdate();\r
-\r
- DirectClear(0);\r
- EmuFrame();\r
- PostProcess();\r
- DirectScreen();\r
- DirectPresent();\r
-// UpdateSound();\r
- }\r
- DSoundExit();\r
-\r
- return 0;\r
-}\r
-\r
-// -------------------------------------------------------------------------------------\r
-\r
-#if 0\r
-extern "C" int dprintf(char *format, ...)\r
-{\r
- char *name=NULL;\r
- va_list val=NULL;\r
-\r
-#ifdef _XBOX\r
- name="d:\\zout.txt";\r
-#else\r
- name="zout.txt";\r
-#endif\r
-\r
- if (DebugFile==NULL) DebugFile=fopen(name,"wt");\r
- if (DebugFile==NULL) return 1;\r
-\r
- fprintf(DebugFile, "%05i: ", emu_frame);\r
- va_start(val,format);\r
- vfprintf(DebugFile,format,val);\r
- fprintf(DebugFile, "\n");\r
- fflush(DebugFile);\r
-\r
- va_end(val);\r
- return 0;\r
-}\r
-#endif\r
-\r
-extern "C" int lprintf(char *format, ...)\r
-{\r
- char str[512];\r
- va_list val=NULL;\r
-\r
- va_start(val,format);\r
- vsprintf(str,format,val);\r
- va_end(val);\r
- OutputDebugString(str);\r
-\r
- return 0;\r
-}\r
-\r