From 15da28c26a6f23e554d75b03965dec680900ef1a Mon Sep 17 00:00:00 2001 From: spacy51 Date: Wed, 19 Aug 2009 20:40:29 +0000 Subject: [PATCH] Added "detect now" tool for detecting the backup media of the cartridge. git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@895 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/win32/MainWnd.cpp | 3 +++ src/win32/MainWnd.h | 1 + src/win32/MainWndOptions.cpp | 30 ++++++++++++++++++++++++++++++ src/win32/VBA.rc | 2 ++ src/win32/resource.h | 3 ++- 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp index f59ef53f..16e01618 100644 --- a/src/win32/MainWnd.cpp +++ b/src/win32/MainWnd.cpp @@ -170,6 +170,7 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd) ON_COMMAND(ID_OPTIONS_EMULATOR_REALTIMECLOCK, OnOptionsEmulatorRealtimeclock) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_REALTIMECLOCK, OnUpdateOptionsEmulatorRealtimeclock) ON_COMMAND(ID_OPTIONS_EMULATOR_REWINDINTERVAL, OnOptionsEmulatorRewindinterval) + ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC, OnOptionsEmulatorSavetypeAutomatic) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC, OnUpdateOptionsEmulatorSavetypeAutomatic) ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM, OnOptionsEmulatorSavetypeEeprom) @@ -186,6 +187,8 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K, OnUpdateOptionsEmulatorSavetypeFlash512k) ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M, OnOptionsEmulatorSavetypeFlash1m) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M, OnUpdateOptionsEmulatorSavetypeFlash1m) + ON_COMMAND(ID_OPTIONS_EMULATOR_SAVETYPE_DETECTNOW, OnOptionsEmulatorSavetypeDetectNow) + ON_COMMAND(ID_OPTIONS_EMULATOR_PNGFORMAT, OnOptionsEmulatorPngformat) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_PNGFORMAT, OnUpdateOptionsEmulatorPngformat) ON_COMMAND(ID_OPTIONS_EMULATOR_BMPFORMAT, OnOptionsEmulatorBmpformat) diff --git a/src/win32/MainWnd.h b/src/win32/MainWnd.h index a06f929a..42f1894d 100644 --- a/src/win32/MainWnd.h +++ b/src/win32/MainWnd.h @@ -188,6 +188,7 @@ protected: afx_msg void OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI* pCmdUI); afx_msg void OnOptionsEmulatorSavetypeFlash1m(); afx_msg void OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI* pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeDetectNow(); afx_msg void OnOptionsEmulatorPngformat(); afx_msg void OnUpdateOptionsEmulatorPngformat(CCmdUI* pCmdUI); afx_msg void OnOptionsEmulatorBmpformat(); diff --git a/src/win32/MainWndOptions.cpp b/src/win32/MainWndOptions.cpp index df6b6a63..a3359bfd 100644 --- a/src/win32/MainWndOptions.cpp +++ b/src/win32/MainWndOptions.cpp @@ -784,6 +784,36 @@ void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI* pCmdUI) pCmdUI->SetCheck(flashSize == 0x20000); } +void MainWnd::OnOptionsEmulatorSavetypeDetectNow() +{ + const int address_max = theApp.romSize - 10; + char temp[11]; temp[10] = '\0'; + CString answer( _T( "This cartridge has probably no backup media." ) ); + + for( int address = 0; address < address_max; address += 4 ) { + memcpy( temp, &rom[address], 10 ); + + if( 0 == strncmp( temp, "EEPROM_V", 8 ) ) { + answer = _T( "This cartridge uses EEPROM." ); + break; + } + if( 0 == strncmp( temp, "SRAM_V", 6 ) ) { + answer = _T( "This cartridge uses SRAM." ); + break; + } + if( ( 0 == strncmp( temp, "FLASH_V", 7 ) ) || ( 0 == strncmp( temp, "FLASH512_V", 10 ) ) ) { + answer = _T( "This cartridge uses FLASH (64 KiB)." ); + break; + } + if( 0 == strncmp( temp, "FLASH1M_V", 9 ) ) { + answer = _T( "This cartridge uses FLASH (128 KiB)." ); + break; + } + } + + MessageBox( answer ); +} + void MainWnd::OnOptionsEmulatorPngformat() { theApp.captureFormat = 0; diff --git a/src/win32/VBA.rc b/src/win32/VBA.rc index 6153e001..30c538c0 100644 --- a/src/win32/VBA.rc +++ b/src/win32/VBA.rc @@ -1885,6 +1885,8 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Flash 64 KB", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH512K MENUITEM "Flash 128 KB", ID_OPTIONS_EMULATOR_SAVETYPE_FLASH1M + MENUITEM SEPARATOR + MENUITEM "Detect now...", 40372 END POPUP "Screenshot &Format" BEGIN diff --git a/src/win32/resource.h b/src/win32/resource.h index e295744a..5ab17819 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -870,13 +870,14 @@ #define ID_FILE_OPEN_GBA 40366 #define ID_OPTIONS_VIDEO_LAYERS_RESET 40367 #define ID_LOADGAME_DONOTCHANGECHEATLIST 40371 +#define ID_OPTIONS_EMULATOR_SAVETYPE_DETECTNOW 40372 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 165 -#define _APS_NEXT_COMMAND_VALUE 40372 +#define _APS_NEXT_COMMAND_VALUE 40373 #define _APS_NEXT_CONTROL_VALUE 1297 #define _APS_NEXT_SYMED_VALUE 103 #endif