diff --git a/desmume/ChangeLog b/desmume/ChangeLog index 423b14cfe..4d8e263ce 100644 --- a/desmume/ChangeLog +++ b/desmume/ChangeLog @@ -61,7 +61,8 @@ ? Fix a bug in texture transformation mode 1 [zeromus] - Fix the buggy auto frameskip logic which made the emu slow to a crawl. Now it runs fast! [zeromus] - Fix resizing, rotate & aspect ration of main window. Add save window position and parameters [CrazyMax] - + - Rewrite all debug tools (autoupdate work now) [CrazyMax] + 0.7.3 -> 0.8 Cocoa: - Save State As function now works. [Jeff B] diff --git a/desmume/src/windows/AboutBox.cpp b/desmume/src/windows/AboutBox.cpp index 2eeed495b..724ab9401 100644 --- a/desmume/src/windows/AboutBox.cpp +++ b/desmume/src/windows/AboutBox.cpp @@ -18,14 +18,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include -#include -#include -#include -#include "CWindow.h" +#include + #include "AboutBox.h" #include "resource.h" @@ -51,4 +46,4 @@ BOOL CALLBACK AboutBox_Proc (HWND dialog, UINT message,WPARAM wparam,LPARAM lpar } } return 0; -} \ No newline at end of file +} diff --git a/desmume/src/windows/AboutBox.h b/desmume/src/windows/AboutBox.h index b93eb12a0..ac53852e8 100644 --- a/desmume/src/windows/AboutBox.h +++ b/desmume/src/windows/AboutBox.h @@ -21,6 +21,6 @@ #ifndef ABOUTBOX_H #define ABOUTBOX_H -BOOL CALLBACK AboutBox_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam); +extern BOOL CALLBACK AboutBox_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam); -#endif +#endif \ No newline at end of file diff --git a/desmume/src/windows/CWindow.cpp b/desmume/src/windows/CWindow.cpp index b0cbcc5ea..b63b00365 100644 --- a/desmume/src/windows/CWindow.cpp +++ b/desmume/src/windows/CWindow.cpp @@ -20,211 +20,196 @@ */ #include "CWindow.h" -#include "resource.h" +#include "debug.h" -CRITICAL_SECTION section; -cwindow_struct *updatewindowlist = NULL; - -////////////////////////////////////////////////////////////////////////////// - -int CWindow_Init(void *win, HINSTANCE hInst, const char * cname, const char * title, int style, int sx, int sy, WNDPROC wP) +WINCLASS::WINCLASS(LPSTR rclass, HINSTANCE hInst) { - static BOOL first = FALSE; - RECT clientaera; - cwindow_struct *win2=(cwindow_struct *)win; + memset(regclass, 0, sizeof(regclass)); + memcpy(regclass, rclass, strlen(rclass)); - win2->autoup = FALSE; - - if(!first) - { - WNDCLASSEX wincl; // Data structure for the windowclass - - // The Window structure - wincl.hInstance = hInst; - wincl.lpszClassName = cname; - wincl.lpfnWndProc = wP; // This function is called by windows - wincl.style = CS_DBLCLKS; // Catch double-clicks - wincl.cbSize = sizeof (WNDCLASSEX); - - // Use default icon and mouse-pointer - //wincl.hIcon = LoadIcon (hInst, MAKEINTRESOURCE(IconDeSmuME));//IDI_APPLICATION); - //wincl.hIconSm = LoadIcon (hInst, MAKEINTRESOURCE(IconDeSmuME));//IDI_APPLICATION); - wincl.hIcon = LoadIcon (hInst, IDI_APPLICATION); - wincl.hIconSm = LoadIcon (hInst, IDI_APPLICATION); - wincl.hCursor = LoadCursor (NULL, IDC_ARROW); - wincl.lpszMenuName = NULL; // No menu - wincl.cbClsExtra = 0; // No extra bytes after the window class - wincl.cbWndExtra = 0; // structure or the window instance - // Use Windows's default color as the background of the window - wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; - - // Register the window class, and if it fails quit the program - if (!RegisterClassEx (&wincl)) - return -1; - win2->first=NULL; - first = TRUE; - } - - clientaera.left = 0; - clientaera.top = 0; - clientaera.right = sx; - clientaera.bottom = sy; - - AdjustWindowRectEx(&clientaera, style, TRUE, 0); - - // The class is registered, let's create the program - win2->hwnd = CreateWindowEx ( - 0, // Extended possibilites for variation - cname, // Classname - title, // Title Text - style, // default window - CW_USEDEFAULT, // Windows decides the position - CW_USEDEFAULT, // where the window ends up on the screen - clientaera.right - clientaera.left, // The programs width - clientaera.bottom - clientaera.top, // and height in pixels - HWND_DESKTOP, // The window is a child-window to desktop - NULL, // No menu - hInst, // Program Instance handler - NULL // No Window Creation data - ); - - win2->prev = NULL; - win2->next = NULL; - win2->Refresh = &CWindow_Refresh; - - return 0; + hwnd = NULL; + hmenu = NULL; + hInstance = hInst; } -////////////////////////////////////////////////////////////////////////////// - -int CWindow_Init2(void *win, HINSTANCE hInst, HWND parent, char * title, int ID, DLGPROC wP) +WINCLASS::~WINCLASS() { - HMENU hSystemMenu; - - cwindow_struct *win2=(cwindow_struct *)win; - - win2->autoup = FALSE; - win2->hwnd = CreateDialog(hInst, MAKEINTRESOURCE(ID), parent, wP); - SetWindowLong(win2->hwnd, DWL_USER, (LONG)win2); - SetWindowText(win2->hwnd, title); - win2->prev = NULL; - win2->next = NULL; - win2->Refresh = &CWindow_Refresh; - - // Append the "Auto Update" to the System Menu - hSystemMenu = GetSystemMenu(win2->hwnd, FALSE); - if(hSystemMenu != 0) - { - AppendMenu(hSystemMenu, MF_MENUBREAK, 0, NULL); - AppendMenu(hSystemMenu, MF_ENABLED|MF_STRING, IDC_AUTO_UPDATE, "Auto Update"); - } - - return 0; } -////////////////////////////////////////////////////////////////////////////// - -void CWindow_Show(void *win) +bool WINCLASS::create(LPSTR caption, int x, int y, int width, int height, int style, HMENU menu) { - ShowWindow (((cwindow_struct *)win)->hwnd, SW_SHOW); -} - -////////////////////////////////////////////////////////////////////////////// - -void CWindow_Hide(void *win) -{ - ShowWindow (((cwindow_struct *)win)->hwnd, SW_HIDE); -} - -////////////////////////////////////////////////////////////////////////////// - -void CWindow_Refresh(void *win) -{ - InvalidateRect(((cwindow_struct *)win)->hwnd, NULL, FALSE); -} - -////////////////////////////////////////////////////////////////////////////// - -void CWindow_UpdateAutoUpdateItem(cwindow_struct *win, int check) -{ - HMENU hSystemMenu; + if (hwnd != NULL) return false; - // Update the "auto update" menu item - hSystemMenu = GetSystemMenu(win->hwnd, FALSE); - if(hSystemMenu != 0) - { - const int checkState[] = - { - MF_UNCHECKED, - MF_CHECKED - }; + hwnd = CreateWindow(regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL); + + if (hwnd != NULL) return true; + return false; +} - CheckMenuItem(hSystemMenu, IDC_AUTO_UPDATE, checkState[check]); +bool WINCLASS::createEx(LPSTR caption, int x, int y, int width, int height, int style, int styleEx, HMENU menu) +{ + if (hwnd != NULL) return false; + + hwnd = CreateWindowEx(styleEx, regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL); + + if (hwnd != NULL) return true; + return false; +} + +bool WINCLASS::setMenu(HMENU menu) +{ + hmenu = menu; + return SetMenu(hwnd, hmenu); +} + +DWORD WINCLASS::checkMenu(UINT idd, UINT check) +{ + return CheckMenuItem(hmenu, idd, check); +} + +HWND WINCLASS::getHWnd() +{ + return hwnd; +} + +void WINCLASS::Show(int mode) +{ + ShowWindow(hwnd, mode); +} + +void WINCLASS::Hide() +{ + ShowWindow(hwnd, SW_HIDE); +} + +//========================================================= Thread class +extern DWORD WINAPI ThreadProc(LPVOID lpParameter) +{ + THREADCLASS *tmp = (THREADCLASS *)lpParameter; + return tmp->ThreadFunc(); +} + +THREADCLASS::THREADCLASS() +{ + hThread = NULL; +} + +THREADCLASS::~THREADCLASS() +{ + closeThread(); +} + +void THREADCLASS::closeThread() +{ + if (hThread) + { + CloseHandle(hThread); + hThread = NULL; } } -////////////////////////////////////////////////////////////////////////////// - -void CWindow_AddToRefreshList(void *win) +bool THREADCLASS::createThread() { - cwindow_struct *win2=(cwindow_struct *)win; + if (hThread) return false; - EnterCriticalSection(§ion); - win2->prev = NULL; - win2->next = updatewindowlist; - if(updatewindowlist) - updatewindowlist->prev = win; - updatewindowlist = (cwindow_struct *)win; - LeaveCriticalSection(§ion); - - CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, TRUE); + hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &threadID); + if (!hThread) return false; + //WaitForSingleObject(hThread, INFINITE); + return true; } -////////////////////////////////////////////////////////////////////////////// - -void CWindow_RemoveFromRefreshList(void *win) +//========================================================= Tools class +TOOLSCLASS::TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC dlgproc) { - cwindow_struct *win2=(cwindow_struct *)win; - - EnterCriticalSection(§ion); - if(updatewindowlist == win) - { - updatewindowlist = (cwindow_struct *)win2->next; - if(updatewindowlist) updatewindowlist->prev = NULL; - } - else - if(win2->prev) - { - ((cwindow_struct *)win2->prev)->next = win2->next; - if(win2->next) ((cwindow_struct *)win2->next)->prev = win2->prev; - } - win2->next = NULL; - win2->prev = NULL; - LeaveCriticalSection(§ion); - - CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, FALSE); + this->dlgproc = dlgproc; + hwnd = NULL; + hInstance = hInst; + idd=IDD; + memset(class_name, 0, sizeof(class_name)); + memset(class_name2, 0, sizeof(class_name2)); } -////////////////////////////////////////////////////////////////////////////// - -int CWindow_ToggleAutoUpdate(void *win) +TOOLSCLASS::~TOOLSCLASS() { - cwindow_struct *win2=(cwindow_struct *)win; - - // remove window from refresh list - if(win2->autoup) - CWindow_RemoveFromRefreshList(win); - - // toggle autoup variable - win2->autoup = !win2->autoup; - - // add window to refresg list if autoupdate is desired - if(win2->autoup) - CWindow_AddToRefreshList(win); - - // checks or unchecks the auto update item in the system menu - CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, win2->autoup); - - return win2->autoup; + close(); } +bool TOOLSCLASS::open() +{ + if (!createThread()) return false; + return true; +} + +bool TOOLSCLASS::close() +{ + return true; +} + +DWORD TOOLSCLASS::ThreadFunc() +{ + MSG messages; + printlog("Start thread\n"); + + GetLastError(); + hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(idd), NULL, (DLGPROC) dlgproc); + + if (!hwnd) + { + printlog("error creating dialog\n"); + return (-2); + } + + ShowWindow(hwnd, SW_SHOW); + UpdateWindow(hwnd); + + while (GetMessage (&messages, NULL, 0, 0)) + { + TranslateMessage(&messages); + DispatchMessage(&messages); + } + + unregClass(); + hwnd = NULL; + + closeThread(); + return 0; +} + +void TOOLSCLASS::regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg) +{ + WNDCLASSEX wc; + + wc.cbSize = sizeof(wc); + if (SecondReg) + strcpy(this->class_name2, class_name); + else + strcpy(this->class_name, class_name); + + wc.lpszClassName = class_name; + wc.hInstance = hInstance; + wc.lpfnWndProc = wproc; + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hIcon = 0; + wc.lpszMenuName = 0; + wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); + wc.style = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hIconSm = 0; + + RegisterClassEx(&wc); +} + +void TOOLSCLASS::unregClass() +{ + if (class_name[0]) + { + UnregisterClass(class_name, hInstance); + } + if (class_name2[0]) + { + UnregisterClass(class_name2, hInstance); + } + memset(class_name, 0, sizeof(class_name)); + memset(class_name2, 0, sizeof(class_name2)); +} diff --git a/desmume/src/windows/CWindow.h b/desmume/src/windows/CWindow.h index 70be571d5..088dc9f73 100644 --- a/desmume/src/windows/CWindow.h +++ b/desmume/src/windows/CWindow.h @@ -22,48 +22,69 @@ #ifndef CWINDOW_H #define CWINDOW_H -#define WIN32_LEAN_AND_MEAN #include -#include "types.h" -#ifdef _x64 - #define DWL_USER DWLP_USER -#endif - -extern CRITICAL_SECTION section; - -typedef struct +class WINCLASS { - HWND hwnd; - BOOL autoup; - void *prev; - void *next; - void *first; - void (*Refresh)(void *win); -} cwindow_struct; +private: + HWND hwnd; + HMENU hmenu; + HINSTANCE hInstance; + char regclass[256]; +public: + WINCLASS(LPSTR rclass, HINSTANCE hInst); + ~WINCLASS(); -int CWindow_Init(void *win, HINSTANCE hInst, const char * cname, const char * title, int style, int sx, int sy, WNDPROC wP); -int CWindow_Init2(void *win, HINSTANCE hInst, HWND parent, char * title, int ID, DLGPROC wP); -void CWindow_Show(void *win); -void CWindow_Hide(void *win); -void CWindow_Refresh(void *win); -void CWindow_AddToRefreshList(void *win); -void CWindow_RemoveFromRefreshList(void *win); -int CWindow_ToggleAutoUpdate(void *win); + bool create(LPSTR caption, int x, int y, int width, int height, int style, + HMENU menu); + bool createEx(LPSTR caption, int x, int y, int width, int height, int style, int styleEx, + HMENU menu); -extern cwindow_struct *updatewindowlist; + bool setMenu(HMENU menu); + DWORD checkMenu(UINT idd, UINT check); -static INLINE void CWindow_RefreshALL() + void Show(int mode); + void Hide(); + + HWND getHWnd(); +}; + +class THREADCLASS { - cwindow_struct *aux; - EnterCriticalSection(§ion); - aux = updatewindowlist; - while(aux) - { - aux->Refresh(aux); - aux = (cwindow_struct *)aux->next; - } - LeaveCriticalSection(§ion); -} + friend DWORD WINAPI ThreadProc(LPVOID lpParameter); + HANDLE hThread; + +public: + THREADCLASS(); + virtual ~THREADCLASS(); + bool createThread(); + void closeThread(); + +protected: + DWORD threadID; + virtual DWORD ThreadFunc()=NULL; +}; + +class TOOLSCLASS : public THREADCLASS +{ +private: + HWND hwnd; + HINSTANCE hInstance; + DLGPROC dlgproc; + int idd; + char class_name[256]; + char class_name2[256]; + +protected: + DWORD ThreadFunc(); + +public: + TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC wndproc); + virtual ~TOOLSCLASS(); + bool open(); + bool close(); + void regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg = false); + void unregClass(); +}; #endif diff --git a/desmume/src/windows/ConfigKeys.cpp b/desmume/src/windows/ConfigKeys.cpp index cfdf02b72..ab9830133 100644 --- a/desmume/src/windows/ConfigKeys.cpp +++ b/desmume/src/windows/ConfigKeys.cpp @@ -31,11 +31,9 @@ #include "ConfigKeys.h" #include "../debug.h" +#include "../common.h" #include "resource.h" -static char IniName[MAX_PATH]; -char vPath[MAX_PATH],*szPath,currDir[MAX_PATH]; - const char *tabkeytext[52] = {"0","1","2","3","4","5","6","7","8","9","A","B","C", "D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X", "Y","Z","SPACE","UP","DOWN","LEFT","RIGHT","TAB","SHIFT","DEL","INSERT","HOME","END","ENTER", @@ -93,38 +91,11 @@ LPDIRECTINPUTDEVICE8 g_pKeyboard; LPDIRECTINPUTDEVICE8 g_pJoystick; DIDEVCAPS g_DIJoycap; -void GetINIPath(char *inipath,u16 bufferSize) -{ - if (*vPath) - szPath = vPath; - else - { - char *p; - ZeroMemory(vPath, sizeof(vPath)); - GetModuleFileName(NULL, vPath, sizeof(vPath)); - p = vPath + lstrlen(vPath); - while (p >= vPath && *p != '\\') p--; - if (++p >= vPath) *p = 0; - szPath = vPath; - } - if (strlen(szPath) + strlen("\\desmume.ini") < bufferSize) - { - sprintf(inipath, "%s\\desmume.ini",szPath); - } else if (bufferSize> strlen(".\\desmume.ini")) { - sprintf(inipath, ".\\desmume.ini",szPath); - } else - { - memset(inipath,0,bufferSize) ; - } -} - void ReadConfig(void) { FILE *fp; int i; - GetINIPath(IniName,MAX_PATH); - i=GetPrivateProfileInt("Keys","Key_A",31, IniName); KEY_A = i; @@ -180,8 +151,6 @@ void WriteConfig(void) FILE *fp; int i; - GetINIPath(IniName,MAX_PATH); - WritePrivateProfileInt("Keys","Key_A",KEY_A,IniName); WritePrivateProfileInt("Keys","Key_B",KEY_B,IniName); WritePrivateProfileInt("Keys","Key_SELECT",KEY_SELECT,IniName); @@ -233,6 +202,7 @@ IDC_COMBO10, IDC_COMBO11, IDC_COMBO12}; +#if 1 BOOL CALLBACK ConfigView_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam) { int i,j; @@ -320,7 +290,7 @@ BOOL CALLBACK ConfigView_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lp } return 0; } - +#endif //================================================================================================ //================================================================================================ @@ -473,4 +443,48 @@ void Input_Process() } } } -} \ No newline at end of file +} + +//============================================================ New config dialog +//============================================================ +//============================================================ +//============================================================ +//============================================================ +//============================================================ +//============================================================ +//============================================================ +#if 0 +bool CALLBACK InputConfigDlgProc( HWND hDlg, + UINT uMessage, + WPARAM wParam, + LPARAM lParam) +{ + switch (uMessage) + { + case WM_INITDIALOG: + return true; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDOK: + EndDialog(hDlg, IDOK); + break; + + case IDCANCEL: + EndDialog(hDlg, IDOK); + break; + } + return true; + } + + //return false; + return DefWindowProc( hDlg, uMessage, wParam, lParam); +} +#endif +void InputConfig(HWND hwnd) +{ + //DialogBox(hAppInst,MAKEINTRESOURCE(IDD_INPUT), hwnd, (DLGPROC) InputConfigDlgProc); + DialogBox(hAppInst,MAKEINTRESOURCE(IDD_CONFIG), hwnd, (DLGPROC) ConfigView_Proc); +} + diff --git a/desmume/src/windows/ConfigKeys.h b/desmume/src/windows/ConfigKeys.h index 864b9083f..9d29b31fe 100644 --- a/desmume/src/windows/ConfigKeys.h +++ b/desmume/src/windows/ConfigKeys.h @@ -24,6 +24,8 @@ #define DIRECTINPUT_VERSION 0x0800 #include "directx/dinput.h" +#include "common.h" + extern const DWORD tabkey[48]; extern DWORD ds_up; extern DWORD ds_down; @@ -44,13 +46,13 @@ extern LPDIRECTINPUT8 g_pDI; extern LPDIRECTINPUTDEVICE8 g_pKeyboard; extern LPDIRECTINPUTDEVICE8 g_pJoystick; -void GetINIPath(char *initpath,u16 bufferSize); void ReadConfig (void); HRESULT Input_Init (HWND hwnd); HRESULT Input_DeInit (void); void Input_Process (void); -BOOL CALLBACK ConfigView_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam); +//BOOL CALLBACK ConfigView_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lparam); +void InputConfig(HWND hwnd); void WritePrivateProfileInt(char* appname, char* keyname, int val, char* file); #endif diff --git a/desmume/src/windows/DeSmuME_2008.vcproj b/desmume/src/windows/DeSmuME_2008.vcproj index 8832aa1c5..7c9ac2efb 100644 --- a/desmume/src/windows/DeSmuME_2008.vcproj +++ b/desmume/src/windows/DeSmuME_2008.vcproj @@ -55,8 +55,8 @@ EnableFiberSafeOptimizations="false" WholeProgramOptimization="false" AdditionalIncludeDirectories="..;.\zlib123;.\zziplib" - PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\"0.8.0b2 DEBUG\";WIN32;BETA_VERSION;SPU_INTERPOLATE" - ExceptionHandling="0" + PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\"DEBUG\";WIN32;BETA_VERSION;SPU_INTERPOLATE" + ExceptionHandling="1" BufferSecurityCheck="false" EnableEnhancedInstructionSet="0" DebugInformationFormat="4" @@ -74,7 +74,7 @@ /> @@ -491,8 +491,8 @@ EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" AdditionalIncludeDirectories="..;.\zlib123;.\zziplib" - PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\"0.8.0b2 x64 SSE2\";WIN32;_x64;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE" - ExceptionHandling="0" + PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\"x64 SSE2\";WIN32;_x64;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE" + ExceptionHandling="1" BufferSecurityCheck="false" EnableEnhancedInstructionSet="0" WarningLevel="1" @@ -552,289 +552,305 @@ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - + - - - + - - - + - - - + - - - - - + - - - + - - - + - - - + - - - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/desmume/src/windows/FirmConfig.cpp b/desmume/src/windows/FirmConfig.cpp index 8cfb310fe..d71b09523 100644 --- a/desmume/src/windows/FirmConfig.cpp +++ b/desmume/src/windows/FirmConfig.cpp @@ -32,10 +32,9 @@ #include "ConfigKeys.h" #include "../debug.h" +#include "../common.h" #include "../NDSSystem.h" -static char IniName[MAX_PATH]; - static char nickname_buffer[11]; static char message_buffer[27]; @@ -53,7 +52,6 @@ static void WriteFirmConfig( struct NDS_fw_config_data *fw_config) { char temp_str[27]; int i; - GetINIPath(IniName,MAX_PATH); WritePrivateProfileInt("Firmware","favColor", fw_config->fav_colour,IniName); WritePrivateProfileInt("Firmware","bMonth", fw_config->birth_month,IniName); diff --git a/desmume/src/windows/IORegView.cpp b/desmume/src/windows/IORegView.cpp index 31acf81bb..5bafee08d 100644 --- a/desmume/src/windows/IORegView.cpp +++ b/desmume/src/windows/IORegView.cpp @@ -19,13 +19,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include "CWindow.h" +#include "ioregview.h" +#include +#include "debug.h" #include "resource.h" #include "../MMU.h" -#include -////////////////////////////////////////////////////////////////////////////// +typedef struct +{ + u32 autoup_secs; + bool autoup; +} ioregview_struct; + +ioregview_struct *IORegView; LRESULT Ioreg_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) { @@ -44,16 +50,16 @@ LRESULT Ioreg_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) sprintf(text, "%08X", (int)MMU.reg_IME[0]); SetWindowText(GetDlgItem(hwnd, IDC_IME), text); - sprintf(text, "%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x0004>>1]);//((u32 *)ARM9.ARM9_REG)[0x10>>2]); + sprintf(text, "%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x0004>>1]); SetWindowText(GetDlgItem(hwnd, IDC_DISPCNT), text); - sprintf(text, "%08X", ((u16 *)MMU.ARM7_REG)[0x0004>>1]);//MMU.DMACycle[0][1]);//((u16 *)ARM9.ARM9_REG)[0x16>>1]); + sprintf(text, "%08X", ((u16 *)MMU.ARM7_REG)[0x0004>>1]); SetWindowText(GetDlgItem(hwnd, IDC_DISPSTAT), text); - sprintf(text, "%08X", (int)((u32 *)ARM9Mem.ARM9_REG)[0x180>>2]);//MMU.DMACycle[0][2]);//((u32 *)ARM9.ARM9_REG)[0x001C>>2]);//MMU.fifos[0].data[MMU.fifos[0].begin]);//((u32 *)MMU.ARM7_REG)[0x210>>2]); + sprintf(text, "%08X", (int)((u32 *)ARM9Mem.ARM9_REG)[0x180>>2]); SetWindowText(GetDlgItem(hwnd, IDC_IPCSYNC), text); - sprintf(text, "%08X", (int)((u32 *)MMU.ARM7_REG)[0x180>>2]);//MMU.DMACycle[0][3]);//nds.ARM9.SPSR.bits.I);//((u32 *)MMU.ARM7_REG)[0x184>>2]); + sprintf(text, "%08X", (int)((u32 *)MMU.ARM7_REG)[0x180>>2]); SetWindowText(GetDlgItem(hwnd, IDC_IPCFIFO), text); EndPaint(hwnd, &ps); @@ -61,37 +67,76 @@ LRESULT Ioreg_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) return 0; } -////////////////////////////////////////////////////////////////////////////// - BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - cwindow_struct *win = (cwindow_struct *)GetWindowLong(hwnd, DWL_USER); switch (message) { case WM_INITDIALOG : + IORegView = new ioregview_struct; + memset(IORegView, 0, sizeof(ioregview_struct)); + IORegView->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, IORegView->autoup_secs); return 1; case WM_CLOSE : - CWindow_RemoveFromRefreshList(win); - if (win) - free(win); - EndDialog(hwnd, 0); + if(IORegView->autoup) + { + KillTimer(hwnd, IDT_VIEW_IOREG); + IORegView->autoup = false; + } + + if (IORegView!=NULL) + { + delete IORegView; + IORegView = NULL; + } + PostQuitMessage(0); return 1; case WM_PAINT: Ioreg_OnPaint(hwnd, wParam, lParam); return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; case WM_COMMAND : switch (LOWORD (wParam)) { case IDC_FERMER : - CWindow_RemoveFromRefreshList(win); - if (win) - free(win); - EndDialog(hwnd, 0); + SendMessage(hwnd, WM_CLOSE, 0, 0); return 1; + case IDC_AUTO_UPDATE : + if(IORegView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_IOREG); + IORegView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + IORegView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_IOREG, IORegView->autoup_secs*1000, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != IORegView->autoup_secs) + { + IORegView->autoup_secs = t; + if (IORegView->autoup) + SetTimer(hwnd, IDT_VIEW_IOREG, + IORegView->autoup_secs*1000, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; } return 0; } - return 0; + return DefWindowProc(hwnd, message, wParam, lParam); } - -////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/IORegView.h b/desmume/src/windows/IORegView.h index 65287f0b6..b04cae1eb 100644 --- a/desmume/src/windows/IORegView.h +++ b/desmume/src/windows/IORegView.h @@ -21,7 +21,8 @@ #ifndef IO_REG_H #define IO_REG_H +#include -BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +extern BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); #endif diff --git a/desmume/src/windows/disView.cpp b/desmume/src/windows/disView.cpp index 9586ebd22..838f15d2d 100644 --- a/desmume/src/windows/disView.cpp +++ b/desmume/src/windows/disView.cpp @@ -24,388 +24,29 @@ #include #include "../MMU.h" #include "../Disassembler.h" +#include "../NDSSystem.h" +#include "../armcpu.h" #include "disView.h" +#include #include "resource.h" +typedef struct +{ + BOOL autogo; + BOOL autoup; + u32 autoup_secs; + u32 curr_ligne; + armcpu_t *cpu; + u16 mode; +} disview_struct; + +disview_struct *DisView7 = NULL; +disview_struct *DisView9 = NULL; + #define INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF)) -extern HDC hdc; - -LRESULT CALLBACK DisViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -u32 cycles = 1; - -void InitDesViewBox() +LRESULT DisViewBox_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam) { - WNDCLASSEX wc; - - wc.cbSize = sizeof(wc); - wc.lpszClassName = _T("DesViewBox"); - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = DisViewBoxWndProc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(cwindow_struct *); - wc.hIconSm = 0; - - RegisterClassEx(&wc); -} - -/* -LRESULT DesViewBox_OnPaint(CDesView * win, WPARAM wParam, LPARAM lParam) -{ - HWND hwnd = GetDlgItem(win->hwnd, IDC_DES_BOX); - HDC hdc; - PAINTSTRUCT ps; - SIZE fontsize; - TCHAR text[100]; - TCHAR txt[100]; - - RECT rect; - GetClientRect(hwnd, &rect); - int lg = rect.right - rect.left; - int ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - HDC mem_dc = CreateCompatibleDC(hdc); - HBITMAP mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT)); - - GetTextExtentPoint32(mem_dc, "0", 1, &fontsize); - - u32 nbligne = ht/fontsize.cy; - - SetTextColor(mem_dc, RGB(0,0,0)); - - if((win->mode==1) || ((win->mode==0) && (win->cpu->CPSR.bits.T == 0))) - { - u32 adr = win->curr_ligne*4; - - for(u32 i = 0; i < nbligne; ++i) - { - u32 ins = MMU_read32(win->cpu->proc_ID, adr); - des_arm_instructions_set[INDEX(ins)](adr, ins, txt); - sprintf(text, "%04X:%04X %08X %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt); - DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); - rect.top+=fontsize.cy; - adr += 4; - } - - 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)); - rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>2) - win->curr_ligne)*fontsize.cy; - rect.bottom = rect.top + fontsize.cy; - FillRect(mem_dc, &rect, brjaune); - des_arm_instructions_set[INDEX(win->cpu->instruction)](win->cpu->instruct_adr, win->cpu->instruction, txt); - sprintf(text, "%04X:%04X %08X %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)win->cpu->instruction, txt); - DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); - DeleteObject(brjaune); - } - } - else - { - u32 adr = win->curr_ligne*2; - - for(u32 i = 0; i < nbligne; ++i) - { - u32 ins = MMU_read16(win->cpu->proc_ID, adr); - des_thumb_instructions_set[ins>>6](adr, ins, txt); - sprintf(text, "%04X:%04X %04X %s", (int)(adr>>16), (int)(adr&0xFFFF), (int)ins, txt); - DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); - rect.top+=fontsize.cy; - adr += 2; - } - - 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)); - - rect.top = (((win->cpu->instruct_adr&0x0FFFFFFF)>>1) - win->curr_ligne)*fontsize.cy; - rect.bottom = rect.top + fontsize.cy; - FillRect(mem_dc, &rect, brjaune); - des_thumb_instructions_set[((win->cpu->instruction)&0xFFFF)>>6](win->cpu->instruct_adr, win->cpu->instruction&0xFFFF, txt); - sprintf(text, "%04X:%04X %04X %s", (int)((win->cpu->instruct_adr&0x0FFFFFFF)>>16), (int)(win->cpu->instruct_adr&0xFFFF), (int)(win->cpu->instruction&0xFFFF), txt); - DrawText(mem_dc, text, -1, &rect, DT_TOP | DT_LEFT | DT_NOPREFIX); - DeleteObject(brjaune); - } - } - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - return 1; -} - -LRESULT DesViewDialog_OnPaint(HWND hwnd, CDesView * win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - TCHAR text[80]; - - hdc = BeginPaint(hwnd, &ps); - - for(u32 i = 0; i < 16; ++i) - { - sprintf(text, "%08X", (int)win->cpu->R[i]); - SetWindowText(GetDlgItem(hwnd, IDC_R0+i), text); - } - - #define OFF 16 - - SetBkMode(hdc, TRANSPARENT); - if(win->cpu->CPSR.bits.N) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 452+OFF, 238, "N", 1); - - if(win->cpu->CPSR.bits.Z) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 464+OFF, 238, "Z", 1); - - if(win->cpu->CPSR.bits.C) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 475+OFF, 238, "C", 1); - - if(win->cpu->CPSR.bits.V) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 486+OFF, 238, "V", 1); - - if(win->cpu->CPSR.bits.Q) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 497+OFF, 238, "Q", 1); - - if(!win->cpu->CPSR.bits.I) - SetTextColor(hdc, RGB(255,0,0)); - else - SetTextColor(hdc, RGB(70, 70, 70)); - TextOut(hdc, 508+OFF, 238, "I", 1); - - sprintf(text, "%02X", (int)win->cpu->CPSR.bits.mode); - SetWindowText(GetDlgItem(hwnd, IDC_MODE), text); - - sprintf(text, "%08X", MMU.timer[0][0]);//win->cpu->SPSR); - SetWindowText(GetDlgItem(hwnd, IDC_TMP), text); - - EndPaint(hwnd, &ps); - return 1; -} - -LRESULT CALLBACK DesViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - CDesView * win = (CDesView *)GetWindowLong(hwnd, 0); - - switch(msg) - { - case WM_NCCREATE: - SetScrollRange(hwnd, SB_VERT, 0, 0x3FFFFF7, TRUE); - SetScrollPos(hwnd, SB_VERT, 10, TRUE); - return 1; - - case WM_NCDESTROY: - free(win); - return 1; - - case WM_PAINT: - DesViewBox_OnPaint(win, wParam, lParam); - return 1; - - case WM_VSCROLL : - { - RECT rect; - SIZE fontsize; - GetClientRect(hwnd, &rect); - HDC dc = GetDC(hwnd); - HFONT old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); - GetTextExtentPoint32(dc, "0", 1, &fontsize); - - int nbligne = (rect.bottom - rect.top)/fontsize.cy; - - switch LOWORD(wParam) - { - case SB_LINEDOWN : - win->curr_ligne = min(0x3FFFFF7*(1+win->cpu->CPSR.bits.T), win->curr_ligne+1); - break; - case SB_LINEUP : - win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-1); - break; - case SB_PAGEDOWN : - win->curr_ligne = min(0x3FFFFF7*(1+win->cpu->CPSR.bits.T), win->curr_ligne+nbligne); - break; - case SB_PAGEUP : - win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-nbligne); - break; - } - - SelectObject(dc, old); - SetScrollPos(hwnd, SB_VERT, win->curr_ligne, TRUE); - InvalidateRect(hwnd, NULL, FALSE); - UpdateWindow(hwnd); - } - return 1; - - case WM_ERASEBKGND: - return 1; - default: - break; - } - - return DefWindowProc(hwnd, msg, wParam, lParam); -} - - -// DES VIEWER -BOOL CALLBACK des_view_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - CDesView * win = (CDesView *)GetWindowLong(hwnd, DWL_USER); - - switch (message) - { - case WM_INITDIALOG : - SetDlgItemInt(hwnd, IDC_SETPNUM, 1, FALSE); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_DES), BM_SETCHECK, TRUE, 0); - return 1; - case WM_CLOSE : - win->remove2RefreshList(); - delete win; - EndDialog(hwnd, 0); - return 1; - case WM_PAINT: - DesViewDialog_OnPaint(hwnd, win, wParam, lParam); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_FERMER : - win->remove2RefreshList(); - delete win; - EndDialog(hwnd, 0); - return 0; - case IDC_AUTO_DES : - win->mode = 0; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX)); - return 1; - case IDC_ARM : - win->mode = 1; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX)); - return 1; - case IDC_THUMB : - win->mode = 2; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX)); - return 1; - case IDC_AUTO_UPDATE : - if(win->autoup) - { - win->remove2RefreshList(); - win->autoup = FALSE; - return 1; - } - win->add2RefreshList(); - win->autoup = TRUE; - return 1; - case IDC_STEP : - { - BITMAPV4HEADER bmi; - - //CreateBitmapIndirect(&bmi); - memset(&bmi, 0, sizeof(bmi)); - bmi.bV4Size = sizeof(bmi); - bmi.bV4Planes = 1; - bmi.bV4BitCount = 16; - bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; - bmi.bV4RedMask = 0x001F; - bmi.bV4GreenMask = 0x03E0; - bmi.bV4BlueMask = 0x7C00; - bmi.bV4Width = 256; - bmi.bV4Height = -192; - int ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE); - NDS_exec(ndstep, TRUE); - if(!win->autoup) win->refresh(); - CWindow::refreshALL(); - SetDIBitsToDevice(hdc, 0, 0, 256, 192*2, 0, 0, 0, 192*2, GPU_screen, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); - } - return 1; - case IDC_GO : - { - char tmp[8]; - int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 8); - u32 adr = 0; - for(u16 i = 0; i='A')&&(tmp[i]<='F')) - { - adr = adr*16 + (tmp[i]-'A'+10); - continue; - } - if((tmp[i]>='0')&&(tmp[i]<='9')) - { - adr = adr*16 + (tmp[i]-'0'); - continue; - } - } - win->curr_ligne = adr>>2; - InvalidateRect(hwnd, NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX)); - } - return 1; - return 1; - } - return 0; - } - return 0; -} - -CDesView::CDesView(HINSTANCE hInst, HWND parent, char * titre, armcpu_t * CPU) : - CWindow(hInst, parent, titre, IDD_DESASSEMBLEUR_VIEWER, des_view_proc), cpu(CPU), mode(0) -{ - SetWindowLong(GetDlgItem(hwnd, IDC_DES_BOX), 0, (LONG)this); -} - -void CDesView::refresh() -{ - if(((cpu->instruct_adr&0x0FFFFFFF)>>(2-cpu->CPSR.bits.T))>=8) - if(((cpu->instruct_adr&0x0FFFFFFF)>>(2-cpu->CPSR.bits.T))<=0x3FFFFF7*(1+cpu->CPSR.bits.T)) - curr_ligne = ((cpu->instruct_adr&0x0FFFFFFF)>>(2-cpu->CPSR.bits.T))-8; - else - curr_ligne = 0x3FFFFEF*(1+cpu->CPSR.bits.T); - else - curr_ligne = 0; - SetScrollRange(GetDlgItem(hwnd, IDC_DES_BOX), SB_VERT, 0, 0x3FFFFF7*(1+cpu->CPSR.bits.T), TRUE); - SetScrollPos(GetDlgItem(hwnd, IDC_DES_BOX), SB_VERT, curr_ligne, TRUE); - InvalidateRect(hwnd, NULL, FALSE); -} -*/ -////////////////////////////////////////////////////////////////////////////// - -LRESULT DisViewBox_OnPaint(disview_struct *win, WPARAM wParam, LPARAM lParam) -{ - HWND hwnd = GetDlgItem(win->hwnd, IDC_DES_BOX); HDC hdc; PAINTSTRUCT ps; SIZE fontsize; @@ -443,8 +84,8 @@ LRESULT DisViewBox_OnPaint(disview_struct *win, WPARAM wParam, LPARAM lParam) u32 i; u32 adr; - if (win->autoup) - win->curr_ligne = (win->cpu->instruct_adr >> 2) - (win->curr_ligne % nbligne) ; + if (win->autoup||win->autogo) + win->curr_ligne = (win->cpu->instruct_adr >> 2) - (win->curr_ligne % nbligne) ; adr = win->curr_ligne*4; for(i = 0; i < nbligne; ++i) @@ -515,15 +156,13 @@ LRESULT DisViewBox_OnPaint(disview_struct *win, WPARAM wParam, LPARAM lParam) return 1; } -////////////////////////////////////////////////////////////////////////////// - LRESULT DisViewDialog_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; TCHAR text[80]; u32 i; - + hdc = BeginPaint(hwnd, &ps); for(i = 0; i < 16; ++i) @@ -581,165 +220,161 @@ LRESULT DisViewDialog_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPA return 1; } -////////////////////////////////////////////////////////////////////////////// - -LRESULT CALLBACK DisViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +// =================================================== ARM7 +LRESULT CALLBACK ViewDisasm_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - disview_struct *win = (disview_struct *)GetWindowLong(hwnd, 0); - - switch(msg) - { - case WM_NCCREATE: - SetScrollRange(hwnd, SB_VERT, 0, 0x3FFFFF7, TRUE); - SetScrollPos(hwnd, SB_VERT, 10, TRUE); - return 1; - - case WM_NCDESTROY: - free(win); - return 1; - - case WM_PAINT: - DisViewBox_OnPaint(win, wParam, lParam); - return 1; - - case WM_VSCROLL : - { - RECT rect; - SIZE fontsize; - HDC dc; - HFONT old; - int nbligne; + switch(msg) + { + case WM_NCCREATE: + SetScrollRange(hwnd, SB_VERT, 0, 0x3FFFFF7, TRUE); + SetScrollPos(hwnd, SB_VERT, 10, TRUE); + return 1; + + case WM_NCDESTROY: + //free(win); + return 1; - GetClientRect(hwnd, &rect); - dc = GetDC(hwnd); - old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); - GetTextExtentPoint32(dc, "0", 1, &fontsize); - - nbligne = (rect.bottom - rect.top)/fontsize.cy; + case WM_PAINT: + DisViewBox_OnPaint(hwnd, DisView7, wParam, lParam); + return 1; - switch LOWORD(wParam) - { - case SB_LINEDOWN : - win->curr_ligne = std::min(0x3FFFFF7*(1+win->cpu->CPSR.bits.T), win->curr_ligne+1); - break; - case SB_LINEUP : - win->curr_ligne = (u32)std::max(0, (s32)win->curr_ligne-1); - break; - case SB_PAGEDOWN : - win->curr_ligne = std::min(0x3FFFFF7*(1+win->cpu->CPSR.bits.T), win->curr_ligne+nbligne); - break; - case SB_PAGEUP : - win->curr_ligne = (u32)std::max(0, (s32)win->curr_ligne-nbligne); - break; - } - - SelectObject(dc, old); - SetScrollPos(hwnd, SB_VERT, win->curr_ligne, TRUE); - InvalidateRect(hwnd, NULL, FALSE); - UpdateWindow(hwnd); - } - return 1; - - case WM_ERASEBKGND: - return 1; - default: - break; - } - - return DefWindowProc(hwnd, msg, wParam, lParam); + case WM_VSCROLL : + { + RECT rect; + SIZE fontsize; + HDC dc; + HFONT old; + int nbligne; + + GetClientRect(hwnd, &rect); + dc = GetDC(hwnd); + old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); + GetTextExtentPoint32(dc, "0", 1, &fontsize); + + nbligne = (rect.bottom - rect.top)/fontsize.cy; + + switch LOWORD(wParam) + { + case SB_LINEDOWN : + DisView7->curr_ligne = std::min(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+1); + break; + case SB_LINEUP : + DisView7->curr_ligne = (u32)std::max(0, (s32)DisView7->curr_ligne-1); + break; + case SB_PAGEDOWN : + DisView7->curr_ligne = std::min(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+nbligne); + break; + case SB_PAGEUP : + DisView7->curr_ligne = (u32)std::max(0, DisView7->curr_ligne-nbligne); + break; + } + + SelectObject(dc, old); + SetScrollPos(hwnd, SB_VERT, DisView7->curr_ligne, TRUE); + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + + case WM_ERASEBKGND: + return 1; + } + return DefWindowProc(hwnd, msg, wParam, lParam); } -////////////////////////////////////////////////////////////////////////////// - -// DES VIEWER -BOOL CALLBACK DisView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK ViewDisasm_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - disview_struct *win = (disview_struct *)GetWindowLong(hwnd, DWL_USER); - - switch (message) + switch (message) { case WM_INITDIALOG : - SetDlgItemInt(hwnd, IDC_SETPNUM, 1, FALSE); - SendMessage(GetDlgItem(hwnd, IDC_AUTO_DES), BM_SETCHECK, TRUE, 0); - return 1; + { + SetWindowText(hwnd, "ARM7 Disassembler"); + SetDlgItemInt(hwnd, IDC_SETPNUM, 1, FALSE); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_DES), BM_SETCHECK, TRUE, 0); + DisView7 = new disview_struct; + memset(DisView7, 0, sizeof(disview_struct)); + DisView7->cpu = &NDS_ARM7; + DisView7->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, DisView7->autoup_secs); + return 1; + } case WM_CLOSE : - CWindow_RemoveFromRefreshList(win); - DisView_Deinit(win); - EndDialog(hwnd, 0); - return 1; + { + if(DisView7->autoup) + { + KillTimer(hwnd, IDT_VIEW_DISASM7); + DisView7->autoup = false; + } + if (DisView7!=NULL) + { + delete DisView7; + DisView7 = NULL; + } + //printlog("Close ARM7 disassembler\n"); + PostQuitMessage(0); + return 1; + } case WM_PAINT: - DisViewDialog_OnPaint(hwnd, win, wParam, lParam); - return 1; + DisViewDialog_OnPaint(hwnd, DisView7, wParam, lParam); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; case WM_COMMAND : switch (LOWORD (wParam)) { case IDC_FERMER : - CWindow_RemoveFromRefreshList(win); - DisView_Deinit(win); - EndDialog(hwnd, 0); + SendMessage(hwnd, WM_CLOSE, 0, 0); return 0; case IDC_AUTO_DES : /* address to line correction */ - if ((win->cpu->CPSR.bits.T) && (win->mode == 1)) { + if ((DisView7->cpu->CPSR.bits.T) && (DisView7->mode == 1)) { /* from arm to thumb, line * 2*/ - win->curr_ligne <<= 1 ; - } else if (!(win->cpu->CPSR.bits.T) && (win->mode == 2)) { + DisView7->curr_ligne <<= 1 ; + } else if (!(DisView7->cpu->CPSR.bits.T) && (DisView7->mode == 2)) { /* from thumb to arm, line / 2 */ - win->curr_ligne >>= 1 ; + DisView7->curr_ligne >>= 1 ; } - win->mode = 0; + DisView7->mode = 0; InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX)); return 1; case IDC_ARM : /* address to line correction */ - if ((win->mode==2) || ((win->mode==0) && (win->cpu->CPSR.bits.T))) { - win->curr_ligne >>= 1 ; + if ((DisView7->mode==2) || ((DisView7->mode==0) && (DisView7->cpu->CPSR.bits.T))) { + DisView7->curr_ligne >>= 1 ; } ; - win->mode = 1; + DisView7->mode = 1; InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX)); return 1; case IDC_THUMB : /* address to line correction */ - if ((win->mode==1) || ((win->mode==0) && !(win->cpu->CPSR.bits.T))) { - win->curr_ligne <<= 1 ; + if ((DisView7->mode==1) || ((DisView7->mode==0) && !(DisView7->cpu->CPSR.bits.T))) { + DisView7->curr_ligne <<= 1 ; } ; - win->mode = 2; + DisView7->mode = 2; InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX)); return 1; case IDC_AUTO_UPDATE : - if(win->autoup) + if(DisView7->autoup) { - CWindow_RemoveFromRefreshList(win); - win->autoup = FALSE; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_DISASM7); + DisView7->autoup = FALSE; return 1; } - CWindow_AddToRefreshList(win); - win->autoup = TRUE; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + DisView7->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_DISASM7, DisView7->autoup_secs*1000, (TIMERPROC) NULL); return 1; - case IDC_STEP : + case IDC_STEP : // TODO: draw in DD { - BITMAPV4HEADER bmi; int ndstep; - - //CreateBitmapIndirect(&bmi); - memset(&bmi, 0, sizeof(bmi)); - bmi.bV4Size = sizeof(bmi); - bmi.bV4Planes = 1; - bmi.bV4BitCount = 16; - bmi.bV4V4Compression = BI_RGB|BI_BITFIELDS; - bmi.bV4RedMask = 0x001F; - bmi.bV4GreenMask = 0x03E0; - bmi.bV4BlueMask = 0x7C00; - bmi.bV4Width = 256; - bmi.bV4Height = -192; ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE); NDS_exec(ndstep, TRUE); - if(!win->autoup) win->Refresh(win); - CWindow_RefreshALL(); - SetDIBitsToDevice(hdc, 0, 0, 256, 192*2, 0, 0, 0, 192*2, GPU_screen, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); } return 1; case IDC_GO : @@ -762,77 +397,265 @@ BOOL CALLBACK DisView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara } } /* address to line correction */ - switch (win->mode) { + switch (DisView7->mode) { case 0: /* auto */ - win->curr_ligne = adr>>1; - if (win->cpu->CPSR.bits.T) { - win->curr_ligne = adr>>1; + DisView7->curr_ligne = adr>>1; + if (DisView7->cpu->CPSR.bits.T) { + DisView7->curr_ligne = adr>>1; } break ; case 1: /* thumb */ - win->curr_ligne = adr>>2; + DisView7->curr_ligne = adr>>2; break ; case 2: /* arm */ - win->curr_ligne = adr>>1; + DisView7->curr_ligne = adr>>1; break ; } ; InvalidateRect(hwnd, NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_DES_BOX)); } return 1; + case IDC_REFRESH: + DisView7->autogo=true; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + DisView7->autogo=false; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != DisView7->autoup_secs) + { + DisView7->autoup_secs = t; + if (DisView7->autoup) + SetTimer(hwnd, IDT_VIEW_DISASM7, + DisView7->autoup_secs*1000, (TIMERPROC) NULL); + } + } + return 1; return 1; } return 0; } - return 0; + + return DefWindowProc(hwnd, message, wParam, lParam); } -////////////////////////////////////////////////////////////////////////////// - -disview_struct *DisView_Init(HINSTANCE hInst, HWND parent, char *title, armcpu_t *CPU) +// =================================================== ARM9 +LRESULT CALLBACK ViewDisasm_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - disview_struct *DisView=NULL; + switch(msg) + { + case WM_NCCREATE: + SetScrollRange(hwnd, SB_VERT, 0, 0x3FFFFF7, TRUE); + SetScrollPos(hwnd, SB_VERT, 10, TRUE); + return 1; + + case WM_NCDESTROY: + //free(win); + return 1; - if ((DisView = (disview_struct *)malloc(sizeof(disview_struct))) == NULL) - return DisView; + case WM_PAINT: + DisViewBox_OnPaint(hwnd, DisView9, wParam, lParam); + return 1; - if (CWindow_Init2(DisView, hInst, parent, title, IDD_DESASSEMBLEUR_VIEWER, DisView_Proc) != 0) - { - free(DisView); - return NULL; - } + case WM_VSCROLL : + { + RECT rect; + SIZE fontsize; + HDC dc; + HFONT old; + int nbligne; - DisView->cpu = CPU; - DisView->mode = 0; - DisView->Refresh = (void (*)(void *))&DisView_Refresh; + GetClientRect(hwnd, &rect); + dc = GetDC(hwnd); + old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); + GetTextExtentPoint32(dc, "0", 1, &fontsize); - SetWindowLong(GetDlgItem(DisView->hwnd, IDC_DES_BOX), 0, (LONG)DisView); + nbligne = (rect.bottom - rect.top)/fontsize.cy; - return DisView; + switch LOWORD(wParam) + { + case SB_LINEDOWN : + DisView9->curr_ligne = std::min(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+1); + break; + case SB_LINEUP : + DisView9->curr_ligne = (u32)std::max(0, (s32)DisView9->curr_ligne-1); + break; + case SB_PAGEDOWN : + DisView9->curr_ligne = std::min(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+nbligne); + break; + case SB_PAGEUP : + DisView9->curr_ligne = (u32)std::max(0, DisView9->curr_ligne-nbligne); + break; + } + + SelectObject(dc, old); + SetScrollPos(hwnd, SB_VERT, DisView9->curr_ligne, TRUE); + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + + case WM_ERASEBKGND: + return 1; + } + return DefWindowProc(hwnd, msg, wParam, lParam); } -////////////////////////////////////////////////////////////////////////////// - -void DisView_Deinit(disview_struct *DisView) +BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - if (DisView) - free(DisView); + switch (message) + { + case WM_INITDIALOG : + { + SetWindowText(hwnd, "ARM9 Disassembler"); + SetDlgItemInt(hwnd, IDC_SETPNUM, 1, FALSE); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_DES), BM_SETCHECK, TRUE, 0); + DisView9 = new disview_struct; + memset(DisView9, 0, sizeof(disview_struct)); + DisView9->cpu = &NDS_ARM9; + DisView9->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, DisView9->autoup_secs); + return 1; + } + case WM_CLOSE : + { + if(DisView9->autoup) + { + KillTimer(hwnd, IDT_VIEW_DISASM9); + DisView9->autoup = false; + } + if (DisView9!=NULL) + { + delete DisView9; + DisView9 = NULL; + } + printlog("Close ARM9 disassembler\n"); + PostQuitMessage(0); + return 1; + } + case WM_PAINT: + DisViewDialog_OnPaint(hwnd, DisView9, wParam, lParam); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 0; + case IDC_AUTO_DES : + /* address to line correction */ + if ((DisView9->cpu->CPSR.bits.T) && (DisView9->mode == 1)) { + /* from arm to thumb, line * 2*/ + DisView9->curr_ligne <<= 1 ; + } else if (!(DisView9->cpu->CPSR.bits.T) && (DisView9->mode == 2)) { + /* from thumb to arm, line / 2 */ + DisView9->curr_ligne >>= 1 ; + } + DisView9->mode = 0; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_ARM : + /* address to line correction */ + if ((DisView9->mode==2) || ((DisView9->mode==0) && (DisView9->cpu->CPSR.bits.T))) { + DisView9->curr_ligne >>= 1 ; + } ; + DisView9->mode = 1; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_THUMB : + /* address to line correction */ + if ((DisView9->mode==1) || ((DisView9->mode==0) && !(DisView9->cpu->CPSR.bits.T))) { + DisView9->curr_ligne <<= 1 ; + } ; + DisView9->mode = 2; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_AUTO_UPDATE : + if(DisView9->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_DISASM9); + DisView9->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + DisView9->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_DISASM9, DisView9->autoup_secs*1000, (TIMERPROC) NULL); + return 1; + case IDC_STEP : // TODO: draw in DD + { + int ndstep; + ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE); + NDS_exec(ndstep, TRUE); + } + return 1; + case IDC_GO : + { + u16 i; + char tmp[16]; + int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 16); + u32 adr = 0; + for(i = 0; i='A')&&(tmp[i]<='F')) + { + adr = adr*16 + (tmp[i]-'A'+10); + continue; + } + if((tmp[i]>='0')&&(tmp[i]<='9')) + { + adr = adr*16 + (tmp[i]-'0'); + continue; + } + } + /* address to line correction */ + switch (DisView9->mode) { + case 0: /* auto */ + DisView9->curr_ligne = adr>>1; + if (DisView9->cpu->CPSR.bits.T) { + DisView9->curr_ligne = adr>>1; + } + break ; + case 1: /* thumb */ + DisView9->curr_ligne = adr>>2; + break ; + case 2: /* arm */ + DisView9->curr_ligne = adr>>1; + break ; + } ; + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + case IDC_REFRESH: + DisView9->autogo=true; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + DisView9->autogo=false; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != DisView9->autoup_secs) + { + DisView9->autoup_secs = t; + if (DisView9->autoup) + SetTimer(hwnd, IDT_VIEW_DISASM9, + DisView9->autoup_secs*1000, (TIMERPROC) NULL); + } + } + return 1; + return 1; + } + return 0; + } + + return DefWindowProc(hwnd, message, wParam, lParam); } - -////////////////////////////////////////////////////////////////////////////// - -void DisView_Refresh(disview_struct *DisView) -{ - if(((DisView->cpu->instruct_adr&0x0FFFFFFF)>>(2-DisView->cpu->CPSR.bits.T))>=8) - if(((DisView->cpu->instruct_adr&0x0FFFFFFF)>>(2-DisView->cpu->CPSR.bits.T))<=0x3FFFFF7*(1+DisView->cpu->CPSR.bits.T)) - DisView->curr_ligne = ((DisView->cpu->instruct_adr&0x0FFFFFFF)>>(2-DisView->cpu->CPSR.bits.T))-8; - else - DisView->curr_ligne = 0x3FFFFEF*(1+DisView->cpu->CPSR.bits.T); - else - DisView->curr_ligne = 0; - SetScrollRange(GetDlgItem(DisView->hwnd, IDC_DES_BOX), SB_VERT, 0, 0x3FFFFF7*(1+DisView->cpu->CPSR.bits.T), TRUE); - SetScrollPos(GetDlgItem(DisView->hwnd, IDC_DES_BOX), SB_VERT, DisView->curr_ligne, TRUE); - InvalidateRect(DisView->hwnd, NULL, FALSE); -} - -////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/disView.h b/desmume/src/windows/disView.h index e62409571..7bae52c9a 100644 --- a/desmume/src/windows/disView.h +++ b/desmume/src/windows/disView.h @@ -22,28 +22,12 @@ #ifndef DISVIEW_H #define DISVIEW_H -#include "../NDSSystem.h" -#include "../armcpu.h" +#include -#include "CWindow.h" +extern BOOL CALLBACK ViewDisasm_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +extern LRESULT CALLBACK ViewDisasm_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -typedef struct -{ - HWND hwnd; - BOOL autoup; - void *prev; - void *next; - void *first; - void (*Refresh)(void *win); - - u32 curr_ligne; - armcpu_t *cpu; - u16 mode; -} disview_struct; - -void InitDesViewBox(); -disview_struct *DisView_Init(HINSTANCE hInst, HWND parent, char *title, armcpu_t *CPU); -void DisView_Deinit(disview_struct *DisView); -void DisView_Refresh(disview_struct *DisView); +extern BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +extern LRESULT CALLBACK ViewDisasm_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); #endif diff --git a/desmume/src/windows/lightView.cpp b/desmume/src/windows/lightView.cpp index f65810f95..3d962c7c7 100644 --- a/desmume/src/windows/lightView.cpp +++ b/desmume/src/windows/lightView.cpp @@ -17,39 +17,23 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include #include "lightView.h" -#include "resource.h" -#include "matrix.h" -#include "gfx3d.h" -#include "armcpu.h" +#include "commctrl.h" #include "colorctrl.h" #include "colorconv.h" +#include "gfx3d.h" +#include "resource.h" +#include "debug.h" - -////////////////////////////////////////////////////////////////////////////// - -BOOL LightView_OnInitDialog(HWND hwnd) +typedef struct { - return TRUE; -} + u32 autoup_secs; + bool autoup; +} lightsview_struct; -////////////////////////////////////////////////////////////////////////////// +lightsview_struct *LightsView = NULL; -BOOL LightView_OnClose(lightview_struct* win) -{ - win->window.autoup = FALSE; - CWindow_RemoveFromRefreshList(win); - EndDialog(win->window.hwnd, 0); - LightView_Deinit(win); - - return TRUE; -} - -////////////////////////////////////////////////////////////////////////////// - -void LightView_OnPaintLight(lightview_struct* win, int index) +void LightView_OnPaintLight(HWND hwnd, int index) { const int idcDir[4] = { @@ -80,102 +64,110 @@ void LightView_OnPaintLight(lightview_struct* win, int index) // Print Light Direction sprintf(buffer, "%.8x", direction); - SetWindowText(GetDlgItem(win->window.hwnd, idcDir[index]), buffer); + SetWindowText(GetDlgItem(hwnd, idcDir[index]), buffer); // Print Light Color sprintf(buffer, "%.4x", color); - SetWindowText(GetDlgItem(win->window.hwnd, idcColorEdit[index]), buffer); + SetWindowText(GetDlgItem(hwnd, idcColorEdit[index]), buffer); // Set Light Color in ColorDisplay component - ColorCtrl_SetColor(GetDlgItem(win->window.hwnd, idcColorCtrl[index]), ColorConv_B5R5R5ToR8G8B8(color)); + ColorCtrl_SetColor(GetDlgItem(hwnd, idcColorCtrl[index]), ColorConv_B5R5R5ToR8G8B8(color)); } ////////////////////////////////////////////////////////////////////////////// -BOOL LightView_OnPaint(lightview_struct* win, HWND hwnd, WPARAM wParam, LPARAM lParam) +BOOL LightView_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; hdc = BeginPaint(hwnd, &ps); - LightView_OnPaintLight(win, 0); - LightView_OnPaintLight(win, 1); - LightView_OnPaintLight(win, 2); - LightView_OnPaintLight(win, 3); + LightView_OnPaintLight(hwnd, 0); + LightView_OnPaintLight(hwnd, 1); + LightView_OnPaintLight(hwnd, 2); + LightView_OnPaintLight(hwnd, 3); EndPaint(hwnd, &ps); return TRUE; } -////////////////////////////////////////////////////////////////////////////// - -BOOL CALLBACK LightView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK ViewLightsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - lightview_struct *win = (lightview_struct *)GetWindowLong(hwnd, DWL_USER); + switch (message) + { + case WM_INITDIALOG: + LightsView = new lightsview_struct; + memset(LightsView, 0, sizeof(lightsview_struct)); + LightsView->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, LightsView->autoup_secs); + break; - switch (message) - { - case WM_INITDIALOG: - LightView_OnInitDialog(hwnd); - break; + case WM_CLOSE: + if(LightsView->autoup) + { + KillTimer(hwnd, IDT_VIEW_LIGHTS); + LightsView->autoup = false; + } + + if (LightsView!=NULL) + { + delete LightsView; + LightsView = NULL; + } + //printlog("Close lights viewer dialog\n"); + PostQuitMessage(0); + break; - case WM_CLOSE: - LightView_OnClose(win); - break; + case WM_PAINT: + LightView_OnPaint(hwnd, wParam, lParam); + break; - case WM_PAINT: - LightView_OnPaint(win, hwnd, wParam, lParam); - break; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; - case WM_COMMAND: - switch (LOWORD (wParam)) - { - case IDOK: - CWindow_RemoveFromRefreshList(win); - LightView_Deinit(win); - EndDialog(hwnd, 0); - return 1; - } - return 0; - - case WM_SYSCOMMAND: - switch (LOWORD (wParam)) - { - case IDC_AUTO_UPDATE: - CWindow_ToggleAutoUpdate(win); - return 1; - } - return 0; - } - return 0; + case WM_COMMAND: + switch (LOWORD (wParam)) + { + case IDOK: + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + case IDC_AUTO_UPDATE : + if(LightsView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_LIGHTS); + LightsView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + LightsView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_LIGHTS, LightsView->autoup_secs*1000, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != LightsView->autoup_secs) + { + LightsView->autoup_secs = t; + if (LightsView->autoup) + SetTimer(hwnd, IDT_VIEW_LIGHTS, + LightsView->autoup_secs*1000, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + return 0; + } + return DefWindowProc(hwnd, message, wParam, lParam); } - -////////////////////////////////////////////////////////////////////////////// - -lightview_struct *LightView_Init(HINSTANCE hInst, HWND parent) -{ - lightview_struct *LightView=NULL; - - if ((LightView = (lightview_struct *)malloc(sizeof(lightview_struct))) == NULL) - return NULL; - - if (CWindow_Init2(LightView, hInst, parent, "Light Viewer", IDD_LIGHT_VIEWER, LightView_Proc) != 0) - { - free(LightView); - return NULL; - } - - return LightView; -} - -////////////////////////////////////////////////////////////////////////////// - -void LightView_Deinit(lightview_struct *LightView) -{ - if (LightView) - free(LightView); -} - -////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/lightView.h b/desmume/src/windows/lightView.h index 172b835bf..f5578bbd1 100644 --- a/desmume/src/windows/lightView.h +++ b/desmume/src/windows/lightView.h @@ -20,15 +20,8 @@ #ifndef LIGHTVIEW_H #define LIGHTVIEW_H -#include "CWindow.h" +#include -typedef struct -{ - cwindow_struct window; -} lightview_struct; - -lightview_struct *LightView_Init(HINSTANCE hInst, HWND parent); -void LightView_Deinit(lightview_struct *view); - -#endif +extern BOOL CALLBACK ViewLightsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +#endif \ No newline at end of file diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 56424cb26..ecbda4fa9 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -1,2194 +1,2238 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - Copyright 2006 Theo Berkau - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#define WIN32_LEAN_AND_MEAN -#include -#include -#include -#include -#include -#include -#include -#include "CWindow.h" -#include "../MMU.h" -#include "../armcpu.h" -#include "../NDSSystem.h" -#include "../debug.h" -#include "../saves.h" -#include "../cflash.h" -#include "resource.h" -#include "memView.h" -#include "disView.h" -#include "ginfo.h" -#include "IORegView.h" -#include "palView.h" -#include "tileView.h" -#include "oamView.h" -#include "mapview.h" -#include "matrixview.h" -#include "lightview.h" -#include "ConfigKeys.h" -#include "FirmConfig.h" -#include "AboutBox.h" -#include "OGLRender.h" -#include "../gfx3d.h" -#include "../render3D.h" -#include "../gdbstub.h" -#include "colorctrl.h" -#include "console.h" -#include "throttle.h" - -#include "snddx.h" - -#include "directx/ddraw.h" - -#define GPU3D_NULL 0 -#define GPU3D_OPENGL 1 - -//===================== Init DirectDraw -LPDIRECTDRAW7 lpDDraw=NULL; -LPDIRECTDRAWSURFACE7 lpPrimarySurface=NULL; -LPDIRECTDRAWSURFACE7 lpBackSurface=NULL; -DDSURFACEDESC2 ddsd; -LPDIRECTDRAWCLIPPER lpDDClipPrimary=NULL; -LPDIRECTDRAWCLIPPER lpDDClipBack=NULL; - -/* The compact flash disk image file */ -static const char *bad_glob_cflash_disk_image_file; -static char cflash_filename_buffer[512]; - -/* Declare Windows procedure */ -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"; -int romnum = 0; - -DWORD threadID; - -HWND hwnd; -HDC hdc; -HINSTANCE hAppInst; -RECT MainWindowRect; - -volatile BOOL execute = FALSE; -volatile BOOL paused = TRUE; -u32 glock = 0; - -BOOL click = FALSE; - -BOOL finished = FALSE; -BOOL romloaded = FALSE; - -void SetRotate(int rot); - -BOOL ForceRatio = TRUE; -float DefaultWidth; -float DefaultHeight; -float widthTradeOff; -float heightTradeOff; - -HMENU menu; -HANDLE runthread_ready=INVALID_HANDLE_VALUE; -HANDLE runthread=INVALID_HANDLE_VALUE; - -const DWORD DI_tabkey[48] = {DIK_0,DIK_1,DIK_2,DIK_3,DIK_4,DIK_5,DIK_6,DIK_7,DIK_8,DIK_9,DIK_A,DIK_B,DIK_C, - DIK_D,DIK_E,DIK_F,DIK_G,DIK_H,DIK_I,DIK_J,DIK_K,DIK_L,DIK_M,DIK_N,DIK_O,DIK_P, - DIK_Q,DIK_R,DIK_S,DIK_T,DIK_U,DIK_V,DIK_W,DIK_X,DIK_Y,DIK_Z,DIK_SPACE,DIK_UP, - DIK_DOWN,DIK_LEFT,DIK_RIGHT,DIK_TAB,DIK_LSHIFT,DIK_DELETE,DIK_INSERT,DIK_HOME, - DIK_END,DIK_RETURN}; -DWORD ds_up,ds_down,ds_left,ds_right,ds_a,ds_b,ds_x,ds_y,ds_l,ds_r,ds_select,ds_start,ds_debug; -static char IniName[MAX_PATH]; -int sndcoretype=SNDCORE_DIRECTX; -int sndbuffersize=735*4; -int sndvolume=100; - -SoundInterface_struct *SNDCoreList[] = { -&SNDDummy, -&SNDFile, -&SNDDIRECTX, -NULL -}; - -GPU3DInterface *core3DList[] = { -&gpu3DNull, -&gpu3Dgl, -}; - -int autoframeskipenab=1; -int frameskiprate=0; -int emu_paused = 0; -static int backupmemorytype=MC_TYPE_AUTODETECT; -static u32 backupmemorysize=1; -unsigned int frameCounter=0; -bool frameAdvance = false; -bool frameCounterDisplay = false; -unsigned short windowSize = 0; - -/* the firmware settings */ -struct NDS_fw_config_data win_fw_config; - - -LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, - LPARAM lParam); - -struct configured_features { - u16 arm9_gdb_port; - u16 arm7_gdb_port; - - const char *cflash_disk_image_file; -}; - -static void -init_configured_features( struct configured_features *config) { - config->arm9_gdb_port = 0; - config->arm7_gdb_port = 0; - - config->cflash_disk_image_file = NULL; -} - - -static int -fill_configured_features( struct configured_features *config, LPSTR lpszArgument) { - int good_args = 0; - LPTSTR cmd_line; - LPWSTR *argv; - int argc; - - argv = CommandLineToArgvW( GetCommandLineW(), &argc); - - if ( argv != NULL) { - int i; - good_args = 1; - for ( i = 1; i < argc && good_args; i++) { - if ( wcsncmp( argv[i], L"--arm9gdb=", 10) == 0) { - wchar_t *end_char; - unsigned long port_num = wcstoul( &argv[i][10], &end_char, 10); - - if ( port_num > 0 && port_num < 65536) { - config->arm9_gdb_port = port_num; - } - else { - MessageBox(NULL,"ARM9 GDB stub port must be in the range 1 to 65535","Error",MB_OK); - good_args = 0; - } - } - else if ( wcsncmp( argv[i], L"--arm7gdb=", 10) == 0) { - wchar_t *end_char; - unsigned long port_num = wcstoul( &argv[i][10], &end_char, 10); - - if ( port_num > 0 && port_num < 65536) { - config->arm7_gdb_port = port_num; - } - else { - MessageBox(NULL,"ARM9 GDB stub port must be in the range 1 to 65535","Error",MB_OK); - good_args = 0; - } - } - else if ( wcsncmp( argv[i], L"--cflash=", 9) == 0) { - if ( config->cflash_disk_image_file == NULL) { - size_t convert_count = wcstombs( &cflash_filename_buffer[0], &argv[i][9], 512); - if ( convert_count > 0) { - config->cflash_disk_image_file = cflash_filename_buffer; - } - } - else { - MessageBox(NULL,"CFlash disk image file already set","Error",MB_OK); - good_args = 0; - } - } - } - LocalFree( argv); - } - - return good_args; -} - -// Rotation definitions -short GPU_rotation = 0; -DWORD GPU_width = 256; -DWORD GPU_height = 192*2; -DWORD rotationstartscan = 192; -DWORD rotationscanlines = 192*2; - -void SetWindowClientSize(HWND hwnd, int cx, int cy) //found at: http://blogs.msdn.com/oldnewthing/archive/2003/09/11/54885.aspx -{ - HMENU hmenu = GetMenu(hwnd); - RECT rcWindow = { 0, 0, cx, cy }; - - /* - * First convert the client rectangle to a window rectangle the - * menu-wrap-agnostic way. - */ - AdjustWindowRect(&rcWindow, WS_CAPTION| WS_SYSMENU |WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, hmenu != NULL); - - /* - * If there is a menu, then check how much wrapping occurs - * when we set a window to the width specified by AdjustWindowRect - * and an infinite amount of height. An infinite height allows - * us to see every single menu wrap. - */ - if (hmenu) { - RECT rcTemp = rcWindow; - rcTemp.bottom = 0x7FFF; /* "Infinite" height */ - SendMessage(hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rcTemp); - - /* - * Adjust our previous calculation to compensate for menu - * wrapping. - */ - rcWindow.bottom += rcTemp.top; - } - SetWindowPos(hwnd, NULL, 0, 0, rcWindow.right - rcWindow.left, - rcWindow.bottom - rcWindow.top, SWP_NOMOVE | SWP_NOZORDER); - - if (lpBackSurface!=NULL) - { - IDirectDrawSurface7_Release(lpBackSurface); - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - ddsd.dwWidth = cx; - ddsd.dwHeight = cy; - - IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpBackSurface, NULL); - } -} - -void ResizingLimit(int wParam, RECT *rc) -{ - u32 width = (rc->right - rc->left); - u32 height = (rc->bottom - rc->top); - - u32 minX = 256; - u32 minY = 414; - - //printlog("width=%i; height=%i\n", width, height); - - if (GPU_rotation == 90 || GPU_rotation == 270) - { - minX = 390; - minY = 272; - } - switch (wParam) - { - case WMSZ_LEFT: - { - if (widthleft=rc->left+(width-minX); - return; - } - - case WMSZ_RIGHT: - { - if (widthright=rc->left+minX; - return; - } - - case WMSZ_TOP: - { - if (heighttop=rc->top+(height-minY); - return; - } - - case WMSZ_BOTTOM: - { - if (heightbottom=rc->top+minY; - return; - } - - case WMSZ_TOPLEFT: - { - if (heighttop=rc->top+(height-minY); - if (widthleft=rc->left+(width-minX); - return; - } - case WMSZ_BOTTOMLEFT: - { - if (heightbottom=rc->top+minY; - if (widthleft=rc->left+(width-minX); - return; - } - - case WMSZ_TOPRIGHT: - { - if (heighttop=rc->top+(height-minY); - if (widthright=rc->left+minX; - return; - } - - case WMSZ_BOTTOMRIGHT: - { - if (heightbottom=rc->top+minY; - if (widthright=rc->left+minX; - return; - } - } - -} - -void ScallingScreen(HWND hwnd, int wParam, RECT *rc) -{ - float aspect; - u32 width; - u32 height; - u32 width2; - u32 height2; - - width = (rc->right - rc->left - widthTradeOff); - height = (rc->bottom - rc->top - heightTradeOff); - - if (width == height) return; - - if (GPU_rotation == 0 || GPU_rotation == 180) - { - aspect = DefaultWidth / DefaultHeight; - } - else - { - aspect = DefaultHeight / DefaultWidth; - } - - switch (wParam) - { - case WMSZ_LEFT: - case WMSZ_RIGHT: - { - height = (int)(width / aspect); - rc->bottom=rc->top+height+heightTradeOff; - return; - } - - case WMSZ_TOP: - case WMSZ_BOTTOM: - { - width = (int)(height * aspect); - rc->right=rc->left+width+widthTradeOff; - return; - } - - case WMSZ_TOPLEFT: - { - width = (int)(height * aspect); - rc->left=rc->right-width-widthTradeOff; - return; - } - case WMSZ_BOTTOMLEFT: - { - height = (int)(width / aspect); - rc->bottom=rc->top + height + heightTradeOff; - return; - } - - case WMSZ_TOPRIGHT: - case WMSZ_BOTTOMRIGHT: - { - width = (int)(height * aspect); - rc->right=rc->left+width+widthTradeOff; - return; - } - } -} - -void ScaleScreen(HWND hwnd, float factor) -{ - if ((GPU_rotation==0)||(GPU_rotation==180)) - { - SetWindowPos(hwnd, NULL, 0, 0, widthTradeOff + DefaultWidth * factor, - heightTradeOff + DefaultHeight * factor, SWP_NOMOVE | SWP_NOZORDER); - } - else - if ((GPU_rotation==90)||(GPU_rotation==270)) - { - SetWindowPos(hwnd, NULL, 0, 0, heightTradeOff + DefaultHeight * factor, - widthTradeOff + DefaultWidth * factor, SWP_NOMOVE | SWP_NOZORDER); - } -} - -void translateXY(s32 *x, s32*y) -{ - s32 tmp; - switch(GPU_rotation) - { - case 90: - tmp = *x; - *x = *y; - *y = 192*2 -tmp; - break; - case 180: - *x = 256-*x; - *y = 192*2-*y; - break; - case 270: - tmp = *x; - *x = 255-*y; - *y = tmp; - break; - } - *y-=192; -} - - // END Rotation definitions - -void Input_Post() -{ - char txt[255]; - BOOL bPressed; - HRESULT hr; - WORD keys[13][3]={{ds_a,0xFFFE,0x01},{ds_b,0xFFFD,0x02},{ds_select,0xFFFB,0x04},{ds_start,0xFFF7,0x08}, - {ds_right,0xFFEF,0x10},{ds_left,0xFFDF,0x20},{ds_up,0xFFBF,0x40},{ds_down,0xFF7F,0x80}, - {ds_r,0xFEFF,0x100},{ds_l,0xFDFF,0x200}, - {ds_x,0xFFFE,0x01},{ds_y,0xFFFD,0x02},{ds_debug,0xFFFB,0x04}}; - int i; - - for (i=0; i<10; i++) - { - bPressed=FALSE; - if (keys[i][0]<48) - if (g_cDIBuf[DI_tabkey[keys[i][0]]]&0x80) bPressed=TRUE; - if (keys[i][0]>=48) - if (g_cDIBuf[208+keys[i][0]]&0x80) bPressed=TRUE; - if (bPressed) - { - ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1]&=keys[i][1]; - ((u16 *)MMU.ARM7_REG)[0x130>>1]&=keys[i][1]; - } - else - { - ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1]|=keys[i][2]; - ((u16 *)MMU.ARM7_REG)[0x130>>1]|=keys[i][2]; - } - } - for (i=10; i<13; i++) - { - bPressed=FALSE; - if (keys[i][0]<48) - if (g_cDIBuf[DI_tabkey[keys[i][0]]]&0x80) bPressed=TRUE; - if (keys[i][0]>=48) - if (g_cDIBuf[208+keys[i][0]]&0x80) bPressed=TRUE; - if (bPressed) - ((u16 *)MMU.ARM7_REG)[0x136>>1]&=keys[i][1]; - else - ((u16 *)MMU.ARM7_REG)[0x136>>1]|=keys[i][2]; - } -} - -int CreateDDrawBuffers() -{ - if (lpDDClipPrimary!=NULL) IDirectDraw7_Release(lpDDClipPrimary); - if (lpPrimarySurface != NULL) IDirectDraw7_Release(lpPrimarySurface); - if (lpBackSurface != NULL) IDirectDraw7_Release(lpBackSurface); - - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - ddsd.dwFlags = DDSD_CAPS; - if (IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpPrimarySurface, NULL) != DD_OK) return -1; - - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; - - if ( (GPU_rotation == 0) || (GPU_rotation == 180) ) - { - ddsd.dwWidth = 256; - ddsd.dwHeight = 384; - } - else - if ( (GPU_rotation == 90) || (GPU_rotation == 270) ) - { - ddsd.dwWidth = 384; - ddsd.dwHeight = 256; - } - - if (IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpBackSurface, NULL) != DD_OK) return -2; - - if (IDirectDraw7_CreateClipper(lpDDraw, 0, &lpDDClipPrimary, NULL) != DD_OK) return -3; - - if (IDirectDrawClipper_SetHWnd(lpDDClipPrimary, 0, hwnd) != DD_OK) return -4; - if (IDirectDrawSurface7_SetClipper(lpPrimarySurface, lpDDClipPrimary) != DD_OK) return -5; - - return 1; -} - - -void Display() -{ - int res; - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags=DDSD_ALL; - res=IDirectDrawSurface7_Lock(lpBackSurface,NULL,&ddsd,DDLOCK_WAIT, NULL); - - if (res == DD_OK) - { - char* buffer = (char*)ddsd.lpSurface; - - int i, j, sz=256*sizeof(u32); - if (ddsd.ddpfPixelFormat.dwRGBBitCount>16) - { - u16 *tmpGPU_Screen_src=(u16*)GPU_screen; - u32 tmpGPU_screen[98304]; - for(i=0; i<98304; i++) - tmpGPU_screen[i]= (((tmpGPU_Screen_src[i]>>10)&0x1F)<<3)| - (((tmpGPU_Screen_src[i]>>5)&0x1F)<<11)| - (((tmpGPU_Screen_src[i])&0x1F)<<19); - switch (GPU_rotation) - { - case 0: - { - for (i = 0; i < 98304; i+=256) //384*256 - { - memcpy(buffer,tmpGPU_screen+i,sz); - buffer += ddsd.lPitch; - } - break; - } - case 90: - { - u32 start; - memset(buffer,0,384*ddsd.lPitch); - for (j=0; j<256; j++) - { - start=98304+j; - for (i=0; i<384; i++) - { - start-=256; - ((u32*)buffer)[i]=((u32 *)tmpGPU_screen)[start]; - } - buffer += ddsd.lPitch; - } - break; - } - case 180: - { - u32 start=98300; - for (j=0; j<384; j++) - { - for (i=0; i<256; i++, --start) - ((u32*)buffer)[i]=((u32 *)tmpGPU_screen)[start]; - buffer += ddsd.lPitch; - } - break; - } - case 270: - { - u32 start; - memset(buffer,0,384*ddsd.lPitch); - for (j=0; j<256; j++) - { - start=256-j; - for (i=0; i<384; i++) - { - ((u32*)buffer)[i]=((u32 *)tmpGPU_screen)[start]; - start+=256; - } - buffer += ddsd.lPitch; - } - break; - } - } - } - else - printlog("16bit depth color not supported"); - IDirectDrawSurface7_Unlock(lpBackSurface,(LPRECT)ddsd.lpSurface); - - if (IDirectDrawSurface7_Blt(lpPrimarySurface,&MainWindowRect,lpBackSurface,0, DDBLT_WAIT,0)==DDERR_SURFACELOST) - { - printlog("DirectDraw buffers is lost\n"); - if (IDirectDrawSurface7_Restore(lpPrimarySurface)==DD_OK) - IDirectDrawSurface7_Restore(lpBackSurface); - } - } - else - { - if (res==DDERR_SURFACELOST) - { - printlog("DirectDraw buffers is lost\n"); - if (IDirectDrawSurface7_Restore(lpPrimarySurface)==DD_OK) - IDirectDrawSurface7_Restore(lpBackSurface); - } - } -} - - -DWORD WINAPI run( LPVOID lpParameter) -{ - char txt[80]; - u32 cycles = 0; - int wait=0; - u64 freq; - u64 OneFrameTime; - int framestoskip=0; - int framesskipped=0; - int skipnextframe=0; - u64 lastticks=0; - u64 curticks=0; - u64 diffticks=0; - u32 framecount=0; - u64 onesecondticks=0; - int fps=0; - int fpsframecount=0; - u64 fpsticks=0; - int res; - - DDCAPS hw_caps, sw_caps; - - InitSpeedThrottle(); - - if (DirectDrawCreateEx(NULL, (LPVOID*)&lpDDraw, IID_IDirectDraw7, NULL) != DD_OK) - { - MessageBox(hwnd,"Unable to initialize DirectDraw","Error",MB_OK); - return -1; - } - - if (IDirectDraw7_SetCooperativeLevel(lpDDraw,hwnd, DDSCL_NORMAL) != DD_OK) - { - MessageBox(hwnd,"Unable to set DirectDraw Cooperative Level","Error",MB_OK); - return -1; - } - - if (CreateDDrawBuffers()<1) - { - MessageBox(hwnd,"Unable to set DirectDraw buffers","Error",MB_OK); - return -1; - } - - NDS_3D_SetDriver (GPU3D_OPENGL); - - if (!gpu3D->NDS_3D_Init ()) - { - MessageBox(hwnd,"Unable to initialize openGL","Error",MB_OK); - return -1; - } - - QueryPerformanceFrequency((LARGE_INTEGER *)&freq); - QueryPerformanceCounter((LARGE_INTEGER *)&lastticks); - OneFrameTime = freq / 60; - - SetEvent(runthread_ready); - - while(!finished) - { - while(execute) - { - cycles = NDS_exec((560190<<1)-cycles,FALSE); - SPU_Emulate(); - Input_Process(); - Input_Post(); - - if (!skipnextframe) - { - Display(); - - fpsframecount++; - QueryPerformanceCounter((LARGE_INTEGER *)&curticks); - bool oneSecond = curticks >= fpsticks + freq; - if(oneSecond) // TODO: print fps on screen in DDraw - { - fps = fpsframecount; - fpsframecount = 0; - QueryPerformanceCounter((LARGE_INTEGER *)&fpsticks); - } - - if(nds.idleFrameCounter==0 || oneSecond) - { - //calculate a 16 frame arm9 load average - int load = 0; - for(int i=0;i<16;i++) - load = load/8 + nds.runCycleCollector[(i+nds.idleFrameCounter)&15]*7/8; - load = std::min(100,std::max(0,(int)(load*100/1120380))); - sprintf(txt,"(%02d%%) %s", load, DESMUME_NAME_AND_VERSION); - SetWindowText(hwnd, txt); - osd->addFixed(10, 10, "%02d Fps", fps); - } - - framesskipped = 0; - - if (framestoskip > 0) - skipnextframe = 1; - } - else - { - framestoskip--; - - if (framestoskip < 1) - skipnextframe = 0; - else - skipnextframe = 1; - - framesskipped++; - } - - while(SpeedThrottle()) - { - } - - if (autoframeskipenab) - { - framecount++; - - if (framecount > 60) - { - framecount = 1; - onesecondticks = 0; - } - - QueryPerformanceCounter((LARGE_INTEGER *)&curticks); - diffticks = curticks-lastticks; - - if(ThrottleIsBehind() && framesskipped < 9) - { - skipnextframe = 1; - framestoskip = 1; - } - - onesecondticks += diffticks; - lastticks = curticks; - } - else - { - if (framestoskip < 1) - framestoskip += frameskiprate; - } - if (frameAdvance) - { - frameAdvance = false; - execute = FALSE; - SPU_Pause(1); - } - frameCounter++; - if (frameCounterDisplay) osd->addFixed(200, 30, "%d",frameCounter); - } - paused = TRUE; - Sleep(500); - } - if (lpDDClipPrimary!=NULL) IDirectDraw7_Release(lpDDClipPrimary); - if (lpPrimarySurface != NULL) IDirectDraw7_Release(lpPrimarySurface); - if (lpBackSurface != NULL) IDirectDraw7_Release(lpBackSurface); - if (lpDDraw != NULL) IDirectDraw7_Release(lpDDraw); - return 1; -} - -void NDS_Pause() -{ - execute = FALSE; - SPU_Pause(1); - while (!paused) {} - printlog("Paused\n"); -} - -void NDS_UnPause() -{ - paused = FALSE; - execute = TRUE; - SPU_Pause(0); - printlog("Unpaused\n"); -} - -void StateSaveSlot(int num) -{ - NDS_Pause(); - savestate_slot(num); - NDS_UnPause(); -} - -void StateLoadSlot(int num) -{ - BOOL wasPaused = paused; - NDS_Pause(); - loadstate_slot(num); - if(!wasPaused) - NDS_UnPause(); - else - Display(); -} - -BOOL LoadROM(char * filename, const char *cflash_disk_image) -{ - NDS_Pause(); - if (strcmp(filename,"")!=0) printlog("Loading ROM: %s\n",filename); - - if (NDS_LoadROM(filename, backupmemorytype, backupmemorysize, cflash_disk_image) > 0) - return TRUE; - - return FALSE; -} - -/* - * The thread handling functions needed by the GDB stub code. - */ -void * -createThread_gdb( void (APIENTRY *thread_function)( void *data), - void *thread_data) { - void *new_thread = CreateThread( NULL, 0, - (LPTHREAD_START_ROUTINE)thread_function, thread_data, - 0, NULL); - - return new_thread; -} - -void -joinThread_gdb( void *thread_handle) { -} - - -void SetLanguage(int langid) -{ - switch(langid) - { - case 1: - // French - SetThreadLocale(MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH), - SORT_DEFAULT)); - break; - case 2: - // Danish - SetThreadLocale(MAKELCID(MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), - SORT_DEFAULT)); - break; - case 0: - // English - SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), - SORT_DEFAULT)); - break; - default: break; - break; - } -} - -void SaveLanguage(int langid) -{ - char text[80]; - - sprintf(text, "%d", langid); - WritePrivateProfileString("General", "Language", text, IniName); -} - -void CheckLanguage(UINT id) -{ - int i; - for (i = IDC_LANGENGLISH; i < IDC_LANGFRENCH+1; i++) - CheckMenuItem(menu, i, MF_BYCOMMAND | MF_UNCHECKED); - - CheckMenuItem(menu, id, MF_BYCOMMAND | MF_CHECKED); -} - -void ChangeLanguage(int id) -{ - HMENU newmenu; - - SetLanguage(id); - newmenu = LoadMenu(hAppInst, "MENU_PRINCIPAL"); - SetMenu(hwnd, newmenu); - DestroyMenu(menu); - menu = newmenu; -} - -void InitCustomControls() -{ - ColorCtrl_Register(); -} - -int WINAPI WinMain (HINSTANCE hThisInstance, - HINSTANCE hPrevInstance, - LPSTR lpszArgument, - int nFunsterStil) - -{ -#ifdef GDB_STUB - gdbstub_handle_t arm9_gdb_stub; - gdbstub_handle_t arm7_gdb_stub; - struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; - struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; - struct armcpu_ctrl_iface *arm9_ctrl_iface; - struct armcpu_ctrl_iface *arm7_ctrl_iface; -#endif - struct configured_features my_config; - - extern bool windows_opengl_init(); - oglrender_init = windows_opengl_init; - - - MSG messages; /* Here messages to the application are saved */ - char text[80]; - cwindow_struct MainWindow; - HACCEL hAccel; - hAppInst=hThisInstance; - - InitCustomControls(); - - OpenConsole(); // Init debug console - - /* default the firmware settings, they may get changed later */ - NDS_FillDefaultFirmwareConfigData( &win_fw_config); - - InitializeCriticalSection(§ion); - - GetINIPath(IniName, MAX_PATH); - GetPrivateProfileString("General", "Language", "-1", text, 80, IniName); - SetLanguage(atoi(text)); - - windowSize = GetPrivateProfileInt("Video","Window Size", 0, IniName); - GPU_rotation = GetPrivateProfileInt("Video","Window Rotate", 0, IniName); - ForceRatio = GetPrivateProfileInt("Video","Window Force Ratio", 1, IniName); - - sprintf(text, "%s", DESMUME_NAME_AND_VERSION); - - init_configured_features( &my_config); - if ( !fill_configured_features( &my_config, lpszArgument)) { - MessageBox(NULL,"Unable to parse command line arguments","Error",MB_OK); - return 0; - } - bad_glob_cflash_disk_image_file = my_config.cflash_disk_image_file; - - hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL)); - -#ifdef DEBUG - LogStart(); -#endif - - if (CWindow_Init(&MainWindow, hThisInstance, szClassName, text, - WS_CAPTION| WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, - 256, 384, WindowProcedure) != 0) - { - MessageBox(NULL,"Unable to create main window","Error",MB_OK); - return 0; - } - - hwnd = MainWindow.hwnd; - menu = LoadMenu(hThisInstance, "MENU_PRINCIPAL"); - SetMenu(hwnd, menu); - - // menu checks - CheckMenuItem(menu, IDC_FORCERATIO, MF_BYCOMMAND | (ForceRatio==1?MF_CHECKED:MF_UNCHECKED)); - - CheckMenuItem(menu, IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW3X, MF_BYCOMMAND | ((windowSize==3)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW4X, MF_BYCOMMAND | ((windowSize==4)?MF_CHECKED:MF_UNCHECKED)); - - CheckMenuItem(menu, IDC_ROTATE0, MF_BYCOMMAND | ((GPU_rotation==0)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_ROTATE90, MF_BYCOMMAND | ((GPU_rotation==90)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_ROTATE180, MF_BYCOMMAND | ((GPU_rotation==180)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_ROTATE270, MF_BYCOMMAND | ((GPU_rotation==270)?MF_CHECKED:MF_UNCHECKED)); - - Input_Init(hwnd); - - hdc = GetDC(hwnd); - DragAcceptFiles(hwnd, TRUE); - - /* Make the window visible on the screen */ - CWindow_Show(&MainWindow); - - InitMemViewBox(); - InitDesViewBox(); - InitTileViewBox(); - InitOAMViewBox(); - printlog("Init NDS\n"); -#ifdef GDB_STUB - if ( my_config.arm9_gdb_port != 0) { - arm9_gdb_stub = createStub_gdb( my_config.arm9_gdb_port, - &arm9_memio, &arm9_direct_memory_iface); - - if ( arm9_gdb_stub == NULL) { - MessageBox(hwnd,"Failed to create ARM9 gdbstub","Error",MB_OK); - return -1; - } - } - if ( my_config.arm7_gdb_port != 0) { - arm7_gdb_stub = createStub_gdb( my_config.arm7_gdb_port, - &arm7_memio, - &arm7_base_memory_iface); - - if ( arm7_gdb_stub == NULL) { - MessageBox(hwnd,"Failed to create ARM7 gdbstub","Error",MB_OK); - return -1; - } - } - - NDS_Init( arm9_memio, &arm9_ctrl_iface, - arm7_memio, &arm7_ctrl_iface); -#else - NDS_Init (); -#endif - - /* - * Activate the GDB stubs - * This has to come after the NDS_Init where the cpus are set up. - */ -#ifdef GDB_STUB - if ( my_config.arm9_gdb_port != 0) { - activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); - } - if ( my_config.arm7_gdb_port != 0) { - activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); - } -#endif - GetPrivateProfileString("General", "Language", "0", text, 80, IniName); - CheckLanguage(IDC_LANGENGLISH+atoi(text)); - - GetPrivateProfileString("Video", "FrameSkip", "AUTO", text, 80, IniName); - - if (strcmp(text, "AUTO") == 0) - { - autoframeskipenab=1; - frameskiprate=0; - CheckMenuItem(menu, IDC_FRAMESKIPAUTO, MF_BYCOMMAND | MF_CHECKED); - } - else - { - autoframeskipenab=0; - frameskiprate=atoi(text); - CheckMenuItem(menu, frameskiprate + IDC_FRAMESKIP0, MF_BYCOMMAND | MF_CHECKED); - } - -#ifdef BETA_VERSION - EnableMenuItem (menu, IDM_SUBMITBUGREPORT, MF_GRAYED); -#endif - printlog("Init sound core\n"); - sndcoretype = GetPrivateProfileInt("Sound","SoundCore", SNDCORE_DIRECTX, IniName); - sndbuffersize = GetPrivateProfileInt("Sound","SoundBufferSize", 735 * 4, IniName); - - if (SPU_ChangeSoundCore(sndcoretype, sndbuffersize) != 0) - { - MessageBox(hwnd,"Unable to initialize DirectSound","Error",MB_OK); - return -1; - } - - sndvolume = GetPrivateProfileInt("Sound","Volume",100, IniName); - SPU_SetVolume(sndvolume); - - /* Read the firmware settings from the init file */ - win_fw_config.fav_colour = GetPrivateProfileInt("Firmware","favColor", 10, IniName); - win_fw_config.birth_month = GetPrivateProfileInt("Firmware","bMonth", 7, IniName); - win_fw_config.birth_day = GetPrivateProfileInt("Firmware","bDay", 15, IniName); - win_fw_config.language = GetPrivateProfileInt("Firmware","Language", 1, IniName); - - { - /* - * Read in the nickname and message. - * Convert the strings into Unicode UTF-16 characters. - */ - char temp_str[27]; - int char_index; - GetPrivateProfileString("Firmware","nickName", "yopyop", temp_str, 11, IniName); - win_fw_config.nickname_len = strlen( temp_str); - - if ( win_fw_config.nickname_len == 0) { - strcpy( temp_str, "yopyop"); - win_fw_config.nickname_len = strlen( temp_str); - } - - for ( char_index = 0; char_index < win_fw_config.nickname_len; char_index++) { - win_fw_config.nickname[char_index] = temp_str[char_index]; - } - - GetPrivateProfileString("Firmware","Message", "DeSmuME makes you happy!", temp_str, 27, IniName); - win_fw_config.message_len = strlen( temp_str); - for ( char_index = 0; char_index < win_fw_config.message_len; char_index++) { - win_fw_config.message[char_index] = temp_str[char_index]; - } - } - - /* Create the dummy firmware */ - NDS_CreateDummyFirmware( &win_fw_config); - - runthread_ready = CreateEvent(NULL,TRUE,FALSE,0); - runthread = CreateThread(NULL, 0, run, NULL, 0, &threadID); - - //wait for the run thread to signal that it is initialized and ready to run - WaitForSingleObject(runthread_ready,INFINITE); - - - // Make sure any quotes from lpszArgument are removed - if (lpszArgument[0] == '\"') - sscanf(lpszArgument, "\"%[^\"]\"", lpszArgument); - - if(LoadROM(lpszArgument, bad_glob_cflash_disk_image_file)) - { - EnableMenuItem(menu, IDM_EXEC, MF_GRAYED); - EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); - EnableMenuItem(menu, IDM_RESET, MF_ENABLED); - EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); - EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_ENABLED); - romloaded = TRUE; - NDS_UnPause(); - } - else - { - EnableMenuItem(menu, IDM_EXEC, MF_ENABLED); - EnableMenuItem(menu, IDM_PAUSE, MF_GRAYED); - EnableMenuItem(menu, IDM_RESET, MF_GRAYED); - EnableMenuItem(menu, IDM_GAME_INFO, MF_GRAYED); - EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_GRAYED); - } - - CheckMenuItem(menu, IDC_SAVETYPE1, MF_BYCOMMAND | MF_CHECKED); - CheckMenuItem(menu, IDC_SAVETYPE2, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_SAVETYPE3, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_SAVETYPE4, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_SAVETYPE5, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_SAVETYPE6, MF_BYCOMMAND | MF_UNCHECKED); - - while (GetMessage (&messages, NULL, 0, 0)) - { - if (TranslateAccelerator(hwnd, hAccel, &messages) == 0) - { - // Translate virtual-key messages into character messages - TranslateMessage(&messages); - // Send message to WindowProcedure - DispatchMessage(&messages); - } - } - { - HRESULT hr=Input_DeInit(); -#ifdef DEBUG - if(FAILED(hr)) LOG("DirectInput deinit failed (0x%08X)\n",hr); - else LOG("DirectInput deinit\n"); -#endif - } -#ifdef DEBUG - LogStop(); -#endif - CloseConsole(); - /* The program return-value is 0 - The value that PostQuitMessage() gave */ - return messages.wParam; -} - -void GetWndRect(HWND hwnd) -{ - POINT ptClient; - RECT rc; - - GetClientRect(hwnd,&rc); - ptClient.x=rc.left; - ptClient.y=rc.top; - ClientToScreen(hwnd,&ptClient); - MainWindowRect.left=ptClient.x; - MainWindowRect.top=ptClient.y; - ptClient.x=rc.right; - ptClient.y=rc.bottom; - ClientToScreen(hwnd,&ptClient); - MainWindowRect.right=ptClient.x; - MainWindowRect.bottom=ptClient.y; -} - -//======================================================================================== -void SetRotate(int rot) -{ - GPU_rotation = rot; - - switch (rot) - { - case 0: - GPU_width = 256; - GPU_height = 192*2; - rotationstartscan = 192; - rotationscanlines = 192*2; - break; - - case 90: - GPU_rotation = 90; - GPU_width = 192*2; - GPU_height = 256; - rotationstartscan = 0; - rotationscanlines = 256; - break; - - case 180: - GPU_rotation = 180; - GPU_width = 256; - GPU_height = 192*2; - rotationstartscan = 0; - rotationscanlines = 192*2; - break; - - case 270: - GPU_rotation = 270; - GPU_width = 192*2; - GPU_height = 256; - rotationstartscan = 0; - rotationscanlines = 256; - break; - } - - SetWindowClientSize(hwnd, GPU_width, GPU_height); - CheckMenuItem(menu, IDC_ROTATE0, MF_BYCOMMAND | ((GPU_rotation==0)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_ROTATE90, MF_BYCOMMAND | ((GPU_rotation==90)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_ROTATE180, MF_BYCOMMAND | ((GPU_rotation==180)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_ROTATE270, MF_BYCOMMAND | ((GPU_rotation==270)?MF_CHECKED:MF_UNCHECKED)); - WritePrivateProfileInt("Video","Window Rotate",GPU_rotation,IniName); -} -//======================================================================================== -LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - static int tmp_execute; - switch (message) // handle the messages - { - /*case WM_ENTERMENULOOP: // temporally removed it (freezes) - { - if (execute) - { - NDS_Pause(); - tmp_execute=2; - } else tmp_execute=-1; - return 0; - } - case WM_EXITMENULOOP: - { - if (tmp_execute==2) NDS_UnPause(); - return 0; - }*/ - - case WM_CREATE: - { - RECT clientSize, fullSize; - GetClientRect(hwnd, &clientSize); - GetWindowRect(hwnd, &fullSize); - DefaultWidth = clientSize.right - clientSize.left; - DefaultHeight = clientSize.bottom - clientSize.top; - widthTradeOff = (fullSize.right - fullSize.left) - (clientSize.right - clientSize.left); - heightTradeOff = (fullSize.bottom - fullSize.top) - (clientSize.bottom - clientSize.top); - - if ( (windowSize < 1) || (windowSize > 4) ) - { - int w=GetPrivateProfileInt("Video","Window width", 0, IniName); - int h=GetPrivateProfileInt("Video","Window height", 0, IniName); - if (w && h) - { - RECT fullSize = {0, 0, w, h}; - ResizingLimit(WMSZ_RIGHT, &fullSize); - - if (ForceRatio) - ScallingScreen(hwnd, WMSZ_RIGHT, &fullSize); - SetWindowPos(hwnd, NULL, 0, 0, fullSize.right - fullSize.left, - fullSize.bottom - fullSize.top, SWP_NOMOVE | SWP_NOZORDER); - } - else - windowSize=1; - } - if ( (windowSize > 0) && (windowSize < 5) ) ScaleScreen(hwnd, windowSize); - - return 0; - - } - case WM_DESTROY: - case WM_CLOSE: - { - NDS_Pause(); - finished = TRUE; - - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - if (windowSize==0) - { - WritePrivateProfileInt("Video","Window width",MainWindowRect.right-MainWindowRect.left+widthTradeOff,IniName); - WritePrivateProfileInt("Video","Window height",MainWindowRect.bottom-MainWindowRect.top+heightTradeOff,IniName); - } - - if (runthread != INVALID_HANDLE_VALUE) - { - if (WaitForSingleObject(runthread,INFINITE) == WAIT_TIMEOUT) - { - // Couldn't close thread cleanly - TerminateThread(runthread,0); - } - CloseHandle(runthread); - } - - NDS_DeInit(); - PostMessage(hwnd, WM_QUIT, 0, 0); - return 0; - } - case WM_MOVE: - GetWndRect(hwnd); - return 0; - case WM_SIZING: - { - RECT *rc=(RECT *)lParam; - - windowSize=0; - ResizingLimit(wParam, rc); - if (ForceRatio) - ScallingScreen(hwnd, wParam, rc); - //printlog("sizing: width=%i; height=%i\n", rc->right - rc->left, rc->bottom - rc->top); - } - break; - case WM_SIZE: - if (ForceRatio) { - if ( windowSize != 0 ) ScaleScreen(hwnd, windowSize); - } - GetWndRect(hwnd); - return 0; - case WM_DROPFILES: - { - char filename[MAX_PATH] = ""; - DragQueryFile((HDROP)wParam,0,filename,MAX_PATH); - DragFinish((HDROP)wParam); - if(LoadROM(filename, bad_glob_cflash_disk_image_file)) - { - EnableMenuItem(menu, IDM_EXEC, MF_GRAYED); - EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); - EnableMenuItem(menu, IDM_RESET, MF_ENABLED); - EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); - EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_ENABLED); - romloaded = TRUE; - NDS_UnPause(); - } - } - return 0; - case WM_MOUSEMOVE: - if (wParam & MK_LBUTTON) - { - RECT r ; - s32 x = (s32)((s16)LOWORD(lParam)); - s32 y = (s32)((s16)HIWORD(lParam)); - GetClientRect(hwnd,&r) ; - /* translate from scaling (screen reoltution to 256x384 or 512x192) */ - switch (GPU_rotation) - { - case 0: - case 180: - x = (x*256) / (r.right - r.left) ; - y = (y*384) / (r.bottom - r.top) ; - break ; - case 90: - case 270: - x = (x*512) / (r.right - r.left) ; - y = (y*192) / (r.bottom - r.top) ; - break ; - } - /* translate for rotation */ - if (GPU_rotation != 0) - translateXY(&x,&y); - else - y-=192; - if(x<0) x = 0; else if(x>255) x = 255; - if(y<0) y = 0; else if(y>192) y = 192; - NDS_setTouchPos(x, y); - return 0; - } - NDS_releasTouch(); - return 0; - case WM_LBUTTONDOWN: - if(HIWORD(lParam)>=192) - { - RECT r ; - s32 x = (s32)((s16)LOWORD(lParam)); - s32 y = (s32)((s16)HIWORD(lParam)); - GetClientRect(hwnd,&r) ; - /* translate from scaling (screen reoltution to 256x384 or 512x192) */ - switch (GPU_rotation) - { - case 0: - case 180: - x = (x*256) / (r.right - r.left) ; - y = (y*384) / (r.bottom - r.top) ; - break ; - case 90: - case 270: - x = (x*512) / (r.right - r.left) ; - y = (y*192) / (r.bottom - r.top) ; - break ; - } - /* translate for rotation */ - if (GPU_rotation != 0) - translateXY(&x,&y); - else - y-=192; - if(y>=0) - { - SetCapture(hwnd); - if(x<0) x = 0; else if(x>255) x = 255; - if(y<0) y = 0; else if(y>192) y = 192; - NDS_setTouchPos(x, y); - click = TRUE; - } - } - return 0; - case WM_LBUTTONUP: - if(click) - ReleaseCapture(); - NDS_releasTouch(); - return 0; - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDM_OPEN: - { - int filterSize = 0, i = 0; - OPENFILENAME ofn; - char filename[MAX_PATH] = "", - fileFilter[512]=""; - NDS_Pause(); //Stop emulation while opening new rom - - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwnd; - - // To avoid #ifdef hell, we'll do a little trick, as lpstrFilter - // needs 0 terminated string, and standard string library, of course, - // can't help us with string creation: just put a '|' were a string end - // should be, and later transform prior assigning to the OPENFILENAME structure - strncpy (fileFilter, "NDS ROM file (*.nds)|*.nds|NDS/GBA ROM File (*.ds.gba)|*.ds.gba|",512); -#ifdef HAVE_LIBZZIP - strncat (fileFilter, "Zipped NDS ROM file (*.zip)|*.zip|",512 - strlen(fileFilter)); -#endif -#ifdef HAVE_LIBZ - strncat (fileFilter, "GZipped NDS ROM file (*.gz)|*.gz|",512 - strlen(fileFilter)); -#endif - strncat (fileFilter, "Any file (*.*)|*.*||",512 - strlen(fileFilter)); - - filterSize = strlen(fileFilter); - for (i = 0; i < filterSize; i++) - { - if (fileFilter[i] == '|') fileFilter[i] = '\0'; - } - ofn.lpstrFilter = fileFilter; - ofn.nFilterIndex = 1; - ofn.lpstrFile = filename; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "nds"; - - if(!GetOpenFileName(&ofn)) - { - if (romloaded) - NDS_UnPause(); //Restart emulation if no new rom chosen - return 0; - } - - LOG("%s\r\n", filename); - - if(LoadROM(filename, bad_glob_cflash_disk_image_file)) - { - EnableMenuItem(menu, IDM_EXEC, MF_GRAYED); - EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); - EnableMenuItem(menu, IDM_RESET, MF_ENABLED); - EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); - EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_ENABLED); - romloaded = TRUE; - NDS_UnPause(); - } - } - return 0; - case IDM_PRINTSCREEN: - { - OPENFILENAME ofn; - char filename[MAX_PATH] = ""; - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = "Bmp file (*.bmp)\0*.bmp\0Any file (*.*)\0*.*\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = filename; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "bmp"; - ofn.Flags = OFN_OVERWRITEPROMPT; - GetSaveFileName(&ofn); - NDS_WriteBMP(filename); - } - return 0; - case IDM_QUICK_PRINTSCREEN: - { - NDS_WriteBMP("./printscreen.bmp"); - } - return 0; - case IDM_STATE_LOAD: - { - OPENFILENAME ofn; - NDS_Pause(); - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = "DeSmuME Savestate (*.dst)\0*.dst\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = SavName; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "dst"; - - if(!GetOpenFileName(&ofn)) - { - NDS_UnPause(); - return 0; - } - - savestate_load(SavName); - NDS_UnPause(); - } - return 0; - case IDM_STATE_SAVE: - { - OPENFILENAME ofn; - NDS_Pause(); - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = "DeSmuME Savestate (*.dst)\0*.dst\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = SavName; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "dst"; - - if(!GetSaveFileName(&ofn)) - { - return 0; - } - - savestate_save(SavName); - NDS_UnPause(); - } - return 0; - case IDM_STATE_SAVE_F1: - StateSaveSlot(1); - return 0; - case IDM_STATE_SAVE_F2: - StateSaveSlot(2); - return 0; - case IDM_STATE_SAVE_F3: - StateSaveSlot(3); - return 0; - case IDM_STATE_SAVE_F4: - StateSaveSlot(4); - return 0; - case IDM_STATE_SAVE_F5: - StateSaveSlot(5); - return 0; - case IDM_STATE_SAVE_F6: - StateSaveSlot(6); - return 0; - case IDM_STATE_SAVE_F7: - StateSaveSlot(7); - return 0; - case IDM_STATE_SAVE_F8: - StateSaveSlot(8); - return 0; - case IDM_STATE_SAVE_F9: - StateSaveSlot(9); - return 0; - case IDM_STATE_SAVE_F10: - StateSaveSlot(10); - return 0; - case IDM_STATE_LOAD_F1: - StateLoadSlot(1); - return 0; - case IDM_STATE_LOAD_F2: - StateLoadSlot(2); - return 0; - case IDM_STATE_LOAD_F3: - StateLoadSlot(3); - return 0; - case IDM_STATE_LOAD_F4: - StateLoadSlot(4); - return 0; - case IDM_STATE_LOAD_F5: - StateLoadSlot(5); - return 0; - case IDM_STATE_LOAD_F6: - StateLoadSlot(6); - return 0; - case IDM_STATE_LOAD_F7: - StateLoadSlot(7); - return 0; - case IDM_STATE_LOAD_F8: - StateLoadSlot(8); - return 0; - case IDM_STATE_LOAD_F9: - StateLoadSlot(9); - return 0; - case IDM_STATE_LOAD_F10: - StateLoadSlot(10); - return 0; - case IDM_IMPORTBACKUPMEMORY: - { - OPENFILENAME ofn; - NDS_Pause(); - ZeroMemory(&ofn, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwnd; - ofn.lpstrFilter = "All supported types\0*.duc;*.sav\0Action Replay DS Save (*.duc)\0*.duc\0DS-Xtreme Save (*.sav)\0*.sav\0\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile = ImportSavName; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrDefExt = "duc"; - - if(!GetOpenFileName(&ofn)) - { - NDS_UnPause(); - return 0; - } - - if (!NDS_ImportSave(ImportSavName)) - MessageBox(hwnd,"Save was not successfully imported","Error",MB_OK); - NDS_UnPause(); - return 0; - } - case IDM_SOUNDSETTINGS: - { - DialogBox(GetModuleHandle(NULL), "SoundSettingsDlg", hwnd, (DLGPROC)SoundSettingsDlgProc); - } - return 0; - case IDM_GAME_INFO: - { - CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_GAME_INFO), hwnd, GinfoView_Proc); - } - return 0; - case IDM_PAL: - { - palview_struct *PalView; - - if ((PalView = PalView_Init(hAppInst, HWND_DESKTOP)) != NULL) - CWindow_Show(PalView); - } - return 0; - case IDM_TILE: - { - tileview_struct *TileView; - - if ((TileView = TileView_Init(hAppInst, HWND_DESKTOP)) != NULL) - CWindow_Show(TileView); - } - return 0; - case IDM_IOREG: - { - cwindow_struct *IoregView; - - if ((IoregView = (cwindow_struct*)malloc(sizeof(cwindow_struct))) == NULL) - return 0; - - if (CWindow_Init2(IoregView, hAppInst, HWND_DESKTOP, "IO REG VIEW", IDD_IO_REG, IoregView_Proc) == 0) - { - CWindow_AddToRefreshList(IoregView); - CWindow_Show(IoregView); - } - } - return 0; - case IDM_QUIT: - PostMessage(hwnd, WM_QUIT, 0, 0); - return 0; - case IDM_MEMORY: - { - memview_struct *MemView; - - if ((MemView = MemView_Init(hAppInst, HWND_DESKTOP, "ARM7 memory viewer", 1)) != NULL) - CWindow_Show(MemView); - - if ((MemView = MemView_Init(hAppInst, HWND_DESKTOP, "ARM9 memory viewer", 0)) != NULL) - CWindow_Show(MemView); - } - return 0; - case IDM_DISASSEMBLER: - { - disview_struct *DisView; - - if ((DisView = DisView_Init(hAppInst, HWND_DESKTOP, "ARM7 Disassembler", &NDS_ARM7)) != NULL) - CWindow_Show(DisView); - - if ((DisView = DisView_Init(hAppInst, HWND_DESKTOP, "ARM9 Disassembler", &NDS_ARM9)) != NULL) - CWindow_Show(DisView); - } - return 0; - case IDM_MAP: - { - mapview_struct *MapView; - - if ((MapView = MapView_Init(hAppInst, HWND_DESKTOP)) != NULL) - { - CWindow_AddToRefreshList(MapView); - CWindow_Show(MapView); - } - } - return 0; - case IDM_OAM: - { - oamview_struct *OamView; - - if ((OamView = OamView_Init(hAppInst, HWND_DESKTOP)) != NULL) - { - CWindow_AddToRefreshList(OamView); - CWindow_Show(OamView); - } - } - return 0; - - case IDM_MATRIX_VIEWER: - { - matrixview_struct *MatrixView; - - if ((MatrixView = MatrixView_Init(hAppInst, HWND_DESKTOP)) != NULL) - { - CWindow_Show(MatrixView); - } - } - return 0; - - case IDM_LIGHT_VIEWER: - { - lightview_struct *LightView; - - if ((LightView = LightView_Init(hAppInst, HWND_DESKTOP)) != NULL) - { - CWindow_Show(LightView); - } - } - return 0; - - case IDM_MBG0 : - if(MainScreen.gpu->dispBG[0]) - { - GPU_remove(MainScreen.gpu, 0); - CheckMenuItem(menu, IDM_MBG0, MF_BYCOMMAND | MF_UNCHECKED); - } - else - { - GPU_addBack(MainScreen.gpu, 0); - CheckMenuItem(menu, IDM_MBG0, MF_BYCOMMAND | MF_CHECKED); - } - return 0; - case IDM_MBG1 : - if(MainScreen.gpu->dispBG[1]) - { - GPU_remove(MainScreen.gpu, 1); - CheckMenuItem(menu, IDM_MBG1, MF_BYCOMMAND | MF_UNCHECKED); - } - else - { - GPU_addBack(MainScreen.gpu, 1); - CheckMenuItem(menu, IDM_MBG1, MF_BYCOMMAND | MF_CHECKED); - } - return 0; - case IDM_MBG2 : - if(MainScreen.gpu->dispBG[2]) - { - GPU_remove(MainScreen.gpu, 2); - CheckMenuItem(menu, IDM_MBG2, MF_BYCOMMAND | MF_UNCHECKED); - } - else - { - GPU_addBack(MainScreen.gpu, 2); - CheckMenuItem(menu, IDM_MBG2, MF_BYCOMMAND | MF_CHECKED); - } - return 0; - case IDM_MBG3 : - if(MainScreen.gpu->dispBG[3]) - { - GPU_remove(MainScreen.gpu, 3); - CheckMenuItem(menu, IDM_MBG3, MF_BYCOMMAND | MF_UNCHECKED); - } - else - { - GPU_addBack(MainScreen.gpu, 3); - CheckMenuItem(menu, IDM_MBG3, MF_BYCOMMAND | MF_CHECKED); - } - return 0; - case IDM_SBG0 : - if(SubScreen.gpu->dispBG[0]) - { - GPU_remove(SubScreen.gpu, 0); - CheckMenuItem(menu, IDM_SBG0, MF_BYCOMMAND | MF_UNCHECKED); - } - else - { - GPU_addBack(SubScreen.gpu, 0); - CheckMenuItem(menu, IDM_SBG0, MF_BYCOMMAND | MF_CHECKED); - } - return 0; - case IDM_SBG1 : - if(SubScreen.gpu->dispBG[1]) - { - GPU_remove(SubScreen.gpu, 1); - CheckMenuItem(menu, IDM_SBG1, MF_BYCOMMAND | MF_UNCHECKED); - } - else - { - GPU_addBack(SubScreen.gpu, 1); - CheckMenuItem(menu, IDM_SBG1, MF_BYCOMMAND | MF_CHECKED); - } - return 0; - case IDM_SBG2 : - if(SubScreen.gpu->dispBG[2]) - { - GPU_remove(SubScreen.gpu, 2); - CheckMenuItem(menu, IDM_SBG2, MF_BYCOMMAND | MF_UNCHECKED); - } - else - { - GPU_addBack(SubScreen.gpu, 2); - CheckMenuItem(menu, IDM_SBG2, MF_BYCOMMAND | MF_CHECKED); - } - return 0; - case IDM_SBG3 : - if(SubScreen.gpu->dispBG[3]) - { - GPU_remove(SubScreen.gpu, 3); - CheckMenuItem(menu, IDM_SBG3, MF_BYCOMMAND | MF_UNCHECKED); - } - else - { - GPU_addBack(SubScreen.gpu, 3); - CheckMenuItem(menu, IDM_SBG3, MF_BYCOMMAND | MF_CHECKED); - } - return 0; - - case ACCEL_SPACEBAR: - case IDM_PAUSE: - if (emu_paused) NDS_UnPause(); - else NDS_Pause(); - emu_paused ^= 1; - CheckMenuItem(menu, IDM_PAUSE, emu_paused ? MF_CHECKED : MF_UNCHECKED); - return 0; - - case ACCEL_N: //Frame Advance - frameAdvance = true; - execute = TRUE; - emu_paused = 1; - CheckMenuItem(menu, IDM_PAUSE, emu_paused ? MF_CHECKED : MF_UNCHECKED); - return 0; - - case ID_VIEW_FRAMECOUNTER: - frameCounterDisplay ^= 1; - CheckMenuItem(menu, ID_VIEW_FRAMECOUNTER, frameCounterDisplay ? MF_CHECKED : MF_UNCHECKED); - return 0; - - #define saver(one,two,three,four,five, six) \ - CheckMenuItem(menu, IDC_SAVETYPE1, MF_BYCOMMAND | one); \ - CheckMenuItem(menu, IDC_SAVETYPE2, MF_BYCOMMAND | two); \ - CheckMenuItem(menu, IDC_SAVETYPE3, MF_BYCOMMAND | three); \ - CheckMenuItem(menu, IDC_SAVETYPE4, MF_BYCOMMAND | four); \ - CheckMenuItem(menu, IDC_SAVETYPE5, MF_BYCOMMAND | five); \ - CheckMenuItem(menu, IDC_SAVETYPE6, MF_BYCOMMAND | six); - - case IDC_SAVETYPE1: - saver(MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); - mmu_select_savetype(0,&backupmemorytype,&backupmemorysize); - return 0; - case IDC_SAVETYPE2: - saver(MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); - mmu_select_savetype(1,&backupmemorytype,&backupmemorysize); - return 0; - case IDC_SAVETYPE3: - saver(MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); - mmu_select_savetype(2,&backupmemorytype,&backupmemorysize); - return 0; - case IDC_SAVETYPE4: - saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED); - mmu_select_savetype(3,&backupmemorytype,&backupmemorysize); - return 0; - case IDC_SAVETYPE5: - saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED); - mmu_select_savetype(4,&backupmemorytype,&backupmemorysize); - return 0; - case IDC_SAVETYPE6: - saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED); - mmu_select_savetype(5,&backupmemorytype,&backupmemorysize); - return 0; - - case IDM_RESET: - NDS_Reset(); - frameCounter=0; - return 0; - case IDM_CONFIG: - { - cwindow_struct ConfigView; - - if (CWindow_Init2(&ConfigView, hAppInst, HWND_DESKTOP, "Configure Controls", IDD_CONFIG, ConfigView_Proc) == 0) - CWindow_Show(&ConfigView); - - } - return 0; - case IDM_FIRMSETTINGS: - { - cwindow_struct FirmConfig; - - if (CWindow_Init2(&FirmConfig, hAppInst, HWND_DESKTOP, - "Configure Controls", IDD_FIRMSETTINGS, FirmConfig_Proc) == 0) - CWindow_Show(&FirmConfig); - - } - return 0; - case IDC_FRAMESKIPAUTO: - case IDC_FRAMESKIP0: - case IDC_FRAMESKIP1: - case IDC_FRAMESKIP2: - case IDC_FRAMESKIP3: - case IDC_FRAMESKIP4: - case IDC_FRAMESKIP5: - case IDC_FRAMESKIP6: - case IDC_FRAMESKIP7: - case IDC_FRAMESKIP8: - case IDC_FRAMESKIP9: - { - if(LOWORD(wParam) == IDC_FRAMESKIPAUTO) - { - autoframeskipenab = 1; - WritePrivateProfileString("Video", "FrameSkip", "AUTO", IniName); - } - else - { - char text[80]; - autoframeskipenab = 0; - frameskiprate = LOWORD(wParam) - IDC_FRAMESKIP0; - sprintf(text, "%d", frameskiprate); - WritePrivateProfileString("Video", "FrameSkip", text, IniName); - } - - CheckMenuItem(menu, IDC_FRAMESKIPAUTO, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_FRAMESKIP0, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_FRAMESKIP1, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_FRAMESKIP2, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_FRAMESKIP3, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_FRAMESKIP4, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_FRAMESKIP5, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_FRAMESKIP6, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_FRAMESKIP7, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_FRAMESKIP8, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, IDC_FRAMESKIP9, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(menu, LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED); - } - return 0; - case IDC_LANGENGLISH: - SaveLanguage(0); - ChangeLanguage(0); - CheckLanguage(LOWORD(wParam)); - return 0; - case IDC_LANGFRENCH: - SaveLanguage(1); - ChangeLanguage(1); - CheckLanguage(LOWORD(wParam)); - return 0; - case IDC_LANGDANISH: - SaveLanguage(1); - ChangeLanguage(2); - CheckLanguage(LOWORD(wParam)); - return 0; - case IDM_WEBSITE: - ShellExecute(NULL, "open", "http://desmume.sourceforge.net", NULL, NULL, SW_SHOWNORMAL); - return 0; - - case IDM_FORUM: - ShellExecute(NULL, "open", "http://forums.desmume.org/index.php", NULL, NULL, SW_SHOWNORMAL); - return 0; - - case IDM_ABOUT: - { - cwindow_struct aboutBox; - - if (CWindow_Init2(&aboutBox, hAppInst, HWND_DESKTOP, "About desmume...", IDD_ABOUT_BOX, AboutBox_Proc) == 0) - CWindow_Show(&aboutBox); - - break; - } - -#ifndef BETA_VERSION - case IDM_SUBMITBUGREPORT: - ShellExecute(NULL, "open", "http://sourceforge.net/tracker/?func=add&group_id=164579&atid=832291", NULL, NULL, SW_SHOWNORMAL); - return 0; -#endif - - case IDC_ROTATE0: - SetRotate(0); - return 0; - case IDC_ROTATE90: - SetRotate(90); - return 0; - case IDC_ROTATE180: - SetRotate(180); - return 0; - case IDC_ROTATE270: - SetRotate(270); - return 0; - - case IDC_WINDOW1X: - windowSize=1; - ScaleScreen(hwnd, windowSize); - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - - CheckMenuItem(menu, IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW3X, MF_BYCOMMAND | ((windowSize==3)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW4X, MF_BYCOMMAND | ((windowSize==4)?MF_CHECKED:MF_UNCHECKED)); - break; - case IDC_WINDOW2X: - windowSize=2; - ScaleScreen(hwnd, windowSize); - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - - CheckMenuItem(menu, IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW3X, MF_BYCOMMAND | ((windowSize==3)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW4X, MF_BYCOMMAND | ((windowSize==4)?MF_CHECKED:MF_UNCHECKED)); - break; - case IDC_WINDOW3X: - windowSize=3; - ScaleScreen(hwnd, windowSize); - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - - CheckMenuItem(menu, IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW3X, MF_BYCOMMAND | ((windowSize==3)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW4X, MF_BYCOMMAND | ((windowSize==4)?MF_CHECKED:MF_UNCHECKED)); - break; - case IDC_WINDOW4X: - windowSize=4; - ScaleScreen(hwnd, windowSize); - WritePrivateProfileInt("Video","Window Size",windowSize,IniName); - - CheckMenuItem(menu, IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW3X, MF_BYCOMMAND | ((windowSize==3)?MF_CHECKED:MF_UNCHECKED)); - CheckMenuItem(menu, IDC_WINDOW4X, MF_BYCOMMAND | ((windowSize==4)?MF_CHECKED:MF_UNCHECKED)); - break; - - case IDC_FORCERATIO: - if (ForceRatio) { - CheckMenuItem(menu, IDC_FORCERATIO, MF_BYCOMMAND | MF_UNCHECKED); - ForceRatio = FALSE; - WritePrivateProfileInt("Video","Window Force Ratio",0,IniName); - } - else { - RECT fullSize; - GetWindowRect(hwnd, &fullSize); - ScallingScreen(hwnd, WMSZ_RIGHT, &fullSize); - SetWindowPos(hwnd, NULL, 0, 0, fullSize.right - fullSize.left, - fullSize.bottom - fullSize.top, SWP_NOMOVE | SWP_NOZORDER); - //ScaleScreen(hwnd, (fullSize.bottom - fullSize.top - heightTradeOff) / DefaultHeight); - CheckMenuItem(menu, IDC_FORCERATIO, MF_BYCOMMAND | MF_CHECKED); - ForceRatio = TRUE; - WritePrivateProfileInt("Video","Window Force Ratio",1,IniName); - } - break; - - } - return 0; - default: /* for messages that we don't deal with */ - return DefWindowProc (hwnd, message, wParam, lParam); - } - - return 0; -} - -LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, - LPARAM lParam) -{ - static int timerid=0; - switch (uMsg) - { - case WM_INITDIALOG: - { - int i; - char tempstr[MAX_PATH]; - // Setup Sound Core Combo box - SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_RESETCONTENT, 0, 0); - SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (LPARAM)"None"); - - for (i = 1; SNDCoreList[i] != NULL; i++) - SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (LPARAM)SNDCoreList[i]->Name); - - // Set Selected Sound Core - for (i = 0; SNDCoreList[i] != NULL; i++) - { - if (sndcoretype == SNDCoreList[i]->id) - SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_SETCURSEL, i, 0); - } - - // Setup Sound Buffer Size Edit Text - sprintf(tempstr, "%d", sndbuffersize); - SetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr); - - // Setup Volume Slider - SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_SETRANGE, 0, MAKELONG(0, 100)); - - // Set Selected Volume - SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_SETPOS, TRUE, sndvolume); - - timerid = SetTimer(hDlg, 1, 500, NULL); - return TRUE; - } - case WM_TIMER: - { - if (timerid == wParam) - { - int setting; - setting = SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_GETPOS, 0, 0); - SPU_SetVolume(setting); - break; - } - break; - } - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDOK: - { - char tempstr[MAX_PATH]; - - EndDialog(hDlg, TRUE); - - NDS_Pause(); - - // Write Sound core type - sndcoretype = SNDCoreList[SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_GETCURSEL, 0, 0)]->id; - sprintf(tempstr, "%d", sndcoretype); - WritePrivateProfileString("Sound", "SoundCore", tempstr, IniName); - - // Write Sound Buffer size - GetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr, 6); - sscanf(tempstr, "%d", &sndbuffersize); - WritePrivateProfileString("Sound", "SoundBufferSize", tempstr, IniName); - - SPU_ChangeSoundCore(sndcoretype, sndbuffersize); - - // Write Volume - sndvolume = SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_GETPOS, 0, 0); - sprintf(tempstr, "%d", sndvolume); - WritePrivateProfileString("Sound", "Volume", tempstr, IniName); - SPU_SetVolume(sndvolume); - NDS_UnPause(); - - return TRUE; - } - case IDCANCEL: - { - EndDialog(hDlg, FALSE); - return TRUE; - } - default: break; - } - - break; - } - case WM_DESTROY: - { - if (timerid != 0) - KillTimer(hDlg, timerid); - break; - } - } - - return FALSE; -} - - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + Copyright 2006 Theo Berkau + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include +#include +#include +#include "CWindow.h" +#include "../MMU.h" +#include "../armcpu.h" +#include "../NDSSystem.h" +#include "../debug.h" +#include "../saves.h" +#include "../cflash.h" +#include "resource.h" +#include "memView.h" +#include "disView.h" +#include "ginfo.h" +#include "IORegView.h" +#include "palView.h" +#include "tileView.h" +#include "oamView.h" +#include "mapview.h" +#include "matrixview.h" +#include "lightview.h" +#include "ConfigKeys.h" +#include "FirmConfig.h" +#include "AboutBox.h" +#include "OGLRender.h" +#include "../gfx3d.h" +#include "../render3D.h" +#include "../gdbstub.h" +#include "colorctrl.h" +#include "console.h" +#include "throttle.h" + +#include "../common.h" + +#include "snddx.h" + +#include "directx/ddraw.h" + +#define GPU3D_NULL 0 +#define GPU3D_OPENGL 1 + +//===================== Init DirectDraw +LPDIRECTDRAW7 lpDDraw=NULL; +LPDIRECTDRAWSURFACE7 lpPrimarySurface=NULL; +LPDIRECTDRAWSURFACE7 lpBackSurface=NULL; +DDSURFACEDESC2 ddsd; +LPDIRECTDRAWCLIPPER lpDDClipPrimary=NULL; +LPDIRECTDRAWCLIPPER lpDDClipBack=NULL; + +/* The compact flash disk image file */ +static const char *bad_glob_cflash_disk_image_file; +static char cflash_filename_buffer[512]; + +/* Declare Windows procedure */ +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"; +int romnum = 0; + +DWORD threadID; + +WINCLASS *MainWindow=NULL; + +//HWND hwnd; +//HDC hdc; +HINSTANCE hAppInst; +RECT MainWindowRect; + +//=========================== view tools +TOOLSCLASS *ViewDisasm_ARM7 = NULL; +TOOLSCLASS *ViewDisasm_ARM9 = NULL; +TOOLSCLASS *ViewMem_ARM7 = NULL; +TOOLSCLASS *ViewMem_ARM9 = NULL; +TOOLSCLASS *ViewRegisters = NULL; +TOOLSCLASS *ViewPalette = NULL; +TOOLSCLASS *ViewTiles = NULL; +TOOLSCLASS *ViewMaps = NULL; +TOOLSCLASS *ViewOAM = NULL; +TOOLSCLASS *ViewMatrices = NULL; +TOOLSCLASS *ViewLights = NULL; + + +volatile BOOL execute = FALSE; +volatile BOOL paused = TRUE; +u32 glock = 0; + +BOOL click = FALSE; + +BOOL finished = FALSE; +BOOL romloaded = FALSE; + +void SetRotate(HWND hwnd, int rot); + +BOOL ForceRatio = TRUE; +float DefaultWidth; +float DefaultHeight; +float widthTradeOff; +float heightTradeOff; + +HMENU menu; +HANDLE runthread_ready=INVALID_HANDLE_VALUE; +HANDLE runthread=INVALID_HANDLE_VALUE; + +const DWORD DI_tabkey[48] = {DIK_0,DIK_1,DIK_2,DIK_3,DIK_4,DIK_5,DIK_6,DIK_7,DIK_8,DIK_9,DIK_A,DIK_B,DIK_C, + DIK_D,DIK_E,DIK_F,DIK_G,DIK_H,DIK_I,DIK_J,DIK_K,DIK_L,DIK_M,DIK_N,DIK_O,DIK_P, + DIK_Q,DIK_R,DIK_S,DIK_T,DIK_U,DIK_V,DIK_W,DIK_X,DIK_Y,DIK_Z,DIK_SPACE,DIK_UP, + DIK_DOWN,DIK_LEFT,DIK_RIGHT,DIK_TAB,DIK_LSHIFT,DIK_DELETE,DIK_INSERT,DIK_HOME, + DIK_END,DIK_RETURN}; +DWORD ds_up,ds_down,ds_left,ds_right,ds_a,ds_b,ds_x,ds_y,ds_l,ds_r,ds_select,ds_start,ds_debug; +//static char IniName[MAX_PATH]; +int sndcoretype=SNDCORE_DIRECTX; +int sndbuffersize=735*4; +int sndvolume=100; + +SoundInterface_struct *SNDCoreList[] = { +&SNDDummy, +&SNDFile, +&SNDDIRECTX, +NULL +}; + +GPU3DInterface *core3DList[] = { +&gpu3DNull, +&gpu3Dgl, +}; + +int autoframeskipenab=1; +int frameskiprate=0; +int emu_paused = 0; +static int backupmemorytype=MC_TYPE_AUTODETECT; +static u32 backupmemorysize=1; +unsigned int frameCounter=0; +bool frameAdvance = false; +bool frameCounterDisplay = false; +bool FpsDisplay = false; +unsigned short windowSize = 0; + +/* the firmware settings */ +struct NDS_fw_config_data win_fw_config; + + +LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, + LPARAM lParam); + +struct configured_features { + u16 arm9_gdb_port; + u16 arm7_gdb_port; + + const char *cflash_disk_image_file; +}; + +static void +init_configured_features( struct configured_features *config) { + config->arm9_gdb_port = 0; + config->arm7_gdb_port = 0; + + config->cflash_disk_image_file = NULL; +} + + +static int +fill_configured_features( struct configured_features *config, LPSTR lpszArgument) { + int good_args = 0; + LPTSTR cmd_line; + LPWSTR *argv; + int argc; + + argv = CommandLineToArgvW( GetCommandLineW(), &argc); + + if ( argv != NULL) { + int i; + good_args = 1; + for ( i = 1; i < argc && good_args; i++) { + if ( wcsncmp( argv[i], L"--arm9gdb=", 10) == 0) { + wchar_t *end_char; + unsigned long port_num = wcstoul( &argv[i][10], &end_char, 10); + + if ( port_num > 0 && port_num < 65536) { + config->arm9_gdb_port = port_num; + } + else { + MessageBox(NULL,"ARM9 GDB stub port must be in the range 1 to 65535","Error",MB_OK); + good_args = 0; + } + } + else if ( wcsncmp( argv[i], L"--arm7gdb=", 10) == 0) { + wchar_t *end_char; + unsigned long port_num = wcstoul( &argv[i][10], &end_char, 10); + + if ( port_num > 0 && port_num < 65536) { + config->arm7_gdb_port = port_num; + } + else { + MessageBox(NULL,"ARM9 GDB stub port must be in the range 1 to 65535","Error",MB_OK); + good_args = 0; + } + } + else if ( wcsncmp( argv[i], L"--cflash=", 9) == 0) { + if ( config->cflash_disk_image_file == NULL) { + size_t convert_count = wcstombs( &cflash_filename_buffer[0], &argv[i][9], 512); + if ( convert_count > 0) { + config->cflash_disk_image_file = cflash_filename_buffer; + } + } + else { + MessageBox(NULL,"CFlash disk image file already set","Error",MB_OK); + good_args = 0; + } + } + } + LocalFree( argv); + } + + return good_args; +} + +// Rotation definitions +short GPU_rotation = 0; +DWORD GPU_width = 256; +DWORD GPU_height = 192*2; +DWORD rotationstartscan = 192; +DWORD rotationscanlines = 192*2; + +void SetWindowClientSize(HWND hwnd, int cx, int cy) //found at: http://blogs.msdn.com/oldnewthing/archive/2003/09/11/54885.aspx +{ + HMENU hmenu = GetMenu(hwnd); + RECT rcWindow = { 0, 0, cx, cy }; + + /* + * First convert the client rectangle to a window rectangle the + * menu-wrap-agnostic way. + */ + AdjustWindowRect(&rcWindow, WS_CAPTION| WS_SYSMENU |WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, hmenu != NULL); + + /* + * If there is a menu, then check how much wrapping occurs + * when we set a window to the width specified by AdjustWindowRect + * and an infinite amount of height. An infinite height allows + * us to see every single menu wrap. + */ + if (hmenu) { + RECT rcTemp = rcWindow; + rcTemp.bottom = 0x7FFF; /* "Infinite" height */ + SendMessage(hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rcTemp); + + /* + * Adjust our previous calculation to compensate for menu + * wrapping. + */ + rcWindow.bottom += rcTemp.top; + } + SetWindowPos(hwnd, NULL, 0, 0, rcWindow.right - rcWindow.left, + rcWindow.bottom - rcWindow.top, SWP_NOMOVE | SWP_NOZORDER); + + if (lpBackSurface!=NULL) + { + IDirectDrawSurface7_Release(lpBackSurface); + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + ddsd.dwWidth = cx; + ddsd.dwHeight = cy; + + IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpBackSurface, NULL); + } +} + +void ResizingLimit(int wParam, RECT *rc) +{ + u32 width = (rc->right - rc->left); + u32 height = (rc->bottom - rc->top); + + u32 minX = 256; + u32 minY = 414; + + //printlog("width=%i; height=%i\n", width, height); + + if (GPU_rotation == 90 || GPU_rotation == 270) + { + minX = 390; + minY = 272; + } + switch (wParam) + { + case WMSZ_LEFT: + { + if (widthleft=rc->left+(width-minX); + return; + } + + case WMSZ_RIGHT: + { + if (widthright=rc->left+minX; + return; + } + + case WMSZ_TOP: + { + if (heighttop=rc->top+(height-minY); + return; + } + + case WMSZ_BOTTOM: + { + if (heightbottom=rc->top+minY; + return; + } + + case WMSZ_TOPLEFT: + { + if (heighttop=rc->top+(height-minY); + if (widthleft=rc->left+(width-minX); + return; + } + case WMSZ_BOTTOMLEFT: + { + if (heightbottom=rc->top+minY; + if (widthleft=rc->left+(width-minX); + return; + } + + case WMSZ_TOPRIGHT: + { + if (heighttop=rc->top+(height-minY); + if (widthright=rc->left+minX; + return; + } + + case WMSZ_BOTTOMRIGHT: + { + if (heightbottom=rc->top+minY; + if (widthright=rc->left+minX; + return; + } + } + +} + +void ScallingScreen(HWND hwnd, int wParam, RECT *rc) +{ + float aspect; + u32 width; + u32 height; + u32 width2; + u32 height2; + + width = (rc->right - rc->left - widthTradeOff); + height = (rc->bottom - rc->top - heightTradeOff); + + if (width == height) return; + + if (GPU_rotation == 0 || GPU_rotation == 180) + { + aspect = DefaultWidth / DefaultHeight; + } + else + { + aspect = DefaultHeight / DefaultWidth; + } + + switch (wParam) + { + case WMSZ_LEFT: + case WMSZ_RIGHT: + { + height = (int)(width / aspect); + rc->bottom=rc->top+height+heightTradeOff; + return; + } + + case WMSZ_TOP: + case WMSZ_BOTTOM: + { + width = (int)(height * aspect); + rc->right=rc->left+width+widthTradeOff; + return; + } + + case WMSZ_TOPLEFT: + { + width = (int)(height * aspect); + rc->left=rc->right-width-widthTradeOff; + return; + } + case WMSZ_BOTTOMLEFT: + { + height = (int)(width / aspect); + rc->bottom=rc->top + height + heightTradeOff; + return; + } + + case WMSZ_TOPRIGHT: + case WMSZ_BOTTOMRIGHT: + { + width = (int)(height * aspect); + rc->right=rc->left+width+widthTradeOff; + return; + } + } +} + +void ScaleScreen(HWND hwnd, float factor) +{ + if ((GPU_rotation==0)||(GPU_rotation==180)) + { + SetWindowPos(hwnd, NULL, 0, 0, widthTradeOff + DefaultWidth * factor, + heightTradeOff + DefaultHeight * factor, SWP_NOMOVE | SWP_NOZORDER); + } + else + if ((GPU_rotation==90)||(GPU_rotation==270)) + { + SetWindowPos(hwnd, NULL, 0, 0, heightTradeOff + DefaultHeight * factor, + widthTradeOff + DefaultWidth * factor, SWP_NOMOVE | SWP_NOZORDER); + } +} + +void translateXY(s32 *x, s32*y) +{ + s32 tmp; + switch(GPU_rotation) + { + case 90: + tmp = *x; + *x = *y; + *y = 192*2 -tmp; + break; + case 180: + *x = 256-*x; + *y = 192*2-*y; + break; + case 270: + tmp = *x; + *x = 255-*y; + *y = tmp; + break; + } + *y-=192; +} + + // END Rotation definitions + +void Input_Post() +{ + char txt[255]; + BOOL bPressed; + HRESULT hr; + WORD keys[13][3]={{ds_a,0xFFFE,0x01},{ds_b,0xFFFD,0x02},{ds_select,0xFFFB,0x04},{ds_start,0xFFF7,0x08}, + {ds_right,0xFFEF,0x10},{ds_left,0xFFDF,0x20},{ds_up,0xFFBF,0x40},{ds_down,0xFF7F,0x80}, + {ds_r,0xFEFF,0x100},{ds_l,0xFDFF,0x200}, + {ds_x,0xFFFE,0x01},{ds_y,0xFFFD,0x02},{ds_debug,0xFFFB,0x04}}; + int i; + + for (i=0; i<10; i++) + { + bPressed=FALSE; + if (keys[i][0]<48) + if (g_cDIBuf[DI_tabkey[keys[i][0]]]&0x80) bPressed=TRUE; + if (keys[i][0]>=48) + if (g_cDIBuf[208+keys[i][0]]&0x80) bPressed=TRUE; + if (bPressed) + { + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1]&=keys[i][1]; + ((u16 *)MMU.ARM7_REG)[0x130>>1]&=keys[i][1]; + } + else + { + ((u16 *)ARM9Mem.ARM9_REG)[0x130>>1]|=keys[i][2]; + ((u16 *)MMU.ARM7_REG)[0x130>>1]|=keys[i][2]; + } + } + for (i=10; i<13; i++) + { + bPressed=FALSE; + if (keys[i][0]<48) + if (g_cDIBuf[DI_tabkey[keys[i][0]]]&0x80) bPressed=TRUE; + if (keys[i][0]>=48) + if (g_cDIBuf[208+keys[i][0]]&0x80) bPressed=TRUE; + if (bPressed) + ((u16 *)MMU.ARM7_REG)[0x136>>1]&=keys[i][1]; + else + ((u16 *)MMU.ARM7_REG)[0x136>>1]|=keys[i][2]; + } +} + +int CreateDDrawBuffers() +{ + if (lpDDClipPrimary!=NULL) IDirectDraw7_Release(lpDDClipPrimary); + if (lpPrimarySurface != NULL) IDirectDraw7_Release(lpPrimarySurface); + if (lpBackSurface != NULL) IDirectDraw7_Release(lpBackSurface); + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; + ddsd.dwFlags = DDSD_CAPS; + if (IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpPrimarySurface, NULL) != DD_OK) return -1; + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + + if ( (GPU_rotation == 0) || (GPU_rotation == 180) ) + { + ddsd.dwWidth = 256; + ddsd.dwHeight = 384; + } + else + if ( (GPU_rotation == 90) || (GPU_rotation == 270) ) + { + ddsd.dwWidth = 384; + ddsd.dwHeight = 256; + } + + if (IDirectDraw7_CreateSurface(lpDDraw, &ddsd, &lpBackSurface, NULL) != DD_OK) return -2; + + if (IDirectDraw7_CreateClipper(lpDDraw, 0, &lpDDClipPrimary, NULL) != DD_OK) return -3; + + if (IDirectDrawClipper_SetHWnd(lpDDClipPrimary, 0, MainWindow->getHWnd()) != DD_OK) return -4; + if (IDirectDrawSurface7_SetClipper(lpPrimarySurface, lpDDClipPrimary) != DD_OK) return -5; + + return 1; +} + + +void Display() +{ + int res; + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags=DDSD_ALL; + res=IDirectDrawSurface7_Lock(lpBackSurface,NULL,&ddsd,DDLOCK_WAIT, NULL); + + if (res == DD_OK) + { + char* buffer = (char*)ddsd.lpSurface; + + int i, j, sz=256*sizeof(u32); + if (ddsd.ddpfPixelFormat.dwRGBBitCount>16) + { + u16 *tmpGPU_Screen_src=(u16*)GPU_screen; + u32 tmpGPU_screen[98304]; + for(i=0; i<98304; i++) + tmpGPU_screen[i]= (((tmpGPU_Screen_src[i]>>10)&0x1F)<<3)| + (((tmpGPU_Screen_src[i]>>5)&0x1F)<<11)| + (((tmpGPU_Screen_src[i])&0x1F)<<19); + switch (GPU_rotation) + { + case 0: + { + for (i = 0; i < 98304; i+=256) //384*256 + { + memcpy(buffer,tmpGPU_screen+i,sz); + buffer += ddsd.lPitch; + } + break; + } + case 90: + { + u32 start; + memset(buffer,0,384*ddsd.lPitch); + for (j=0; j<256; j++) + { + start=98304+j; + for (i=0; i<384; i++) + { + start-=256; + ((u32*)buffer)[i]=((u32 *)tmpGPU_screen)[start]; + } + buffer += ddsd.lPitch; + } + break; + } + case 180: + { + u32 start=98300; + for (j=0; j<384; j++) + { + for (i=0; i<256; i++, --start) + ((u32*)buffer)[i]=((u32 *)tmpGPU_screen)[start]; + buffer += ddsd.lPitch; + } + break; + } + case 270: + { + u32 start; + memset(buffer,0,384*ddsd.lPitch); + for (j=0; j<256; j++) + { + start=256-j; + for (i=0; i<384; i++) + { + ((u32*)buffer)[i]=((u32 *)tmpGPU_screen)[start]; + start+=256; + } + buffer += ddsd.lPitch; + } + break; + } + } + } + else + printlog("16bit depth color not supported"); + IDirectDrawSurface7_Unlock(lpBackSurface,(LPRECT)ddsd.lpSurface); + + if (IDirectDrawSurface7_Blt(lpPrimarySurface,&MainWindowRect,lpBackSurface,0, DDBLT_WAIT,0)==DDERR_SURFACELOST) + { + printlog("DirectDraw buffers is lost\n"); + if (IDirectDrawSurface7_Restore(lpPrimarySurface)==DD_OK) + IDirectDrawSurface7_Restore(lpBackSurface); + } + } + else + { + if (res==DDERR_SURFACELOST) + { + printlog("DirectDraw buffers is lost\n"); + if (IDirectDrawSurface7_Restore(lpPrimarySurface)==DD_OK) + IDirectDrawSurface7_Restore(lpBackSurface); + } + } +} + + +DWORD WINAPI run( LPVOID lpParameter) +{ + char txt[80]; + u32 cycles = 0; + int wait=0; + u64 freq; + u64 OneFrameTime; + int framestoskip=0; + int framesskipped=0; + int skipnextframe=0; + u64 lastticks=0; + u64 curticks=0; + u64 diffticks=0; + u32 framecount=0; + u64 onesecondticks=0; + int fps=0; + int fpsframecount=0; + u64 fpsticks=0; + int res; + HWND hwnd = MainWindow->getHWnd(); + + DDCAPS hw_caps, sw_caps; + + InitSpeedThrottle(); + + if (DirectDrawCreateEx(NULL, (LPVOID*)&lpDDraw, IID_IDirectDraw7, NULL) != DD_OK) + { + MessageBox(hwnd,"Unable to initialize DirectDraw","Error",MB_OK); + return -1; + } + + if (IDirectDraw7_SetCooperativeLevel(lpDDraw,hwnd, DDSCL_NORMAL) != DD_OK) + { + MessageBox(hwnd,"Unable to set DirectDraw Cooperative Level","Error",MB_OK); + return -1; + } + + if (CreateDDrawBuffers()<1) + { + MessageBox(hwnd,"Unable to set DirectDraw buffers","Error",MB_OK); + return -1; + } + + NDS_3D_SetDriver (GPU3D_OPENGL); + + if (!gpu3D->NDS_3D_Init ()) + { + MessageBox(hwnd,"Unable to initialize openGL","Error",MB_OK); + return -1; + } + + QueryPerformanceFrequency((LARGE_INTEGER *)&freq); + QueryPerformanceCounter((LARGE_INTEGER *)&lastticks); + OneFrameTime = freq / 60; + + SetEvent(runthread_ready); + + while(!finished) + { + while(execute) + { + cycles = NDS_exec((560190<<1)-cycles,FALSE); + SPU_Emulate(); + Input_Process(); + Input_Post(); + + if (!skipnextframe) + { + Display(); + + fpsframecount++; + QueryPerformanceCounter((LARGE_INTEGER *)&curticks); + bool oneSecond = curticks >= fpsticks + freq; + if(oneSecond) // TODO: print fps on screen in DDraw + { + fps = fpsframecount; + fpsframecount = 0; + QueryPerformanceCounter((LARGE_INTEGER *)&fpsticks); + } + + if(nds.idleFrameCounter==0 || oneSecond) + { + //calculate a 16 frame arm9 load average + int load = 0; + for(int i=0;i<16;i++) + load = load/8 + nds.runCycleCollector[(i+nds.idleFrameCounter)&15]*7/8; + load = std::min(100,std::max(0,(int)(load*100/1120380))); + sprintf(txt,"(%02d%%) %s", load, DESMUME_NAME_AND_VERSION); + SetWindowText(hwnd, txt); + if (FpsDisplay) osd->addFixed(10, 10, "%02d Fps", fps); + } + + framesskipped = 0; + + if (framestoskip > 0) + skipnextframe = 1; + } + else + { + framestoskip--; + + if (framestoskip < 1) + skipnextframe = 0; + else + skipnextframe = 1; + + framesskipped++; + } + + while(SpeedThrottle()) + { + } + + if (autoframeskipenab) + { + framecount++; + + if (framecount > 60) + { + framecount = 1; + onesecondticks = 0; + } + + QueryPerformanceCounter((LARGE_INTEGER *)&curticks); + diffticks = curticks-lastticks; + + if(ThrottleIsBehind() && framesskipped < 9) + { + skipnextframe = 1; + framestoskip = 1; + } + + onesecondticks += diffticks; + lastticks = curticks; + } + else + { + if (framestoskip < 1) + framestoskip += frameskiprate; + } + if (frameAdvance) + { + frameAdvance = false; + execute = FALSE; + SPU_Pause(1); + } + frameCounter++; + if (frameCounterDisplay) osd->addFixed(200, 30, "%d",frameCounter); + } + paused = TRUE; + Sleep(500); + } + if (lpDDClipPrimary!=NULL) IDirectDraw7_Release(lpDDClipPrimary); + if (lpPrimarySurface != NULL) IDirectDraw7_Release(lpPrimarySurface); + if (lpBackSurface != NULL) IDirectDraw7_Release(lpBackSurface); + if (lpDDraw != NULL) IDirectDraw7_Release(lpDDraw); + return 1; +} + +void NDS_Pause() +{ + execute = FALSE; + SPU_Pause(1); + while (!paused) {} + printlog("Paused\n"); +} + +void NDS_UnPause() +{ + paused = FALSE; + execute = TRUE; + SPU_Pause(0); + printlog("Unpaused\n"); +} + +void StateSaveSlot(int num) +{ + NDS_Pause(); + savestate_slot(num); + NDS_UnPause(); +} + +void StateLoadSlot(int num) +{ + BOOL wasPaused = paused; + NDS_Pause(); + loadstate_slot(num); + if(!wasPaused) + NDS_UnPause(); + else + Display(); +} + +BOOL LoadROM(char * filename, const char *cflash_disk_image) +{ + NDS_Pause(); + if (strcmp(filename,"")!=0) printlog("Loading ROM: %s\n",filename); + + if (NDS_LoadROM(filename, backupmemorytype, backupmemorysize, cflash_disk_image) > 0) + return TRUE; + + return FALSE; +} + +/* + * The thread handling functions needed by the GDB stub code. + */ +void * +createThread_gdb( void (APIENTRY *thread_function)( void *data), + void *thread_data) { + void *new_thread = CreateThread( NULL, 0, + (LPTHREAD_START_ROUTINE)thread_function, thread_data, + 0, NULL); + + return new_thread; +} + +void +joinThread_gdb( void *thread_handle) { +} + + +void SetLanguage(int langid) +{ + switch(langid) + { + case 1: + // French + SetThreadLocale(MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_FRENCH), + SORT_DEFAULT)); + break; + case 2: + // Danish + SetThreadLocale(MAKELCID(MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), + SORT_DEFAULT)); + break; + case 0: + // English + SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), + SORT_DEFAULT)); + break; + default: break; + break; + } +} + +void SaveLanguage(int langid) +{ + char text[80]; + + sprintf(text, "%d", langid); + WritePrivateProfileString("General", "Language", text, IniName); +} + +void CheckLanguage(UINT id) +{ + int i; + for (i = IDC_LANGENGLISH; i < IDC_LANGFRENCH+1; i++) + MainWindow->checkMenu(i, MF_BYCOMMAND | MF_UNCHECKED); + + MainWindow->checkMenu(id, MF_BYCOMMAND | MF_CHECKED); +} + +void ChangeLanguage(int id) +{ + HMENU newmenu; + + SetLanguage(id); + newmenu = LoadMenu(hAppInst, "MENU_PRINCIPAL"); + SetMenu(MainWindow->getHWnd(), newmenu); + DestroyMenu(menu); + menu = newmenu; +} + +int RegClass(WNDPROC Proc, LPCTSTR szName) +{ + WNDCLASS wc; + + wc.style = CS_DBLCLKS; + wc.cbClsExtra = wc.cbWndExtra=0; + wc.lpfnWndProc=Proc; + wc.hInstance=hAppInst; + wc.hIcon=LoadIcon(hAppInst,MAKEINTRESOURCE(IDI_APPLICATION)); + //wc.hIconSm=LoadIcon(hAppInst,MAKEINTRESOURCE(IDI_APPLICATION)); + wc.hCursor=LoadCursor(NULL,IDC_ARROW); + wc.hbrBackground=(HBRUSH)(COLOR_BACKGROUND); + wc.lpszMenuName=(LPCTSTR)NULL; + wc.lpszClassName=szName; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + return RegisterClass(&wc); +} + + +int WINAPI WinMain (HINSTANCE hThisInstance, + HINSTANCE hPrevInstance, + LPSTR lpszArgument, + int nFunsterStil) + +{ +#ifdef GDB_STUB + gdbstub_handle_t arm9_gdb_stub; + gdbstub_handle_t arm7_gdb_stub; + struct armcpu_memory_iface *arm9_memio = &arm9_base_memory_iface; + struct armcpu_memory_iface *arm7_memio = &arm7_base_memory_iface; + struct armcpu_ctrl_iface *arm9_ctrl_iface; + struct armcpu_ctrl_iface *arm7_ctrl_iface; +#endif + struct configured_features my_config; + + extern bool windows_opengl_init(); + oglrender_init = windows_opengl_init; + + + MSG messages; /* Here messages to the application are saved */ + char text[80]; + HACCEL hAccel; + hAppInst=hThisInstance; + + init_configured_features( &my_config); + if ( !fill_configured_features( &my_config, lpszArgument)) { + MessageBox(NULL,"Unable to parse command line arguments","Error",MB_OK); + return 0; + } + ColorCtrl_Register(); + + OpenConsole(); // Init debug console + + if (!RegClass(WindowProcedure, "DeSmuME")) + { + MessageBox(NULL, "Error registering windows class", "DeSmuME", MB_OK); + exit(-1); + } + + GetINIPath(); + windowSize = GetPrivateProfileInt("Video","Window Size", 0, IniName); + GPU_rotation = GetPrivateProfileInt("Video","Window Rotate", 0, IniName); + ForceRatio = GetPrivateProfileInt("Video","Window Force Ratio", 1, IniName); + FpsDisplay = GetPrivateProfileInt("Video","Display Fps", 0, IniName); + + //sprintf(text, "%s", DESMUME_NAME_AND_VERSION); + MainWindow = new WINCLASS(CLASSNAME, hThisInstance); + if (!MainWindow->create(TITLE, CW_USEDEFAULT, CW_USEDEFAULT, 256, 384, + WS_CAPTION| WS_SYSMENU | WS_SIZEBOX | WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + NULL)) + { + MessageBox(NULL, "Error creating main window", "DeSmuME", MB_OK); + delete MainWindow; + exit(-1); + } + + /* default the firmware settings, they may get changed later */ + NDS_FillDefaultFirmwareConfigData( &win_fw_config); + + GetPrivateProfileString("General", "Language", "-1", text, 80, IniName); + SetLanguage(atoi(text)); + + bad_glob_cflash_disk_image_file = my_config.cflash_disk_image_file; + + hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL)); + +#ifdef DEBUG + LogStart(); +#endif + + if (!MainWindow->setMenu(LoadMenu(hThisInstance, "MENU_PRINCIPAL"))) + { + MessageBox(NULL, "Error creating main menu", "DeSmuME", MB_OK); + delete MainWindow; + exit(-1); + } + + // menu checks + MainWindow->checkMenu(IDC_FORCERATIO, MF_BYCOMMAND | (ForceRatio==1?MF_CHECKED:MF_UNCHECKED)); + + MainWindow->checkMenu(ID_VIEW_DISPLAYFPS, FpsDisplay ? MF_CHECKED : MF_UNCHECKED); + + MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?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_ROTATE0, MF_BYCOMMAND | ((GPU_rotation==0)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_ROTATE90, MF_BYCOMMAND | ((GPU_rotation==90)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_ROTATE180, MF_BYCOMMAND | ((GPU_rotation==180)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_ROTATE270, MF_BYCOMMAND | ((GPU_rotation==270)?MF_CHECKED:MF_UNCHECKED)); + + DragAcceptFiles(MainWindow->getHWnd(), TRUE); + + printlog("Init NDS\n"); + + Input_Init(MainWindow->getHWnd()); + + ViewDisasm_ARM7 = new TOOLSCLASS(hThisInstance, IDD_DESASSEMBLEUR_VIEWER7, (DLGPROC) ViewDisasm_ARM7Proc); + ViewDisasm_ARM9 = new TOOLSCLASS(hThisInstance, IDD_DESASSEMBLEUR_VIEWER9, (DLGPROC) ViewDisasm_ARM9Proc); + ViewMem_ARM7 = new TOOLSCLASS(hThisInstance, IDD_MEM_VIEWER7, (DLGPROC) ViewMem_ARM7Proc); + ViewMem_ARM9 = new TOOLSCLASS(hThisInstance, IDD_MEM_VIEWER9, (DLGPROC) ViewMem_ARM9Proc); + ViewRegisters = new TOOLSCLASS(hThisInstance, IDD_IO_REG, (DLGPROC) IoregView_Proc); + ViewPalette = new TOOLSCLASS(hThisInstance, IDD_PAL, (DLGPROC) ViewPalProc); + ViewTiles = new TOOLSCLASS(hThisInstance, IDD_TILE, (DLGPROC) ViewTilesProc); + ViewMaps = new TOOLSCLASS(hThisInstance, IDD_MAP, (DLGPROC) ViewMapsProc); + ViewOAM = new TOOLSCLASS(hThisInstance, IDD_OAM, (DLGPROC) ViewOAMProc); + ViewMatrices = new TOOLSCLASS(hThisInstance, IDD_MATRIX_VIEWER, (DLGPROC) ViewMatricesProc); + ViewLights = new TOOLSCLASS(hThisInstance, IDD_LIGHT_VIEWER, (DLGPROC) ViewLightsProc); + +#ifdef GDB_STUB + if ( my_config.arm9_gdb_port != 0) { + arm9_gdb_stub = createStub_gdb( my_config.arm9_gdb_port, + &arm9_memio, &arm9_direct_memory_iface); + + if ( arm9_gdb_stub == NULL) { + MessageBox(hwnd,"Failed to create ARM9 gdbstub","Error",MB_OK); + return -1; + } + } + if ( my_config.arm7_gdb_port != 0) { + arm7_gdb_stub = createStub_gdb( my_config.arm7_gdb_port, + &arm7_memio, + &arm7_base_memory_iface); + + if ( arm7_gdb_stub == NULL) { + MessageBox(hwnd,"Failed to create ARM7 gdbstub","Error",MB_OK); + return -1; + } + } + + NDS_Init( arm9_memio, &arm9_ctrl_iface, + arm7_memio, &arm7_ctrl_iface); +#else + NDS_Init (); +#endif + + /* + * Activate the GDB stubs + * This has to come after the NDS_Init where the cpus are set up. + */ +#ifdef GDB_STUB + if ( my_config.arm9_gdb_port != 0) { + activateStub_gdb( arm9_gdb_stub, arm9_ctrl_iface); + } + if ( my_config.arm7_gdb_port != 0) { + activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface); + } +#endif + GetPrivateProfileString("General", "Language", "0", text, 80, IniName); //================================================== ??? + CheckLanguage(IDC_LANGENGLISH+atoi(text)); + + GetPrivateProfileString("Video", "FrameSkip", "AUTO", text, 80, IniName); + + if (strcmp(text, "AUTO") == 0) + { + autoframeskipenab=1; + frameskiprate=0; + MainWindow->checkMenu(IDC_FRAMESKIPAUTO, MF_BYCOMMAND | MF_CHECKED); + } + else + { + autoframeskipenab=0; + frameskiprate=atoi(text); + MainWindow->checkMenu(frameskiprate + IDC_FRAMESKIP0, MF_BYCOMMAND | MF_CHECKED); + } + +#ifdef BETA_VERSION + EnableMenuItem (menu, IDM_SUBMITBUGREPORT, MF_GRAYED); +#endif + printlog("Init sound core\n"); + sndcoretype = GetPrivateProfileInt("Sound","SoundCore", SNDCORE_DIRECTX, IniName); + sndbuffersize = GetPrivateProfileInt("Sound","SoundBufferSize", 735 * 4, IniName); + + if (SPU_ChangeSoundCore(sndcoretype, sndbuffersize) != 0) + { + MessageBox(MainWindow->getHWnd(),"Unable to initialize DirectSound","Error",MB_OK); + return -1; + } + + sndvolume = GetPrivateProfileInt("Sound","Volume",100, IniName); + SPU_SetVolume(sndvolume); + + /* Read the firmware settings from the init file */ + win_fw_config.fav_colour = GetPrivateProfileInt("Firmware","favColor", 10, IniName); + win_fw_config.birth_month = GetPrivateProfileInt("Firmware","bMonth", 7, IniName); + win_fw_config.birth_day = GetPrivateProfileInt("Firmware","bDay", 15, IniName); + win_fw_config.language = GetPrivateProfileInt("Firmware","Language", 1, IniName); + + { + /* + * Read in the nickname and message. + * Convert the strings into Unicode UTF-16 characters. + */ + char temp_str[27]; + int char_index; + GetPrivateProfileString("Firmware","nickName", "yopyop", temp_str, 11, IniName); + win_fw_config.nickname_len = strlen( temp_str); + + if ( win_fw_config.nickname_len == 0) { + strcpy( temp_str, "yopyop"); + win_fw_config.nickname_len = strlen( temp_str); + } + + for ( char_index = 0; char_index < win_fw_config.nickname_len; char_index++) { + win_fw_config.nickname[char_index] = temp_str[char_index]; + } + + GetPrivateProfileString("Firmware","Message", "DeSmuME makes you happy!", temp_str, 27, IniName); + win_fw_config.message_len = strlen( temp_str); + for ( char_index = 0; char_index < win_fw_config.message_len; char_index++) { + win_fw_config.message[char_index] = temp_str[char_index]; + } + } + + /* Create the dummy firmware */ + NDS_CreateDummyFirmware( &win_fw_config); + + runthread_ready = CreateEvent(NULL,TRUE,FALSE,0); + runthread = CreateThread(NULL, 0, run, NULL, 0, &threadID); + + //wait for the run thread to signal that it is initialized and ready to run + WaitForSingleObject(runthread_ready,INFINITE); + + // Make sure any quotes from lpszArgument are removed + if (lpszArgument[0] == '\"') + sscanf(lpszArgument, "\"%[^\"]\"", lpszArgument); + + if(LoadROM(lpszArgument, bad_glob_cflash_disk_image_file)) + { + EnableMenuItem(menu, IDM_EXEC, MF_GRAYED); + EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); + EnableMenuItem(menu, IDM_RESET, MF_ENABLED); + EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); + EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_ENABLED); + romloaded = TRUE; + NDS_UnPause(); + } + else + { + EnableMenuItem(menu, IDM_EXEC, MF_ENABLED); + EnableMenuItem(menu, IDM_PAUSE, MF_GRAYED); + EnableMenuItem(menu, IDM_RESET, MF_GRAYED); + EnableMenuItem(menu, IDM_GAME_INFO, MF_GRAYED); + EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_GRAYED); + } + + MainWindow->checkMenu(IDC_SAVETYPE1, MF_BYCOMMAND | MF_CHECKED); + MainWindow->checkMenu(IDC_SAVETYPE2, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_SAVETYPE3, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_SAVETYPE4, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_SAVETYPE5, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_SAVETYPE6, MF_BYCOMMAND | MF_UNCHECKED); + + MainWindow->Show(SW_NORMAL); + + while (GetMessage (&messages, NULL, 0, 0)) + { + if (TranslateAccelerator(MainWindow->getHWnd(), hAccel, &messages) == 0) + { + // Translate virtual-key messages into character messages + TranslateMessage(&messages); + // Send message to WindowProcedure + DispatchMessage(&messages); + } + } + { + HRESULT hr=Input_DeInit(); +#ifdef DEBUG + if(FAILED(hr)) LOG("DirectInput deinit failed (0x%08X)\n",hr); + else LOG("DirectInput deinit\n"); +#endif + } +#ifdef DEBUG + LogStop(); +#endif + if (ViewLights!=NULL) delete ViewLights; + if (ViewMatrices!=NULL) delete ViewMatrices; + if (ViewOAM!=NULL) delete ViewOAM; + if (ViewMaps!=NULL) delete ViewMaps; + if (ViewTiles!=NULL) delete ViewTiles; + if (ViewPalette!=NULL) delete ViewPalette; + if (ViewRegisters!=NULL) delete ViewRegisters; + if (ViewMem_ARM9!=NULL) delete ViewMem_ARM9; + if (ViewMem_ARM7!=NULL) delete ViewMem_ARM7; + if (ViewDisasm_ARM9!=NULL) delete ViewDisasm_ARM9; + if (ViewDisasm_ARM7!=NULL) delete ViewDisasm_ARM7; + + delete MainWindow; + + CloseConsole(); + /* The program return-value is 0 - The value that PostQuitMessage() gave */ + return messages.wParam; +} + +void GetWndRect(HWND hwnd) +{ + POINT ptClient; + RECT rc; + + GetClientRect(hwnd,&rc); + ptClient.x=rc.left; + ptClient.y=rc.top; + ClientToScreen(hwnd,&ptClient); + MainWindowRect.left=ptClient.x; + MainWindowRect.top=ptClient.y; + ptClient.x=rc.right; + ptClient.y=rc.bottom; + ClientToScreen(hwnd,&ptClient); + MainWindowRect.right=ptClient.x; + MainWindowRect.bottom=ptClient.y; +} + +//======================================================================================== +void SetRotate(HWND hwnd, int rot) +{ + GPU_rotation = rot; + + switch (rot) + { + case 0: + GPU_width = 256; + GPU_height = 192*2; + rotationstartscan = 192; + rotationscanlines = 192*2; + break; + + case 90: + GPU_rotation = 90; + GPU_width = 192*2; + GPU_height = 256; + rotationstartscan = 0; + rotationscanlines = 256; + break; + + case 180: + GPU_rotation = 180; + GPU_width = 256; + GPU_height = 192*2; + rotationstartscan = 0; + rotationscanlines = 192*2; + break; + + case 270: + GPU_rotation = 270; + GPU_width = 192*2; + GPU_height = 256; + rotationstartscan = 0; + rotationscanlines = 256; + break; + } + + SetWindowClientSize(hwnd, GPU_width, GPU_height); + MainWindow->checkMenu(IDC_ROTATE0, MF_BYCOMMAND | ((GPU_rotation==0)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_ROTATE90, MF_BYCOMMAND | ((GPU_rotation==90)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_ROTATE180, MF_BYCOMMAND | ((GPU_rotation==180)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_ROTATE270, MF_BYCOMMAND | ((GPU_rotation==270)?MF_CHECKED:MF_UNCHECKED)); + WritePrivateProfileInt("Video","Window Rotate",GPU_rotation,IniName); +} +//======================================================================================== +LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + static int tmp_execute; + switch (message) // handle the messages + { + /*case WM_ENTERMENULOOP: // temporally removed it (freezes) + { + if (execute) + { + NDS_Pause(); + tmp_execute=2; + } else tmp_execute=-1; + return 0; + } + case WM_EXITMENULOOP: + { + if (tmp_execute==2) NDS_UnPause(); + return 0; + }*/ + + case WM_CREATE: + { + RECT clientSize, fullSize; + GetClientRect(hwnd, &clientSize); + GetWindowRect(hwnd, &fullSize); + DefaultWidth = clientSize.right - clientSize.left; + DefaultHeight = clientSize.bottom - clientSize.top; + widthTradeOff = (fullSize.right - fullSize.left) - (clientSize.right - clientSize.left); + heightTradeOff = (fullSize.bottom - fullSize.top) - (clientSize.bottom - clientSize.top); + + if ( (windowSize < 1) || (windowSize > 4) ) + { + int w=GetPrivateProfileInt("Video","Window width", 0, IniName); + int h=GetPrivateProfileInt("Video","Window height", 0, IniName); + if (w && h) + { + RECT fullSize = {0, 0, w, h}; + ResizingLimit(WMSZ_RIGHT, &fullSize); + + if (ForceRatio) + ScallingScreen(hwnd, WMSZ_RIGHT, &fullSize); + SetWindowPos(hwnd, NULL, 0, 0, fullSize.right - fullSize.left, + fullSize.bottom - fullSize.top, SWP_NOMOVE | SWP_NOZORDER); + } + else + windowSize=1; + } + if ( (windowSize > 0) && (windowSize < 5) ) ScaleScreen(hwnd, windowSize); + + return 0; + + } + case WM_DESTROY: + case WM_CLOSE: + { + NDS_Pause(); + finished = TRUE; + + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + if (windowSize==0) + { + WritePrivateProfileInt("Video","Window width",MainWindowRect.right-MainWindowRect.left+widthTradeOff,IniName); + WritePrivateProfileInt("Video","Window height",MainWindowRect.bottom-MainWindowRect.top+heightTradeOff,IniName); + } + + if (runthread != INVALID_HANDLE_VALUE) + { + if (WaitForSingleObject(runthread,INFINITE) == WAIT_TIMEOUT) + { + // Couldn't close thread cleanly + TerminateThread(runthread,0); + } + CloseHandle(runthread); + } + + NDS_DeInit(); + PostMessage(hwnd, WM_QUIT, 0, 0); + return 0; + } + case WM_MOVE: + GetWndRect(hwnd); + return 0; + case WM_SIZING: + { + RECT *rc=(RECT *)lParam; + + windowSize=0; + ResizingLimit(wParam, rc); + if (ForceRatio) + ScallingScreen(hwnd, wParam, rc); + //printlog("sizing: width=%i; height=%i\n", rc->right - rc->left, rc->bottom - rc->top); + } + break; + case WM_SIZE: + if (ForceRatio) { + if ( windowSize != 0 ) ScaleScreen(hwnd, windowSize); + } + GetWndRect(hwnd); + return 0; + case WM_DROPFILES: + { + char filename[MAX_PATH] = ""; + DragQueryFile((HDROP)wParam,0,filename,MAX_PATH); + DragFinish((HDROP)wParam); + if(LoadROM(filename, bad_glob_cflash_disk_image_file)) + { + EnableMenuItem(menu, IDM_EXEC, MF_GRAYED); + EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); + EnableMenuItem(menu, IDM_RESET, MF_ENABLED); + EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); + EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_ENABLED); + romloaded = TRUE; + NDS_UnPause(); + } + } + return 0; + case WM_MOUSEMOVE: + if (wParam & MK_LBUTTON) + { + RECT r ; + s32 x = (s32)((s16)LOWORD(lParam)); + s32 y = (s32)((s16)HIWORD(lParam)); + GetClientRect(hwnd,&r) ; + /* translate from scaling (screen reoltution to 256x384 or 512x192) */ + switch (GPU_rotation) + { + case 0: + case 180: + x = (x*256) / (r.right - r.left) ; + y = (y*384) / (r.bottom - r.top) ; + break ; + case 90: + case 270: + x = (x*512) / (r.right - r.left) ; + y = (y*192) / (r.bottom - r.top) ; + break ; + } + /* translate for rotation */ + if (GPU_rotation != 0) + translateXY(&x,&y); + else + y-=192; + if(x<0) x = 0; else if(x>255) x = 255; + if(y<0) y = 0; else if(y>192) y = 192; + NDS_setTouchPos(x, y); + return 0; + } + NDS_releasTouch(); + return 0; + case WM_LBUTTONDOWN: + if(HIWORD(lParam)>=192) + { + RECT r ; + s32 x = (s32)((s16)LOWORD(lParam)); + s32 y = (s32)((s16)HIWORD(lParam)); + GetClientRect(hwnd,&r) ; + /* translate from scaling (screen reoltution to 256x384 or 512x192) */ + switch (GPU_rotation) + { + case 0: + case 180: + x = (x*256) / (r.right - r.left) ; + y = (y*384) / (r.bottom - r.top) ; + break ; + case 90: + case 270: + x = (x*512) / (r.right - r.left) ; + y = (y*192) / (r.bottom - r.top) ; + break ; + } + /* translate for rotation */ + if (GPU_rotation != 0) + translateXY(&x,&y); + else + y-=192; + if(y>=0) + { + SetCapture(hwnd); + if(x<0) x = 0; else if(x>255) x = 255; + if(y<0) y = 0; else if(y>192) y = 192; + NDS_setTouchPos(x, y); + click = TRUE; + } + } + return 0; + case WM_LBUTTONUP: + if(click) + ReleaseCapture(); + NDS_releasTouch(); + return 0; + + case WM_COMMAND: + switch(LOWORD(wParam)) + { + case IDM_QUIT: + PostMessage(hwnd, WM_QUIT, 0, 0); + return 0; + case IDM_OPEN: + { + int filterSize = 0, i = 0; + OPENFILENAME ofn; + char filename[MAX_PATH] = "", + fileFilter[512]=""; + NDS_Pause(); //Stop emulation while opening new rom + + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + + // To avoid #ifdef hell, we'll do a little trick, as lpstrFilter + // needs 0 terminated string, and standard string library, of course, + // can't help us with string creation: just put a '|' were a string end + // should be, and later transform prior assigning to the OPENFILENAME structure + strncpy (fileFilter, "NDS ROM file (*.nds)|*.nds|NDS/GBA ROM File (*.ds.gba)|*.ds.gba|",512); +#ifdef HAVE_LIBZZIP + strncat (fileFilter, "Zipped NDS ROM file (*.zip)|*.zip|",512 - strlen(fileFilter)); +#endif +#ifdef HAVE_LIBZ + strncat (fileFilter, "GZipped NDS ROM file (*.gz)|*.gz|",512 - strlen(fileFilter)); +#endif + strncat (fileFilter, "Any file (*.*)|*.*||",512 - strlen(fileFilter)); + + filterSize = strlen(fileFilter); + for (i = 0; i < filterSize; i++) + { + if (fileFilter[i] == '|') fileFilter[i] = '\0'; + } + ofn.lpstrFilter = fileFilter; + ofn.nFilterIndex = 1; + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "nds"; + + if(!GetOpenFileName(&ofn)) + { + if (romloaded) + NDS_UnPause(); //Restart emulation if no new rom chosen + return 0; + } + + LOG("%s\r\n", filename); + + if(LoadROM(filename, bad_glob_cflash_disk_image_file)) + { + EnableMenuItem(menu, IDM_EXEC, MF_GRAYED); + EnableMenuItem(menu, IDM_PAUSE, MF_ENABLED); + EnableMenuItem(menu, IDM_RESET, MF_ENABLED); + EnableMenuItem(menu, IDM_GAME_INFO, MF_ENABLED); + EnableMenuItem(menu, IDM_IMPORTBACKUPMEMORY, MF_ENABLED); + romloaded = TRUE; + NDS_UnPause(); + } + } + return 0; + case IDM_PRINTSCREEN: + { + OPENFILENAME ofn; + char filename[MAX_PATH] = ""; + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "Bmp file (*.bmp)\0*.bmp\0Any file (*.*)\0*.*\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = filename; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "bmp"; + ofn.Flags = OFN_OVERWRITEPROMPT; + GetSaveFileName(&ofn); + NDS_WriteBMP(filename); + } + return 0; + case IDM_QUICK_PRINTSCREEN: + { + NDS_WriteBMP("./printscreen.bmp"); + } + return 0; + case IDM_STATE_LOAD: + { + OPENFILENAME ofn; + NDS_Pause(); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "DeSmuME Savestate (*.dst)\0*.dst\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = SavName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "dst"; + + if(!GetOpenFileName(&ofn)) + { + NDS_UnPause(); + return 0; + } + + savestate_load(SavName); + NDS_UnPause(); + } + return 0; + case IDM_STATE_SAVE: + { + OPENFILENAME ofn; + NDS_Pause(); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "DeSmuME Savestate (*.dst)\0*.dst\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = SavName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "dst"; + + if(!GetSaveFileName(&ofn)) + { + return 0; + } + + savestate_save(SavName); + NDS_UnPause(); + } + return 0; + case IDM_STATE_SAVE_F1: + StateSaveSlot(1); + return 0; + case IDM_STATE_SAVE_F2: + StateSaveSlot(2); + return 0; + case IDM_STATE_SAVE_F3: + StateSaveSlot(3); + return 0; + case IDM_STATE_SAVE_F4: + StateSaveSlot(4); + return 0; + case IDM_STATE_SAVE_F5: + StateSaveSlot(5); + return 0; + case IDM_STATE_SAVE_F6: + StateSaveSlot(6); + return 0; + case IDM_STATE_SAVE_F7: + StateSaveSlot(7); + return 0; + case IDM_STATE_SAVE_F8: + StateSaveSlot(8); + return 0; + case IDM_STATE_SAVE_F9: + StateSaveSlot(9); + return 0; + case IDM_STATE_SAVE_F10: + StateSaveSlot(10); + return 0; + case IDM_STATE_LOAD_F1: + StateLoadSlot(1); + return 0; + case IDM_STATE_LOAD_F2: + StateLoadSlot(2); + return 0; + case IDM_STATE_LOAD_F3: + StateLoadSlot(3); + return 0; + case IDM_STATE_LOAD_F4: + StateLoadSlot(4); + return 0; + case IDM_STATE_LOAD_F5: + StateLoadSlot(5); + return 0; + case IDM_STATE_LOAD_F6: + StateLoadSlot(6); + return 0; + case IDM_STATE_LOAD_F7: + StateLoadSlot(7); + return 0; + case IDM_STATE_LOAD_F8: + StateLoadSlot(8); + return 0; + case IDM_STATE_LOAD_F9: + StateLoadSlot(9); + return 0; + case IDM_STATE_LOAD_F10: + StateLoadSlot(10); + return 0; + case IDM_IMPORTBACKUPMEMORY: + { + OPENFILENAME ofn; + NDS_Pause(); + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwnd; + ofn.lpstrFilter = "All supported types\0*.duc;*.sav\0Action Replay DS Save (*.duc)\0*.duc\0DS-Xtreme Save (*.sav)\0*.sav\0\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile = ImportSavName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrDefExt = "duc"; + + if(!GetOpenFileName(&ofn)) + { + NDS_UnPause(); + return 0; + } + + if (!NDS_ImportSave(ImportSavName)) + MessageBox(hwnd,"Save was not successfully imported","Error",MB_OK); + NDS_UnPause(); + return 0; + } + case IDM_SOUNDSETTINGS: + { + bool tpaused=false; + if (execute) + { + tpaused=true; + NDS_Pause(); + } + DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_SOUNDSETTINGS), hwnd, (DLGPROC)SoundSettingsDlgProc); + if (tpaused) + NDS_UnPause(); + } + return 0; + case IDM_GAME_INFO: + { + CreateDialog(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_GAME_INFO), hwnd, GinfoView_Proc); + } + return 0; + +//========================================================= Tools + case IDM_PAL: + ViewPalette->open(); + return 0; + case IDM_TILE: + { + ViewTiles->regClass("TileViewBox", TileViewBoxProc); + ViewTiles->regClass("MiniTileViewBox", MiniTileViewBoxProc, true); + if (!ViewTiles->open()) + ViewTiles->unregClass(); + } + return 0; + case IDM_IOREG: + ViewRegisters->open(); + return 0; + case IDM_MEMORY: + ViewMem_ARM7->regClass("MemViewBox7", ViewMem_ARM7BoxProc); + if (!ViewMem_ARM7->open()) + ViewMem_ARM7->unregClass(); + ViewMem_ARM9->regClass("MemViewBox9", ViewMem_ARM9BoxProc); + if (!ViewMem_ARM9->open()) + ViewMem_ARM9->unregClass(); + return 0; + case IDM_DISASSEMBLER: + ViewDisasm_ARM7->regClass("DesViewBox7",ViewDisasm_ARM7BoxProc); + if (!ViewDisasm_ARM7->open()) + ViewDisasm_ARM7->unregClass(); + + ViewDisasm_ARM9->regClass("DesViewBox9",ViewDisasm_ARM9BoxProc); + if (!ViewDisasm_ARM9->open()) + ViewDisasm_ARM9->unregClass(); + return 0; + case IDM_MAP: + ViewMaps->open(); + return 0; + case IDM_OAM: + ViewOAM->regClass("OAMViewBox", ViewOAMBoxProc); + if (!ViewOAM->open()) + ViewOAM->unregClass(); + return 0; + + case IDM_MATRIX_VIEWER: + ViewMatrices->open(); + return 0; + + case IDM_LIGHT_VIEWER: + ViewLights->open(); + return 0; +//========================================================== Tools end + + case IDM_MBG0 : + if(MainScreen.gpu->dispBG[0]) + { + GPU_remove(MainScreen.gpu, 0); + MainWindow->checkMenu(IDM_MBG0, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(MainScreen.gpu, 0); + MainWindow->checkMenu(IDM_MBG0, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_MBG1 : + if(MainScreen.gpu->dispBG[1]) + { + GPU_remove(MainScreen.gpu, 1); + MainWindow->checkMenu(IDM_MBG1, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(MainScreen.gpu, 1); + MainWindow->checkMenu(IDM_MBG1, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_MBG2 : + if(MainScreen.gpu->dispBG[2]) + { + GPU_remove(MainScreen.gpu, 2); + MainWindow->checkMenu(IDM_MBG2, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(MainScreen.gpu, 2); + MainWindow->checkMenu(IDM_MBG2, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_MBG3 : + if(MainScreen.gpu->dispBG[3]) + { + GPU_remove(MainScreen.gpu, 3); + MainWindow->checkMenu(IDM_MBG3, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(MainScreen.gpu, 3); + MainWindow->checkMenu(IDM_MBG3, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_SBG0 : + if(SubScreen.gpu->dispBG[0]) + { + GPU_remove(SubScreen.gpu, 0); + MainWindow->checkMenu(IDM_SBG0, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(SubScreen.gpu, 0); + MainWindow->checkMenu(IDM_SBG0, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_SBG1 : + if(SubScreen.gpu->dispBG[1]) + { + GPU_remove(SubScreen.gpu, 1); + MainWindow->checkMenu(IDM_SBG1, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(SubScreen.gpu, 1); + MainWindow->checkMenu(IDM_SBG1, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_SBG2 : + if(SubScreen.gpu->dispBG[2]) + { + GPU_remove(SubScreen.gpu, 2); + MainWindow->checkMenu(IDM_SBG2, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(SubScreen.gpu, 2); + MainWindow->checkMenu(IDM_SBG2, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDM_SBG3 : + if(SubScreen.gpu->dispBG[3]) + { + GPU_remove(SubScreen.gpu, 3); + MainWindow->checkMenu(IDM_SBG3, MF_BYCOMMAND | MF_UNCHECKED); + } + else + { + GPU_addBack(SubScreen.gpu, 3); + MainWindow->checkMenu(IDM_SBG3, MF_BYCOMMAND | MF_CHECKED); + } + return 0; + + case ACCEL_SPACEBAR: + case IDM_PAUSE: + if (emu_paused) NDS_UnPause(); + else NDS_Pause(); + emu_paused ^= 1; + MainWindow->checkMenu(IDM_PAUSE, emu_paused ? MF_CHECKED : MF_UNCHECKED); + return 0; + + case ACCEL_N: //Frame Advance + frameAdvance = true; + execute = TRUE; + emu_paused = 1; + MainWindow->checkMenu(IDM_PAUSE, emu_paused ? MF_CHECKED : MF_UNCHECKED); + return 0; + + case ID_VIEW_FRAMECOUNTER: + frameCounterDisplay ^= 1; + MainWindow->checkMenu(ID_VIEW_FRAMECOUNTER, frameCounterDisplay ? MF_CHECKED : MF_UNCHECKED); + return 0; + + case ID_VIEW_DISPLAYFPS: + FpsDisplay ^= 1; + MainWindow->checkMenu(ID_VIEW_DISPLAYFPS, FpsDisplay ? MF_CHECKED : MF_UNCHECKED); + WritePrivateProfileInt("Video", "Display Fps", FpsDisplay, IniName); + return 0; + + #define saver(one,two,three,four,five, six) \ + MainWindow->checkMenu(IDC_SAVETYPE1, MF_BYCOMMAND | one); \ + MainWindow->checkMenu(IDC_SAVETYPE2, MF_BYCOMMAND | two); \ + MainWindow->checkMenu(IDC_SAVETYPE3, MF_BYCOMMAND | three); \ + MainWindow->checkMenu(IDC_SAVETYPE4, MF_BYCOMMAND | four); \ + MainWindow->checkMenu(IDC_SAVETYPE5, MF_BYCOMMAND | five); \ + MainWindow->checkMenu(IDC_SAVETYPE6, MF_BYCOMMAND | six); + + case IDC_SAVETYPE1: + saver(MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); + mmu_select_savetype(0,&backupmemorytype,&backupmemorysize); + return 0; + case IDC_SAVETYPE2: + saver(MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); + mmu_select_savetype(1,&backupmemorytype,&backupmemorysize); + return 0; + case IDC_SAVETYPE3: + saver(MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED); + mmu_select_savetype(2,&backupmemorytype,&backupmemorysize); + return 0; + case IDC_SAVETYPE4: + saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED,MF_UNCHECKED); + mmu_select_savetype(3,&backupmemorytype,&backupmemorysize); + return 0; + case IDC_SAVETYPE5: + saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED,MF_UNCHECKED); + mmu_select_savetype(4,&backupmemorytype,&backupmemorysize); + return 0; + case IDC_SAVETYPE6: + saver(MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_UNCHECKED,MF_CHECKED); + mmu_select_savetype(5,&backupmemorytype,&backupmemorysize); + return 0; + + case IDM_RESET: + NDS_Reset(); + frameCounter=0; + return 0; + case IDM_CONFIG: + { + bool tpaused=false; + if (execute) + { + tpaused=true; + NDS_Pause(); + } + InputConfig(hwnd); + if (tpaused) + NDS_UnPause(); + } + return 0; + case IDM_FIRMSETTINGS: + { + bool tpaused=false; + if (execute) + { + tpaused=true; + NDS_Pause(); + } + DialogBox(hAppInst,MAKEINTRESOURCE(IDD_FIRMSETTINGS), hwnd, (DLGPROC) FirmConfig_Proc); + if (tpaused) + NDS_UnPause(); + + return 0; + } + case IDC_FRAMESKIPAUTO: + case IDC_FRAMESKIP0: + case IDC_FRAMESKIP1: + case IDC_FRAMESKIP2: + case IDC_FRAMESKIP3: + case IDC_FRAMESKIP4: + case IDC_FRAMESKIP5: + case IDC_FRAMESKIP6: + case IDC_FRAMESKIP7: + case IDC_FRAMESKIP8: + case IDC_FRAMESKIP9: + { + if(LOWORD(wParam) == IDC_FRAMESKIPAUTO) + { + autoframeskipenab = 1; + WritePrivateProfileString("Video", "FrameSkip", "AUTO", IniName); + } + else + { + char text[80]; + autoframeskipenab = 0; + frameskiprate = LOWORD(wParam) - IDC_FRAMESKIP0; + sprintf(text, "%d", frameskiprate); + WritePrivateProfileString("Video", "FrameSkip", text, IniName); + } + + MainWindow->checkMenu(IDC_FRAMESKIPAUTO, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP0, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP1, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP2, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP3, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP4, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP5, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP6, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP7, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP8, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(IDC_FRAMESKIP9, MF_BYCOMMAND | MF_UNCHECKED); + MainWindow->checkMenu(LOWORD(wParam), MF_BYCOMMAND | MF_CHECKED); + } + return 0; + case IDC_LANGENGLISH: + SaveLanguage(0); + ChangeLanguage(0); + CheckLanguage(LOWORD(wParam)); + return 0; + case IDC_LANGFRENCH: + SaveLanguage(1); + ChangeLanguage(1); + CheckLanguage(LOWORD(wParam)); + return 0; + case IDC_LANGDANISH: + SaveLanguage(1); + ChangeLanguage(2); + CheckLanguage(LOWORD(wParam)); + return 0; + case IDM_WEBSITE: + ShellExecute(NULL, "open", "http://desmume.sourceforge.net", NULL, NULL, SW_SHOWNORMAL); + return 0; + + case IDM_FORUM: + ShellExecute(NULL, "open", "http://forums.desmume.org/index.php", NULL, NULL, SW_SHOWNORMAL); + return 0; + + case IDM_ABOUT: + { + bool tpaused=false; + if (execute) + { + tpaused=true; + NDS_Pause(); + } + DialogBox(hAppInst,MAKEINTRESOURCE(IDD_ABOUT_BOX), hwnd, (DLGPROC) AboutBox_Proc); + if (tpaused) + NDS_UnPause(); + + return 0; + } + +#ifndef BETA_VERSION + case IDM_SUBMITBUGREPORT: + ShellExecute(NULL, "open", "http://sourceforge.net/tracker/?func=add&group_id=164579&atid=832291", NULL, NULL, SW_SHOWNORMAL); + return 0; +#endif + + case IDC_ROTATE0: + SetRotate(hwnd, 0); + return 0; + case IDC_ROTATE90: + SetRotate(hwnd, 90); + return 0; + case IDC_ROTATE180: + SetRotate(hwnd, 180); + return 0; + case IDC_ROTATE270: + SetRotate(hwnd, 270); + return 0; + + case IDC_WINDOW1X: + windowSize=1; + ScaleScreen(hwnd, windowSize); + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + + MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?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)); + break; + case IDC_WINDOW2X: + windowSize=2; + ScaleScreen(hwnd, windowSize); + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + + MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?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)); + break; + case IDC_WINDOW3X: + windowSize=3; + ScaleScreen(hwnd, windowSize); + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + + MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?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)); + break; + case IDC_WINDOW4X: + windowSize=4; + ScaleScreen(hwnd, windowSize); + WritePrivateProfileInt("Video","Window Size",windowSize,IniName); + + MainWindow->checkMenu(IDC_WINDOW1X, MF_BYCOMMAND | ((windowSize==1)?MF_CHECKED:MF_UNCHECKED)); + MainWindow->checkMenu(IDC_WINDOW2X, MF_BYCOMMAND | ((windowSize==2)?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)); + break; + + case IDC_FORCERATIO: + if (ForceRatio) { + MainWindow->checkMenu(IDC_FORCERATIO, MF_BYCOMMAND | MF_UNCHECKED); + ForceRatio = FALSE; + WritePrivateProfileInt("Video","Window Force Ratio",0,IniName); + } + else { + RECT fullSize; + GetWindowRect(hwnd, &fullSize); + ScallingScreen(hwnd, WMSZ_RIGHT, &fullSize); + SetWindowPos(hwnd, NULL, 0, 0, fullSize.right - fullSize.left, + fullSize.bottom - fullSize.top, SWP_NOMOVE | SWP_NOZORDER); + //ScaleScreen(hwnd, (fullSize.bottom - fullSize.top - heightTradeOff) / DefaultHeight); + MainWindow->checkMenu(IDC_FORCERATIO, MF_BYCOMMAND | MF_CHECKED); + ForceRatio = TRUE; + WritePrivateProfileInt("Video","Window Force Ratio",1,IniName); + } + break; + + } + return 0; + default: /* for messages that we don't deal with */ + return DefWindowProc (hwnd, message, wParam, lParam); + } + + return 0; +} + +LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, + LPARAM lParam) +{ + static int timerid=0; + switch (uMsg) + { + case WM_INITDIALOG: + { + int i; + char tempstr[MAX_PATH]; + // Setup Sound Core Combo box + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_RESETCONTENT, 0, 0); + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (LPARAM)"None"); + + for (i = 1; SNDCoreList[i] != NULL; i++) + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (LPARAM)SNDCoreList[i]->Name); + + // Set Selected Sound Core + for (i = 0; SNDCoreList[i] != NULL; i++) + { + if (sndcoretype == SNDCoreList[i]->id) + SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_SETCURSEL, i, 0); + } + + // Setup Sound Buffer Size Edit Text + sprintf(tempstr, "%d", sndbuffersize); + SetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr); + + // Setup Volume Slider + SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_SETRANGE, 0, MAKELONG(0, 100)); + + // Set Selected Volume + SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_SETPOS, TRUE, sndvolume); + + timerid = SetTimer(hDlg, 1, 500, NULL); + return TRUE; + } + case WM_TIMER: + { + if (timerid == wParam) + { + int setting; + setting = SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_GETPOS, 0, 0); + SPU_SetVolume(setting); + break; + } + break; + } + case WM_COMMAND: + { + switch (LOWORD(wParam)) + { + case IDOK: + { + char tempstr[MAX_PATH]; + + EndDialog(hDlg, TRUE); + + // Write Sound core type + sndcoretype = SNDCoreList[SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_GETCURSEL, 0, 0)]->id; + sprintf(tempstr, "%d", sndcoretype); + WritePrivateProfileString("Sound", "SoundCore", tempstr, IniName); + + // Write Sound Buffer size + GetDlgItemText(hDlg, IDC_SOUNDBUFFERET, tempstr, 6); + sscanf(tempstr, "%d", &sndbuffersize); + WritePrivateProfileString("Sound", "SoundBufferSize", tempstr, IniName); + + SPU_ChangeSoundCore(sndcoretype, sndbuffersize); + + // Write Volume + sndvolume = SendDlgItemMessage(hDlg, IDC_SLVOLUME, TBM_GETPOS, 0, 0); + sprintf(tempstr, "%d", sndvolume); + WritePrivateProfileString("Sound", "Volume", tempstr, IniName); + SPU_SetVolume(sndvolume); + + return TRUE; + } + case IDCANCEL: + { + EndDialog(hDlg, FALSE); + return TRUE; + } + default: break; + } + + break; + } + case WM_DESTROY: + { + if (timerid != 0) + KillTimer(hDlg, timerid); + break; + } + } + + return FALSE; +} + + diff --git a/desmume/src/windows/mapView.cpp b/desmume/src/windows/mapView.cpp index 2ad5b394c..1fe5cf1e3 100644 --- a/desmume/src/windows/mapView.cpp +++ b/desmume/src/windows/mapView.cpp @@ -19,14 +19,24 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "mapview.h" -#include "resource.h" +#include "mapView.h" +#include #include "../MMU.h" #include "../NDSSystem.h" +#include "debug.h" +#include "resource.h" -#include +typedef struct +{ + u32 autoup_secs; + bool autoup; -////////////////////////////////////////////////////////////////////////////// + u16 map; + u16 lcd; + u16 bitmap[1024*1024]; +} mapview_struct; + +mapview_struct *MapView = NULL; LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM lParam) { @@ -205,15 +215,19 @@ LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM l return 0; } -////////////////////////////////////////////////////////////////////////////// - -BOOL CALLBACK MapView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - mapview_struct * win = (mapview_struct *)GetWindowLong(hwnd, DWL_USER); - switch (message) + switch (message) { case WM_INITDIALOG : { + MapView = new mapview_struct; + memset(MapView, 0, sizeof(MapView)); + MapView->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, MapView->autoup_secs); HWND combo = GetDlgItem(hwnd, IDC_BG_SELECT); SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 0"); SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 1"); @@ -227,21 +241,62 @@ BOOL CALLBACK MapView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara } return 1; case WM_CLOSE : - CWindow_RemoveFromRefreshList(win); - MapView_Deinit(win); - EndDialog(hwnd, 0); - return 1; + { + if(MapView->autoup) + { + KillTimer(hwnd, IDT_VIEW_MAP); + MapView->autoup = false; + } + if (MapView!=NULL) + { + delete MapView; + MapView = NULL; + } + //printlog("Close Map view dialog\n"); + PostQuitMessage(0); + return 0; + } case WM_PAINT: - MapView_OnPaint(win, hwnd, wParam, lParam); + MapView_OnPaint(MapView, hwnd, wParam, lParam); return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; case WM_COMMAND : switch (LOWORD (wParam)) { case IDC_FERMER : - CWindow_RemoveFromRefreshList(win); - MapView_Deinit(win); - EndDialog(hwnd, 0); + SendMessage(hwnd, WM_CLOSE, 0, 0); return 1; + case IDC_AUTO_UPDATE : + if(MapView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_MAP); + MapView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + MapView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_MAP, MapView->autoup_secs*1000, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != MapView->autoup_secs) + { + MapView->autoup_secs = t; + if (MapView->autoup) + SetTimer(hwnd, IDT_VIEW_MAP, + MapView->autoup_secs*1000, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; case IDC_BG_SELECT : switch(HIWORD(wParam)) { @@ -255,54 +310,23 @@ BOOL CALLBACK MapView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara case 1 : case 2 : case 3 : - win->map = sel; - win->lcd = 0; + MapView->map = sel; + MapView->lcd = 0; break; case 4 : case 5 : case 6 : case 7 : - win->map = sel-4; - win->lcd = 1; + MapView->map = sel-4; + MapView->lcd = 1; break; } } - CWindow_Refresh(win); + InvalidateRect(hwnd, NULL, FALSE); return 1; }//switch et case }//switch return 1; } - return 0; + return DefWindowProc(hwnd, message, wParam, lParam); } - -////////////////////////////////////////////////////////////////////////////// - -mapview_struct *MapView_Init(HINSTANCE hInst, HWND parent) -{ - mapview_struct *MapView=NULL; - - if ((MapView = (mapview_struct *)malloc(sizeof(mapview_struct))) == NULL) - return MapView; - - if (CWindow_Init2(MapView, hInst, parent, "Map viewer", IDD_MAP, MapView_Proc) != 0) - { - free(MapView); - return NULL; - } - - MapView->map = 0; - MapView->lcd = 0; - - return MapView; -} - -////////////////////////////////////////////////////////////////////////////// - -void MapView_Deinit(mapview_struct *MapView) -{ - if (MapView) - free(MapView); -} - -////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/mapView.h b/desmume/src/windows/mapView.h index dd0cd20ff..876daa3b8 100644 --- a/desmume/src/windows/mapView.h +++ b/desmume/src/windows/mapView.h @@ -22,23 +22,8 @@ #ifndef MAPVIEW_H #define MAPVIEW_H -#include "CWindow.h" +#include -typedef struct -{ - HWND hwnd; - BOOL autoup; - void *prev; - void *next; - void *first; - void (*Refresh)(void *win); +extern BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - u16 map; - u16 lcd; - u16 bitmap[1024*1024]; -} mapview_struct; - -mapview_struct *MapView_Init(HINSTANCE hInst, HWND parent); -void MapView_Deinit(mapview_struct *MapView); - -#endif +#endif \ No newline at end of file diff --git a/desmume/src/windows/matrixView.cpp b/desmume/src/windows/matrixView.cpp index 11ab3563c..48f8ab882 100644 --- a/desmume/src/windows/matrixView.cpp +++ b/desmume/src/windows/matrixView.cpp @@ -17,18 +17,21 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include #include "matrixView.h" +#include +#include "debug.h" #include "resource.h" -#include "matrix.h" -#include "armcpu.h" #include "gfx3d.h" +typedef struct +{ + u32 autoup_secs; + bool autoup; +} matrixview_struct; -////////////////////////////////////////////////////////////////////////////// +matrixview_struct *MatrixView = NULL; -void MatrixView_SetMatrix(matrixview_struct* win, const int* idcs, float* matrix) +void MatrixView_SetMatrix(HWND hwnd, const int* idcs, float* matrix) { int n; char buffer[64]; @@ -37,52 +40,11 @@ void MatrixView_SetMatrix(matrixview_struct* win, const int* idcs, float* matrix { sprintf(buffer, "%.4f", matrix[n]); //sprintf(buffer, "%.8x", (int)(matrix[n]*4096)); - SetWindowText(GetDlgItem(win->window.hwnd, idcs[n]), buffer); + SetWindowText(GetDlgItem(hwnd, idcs[n]), buffer); } } -////////////////////////////////////////////////////////////////////////////// - -BOOL MatrixView_OnInitDialog(HWND hwnd) -{ - int n; - HWND hPosCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_COORD_COMBO); - HWND hDirCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_DIR_COMBO); - - // Setup position and direction matrix comboboxes with stack indices - SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)"Current"); - SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)"Current"); - - for(n = 0; n < 32; n++) - { - char buffer[4]; - - sprintf(buffer, "%d", n); - SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)buffer); - SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)buffer); - } - - SendMessage(hPosCombo, CB_SETCURSEL, 0, 0); - SendMessage(hDirCombo, CB_SETCURSEL, 0, 0); - - return TRUE; -} - -////////////////////////////////////////////////////////////////////////////// - -BOOL MatrixView_OnClose(matrixview_struct* win) -{ - win->window.autoup = FALSE; - CWindow_RemoveFromRefreshList(win); - EndDialog(win->window.hwnd, 0); - MatrixView_Deinit(win); - - return TRUE; -} - -////////////////////////////////////////////////////////////////////////////// - -void MatrixView_OnPaintPositionMatrix(matrixview_struct* win) +void MatrixView_OnPaintPositionMatrix(HWND hwnd) { // IDC for each matrix coefficient const int idcGroup[16] = @@ -94,18 +56,18 @@ void MatrixView_OnPaintPositionMatrix(matrixview_struct* win) }; float matrix[16]; - HWND hStackCombo = GetDlgItem(win->window.hwnd, IDC_MATRIX_VIEWER_COORD_COMBO); + HWND hStackCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_COORD_COMBO); int stackIndex; stackIndex = SendMessage(hStackCombo, CB_GETCURSEL, 0, 0) - 1; gfx3d_glGetMatrix(1, stackIndex, matrix); - MatrixView_SetMatrix(win, idcGroup, matrix); + MatrixView_SetMatrix(hwnd, idcGroup, matrix); } ////////////////////////////////////////////////////////////////////////////// -void MatrixView_OnPaintDirectionMatrix(matrixview_struct* win) +void MatrixView_OnPaintDirectionMatrix(HWND hwnd) { // IDC for each matrix coefficient const int idcGroup[16] = @@ -117,18 +79,18 @@ void MatrixView_OnPaintDirectionMatrix(matrixview_struct* win) }; float matrix[16]; - HWND hStackCombo = GetDlgItem(win->window.hwnd, IDC_MATRIX_VIEWER_DIR_COMBO); + HWND hStackCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_DIR_COMBO); int stackIndex; stackIndex = SendMessage(hStackCombo, CB_GETCURSEL, 0, 0) - 1; gfx3d_glGetMatrix(2, stackIndex, matrix); - MatrixView_SetMatrix(win, idcGroup, matrix); + MatrixView_SetMatrix(hwnd, idcGroup, matrix); } ////////////////////////////////////////////////////////////////////////////// -void MatrixView_OnPaintProjectionMatrix(matrixview_struct* win) +void MatrixView_OnPaintProjectionMatrix(HWND hwnd) { // IDC for each matrix coefficient const int idcGroup[16] = @@ -142,12 +104,12 @@ void MatrixView_OnPaintProjectionMatrix(matrixview_struct* win) float mat[16]; gfx3d_glGetMatrix(0, -1, mat); - MatrixView_SetMatrix(win, idcGroup, mat); + MatrixView_SetMatrix(hwnd, idcGroup, mat); } ////////////////////////////////////////////////////////////////////////////// -void MatrixView_OnPaintTextureMatrix(matrixview_struct* win) +void MatrixView_OnPaintTextureMatrix(HWND hwnd) { // IDC for each matrix coefficient const int idcGroup[16] = @@ -161,98 +123,130 @@ void MatrixView_OnPaintTextureMatrix(matrixview_struct* win) float mat[16]; gfx3d_glGetMatrix(3, -1, mat); - MatrixView_SetMatrix(win, idcGroup, mat); + MatrixView_SetMatrix(hwnd, idcGroup, mat); } -////////////////////////////////////////////////////////////////////////////// - -BOOL MatrixView_OnPaint(matrixview_struct* win, HWND hwnd, WPARAM wParam, LPARAM lParam) +BOOL MatrixView_OnPaint( HWND hwnd, WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; hdc = BeginPaint(hwnd, &ps); - MatrixView_OnPaintProjectionMatrix(win); - MatrixView_OnPaintPositionMatrix(win); - MatrixView_OnPaintDirectionMatrix(win); - MatrixView_OnPaintTextureMatrix(win); + MatrixView_OnPaintProjectionMatrix(hwnd); + MatrixView_OnPaintPositionMatrix(hwnd); + MatrixView_OnPaintDirectionMatrix(hwnd); + MatrixView_OnPaintTextureMatrix(hwnd); EndPaint(hwnd, &ps); return TRUE; } -////////////////////////////////////////////////////////////////////////////// - -BOOL CALLBACK MatrixView_Proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK ViewMatricesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - matrixview_struct *win = (matrixview_struct *)GetWindowLong(hwnd, DWL_USER); - switch (message) { case WM_INITDIALOG: - return MatrixView_OnInitDialog(hwnd); + { + MatrixView = new matrixview_struct; + memset(MatrixView, 0, sizeof(matrixview_struct)); + MatrixView->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, MatrixView->autoup_secs); + int n; + HWND hPosCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_COORD_COMBO); + HWND hDirCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_DIR_COMBO); + + // Setup position and direction matrix comboboxes with stack indices + SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)"Current"); + SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)"Current"); + + for(n = 0; n < 32; n++) + { + char buffer[4]; + + sprintf(buffer, "%d", n); + SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)buffer); + SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)buffer); + } + + SendMessage(hPosCombo, CB_SETCURSEL, 0, 0); + SendMessage(hDirCombo, CB_SETCURSEL, 0, 0); + return 1; + } case WM_CLOSE: - return MatrixView_OnClose(win); + { + if(MatrixView->autoup) + { + KillTimer(hwnd, IDT_VIEW_MATRIX); + MatrixView->autoup = false; + } + + if (MatrixView!=NULL) + { + delete MatrixView; + MatrixView = NULL; + } + //printlog("Close Matrix view dialog\n"); + PostQuitMessage(0); + return 0; + } case WM_PAINT: - return MatrixView_OnPaint(win, hwnd, wParam, lParam); + MatrixView_OnPaint(hwnd, wParam, lParam); + return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; case WM_COMMAND: switch (LOWORD (wParam)) { case IDOK: - CWindow_RemoveFromRefreshList(win); - MatrixView_Deinit(win); - EndDialog(hwnd, 0); + SendMessage(hwnd, WM_CLOSE, 0, 0); return 1; + case IDC_AUTO_UPDATE : + if(MatrixView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_MATRIX); + MatrixView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + MatrixView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_MATRIX, MatrixView->autoup_secs*1000, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != MatrixView->autoup_secs) + { + MatrixView->autoup_secs = t; + if (MatrixView->autoup) + SetTimer(hwnd, IDT_VIEW_MATRIX, + MatrixView->autoup_secs*1000, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_MATRIX_VIEWER_DIR_COMBO: case IDC_MATRIX_VIEWER_COORD_COMBO: InvalidateRect(hwnd, NULL, FALSE); return 1; } return 0; - - case WM_SYSCOMMAND: - switch (LOWORD (wParam)) - { - case IDC_AUTO_UPDATE: - CWindow_ToggleAutoUpdate(win); - return 1; - } - return 0; } - return 0; + return DefWindowProc(hwnd, message, wParam, lParam); } - -////////////////////////////////////////////////////////////////////////////// - -matrixview_struct *MatrixView_Init(HINSTANCE hInst, HWND parent) -{ - matrixview_struct *MatrixView=NULL; - - if ((MatrixView = (matrixview_struct *)malloc(sizeof(matrixview_struct))) == NULL) - return NULL; - - if (CWindow_Init2(&MatrixView->window, hInst, parent, "Matrix viewer", IDD_MATRIX_VIEWER, MatrixView_Proc) != 0) - { - free(MatrixView); - return NULL; - } - - return MatrixView; -} - -////////////////////////////////////////////////////////////////////////////// - -void MatrixView_Deinit(matrixview_struct *MatrixView) -{ - if (MatrixView) - free(MatrixView); -} - -////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/matrixView.h b/desmume/src/windows/matrixView.h index 9f1e3c754..c49656543 100644 --- a/desmume/src/windows/matrixView.h +++ b/desmume/src/windows/matrixView.h @@ -20,15 +20,8 @@ #ifndef MATRIXVIEW_H #define MATRIXVIEW_H -#include "CWindow.h" +#include -typedef struct -{ - cwindow_struct window; -} matrixview_struct; +extern BOOL CALLBACK ViewMatricesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); -matrixview_struct *MatrixView_Init(HINSTANCE hInst, HWND parent); -void MatrixView_Deinit(matrixview_struct *MatrixView); - -#endif - +#endif \ No newline at end of file diff --git a/desmume/src/windows/memView.cpp b/desmume/src/windows/memView.cpp index 1165fedba..0df27eebe 100644 --- a/desmume/src/windows/memView.cpp +++ b/desmume/src/windows/memView.cpp @@ -1,580 +1,506 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include "memView.h" +#include +#include "../MMU.h" +#include "debug.h" +#include "resource.h" + +typedef struct +{ + u32 autoup_secs; + bool autoup; - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include -#include "memView.h" -#include "../MMU.h" -#include "resource.h" - -LRESULT CALLBACK MemViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -void InitMemViewBox() -{ - WNDCLASSEX wc; - - wc.cbSize = sizeof(wc); - wc.lpszClassName = _T("MemViewBox"); - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = MemViewBoxWndProc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(cwindow_struct *); - wc.hIconSm = 0; - - RegisterClassEx(&wc); -} - -/* -LRESULT MemViewBox_OnPaint(CMemView * win, WPARAM wParam, LPARAM lParam) -{ - HWND hwnd = GetDlgItem(win->hwnd, IDC_MEM_BOX); - HDC hdc; - PAINTSTRUCT ps; - SIZE fontsize; - TCHAR text[80]; - - RECT rect; - GetClientRect(hwnd, &rect); - int lg = rect.right - rect.left; - int ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - HDC mem_dc = CreateCompatibleDC(hdc); - HBITMAP mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT)); - - GetTextExtentPoint32(mem_dc, "0", 1, &fontsize); - - int nbligne = ht/fontsize.cy; - - SetTextColor(mem_dc, RGB(0,0,0)); - - RECT r; - - r.top = 3; - r.left = 3; - r.bottom = r.top+fontsize.cy; - r.right = rect.right-3; - - u32 adr = win->curr_ligne*0x10; - - for(int i=0; i>16), (int)(adr&0xFFFF)); - DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); - r.left += 11*fontsize.cx; - int j; - - if(win->representation == 0) - for(j=0; j<16; ++j) - { - sprintf(text, "%02X", MMU_read8(win->cpu, adr+j)); - DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); - r.left+=3*fontsize.cx; - } - else - if(win->representation == 1) - for(j=0; j<16; j+=2) - { - sprintf(text, "%04X", MMU_read16(win->cpu, adr+j)); - DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); - r.left+=5*fontsize.cx; - } - else - for(j=0; j<16; j+=4) - { - sprintf(text, "%08X", (int)MMU_read32(win->cpu, adr+j)); - DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); - r.left+=9*fontsize.cx; - } - - r.left+=fontsize.cx; - - for(j=0; j<16; ++j) - { - u8 c = MMU_read8(win->cpu, adr+j); - if(c >= 32 && c <= 127) { - text[j] = (char)c; - } - else - text[j] = '.'; - } - text[j] = '\0'; - DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); - - adr+=0x10; - r.top += fontsize.cy; - r.bottom += fontsize.cy; - r.left = 3; - } - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - return 1; -} - -LRESULT CALLBACK MemViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - CMemView * win = (CMemView *)GetWindowLong(hwnd, 0); - - switch(msg) - { - case WM_NCCREATE: - SetScrollRange(hwnd, SB_VERT, 0, 0x0FFFFFFF, TRUE); - SetScrollPos(hwnd, SB_VERT, 10, TRUE); - return 1; - - case WM_NCDESTROY: - return 1; - - case WM_PAINT: - MemViewBox_OnPaint(win, wParam, lParam); - return 1; - - case WM_ERASEBKGND: - return 1; - case WM_VSCROLL : - { - RECT rect; - SIZE fontsize; - GetClientRect(hwnd, &rect); - HDC dc = GetDC(hwnd); - HFONT old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); - GetTextExtentPoint32(dc, "0", 1, &fontsize); - - int nbligne = (rect.bottom - rect.top)/fontsize.cy; - - switch LOWORD(wParam) + s8 cpu; + u32 curr_ligne; + u8 representation; +} memview_struct; + + +memview_struct *MemView7 = NULL; +memview_struct *MemView9 = NULL; + +LRESULT MemViewBox_OnPaint(HWND hwnd, memview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + SIZE fontsize; + TCHAR text[80]; + int i; + RECT rect; + int lg; + int ht; + HDC mem_dc; + HBITMAP mem_bmp; + int nbligne; + RECT r; + u32 adr; + + GetClientRect(hwnd, &rect); + lg = rect.right - rect.left; + ht = rect.bottom - rect.top; + + hdc = BeginPaint(hwnd, &ps); + + mem_dc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT)); + + GetTextExtentPoint32(mem_dc, "0", 1, &fontsize); + + nbligne = ht/fontsize.cy; + + SetTextColor(mem_dc, RGB(0,0,0)); + + r.top = 3; + r.left = 3; + r.bottom = r.top+fontsize.cy; + r.right = rect.right-3; + + adr = win->curr_ligne*0x10; + printlog("curr_ligne=%i\n", win->curr_ligne); + + for(i=0; i>16), (int)(adr&0xFFFF)); + DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); + r.left += 11*fontsize.cx; + + if(win->representation == 0) + for(j=0; j<16; ++j) + { + sprintf(text, "%02X", MMU_read8(win->cpu, adr+j)); + DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); + r.left+=3*fontsize.cx; + } + else + if(win->representation == 1) + for(j=0; j<16; j+=2) + { + sprintf(text, "%04X", MMU_read16(win->cpu, adr+j)); + DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); + r.left+=5*fontsize.cx; + } + else + for(j=0; j<16; j+=4) + { + sprintf(text, "%08X", (int)MMU_read32(win->cpu, adr+j)); + DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); + r.left+=9*fontsize.cx; + } + + r.left+=fontsize.cx; + + for(j=0; j<16; ++j) + { + u8 c = MMU_read8(win->cpu, adr+j); + if(c >= 32 && c <= 127) { + text[j] = (char)c; + } + else + text[j] = '.'; + } + text[j] = '\0'; + DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); + + adr+=0x10; + r.top += fontsize.cy; + r.bottom += fontsize.cy; + r.left = 3; + } + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 1; +} + +//=================================================== ARM7 +LRESULT CALLBACK ViewMem_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_NCCREATE: + SetScrollRange(hwnd, SB_VERT, 0, 0x0FFFFFFF, TRUE); + SetScrollPos(hwnd, SB_VERT, 10, TRUE); + return 1; + + case WM_NCDESTROY: + return 1; + + case WM_PAINT: + MemViewBox_OnPaint(hwnd, MemView7, wParam, lParam); + return 1; + + case WM_ERASEBKGND: + return 1; + case WM_VSCROLL : + { + RECT rect; + SIZE fontsize; + HDC dc; + HFONT old; + int nbligne; + + GetClientRect(hwnd, &rect); + dc = GetDC(hwnd); + old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); + GetTextExtentPoint32(dc, "0", 1, &fontsize); + + nbligne = (rect.bottom - rect.top)/fontsize.cy; + + switch LOWORD(wParam) + { + case SB_LINEDOWN : + MemView7->curr_ligne = std::min((u32)0x0FFFFFFFF, (u32)MemView7->curr_ligne+1); + break; + case SB_LINEUP : + MemView7->curr_ligne = (u32)std::max((u32)0l, (u32)MemView7->curr_ligne-1); + break; + case SB_PAGEDOWN : + MemView7->curr_ligne = std::min((u32)0x0FFFFFFFF, (u32)MemView7->curr_ligne+nbligne); + break; + case SB_PAGEUP : + MemView7->curr_ligne = (u32)std::max((u32)0l, (u32)MemView7->curr_ligne-nbligne); + break; + } + + SelectObject(dc, old); + SetScrollPos(hwnd, SB_VERT, MemView7->curr_ligne, TRUE); + InvalidateRect(hwnd, NULL, FALSE); + UpdateWindow(hwnd); + } + return 1; + } + + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +bool CALLBACK ViewMem_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + + switch (message) + { + case WM_INITDIALOG : + { + SetWindowText(hwnd, "ARM7 memory viewer"); + SendMessage(GetDlgItem(hwnd, IDC_8_BIT), BM_SETCHECK, TRUE, 0); + MemView7 = new memview_struct; + memset(MemView7, 0, sizeof(memview_struct)); + MemView7->cpu = 1; + MemView7->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, MemView7->autoup_secs); + return 0; + } + case WM_CLOSE: + { + if(MemView7->autoup) + { + KillTimer(hwnd, IDT_VIEW_MEM7); + MemView7->autoup = false; + } + + if (MemView7!=NULL) + { + delete MemView7; + MemView7 = NULL; + } + //printlog("Close ARM7 memory dialog\n"); + PostQuitMessage(0); + return 0; + } + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_8_BIT : + MemView7->representation = 0; + InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); + UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); + return 1; + case IDC_16_BIT : + MemView7->representation = 1; + InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); + UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); + return 1; + case IDC_32_BIT : + MemView7->representation = 2; + InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); + UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); + return 1; + case IDC_AUTO_UPDATE : + if(MemView7->autoup) { - case SB_LINEDOWN : - win->curr_ligne = min(0X0FFFFFFFF, win->curr_ligne+1); - break; - case SB_LINEUP : - win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-1); - break; - case SB_PAGEDOWN : - win->curr_ligne = min(0X0FFFFFFFF, win->curr_ligne+nbligne); - break; - case SB_PAGEUP : - win->curr_ligne = (u32)max(0, (s32)win->curr_ligne-nbligne); - break; - } - - SelectObject(dc, old); - SetScrollPos(hwnd, SB_VERT, win->curr_ligne, TRUE); - InvalidateRect(hwnd, NULL, FALSE); - UpdateWindow(hwnd); - } - return 1; - - default: - break; - } - - return DefWindowProc(hwnd, msg, wParam, lParam); -} - - -// MEM VIEWER -BOOL CALLBACK mem_view_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - CMemView * win = (CMemView *)GetWindowLong(hwnd, DWL_USER); - switch (message) - { - case WM_INITDIALOG : - SendMessage(GetDlgItem(hwnd, IDC_8_BIT), BM_SETCHECK, TRUE, 0); - return 1; - case WM_CLOSE : - win->remove2RefreshList(); - delete win; - EndDialog(hwnd, 0); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_8_BIT : - win->representation = 0; - InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); - return 1; - case IDC_16_BIT : - win->representation = 1; - InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); - return 1; - case IDC_32_BIT : - win->representation = 2; - InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); - return 1; - case IDC_AUTO_UPDATE : - if(win->autoup) - { - win->remove2RefreshList(); - win->autoup = FALSE; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_MEM7); + MemView7->autoup = FALSE; return 1; } - win->add2RefreshList(); - win->autoup = TRUE; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + MemView7->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_MEM7, MemView7->autoup_secs*1000, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != MemView7->autoup_secs) + { + MemView7->autoup_secs = t; + if (MemView7->autoup) + SetTimer(hwnd, IDT_VIEW_MEM7, + MemView7->autoup_secs*1000, (TIMERPROC) NULL); + } + } return 1; - case IDC_GO : + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_GO : + { + char tmp[8]; + int lg = GetDlgItemText(hwnd, IDC_GOTOMEM, tmp, 8); + u32 adr = 0; + u16 i; + + for(i = 0; i='A')&&(tmp[i]<='F')) + { + adr = adr*16 + (tmp[i]-'A'+10); + continue; + } + if((tmp[i]>='0')&&(tmp[i]<='9')) + { + adr = adr*16 + (tmp[i]-'0'); + continue; + } + } + MemView7->curr_ligne = (adr>>4); + InvalidateRect(hwnd, NULL, FALSE); + UpdateWindow(hwnd); + } + return 1; + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + } + } + return DefWindowProc(hwnd, message, wParam, lParam); +} + +//=================================================== ARM9 +LRESULT CALLBACK ViewMem_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_NCCREATE: + SetScrollRange(hwnd, SB_VERT, 0, 0x0FFFFFFF, TRUE); + SetScrollPos(hwnd, SB_VERT, 10, TRUE); + return 1; + + case WM_NCDESTROY: + return 1; + + case WM_PAINT: + MemViewBox_OnPaint(hwnd, MemView9, wParam, lParam); + return 1; + + case WM_ERASEBKGND: + return 1; + case WM_VSCROLL : + { + RECT rect; + SIZE fontsize; + HDC dc; + HFONT old; + int nbligne; + + GetClientRect(hwnd, &rect); + dc = GetDC(hwnd); + old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); + GetTextExtentPoint32(dc, "0", 1, &fontsize); + + nbligne = (rect.bottom - rect.top)/fontsize.cy; + + switch LOWORD(wParam) + { + case SB_LINEDOWN : + MemView9->curr_ligne = std::min((u32)0x0FFFFFFFF, (u32)MemView9->curr_ligne+1); + break; + case SB_LINEUP : + MemView9->curr_ligne = (u32)std::max((u32)0l, (u32)MemView9->curr_ligne-1); + break; + case SB_PAGEDOWN : + MemView9->curr_ligne = std::min((u32)0x0FFFFFFFF, (u32)MemView9->curr_ligne+nbligne); + break; + case SB_PAGEUP : + MemView9->curr_ligne = (u32)std::max((u32)0l, (u32)MemView9->curr_ligne-nbligne); + break; + } + + SelectObject(dc, old); + SetScrollPos(hwnd, SB_VERT, MemView9->curr_ligne, TRUE); + InvalidateRect(hwnd, NULL, FALSE); + UpdateWindow(hwnd); + } + return 1; + } + + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +bool CALLBACK ViewMem_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + + switch (message) + { + case WM_INITDIALOG : + { + SetWindowText(hwnd, "ARM9 memory viewer"); + SendMessage(GetDlgItem(hwnd, IDC_8_BIT), BM_SETCHECK, TRUE, 0); + MemView9 = new memview_struct; + memset(MemView9, 0, sizeof(memview_struct)); + MemView9->cpu = 0; + MemView9->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, MemView9->autoup_secs); + return 0; + } + case WM_CLOSE: + { + if(MemView9->autoup) + { + KillTimer(hwnd, IDT_VIEW_MEM9); + MemView9->autoup = false; + } + + if (MemView9!=NULL) + { + delete MemView9; + MemView9 = NULL; + } + //printlog("Close ARM9 memory dialog\n"); + PostQuitMessage(0); + return 0; + } + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; + + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_8_BIT : + MemView9->representation = 0; + InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); + UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); + return 1; + case IDC_16_BIT : + MemView9->representation = 1; + InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); + UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); + return 1; + case IDC_32_BIT : + MemView9->representation = 2; + InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); + UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); + return 1; + case IDC_AUTO_UPDATE : + if(MemView9->autoup) { - char tmp[8]; - int lg = GetDlgItemText(hwnd, IDC_GOTOMEM, tmp, 8); - u32 adr = 0; - for(u16 i = 0; i='A')&&(tmp[i]<='F')) - { - adr = adr*16 + (tmp[i]-'A'+10); - continue; - } - if((tmp[i]>='0')&&(tmp[i]<='9')) - { - adr = adr*16 + (tmp[i]-'0'); - continue; - } - } - win->curr_ligne = (adr>>4); - InvalidateRect(hwnd, NULL, FALSE); - UpdateWindow(hwnd); - } - return 1; - case IDC_FERMER : - win->remove2RefreshList(); - delete win; - EndDialog(hwnd, 0); - return 1; - } - return 0; - } - return 0; -} - -CMemView::CMemView(HINSTANCE hInst, HWND parent, char * titre, u8 CPU) : - CWindow(hInst, parent, titre, IDD_MEM_VIEWER, mem_view_proc), cpu(CPU), curr_ligne(0), representation(0) -{ - SetWindowLong(GetDlgItem(hwnd, IDC_MEM_BOX), 0, (LONG)this); -} -*/ - -////////////////////////////////////////////////////////////////////////////// - -LRESULT MemViewBox_OnPaint(memview_struct * win, WPARAM wParam, LPARAM lParam) -{ - HWND hwnd = GetDlgItem(win->hwnd, IDC_MEM_BOX); - HDC hdc; - PAINTSTRUCT ps; - SIZE fontsize; - TCHAR text[80]; - int i; - RECT rect; - int lg; - int ht; - HDC mem_dc; - HBITMAP mem_bmp; - int nbligne; - RECT r; - u32 adr; - - GetClientRect(hwnd, &rect); - lg = rect.right - rect.left; - ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - mem_dc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT)); - - GetTextExtentPoint32(mem_dc, "0", 1, &fontsize); - - nbligne = ht/fontsize.cy; - - SetTextColor(mem_dc, RGB(0,0,0)); - - r.top = 3; - r.left = 3; - r.bottom = r.top+fontsize.cy; - r.right = rect.right-3; - - adr = win->curr_ligne*0x10; - - for(i=0; i>16), (int)(adr&0xFFFF)); - DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); - r.left += 11*fontsize.cx; - - if(win->representation == 0) - for(j=0; j<16; ++j) - { - sprintf(text, "%02X", MMU_read8(win->cpu, adr+j)); - DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); - r.left+=3*fontsize.cx; - } - else - if(win->representation == 1) - for(j=0; j<16; j+=2) - { - sprintf(text, "%04X", MMU_read16(win->cpu, adr+j)); - DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); - r.left+=5*fontsize.cx; - } - else - for(j=0; j<16; j+=4) - { - sprintf(text, "%08X", (int)MMU_read32(win->cpu, adr+j)); - DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); - r.left+=9*fontsize.cx; - } - - r.left+=fontsize.cx; - - for(j=0; j<16; ++j) - { - u8 c = MMU_read8(win->cpu, adr+j); - if(c >= 32 && c <= 127) { - text[j] = (char)c; - } - else - text[j] = '.'; - } - text[j] = '\0'; - DrawText(mem_dc, text, -1, &r, DT_TOP | DT_LEFT | DT_NOPREFIX); - - adr+=0x10; - r.top += fontsize.cy; - r.bottom += fontsize.cy; - r.left = 3; - } - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - return 1; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT CALLBACK MemViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - memview_struct *win = (memview_struct *)GetWindowLong(hwnd, 0); - - switch(msg) - { - case WM_NCCREATE: - SetScrollRange(hwnd, SB_VERT, 0, 0x0FFFFFFF, TRUE); - SetScrollPos(hwnd, SB_VERT, 10, TRUE); - return 1; - - case WM_NCDESTROY: - return 1; - - case WM_PAINT: - MemViewBox_OnPaint(win, wParam, lParam); - return 1; - - case WM_ERASEBKGND: - return 1; - case WM_VSCROLL : - { - RECT rect; - SIZE fontsize; - HDC dc; - HFONT old; - int nbligne; - - GetClientRect(hwnd, &rect); - dc = GetDC(hwnd); - old = (HFONT)SelectObject(dc, GetStockObject(SYSTEM_FIXED_FONT)); - GetTextExtentPoint32(dc, "0", 1, &fontsize); - - nbligne = (rect.bottom - rect.top)/fontsize.cy; - - switch LOWORD(wParam) - { - case SB_LINEDOWN : - win->curr_ligne = std::min((s32)0x0FFFFFFFF, (s32)win->curr_ligne+1); - break; - case SB_LINEUP : - win->curr_ligne = (u32)std::max(0l, (s32)win->curr_ligne-1); - break; - case SB_PAGEDOWN : - win->curr_ligne = std::min((s32)0x0FFFFFFFF, (s32)win->curr_ligne+nbligne); - break; - case SB_PAGEUP : - win->curr_ligne = (u32)std::max(0l, (s32)win->curr_ligne-nbligne); - break; - } - - SelectObject(dc, old); - SetScrollPos(hwnd, SB_VERT, win->curr_ligne, TRUE); - InvalidateRect(hwnd, NULL, FALSE); - UpdateWindow(hwnd); - } - return 1; - - default: - break; - } - - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -////////////////////////////////////////////////////////////////////////////// - -// MEM VIEWER -BOOL CALLBACK MemView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - memview_struct *win = (memview_struct *)GetWindowLong(hwnd, DWL_USER); - - switch (message) - { - case WM_INITDIALOG : - SendMessage(GetDlgItem(hwnd, IDC_8_BIT), BM_SETCHECK, TRUE, 0); - return 1; - case WM_CLOSE : - CWindow_RemoveFromRefreshList(win); - MemView_Deinit(win); - EndDialog(hwnd, 0); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_8_BIT : - win->representation = 0; - InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); - return 1; - case IDC_16_BIT : - win->representation = 1; - InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); - return 1; - case IDC_32_BIT : - win->representation = 2; - InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); - UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); - return 1; - case IDC_AUTO_UPDATE : - if(win->autoup) - { - CWindow_RemoveFromRefreshList(win); - win->autoup = FALSE; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_MEM9); + MemView9->autoup = FALSE; return 1; } - CWindow_AddToRefreshList(win); - win->autoup = TRUE; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + MemView9->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_MEM9, MemView9->autoup_secs*1000, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != MemView9->autoup_secs) + { + MemView9->autoup_secs = t; + if (MemView9->autoup) + SetTimer(hwnd, IDT_VIEW_MEM9, + MemView9->autoup_secs*1000, (TIMERPROC) NULL); + } + } return 1; - case IDC_GO : - { - char tmp[8]; - int lg = GetDlgItemText(hwnd, IDC_GOTOMEM, tmp, 8); - u32 adr = 0; - u16 i; - - for(i = 0; i='A')&&(tmp[i]<='F')) - { - adr = adr*16 + (tmp[i]-'A'+10); - continue; - } - if((tmp[i]>='0')&&(tmp[i]<='9')) - { - adr = adr*16 + (tmp[i]-'0'); - continue; - } - } - win->curr_ligne = (adr>>4); - InvalidateRect(hwnd, NULL, FALSE); - UpdateWindow(hwnd); - } - return 1; - case IDC_FERMER : - CWindow_RemoveFromRefreshList(win); - MemView_Deinit(win); - EndDialog(hwnd, 0); - return 1; - } - return 0; - } - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -memview_struct *MemView_Init(HINSTANCE hInst, HWND parent, char *title, u8 CPU) -{ - memview_struct *MemView = NULL; - - if ((MemView = (memview_struct *)malloc(sizeof(memview_struct))) == NULL) - return MemView; - - if (CWindow_Init2(MemView, hInst, parent, title, IDD_MEM_VIEWER, MemView_Proc) != 0) - { - free(MemView); - return NULL; - } - - MemView->cpu = CPU; - MemView->curr_ligne = 0; - MemView->representation = 0; - - SetWindowLong(GetDlgItem(MemView->hwnd, IDC_MEM_BOX), 0, (LONG)MemView); - - return MemView; -} - -////////////////////////////////////////////////////////////////////////////// - -void MemView_Deinit(memview_struct *MemView) -{ - if (MemView) - free(MemView); -} - -////////////////////////////////////////////////////////////////////////////// + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_GO : + { + char tmp[8]; + int lg = GetDlgItemText(hwnd, IDC_GOTOMEM, tmp, 8); + u32 adr = 0; + u16 i; + + for(i = 0; i='A')&&(tmp[i]<='F')) + { + adr = adr*16 + (tmp[i]-'A'+10); + continue; + } + if((tmp[i]>='0')&&(tmp[i]<='9')) + { + adr = adr*16 + (tmp[i]-'0'); + continue; + } + } + MemView9->curr_ligne = (adr>>4); + InvalidateRect(hwnd, NULL, FALSE); + UpdateWindow(hwnd); + } + return 1; + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + } + } + return DefWindowProc(hwnd, message, wParam, lParam); +} diff --git a/desmume/src/windows/memView.h b/desmume/src/windows/memView.h index a464755e0..81c6c1e36 100644 --- a/desmume/src/windows/memView.h +++ b/desmume/src/windows/memView.h @@ -22,36 +22,12 @@ #ifndef MEM_VIEW_H #define MEM_VIEW_H -#include "CWindow.h" +#include -/* -class CMemView : public CWindow -{ -public : - CMemView(HINSTANCE hInst, HWND parent, char * titre, u8 CPU); - - s8 cpu; - u32 curr_ligne; - u8 representation; -}; -*/ +extern bool CALLBACK ViewMem_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +extern LRESULT CALLBACK ViewMem_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -typedef struct -{ - HWND hwnd; - BOOL autoup; - void *prev; - void *next; - void *first; - void (*Refresh)(void *win); +extern bool CALLBACK ViewMem_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +extern LRESULT CALLBACK ViewMem_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - s8 cpu; - u32 curr_ligne; - u8 representation; -} memview_struct; - -void InitMemViewBox(); -memview_struct *MemView_Init(HINSTANCE hInst, HWND parent, char *title, u8 CPU); -void MemView_Deinit(memview_struct *MemView); - -#endif +#endif \ No newline at end of file diff --git a/desmume/src/windows/oamView.cpp b/desmume/src/windows/oamView.cpp index 629290771..09672157e 100644 --- a/desmume/src/windows/oamView.cpp +++ b/desmume/src/windows/oamView.cpp @@ -19,16 +19,26 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include +#include "oamView.h" +#include +#include "debug.h" #include "resource.h" #include "../MMU.h" -#include "oamView.h" #include "../GPU.h" - #include "../NDSSystem.h" -extern NDSSystem nds; +typedef struct +{ + u32 autoup_secs; + bool autoup; + + s16 num; + OAM *oam; + GPU *gpu; +} oamview_struct; + +oamview_struct *OAMView = NULL; +//extern NDSSystem nds; const char dimm[4][4][8] = { @@ -38,35 +48,9 @@ const char dimm[4][4][8] = {"64 x 64", "64 x 32", "32 x 64", "- x -"}, }; -////////////////////////////////////////////////////////////////////////////// - -LRESULT CALLBACK OAMViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -void InitOAMViewBox() +LRESULT OAMViewBox_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) { - WNDCLASSEX wc; - - wc.cbSize = sizeof(wc); - wc.lpszClassName = _T("OAMViewBox"); - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = OAMViewBoxWndProc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(cwindow_struct *); - wc.hIconSm = 0; - - RegisterClassEx(&wc); -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT OAMViewBox_OnPaint(oamview_struct * win, WPARAM wParam, LPARAM lParam) -{ - HWND hwnd = GetDlgItem(win->hwnd, IDC_OAM_BOX); + //HWND hwnd = GetDlgItem(win->hwnd, IDC_OAM_BOX); HDC hdc; PAINTSTRUCT ps; // TCHAR text[80]; @@ -98,34 +82,8 @@ LRESULT OAMViewBox_OnPaint(oamview_struct * win, WPARAM wParam, LPARAM lParam) return 0; } -////////////////////////////////////////////////////////////////////////////// - -LRESULT CALLBACK OAMViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +LRESULT OamView_OnPaint(HWND hwnd, oamview_struct *win, WPARAM wParam, LPARAM lParam) { -// oamView * win = (oamView *)GetWindowLong(hwnd, 0); - - switch(msg) - { - case WM_NCCREATE: - return 1; - case WM_NCDESTROY: - return 1; - /*case WM_PAINT: - OAMViewBox_OnPaint(win, wParam, lParam); - return 1;*/ - case WM_ERASEBKGND: - return 1; - default: - break; - } - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT OamView_OnPaint(oamview_struct *win, WPARAM wParam, LPARAM lParam) -{ - HWND hwnd = win->hwnd; HDC hdc; PAINTSTRUCT ps; OAM * oam = &win->oam[win->num]; @@ -227,15 +185,42 @@ LRESULT OamView_OnPaint(oamview_struct *win, WPARAM wParam, LPARAM lParam) return 0; } -////////////////////////////////////////////////////////////////////////////// - -BOOL CALLBACK OamView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK ViewOAMBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - oamview_struct *win = (oamview_struct *)GetWindowLong(hwnd, DWL_USER); - switch (message) + switch(msg) + { + case WM_NCCREATE: + return 1; + case WM_NCDESTROY: + return 1; + case WM_PAINT: + OAMViewBox_OnPaint(hwnd, wParam, lParam); + return 1; + case WM_ERASEBKGND: + return 1; + default: + break; + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +BOOL CALLBACK ViewOAMProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { case WM_INITDIALOG : { + OAMView = new oamview_struct; + memset(OAMView, 0, sizeof(oamview_struct)); + OAMView->oam = (OAM *)(ARM9Mem.ARM9_OAM); + OAMView->gpu = MainScreen.gpu; + + OAMView->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, OAMView->autoup_secs); + HWND combo = GetDlgItem(hwnd, IDC_SCR_SELECT); SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen sprite"); SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen sprite"); @@ -243,37 +228,79 @@ BOOL CALLBACK OamView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara } return 1; case WM_CLOSE : - CWindow_RemoveFromRefreshList(win); - OamView_Deinit(win); - EndDialog(hwnd, 0); - return 1; + { + if(OAMView->autoup) + { + KillTimer(hwnd, IDT_VIEW_OAM); + OAMView->autoup = false; + } + + if (OAMView!=NULL) + { + delete OAMView; + OAMView = NULL; + } + //printlog("Close OAM viewer dialog\n"); + PostQuitMessage(0); + return 0; + } case WM_PAINT: - OamView_OnPaint(win, wParam, lParam); + OamView_OnPaint(hwnd, OAMView, wParam, lParam); return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; case WM_HSCROLL : switch LOWORD(wParam) { case SB_LINERIGHT : - ++(win->num); - if(win->num>127) - win->num = 127; + ++(OAMView->num); + if(OAMView->num>127) + OAMView->num = 127; break; case SB_LINELEFT : - --(win->num); - if(win->num<0) - win->num = 0; + --(OAMView->num); + if(OAMView->num<0) + OAMView->num = 0; break; } - CWindow_Refresh(win); + InvalidateRect(hwnd, NULL, FALSE); return 1; case WM_COMMAND : switch (LOWORD (wParam)) { case IDC_FERMER : - CWindow_RemoveFromRefreshList(win); - OamView_Deinit(win); - EndDialog(hwnd, 0); + SendMessage(hwnd, WM_CLOSE, 0, 0); return 1; + case IDC_AUTO_UPDATE : + if(OAMView->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_OAM); + OAMView->autoup = FALSE; + return 1; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + OAMView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_OAM, OAMView->autoup_secs*1000, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != OAMView->autoup_secs) + { + OAMView->autoup_secs = t; + if (OAMView->autoup) + SetTimer(hwnd, IDT_VIEW_OAM, + OAMView->autoup_secs*1000, (TIMERPROC) NULL); + } + } + return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; case IDC_SCR_SELECT : switch(HIWORD(wParam)) { @@ -283,56 +310,23 @@ BOOL CALLBACK OamView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara switch(sel) { case 0 : - win->oam = (OAM *)ARM9Mem.ARM9_OAM; - win->num = 0; - win->gpu = MainScreen.gpu; + OAMView->oam = (OAM *)ARM9Mem.ARM9_OAM; + OAMView->num = 0; + OAMView->gpu = MainScreen.gpu; break; case 1 : - win->oam = (OAM *)(ARM9Mem.ARM9_OAM+0x400); - win->num = 0; - win->gpu = SubScreen.gpu; + OAMView->oam = (OAM *)(ARM9Mem.ARM9_OAM+0x400); + OAMView->num = 0; + OAMView->gpu = SubScreen.gpu; break; } } - CWindow_Refresh(win); + InvalidateRect(hwnd, NULL, FALSE); return 1; } return 1; } return 0; } - return 0; + return DefWindowProc(hwnd, message, wParam, lParam); } - - -////////////////////////////////////////////////////////////////////////////// - -oamview_struct *OamView_Init(HINSTANCE hInst, HWND parent) -{ - oamview_struct *OamView=NULL; - - if ((OamView = (oamview_struct *)malloc(sizeof(oamview_struct))) == NULL) - return OamView; - - if (CWindow_Init2(OamView, hInst, parent, "OAM Viewer", IDD_OAM, OamView_Proc) != 0) - { - free(OamView); - return NULL; - } - - OamView->oam = (OAM *)(ARM9Mem.ARM9_OAM); - OamView->num = 0; - OamView->gpu = MainScreen.gpu; - - return OamView; -} - -////////////////////////////////////////////////////////////////////////////// - -void OamView_Deinit(oamview_struct *OamView) -{ - if (OamView) - free(OamView); -} - -////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/oamView.h b/desmume/src/windows/oamView.h index 784372aa7..724ada26a 100644 --- a/desmume/src/windows/oamView.h +++ b/desmume/src/windows/oamView.h @@ -22,25 +22,9 @@ #ifndef OAMVIEW_H #define OAMVIEW_H -#include "CWindow.h" -#include "../GPU.h" +#include -typedef struct -{ - HWND hwnd; - BOOL autoup; - void *prev; - void *next; - void *first; - void (*Refresh)(void *win); - - s16 num; - OAM *oam; - GPU *gpu; -} oamview_struct; - -extern void InitOAMViewBox(); -oamview_struct *OamView_Init(HINSTANCE hInst, HWND parent); -void OamView_Deinit(oamview_struct *OamView); +extern LRESULT CALLBACK ViewOAMBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +extern BOOL CALLBACK ViewOAMProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); #endif diff --git a/desmume/src/windows/ogl.cpp b/desmume/src/windows/ogl.cpp index 2925804ed..6c83ae3fe 100644 --- a/desmume/src/windows/ogl.cpp +++ b/desmume/src/windows/ogl.cpp @@ -3,8 +3,9 @@ #include #include #include "console.h" +#include "CWindow.h" -extern HWND hwnd; +extern WINCLASS *MainWindow; int CheckHardwareSupport(HDC hdc) { @@ -32,7 +33,7 @@ bool windows_opengl_init() int res; char *opengl_modes[3]={"software","half hardware (MCD driver)","hardware"}; - oglDC = GetDC (hwnd); + oglDC = GetDC (MainWindow->getHWnd()); memset(&pfd,0, sizeof(PIXELFORMATDESCRIPTOR)); pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); diff --git a/desmume/src/windows/palView.cpp b/desmume/src/windows/palView.cpp index f4ccc3b3c..ce8b68101 100644 --- a/desmume/src/windows/palView.cpp +++ b/desmume/src/windows/palView.cpp @@ -19,13 +19,22 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include "resource.h" #include "palView.h" +#include +#include "debug.h" +#include "resource.h" #include "../MMU.h" -#include -////////////////////////////////////////////////////////////////////////////// +typedef struct +{ + u32 autoup_secs; + bool autoup; + + u16 *adr; + s16 palnum; +} palview_struct; + +palview_struct *PalView = NULL; LRESULT PalView_OnPaint(const u16 * adr, u16 num, HWND hwnd, WPARAM wParam, LPARAM lParam) { @@ -74,17 +83,21 @@ LRESULT PalView_OnPaint(const u16 * adr, u16 num, HWND hwnd, WPARAM wParam, LPAR return 0; } -////////////////////////////////////////////////////////////////////////////// - -BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +BOOL CALLBACK ViewPalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - //ATTENTION null Ela creation donc la boite ne doit pas tre visible a la cration - palview_struct *win = (palview_struct *)GetWindowLong(hwnd, DWL_USER); - - switch (message) + switch (message) { case WM_INITDIALOG : { + PalView = new palview_struct; + memset(PalView, 0, sizeof(palview_struct)); + PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM; + PalView->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, PalView->autoup_secs); + HWND combo = GetDlgItem(hwnd, IDC_PAL_SELECT); SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen BG PAL"); SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen BG PAL"); @@ -111,48 +124,80 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); } return 1; - case WM_CLOSE : - CWindow_RemoveFromRefreshList(win); - PalView_Deinit(win); - EndDialog(hwnd, 0); - return 1; + case WM_CLOSE : + { + if(PalView->autoup) + { + KillTimer(hwnd, IDT_VIEW_DISASM7); + PalView->autoup = false; + } + + if (PalView!=NULL) + { + delete PalView; + PalView = NULL; + } + //printlog("Close Palette view dialog\n"); + PostQuitMessage(0); + return 0; + } case WM_PAINT: - PalView_OnPaint(win->adr, win->palnum, hwnd, wParam, lParam); + PalView_OnPaint(PalView->adr, PalView->palnum, hwnd, wParam, lParam); return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; case WM_HSCROLL : switch LOWORD(wParam) { case SB_LINERIGHT : - ++(win->palnum); - if(win->palnum>15) - win->palnum = 15; + ++(PalView->palnum); + if(PalView->palnum>15) + PalView->palnum = 15; break; case SB_LINELEFT : - --(win->palnum); - if(win->palnum<0) - win->palnum = 0; + --(PalView->palnum); + if(PalView->palnum<0) + PalView->palnum = 0; break; } - CWindow_Refresh(win); + InvalidateRect(hwnd, NULL, FALSE); return 1; case WM_COMMAND : switch (LOWORD (wParam)) { case IDC_FERMER : - CWindow_RemoveFromRefreshList(win); - PalView_Deinit(win); - EndDialog(hwnd, 0); + SendMessage(hwnd, WM_CLOSE, 0, 0); return 1; case IDC_AUTO_UPDATE : - if(win->autoup) + if(PalView->autoup) { - CWindow_RemoveFromRefreshList(win); - win->autoup = FALSE; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_PAL); + PalView->autoup = FALSE; return 1; } - CWindow_AddToRefreshList(win); - win->autoup = TRUE; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + PalView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_PAL, PalView->autoup_secs*1000, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != PalView->autoup_secs) + { + PalView->autoup_secs = t; + if (PalView->autoup) + SetTimer(hwnd, IDT_VIEW_PAL, + PalView->autoup_secs*1000, (TIMERPROC) NULL); + } + } return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; case IDC_PAL_SELECT : switch(HIWORD(wParam)) { @@ -163,26 +208,26 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara switch(sel) { case 0 : - win->adr = (u16 *)ARM9Mem.ARM9_VMEM; - win->palnum = 0; + PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM; + PalView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); break; case 1 : - win->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200; - win->palnum = 0; + PalView->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200; + PalView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); break; case 2 : - win->adr = (u16 *)ARM9Mem.ARM9_VMEM + 0x100; - win->palnum = 0; + PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM + 0x100; + PalView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); break; case 3 : - win->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; - win->palnum = 0; + PalView->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; + PalView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); break; @@ -190,8 +235,8 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara case 5 : case 6 : case 7 : - win->adr = ((u16 *)(ARM9Mem.ExtPal[0][sel-4])); - win->palnum = 0; + PalView->adr = ((u16 *)(ARM9Mem.ExtPal[0][sel-4])); + PalView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); break; @@ -199,22 +244,22 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara case 9 : case 10 : case 11 : - win->adr = ((u16 *)(ARM9Mem.ExtPal[1][sel-8])); - win->palnum = 0; + PalView->adr = ((u16 *)(ARM9Mem.ExtPal[1][sel-8])); + PalView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); break; case 12 : case 13 : - win->adr = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12])); - win->palnum = 0; + PalView->adr = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12])); + PalView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); break; case 14 : case 15 : - win->adr = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14])); - win->palnum = 0; + PalView->adr = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14])); + PalView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); break; @@ -222,15 +267,15 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara case 17 : case 18 : case 19 : - win->adr = ((u16 *)(ARM9Mem.texPalSlot[sel-16])); - win->palnum = 0; + PalView->adr = ((u16 *)(ARM9Mem.texPalSlot[sel-16])); + PalView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW); EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE); break; default : return 1; } - CWindow_Refresh(win); + InvalidateRect(hwnd, NULL, FALSE); return 1; } } @@ -238,36 +283,5 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara } return 0; } - return 0; + return DefWindowProc(hwnd, message, wParam, lParam); } - -////////////////////////////////////////////////////////////////////////////// - -palview_struct *PalView_Init(HINSTANCE hInst, HWND parent) -{ - palview_struct *PalView=NULL; - - if ((PalView = (palview_struct *)malloc(sizeof(palview_struct))) == NULL) - return PalView; - - if (CWindow_Init2(PalView, hInst, parent, "Palette viewer", IDD_PAL, PalView_Proc) != 0) - { - free(PalView); - return NULL; - } - - PalView->palnum = 0; - PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM; - - return PalView; -} - -////////////////////////////////////////////////////////////////////////////// - -void PalView_Deinit(palview_struct *PalView) -{ - if (PalView) - free(PalView); -} - -////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/palView.h b/desmume/src/windows/palView.h index a0a3c4fea..b32a6ed48 100644 --- a/desmume/src/windows/palView.h +++ b/desmume/src/windows/palView.h @@ -22,25 +22,9 @@ #ifndef PALVIEW_H #define PALVIEW_H -#include "CWindow.h" +#include +#include -typedef struct -{ - HWND hwnd; - BOOL autoup; - void *prev; - void *next; - void *first; - void (*Refresh)(void *win); - - u16 *adr; - s16 palnum; -} palview_struct; - -//BOOL CALLBACK palView_proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); - -palview_struct *PalView_Init(HINSTANCE hInst, HWND parent); -void PalView_Deinit(palview_struct *PalView); - -#endif +extern BOOL CALLBACK ViewPalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +#endif \ No newline at end of file diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index 52f40fa46..c637aaa98 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -4,15 +4,21 @@ // #define IDM_OPEN 101 #define IDM_QUIT 102 +#define IDB_NINTENDO_DS_LOGO 102 #define IDC_FERMER 103 +#define IDD_DESASSEMBLEUR_VIEWER7 103 #define IDC_STEP 104 +#define IDD_MEM_VIEWER7 104 #define IDC_SETPNUM 105 +#define IDD_CONFIG 105 #define IDC_SCROLLER 106 +#define IDD_SOUNDSETTINGS 106 #define IDC_GO 107 #define IDC_AUTO_UPDATE 108 #define IDM_MEMORY 109 #define IDM_DISASSEMBLER 110 #define IDM_GAME_INFO 111 +#define IDC_AUTO_UPDATE2 111 #define IDM_EXEC 112 #define IDM_PAUSE 113 #define IDM_RESET 114 @@ -74,7 +80,7 @@ #define IDC_COMBO13 172 #define IDC_BUTTON1 173 #define IDM_CONFIG 180 -#define IDD_CONFIG 181 +#define IDD_INPUT 181 #define IDC_SAVETYPE1 182 #define IDC_SAVETYPE2 183 #define IDC_SAVETYPE3 184 @@ -142,8 +148,6 @@ #define IDC_DISPSTAT 606 #define IDC_IPCSYNC 607 #define IDC_IPCFIFO 608 -#define IDD_LOG 701 -#define IDC_LOG 702 #define IDD_PAL 703 #define IDD_TILE 704 #define IDC_PAL_SELECT 705 @@ -175,21 +179,36 @@ #define IDC_PROP1 909 #define IDC_OAM_BOX 910 #define IDC_SOUNDCORECB 1000 +#define IDC_EDIT3 1000 #define IDC_SOUNDBUFFERET 1001 +#define IDC_EDIT4 1001 #define IDC_SLVOLUME 1002 +#define IDC_EDIT5 1002 #define IDC_ROTATE0 1003 +#define IDC_EDIT6 1003 #define IDC_ROTATE90 1004 +#define IDC_EDIT7 1004 #define IDC_ROTATE180 1005 +#define IDC_EDIT8 1005 #define IDC_ROTATE270 1006 +#define IDC_EDIT9 1006 +#define IDC_EDIT10 1007 +#define IDC_EDIT11 1008 #define IDC_FORCERATIO 1009 +#define IDC_EDIT12 1009 #define IDC_WINDOW1X 1010 +#define IDC_EDIT13 1010 +#define IDC_AUTO_UPDATE_SPIN 1010 #define IDC_WINDOW2X 1011 +#define IDC_AUTO_UPDATE_SECS 1011 #define IDC_WINDOW3X 1012 +#define IDC_REFRESH 1012 #define IDC_WINDOW4X 1013 #define IDM_FIRMSETTINGS 1100 #define IDD_FIRMSETTINGS 1101 #define IDC_EDIT1 1102 #define IDC_EDIT2 1103 +#define IDC_EDIT14 1104 #define IDD_MATRIX_VIEWER 1200 #define IDM_MATRIX_VIEWER 1200 #define IDC_MATRIX_VIEWER_COORD_GROUP 1201 @@ -268,7 +287,9 @@ #define IDC_LIGHT_VIWER_LIGHT0_GROUP 1301 #define IDC_AUTHORS_LIST 1302 #define IDC_LIGHT_VIEWER_LIGHT0COLOR_COLORCTRL 1302 +#define IDD_DESASSEMBLEUR_VIEWER9 1302 #define IDC_LIGHT_VIEWER_LIGHT0COLOR_EDIT 1303 +#define IDD_MEM_VIEWER9 1303 #define IDC_LIGHT_VIEWER_LIGHT0VECTOR_EDIT 1304 #define IDC_LIGHT_VIWER_LIGHT1_GROUP 1311 #define IDC_LIGHT_VIEWER_LIGHT1COLOR_COLORCTRL 1312 @@ -282,6 +303,17 @@ #define IDC_LIGHT_VIEWER_LIGHT3COLOR_COLORCTRL 1332 #define IDC_LIGHT_VIEWER_LIGHT3COLOR_EDIT 1333 #define IDC_LIGHT_VIEWER_LIGHT3VECTOR_EDIT 1334 +#define IDT_VIEW_DISASM7 10001 +#define IDT_VIEW_DISASM9 10002 +#define IDT_VIEW_MEM7 10003 +#define IDT_VIEW_MEM9 10004 +#define IDT_VIEW_IOREG 10005 +#define IDT_VIEW_PAL 10006 +#define IDT_VIEW_TILE 10007 +#define IDT_VIEW_MAP 10008 +#define IDT_VIEW_OAM 10009 +#define IDT_VIEW_MATRIX 10010 +#define IDT_VIEW_LIGHTS 10011 #define IDM_ABOUT 40003 #define ACCEL_P 40004 #define ACCEL_SPACEBAR 40005 @@ -290,14 +322,17 @@ #define ID_VIS_DISPLAYFRAMECOUNTER 40008 #define ID_VIEW_FRAMECOUNTER 40009 #define ID_VIEW_DISPLAYFRAMECOUNTER40009 40009 +#define ID_VIEW_DISPLAYFPS 40010 +#define ID_VIS_DISPLAYFPS 40011 +#define ID_VIEW_DISPLAYFPS40012 40012 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40010 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_RESOURCE_VALUE 107 +#define _APS_NEXT_COMMAND_VALUE 40013 +#define _APS_NEXT_CONTROL_VALUE 1013 +#define _APS_NEXT_SYMED_VALUE 112 #endif #endif diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index d4e1f8aff..b76d1e1d2 100644 --- a/desmume/src/windows/resources.rc +++ b/desmume/src/windows/resources.rc @@ -17,7 +17,7 @@ #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) #ifdef _WIN32 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1252) +#pragma code_page(1251) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// @@ -51,6 +51,13 @@ BEGIN "N", ACCEL_N, VIRTKEY, NOINVERT END + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDB_NINTENDO_DS_LOGO BITMAP "NintendoDS(tm)_logo.bmp" #endif // Neutral resources ///////////////////////////////////////////////////////////////////////////// @@ -136,6 +143,7 @@ BEGIN MENUITEM "&Bevar Hjde og Bredde", IDC_FORCERATIO MENUITEM SEPARATOR MENUITEM "Display Frame Counter", ID_VIEW_FRAMECOUNTER + MENUITEM "Display Fps", ID_VIEW_DISPLAYFPS END POPUP "&Konfigure" BEGIN @@ -243,10 +251,10 @@ BEGIN LTEXT "Select:",IDC_STATIC,17,190,28,9 END -IDD_MEM_VIEWER DIALOG 0, 0, 428, 178 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_MEM_VIEWER7 DIALOGEX 0, 0, 428, 178 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "Vis Hukommelse" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN CONTROL "8 bit",IDC_8_BIT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,29,10 CONTROL "16 bit",IDC_16_BIT,"Button",BS_AUTORADIOBUTTON,44,4,33,10 @@ -254,15 +262,18 @@ BEGIN LTEXT "G Til:",IDC_STATIC,130,4,33,10 EDITTEXT IDC_GOTOMEM,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP PUSHBUTTON "&Start",IDC_GO,240,1,20,14 - CONTROL "Auto-opdatere",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,350,1,75,14 - CONTROL "Rediger",IDC_MEM_BOX,"MemViewBox",WS_VSCROLL | WS_TABSTOP,4,16,424,142,WS_EX_CLIENTEDGE + CONTROL "Rediger",IDC_MEM_BOX,"MemViewBox7",WS_VSCROLL | WS_TABSTOP,4,16,424,142,WS_EX_CLIENTEDGE PUSHBUTTON "&Luk",IDC_FERMER,185,162,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,1,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,382,2,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,394,2,11,14 + LTEXT "secs",IDC_STATIC,406,5,16,8 END -IDD_DESASSEMBLEUR_VIEWER DIALOG 0, 0, 380, 186 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_DESASSEMBLEUR_VIEWER7 DIALOGEX 0, 0, 380, 186 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "Disassembler" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN CONTROL "Auto ",IDC_AUTO_DES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,35,10 CONTROL "ARM",IDC_ARM,"Button",BS_AUTORADIOBUTTON,44,4,35,10 @@ -270,9 +281,8 @@ BEGIN LTEXT "G til:",IDC_STATIC,130,4,33,10 EDITTEXT IDC_GOTODES,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP PUSHBUTTON "&Start",IDC_GO,240,1,20,14 - CONTROL "Auto-opdatere",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,300,1,75,14 - CONTROL "Rediger",IDC_DES_BOX,"DesViewBox",WS_VSCROLL | WS_TABSTOP,4,16,296,150,WS_EX_CLIENTEDGE - PUSHBUTTON "&Luk",IDC_FERMER,185,170,50,14 + CONTROL "Rediger",IDC_DES_BOX,"DesViewBox7",WS_VSCROLL | WS_TABSTOP,4,16,296,150,WS_EX_CLIENTEDGE + PUSHBUTTON "&Luk",IDC_FERMER,246,170,50,14 EDITTEXT IDC_SETPNUM,5,170,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP PUSHBUTTON "&Step",IDC_STEP,75,170,50,14 LTEXT "R0 :",IDC_STATIC,304,16,17,8 @@ -311,6 +321,11 @@ BEGIN LTEXT "00000000",IDC_R15,325,136,40,8 LTEXT "",IDC_MODE,327,158,28,8 LTEXT "",IDC_TMP,327,168,40,8 + PUSHBUTTON "&Refresh",IDC_REFRESH,162,170,50,14,BS_ICON + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,285,1,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,340,3,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,352,2,11,14 + LTEXT "secs",IDC_STATIC,364,5,16,8 END IDD_GAME_INFO DIALOG 0, 0, 150, 150 @@ -335,10 +350,10 @@ BEGIN LTEXT "",IDC_DATA,60,52,100,8 END -IDD_IO_REG DIALOG 0, 0, 150, 150 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_IO_REG DIALOGEX 0, 0, 150, 150 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "IO Registre" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN PUSHBUTTON "&Luk",IDC_FERMER,50,134,50,14 LTEXT "Int Handler :",IDC_STATIC,4,4,41,8 @@ -355,33 +370,31 @@ BEGIN LTEXT "",IDC_DISPSTAT,45,36,130,8 LTEXT "",IDC_IPCSYNC,45,44,130,8 LTEXT "",IDC_IPCFIFO,45,52,130,8 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,32,115,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,87,117,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,99,116,11,14 + LTEXT "secs",IDC_STATIC,111,119,16,8 END -IDD_LOG DIALOG 0, 0, 300, 300 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU -CAPTION "Logbog" -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Rediger",IDC_LOG,"LogView",WS_VSCROLL | WS_TABSTOP,4,4,292,280,WS_EX_CLIENTEDGE - PUSHBUTTON "&Luk",IDC_FERMER,125,285,50,14 -END - -IDD_PAL DIALOG 0, 0, 120, 165 +IDD_PAL DIALOGEX 0, 0, 120, 190 STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU CAPTION "Palette Fremvisning" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_PAL_SELECT,15,3,90,14,CBS_DROPDOWN | WS_TABSTOP LTEXT "Pal : 0",IDC_PALNUM,3,21,25,8 SCROLLBAR IDC_SCROLLER,30,18,20,14 - CONTROL "Auto-opdatere",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,60,18,75,14 - PUSHBUTTON "&Luk",IDC_FERMER,35,149,50,14 + PUSHBUTTON "&Luk",IDC_FERMER,35,169,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,150,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,68,151,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,80,151,11,14 + LTEXT "secs",IDC_STATIC,92,154,16,8 END -IDD_TILE DIALOG 0, 0, 446, 180 +IDD_TILE DIALOGEX 0, 0, 446, 180 STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU CAPTION "TILE Fremvisning" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_PAL_SELECT,4,13,90,14,CBS_DROPDOWN | WS_TABSTOP LTEXT "Pal : 0",IDC_PALNUM,4,31,25,8 @@ -390,17 +403,20 @@ BEGIN CONTROL "Bitmap",IDC_BITMAP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,4,68,35,10 CONTROL "256 Farver",IDC_256COUL,"Button",BS_AUTORADIOBUTTON,4,80,55,10 CONTROL "16 Farver",IDC_16COUL,"Button",BS_AUTORADIOBUTTON,4,92,50,10 - CONTROL "Auto-opdatere",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,369,164,75,14 CONTROL "Rediger",IDC_Tile_BOX,"TileViewBox",WS_TABSTOP,100,2,344,160,WS_EX_CLIENTEDGE CONTROL "Rediger",IDC_MINI_TILE,"MiniTileViewBox",WS_TABSTOP,22,116,56,52,WS_EX_CLIENTEDGE LTEXT "Tile Num : 0",IDC_TILENUM,23,170,100,8 PUSHBUTTON "&Luk",IDC_FERMER,198,164,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,349,165,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,404,165,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,416,164,11,14 + LTEXT "secs",IDC_STATIC,428,167,16,8 END -IDD_MAP DIALOG 0, 0, 485, 320 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_MAP DIALOGEX 0, 0, 485, 320 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "MAP Fremviser" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_BG_SELECT,4,4,90,14,CBS_DROPDOWN | WS_TABSTOP LTEXT "Mode :",IDC_STATIC,4,20,45,8 @@ -418,12 +434,16 @@ BEGIN LTEXT "",IDC_MSIZE,48,70,85,8 LTEXT "",IDC_SCROLL,48,80,85,8 PUSHBUTTON "&Luk",IDC_FERMER,4,300,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,92,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,59,93,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,71,93,11,14 + LTEXT "secs",IDC_STATIC,83,96,16,8 END -IDD_OAM DIALOG 0, 0, 300, 200 +IDD_OAM DIALOGEX 0, 0, 300, 200 STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU CAPTION "OAM Fremviser" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_SCR_SELECT,4,4,90,14,CBS_DROPDOWN | WS_TABSTOP SCROLLBAR IDC_SCROLLER,48,20,20,14 @@ -446,13 +466,17 @@ BEGIN LTEXT "",IDC_MOS,48,106,42,8 LTEXT "",IDC_PROP0,4,116,86,8 LTEXT "",IDC_PROP1,4,126,86,8 - PUSHBUTTON "&Luk",IDC_FERMER,50,134,50,14 + PUSHBUTTON "&Luk",IDC_FERMER,50,181,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,161,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,59,162,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,71,161,11,14 + LTEXT "secs",IDC_STATIC,83,163,16,8 END -SOUNDSETTINGSDLG DIALOG 0, 0, 174, 96 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +IDD_SOUNDSETTINGS DIALOGEX 0, 0, 174, 96 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Lyd Indstillinger" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN GROUPBOX "Lyd Indstillinger",-1,3,2,168,28 LTEXT "Lyd Driver",-1,10,14,40,10 @@ -487,6 +511,104 @@ BEGIN EDITTEXT IDC_EDIT2,66,33,82,14,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP END +IDD_DESASSEMBLEUR_VIEWER9 DIALOGEX 0, 0, 380, 186 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION +CAPTION "Disassembler" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + CONTROL "Auto ",IDC_AUTO_DES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,35,10 + CONTROL "ARM",IDC_ARM,"Button",BS_AUTORADIOBUTTON,44,4,35,10 + CONTROL "Thumb",IDC_THUMB,"Button",BS_AUTORADIOBUTTON,82,4,40,10 + LTEXT "G til:",IDC_STATIC,130,4,33,10 + EDITTEXT IDC_GOTODES,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP + PUSHBUTTON "&Start",IDC_GO,240,1,20,14 + CONTROL "Rediger",IDC_DES_BOX,"DesViewBox9",WS_VSCROLL | WS_TABSTOP,4,16,296,150,WS_EX_CLIENTEDGE + PUSHBUTTON "&Luk",IDC_FERMER,246,170,50,14 + EDITTEXT IDC_SETPNUM,5,170,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP + PUSHBUTTON "&Step",IDC_STEP,75,170,50,14 + LTEXT "R0 :",IDC_STATIC,304,16,17,8 + LTEXT "R1 :",IDC_STATIC,304,24,17,8 + LTEXT "R2 :",IDC_STATIC,304,32,17,8 + LTEXT "R3 :",IDC_STATIC,304,40,17,8 + LTEXT "R4 :",IDC_STATIC,304,48,17,8 + LTEXT "R5 :",IDC_STATIC,304,56,17,8 + LTEXT "R6 :",IDC_STATIC,304,64,17,8 + LTEXT "R7 :",IDC_STATIC,304,72,17,8 + LTEXT "R8 :",IDC_STATIC,304,80,17,8 + LTEXT "R9 :",IDC_STATIC,304,88,17,8 + LTEXT "R10 :",IDC_STATIC,304,96,17,8 + LTEXT "R11 :",IDC_STATIC,304,104,17,8 + LTEXT "R12 :",IDC_STATIC,304,112,17,8 + LTEXT "SP :",IDC_STATIC,304,120,17,8 + LTEXT "LR :",IDC_STATIC,304,128,17,8 + LTEXT "PC :",IDC_STATIC,304,136,17,8 + LTEXT "Mode :",IDC_STATIC,304,158,22,8 + LTEXT "SPSR :",IDC_STATIC,304,168,22,8 + LTEXT "00000000",IDC_R0,325,16,40,8 + LTEXT "00000000",IDC_R1,325,24,40,8 + LTEXT "00000000",IDC_R2,325,32,40,8 + LTEXT "00000000",IDC_R3,325,40,40,8 + LTEXT "00000000",IDC_R4,325,48,40,8 + LTEXT "00000000",IDC_R5,325,56,40,8 + LTEXT "00000000",IDC_R6,325,64,40,8 + LTEXT "00000000",IDC_R7,325,72,40,8 + LTEXT "00000000",IDC_R8,325,80,40,8 + LTEXT "00000000",IDC_R9,325,88,40,8 + LTEXT "00000000",IDC_R10,325,96,40,8 + LTEXT "00000000",IDC_R11,325,104,40,8 + LTEXT "00000000",IDC_R12,325,112,40,8 + LTEXT "00000000",IDC_R13,325,120,40,8 + LTEXT "00000000",IDC_R14,325,128,40,8 + LTEXT "00000000",IDC_R15,325,136,40,8 + LTEXT "",IDC_MODE,327,158,28,8 + LTEXT "",IDC_TMP,327,168,40,8 + PUSHBUTTON "&Refresh",IDC_REFRESH,162,170,50,14,BS_ICON + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,285,1,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,340,3,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,352,2,11,14 + LTEXT "secs",IDC_STATIC,364,5,16,8 +END + +IDD_MEM_VIEWER9 DIALOGEX 0, 0, 428, 178 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION +CAPTION "Vis Hukommelse" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + CONTROL "8 bit",IDC_8_BIT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,29,10 + CONTROL "16 bit",IDC_16_BIT,"Button",BS_AUTORADIOBUTTON,44,4,33,10 + CONTROL "32 bit",IDC_32_BIT,"Button",BS_AUTORADIOBUTTON,82,4,33,10 + LTEXT "G Til:",IDC_STATIC,130,4,33,10 + EDITTEXT IDC_GOTOMEM,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP + PUSHBUTTON "&Start",IDC_GO,240,1,20,14 + CONTROL "Rediger",IDC_MEM_BOX,"MemViewBox9",WS_VSCROLL | WS_TABSTOP,4,16,424,142,WS_EX_CLIENTEDGE + PUSHBUTTON "&Luk",IDC_FERMER,185,162,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,1,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,382,2,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,394,2,11,14 + LTEXT "secs",IDC_STATIC,406,5,16,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_PAL, DIALOG + BEGIN + BOTTOMMARGIN, 165 + END + + IDD_MEM_VIEWER9, DIALOG + BEGIN + BOTTOMMARGIN, 176 + END +END +#endif // APSTUDIO_INVOKED + #endif // Danish resources ///////////////////////////////////////////////////////////////////////////// @@ -500,40 +622,6 @@ LANGUAGE LANG_GERMAN, SUBLANG_GERMAN #pragma code_page(1252) #endif //_WIN32 -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_LIGHT_VIEWER DIALOGEX 0, 0, 197, 89 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CAPTION | WS_SYSMENU -CAPTION "Light Viewer" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,140,68,50,14 - GROUPBOX "Light0",IDC_LIGHT_VIWER_LIGHT0_GROUP,7,7,90,27 - EDITTEXT IDC_LIGHT_VIEWER_LIGHT0VECTOR_EDIT,58,16,35,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP - EDITTEXT IDC_LIGHT_VIEWER_LIGHT0COLOR_EDIT,33,16,23,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP - CONTROL "",IDC_LIGHT_VIEWER_LIGHT0COLOR_COLORCTRL, - "DeSmuME_ColorCtrl",WS_TABSTOP,11,16,19,14 - GROUPBOX "Light1",IDC_LIGHT_VIWER_LIGHT1_GROUP,100,7,90,27 - EDITTEXT IDC_LIGHT_VIEWER_LIGHT1VECTOR_EDIT,151,16,35,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP - EDITTEXT IDC_LIGHT_VIEWER_LIGHT1COLOR_EDIT,126,16,23,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP - CONTROL "",IDC_LIGHT_VIEWER_LIGHT1COLOR_COLORCTRL, - "DeSmuME_ColorCtrl",WS_TABSTOP,104,16,19,14 - GROUPBOX "Light2",IDC_LIGHT_VIWER_LIGHT2_GROUP,7,33,90,27 - EDITTEXT IDC_LIGHT_VIEWER_LIGHT2VECTOR_EDIT,58,43,35,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP - EDITTEXT IDC_LIGHT_VIEWER_LIGHT2COLOR_EDIT,33,43,23,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP - CONTROL "",IDC_LIGHT_VIEWER_LIGHT2COLOR_COLORCTRL, - "DeSmuME_ColorCtrl",WS_TABSTOP,11,43,19,14 - GROUPBOX "Light3",IDC_LIGHT_VIWER_LIGHT3_GROUP,100,33,90,27 - EDITTEXT IDC_LIGHT_VIEWER_LIGHT3VECTOR_EDIT,151,43,35,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP - EDITTEXT IDC_LIGHT_VIEWER_LIGHT3COLOR_EDIT,126,43,23,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP - CONTROL "",IDC_LIGHT_VIEWER_LIGHT3COLOR_COLORCTRL, - "DeSmuME_ColorCtrl",WS_TABSTOP,104,43,19,14 -END - - ///////////////////////////////////////////////////////////////////////////// // // Icon @@ -566,25 +654,6 @@ END #endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_LIGHT_VIEWER, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 190 - TOPMARGIN, 7 - BOTTOMMARGIN, 82 - END -END -#endif // APSTUDIO_INVOKED - #endif // German (Germany) resources ///////////////////////////////////////////////////////////////////////////// @@ -670,6 +739,7 @@ BEGIN MENUITEM "&Force Maintain Ratio", IDC_FORCERATIO MENUITEM SEPARATOR MENUITEM "Display Frame Counter", ID_VIEW_FRAMECOUNTER + MENUITEM "Display FPS", ID_VIEW_DISPLAYFPS END POPUP "&Config" BEGIN @@ -746,6 +816,38 @@ END // Dialog // +IDD_LIGHT_VIEWER DIALOGEX 0, 0, 197, 89 +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CAPTION +CAPTION "Light Viewer" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,140,68,50,14 + GROUPBOX "Light0",IDC_LIGHT_VIWER_LIGHT0_GROUP,7,7,90,27 + EDITTEXT IDC_LIGHT_VIEWER_LIGHT0VECTOR_EDIT,58,16,35,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP + EDITTEXT IDC_LIGHT_VIEWER_LIGHT0COLOR_EDIT,33,16,23,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP + CONTROL "",IDC_LIGHT_VIEWER_LIGHT0COLOR_COLORCTRL, + "DeSmuME_ColorCtrl",WS_TABSTOP,11,16,19,14 + GROUPBOX "Light1",IDC_LIGHT_VIWER_LIGHT1_GROUP,100,7,90,27 + EDITTEXT IDC_LIGHT_VIEWER_LIGHT1VECTOR_EDIT,151,16,35,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP + EDITTEXT IDC_LIGHT_VIEWER_LIGHT1COLOR_EDIT,126,16,23,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP + CONTROL "",IDC_LIGHT_VIEWER_LIGHT1COLOR_COLORCTRL, + "DeSmuME_ColorCtrl",WS_TABSTOP,104,16,19,14 + GROUPBOX "Light2",IDC_LIGHT_VIWER_LIGHT2_GROUP,7,33,90,27 + EDITTEXT IDC_LIGHT_VIEWER_LIGHT2VECTOR_EDIT,58,43,35,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP + EDITTEXT IDC_LIGHT_VIEWER_LIGHT2COLOR_EDIT,33,43,23,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP + CONTROL "",IDC_LIGHT_VIEWER_LIGHT2COLOR_COLORCTRL, + "DeSmuME_ColorCtrl",WS_TABSTOP,11,43,19,14 + GROUPBOX "Light3",IDC_LIGHT_VIWER_LIGHT3_GROUP,100,33,90,27 + EDITTEXT IDC_LIGHT_VIEWER_LIGHT3VECTOR_EDIT,151,43,35,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP + EDITTEXT IDC_LIGHT_VIEWER_LIGHT3COLOR_EDIT,126,43,23,14,ES_AUTOHSCROLL | ES_READONLY | WS_GROUP + CONTROL "",IDC_LIGHT_VIEWER_LIGHT3COLOR_COLORCTRL, + "DeSmuME_ColorCtrl",WS_TABSTOP,104,43,19,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,66,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,68,67,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,80,67,11,14 + LTEXT "secs",IDC_STATIC,92,70,16,8 +END + IDD_CONFIG DIALOGEX 0, 0, 125, 227 STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Configure Keys" @@ -780,10 +882,10 @@ BEGIN LTEXT "Select:",IDC_STATIC,17,190,28,9 END -IDD_MEM_VIEWER DIALOG 0, 0, 428, 178 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_MEM_VIEWER7 DIALOGEX 0, 0, 428, 178 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION CAPTION "View Memory" -FONT 8, "MS Sans Serif" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN CONTROL "8 bit",IDC_8_BIT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,29,10 CONTROL "16 bit",IDC_16_BIT,"Button",BS_AUTORADIOBUTTON,44,4,33,10 @@ -791,15 +893,18 @@ BEGIN LTEXT "Go to:",IDC_STATIC,130,4,33,10 EDITTEXT IDC_GOTOMEM,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP PUSHBUTTON "&GO",IDC_GO,240,1,20,14 - CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,350,1,75,14 - CONTROL "Edit",IDC_MEM_BOX,"MemViewBox",WS_VSCROLL | WS_TABSTOP,4,16,424,142,WS_EX_CLIENTEDGE PUSHBUTTON "&Close",IDC_FERMER,185,162,50,14 + CONTROL "Rediger",IDC_MEM_BOX,"MemViewBox7",WS_VSCROLL | WS_TABSTOP,4,16,424,142,WS_EX_CLIENTEDGE + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,1,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,382,2,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,394,2,11,14 + LTEXT "secs",IDC_STATIC,406,5,16,8 END -IDD_DESASSEMBLEUR_VIEWER DIALOG 0, 0, 380, 186 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_DESASSEMBLEUR_VIEWER7 DIALOGEX 0, 0, 380, 186 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "Disassembler" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN CONTROL "Auto ",IDC_AUTO_DES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,35,10 CONTROL "ARM",IDC_ARM,"Button",BS_AUTORADIOBUTTON,44,4,35,10 @@ -807,9 +912,9 @@ BEGIN LTEXT "Go to:",IDC_STATIC,130,4,33,10 EDITTEXT IDC_GOTODES,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP PUSHBUTTON "&GO",IDC_GO,240,1,20,14 - CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,300,1,75,14 - CONTROL "Edit",IDC_DES_BOX,"DesViewBox",WS_VSCROLL | WS_TABSTOP,4,16,296,150,WS_EX_CLIENTEDGE - PUSHBUTTON "&Close",IDC_FERMER,185,170,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,285,1,54,14 + CONTROL "Edit",IDC_DES_BOX,"DesViewBox7",WS_VSCROLL | WS_TABSTOP,4,16,296,150,WS_EX_CLIENTEDGE + PUSHBUTTON "&Close",IDC_FERMER,248,170,50,14 EDITTEXT IDC_SETPNUM,5,170,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP PUSHBUTTON "&Step",IDC_STEP,75,170,50,14 LTEXT "R0 :",IDC_STATIC,304,16,17,8 @@ -848,6 +953,10 @@ BEGIN LTEXT "00000000",IDC_R15,325,136,40,8 LTEXT "",IDC_MODE,327,158,28,8 LTEXT "",IDC_TMP,327,168,40,8 + EDITTEXT IDC_AUTO_UPDATE_SECS,340,3,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,352,2,11,14 + LTEXT "secs",IDC_STATIC,364,5,16,8 + PUSHBUTTON "&Refresh",IDC_REFRESH,162,170,50,14,BS_ICON END IDD_GAME_INFO DIALOG 0, 0, 150, 150 @@ -872,10 +981,10 @@ BEGIN LTEXT "",IDC_DATA,60,52,100,8 END -IDD_IO_REG DIALOG 0, 0, 150, 150 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_IO_REG DIALOGEX 0, 0, 150, 150 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "IO REG" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN PUSHBUTTON "&Close",IDC_FERMER,50,134,50,14 LTEXT "Int Handler :",IDC_STATIC,4,4,41,8 @@ -892,33 +1001,31 @@ BEGIN LTEXT "",IDC_DISPSTAT,45,36,130,8 LTEXT "",IDC_IPCSYNC,45,44,130,8 LTEXT "",IDC_IPCFIFO,45,52,130,8 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,32,115,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,87,117,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,99,116,11,14 + LTEXT "secs",IDC_STATIC,111,119,16,8 END -IDD_LOG DIALOG 0, 0, 300, 300 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU -CAPTION "Log" -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Edit",IDC_LOG,"LogView",WS_VSCROLL | WS_TABSTOP,4,4,292,280,WS_EX_CLIENTEDGE - PUSHBUTTON "&Close",IDC_FERMER,125,285,50,14 -END - -IDD_PAL DIALOG 0, 0, 120, 165 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_PAL DIALOGEX 0, 0, 120, 184 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "PAL VIEW" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_PAL_SELECT,15,3,90,14,CBS_DROPDOWN | WS_TABSTOP LTEXT "Pal : 0",IDC_PALNUM,3,21,25,8 SCROLLBAR IDC_SCROLLER,30,18,20,14 - CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,60,18,75,14 - PUSHBUTTON "&Close",IDC_FERMER,35,149,50,14 + PUSHBUTTON "&Close",IDC_FERMER,35,169,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,150,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,68,151,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,80,151,11,14 + LTEXT "secs",IDC_STATIC,92,154,16,8 END -IDD_TILE DIALOG 0, 0, 446, 180 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU -CAPTION "TILE VIEW" -FONT 8, "MS Sans Serif" +IDD_TILE DIALOGEX 0, 0, 446, 180 +STYLE DS_SETFONT | DS_CENTER | WS_VISIBLE | WS_CAPTION +CAPTION "TILE Fremvisning" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_PAL_SELECT,4,13,90,14,CBS_DROPDOWN | WS_TABSTOP LTEXT "Pal : 0",IDC_PALNUM,4,31,25,8 @@ -927,17 +1034,20 @@ BEGIN CONTROL "Bitmap",IDC_BITMAP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,4,68,35,10 CONTROL "256 colors",IDC_256COUL,"Button",BS_AUTORADIOBUTTON,4,80,55,10 CONTROL "16 colors",IDC_16COUL,"Button",BS_AUTORADIOBUTTON,4,92,50,10 - CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,369,164,75,14 - CONTROL "Edit",IDC_Tile_BOX,"TileViewBox",WS_TABSTOP,100,2,344,160,WS_EX_CLIENTEDGE - CONTROL "Edit",IDC_MINI_TILE,"MiniTileViewBox",WS_TABSTOP,22,116,56,52,WS_EX_CLIENTEDGE + CONTROL "Edit",IDC_Tile_BOX,"TileViewBox",0x0,100,2,344,160,WS_EX_CLIENTEDGE + CONTROL "Edit",IDC_MINI_TILE,"MiniTileViewBox",0x0,22,116,56,52,WS_EX_CLIENTEDGE LTEXT "Tile num : 0",IDC_TILENUM,23,170,100,8 PUSHBUTTON "&Close",IDC_FERMER,198,164,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,349,165,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,404,165,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,416,164,11,14 + LTEXT "secs",IDC_STATIC,428,167,16,8 END -IDD_MAP DIALOG 0, 0, 485, 320 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_MAP DIALOGEX 0, 0, 485, 320 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "MAP VIEW" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_BG_SELECT,4,4,90,14,CBS_DROPDOWN | WS_TABSTOP LTEXT "Mode :",IDC_STATIC,4,20,45,8 @@ -955,12 +1065,16 @@ BEGIN LTEXT "",IDC_MSIZE,48,70,85,8 LTEXT "",IDC_SCROLL,48,80,85,8 PUSHBUTTON "&Close",IDC_FERMER,4,300,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,92,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,59,93,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,71,93,11,14 + LTEXT "secs",IDC_STATIC,83,96,16,8 END -IDD_OAM DIALOG 0, 0, 300, 200 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_OAM DIALOGEX 0, 0, 300, 200 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "OAM Viewer" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_SCR_SELECT,4,4,90,14,CBS_DROPDOWN | WS_TABSTOP SCROLLBAR IDC_SCROLLER,48,20,20,14 @@ -983,13 +1097,17 @@ BEGIN LTEXT "",IDC_MOS,48,106,42,8 LTEXT "",IDC_PROP0,4,116,86,8 LTEXT "",IDC_PROP1,4,126,86,8 - PUSHBUTTON "&Close",IDC_FERMER,50,134,50,14 + PUSHBUTTON "&Close",IDC_FERMER,50,180,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,161,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,59,162,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,71,161,11,14 + LTEXT "secs",IDC_STATIC,83,163,16,8 END -SOUNDSETTINGSDLG DIALOG 0, 0, 174, 96 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +IDD_SOUNDSETTINGS DIALOGEX 0, 0, 174, 96 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Sound Settings" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN GROUPBOX "Sound Core Settings",-1,3,2,168,28 LTEXT "Sound Core",-1,10,14,40,10 @@ -1003,29 +1121,29 @@ BEGIN PUSHBUTTON "&Cancel",IDCANCEL,127,78,40,14 END -IDD_FIRMSETTINGS DIALOG 0, 0, 161, 145 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +IDD_FIRMSETTINGS DIALOGEX 0, 0, 161, 145 +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Firmware Settings" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN + EDITTEXT IDC_EDIT1,66,14,82,14,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP + EDITTEXT IDC_EDIT2,66,33,82,14,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP + COMBOBOX IDC_COMBO1,66,53,84,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO2,66,71,84,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO3,66,88,84,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO4,66,105,84,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP DEFPUSHBUTTON "&OK",IDOK,7,124,50,14 PUSHBUTTON "&Cancel",IDCANCEL,104,124,50,14 CONTROL "Favourite Color:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,9,55,52,12 - COMBOBOX IDC_COMBO1,66,53,84,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP CONTROL "Birth Month:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,9,72,52,12 - COMBOBOX IDC_COMBO2,66,71,84,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP CONTROL "Birthday:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,9,90,52,12 - COMBOBOX IDC_COMBO3,66,88,84,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP CONTROL "Language:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,9,106,52,12 - COMBOBOX IDC_COMBO4,66,105,84,14,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP CONTROL "Nickname:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,9,17,52,12 - EDITTEXT IDC_EDIT1,66,14,82,14,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP CONTROL "Message:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,9,36,52,12 - EDITTEXT IDC_EDIT2,66,33,82,14,ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP END IDD_MATRIX_VIEWER DIALOGEX 0, 0, 364, 177 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CAPTION | WS_SYSMENU +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_CAPTION CAPTION "Matrix Viewer" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN @@ -1100,17 +1218,138 @@ BEGIN EDITTEXT IDC_MATRIX_VIEWER_TEX_24_EDIT,312,108,40,12,ES_AUTOHSCROLL | ES_READONLY EDITTEXT IDC_MATRIX_VIEWER_TEX_34_EDIT,312,122,40,12,ES_AUTOHSCROLL | ES_READONLY EDITTEXT IDC_MATRIX_VIEWER_TEX_44_EDIT,312,135,40,12,ES_AUTOHSCROLL | ES_READONLY + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,154,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,68,155,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,80,155,11,14 + LTEXT "secs",IDC_STATIC,92,158,16,8 END IDD_ABOUT_BOX DIALOGEX 0, 0, 126, 284 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "About desmume..." +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION +CAPTION "About DeSmuME..." FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "Aceptar",IDC_FERMER,38,263,50,14 + DEFPUSHBUTTON "Close",IDC_FERMER,38,263,50,14 CTEXT "",IDC_AUTHORS_LIST,7,7,112,250,0,WS_EX_CLIENTEDGE END +IDD_INPUT DIALOGEX 0, 0, 325, 148 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Configure controls" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + EDITTEXT IDC_EDIT4,32,69,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT1,7,83,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT3,57,83,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT2,32,97,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT5,271,97,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT10,290,81,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT8,247,80,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT6,271,63,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT11,7,7,50,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT12,268,7,50,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT7,248,30,34,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT9,285,30,30,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY + EDITTEXT IDC_EDIT13,28,30,34,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + EDITTEXT IDC_EDIT14,7,127,26,14,ES_CENTER | ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + DEFPUSHBUTTON "OK",IDOK,205,127,50,14 + PUSHBUTTON "Cancel",IDCANCEL,268,127,50,14 + GROUPBOX "",IDC_STATIC,7,17,311,109 + CONTROL 102,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE | WS_BORDER,92,30,149,86 + CONTROL "",IDC_STATIC,"Static",SS_GRAYRECT,33,83,24,14 + LTEXT "up",IDC_STATIC,41,59,9,8 + LTEXT "left",IDC_STATIC,15,73,12,8 + LTEXT "Y",IDC_STATIC,257,94,8,8 + LTEXT "select",IDC_STATIC,255,44,20,8 + LTEXT "B",IDC_STATIC,282,111,8,8 + LTEXT "A",IDC_STATIC,302,95,8,8 + LTEXT "X",IDC_STATIC,282,77,8,8 + LTEXT "down",IDC_STATIC,37,110,18,8 + LTEXT "start",IDC_STATIC,292,43,16,8 + LTEXT "R",IDC_STATIC,258,10,8,8 + LTEXT "L",IDC_STATIC,60,10,8,8 + LTEXT "right",IDC_STATIC,63,73,16,8 + LTEXT "power",IDC_STATIC,36,46,21,8 + LTEXT "open/close fold",IDC_STATIC,36,129,50,8 +END + +IDD_DESASSEMBLEUR_VIEWER9 DIALOGEX 0, 0, 380, 186 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION +CAPTION "Disassembler" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + CONTROL "Auto ",IDC_AUTO_DES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,35,10 + CONTROL "ARM",IDC_ARM,"Button",BS_AUTORADIOBUTTON,44,4,35,10 + CONTROL "Thumb",IDC_THUMB,"Button",BS_AUTORADIOBUTTON,82,4,40,10 + LTEXT "Go to:",IDC_STATIC,130,4,33,10 + EDITTEXT IDC_GOTODES,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP + PUSHBUTTON "&GO",IDC_GO,240,1,20,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,285,1,54,14 + CONTROL "Edit",IDC_DES_BOX,"DesViewBox9",WS_VSCROLL | WS_TABSTOP,4,16,296,150,WS_EX_CLIENTEDGE + PUSHBUTTON "&Close",IDC_FERMER,248,170,50,14 + EDITTEXT IDC_SETPNUM,5,170,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP + PUSHBUTTON "&Step",IDC_STEP,75,170,50,14 + LTEXT "R0 :",IDC_STATIC,304,16,17,8 + LTEXT "R1 :",IDC_STATIC,304,24,17,8 + LTEXT "R2 :",IDC_STATIC,304,32,17,8 + LTEXT "R3 :",IDC_STATIC,304,40,17,8 + LTEXT "R4 :",IDC_STATIC,304,48,17,8 + LTEXT "R5 :",IDC_STATIC,304,56,17,8 + LTEXT "R6 :",IDC_STATIC,304,64,17,8 + LTEXT "R7 :",IDC_STATIC,304,72,17,8 + LTEXT "R8 :",IDC_STATIC,304,80,17,8 + LTEXT "R9 :",IDC_STATIC,304,88,17,8 + LTEXT "R10 :",IDC_STATIC,304,96,17,8 + LTEXT "R11 :",IDC_STATIC,304,104,17,8 + LTEXT "R12 :",IDC_STATIC,304,112,17,8 + LTEXT "SP :",IDC_STATIC,304,120,17,8 + LTEXT "LR :",IDC_STATIC,304,128,17,8 + LTEXT "PC :",IDC_STATIC,304,136,17,8 + LTEXT "Mode :",IDC_STATIC,304,158,22,8 + LTEXT "SPSR :",IDC_STATIC,304,168,22,8 + LTEXT "00000000",IDC_R0,325,16,40,8 + LTEXT "00000000",IDC_R1,325,24,40,8 + LTEXT "00000000",IDC_R2,325,32,40,8 + LTEXT "00000000",IDC_R3,325,40,40,8 + LTEXT "00000000",IDC_R4,325,48,40,8 + LTEXT "00000000",IDC_R5,325,56,40,8 + LTEXT "00000000",IDC_R6,325,64,40,8 + LTEXT "00000000",IDC_R7,325,72,40,8 + LTEXT "00000000",IDC_R8,325,80,40,8 + LTEXT "00000000",IDC_R9,325,88,40,8 + LTEXT "00000000",IDC_R10,325,96,40,8 + LTEXT "00000000",IDC_R11,325,104,40,8 + LTEXT "00000000",IDC_R12,325,112,40,8 + LTEXT "00000000",IDC_R13,325,120,40,8 + LTEXT "00000000",IDC_R14,325,128,40,8 + LTEXT "00000000",IDC_R15,325,136,40,8 + LTEXT "",IDC_MODE,327,158,28,8 + LTEXT "",IDC_TMP,327,168,40,8 + EDITTEXT IDC_AUTO_UPDATE_SECS,340,3,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,352,2,11,14 + LTEXT "secs",IDC_STATIC,364,5,16,8 + PUSHBUTTON "&Refresh",IDC_REFRESH,162,170,50,14,BS_ICON +END + +IDD_MEM_VIEWER9 DIALOGEX 0, 0, 428, 178 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION +CAPTION "View Memory" +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + CONTROL "8 bit",IDC_8_BIT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,29,10 + CONTROL "16 bit",IDC_16_BIT,"Button",BS_AUTORADIOBUTTON,44,4,33,10 + CONTROL "32 bit",IDC_32_BIT,"Button",BS_AUTORADIOBUTTON,82,4,33,10 + LTEXT "Go to:",IDC_STATIC,130,4,33,10 + EDITTEXT IDC_GOTOMEM,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP + PUSHBUTTON "&GO",IDC_GO,240,1,20,14 + PUSHBUTTON "&Close",IDC_FERMER,185,162,50,14 + CONTROL "Rediger",IDC_MEM_BOX,"MemViewBox9",WS_VSCROLL | WS_TABSTOP,4,16,424,142,WS_EX_CLIENTEDGE + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,1,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,382,2,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,394,2,11,14 + LTEXT "secs",IDC_STATIC,406,5,16,8 +END + ///////////////////////////////////////////////////////////////////////////// // @@ -1120,6 +1359,19 @@ END #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN + IDD_LIGHT_VIEWER, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 190 + TOPMARGIN, 7 + BOTTOMMARGIN, 82 + END + + IDD_PAL, DIALOG + BEGIN + BOTTOMMARGIN, 165 + END + IDD_MATRIX_VIEWER, DIALOG BEGIN LEFTMARGIN, 7 @@ -1135,6 +1387,15 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 277 END + + IDD_INPUT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 318 + VERTGUIDE, 161 + TOPMARGIN, 7 + BOTTOMMARGIN, 141 + END END #endif // APSTUDIO_INVOKED @@ -1223,6 +1484,7 @@ BEGIN MENUITEM "&Force Maintain Ratio", IDC_FORCERATIO MENUITEM SEPARATOR MENUITEM "Display Frame Counter", ID_VIEW_FRAMECOUNTER + MENUITEM "Display Fps", ID_VIEW_DISPLAYFPS END POPUP "&Config" BEGIN @@ -1296,10 +1558,10 @@ END // Dialog // -IDD_MEM_VIEWER DIALOG 0, 0, 428, 178 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_MEM_VIEWER7 DIALOGEX 0, 0, 428, 178 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "Visualisation de la memoire" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN CONTROL "8 bit",IDC_8_BIT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,29,10 CONTROL "16 bit",IDC_16_BIT,"Button",BS_AUTORADIOBUTTON,44,4,33,10 @@ -1307,15 +1569,18 @@ BEGIN LTEXT "Aller E:",IDC_STATIC,130,4,33,10 EDITTEXT IDC_GOTOMEM,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP PUSHBUTTON "&GO",IDC_GO,240,1,20,14 - CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,350,1,75,14 - CONTROL "Edit",IDC_MEM_BOX,"MemViewBox",WS_VSCROLL | WS_TABSTOP,4,16,424,142,WS_EX_CLIENTEDGE + CONTROL "Edit",IDC_MEM_BOX,"MemViewBox7",WS_VSCROLL | WS_TABSTOP,4,16,424,142,WS_EX_CLIENTEDGE PUSHBUTTON "&Fermer",IDC_FERMER,185,162,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,1,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,382,2,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,394,2,11,14 + LTEXT "secs",IDC_STATIC,406,5,16,8 END -IDD_DESASSEMBLEUR_VIEWER DIALOG 0, 0, 380, 186 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_DESASSEMBLEUR_VIEWER7 DIALOGEX 0, 0, 380, 186 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "Desassembleur" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN CONTROL "Auto ",IDC_AUTO_DES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,35,10 CONTROL "ARM",IDC_ARM,"Button",BS_AUTORADIOBUTTON,44,4,35,10 @@ -1323,9 +1588,8 @@ BEGIN LTEXT "Aller E:",IDC_STATIC,130,4,33,10 EDITTEXT IDC_GOTODES,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP PUSHBUTTON "&GO",IDC_GO,240,1,20,14 - CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,300,1,75,14 - CONTROL "Edit",IDC_DES_BOX,"DesViewBox",WS_VSCROLL | WS_TABSTOP,4,16,296,150,WS_EX_CLIENTEDGE - PUSHBUTTON "&Fermer",IDC_FERMER,185,170,50,14 + CONTROL "Edit",IDC_DES_BOX,"DesViewBox7",WS_VSCROLL | WS_TABSTOP,4,16,296,150,WS_EX_CLIENTEDGE + PUSHBUTTON "&Fermer",IDC_FERMER,246,170,50,14 EDITTEXT IDC_SETPNUM,5,170,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP PUSHBUTTON "&Step",IDC_STEP,75,170,50,14 LTEXT "R0 :",IDC_STATIC,304,16,17,8 @@ -1364,6 +1628,11 @@ BEGIN LTEXT "00000000",IDC_R15,325,136,40,8 LTEXT "",IDC_MODE,327,158,28,8 LTEXT "",IDC_TMP,327,168,40,8 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,285,1,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,340,3,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,352,2,11,14 + LTEXT "secs",IDC_STATIC,364,5,16,8 + PUSHBUTTON "&Refresh",IDC_REFRESH,162,170,50,14,BS_ICON END IDD_GAME_INFO DIALOG 0, 0, 150, 150 @@ -1388,10 +1657,10 @@ BEGIN LTEXT "",IDC_DATA,45,52,100,8 END -IDD_IO_REG DIALOG 0, 0, 150, 150 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_IO_REG DIALOGEX 0, 0, 150, 150 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "IO REG" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN PUSHBUTTON "&Fermer",IDC_FERMER,50,134,50,14 LTEXT "Int Handler :",IDC_STATIC,4,4,41,8 @@ -1408,33 +1677,32 @@ BEGIN LTEXT "",IDC_DISPSTAT,45,36,130,8 LTEXT "",IDC_IPCSYNC,45,44,130,8 LTEXT "",IDC_IPCFIFO,45,52,130,8 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,32,115,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,87,117,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,99,116,11,14 + LTEXT "secs",IDC_STATIC,111,119,16,8 END -IDD_LOG DIALOG 0, 0, 300, 300 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU -CAPTION "Log" -FONT 8, "MS Sans Serif" -BEGIN - CONTROL "Edit",IDC_LOG,"LogView",WS_VSCROLL | WS_TABSTOP,4,4,292,280,WS_EX_CLIENTEDGE - PUSHBUTTON "&Fermer",IDC_FERMER,125,285,50,14 -END - -IDD_PAL DIALOG 0, 0, 120, 165 +IDD_PAL DIALOGEX 0, 0, 120, 194 STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU CAPTION "PAL VIEW" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_PAL_SELECT,15,3,90,14,CBS_DROPDOWN | WS_TABSTOP LTEXT "Pal : 0",IDC_PALNUM,3,21,25,8 SCROLLBAR IDC_SCROLLER,30,18,20,14 CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,60,18,75,14 - PUSHBUTTON "&Fermer",IDC_FERMER,35,149,50,14 + PUSHBUTTON "&Fermer",IDC_FERMER,35,169,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,150,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,68,151,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,80,151,11,14 + LTEXT "secs",IDC_STATIC,92,154,16,8 END -IDD_TILE DIALOG 0, 0, 446, 180 +IDD_TILE DIALOGEX 0, 0, 446, 180 STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU CAPTION "TILE VIEW" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_PAL_SELECT,4,13,90,14,CBS_DROPDOWN | WS_TABSTOP LTEXT "Pal : 0",IDC_PALNUM,4,31,25,8 @@ -1443,17 +1711,20 @@ BEGIN CONTROL "Bitmap",IDC_BITMAP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,4,68,35,10 CONTROL "256 couleurs",IDC_256COUL,"Button",BS_AUTORADIOBUTTON,4,80,55,10 CONTROL "16 couleurs",IDC_16COUL,"Button",BS_AUTORADIOBUTTON,4,92,50,10 - CONTROL "Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,369,164,75,14 CONTROL "Edit",IDC_Tile_BOX,"TileViewBox",WS_TABSTOP,100,2,344,160,WS_EX_CLIENTEDGE CONTROL "Edit",IDC_MINI_TILE,"MiniTileViewBox",WS_TABSTOP,22,116,56,52,WS_EX_CLIENTEDGE LTEXT "Tile num : 0",IDC_TILENUM,23,170,100,8 PUSHBUTTON "&Fermer",IDC_FERMER,198,164,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,349,165,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,404,165,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,416,164,11,14 + LTEXT "secs",IDC_STATIC,428,167,16,8 END -IDD_MAP DIALOG 0, 0, 485, 320 -STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU +IDD_MAP DIALOGEX 0, 0, 485, 320 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION CAPTION "MAP VIEW" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_BG_SELECT,4,4,90,14,CBS_DROPDOWN | WS_TABSTOP LTEXT "Mode :",IDC_STATIC,4,20,45,8 @@ -1471,12 +1742,16 @@ BEGIN LTEXT "",IDC_MSIZE,48,70,85,8 LTEXT "",IDC_SCROLL,48,80,85,8 PUSHBUTTON "&Fermer",IDC_FERMER,4,300,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,92,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,59,93,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,71,93,11,14 + LTEXT "secs",IDC_STATIC,83,96,16,8 END -IDD_OAM DIALOG 0, 0, 300, 200 +IDD_OAM DIALOGEX 0, 0, 300, 200 STYLE DS_SETFONT | WS_CAPTION | WS_SYSMENU CAPTION "OAM Viewer" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN COMBOBOX IDC_SCR_SELECT,4,4,90,14,CBS_DROPDOWN | WS_TABSTOP SCROLLBAR IDC_SCROLLER,48,20,20,14 @@ -1499,9 +1774,106 @@ BEGIN LTEXT "",IDC_MOS,48,106,42,8 LTEXT "",IDC_PROP0,4,116,86,8 LTEXT "",IDC_PROP1,4,126,86,8 - PUSHBUTTON "&Fermer",IDC_FERMER,50,134,50,14 + PUSHBUTTON "&Fermer",IDC_FERMER,50,180,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,161,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,59,162,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,71,161,11,14 + LTEXT "secs",IDC_STATIC,83,163,16,8 END +IDD_DESASSEMBLEUR_VIEWER9 DIALOGEX 0, 0, 380, 186 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION +CAPTION "Desassembleur" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + CONTROL "Auto ",IDC_AUTO_DES,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,35,10 + CONTROL "ARM",IDC_ARM,"Button",BS_AUTORADIOBUTTON,44,4,35,10 + CONTROL "Thumb",IDC_THUMB,"Button",BS_AUTORADIOBUTTON,82,4,40,10 + LTEXT "Aller E:",IDC_STATIC,130,4,33,10 + EDITTEXT IDC_GOTODES,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP + PUSHBUTTON "&GO",IDC_GO,240,1,20,14 + CONTROL "Edit",IDC_DES_BOX,"DesViewBox9",WS_VSCROLL | WS_TABSTOP,4,16,296,150,WS_EX_CLIENTEDGE + PUSHBUTTON "&Fermer",IDC_FERMER,246,170,50,14 + EDITTEXT IDC_SETPNUM,5,170,65,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP + PUSHBUTTON "&Step",IDC_STEP,75,170,50,14 + LTEXT "R0 :",IDC_STATIC,304,16,17,8 + LTEXT "R1 :",IDC_STATIC,304,24,17,8 + LTEXT "R2 :",IDC_STATIC,304,32,17,8 + LTEXT "R3 :",IDC_STATIC,304,40,17,8 + LTEXT "R4 :",IDC_STATIC,304,48,17,8 + LTEXT "R5 :",IDC_STATIC,304,56,17,8 + LTEXT "R6 :",IDC_STATIC,304,64,17,8 + LTEXT "R7 :",IDC_STATIC,304,72,17,8 + LTEXT "R8 :",IDC_STATIC,304,80,17,8 + LTEXT "R9 :",IDC_STATIC,304,88,17,8 + LTEXT "R10 :",IDC_STATIC,304,96,17,8 + LTEXT "R11 :",IDC_STATIC,304,104,17,8 + LTEXT "R12 :",IDC_STATIC,304,112,17,8 + LTEXT "SP :",IDC_STATIC,304,120,17,8 + LTEXT "LR :",IDC_STATIC,304,128,17,8 + LTEXT "PC :",IDC_STATIC,304,136,17,8 + LTEXT "Mode :",IDC_STATIC,304,158,22,8 + LTEXT "SPSR :",IDC_STATIC,304,168,22,8 + LTEXT "00000000",IDC_R0,325,16,40,8 + LTEXT "00000000",IDC_R1,325,24,40,8 + LTEXT "00000000",IDC_R2,325,32,40,8 + LTEXT "00000000",IDC_R3,325,40,40,8 + LTEXT "00000000",IDC_R4,325,48,40,8 + LTEXT "00000000",IDC_R5,325,56,40,8 + LTEXT "00000000",IDC_R6,325,64,40,8 + LTEXT "00000000",IDC_R7,325,72,40,8 + LTEXT "00000000",IDC_R8,325,80,40,8 + LTEXT "00000000",IDC_R9,325,88,40,8 + LTEXT "00000000",IDC_R10,325,96,40,8 + LTEXT "00000000",IDC_R11,325,104,40,8 + LTEXT "00000000",IDC_R12,325,112,40,8 + LTEXT "00000000",IDC_R13,325,120,40,8 + LTEXT "00000000",IDC_R14,325,128,40,8 + LTEXT "00000000",IDC_R15,325,136,40,8 + LTEXT "",IDC_MODE,327,158,28,8 + LTEXT "",IDC_TMP,327,168,40,8 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,285,1,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,340,3,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,352,2,11,14 + LTEXT "secs",IDC_STATIC,364,5,16,8 + PUSHBUTTON "&Refresh",IDC_REFRESH,162,170,50,14,BS_ICON +END + +IDD_MEM_VIEWER9 DIALOGEX 0, 0, 428, 178 +STYLE DS_SETFONT | DS_CENTER | WS_CAPTION +CAPTION "Visualisation de la memoire" +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + CONTROL "8 bit",IDC_8_BIT,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,4,29,10 + CONTROL "16 bit",IDC_16_BIT,"Button",BS_AUTORADIOBUTTON,44,4,33,10 + CONTROL "32 bit",IDC_32_BIT,"Button",BS_AUTORADIOBUTTON,82,4,33,10 + LTEXT "Aller E:",IDC_STATIC,130,4,33,10 + EDITTEXT IDC_GOTOMEM,155,1,82,14,ES_UPPERCASE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_GROUP + PUSHBUTTON "&GO",IDC_GO,240,1,20,14 + CONTROL "Edit",IDC_MEM_BOX,"MemViewBox9",WS_VSCROLL | WS_TABSTOP,4,16,424,142,WS_EX_CLIENTEDGE + PUSHBUTTON "&Fermer",IDC_FERMER,185,162,50,14 + CONTROL "&Auto-update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,1,54,14 + EDITTEXT IDC_AUTO_UPDATE_SECS,382,2,12,14,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED + CONTROL "",IDC_AUTO_UPDATE_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS | WS_DISABLED,394,2,11,14 + LTEXT "secs",IDC_STATIC,406,5,16,8 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_PAL, DIALOG + BEGIN + BOTTOMMARGIN, 165 + END +END +#endif // APSTUDIO_INVOKED + #endif // French (France) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/snddx.cpp b/desmume/src/windows/snddx.cpp index b5636131a..bf176991a 100755 --- a/desmume/src/windows/snddx.cpp +++ b/desmume/src/windows/snddx.cpp @@ -30,6 +30,7 @@ const char* __stdcall DXGetErrorDescription8A(HRESULT hr); #endif #include "SPU.h" #include "snddx.h" +#include "CWindow.h" int SNDDXInit(int buffersize); void SNDDXDeInit(); @@ -53,7 +54,8 @@ SNDDXSetVolume LPDIRECTSOUND8 lpDS8; LPDIRECTSOUNDBUFFER lpDSB, lpDSB2; -extern HWND hwnd; + +extern WINCLASS *MainWindow; static s16 *stereodata16; static u32 soundoffset=0; @@ -77,7 +79,7 @@ int SNDDXInit(int buffersize) return -1; } - if ((ret = IDirectSound8_SetCooperativeLevel(lpDS8, hwnd, DSSCL_PRIORITY)) != DS_OK) + if ((ret = IDirectSound8_SetCooperativeLevel(lpDS8, MainWindow->getHWnd(), DSSCL_PRIORITY)) != DS_OK) { sprintf(tempstr, "IDirectSound8_SetCooperativeLevel error: %s - %s", DXGetErrorString8(ret), DXGetErrorDescription8(ret)); MessageBox (NULL, tempstr, "Error", MB_OK | MB_ICONINFORMATION); diff --git a/desmume/src/windows/tileView.cpp b/desmume/src/windows/tileView.cpp index 428ef000d..73c510255 100644 --- a/desmume/src/windows/tileView.cpp +++ b/desmume/src/windows/tileView.cpp @@ -19,103 +19,31 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include -#include #include "tileView.h" +#include "commctrl.h" #include "resource.h" +#include "debug.h" #include "../MMU.h" -LRESULT CALLBACK TileViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); -LRESULT CALLBACK MiniTileViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - -////////////////////////////////////////////////////////////////////////////// - -void InitTileViewBox() +typedef struct { - WNDCLASSEX wc; - - wc.cbSize = sizeof(wc); - wc.lpszClassName = _T("TileViewBox"); - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = TileViewBoxWndProc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(cwindow_struct *); - wc.hIconSm = 0; - - RegisterClassEx(&wc); - - wc.cbSize = sizeof(wc); - wc.lpszClassName = _T("MiniTileViewBox"); - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = MiniTileViewBoxWndProc; - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hIcon = 0; - wc.lpszMenuName = 0; - wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE); - wc.style = 0; - wc.cbClsExtra = 0; - wc.cbWndExtra = sizeof(cwindow_struct *); - wc.hIconSm = 0; - - RegisterClassEx(&wc); -} + u32 autoup_secs; + bool autoup; -////////////////////////////////////////////////////////////////////////////// + HWND hwnd; + u8 * mem; + u16 * pal; + s16 palnum; + u16 tilenum; + u8 coul; + u32 x; + u32 y; +} tileview_struct; -LRESULT MiniTileViewBox_Paint(tileview_struct * win, WPARAM wParam, LPARAM lParam) +tileview_struct *TileView = NULL; + +LRESULT TileViewBox_Direct(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) { - HWND hwnd_dst = GetDlgItem(win->hwnd, IDC_MINI_TILE); - HWND hwnd_src = GetDlgItem(win->hwnd, IDC_Tile_BOX); - HDC hdc_src; - HDC hdc_dst; - char txt[80]; - - PAINTSTRUCT ps; - - hdc_dst = BeginPaint(hwnd_dst, &ps); - hdc_src = GetDC(hwnd_src); - StretchBlt(hdc_dst, 0, 0, 80, 80, hdc_src, win->x, win->y, 8, 8, SRCCOPY); - sprintf(txt, "Tile num : 0x%X", win->tilenum); - SetWindowText(GetDlgItem(win->hwnd, IDC_TILENUM), txt); - EndPaint(hwnd_dst, &ps); - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT CALLBACK MiniTileViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - tileview_struct * win = (tileview_struct *)GetWindowLong(hwnd, 0); - - switch(msg) - { - case WM_NCCREATE: - return 1; - case WM_NCDESTROY: - return 1; - case WM_PAINT : - MiniTileViewBox_Paint(win, wParam, lParam); - return 1; - case WM_ERASEBKGND: - return 1; - default: - break; - } - - return DefWindowProc(hwnd, msg, wParam, lParam); -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT TileViewBox_Direct(tileview_struct * win, WPARAM wParam, LPARAM lParam) -{ - HWND hwnd = GetDlgItem(win->hwnd, IDC_Tile_BOX); HDC hdc; PAINTSTRUCT ps; // SIZE fontsize; @@ -163,9 +91,8 @@ LRESULT TileViewBox_Direct(tileview_struct * win, WPARAM wParam, LPARAM lParam) ////////////////////////////////////////////////////////////////////////////// -LRESULT TileViewBox_Pal256(tileview_struct * win, WPARAM wParam, LPARAM lParam) +LRESULT TileViewBox_Pal256(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) { - HWND hwnd = GetDlgItem(win->hwnd, IDC_Tile_BOX); HDC hdc; PAINTSTRUCT ps; // SIZE fontsize; @@ -215,7 +142,7 @@ LRESULT TileViewBox_Pal256(tileview_struct * win, WPARAM wParam, LPARAM lParam) bitmap[x + (y*256) + (num*8) +(num2*256*8)] = pal[win->mem[x + (y*8) + (num*64) +(num2*2048)]]; SetDIBitsToDevice(mem_dc, 0, 0, 256, 256, 0, 0, 0, 256, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); sprintf(text, "Pal : %d", win->palnum); - SetWindowText(GetDlgItem(win->hwnd, IDC_PALNUM), text); + SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), text); } else TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); @@ -231,9 +158,8 @@ LRESULT TileViewBox_Pal256(tileview_struct * win, WPARAM wParam, LPARAM lParam) ////////////////////////////////////////////////////////////////////////////// -LRESULT TileViewBox_Pal16(tileview_struct * win, WPARAM wParam, LPARAM lParam) +LRESULT TileViewBox_Pal16(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) { - HWND hwnd = GetDlgItem(win->hwnd, IDC_Tile_BOX); HDC hdc; PAINTSTRUCT ps; // SIZE fontsize; @@ -283,7 +209,7 @@ LRESULT TileViewBox_Pal16(tileview_struct * win, WPARAM wParam, LPARAM lParam) } SetDIBitsToDevice(mem_dc, 0, 0, 512, 256, 0, 0, 0, 256, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); sprintf(text, "Pal : %d", win->palnum); - SetWindowText(GetDlgItem(win->hwnd, IDC_PALNUM), text); + SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), text); } else TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); @@ -299,70 +225,110 @@ LRESULT TileViewBox_Pal16(tileview_struct * win, WPARAM wParam, LPARAM lParam) ////////////////////////////////////////////////////////////////////////////// -LRESULT CALLBACK TileViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +LRESULT CALLBACK TileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - tileview_struct * win = (tileview_struct *)GetWindowLong(hwnd, 0); - - switch(msg) - { - case WM_NCCREATE: - return 1; - case WM_NCDESTROY: - return 1; - case WM_PAINT: - switch(win->coul) - { - case 0 : - TileViewBox_Direct(win, wParam, lParam); - return 1; - case 1 : - TileViewBox_Pal256(win, wParam, lParam); - return 1; - case 2 : - TileViewBox_Pal16(win, wParam, lParam); - return 1; - } - return 1; - case WM_LBUTTONDOWN : - switch(win->coul) - { - case 0 : - case 1 : - if(LOWORD(lParam)<(32*8)) - { - win->x = ((LOWORD(lParam)>>3)<<3); - win->y = (HIWORD(lParam)>>3)<<3; - win->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*32; - } - break; - case 2 : - win->x = ((LOWORD(lParam)>>3)<<3); - win->y = (HIWORD(lParam)>>3)<<3; - win->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*64; - break; - } - InvalidateRect(GetDlgItem(win->hwnd, IDC_MINI_TILE), NULL, FALSE); - UpdateWindow(GetDlgItem(win->hwnd, IDC_MINI_TILE)); - //CWindow_Refresh(win); - return 1; - case WM_ERASEBKGND: - return 1; - default: - break; - } - - return DefWindowProc(hwnd, msg, wParam, lParam); + switch(msg) + { + case WM_INITDIALOG: + return 1; + case WM_NCCREATE: + return 1; + case WM_NCDESTROY: + return 1; + case WM_PAINT: + switch(TileView->coul) + { + case 0 : + TileViewBox_Direct(hwnd, TileView, wParam, lParam); + break; + case 1 : + TileViewBox_Pal256(hwnd, TileView, wParam, lParam); + break; + case 2 : + TileViewBox_Pal16(hwnd, TileView, wParam, lParam); + break; + } + break; + case WM_LBUTTONDOWN : + switch(TileView->coul) + { + case 0 : + case 1 : + if(LOWORD(lParam)<(32*8)) + { + TileView->x = ((LOWORD(lParam)>>3)<<3); + TileView->y = (HIWORD(lParam)>>3)<<3; + TileView->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*32; + } + break; + case 2 : + TileView->x = ((LOWORD(lParam)>>3)<<3); + TileView->y = (HIWORD(lParam)>>3)<<3; + TileView->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*64; + break; + } + InvalidateRect(GetDlgItem(hwnd, IDC_MINI_TILE), NULL, FALSE); + return 1; + case WM_ERASEBKGND: + return 1; + } + return DefWindowProc(hwnd, msg, wParam, lParam); } -////////////////////////////////////////////////////////////////////////////// - -BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +LRESULT MiniTileViewBox_Paint(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) { - tileview_struct * win = (tileview_struct *)GetWindowLong(hwnd, DWL_USER); - switch (message) + HWND hwnd_src = GetDlgItem(hwnd, IDC_Tile_BOX); + HDC hdc_src; + HDC hdc_dst; + char txt[80]; + + PAINTSTRUCT ps; + + hdc_dst = BeginPaint(hwnd, &ps); + hdc_src = GetDC(hwnd_src); + StretchBlt(hdc_dst, 0, 0, 80, 80, hdc_src, win->x, win->y, 8, 8, SRCCOPY); + sprintf(txt, "Tile num : 0x%X", win->tilenum); + SetWindowText(GetDlgItem(win->hwnd, IDC_TILENUM), txt); + EndPaint(hwnd, &ps); + return 0; +} + +LRESULT CALLBACK MiniTileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) + { + case WM_NCCREATE: + return 1; + case WM_NCDESTROY: + return 1; + case WM_PAINT : + MiniTileViewBox_Paint(hwnd, TileView, wParam, lParam); + break; + case WM_ERASEBKGND: + return 1; + default: + break; + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +BOOL CALLBACK ViewTilesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) { case WM_INITDIALOG : { + TileView = new tileview_struct; + memset(TileView, 0, sizeof(tileview_struct)); + TileView->hwnd = hwnd; + TileView->mem = ARM9Mem.ARM9_ABG; + TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM); + TileView->autoup_secs = 5; + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETRANGE, 0, MAKELONG(99, 1)); + SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), + UDM_SETPOS32, 0, TileView->autoup_secs); + HWND combo = GetDlgItem(hwnd, IDC_PAL_SELECT); SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen BG PAL"); SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen BG PAL"); @@ -422,55 +388,84 @@ BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar } return 1; case WM_CLOSE : - CWindow_RemoveFromRefreshList(win); - TileView_Deinit(win); - EndDialog(hwnd, 0); + if(TileView->autoup) + { + KillTimer(hwnd, IDT_VIEW_TILE); + TileView->autoup = false; + } + if (TileView!=NULL) + { + delete TileView; + TileView = NULL; + } + //printlog("Close Tile view dialog\n"); + PostQuitMessage(0); return 1; + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + return 1; case WM_HSCROLL : switch LOWORD(wParam) { case SB_LINERIGHT : - ++(win->palnum); - if(win->palnum>15) - win->palnum = 15; + ++(TileView->palnum); + if(TileView->palnum>15) + TileView->palnum = 15; break; case SB_LINELEFT : - --(win->palnum); - if(win->palnum<0) - win->palnum = 0; + --(TileView->palnum); + if(TileView->palnum<0) + TileView->palnum = 0; break; } - CWindow_Refresh(win); + InvalidateRect(hwnd, NULL, FALSE); return 1; case WM_COMMAND : switch (LOWORD (wParam)) { case IDC_FERMER : - CWindow_RemoveFromRefreshList(win); - TileView_Deinit(win); - EndDialog(hwnd, 0); + SendMessage(hwnd, WM_CLOSE, 0, 0); return 1; case IDC_AUTO_UPDATE : - if(win->autoup) + if(TileView->autoup) { - CWindow_RemoveFromRefreshList(win); - win->autoup = FALSE; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false); + KillTimer(hwnd, IDT_VIEW_TILE); + TileView->autoup = FALSE; return 1; } - CWindow_AddToRefreshList(win); - win->autoup = TRUE; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true); + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true); + TileView->autoup = TRUE; + SetTimer(hwnd, IDT_VIEW_TILE, TileView->autoup_secs*1000, (TIMERPROC) NULL); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + if (t != TileView->autoup_secs) + { + TileView->autoup_secs = t; + if (TileView->autoup) + SetTimer(hwnd, IDT_VIEW_TILE, + TileView->autoup_secs*1000, (TIMERPROC) NULL); + } + } return 1; + case IDC_REFRESH: + InvalidateRect(hwnd, NULL, FALSE); + return 1; case IDC_BITMAP : - win->coul = 0; - CWindow_Refresh(win); + TileView->coul = 0; + InvalidateRect(hwnd, NULL, FALSE); return 1; case IDC_256COUL : - win->coul = 1; - CWindow_Refresh(win); + TileView->coul = 1; + InvalidateRect(hwnd, NULL, FALSE); return 1; case IDC_16COUL : - win->coul = 2; - CWindow_Refresh(win); + TileView->coul = 2; + InvalidateRect(hwnd, NULL, FALSE); return 1; case IDC_MEM_SELECT : switch(HIWORD(wParam)) @@ -489,21 +484,21 @@ BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar case 5 : case 6 : case 7 : - win->mem = ARM9Mem.ARM9_ABG + 0x10000*sel; + TileView->mem = ARM9Mem.ARM9_ABG + 0x10000*sel; break; case 8 : case 9 : - win->mem = ARM9Mem.ARM9_BBG + 0x10000*(sel-8); + TileView->mem = ARM9Mem.ARM9_BBG + 0x10000*(sel-8); break; case 10 : case 11 : case 12 : case 13 : - win->mem = ARM9Mem.ARM9_AOBJ + 0x10000*(sel-10); + TileView->mem = ARM9Mem.ARM9_AOBJ + 0x10000*(sel-10); break; case 14 : case 15 : - win->mem = ARM9Mem.ARM9_BOBJ + 0x10000*(sel-14); + TileView->mem = ARM9Mem.ARM9_BOBJ + 0x10000*(sel-14); break; case 16 : case 17 : @@ -515,12 +510,12 @@ BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar case 23 : case 24 : case 25 : - win->mem = ARM9Mem.ARM9_LCD + 0x10000*(sel-16); + TileView->mem = ARM9Mem.ARM9_LCD + 0x10000*(sel-16); break; default : return 1; } - CWindow_Refresh(win); + InvalidateRect(hwnd, NULL, FALSE); return 1; } } @@ -535,26 +530,26 @@ BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar switch(sel) { case 0 : - win->pal = (u16 *)ARM9Mem.ARM9_VMEM; - win->palnum = 0; + TileView->pal = (u16 *)ARM9Mem.ARM9_VMEM; + TileView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); break; case 1 : - win->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200; - win->palnum = 0; + TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200; + TileView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); break; case 2 : - win->pal = (u16 *)ARM9Mem.ARM9_VMEM + 0x100; - win->palnum = 0; + TileView->pal = (u16 *)ARM9Mem.ARM9_VMEM + 0x100; + TileView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); break; case 3 : - win->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; - win->palnum = 0; + TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; + TileView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); break; @@ -562,110 +557,72 @@ BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar case 5 : case 6 : case 7 : - win->pal = ((u16 *)(ARM9Mem.ExtPal[0][sel-4])); - win->palnum = 0; + TileView->pal = ((u16 *)(ARM9Mem.ExtPal[0][sel-4])); + TileView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_HIDE); EnableWindow(GetDlgItem(hwnd, IDC_16COUL), FALSE); - if(win->coul == 2) + if(TileView->coul == 2) { SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); - win->coul = 1; + TileView->coul = 1; } break; case 8 : case 9 : case 10 : case 11 : - win->pal = ((u16 *)(ARM9Mem.ExtPal[1][sel-8])); - win->palnum = 0; + TileView->pal = ((u16 *)(ARM9Mem.ExtPal[1][sel-8])); + TileView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_HIDE); EnableWindow(GetDlgItem(hwnd, IDC_16COUL), FALSE); - if(win->coul == 2) + if(TileView->coul == 2) { SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); - win->coul = 1; + TileView->coul = 1; } break; case 12 : case 13 : - win->pal = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12])); - win->palnum = 0; - if(win->coul == 2) + TileView->pal = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12])); + TileView->palnum = 0; + if(TileView->coul == 2) { SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); - win->coul = 1; + TileView->coul = 1; } break; case 14 : case 15 : - win->pal = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14])); - win->palnum = 0; - if(win->coul == 2) + TileView->pal = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14])); + TileView->palnum = 0; + if(TileView->coul == 2) { SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); - win->coul = 1; + TileView->coul = 1; } break; case 16 : case 17 : case 18 : case 19 : - win->pal = ((u16 *)(ARM9Mem.texPalSlot[sel-16])); - win->palnum = 0; + TileView->pal = ((u16 *)(ARM9Mem.texPalSlot[sel-16])); + TileView->palnum = 0; ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); break; default : return 1; } - CWindow_Refresh(win); + InvalidateRect(hwnd, NULL, FALSE); return 1; } } } return 0; } - return 0; + return DefWindowProc(hwnd, message, wParam, lParam); } - -////////////////////////////////////////////////////////////////////////////// - -tileview_struct *TileView_Init(HINSTANCE hInst, HWND parent) -{ - tileview_struct *TileView=NULL; - - if ((TileView = (tileview_struct *)malloc(sizeof(tileview_struct))) == NULL) - return TileView; - - if (CWindow_Init2(TileView, hInst, parent, "Tile viewer", IDD_TILE, TileView_Proc) != 0) - { - free(TileView); - return NULL; - } - - TileView->mem = ARM9Mem.ARM9_ABG; - TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM); - TileView->palnum = 0; - TileView->coul = 0; - TileView->x = 0; - TileView->y = 0; - - SetWindowLong(GetDlgItem(TileView->hwnd, IDC_Tile_BOX), 0, (LONG)TileView); - SetWindowLong(GetDlgItem(TileView->hwnd, IDC_MINI_TILE), 0, (LONG)TileView); - - return TileView; -} - -////////////////////////////////////////////////////////////////////////////// - -void TileView_Deinit(tileview_struct *TileView) -{ - if (TileView) - free(TileView); -} - -////////////////////////////////////////////////////////////////////////////// diff --git a/desmume/src/windows/tileView.h b/desmume/src/windows/tileView.h index b3deaa95b..6c466ab1b 100644 --- a/desmume/src/windows/tileView.h +++ b/desmume/src/windows/tileView.h @@ -22,29 +22,11 @@ #ifndef TILEVIEW_H #define TILEVIEW_H -#include "CWindow.h" +#include +#include -typedef struct -{ - HWND hwnd; - BOOL autoup; - void *prev; - void *next; - void *first; - void (*Refresh)(void *win); - - u8 * mem; - u16 * pal; - s16 palnum; - u16 tilenum; - u8 coul; - u32 x; - u32 y; -} tileview_struct; - - -void InitTileViewBox(); -tileview_struct *TileView_Init(HINSTANCE hInst, HWND parent); -void TileView_Deinit(tileview_struct *TileView); +extern LRESULT CALLBACK TileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +extern LRESULT CALLBACK MiniTileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); +extern BOOL CALLBACK ViewTilesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); #endif