#include "app.h"\r
//#include "FileMenu.h"\r
\r
-char LoopQuit=0;\r
+char LoopQuit=0,LoopWait=0,LoopWaiting=0;\r
static FILE *DebugFile=NULL;\r
int LoopMode=0;\r
static void UpdateSound(int len);\r
PsndRate=44100;\r
\r
// Init Direct3D:\r
- ret=DirectInit(); if (ret) { error("Direct3D init failed"); return 1; }\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
- //FileMenu.init();\r
\r
LoopMode=8;\r
PicoWriteSound = UpdateSound;\r
+ PicoAutoRgnOrder = 0x184;\r
\r
return 0;\r
}\r
{\r
dprintf(debugString());\r
\r
- //FileMenu.exit();\r
EmuExit();\r
- DSoundExit(); PsndLen=0;\r
InputExit();\r
DirectExit();\r
\r
\r
// ----------------------------------------------------------------\r
\r
-static int DoGame()\r
+static void UpdateSound(int len)\r
{\r
- EmuFrame();\r
-\r
- if (Inp.held[7]==1) LoopMode=2; // Right thumb = Toggle Menu\r
-\r
- return 0;\r
+ while (DSoundUpdate() > 0) { Sleep(1); }\r
+ //while (DSoundUpdate()== 0) { }\r
}\r
-// ----------------------------------------------------------------\r
\r
-/*\r
-static int MenuUpdate()\r
+static void PostProcess()\r
{\r
- int delta=0;\r
-\r
- if (Inp.repeat[0]) delta-=0x100;\r
- if (Inp.repeat[1]) delta+=0x100;\r
-\r
- if (Inp.button[14]>30) delta-=Inp.button[14]-30;\r
- if (Inp.button[15]>30) delta+=Inp.button[15]-30;\r
-\r
- if (delta) FileMenu.scroll(delta);\r
-\r
- if (Inp.held[8]==1 || Inp.held[10]==1 || Inp.held[4]==1) // A, X or Start\r
+ static int lock_to_1_1_prev = 0, is_40_prev = 0;\r
+ int is_40 = PicoGetStat(PS_40_CELL);\r
+ if (lock_to_1_1)\r
{\r
- //RomFree();\r
- //FileMenu.getFilePath(RomName);\r
- //RomLoad();\r
- //LoopMode=8; // Go to game\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
-\r
- if (Inp.held[7]==1) LoopMode=8; // Right thumb = Toggle Menu\r
-\r
- return 0;\r
-}\r
-\r
-static int MenuRender()\r
-{\r
- WCHAR text[80]={0};\r
- wsprintfW(text,L"%.40S v%x.%.3x",AppName,PicoVer>>12,PicoVer&0xfff);\r
- FontSetColour(0x60c0ff);\r
- FontText(text,64,48);\r
-\r
- FileMenu.render();\r
-\r
- return 0;\r
-}\r
-*/\r
-\r
-// ----------------------------------------------------------------\r
-\r
-static int ModeUpdate()\r
-{\r
- if (Inp.held[14] && Inp.held[15] && Inp.held[12]==1) LoopQuit=1; // L+R+black to quit:\r
- if (Inp.button[4]>30 && Inp.button[5]>30) LoopQuit=1; // Start and back to quit\r
-\r
- if (LoopMode==8) { DoGame(); return 0; }\r
-\r
- if (DSoundNext) memset(DSoundNext,0,PsndLen<<2);\r
-\r
-// if (LoopMode==2) { FileMenu.scan(); LoopMode++; return 0; }\r
-// if (LoopMode==3) { MenuUpdate(); return 0; }\r
-// if (LoopMode==4) { LightCalUpdate(); return 0; }\r
-\r
- LoopMode=2; // Unknown mode, go to rom menu\r
- return 0;\r
-}\r
-\r
-\r
-static int ModeRender()\r
-{\r
- DirectScreen();\r
-// if (LoopMode==3) MenuRender();\r
-// if (LoopMode==4) LightCalRender();\r
-\r
- return 0;\r
-}\r
-\r
-static void UpdateSound(int len)\r
-{\r
- while (DSoundUpdate() > 0) { Sleep(1); }\r
- while (DSoundUpdate()== 0) { }\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
// 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
- ModeUpdate();\r
- ModeRender();\r
+ EmuFrame();\r
+ PostProcess();\r
+ DirectScreen();\r
DirectPresent();\r
// UpdateSound();\r
}\r
+ DSoundExit();\r
\r
return 0;\r
}\r
}\r
#endif\r
\r
-extern "C" int dprintf2(char *format, ...)\r
+extern "C" int lprintf(char *format, ...)\r
{\r
char str[512];\r
va_list val=NULL;\r