diff --git a/desmume/ChangeLog b/desmume/ChangeLog index 649a1c77a..4da1ed119 100644 --- a/desmume/ChangeLog +++ b/desmume/ChangeLog @@ -21,12 +21,12 @@ Graphics: bug: fix 256B granularity sprite addressing for sub gpu bug: fix 128-wide captures bug: swrast: add clear image emulation - bug: swrast: add edge marking Windows: bug: improve map view tool to support more modes enh: added 2x resizing filters (hq2x, 2xsai, supereagle, scanlines) enh: soundview can now mute channels + enh: multicore optimization for filters, rotation, OSD Linux: enh: alsa microphone support diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index 29ac64138..f5e3bd156 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -874,8 +874,9 @@ void GPU_addBack(GPU * gpu, u8 num) /*****************************************************************************/ template -FORCEINLINE bool GPU::withinRect(u8 x) const +FORCEINLINE u8 GPU::withinRect(u16 x) const { + assert(x<256); //only way to be >256 is in debug views, and mosaic shouldnt be enabled for those return curr_win[WIN_NUM][x]; } @@ -1140,7 +1141,7 @@ finish: static void mosaicSpriteLinePixel(GPU * gpu, int x, u16 l, u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab) { int x_int; - u8 y = l; + int y = l; _OAM_ * spriteInfo = (_OAM_ *)(gpu->oam + gpu->sprNum[x]); bool enabled = spriteInfo->Mosaic; @@ -1459,7 +1460,7 @@ template FORCEINLINE void extRotBG2(GPU * gpu, s32 X, s32 Y, s16 PA u8 num = gpu->currBgNum; struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; - u8 *map, *tile, *pal; + u8 *pal; switch(gpu->BGTypes[num]) { @@ -1785,7 +1786,7 @@ void GPU::_spriteRender(u8 * dst, u8 * dst_alpha, u8 * typeTab, u8 * prioTab) struct _DISPCNT * dispCnt = &(gpu->dispx_st)->dispx_DISPCNT.bits; _OAM_ * spriteInfo = (_OAM_ *)(gpu->oam + (nbShow-1));// + 127; u8 block = gpu->sprBoundary; - u16 i; + u8 i; #ifdef WORDS_BIGENDIAN *(((u16*)spriteInfo)+1) = (*(((u16*)spriteInfo)+1) >> 1) | *(((u16*)spriteInfo)+1) << 15; @@ -2370,7 +2371,7 @@ static void GPU_ligne_layer(NDS_Screen * screen, u16 l) BG_enabled = FALSE; for(int j=0;j<8;j++) - gpu->blend2[j] = (gpu->BLDCNT & (0x100 << j)); + gpu->blend2[j] = (gpu->BLDCNT & (0x100 << j))!=0; // paint lower priorities fist // then higher priorities on top @@ -2386,8 +2387,8 @@ static void GPU_ligne_layer(NDS_Screen * screen, u16 l) i16 = item->BGs[i]; if (gpu->LayersEnable[i16]) { - gpu->currBgNum = i16; - gpu->blend1 = gpu->BLDCNT & (1 << gpu->currBgNum); + gpu->currBgNum = (u8)i16; + gpu->blend1 = (gpu->BLDCNT & (1 << gpu->currBgNum))!=0; struct _BGxCNT *bgCnt = &(gpu->dispx_st)->dispx_BGxCNT[i16].bits; gpu->curr_mosaic_enabled = bgCnt->Mosaic_Enable; @@ -2433,7 +2434,7 @@ static void GPU_ligne_layer(NDS_Screen * screen, u16 l) if (gpu->LayersEnable[4]) { gpu->currBgNum = 4; - gpu->blend1 = gpu->BLDCNT & (1 << gpu->currBgNum); + gpu->blend1 = (gpu->BLDCNT & (1 << gpu->currBgNum))!=0; for (int i=0; i < item->nbPixelsX; i++) { diff --git a/desmume/src/GPU.h b/desmume/src/GPU.h index 4ba9f2788..6af74738a 100644 --- a/desmume/src/GPU.h +++ b/desmume/src/GPU.h @@ -716,14 +716,14 @@ struct GPU u8 WIN1V1; u8 WININ0; - u8 WININ0_SPECIAL; + bool WININ0_SPECIAL; u8 WININ1; - u8 WININ1_SPECIAL; + bool WININ1_SPECIAL; u8 WINOUT; - u8 WINOUT_SPECIAL; + bool WINOUT_SPECIAL; u8 WINOBJ; - u8 WINOBJ_SPECIAL; + bool WINOBJ_SPECIAL; u8 WIN0_ENABLED; u8 WIN1_ENABLED; @@ -836,7 +836,7 @@ struct GPU // check whether (x,y) is within the rectangle (including wraparounds) template - bool withinRect(u8 x) const; + u8 withinRect(u16 x) const; void setBLDALPHA(u16 val) { @@ -974,9 +974,9 @@ inline void GPU_setWIN1_V1(GPU* gpu, u8 val) { gpu->WIN1V1 = val; } inline void GPU_setWININ(GPU* gpu, u16 val) { gpu->WININ0=val&0x1F; - gpu->WININ0_SPECIAL=(val>>5)&1; + gpu->WININ0_SPECIAL=((val>>5)&1)!=0; gpu->WININ1=(val>>8)&0x1F; - gpu->WININ1_SPECIAL=(val>>13)&1; + gpu->WININ1_SPECIAL=((val>>13)&1)!=0; } inline void GPU_setWININ0(GPU* gpu, u8 val) { gpu->WININ0 = val&0x1F; gpu->WININ0_SPECIAL = (val>>5)&1; } @@ -984,9 +984,9 @@ inline void GPU_setWININ1(GPU* gpu, u8 val) { gpu->WININ1 = val&0x1F; gpu->WININ inline void GPU_setWINOUT16(GPU* gpu, u16 val) { gpu->WINOUT=val&0x1F; - gpu->WINOUT_SPECIAL=(val>>5)&1; + gpu->WINOUT_SPECIAL=((val>>5)&1)!=0; gpu->WINOBJ=(val>>8)&0x1F; - gpu->WINOBJ_SPECIAL=(val>>13)&1; + gpu->WINOBJ_SPECIAL=((val>>13)&1)!=0; } inline void GPU_setWINOUT(GPU* gpu, u8 val) { gpu->WINOUT = val&0x1F; gpu->WINOUT_SPECIAL = (val>>5)&1; } inline void GPU_setWINOBJ(GPU* gpu, u8 val) { gpu->WINOBJ = val&0x1F; gpu->WINOBJ_SPECIAL = (val>>5)&1; } diff --git a/desmume/src/MMU.cpp b/desmume/src/MMU.cpp index 285087d8d..4ad7c0952 100644 --- a/desmume/src/MMU.cpp +++ b/desmume/src/MMU.cpp @@ -992,10 +992,10 @@ static void execsqrt() { if (cnt&1) { u64 v = T1ReadQuad(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8); - ret = isqrt(v); + ret = (u32)isqrt(v); } else { u32 v = T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B8); - ret = isqrt(v); + ret = (u32)isqrt(v); } T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B4, 0); T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x2B0, cnt | 0x8000); diff --git a/desmume/src/MMU.h b/desmume/src/MMU.h index dc2ef1649..35937732c 100644 --- a/desmume/src/MMU.h +++ b/desmume/src/MMU.h @@ -289,7 +289,7 @@ u16 FASTCALL _MMU_ARM7_read16(u32 adr); u32 FASTCALL _MMU_ARM7_read32(u32 adr); extern u32 _MMU_MAIN_MEM_MASK; -inline void SetupMMU(bool debugConsole) { +inline void SetupMMU(BOOL debugConsole) { if(debugConsole) _MMU_MAIN_MEM_MASK = 0x7FFFFF; else _MMU_MAIN_MEM_MASK = 0x3FFFFF; } diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 6039cdf70..e2ac30a23 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -1194,7 +1194,7 @@ int NDS_WriteBMP(const char *filename) pixel-=r<<10; g = pixel>>5; pixel-=g<<5; - b = pixel; + b = (u8)pixel; r*=255/31; g*=255/31; b*=255/31; @@ -2352,12 +2352,12 @@ void NDS_Reset() if((CommonSettings.UseExtBIOS == true) && (CommonSettings.UseExtFirmware == true) && (CommonSettings.BootFromFirmware == true) && (fw_success == TRUE)) { - for(int i = 0; i < nds.FW_ARM9BootCodeSize; i += 4) + for(u32 i = 0; i < nds.FW_ARM9BootCodeSize; i += 4) { _MMU_write32((nds.FW_ARM9BootCodeAddr + i), T1ReadLong(nds.FW_ARM9BootCode, i)); } - for(int i = 0; i < nds.FW_ARM7BootCodeSize; i += 4) + for(u32 i = 0; i < nds.FW_ARM7BootCodeSize; i += 4) { _MMU_write32((nds.FW_ARM7BootCodeAddr + i), T1ReadLong(nds.FW_ARM7BootCode, i)); } @@ -2372,7 +2372,7 @@ void NDS_Reset() src = header->ARM9src; dst = header->ARM9cpy; - for(int i = 0; i < (header->ARM9binSize>>2); ++i) + for(u32 i = 0; i < (header->ARM9binSize>>2); ++i) { _MMU_write32(dst, T1ReadLong(MMU.CART_ROM, src)); dst += 4; @@ -2382,7 +2382,7 @@ void NDS_Reset() src = header->ARM7src; dst = header->ARM7cpy; - for(int i = 0; i < (header->ARM7binSize>>2); ++i) + for(u32 i = 0; i < (header->ARM7binSize>>2); ++i) { _MMU_write32(dst, T1ReadLong(MMU.CART_ROM, src)); dst += 4; diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 9101b55ed..883889275 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -98,7 +98,7 @@ extern autohold AutoHold; int NDS_WritePNG(const char *fname); -extern volatile BOOL execute; +extern volatile bool execute; extern BOOL click; /* diff --git a/desmume/src/arm_instructions.cpp b/desmume/src/arm_instructions.cpp index a0b19d056..484672220 100644 --- a/desmume/src/arm_instructions.cpp +++ b/desmume/src/arm_instructions.cpp @@ -31,7 +31,7 @@ #define cpu (&ARMPROC) #define TEMPLATE template -extern volatile BOOL execute; +extern volatile bool execute; #define LSL_IMM shift_op = cpu->R[REG_POS(i,0)]<<((i>>7)&0x1F); diff --git a/desmume/src/cheatSystem.cpp b/desmume/src/cheatSystem.cpp index b6982a961..e04143cca 100644 --- a/desmume/src/cheatSystem.cpp +++ b/desmume/src/cheatSystem.cpp @@ -393,7 +393,7 @@ static void cheats_ARparser(CHEATS_LIST cheat) static BOOL cheatsXXcodePreparser(CHEATS_LIST *cheat, char *code) { - u16 count = 0; + int count = 0; u16 t = 0; char tmp_buf[sizeof(cheat->hi)+sizeof(cheat->lo)]; diff --git a/desmume/src/cheatSystem.h b/desmume/src/cheatSystem.h index 616de6a5c..365632eb2 100644 --- a/desmume/src/cheatSystem.h +++ b/desmume/src/cheatSystem.h @@ -36,7 +36,7 @@ typedef struct u32 hi[255]; u32 lo[255]; char description[75]; - u8 num; + int num; u8 size; } CHEATS_LIST; diff --git a/desmume/src/cli/main.cpp b/desmume/src/cli/main.cpp index e2fb77bba..caf63e39b 100644 --- a/desmume/src/cli/main.cpp +++ b/desmume/src/cli/main.cpp @@ -57,7 +57,7 @@ #include "../gdbstub.h" #endif -volatile BOOL execute = FALSE; +volatile bool execute = false; static float nds_screen_size_ratio = 1.0f; @@ -829,7 +829,7 @@ int main(int argc, char ** argv) { } #endif - execute = TRUE; + execute = true; if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) { diff --git a/desmume/src/common.cpp b/desmume/src/common.cpp index 1a8cb5f5a..6df5cd606 100644 --- a/desmume/src/common.cpp +++ b/desmume/src/common.cpp @@ -42,7 +42,7 @@ char IniName[MAX_PATH]; void GetINIPath() { - char vPath[MAX_PATH], *szPath, currDir[MAX_PATH]; + char vPath[MAX_PATH], *szPath; /*if (*vPath) szPath = vPath; else diff --git a/desmume/src/common.h b/desmume/src/common.h index b142fbce4..af87d4b78 100644 --- a/desmume/src/common.h +++ b/desmume/src/common.h @@ -66,7 +66,7 @@ extern u8 gba_header_data_0x04[156]; extern HINSTANCE hAppInst; - extern BOOL romloaded; + extern bool romloaded; extern char IniName[MAX_PATH]; extern void GetINIPath(); diff --git a/desmume/src/gtk-glade/desmume.cpp b/desmume/src/gtk-glade/desmume.cpp index 3d692781d..90085b1b6 100755 --- a/desmume/src/gtk-glade/desmume.cpp +++ b/desmume/src/gtk-glade/desmume.cpp @@ -29,7 +29,7 @@ static BOOL regMainLoop = FALSE; static BOOL noticed_3D=FALSE; -volatile BOOL execute = FALSE; +volatile bool execute = false; BOOL click = FALSE; void desmume_mem_init(); @@ -49,12 +49,12 @@ void desmume_init( struct armcpu_memory_iface *arm9_mem_if, NDS_Init(); #endif SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); - execute = FALSE; + execute = false; } void desmume_free() { - execute = FALSE; + execute = false; NDS_DeInit(); } @@ -74,14 +74,14 @@ void desmume_savetype(int type) { void desmume_pause() { - execute = FALSE; + execute = false; SPU_Pause(1); } void desmume_resume() { SPU_Pause(0); - execute = TRUE; + execute = true; if(!regMainLoop) g_idle_add_full(EMULOOP_PRIO, &EmuLoop, NULL, NULL); regMainLoop = TRUE; @@ -96,7 +96,7 @@ void desmume_reset() void desmume_toggle() { - execute = (execute) ? FALSE : TRUE; + execute ^= true; } /*INLINE BOOL desmume_running() { diff --git a/desmume/src/gtk/desmume.cpp b/desmume/src/gtk/desmume.cpp index 600da1d55..aa35b689a 100644 --- a/desmume/src/gtk/desmume.cpp +++ b/desmume/src/gtk/desmume.cpp @@ -27,7 +27,7 @@ #include "desmume.h" #include "movie.h" -volatile BOOL execute = FALSE; +volatile bool execute = false; BOOL click = FALSE; void desmume_init( struct armcpu_memory_iface *arm9_mem_if, @@ -45,30 +45,30 @@ void desmume_init( struct armcpu_memory_iface *arm9_mem_if, if ( !disable_sound) { SPU_ChangeSoundCore(SNDCORE_SDL, 735 * 4); } - execute = FALSE; + execute = false; } void desmume_free( void) { - execute = FALSE; + execute = false; NDS_DeInit(); } void desmume_pause( void) { - execute = FALSE; + execute = false; SPU_Pause(1); } void desmume_resume( void) { - execute = TRUE; + execute = true; SPU_Pause(0); } void desmume_toggle( void) { - execute = (execute) ? FALSE : TRUE; + execute ^= true; } -BOOL desmume_running( void) +bool desmume_running( void) { return execute; } diff --git a/desmume/src/gtk/desmume.h b/desmume/src/gtk/desmume.h index 883982183..d91f41c63 100644 --- a/desmume/src/gtk/desmume.h +++ b/desmume/src/gtk/desmume.h @@ -32,7 +32,7 @@ extern void desmume_free( void); extern void desmume_pause( void); extern void desmume_resume( void); extern void desmume_toggle( void); -extern BOOL desmume_running( void); +extern bool desmume_running( void); extern void desmume_cycle( void); diff --git a/desmume/src/lua-engine.cpp b/desmume/src/lua-engine.cpp index 2c1b2c43e..034e2f589 100644 --- a/desmume/src/lua-engine.cpp +++ b/desmume/src/lua-engine.cpp @@ -2859,8 +2859,7 @@ DEFINE_LUA_FUNCTION(movie_getlength, "") } DEFINE_LUA_FUNCTION(movie_isactive, "") { - if(movieMode != MOVIEMODE_INACTIVE); - lua_pushboolean(L, true); + lua_pushboolean(L, movieMode != MOVIEMODE_INACTIVE); return 1; } DEFINE_LUA_FUNCTION(movie_rerecordcount, "") diff --git a/desmume/src/path.h b/desmume/src/path.h index 6671842f0..bebba0447 100644 --- a/desmume/src/path.h +++ b/desmume/src/path.h @@ -128,7 +128,7 @@ public: ReadKey(pathToLua, LUAKEY); #ifdef WIN32 GetPrivateProfileString(SECTION, FORMATKEY, "%f_%s_%r", screenshotFormat, MAX_FORMAT, IniName); - savelastromvisit = GetPrivateProfileInt(SECTION, LASTVISITKEY, TRUE, IniName); + savelastromvisit = GetPrivateProfileBool(SECTION, LASTVISITKEY, true, IniName); currentimageformat = (ImageFormat)GetPrivateProfileInt(SECTION, DEFAULTFORMATKEY, PNG, IniName); #endif /* @@ -252,7 +252,7 @@ public: std::string file; time_t now = time(NULL); tm *time_struct = localtime(&now); - srand(now); + srand((unsigned int)now); for(int i = 0; i < MAX_FORMAT;i++) { diff --git a/desmume/src/rasterize.cpp b/desmume/src/rasterize.cpp index 2f584327e..b1aabffa6 100644 --- a/desmume/src/rasterize.cpp +++ b/desmume/src/rasterize.cpp @@ -647,7 +647,7 @@ FORCEINLINE fixed28_4 FloatToFixed28_4( float Value ) { return (fixed28_4)(Value * 16); } FORCEINLINE float Fixed28_4ToFloat( fixed28_4 Value ) { - return Value / 16.0; + return Value / 16.0f; } //inline fixed16_16 FloatToFixed16_16( float Value ) { // return (fixed16_6)(Value * 65536); @@ -965,50 +965,50 @@ static void SoftRastVramReconfigureSignal() { static void SoftRastFramebufferProcess() { - //this is not very accurate, but it works roughly - if(gfx3d.enableEdgeMarking) - { - u8 clearPolyid = ((gfx3d.clearColor>>24)&0x3F)>>3; + //this is not very accurate. taking it out for now + //if(gfx3d.enableEdgeMarking) + //{ + // u8 clearPolyid = ((gfx3d.clearColor>>24)&0x3F)>>3; - //TODO - need to test and find out whether these get grabbed at flush time, or at render time - //we can do this by rendering a 3d frame and then freezing the system, but only changing the edge mark colors + // //TODO - need to test and find out whether these get grabbed at flush time, or at render time + // //we can do this by rendering a 3d frame and then freezing the system, but only changing the edge mark colors - //now, I am not entirely sure about this. I can't find any documentation about the high bit here but - //it doesnt seem plausible to me that its all or nothing. I think that only polyid groups with a color - //with the high bit set get edge marked. - u16 edgeMarkColors[8]; - bool edgeMarkEnables[8]; - for(int i=0;i<8;i++) - { - edgeMarkColors[i] = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x330+i*2); - edgeMarkEnables[i] = (edgeMarkColors[i]&0x8000)!=0; - } + // //now, I am not entirely sure about this. I can't find any documentation about the high bit here but + // //it doesnt seem plausible to me that its all or nothing. I think that only polyid groups with a color + // //with the high bit set get edge marked. + // u16 edgeMarkColors[8]; + // bool edgeMarkEnables[8]; + // for(int i=0;i<8;i++) + // { + // edgeMarkColors[i] = T1ReadWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x330+i*2); + // edgeMarkEnables[i] = (edgeMarkColors[i]&0x8000)!=0; + // } - for(int i=0,y=0;y<192;y++) - { - for(int x=0;x<256;x++,i++) - { - Fragment &destFragment = screen[i]; - FragmentColor &destFragmentColor = screenColor[i]; - u8 self = destFragment.polyid.opaque>>3; - if(!edgeMarkEnables[self]) continue; - if(destFragment.isTranslucentPoly) continue; + // for(int i=0,y=0;y<192;y++) + // { + // for(int x=0;x<256;x++,i++) + // { + // Fragment &destFragment = screen[i]; + // FragmentColor &destFragmentColor = screenColor[i]; + // u8 self = destFragment.polyid.opaque>>3; + // if(!edgeMarkEnables[self]) continue; + // if(destFragment.isTranslucentPoly) continue; - u8 left = x==0?clearPolyid:(screen[i-1].polyid.opaque>>3); - u8 right = x==255?clearPolyid:(screen[i+1].polyid.opaque>>3); - u8 top = y==0?clearPolyid:(screen[i-256].polyid.opaque>>3); - u8 bottom = y==191?clearPolyid:(screen[i+256].polyid.opaque>>3); + // u8 left = x==0?clearPolyid:(screen[i-1].polyid.opaque>>3); + // u8 right = x==255?clearPolyid:(screen[i+1].polyid.opaque>>3); + // u8 top = y==0?clearPolyid:(screen[i-256].polyid.opaque>>3); + // u8 bottom = y==191?clearPolyid:(screen[i+256].polyid.opaque>>3); - if(left != self || right != self || top != self || bottom != self) - { - destFragmentColor.color = edgeMarkColors[self]; - } - + // if(left != self || right != self || top != self || bottom != self) + // { + // destFragmentColor.color = edgeMarkColors[self]; + // } + // - } - } + // } + // } - } + //} } diff --git a/desmume/src/readwrite.cpp b/desmume/src/readwrite.cpp index dc8ae1e5e..5c2e98ecc 100644 --- a/desmume/src/readwrite.cpp +++ b/desmume/src/readwrite.cpp @@ -47,8 +47,8 @@ int read8le(u8 *Bufo, std::istream *is) int write16le(u16 b, FILE *fp) { u8 s[2]; - s[0]=b; - s[1]=b>>8; + s[0]=(u8)b; + s[1]=(u8)(b>>8); return((fwrite(s,1,2,fp)<2)?0:2); } @@ -57,8 +57,8 @@ int write16le(u16 b, FILE *fp) int write16le(u16 b, std::ostream *os) { u8 s[2]; - s[0]=b; - s[1]=b>>8; + s[0]=(u8)b; + s[1]=(u8)(b>>8); os->write((char*)&s,2); return 2; } @@ -67,20 +67,20 @@ int write16le(u16 b, std::ostream *os) int write32le(u32 b, FILE *fp) { u8 s[4]; - s[0]=b; - s[1]=b>>8; - s[2]=b>>16; - s[3]=b>>24; + s[0]=(u8)b; + s[1]=(u8)(b>>8); + s[2]=(u8)(b>>16); + s[3]=(u8)(b>>24); return((fwrite(s,1,4,fp)<4)?0:4); } int write32le(u32 b, std::ostream* os) { u8 s[4]; - s[0]=b; - s[1]=b>>8; - s[2]=b>>16; - s[3]=b>>24; + s[0]=(u8)b; + s[1]=(u8)(b>>8); + s[2]=(u8)(b>>16); + s[3]=(u8)(b>>24); os->write((char*)&s,4); return 4; } @@ -90,14 +90,14 @@ void writebool(bool b, std::ostream* os) { write32le(b?1:0,os); } int write64le(u64 b, std::ostream* os) { u8 s[8]; - s[0]=b; - s[1]=b>>8; - s[2]=b>>16; - s[3]=b>>24; - s[4]=b>>32; - s[5]=b>>40; - s[6]=b>>48; - s[7]=b>>56; + s[0]=(u8)b; + s[1]=(u8)(b>>8); + s[2]=(u8)(b>>16); + s[3]=(u8)(b>>24); + s[4]=(u8)(b>>32); + s[5]=(u8)(b>>40); + s[6]=(u8)(b>>48); + s[7]=(u8)(b>>56); os->write((char*)&s,8); return 8; } @@ -161,7 +161,7 @@ int readbool(bool *b, std::istream* is) { u32 temp; int ret = read32le(&temp,is); - *b = (bool)temp; + *b = temp!=0; return ret; } diff --git a/desmume/src/rtc.cpp b/desmume/src/rtc.cpp index 43c7f977c..2fbcf61b4 100644 --- a/desmume/src/rtc.cpp +++ b/desmume/src/rtc.cpp @@ -89,7 +89,6 @@ void InitMovieTime(void) movie.weekday=4; } -#ifdef WIN32 static void MovieTime(void) { //now, you might think it is silly to go through all these conniptions @@ -102,21 +101,16 @@ static void MovieTime(void) { u64 frameCycles = (u64)arm9rate_unitsperframe * currFrameCounter; u64 totalcycles = frameCycles + noon; - u32 totalseconds=totalcycles/arm9rate_unitspersecond; + u64 totalseconds=totalcycles/arm9rate_unitspersecond; - movie.sec=totalseconds % 60; - movie.minute=totalseconds/60; + movie.sec=(int)(totalseconds % 60); + movie.minute=(int)(totalseconds/60); movie.hour=movie.minute/60; //convert to sane numbers movie.minute=movie.minute % 60; movie.hour=movie.hour % 24; } -#else -static void MovieTime(void) -{ -} -#endif static void rtcRecv() { diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index 91b14a2cc..2897d4c87 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -1015,7 +1015,7 @@ void rewindsave () { rewindbuffer.push_back(ms); - if(rewindbuffer.size() > rewindstates) { + if((int)rewindbuffer.size() > rewindstates) { delete *rewindbuffer.begin(); rewindbuffer.erase(rewindbuffer.begin()); } diff --git a/desmume/src/texcache.cpp b/desmume/src/texcache.cpp index e33220d0a..bb17ad6a2 100644 --- a/desmume/src/texcache.cpp +++ b/desmume/src/texcache.cpp @@ -586,7 +586,7 @@ REJECT: for(int j=0;j>1; - for(u32 x = 0; x < len; ++x) + for(int x = 0; x < len; ++x) { u16 c = map[x]; int alpha = ((c&0x8000)?opaqueColor:0); diff --git a/desmume/src/thumb_instructions.cpp b/desmume/src/thumb_instructions.cpp index 0113ce115..cb761bc5f 100644 --- a/desmume/src/thumb_instructions.cpp +++ b/desmume/src/thumb_instructions.cpp @@ -35,7 +35,7 @@ #define REG_NUM(i, n) (((i)>>n)&0x7) -extern volatile BOOL execute; +extern volatile bool execute; TEMPLATE static u32 FASTCALL OP_UND_THUMB() { diff --git a/desmume/src/types.h b/desmume/src/types.h index 07539035c..501b7fb0a 100644 --- a/desmume/src/types.h +++ b/desmume/src/types.h @@ -286,16 +286,16 @@ inline float u32_to_float(u32 u) { ///stores a 32bit value into the provided byte array in guaranteed little endian form inline void en32lsb(u8 *buf, u32 morp) { - buf[0]=morp; - buf[1]=morp>>8; - buf[2]=morp>>16; - buf[3]=morp>>24; + buf[0]=(u8)(morp); + buf[1]=(u8)(morp>>8); + buf[2]=(u8)(morp>>16); + buf[3]=(u8)(morp>>24); } inline void en16lsb(u8* buf, u16 morp) { - buf[0]=morp; - buf[1]=morp>>8; + buf[0]=(u8)morp; + buf[1]=(u8)(morp>>8); } ///unpacks a 64bit little endian value from the provided byte array into host byte order diff --git a/desmume/src/utils/guid.cpp b/desmume/src/utils/guid.cpp index 6d4206c63..5c555610d 100644 --- a/desmume/src/utils/guid.cpp +++ b/desmume/src/utils/guid.cpp @@ -61,9 +61,9 @@ void Desmume_Guid::scan(std::string& str) { char* endptr = (char*)str.c_str(); en32lsb(data,strtoul(endptr,&endptr,16)); - en16lsb(data+4,strtoul(endptr+1,&endptr,16)); - en16lsb(data+6,strtoul(endptr+1,&endptr,16)); - en16lsb(data+8,strtoul(endptr+1,&endptr,16)); + en16lsb(data+4,(u16)strtoul(endptr+1,&endptr,16)); + en16lsb(data+6,(u16)strtoul(endptr+1,&endptr,16)); + en16lsb(data+8,(u16)strtoul(endptr+1,&endptr,16)); endptr++; for(int i=0;i<6;i++) data[10+i] = hexToByte(&endptr); diff --git a/desmume/src/windows/CWindow.cpp b/desmume/src/windows/CWindow.cpp index 11a18b838..aca0ccbe2 100644 --- a/desmume/src/windows/CWindow.cpp +++ b/desmume/src/windows/CWindow.cpp @@ -62,12 +62,12 @@ bool WINCLASS::createEx(LPSTR caption, int x, int y, int width, int height, int bool WINCLASS::setMenu(HMENU menu) { hmenu = menu; - return SetMenu(hwnd, hmenu); + return SetMenu(hwnd, hmenu)==TRUE; } -DWORD WINCLASS::checkMenu(UINT idd, UINT check) +DWORD WINCLASS::checkMenu(UINT idd, bool check) { - return CheckMenuItem(hmenu, idd, check); + return CheckMenuItem(hmenu, idd, MF_BYCOMMAND | (check?MF_CHECKED:MF_UNCHECKED)); } HWND WINCLASS::getHWnd() diff --git a/desmume/src/windows/CWindow.h b/desmume/src/windows/CWindow.h index 9e2a52db1..1b8d7f15a 100644 --- a/desmume/src/windows/CWindow.h +++ b/desmume/src/windows/CWindow.h @@ -42,7 +42,7 @@ public: HMENU menu); bool setMenu(HMENU menu); - DWORD checkMenu(UINT idd, UINT check); + DWORD checkMenu(UINT idd, bool check); void Show(int mode); void Hide(); diff --git a/desmume/src/windows/disView.cpp b/desmume/src/windows/disView.cpp index 195b1e2ef..6d7df45a2 100644 --- a/desmume/src/windows/disView.cpp +++ b/desmume/src/windows/disView.cpp @@ -102,7 +102,7 @@ LRESULT DisViewBox_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM - if(((win->cpu->instruct_adr&0x0FFFFFFF) >= win->curr_ligne<<2)&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+nbligne<<2))) + if(((win->cpu->instruct_adr&0x0FFFFFFF) >= (win->curr_ligne<<2))&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+(nbligne<<2)))) { HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0)); SetBkColor(mem_dc, RGB(255, 255, 0)); @@ -134,7 +134,7 @@ LRESULT DisViewBox_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM adr += 2; } - if(((win->cpu->instruct_adr&0x0FFFFFFF) >= win->curr_ligne<<1)&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+nbligne<<1))) + if(((win->cpu->instruct_adr&0x0FFFFFFF) >= (win->curr_ligne<<1))&&((win->cpu->instruct_adr&0x0FFFFFFF) <= (win->curr_ligne+(nbligne<<1)))) { HBRUSH brjaune = CreateSolidBrush(RGB(255, 255, 0)); SetBkColor(mem_dc, RGB(255, 255, 0)); diff --git a/desmume/src/windows/filter/2xsai.cpp b/desmume/src/windows/filter/2xsai.cpp index 610e3efab..ec136d21e 100644 --- a/desmume/src/windows/filter/2xsai.cpp +++ b/desmume/src/windows/filter/2xsai.cpp @@ -239,9 +239,9 @@ void SuperEagle(uint8 *srcPtr, uint32 srcPitch, { uint32 *dP; uint16 *bP; - uint16 *xP; #ifdef MMX + uint16 *xP; if (mmx_cpu && width != 512) { for (height; height; height-=1) @@ -414,9 +414,9 @@ void _2xSaI(uint8 *srcPtr, uint32 srcPitch, { uint32 *dP; uint16 *bP; - uint16 *xP; #ifdef MMX + uint16 *xP; if (mmx_cpu && width != 512) { for (height; height; height-=1) diff --git a/desmume/src/windows/inputdx.cpp b/desmume/src/windows/inputdx.cpp index 4795ecd42..fcde5f8cf 100644 --- a/desmume/src/windows/inputdx.cpp +++ b/desmume/src/windows/inputdx.cpp @@ -246,7 +246,7 @@ SGuitar DefaultGuitar = { false, 'E', 'R', 'T', 'Y' }; SGuitar Guitar; u8 guitarState = 0; -extern volatile BOOL paused; +extern volatile bool paused; #define MAXKEYPAD 15 @@ -1889,8 +1889,6 @@ void EnableDisableKeyFields (int index, HWND hDlg) INT_PTR CALLBACK DlgInputConfig(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - char temp[256]; - short C; int i, which; static int index=0; @@ -2083,30 +2081,30 @@ switch(msg) // break; } - switch(HIWORD(wParam)) - { - //case CBN_SELCHANGE: - // index = SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_GETCURSEL,0,0); - // SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_SETCURSEL,(WPARAM)index,0); - // if(index > 4) index += 3; // skip controllers 6, 7, and 8 in the input dialog - // if(index < 8) - // { - // SendDlgItemMessage(hDlg,IDC_JPTOGGLE,BM_SETCHECK, Joypad[index].Enabled ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); - // EnableWindow(GetDlgItem(hDlg,IDC_JPTOGGLE),TRUE); - // } - // else - // { - // SendDlgItemMessage(hDlg,IDC_JPTOGGLE,BM_SETCHECK, Joypad[index-8].Enabled ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); - // EnableWindow(GetDlgItem(hDlg,IDC_JPTOGGLE),FALSE); - // } + //switch(HIWORD(wParam)) + //{ + // case CBN_SELCHANGE: + // index = SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_GETCURSEL,0,0); + // SendDlgItemMessage(hDlg,IDC_JPCOMBO,CB_SETCURSEL,(WPARAM)index,0); + // if(index > 4) index += 3; // skip controllers 6, 7, and 8 in the input dialog + // if(index < 8) + // { + // SendDlgItemMessage(hDlg,IDC_JPTOGGLE,BM_SETCHECK, Joypad[index].Enabled ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); + // EnableWindow(GetDlgItem(hDlg,IDC_JPTOGGLE),TRUE); + // } + // else + // { + // SendDlgItemMessage(hDlg,IDC_JPTOGGLE,BM_SETCHECK, Joypad[index-8].Enabled ? (WPARAM)BST_CHECKED : (WPARAM)BST_UNCHECKED, 0); + // EnableWindow(GetDlgItem(hDlg,IDC_JPTOGGLE),FALSE); + // } - // set_buttoninfo(index,hDlg); + // set_buttoninfo(index,hDlg); - // EnableDisableKeyFields(index,hDlg); + // EnableDisableKeyFields(index,hDlg); - // break; - } - return FALSE; + // break; + //} + //return FALSE; } @@ -2366,20 +2364,20 @@ void input_process() //not appropriate right now in desmume //if (paused) return; - bool R = joypads[0] & RIGHT_MASK; - bool L = joypads[0] & LEFT_MASK; - bool D = joypads[0] & DOWN_MASK; - bool U = joypads[0] & UP_MASK; - bool T = joypads[0] & START_MASK; - bool S = joypads[0] & SELECT_MASK; - bool B = joypads[0] & B_MASK; - bool A = joypads[0] & A_MASK; - bool Y = joypads[0] & Y_MASK; - bool X = joypads[0] & X_MASK; - bool W = joypads[0] & L_MASK; - bool E = joypads[0] & R_MASK; - bool G = joypads[0] & DEBUG_MASK; - bool F = joypads[0] & LID_MASK; + bool R = (joypads[0] & RIGHT_MASK)!=0; + bool L = (joypads[0] & LEFT_MASK)!=0; + bool D = (joypads[0] & DOWN_MASK)!=0; + bool U = (joypads[0] & UP_MASK)!=0; + bool T = (joypads[0] & START_MASK)!=0; + bool S = (joypads[0] & SELECT_MASK)!=0; + bool B = (joypads[0] & B_MASK)!=0; + bool A = (joypads[0] & A_MASK)!=0; + bool Y = (joypads[0] & Y_MASK)!=0; + bool X = (joypads[0] & X_MASK)!=0; + bool W = (joypads[0] & L_MASK)!=0; + bool E = (joypads[0] & R_MASK)!=0; + bool G = (joypads[0] & DEBUG_MASK)!=0; + bool F = (joypads[0] & LID_MASK)!=0; if(AutoHoldPressed && R) AutoHold.Right ^= true; if(AutoHoldPressed && L) AutoHold.Left ^= true; diff --git a/desmume/src/windows/lightView.cpp b/desmume/src/windows/lightView.cpp index 6894ef32b..ca6e778c2 100644 --- a/desmume/src/windows/lightView.cpp +++ b/desmume/src/windows/lightView.cpp @@ -62,7 +62,7 @@ void LightView_OnPaintLight(HWND hwnd, int index) unsigned int color; unsigned int direction; - ColorCtrl* colorCtrl; + //ColorCtrl* colorCtrl; char buffer[128]; // Get necessary information from gfx3d module diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 606d5df70..54182ce40 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -140,6 +140,10 @@ void wxTest() { #endif +const int kGapNone = 0; +const int kGapBorder = 5; +const int kGapNDS = 64; + static BOOL OpenCore(const char* filename); //----Recent ROMs menu globals---------- @@ -179,10 +183,15 @@ LPDIRECTDRAWCLIPPER lpDDClipBack=NULL; #define WM_CUSTKEYDOWN (WM_USER+50) #define WM_CUSTKEYUP (WM_USER+51) -/* Declare Windows procedure */ + +inline bool IsDlgCheckboxChecked(HWND hDlg, int id) +{ + return IsDlgButtonChecked(hDlg,id) == BST_CHECKED; +} + LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); -/* Make the class name into a global variable */ + char SavName[MAX_PATH] = ""; char ImportSavName[MAX_PATH] = ""; char szClassName[ ] = "DeSmuME"; @@ -202,9 +211,9 @@ int WndX = 0; int WndY = 0; extern HWND RamSearchHWnd; -static BOOL lostFocusPause = TRUE; -static BOOL lastPauseFromLostFocus = FALSE; -static int FrameLimit = 1; +static bool lostFocusPause = true; +static bool lastPauseFromLostFocus = false; +static bool FrameLimit = true; std::vector LuaScriptHWnds; LRESULT CALLBACK LuaScriptProc(HWND, UINT, WPARAM, LPARAM); @@ -222,19 +231,19 @@ TOOLSCLASS *ViewOAM = NULL; TOOLSCLASS *ViewMatrices = NULL; TOOLSCLASS *ViewLights = NULL; -volatile BOOL execute = FALSE; -volatile BOOL paused = TRUE; +volatile bool execute = false; +volatile bool paused = true; volatile BOOL pausedByMinimize = FALSE; u32 glock = 0; BOOL finished = FALSE; -BOOL romloaded = FALSE; +bool romloaded = false; void SetScreenGap(int gap); void SetRotate(HWND hwnd, int rot); -BOOL ForceRatio = TRUE; +bool ForceRatio = true; float DefaultWidth; float DefaultHeight; float widthTradeOff; @@ -258,7 +267,7 @@ GPU3DInterface *core3DList[] = { NULL }; -int autoframeskipenab=0; +bool autoframeskipenab=0; int frameskiprate=0; int emu_paused = 0; bool frameAdvance = false; @@ -603,7 +612,7 @@ void SaveRecentRoms() { temp.str(""); temp << "Recent Rom " << (x+1); - if (x < RecentRoms.size()) //If it exists in the array, save it + if (x < (int)RecentRoms.size()) //If it exists in the array, save it WritePrivateProfileString("General",temp.str().c_str(),RecentRoms[x].c_str(),IniName); else //Else, make it empty WritePrivateProfileString("General",temp.str().c_str(), "",IniName); @@ -917,7 +926,6 @@ void CheckMessages() DWORD WINAPI run() { - char txt[80]; u32 cycles = 0; int wait=0; u64 freq; @@ -933,11 +941,8 @@ DWORD WINAPI run() int fps=0; int fpsframecount=0; u64 fpsticks=0; - int res; HWND hwnd = MainWindow->getHWnd(); - DDCAPS hw_caps, sw_caps; - InitSpeedThrottle(); osd->setRotate(video.rotation); @@ -1325,9 +1330,9 @@ void CheckLanguage(UINT id) { int i; for (i = IDC_LANGENGLISH; i < IDC_LANG_CHINESE_SIMPLIFIED+1; i++) - MainWindow->checkMenu(i, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(i, false); - MainWindow->checkMenu(id, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(id, true); } void ChangeLanguage(int id) @@ -1478,30 +1483,30 @@ int _main() windowSize = GetPrivateProfileInt("Video","Window Size", 0, IniName); video.rotation = GetPrivateProfileInt("Video","Window Rotate", 0, IniName); - ForceRatio = GetPrivateProfileInt("Video","Window Force Ratio", 1, IniName); + ForceRatio = GetPrivateProfileBool("Video","Window Force Ratio", 1, IniName); WndX = GetPrivateProfileInt("Video","WindowPosX", CW_USEDEFAULT, IniName); WndY = GetPrivateProfileInt("Video","WindowPosY", CW_USEDEFAULT, IniName); video.width = GetPrivateProfileInt("Video", "Width", 256, IniName); video.height = GetPrivateProfileInt("Video", "Height", 384, IniName); - CommonSettings.hud.FpsDisplay = GetPrivateProfileBool("Display","Display Fps", 0, IniName); - CommonSettings.hud.FrameCounterDisplay = GetPrivateProfileBool("Display","FrameCounter", 0, IniName); - CommonSettings.hud.ShowInputDisplay = GetPrivateProfileBool("Display","Display Input", 0, IniName); - CommonSettings.hud.ShowLagFrameCounter = GetPrivateProfileBool("Display","Display Lag Counter", 0, IniName); - CommonSettings.hud.ShowMicrophone = GetPrivateProfileBool("Display","Display Microphone", 0, IniName); + CommonSettings.hud.FpsDisplay = GetPrivateProfileBool("Display","Display Fps", false, IniName); + CommonSettings.hud.FrameCounterDisplay = GetPrivateProfileBool("Display","FrameCounter", false, IniName); + CommonSettings.hud.ShowInputDisplay = GetPrivateProfileBool("Display","Display Input", false, IniName); + CommonSettings.hud.ShowLagFrameCounter = GetPrivateProfileBool("Display","Display Lag Counter", false, IniName); + CommonSettings.hud.ShowMicrophone = GetPrivateProfileBool("Display","Display Microphone", false, IniName); video.screengap = GetPrivateProfileInt("Display", "ScreenGap", 0, IniName); - FrameLimit = GetPrivateProfileInt("FrameLimit", "FrameLimit", 1, IniName); + FrameLimit = GetPrivateProfileBool("FrameLimit", "FrameLimit", true, IniName); CommonSettings.showGpu.main = GetPrivateProfileInt("Display", "MainGpu", 1, IniName) != 0; CommonSettings.showGpu.sub = GetPrivateProfileInt("Display", "SubGpu", 1, IniName) != 0; - lostFocusPause = GetPrivateProfileInt("Focus", "BackgroundPause", 0, IniName); + lostFocusPause = GetPrivateProfileBool("Focus", "BackgroundPause", false, IniName); //Get Ram-Watch values - RWSaveWindowPos = GetPrivateProfileInt("RamWatch", "SaveWindowPos", 0, IniName); + RWSaveWindowPos = GetPrivateProfileBool("RamWatch", "SaveWindowPos", false, IniName); ramw_x = GetPrivateProfileInt("RamWatch", "RWWindowPosX", 0, IniName); ramw_y = GetPrivateProfileInt("RamWatch", "RWWindowPosY", 0, IniName); - AutoRWLoad = GetPrivateProfileInt("RamWatch", "Auto-load", 0, IniName); + AutoRWLoad = GetPrivateProfileBool("RamWatch", "Auto-load", false, IniName); for(int i = 0; i < MAX_RECENT_WATCHES; i++) { char str[256]; @@ -1673,13 +1678,13 @@ int _main() { autoframeskipenab=1; frameskiprate=0; - MainWindow->checkMenu(IDC_FRAMESKIPAUTO, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(IDC_FRAMESKIPAUTO, true); } else { autoframeskipenab=0; frameskiprate=atoi(text); - MainWindow->checkMenu(frameskiprate + IDC_FRAMESKIP0, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(frameskiprate + IDC_FRAMESKIP0, true); } int KeyInRepeatMSec=20; @@ -1687,7 +1692,7 @@ int _main() hKeyInputTimer = timeSetEvent (KeyInRepeatMSec, 0, KeyInputTimer, 0, TIME_PERIODIC); cur3DCore = GetPrivateProfileInt("3D", "Renderer", GPU3D_OPENGL, IniName); - CommonSettings.HighResolutionInterpolateColor = GetPrivateProfileInt("3D", "HighResolutionInterpolateColor", 1, IniName); + CommonSettings.HighResolutionInterpolateColor = GetPrivateProfileBool("3D", "HighResolutionInterpolateColor", 1, IniName); CommonSettings.gfx3d_flushMode = GetPrivateProfileInt("3D", "AlternateFlush", 0, IniName); NDS_3D_ChangeCore(cur3DCore); @@ -1712,15 +1717,15 @@ int _main() sndvolume = GetPrivateProfileInt("Sound","Volume",100, IniName); SPU_SetVolume(sndvolume); - CommonSettings.DebugConsole = GetPrivateProfileInt("Emulation", "DebugConsole", FALSE, IniName); - CommonSettings.UseExtBIOS = GetPrivateProfileInt("BIOS", "UseExtBIOS", FALSE, IniName); + CommonSettings.DebugConsole = GetPrivateProfileBool("Emulation", "DebugConsole", FALSE, IniName); + CommonSettings.UseExtBIOS = GetPrivateProfileBool("BIOS", "UseExtBIOS", FALSE, IniName); GetPrivateProfileString("BIOS", "ARM9BIOSFile", "bios9.bin", CommonSettings.ARM9BIOS, 256, IniName); GetPrivateProfileString("BIOS", "ARM7BIOSFile", "bios7.bin", CommonSettings.ARM7BIOS, 256, IniName); - CommonSettings.SWIFromBIOS = GetPrivateProfileInt("BIOS", "SWIFromBIOS", FALSE, IniName); + CommonSettings.SWIFromBIOS = GetPrivateProfileBool("BIOS", "SWIFromBIOS", FALSE, IniName); - CommonSettings.UseExtFirmware = GetPrivateProfileInt("Firmware", "UseExtFirmware", FALSE, IniName); + CommonSettings.UseExtFirmware = GetPrivateProfileBool("Firmware", "UseExtFirmware", FALSE, IniName); GetPrivateProfileString("Firmware", "FirmwareFile", "firmware.bin", CommonSettings.Firmware, 256, IniName); - CommonSettings.BootFromFirmware = GetPrivateProfileInt("Firmware", "BootFromFirmware", FALSE, IniName); + CommonSettings.BootFromFirmware = GetPrivateProfileBool("Firmware", "BootFromFirmware", FALSE, IniName); CommonSettings.wifiBridgeAdapterNum = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName); @@ -1972,10 +1977,10 @@ void UpdateScreenRects() void SetScreenGap(int gap) { - video.screengap = gap; MainWindow->setMinSize(video.rotatedwidthgap(), video.rotatedheightgap()); MainWindow->setClientSize(video.rotatedwidthgap(), video.rotatedheightgap()); + UpdateWndRects(MainWindow->getHWnd()); } //======================================================================================== @@ -2471,7 +2476,8 @@ void RunConfig(CONFIGSCREEN which) NDS_UnPause(); } -void FilterUpdate (HWND hwnd, bool user){ +void FilterUpdate (HWND hwnd, bool user) +{ UpdateScreenRects(); UpdateWndRects(hwnd); SetScreenGap(video.screengap); @@ -2483,6 +2489,11 @@ void FilterUpdate (HWND hwnd, bool user){ WritePrivateProfileInt("Video", "Height", video.height, IniName); } +void DesEnableMenuItem(HMENU hMenu, UINT uIDEnableItem, bool enable) +{ + EnableMenuItem(hMenu, uIDEnableItem, MF_BYCOMMAND | (enable?MF_ENABLED:MF_GRAYED)); +} + //======================================================================================== LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -2507,108 +2518,121 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM SetMenuItemInfo(mainMenu, IDM_FILE_RECORDWAV, FALSE, &mii); //Menu items dependent on a ROM loaded - EnableMenuItem(mainMenu, IDM_GAME_INFO, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_IMPORTBACKUPMEMORY,MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_EXPORTBACKUPMEMORY,MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_STATE_SAVE, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_STATE_LOAD, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_PRINTSCREEN, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_QUICK_PRINTSCREEN, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_FILE_RECORDAVI, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_FILE_RECORDWAV, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_RESET, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_SHUT_UP, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_CHEATS_LIST, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_CHEATS_SEARCH, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_WIFISETTINGS, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); + DesEnableMenuItem(mainMenu, IDM_GAME_INFO, romloaded); + DesEnableMenuItem(mainMenu, IDM_IMPORTBACKUPMEMORY,romloaded); + DesEnableMenuItem(mainMenu, IDM_EXPORTBACKUPMEMORY,romloaded); + DesEnableMenuItem(mainMenu, IDM_STATE_SAVE, romloaded); + DesEnableMenuItem(mainMenu, IDM_STATE_LOAD, romloaded); + DesEnableMenuItem(mainMenu, IDM_PRINTSCREEN, romloaded); + DesEnableMenuItem(mainMenu, IDM_QUICK_PRINTSCREEN, romloaded); + DesEnableMenuItem(mainMenu, IDM_FILE_RECORDAVI, romloaded); + DesEnableMenuItem(mainMenu, IDM_FILE_RECORDWAV, romloaded); + DesEnableMenuItem(mainMenu, IDM_RESET, romloaded); + DesEnableMenuItem(mainMenu, IDM_SHUT_UP, romloaded); + DesEnableMenuItem(mainMenu, IDM_CHEATS_LIST, romloaded); + DesEnableMenuItem(mainMenu, IDM_CHEATS_SEARCH, romloaded); + DesEnableMenuItem(mainMenu, IDM_WIFISETTINGS, romloaded); - EnableMenuItem(mainMenu, IDM_RECORD_MOVIE, MF_BYCOMMAND | (romloaded && movieMode == MOVIEMODE_INACTIVE) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_PLAY_MOVIE, MF_BYCOMMAND | (romloaded && movieMode == MOVIEMODE_INACTIVE) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_STOPMOVIE, MF_BYCOMMAND | (romloaded && movieMode != MOVIEMODE_INACTIVE) ? MF_ENABLED : MF_GRAYED); + DesEnableMenuItem(mainMenu, IDM_RECORD_MOVIE, (romloaded && movieMode == MOVIEMODE_INACTIVE)); + DesEnableMenuItem(mainMenu, IDM_PLAY_MOVIE, (romloaded && movieMode == MOVIEMODE_INACTIVE)); + DesEnableMenuItem(mainMenu, IDM_STOPMOVIE, (romloaded && movieMode != MOVIEMODE_INACTIVE)); - EnableMenuItem(mainMenu, ID_RAM_WATCH, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, ID_RAM_SEARCH, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); + DesEnableMenuItem(mainMenu, ID_RAM_WATCH, romloaded); + DesEnableMenuItem(mainMenu, ID_RAM_SEARCH, romloaded); //Update savestate slot items based on ROM loaded for (int x = 0; x < 10; x++) { - EnableMenuItem(mainMenu, IDM_STATE_SAVE_F1+x, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(mainMenu, IDM_STATE_LOAD_F1+x, MF_BYCOMMAND | (romloaded) ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(mainMenu, IDM_STATE_SAVE_F1+x, romloaded); + EnableMenuItem(mainMenu, IDM_STATE_LOAD_F1+x, romloaded); } //Gray the recent ROM menu item if there are no recent ROMs - EnableMenuItem(mainMenu, ID_FILE_RECENTROM, MF_BYCOMMAND | (RecentRoms.size()) ? MF_ENABLED : MF_GRAYED); + EnableMenuItem(mainMenu, ID_FILE_RECENTROM, (RecentRoms.size())); //Updated Checked menu items //Pause - MainWindow->checkMenu(IDM_PAUSE, MF_BYCOMMAND | ((paused)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDM_PAUSE, ((paused))); //Force Maintain Ratio - MainWindow->checkMenu(IDC_FORCERATIO, MF_BYCOMMAND | ((ForceRatio)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_FORCERATIO, ((ForceRatio))); //Screen rotation - MainWindow->checkMenu(IDC_ROTATE0, MF_BYCOMMAND | ((video.rotation==0)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDC_ROTATE90, MF_BYCOMMAND | ((video.rotation==90)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDC_ROTATE180, MF_BYCOMMAND | ((video.rotation==180)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDC_ROTATE270, MF_BYCOMMAND | ((video.rotation==270)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_ROTATE0, ((video.rotation==0))); + MainWindow->checkMenu(IDC_ROTATE90, ((video.rotation==90))); + MainWindow->checkMenu(IDC_ROTATE180, ((video.rotation==180))); + MainWindow->checkMenu(IDC_ROTATE270, ((video.rotation==270))); //Window Size - MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDC_WINDOW1_5X, MF_BYCOMMAND |((windowSize==65535)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDC_WINDOW2_5X, MF_BYCOMMAND |((windowSize==65534)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDC_WINDOW3X, MF_BYCOMMAND | ((windowSize==3)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDC_WINDOW4X, MF_BYCOMMAND | ((windowSize==4)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_WINDOW1X, ((windowSize==1))); + MainWindow->checkMenu(IDC_WINDOW1_5X, ((windowSize==65535))); + MainWindow->checkMenu(IDC_WINDOW2X, ((windowSize==2))); + MainWindow->checkMenu(IDC_WINDOW2_5X, ((windowSize==65534))); + MainWindow->checkMenu(IDC_WINDOW3X, ((windowSize==3))); + MainWindow->checkMenu(IDC_WINDOW4X, ((windowSize==4))); //Screen Separation - MainWindow->checkMenu(IDM_SCREENSEP_NONE, MF_BYCOMMAND | ((video.screengap==0)? MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDM_SCREENSEP_BORDER, MF_BYCOMMAND | ((video.screengap==5)? MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, MF_BYCOMMAND | ((video.screengap==64)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDM_SCREENSEP_NONE, ((video.screengap==0))); + MainWindow->checkMenu(IDM_SCREENSEP_BORDER, ((video.screengap==5))); + MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, ((video.screengap==64))); //Counters / Etc. - MainWindow->checkMenu(ID_VIEW_FRAMECOUNTER, MF_BYCOMMAND | ((CommonSettings.hud.FrameCounterDisplay)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(ID_VIEW_DISPLAYFPS, MF_BYCOMMAND | ((CommonSettings.hud.FpsDisplay) ?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(ID_VIEW_DISPLAYINPUT, MF_BYCOMMAND | ((CommonSettings.hud.ShowInputDisplay) ?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(ID_VIEW_DISPLAYLAG, MF_BYCOMMAND | ((CommonSettings.hud.ShowLagFrameCounter)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(ID_VIEW_DISPLAYMICROPHONE, MF_BYCOMMAND | ((CommonSettings.hud.ShowMicrophone)?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(ID_VIEW_HUDEDITOR, MF_BYCOMMAND | ((HudEditorMode) ?MF_CHECKED:MF_UNCHECKED)); - MainWindow->checkMenu(IDC_FRAMELIMIT, MF_BYCOMMAND | ((FrameLimit) ?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(ID_VIEW_FRAMECOUNTER,CommonSettings.hud.FrameCounterDisplay); + MainWindow->checkMenu(ID_VIEW_DISPLAYFPS,CommonSettings.hud.FpsDisplay); + MainWindow->checkMenu(ID_VIEW_DISPLAYINPUT,CommonSettings.hud.ShowInputDisplay); + MainWindow->checkMenu(ID_VIEW_DISPLAYLAG,CommonSettings.hud.ShowLagFrameCounter); + MainWindow->checkMenu(ID_VIEW_DISPLAYMICROPHONE,CommonSettings.hud.ShowMicrophone); + MainWindow->checkMenu(ID_VIEW_HUDEDITOR, HudEditorMode); + MainWindow->checkMenu(IDC_FRAMELIMIT, FrameLimit); //Frame Skip - MainWindow->checkMenu(IDC_FRAMESKIPAUTO, MF_BYCOMMAND | ((autoframeskipenab)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_FRAMESKIPAUTO, ((autoframeskipenab))); - MainWindow->checkMenu(IDC_FRAMESKIP0, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==0) ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDC_FRAMESKIP1, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==1) ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDC_FRAMESKIP2, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==2) ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDC_FRAMESKIP3, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==3) ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDC_FRAMESKIP4, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==4) ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDC_FRAMESKIP5, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==5) ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDC_FRAMESKIP6, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==6) ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDC_FRAMESKIP7, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==7) ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDC_FRAMESKIP8, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==8) ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDC_FRAMESKIP9, MF_BYCOMMAND | (!autoframeskipenab && frameskiprate==9) ? MF_CHECKED:MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP0, (!autoframeskipenab && frameskiprate==0) ); + MainWindow->checkMenu(IDC_FRAMESKIP1, (!autoframeskipenab && frameskiprate==1) ); + MainWindow->checkMenu(IDC_FRAMESKIP2, (!autoframeskipenab && frameskiprate==2) ); + MainWindow->checkMenu(IDC_FRAMESKIP3, (!autoframeskipenab && frameskiprate==3) ); + MainWindow->checkMenu(IDC_FRAMESKIP4, (!autoframeskipenab && frameskiprate==4) ); + MainWindow->checkMenu(IDC_FRAMESKIP5, (!autoframeskipenab && frameskiprate==5) ); + MainWindow->checkMenu(IDC_FRAMESKIP6, (!autoframeskipenab && frameskiprate==6) ); + MainWindow->checkMenu(IDC_FRAMESKIP7, (!autoframeskipenab && frameskiprate==7) ); + MainWindow->checkMenu(IDC_FRAMESKIP8, (!autoframeskipenab && frameskiprate==8) ); + MainWindow->checkMenu(IDC_FRAMESKIP9, (!autoframeskipenab && frameskiprate==9) ); - MainWindow->checkMenu(IDM_MGPU, MF_BYCOMMAND | CommonSettings.showGpu.main ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDM_SGPU, MF_BYCOMMAND | CommonSettings.showGpu.sub ? MF_CHECKED:MF_UNCHECKED); + //gpu visibility toggles + MainWindow->checkMenu(IDM_MGPU, CommonSettings.showGpu.main ); + MainWindow->checkMenu(IDM_SGPU, CommonSettings.showGpu.sub ); + //TODO - change how the gpu visibility flags work //Filters + MainWindow->checkMenu(IDM_RENDER_NORMAL, video.currentfilter == video.NONE ); + MainWindow->checkMenu(IDM_RENDER_HQ2X, video.currentfilter == video.HQ2X ); + MainWindow->checkMenu(IDM_RENDER_2XSAI, video.currentfilter == video._2XSAI ); + MainWindow->checkMenu(IDM_RENDER_SUPER2XSAI, video.currentfilter == video.SUPER2XSAI ); + MainWindow->checkMenu(IDM_RENDER_SUPEREAGLE, video.currentfilter == video.SUPEREAGLE ); + MainWindow->checkMenu(IDM_RENDER_SCANLINE, video.currentfilter == video.SCANLINE ); + MainWindow->checkMenu(IDM_RENDER_BILINEAR, video.currentfilter == video.BILINEAR ); - MainWindow->checkMenu(IDM_RENDER_NORMAL, MF_BYCOMMAND | video.currentfilter == video.NONE ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDM_RENDER_HQ2X, MF_BYCOMMAND | video.currentfilter == video.HQ2X ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDM_RENDER_2XSAI, MF_BYCOMMAND | video.currentfilter == video._2XSAI ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDM_RENDER_SUPER2XSAI, MF_BYCOMMAND | video.currentfilter == video.SUPER2XSAI ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDM_RENDER_SUPEREAGLE, MF_BYCOMMAND | video.currentfilter == video.SUPEREAGLE ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDM_RENDER_SCANLINE, MF_BYCOMMAND | video.currentfilter == video.SCANLINE ? MF_CHECKED:MF_UNCHECKED); - MainWindow->checkMenu(IDM_RENDER_BILINEAR, MF_BYCOMMAND | video.currentfilter == video.BILINEAR ? MF_CHECKED:MF_UNCHECKED); - - MainWindow->checkMenu(IDC_STATEREWINDING, MF_BYCOMMAND | staterewindingenabled == 1 ? MF_CHECKED:MF_UNCHECKED); + MainWindow->checkMenu(IDC_STATEREWINDING, staterewindingenabled == 1 ); //Language selection + MainWindow->checkMenu(IDC_BACKGROUNDPAUSE, lostFocusPause); + + //screen gaps + MainWindow->checkMenu(IDM_SCREENSEP_NONE, false); + MainWindow->checkMenu(IDM_SCREENSEP_BORDER, false); + MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, false); + if(video.screengap == kGapNone) + MainWindow->checkMenu(IDM_SCREENSEP_NONE, true); + else if(video.screengap == kGapBorder) + MainWindow->checkMenu(IDM_SCREENSEP_BORDER, true); + else if(video.screengap == kGapNDS) + MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, true); - MainWindow->checkMenu(IDC_BACKGROUNDPAUSE, MF_BYCOMMAND | ((lostFocusPause)?MF_CHECKED:MF_UNCHECKED)); //Save type const int savelist[] = {IDC_SAVETYPE1,IDC_SAVETYPE2,IDC_SAVETYPE3,IDC_SAVETYPE4,IDC_SAVETYPE5,IDC_SAVETYPE6,IDC_SAVETYPE7}; - for(int i=0;i<7;i++) MainWindow->checkMenu(savelist[i], MF_BYCOMMAND | MF_UNCHECKED); - MainWindow->checkMenu(savelist[CommonSettings.manualBackupType], MF_BYCOMMAND | MF_CHECKED); + for(int i=0;i<7;i++) + MainWindow->checkMenu(savelist[i], MF_UNCHECKED); + MainWindow->checkMenu(savelist[CommonSettings.manualBackupType], true); return 0; @@ -3216,96 +3240,96 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM if(MainScreen.gpu->dispBG[0]) { GPU_remove(MainScreen.gpu, 0); - MainWindow->checkMenu(IDM_MBG0, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDM_MBG0, false); } else { GPU_addBack(MainScreen.gpu, 0); - MainWindow->checkMenu(IDM_MBG0, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(IDM_MBG0, true); } return 0; case IDM_MBG1 : if(MainScreen.gpu->dispBG[1]) { GPU_remove(MainScreen.gpu, 1); - MainWindow->checkMenu(IDM_MBG1, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDM_MBG1, false); } else { GPU_addBack(MainScreen.gpu, 1); - MainWindow->checkMenu(IDM_MBG1, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(IDM_MBG1, true); } return 0; case IDM_MBG2 : if(MainScreen.gpu->dispBG[2]) { GPU_remove(MainScreen.gpu, 2); - MainWindow->checkMenu(IDM_MBG2, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDM_MBG2, false); } else { GPU_addBack(MainScreen.gpu, 2); - MainWindow->checkMenu(IDM_MBG2, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(IDM_MBG2, true); } return 0; case IDM_MBG3 : if(MainScreen.gpu->dispBG[3]) { GPU_remove(MainScreen.gpu, 3); - MainWindow->checkMenu(IDM_MBG3, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDM_MBG3, false); } else { GPU_addBack(MainScreen.gpu, 3); - MainWindow->checkMenu(IDM_MBG3, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(IDM_MBG3, true); } return 0; case IDM_SBG0 : if(SubScreen.gpu->dispBG[0]) { GPU_remove(SubScreen.gpu, 0); - MainWindow->checkMenu(IDM_SBG0, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDM_SBG0, false); } else { GPU_addBack(SubScreen.gpu, 0); - MainWindow->checkMenu(IDM_SBG0, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(IDM_SBG0, true); } return 0; case IDM_SBG1 : if(SubScreen.gpu->dispBG[1]) { GPU_remove(SubScreen.gpu, 1); - MainWindow->checkMenu(IDM_SBG1, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDM_SBG1, false); } else { GPU_addBack(SubScreen.gpu, 1); - MainWindow->checkMenu(IDM_SBG1, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(IDM_SBG1, true); } return 0; case IDM_SBG2 : if(SubScreen.gpu->dispBG[2]) { GPU_remove(SubScreen.gpu, 2); - MainWindow->checkMenu(IDM_SBG2, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDM_SBG2, false); } else { GPU_addBack(SubScreen.gpu, 2); - MainWindow->checkMenu(IDM_SBG2, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(IDM_SBG2, true); } return 0; case IDM_SBG3 : if(SubScreen.gpu->dispBG[3]) { GPU_remove(SubScreen.gpu, 3); - MainWindow->checkMenu(IDM_SBG3, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDM_SBG3, false); } else { GPU_addBack(SubScreen.gpu, 3); - MainWindow->checkMenu(IDM_SBG3, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(IDM_SBG3, true); } return 0; @@ -3335,54 +3359,48 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM return 0; case ID_VIEW_FRAMECOUNTER: CommonSettings.hud.FrameCounterDisplay ^= true; - MainWindow->checkMenu(ID_VIEW_FRAMECOUNTER, CommonSettings.hud.FrameCounterDisplay ? MF_CHECKED : MF_UNCHECKED); WritePrivateProfileBool("Display", "Display Fps", CommonSettings.hud.FpsDisplay, IniName); return 0; case ID_VIEW_DISPLAYFPS: CommonSettings.hud.FpsDisplay ^= true; - MainWindow->checkMenu(ID_VIEW_DISPLAYFPS, CommonSettings.hud.FpsDisplay ? MF_CHECKED : MF_UNCHECKED); WritePrivateProfileBool("Display", "Display Fps", CommonSettings.hud.FpsDisplay, IniName); osd->clear(); return 0; case ID_VIEW_DISPLAYINPUT: CommonSettings.hud.ShowInputDisplay ^= true; - MainWindow->checkMenu(ID_VIEW_DISPLAYINPUT, CommonSettings.hud.ShowInputDisplay ? MF_CHECKED : MF_UNCHECKED); WritePrivateProfileBool("Display", "Display Input", CommonSettings.hud.ShowInputDisplay, IniName); osd->clear(); return 0; case ID_VIEW_DISPLAYLAG: CommonSettings.hud.ShowLagFrameCounter ^= true; - MainWindow->checkMenu(ID_VIEW_DISPLAYLAG, CommonSettings.hud.ShowLagFrameCounter ? MF_CHECKED : MF_UNCHECKED); WritePrivateProfileBool("Display", "Display Lag Counter", CommonSettings.hud.ShowLagFrameCounter, IniName); osd->clear(); return 0; case ID_VIEW_HUDEDITOR: HudEditorMode ^= true; - MainWindow->checkMenu(ID_VIEW_HUDEDITOR, HudEditorMode ? MF_CHECKED : MF_UNCHECKED); osd->clear(); osd->border(HudEditorMode); return 0; case ID_VIEW_DISPLAYMICROPHONE: CommonSettings.hud.ShowMicrophone ^= true; - MainWindow->checkMenu(ID_VIEW_DISPLAYMICROPHONE, CommonSettings.hud.ShowMicrophone ? MF_CHECKED : MF_UNCHECKED); WritePrivateProfileBool("Display", "Display Microphone", CommonSettings.hud.ShowMicrophone, IniName); osd->clear(); return 0; case ID_RAM_SEARCH: - if(!RamSearchHWnd) - { - InitRamSearch(); - RamSearchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMSEARCH), hwnd, (DLGPROC) RamSearchProc); - } - else - SetForegroundWindow(RamSearchHWnd); - break; + if(!RamSearchHWnd) + { + InitRamSearch(); + RamSearchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMSEARCH), hwnd, (DLGPROC) RamSearchProc); + } + else + SetForegroundWindow(RamSearchHWnd); + break; case ID_RAM_WATCH: if(!RamWatchHWnd) @@ -3483,35 +3501,17 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case IDC_FRAMELIMIT: FrameLimit ^= 1; - MainWindow->checkMenu(IDC_FRAMELIMIT, FrameLimit ? MF_CHECKED : MF_UNCHECKED); WritePrivateProfileInt("FrameLimit", "FrameLimit", FrameLimit, IniName); return 0; + case IDM_SCREENSEP_NONE: - { - SetScreenGap(0); - MainWindow->checkMenu(IDM_SCREENSEP_NONE, MF_BYCOMMAND | MF_CHECKED); - MainWindow->checkMenu(IDM_SCREENSEP_BORDER, MF_BYCOMMAND | MF_UNCHECKED); - MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, MF_BYCOMMAND | MF_UNCHECKED); - UpdateWndRects(hwnd); - } + SetScreenGap(kGapNone); return 0; case IDM_SCREENSEP_BORDER: - { - SetScreenGap(5); - MainWindow->checkMenu(IDM_SCREENSEP_NONE, MF_BYCOMMAND | MF_UNCHECKED); - MainWindow->checkMenu(IDM_SCREENSEP_BORDER, MF_BYCOMMAND | MF_CHECKED); - MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, MF_BYCOMMAND | MF_UNCHECKED); - UpdateWndRects(hwnd); - } + SetScreenGap(kGapBorder); return 0; case IDM_SCREENSEP_NDSGAP: - { - SetScreenGap(64); - MainWindow->checkMenu(IDM_SCREENSEP_NONE, MF_BYCOMMAND | MF_UNCHECKED); - MainWindow->checkMenu(IDM_SCREENSEP_BORDER, MF_BYCOMMAND | MF_UNCHECKED); - MainWindow->checkMenu(IDM_SCREENSEP_NDSGAP, MF_BYCOMMAND | MF_CHECKED); - UpdateWndRects(hwnd); - } + SetScreenGap(kGapNDS); return 0; case IDM_WEBSITE: ShellExecute(NULL, "open", "http://desmume.sourceforge.net", NULL, NULL, SW_SHOWNORMAL); @@ -3665,7 +3665,7 @@ LRESULT CALLBACK GFX3DSettingsDlgProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) { case IDOK: { - CommonSettings.HighResolutionInterpolateColor = IsDlgButtonChecked(hw,IDC_INTERPOLATECOLOR); + CommonSettings.HighResolutionInterpolateColor = IsDlgCheckboxChecked(hw,IDC_INTERPOLATECOLOR); NDS_3D_ChangeCore(ComboBox_GetCurSel(GetDlgItem(hw, IDC_3DCORE))); WritePrivateProfileInt("3D", "Renderer", cur3DCore, IniName); WritePrivateProfileInt("3D", "HighResolutionInterpolateColor", CommonSettings.HighResolutionInterpolateColor?1:0, IniName); @@ -3757,19 +3757,19 @@ LRESULT CALLBACK EmulationSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, L HWND cur; - CommonSettings.UseExtBIOS = IsDlgButtonChecked(hDlg, IDC_USEEXTBIOS); + CommonSettings.UseExtBIOS = IsDlgCheckboxChecked(hDlg, IDC_USEEXTBIOS); cur = GetDlgItem(hDlg, IDC_ARM9BIOS); GetWindowText(cur, CommonSettings.ARM9BIOS, 256); cur = GetDlgItem(hDlg, IDC_ARM7BIOS); GetWindowText(cur, CommonSettings.ARM7BIOS, 256); - CommonSettings.SWIFromBIOS = IsDlgButtonChecked(hDlg, IDC_BIOSSWIS); + CommonSettings.SWIFromBIOS = IsDlgCheckboxChecked(hDlg, IDC_BIOSSWIS); - CommonSettings.UseExtFirmware = IsDlgButtonChecked(hDlg, IDC_USEEXTFIRMWARE); + CommonSettings.UseExtFirmware = IsDlgCheckboxChecked(hDlg, IDC_USEEXTFIRMWARE); cur = GetDlgItem(hDlg, IDC_FIRMWARE); GetWindowText(cur, CommonSettings.Firmware, 256); - CommonSettings.BootFromFirmware = IsDlgButtonChecked(hDlg, IDC_FIRMWAREBOOT); + CommonSettings.BootFromFirmware = IsDlgCheckboxChecked(hDlg, IDC_FIRMWAREBOOT); - CommonSettings.DebugConsole = IsDlgButtonChecked(hDlg, IDC_CHECKBOX_DEBUGGERMODE); + CommonSettings.DebugConsole = IsDlgCheckboxChecked(hDlg, IDC_CHECKBOX_DEBUGGERMODE); WritePrivateProfileInt("Emulation", "DebugConsole", ((CommonSettings.DebugConsole == true) ? 1 : 0), IniName); WritePrivateProfileInt("BIOS", "UseExtBIOS", ((CommonSettings.UseExtBIOS == true) ? 1 : 0), IniName); @@ -3879,7 +3879,7 @@ LRESULT CALLBACK MicrophoneSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, { HWND cur; - UseMicSample = GetPrivateProfileInt("Use Mic Sample", "UseMicSample", FALSE, IniName); + UseMicSample = GetPrivateProfileBool("Use Mic Sample", "UseMicSample", false, IniName); CheckDlgButton(hDlg, IDC_USEMICSAMPLE, ((UseMicSample == true) ? BST_CHECKED : BST_UNCHECKED)); GetPrivateProfileString("Use Mic Sample", "MicSampleFile", "micsample.raw", MicSampleName, MAX_PATH, IniName); SetDlgItemText(hDlg, IDC_MICSAMPLE, MicSampleName); @@ -3906,7 +3906,7 @@ LRESULT CALLBACK MicrophoneSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, { HWND cur; - UseMicSample = IsDlgButtonChecked(hDlg, IDC_USEMICSAMPLE); + UseMicSample = IsDlgCheckboxChecked(hDlg, IDC_USEMICSAMPLE); cur = GetDlgItem(hDlg, IDC_MICSAMPLE); GetWindowText(cur, MicSampleName, 256); diff --git a/desmume/src/windows/main.h b/desmume/src/windows/main.h index 1ff526d05..b4772cb00 100644 --- a/desmume/src/windows/main.h +++ b/desmume/src/windows/main.h @@ -4,7 +4,7 @@ #include "CWindow.h" extern WINCLASS *MainWindow; -extern volatile BOOL execute, paused; +extern volatile bool execute, paused; void NDS_Pause(); void NDS_UnPause(); void LoadSaveStateInfo(); diff --git a/desmume/src/windows/mapView.cpp b/desmume/src/windows/mapView.cpp index 096ba811a..ac14c30af 100644 --- a/desmume/src/windows/mapView.cpp +++ b/desmume/src/windows/mapView.cpp @@ -35,7 +35,7 @@ struct mapview_struct u32 autoup_secs; bool autoup; - u16 map; + u8 map; u16 lcd; u16 bitmap[1024*1024]; bool clear; diff --git a/desmume/src/windows/memView.cpp b/desmume/src/windows/memView.cpp index d7d794cb3..08d77983c 100644 --- a/desmume/src/windows/memView.cpp +++ b/desmume/src/windows/memView.cpp @@ -362,7 +362,6 @@ BOOL CALLBACK MemView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam { FILE *f; u8 memory[0x100]; - int line; MMU_DumpMemBlock(data->cpu, data->address, 0x100, memory); diff --git a/desmume/src/windows/throttle.cpp b/desmume/src/windows/throttle.cpp index dc1f85302..6986f61ee 100644 --- a/desmume/src/windows/throttle.cpp +++ b/desmume/src/windows/throttle.cpp @@ -90,7 +90,7 @@ waiter: Sleep(100); return 1; } - Sleep(sleepy); + Sleep((DWORD)sleepy); goto waiter; } if( (ttime-ltime) >= (tfreq*4/desiredfps)) diff --git a/desmume/src/windows/tileView.cpp b/desmume/src/windows/tileView.cpp index a798bd134..b11c5ad5f 100644 --- a/desmume/src/windows/tileView.cpp +++ b/desmume/src/windows/tileView.cpp @@ -138,7 +138,7 @@ LRESULT TileViewBox_Pal256(HWND hwnd, tileview_struct * win, WPARAM wParam, LPAR if(win->pal) { - u32 i, num2, num, y, x; + u32 num2, num, y, x; u8* mem; if(win->target >= ARM9MEM_LCDC)