X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fwin32%2FGenaDrive%2FLoop.cpp;h=b4b3eec35b5d7ef217ebfc14c6286007c9c5e9d5;hb=03a265e5ebabff7adbb4f97387f81e9b0428dbee;hp=54d35197a997c75bd286954eba36f223e6896629;hpb=cc68a136aa179a5f32fe40208371eb9c2b0aadae;p=picodrive.git diff --git a/platform/win32/GenaDrive/Loop.cpp b/platform/win32/GenaDrive/Loop.cpp index 54d3519..b4b3eec 100644 --- a/platform/win32/GenaDrive/Loop.cpp +++ b/platform/win32/GenaDrive/Loop.cpp @@ -1,27 +1,10 @@ #include "app.h" -#include "FileMenu.h" - -// sram -struct PicoSRAM -{ - unsigned char *data; // actual data - unsigned int start; // start address in 68k address space - unsigned int end; - unsigned char resize; // 1=SRAM size changed and needs to be reallocated on PicoReset - unsigned char reg_back; // copy of Pico.m.sram_reg to set after reset - unsigned char changed; - unsigned char pad; -}; - -extern "C" PicoSRAM SRam; -extern char *romname; -int fastForward=0; -int frameStep=0; +//#include "FileMenu.h" char LoopQuit=0; static FILE *DebugFile=NULL; int LoopMode=0; -static void UpdateSound(); +static void UpdateSound(int len); int LoopInit() { @@ -30,19 +13,18 @@ int LoopInit() // bits LSb->MSb: // enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound; // alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites - PicoOpt=0x1f; + PicoOpt=0xbcc7; PsndRate=44100; - //PsndLen=PsndRate/60; // calculated later by pico itself // Init Direct3D: - ret=DirectInit(); if (ret) return 1; + ret=DirectInit(); if (ret) { error("DirectX video init failed"); return 1; } InputInit(); // Init DirectSound: //DSoundInit(); ret=EmuInit(); if (ret) return 1; - FileMenu.init(); + //FileMenu.init(); LoopMode=8; PicoWriteSound = UpdateSound; @@ -50,39 +32,13 @@ int LoopInit() return 0; } -void preLoopInit() -{ - romname[strlen(romname)-3] = 0; - strcat(romname, "srm"); - int sram_size = SRam.end-SRam.start+1; - if(SRam.reg_back & 4) sram_size=0x2000; - FILE *f = fopen(romname, "rb"); - if(f && SRam.data) - fread(SRam.data, 1, sram_size, f); - if(f) fclose(f); -} - extern "C" char *debugString(); void LoopExit() { dprintf(debugString()); - romname[strlen(romname)-3] = 0; - strcat(romname, "srm"); - int sram_size = SRam.end-SRam.start+1; - if(SRam.reg_back & 4) sram_size=0x2000; - for(; sram_size > 0; sram_size--) - if(SRam.data[sram_size-1]) break; - if(sram_size) { - FILE *f = fopen(romname, "wb"); - if(f) { - fwrite(SRam.data, 1, sram_size, f); - fclose(f); - } - } - - FileMenu.exit(); + //FileMenu.exit(); EmuExit(); DSoundExit(); PsndLen=0; InputExit(); @@ -94,18 +50,9 @@ void LoopExit() // ---------------------------------------------------------------- -int emu_frame = 0; - static int DoGame() { - if(fastForward) { PicoSkipFrame+=1; PicoSkipFrame&=7; } - else PicoSkipFrame=0; - - if(frameStep==1) return 0; - else if(frameStep==3) frameStep=1; - EmuFrame(); - emu_frame++; if (Inp.held[7]==1) LoopMode=2; // Right thumb = Toggle Menu @@ -113,6 +60,7 @@ static int DoGame() } // ---------------------------------------------------------------- +/* static int MenuUpdate() { int delta=0; @@ -149,6 +97,7 @@ static int MenuRender() return 0; } +*/ // ---------------------------------------------------------------- @@ -159,11 +108,11 @@ static int ModeUpdate() if (LoopMode==8) { DoGame(); return 0; } - if (DSoundNext) memset(DSoundNext,0,PsndLen<<2); +// 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; } +// 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; @@ -173,17 +122,16 @@ static int ModeUpdate() static int ModeRender() { DirectScreen(); - if (LoopMode==3) MenuRender(); - if (LoopMode==4) LightCalRender(); +// if (LoopMode==3) MenuRender(); +// if (LoopMode==4) LightCalRender(); return 0; } -static void UpdateSound() +static void UpdateSound(int len) { - if(fastForward) return; - while (DSoundUpdate()) { Sleep(1); } - while (DSoundUpdate()==0) { } + while (DSoundUpdate() > 0) { Sleep(1); } + while (DSoundUpdate()== 0) { } } int LoopCode() @@ -206,6 +154,7 @@ int LoopCode() // ------------------------------------------------------------------------------------- +#if 0 extern "C" int dprintf(char *format, ...) { char *name=NULL; @@ -229,6 +178,7 @@ extern "C" int dprintf(char *format, ...) va_end(val); return 0; } +#endif extern "C" int dprintf2(char *format, ...) { @@ -242,3 +192,4 @@ extern "C" int dprintf2(char *format, ...) return 0; } +