X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fwin32%2FGenaDrive%2FLoop.cpp;h=8aa05612aa34594aeb33289c16592deb546bd75c;hb=4609d0cdb87fcdd5f419153d7a76e2b06242b294;hp=b19539af9785a7f135bbbc64a44a254941a1c25c;hpb=e0978fa87d22f168ea9c039c6e2c5bf1274ba9e0;p=picodrive.git diff --git a/platform/win32/GenaDrive/Loop.cpp b/platform/win32/GenaDrive/Loop.cpp index b19539a..8aa0561 100644 --- a/platform/win32/GenaDrive/Loop.cpp +++ b/platform/win32/GenaDrive/Loop.cpp @@ -1,7 +1,7 @@ #include "app.h" //#include "FileMenu.h" -char LoopQuit=0; +char LoopQuit=0,LoopWait=0,LoopWaiting=0; static FILE *DebugFile=NULL; int LoopMode=0; static void UpdateSound(int len); @@ -24,10 +24,10 @@ int LoopInit() //DSoundInit(); ret=EmuInit(); if (ret) return 1; - //FileMenu.init(); LoopMode=8; PicoWriteSound = UpdateSound; + PicoAutoRgnOrder = 0x184; return 0; } @@ -38,9 +38,7 @@ void LoopExit() { dprintf(debugString()); - //FileMenu.exit(); EmuExit(); - DSoundExit(); PsndLen=0; InputExit(); DirectExit(); @@ -50,88 +48,29 @@ void LoopExit() // ---------------------------------------------------------------- -static int DoGame() +static void UpdateSound(int len) { - EmuFrame(); - - if (Inp.held[7]==1) LoopMode=2; // Right thumb = Toggle Menu - - return 0; + while (DSoundUpdate() > 0) { Sleep(1); } + //while (DSoundUpdate()== 0) { } } -// ---------------------------------------------------------------- -/* -static int MenuUpdate() +static void PostProcess() { - int delta=0; - - if (Inp.repeat[0]) delta-=0x100; - if (Inp.repeat[1]) delta+=0x100; - - if (Inp.button[14]>30) delta-=Inp.button[14]-30; - if (Inp.button[15]>30) delta+=Inp.button[15]-30; - - if (delta) FileMenu.scroll(delta); - - if (Inp.held[8]==1 || Inp.held[10]==1 || Inp.held[4]==1) // A, X or Start + static int lock_to_1_1_prev = 0, is_40_prev = -1; + int is_40; + PicoGetInternal(PI_IS40_CELL, (pint_ret_t *)&is_40); + if (lock_to_1_1) { - //RomFree(); - //FileMenu.getFilePath(RomName); - //RomLoad(); - //LoopMode=8; // Go to game + if (is_40 != is_40_prev || !lock_to_1_1_prev) + PostMessage(FrameWnd, WM_COMMAND, 0x20000 | (is_40 ? 1100 : 1101), 0); } - - if (Inp.held[7]==1) LoopMode=8; // Right thumb = Toggle Menu - - return 0; -} - -static int MenuRender() -{ - WCHAR text[80]={0}; - wsprintfW(text,L"%.40S v%x.%.3x",AppName,PicoVer>>12,PicoVer&0xfff); - FontSetColour(0x60c0ff); - FontText(text,64,48); - - FileMenu.render(); - - return 0; -} -*/ - -// ---------------------------------------------------------------- - -static int ModeUpdate() -{ - if (Inp.held[14] && Inp.held[15] && Inp.held[12]==1) LoopQuit=1; // L+R+black to quit: - if (Inp.button[4]>30 && Inp.button[5]>30) LoopQuit=1; // Start and back to quit - - if (LoopMode==8) { DoGame(); return 0; } - -// if (DSoundNext) memset(DSoundNext,0,PsndLen<<2); - -// if (LoopMode==2) { FileMenu.scan(); LoopMode++; return 0; } -// if (LoopMode==3) { MenuUpdate(); return 0; } -// if (LoopMode==4) { LightCalUpdate(); return 0; } - - LoopMode=2; // Unknown mode, go to rom menu - return 0; -} - - -static int ModeRender() -{ - DirectScreen(); -// if (LoopMode==3) MenuRender(); -// if (LoopMode==4) LightCalRender(); - - return 0; -} - -static void UpdateSound(int len) -{ - while (DSoundUpdate() > 0) { Sleep(1); } - while (DSoundUpdate()== 0) { } + if (is_40 != is_40_prev) + { + EmuScreenRect.left = is_40 ? 0 : 32; + EmuScreenRect.right = is_40 ? 320 : 256+32; + } + lock_to_1_1_prev = lock_to_1_1; + is_40_prev = is_40; } int LoopCode() @@ -140,14 +79,23 @@ int LoopCode() // Main loop: while (!LoopQuit) { + if (LoopWait) + { + DSoundExit(); + while (!LoopQuit && LoopWait) { LoopWaiting=1; Sleep(100); } + if (LoopQuit) break; + DSoundInit(); + } InputUpdate(); DirectClear(0); - ModeUpdate(); - ModeRender(); + EmuFrame(); + PostProcess(); + DirectScreen(); DirectPresent(); // UpdateSound(); } + DSoundExit(); return 0; } @@ -180,7 +128,7 @@ extern "C" int dprintf(char *format, ...) } #endif -extern "C" int dprintf2(char *format, ...) +extern "C" int lprintf(char *format, ...) { char str[512]; va_list val=NULL;