2 #include "FileMenu.h"
\r
7 unsigned char *data; // actual data
\r
8 unsigned int start; // start address in 68k address space
\r
10 unsigned char resize; // 1=SRAM size changed and needs to be reallocated on PicoReset
\r
11 unsigned char reg_back; // copy of Pico.m.sram_reg to set after reset
\r
12 unsigned char changed;
\r
16 extern "C" PicoSRAM SRam;
\r
17 extern char *romname;
\r
22 static FILE *DebugFile=NULL;
\r
24 static void UpdateSound();
\r
31 // enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound;
\r
32 // alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites
\r
35 //PsndLen=PsndRate/60; // calculated later by pico itself
\r
38 ret=DirectInit(); if (ret) return 1;
\r
41 // Init DirectSound:
\r
44 ret=EmuInit(); if (ret) return 1;
\r
48 PicoWriteSound = UpdateSound;
\r
55 romname[strlen(romname)-3] = 0;
\r
56 strcat(romname, "srm");
\r
57 int sram_size = SRam.end-SRam.start+1;
\r
58 if(SRam.reg_back & 4) sram_size=0x2000;
\r
59 FILE *f = fopen(romname, "rb");
\r
61 fread(SRam.data, 1, sram_size, f);
\r
65 extern "C" char *debugString();
\r
69 dprintf(debugString());
\r
71 romname[strlen(romname)-3] = 0;
\r
72 strcat(romname, "srm");
\r
73 int sram_size = SRam.end-SRam.start+1;
\r
74 if(SRam.reg_back & 4) sram_size=0x2000;
\r
75 for(; sram_size > 0; sram_size--)
\r
76 if(SRam.data[sram_size-1]) break;
\r
78 FILE *f = fopen(romname, "wb");
\r
80 fwrite(SRam.data, 1, sram_size, f);
\r
87 DSoundExit(); PsndLen=0;
\r
91 if (DebugFile) fclose(DebugFile);
\r
95 // ----------------------------------------------------------------
\r
101 if(fastForward) { PicoSkipFrame+=1; PicoSkipFrame&=7; }
\r
102 else PicoSkipFrame=0;
\r
104 if(frameStep==1) return 0;
\r
105 else if(frameStep==3) frameStep=1;
\r
110 if (Inp.held[7]==1) LoopMode=2; // Right thumb = Toggle Menu
\r
114 // ----------------------------------------------------------------
\r
116 static int MenuUpdate()
\r
120 if (Inp.repeat[0]) delta-=0x100;
\r
121 if (Inp.repeat[1]) delta+=0x100;
\r
123 if (Inp.button[14]>30) delta-=Inp.button[14]-30;
\r
124 if (Inp.button[15]>30) delta+=Inp.button[15]-30;
\r
126 if (delta) FileMenu.scroll(delta);
\r
128 if (Inp.held[8]==1 || Inp.held[10]==1 || Inp.held[4]==1) // A, X or Start
\r
131 //FileMenu.getFilePath(RomName);
\r
133 //LoopMode=8; // Go to game
\r
136 if (Inp.held[7]==1) LoopMode=8; // Right thumb = Toggle Menu
\r
141 static int MenuRender()
\r
143 WCHAR text[80]={0};
\r
144 wsprintfW(text,L"%.40S v%x.%.3x",AppName,PicoVer>>12,PicoVer&0xfff);
\r
145 FontSetColour(0x60c0ff);
\r
146 FontText(text,64,48);
\r
153 // ----------------------------------------------------------------
\r
155 static int ModeUpdate()
\r
157 if (Inp.held[14] && Inp.held[15] && Inp.held[12]==1) LoopQuit=1; // L+R+black to quit:
\r
158 if (Inp.button[4]>30 && Inp.button[5]>30) LoopQuit=1; // Start and back to quit
\r
160 if (LoopMode==8) { DoGame(); return 0; }
\r
162 if (DSoundNext) memset(DSoundNext,0,PsndLen<<2);
\r
164 if (LoopMode==2) { FileMenu.scan(); LoopMode++; return 0; }
\r
165 if (LoopMode==3) { MenuUpdate(); return 0; }
\r
166 if (LoopMode==4) { LightCalUpdate(); return 0; }
\r
168 LoopMode=2; // Unknown mode, go to rom menu
\r
173 static int ModeRender()
\r
176 if (LoopMode==3) MenuRender();
\r
177 if (LoopMode==4) LightCalRender();
\r
182 static void UpdateSound()
\r
184 if(fastForward) return;
\r
185 while (DSoundUpdate()) { Sleep(1); }
\r
186 while (DSoundUpdate()==0) { }
\r
207 // -------------------------------------------------------------------------------------
\r
209 extern "C" int dprintf(char *format, ...)
\r
215 name="d:\\zout.txt";
\r
220 if (DebugFile==NULL) DebugFile=fopen(name,"wt");
\r
221 if (DebugFile==NULL) return 1;
\r
223 fprintf(DebugFile, "%05i: ", emu_frame);
\r
224 va_start(val,format);
\r
225 vfprintf(DebugFile,format,val);
\r
226 fprintf(DebugFile, "\n");
\r
233 extern "C" int dprintf2(char *format, ...)
\r
238 va_start(val,format);
\r
239 vsprintf(str,format,val);
\r
241 OutputDebugString(str);
\r