win port:

- Rewrite all debug tools;
- Fix for compile and reorganize VS2008 project
This commit is contained in:
mtabachenko 2008-09-23 14:30:44 +00:00
parent bc8944701f
commit 56cc01681d
32 changed files with 5329 additions and 5168 deletions

View File

@ -61,6 +61,7 @@
? 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:

View File

@ -18,14 +18,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <mmsystem.h>
#include <COMMDLG.H>
#include <string.h>
#include "CWindow.h"
#include <windows.h>
#include "AboutBox.h"
#include "resource.h"

View File

@ -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

View File

@ -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;
hwnd = NULL;
hmenu = NULL;
hInstance = hInst;
}
if(!first)
WINCLASS::~WINCLASS()
{
}
bool WINCLASS::create(LPSTR caption, int x, int y, int width, int height, int style, HMENU menu)
{
if (hwnd != NULL) return false;
hwnd = CreateWindow(regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL);
if (hwnd != NULL) return true;
return false;
}
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)
{
WNDCLASSEX wincl; // Data structure for the windowclass
CloseHandle(hThread);
hThread = NULL;
}
}
// 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);
bool THREADCLASS::createThread()
{
if (hThread) return false;
// 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;
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &threadID);
if (!hThread) return false;
//WaitForSingleObject(hThread, INFINITE);
return true;
}
// Register the window class, and if it fails quit the program
if (!RegisterClassEx (&wincl))
return -1;
win2->first=NULL;
first = TRUE;
//========================================================= Tools class
TOOLSCLASS::TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC dlgproc)
{
this->dlgproc = dlgproc;
hwnd = NULL;
hInstance = hInst;
idd=IDD;
memset(class_name, 0, sizeof(class_name));
memset(class_name2, 0, sizeof(class_name2));
}
TOOLSCLASS::~TOOLSCLASS()
{
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);
}
clientaera.left = 0;
clientaera.top = 0;
clientaera.right = sx;
clientaera.bottom = sy;
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
AdjustWindowRectEx(&clientaera, style, TRUE, 0);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
// 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;
unregClass();
hwnd = NULL;
closeThread();
return 0;
}
//////////////////////////////////////////////////////////////////////////////
int CWindow_Init2(void *win, HINSTANCE hInst, HWND parent, char * title, int ID, DLGPROC wP)
void TOOLSCLASS::regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg)
{
HMENU hSystemMenu;
WNDCLASSEX wc;
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)
{
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;
// Update the "auto update" menu item
hSystemMenu = GetSystemMenu(win->hwnd, FALSE);
if(hSystemMenu != 0)
{
const int checkState[] =
{
MF_UNCHECKED,
MF_CHECKED
};
CheckMenuItem(hSystemMenu, IDC_AUTO_UPDATE, checkState[check]);
}
}
//////////////////////////////////////////////////////////////////////////////
void CWindow_AddToRefreshList(void *win)
{
cwindow_struct *win2=(cwindow_struct *)win;
EnterCriticalSection(&section);
win2->prev = NULL;
win2->next = updatewindowlist;
if(updatewindowlist)
updatewindowlist->prev = win;
updatewindowlist = (cwindow_struct *)win;
LeaveCriticalSection(&section);
CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, TRUE);
}
//////////////////////////////////////////////////////////////////////////////
void CWindow_RemoveFromRefreshList(void *win)
{
cwindow_struct *win2=(cwindow_struct *)win;
EnterCriticalSection(&section);
if(updatewindowlist == win)
{
updatewindowlist = (cwindow_struct *)win2->next;
if(updatewindowlist) updatewindowlist->prev = NULL;
}
wc.cbSize = sizeof(wc);
if (SecondReg)
strcpy(this->class_name2, class_name);
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(&section);
strcpy(this->class_name, class_name);
CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, FALSE);
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);
}
//////////////////////////////////////////////////////////////////////////////
int CWindow_ToggleAutoUpdate(void *win)
void TOOLSCLASS::unregClass()
{
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;
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));
}

View File

@ -22,48 +22,69 @@
#ifndef CWINDOW_H
#define CWINDOW_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "types.h"
#ifdef _x64
#define DWL_USER DWLP_USER
#endif
extern CRITICAL_SECTION section;
typedef struct
class WINCLASS
{
private:
HWND hwnd;
BOOL autoup;
void *prev;
void *next;
void *first;
void (*Refresh)(void *win);
} cwindow_struct;
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(&section);
aux = updatewindowlist;
while(aux)
{
aux->Refresh(aux);
aux = (cwindow_struct *)aux->next;
}
LeaveCriticalSection(&section);
}
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

View File

@ -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
//================================================================================================
//================================================================================================
@ -474,3 +444,47 @@ void Input_Process()
}
}
}
//============================================================ 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);
}

View File

@ -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

View File

@ -55,8 +55,8 @@
EnableFiberSafeOptimizations="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;0.8.0b2 DEBUG\&quot;;WIN32;BETA_VERSION;SPU_INTERPOLATE"
ExceptionHandling="0"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;DEBUG\&quot;;WIN32;BETA_VERSION;SPU_INTERPOLATE"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="0"
DebugInformationFormat="4"
@ -74,7 +74,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib"
AdditionalDependencies="comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib"
OutputFile="$(OutDir)\$(ProjectName)_debug.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
@ -140,8 +140,8 @@
EnableFiberSafeOptimizations="false"
WholeProgramOptimization="false"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;0.8.0b2 x64 DEBUG\&quot;;WIN32;_x64;BETA_VERSION;SPU_INTERPOLATE"
ExceptionHandling="0"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;x64 DEBUG\&quot;;WIN32;_x64;BETA_VERSION;SPU_INTERPOLATE"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="0"
DebugInformationFormat="3"
@ -227,9 +227,9 @@
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;0.8.0b2 SSE2\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;SSE2\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE;NOMINMAX"
StringPooling="true"
ExceptionHandling="0"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
@ -249,13 +249,13 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib"
AdditionalDependencies="comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr8.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib"
OutputFile="$(OutDir)\$(ProjectName)_sse2.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
Profile="true"
Profile="false"
/>
<Tool
Name="VCALinkTool"
@ -315,8 +315,8 @@
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;0.8.0b2 x64 SSE2\&quot;;WIN32;_x64;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE"
ExceptionHandling="0"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;x64 SSE2\&quot;;WIN32;_x64;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="0"
WarningLevel="1"
@ -369,8 +369,8 @@
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
OutputDirectory="$(SolutionDir)\__bins"
IntermediateDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
WholeProgramOptimization="1"
@ -405,7 +405,7 @@
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;0.8.0b2\&quot;;WIN32;HAVE_LIBZ;HAVE_LIBZZIP;BETA_VERSION;SPU_INTERPOLATE"
StringPooling="true"
ExceptionHandling="0"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
@ -425,7 +425,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib"
AdditionalDependencies="comctl32.lib opengl32.lib glu32.lib ws2_32.lib user32.lib gdi32.lib directx\dxguid.lib shell32.lib comdlg32.lib directx\dxerr.lib directx\dsound.lib directx\dinput8.lib directx\ddraw.lib zlib-2008-x32.lib zziplib-2008-x32.lib"
OutputFile="$(OutDir)\$(ProjectName)_sse2.exe"
AdditionalLibraryDirectories=".\zlib123;.\zziplib"
GenerateDebugInformation="true"
@ -458,8 +458,8 @@
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
OutputDirectory="$(SolutionDir)\__bins"
IntermediateDirectory="$(SolutionDir)\.VS2008\$(ConfigurationName)\$(PlatformName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
>
@ -491,8 +491,8 @@
EnableFiberSafeOptimizations="true"
WholeProgramOptimization="true"
AdditionalIncludeDirectories="..;.\zlib123;.\zziplib"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;0.8.0b2 x64 SSE2\&quot;;WIN32;_x64;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE"
ExceptionHandling="0"
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;VERSION=\&quot;x64 SSE2\&quot;;WIN32;_x64;HAVE_LIBZ;HAVE_LIBZZIP;SSE2;BETA_VERSION;SPU_INTERPOLATE"
ExceptionHandling="1"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="0"
WarningLevel="1"
@ -552,10 +552,9 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\AboutBox.cpp"
<Filter
Name="core"
>
</File>
<File
RelativePath="..\arm_instructions.cpp"
>
@ -573,25 +572,13 @@
>
</File>
<File
RelativePath=".\colorctrl.cpp"
>
</File>
<File
RelativePath=".\ConfigKeys.cpp"
>
</File>
<File
RelativePath=".\console.cpp"
RelativePath="..\common.cpp"
>
</File>
<File
RelativePath="..\cp15.cpp"
>
</File>
<File
RelativePath=".\CWindow.cpp"
>
</File>
<File
RelativePath="..\debug.cpp"
>
@ -600,32 +587,16 @@
RelativePath="..\Disassembler.cpp"
>
</File>
<File
RelativePath=".\disView.cpp"
>
</File>
<File
RelativePath="..\FIFO.cpp"
>
</File>
<File
RelativePath=".\FirmConfig.cpp"
>
</File>
<File
RelativePath="..\fs-windows.cpp"
>
</File>
<File
RelativePath="..\gdbstub\gdbstub.cpp"
>
</File>
<File
RelativePath="..\gfx3d.cpp"
>
</File>
<File
RelativePath=".\ginfo.cpp"
RelativePath="..\gl_vertex.cpp"
>
</File>
<File
@ -636,22 +607,6 @@
RelativePath="..\GPU_OSD.cpp"
>
</File>
<File
RelativePath=".\IORegView.cpp"
>
</File>
<File
RelativePath=".\lightView.cpp"
>
</File>
<File
RelativePath=".\main.cpp"
>
</File>
<File
RelativePath=".\mapView.cpp"
>
</File>
<File
RelativePath="..\matrix.cpp"
>
@ -763,18 +718,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\matrixView.cpp"
>
</File>
<File
RelativePath="..\mc.cpp"
>
</File>
<File
RelativePath=".\memView.cpp"
>
</File>
<File
RelativePath="..\MMU.cpp"
>
@ -783,20 +730,12 @@
RelativePath="..\NDSSystem.cpp"
>
</File>
<File
RelativePath=".\oamView.cpp"
>
</File>
<File
RelativePath=".\ogl.cpp"
>
</File>
<File
RelativePath="..\OGLRender.cpp"
>
</File>
<File
RelativePath=".\palView.cpp"
RelativePath="..\readwrite.cpp"
>
</File>
<File
@ -811,40 +750,212 @@
RelativePath="..\saves.cpp"
>
</File>
<File
RelativePath=".\snddx.cpp"
>
</File>
<File
RelativePath="..\SPU.cpp"
>
</File>
<File
RelativePath=".\throttle.cpp"
>
</File>
<File
RelativePath="..\thumb_instructions.cpp"
>
</File>
<File
RelativePath=".\tileView.cpp"
>
</File>
<File
RelativePath="..\wifi.cpp"
>
</File>
</Filter>
<Filter
Name="windows"
>
<File
RelativePath=".\AboutBox.cpp"
>
</File>
<File
RelativePath=".\colorctrl.cpp"
>
</File>
<File
RelativePath=".\ConfigKeys.cpp"
>
</File>
<File
RelativePath=".\console.cpp"
>
</File>
<File
RelativePath=".\CWindow.cpp"
>
</File>
<File
RelativePath=".\disView.cpp"
>
</File>
<File
RelativePath=".\FirmConfig.cpp"
>
</File>
<File
RelativePath=".\fs-windows.cpp"
>
</File>
<File
RelativePath=".\ginfo.cpp"
>
</File>
<File
RelativePath=".\IORegView.cpp"
>
</File>
<File
RelativePath=".\lightView.cpp"
>
</File>
<File
RelativePath=".\main.cpp"
>
</File>
<File
RelativePath=".\mapView.cpp"
>
</File>
<File
RelativePath=".\matrixView.cpp"
>
</File>
<File
RelativePath=".\memView.cpp"
>
</File>
<File
RelativePath=".\oamView.cpp"
>
</File>
<File
RelativePath=".\ogl.cpp"
>
</File>
<File
RelativePath=".\palView.cpp"
>
</File>
<File
RelativePath=".\snddx.cpp"
>
</File>
<File
RelativePath=".\throttle.cpp"
>
</File>
<File
RelativePath=".\tileView.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\font_eng.inc"
>
</File>
<File
RelativePath="..\instruction_tabdef.inc"
>
</File>
<File
RelativePath="..\thumb_tabdef.inc"
>
</File>
<Filter
Name="windows"
>
<File
RelativePath=".\AboutBox.h"
>
</File>
<File
RelativePath=".\colorconv.h"
>
</File>
<File
RelativePath=".\colorctrl.h"
>
</File>
<File
RelativePath=".\ConfigKeys.h"
>
</File>
<File
RelativePath=".\console.h"
>
</File>
<File
RelativePath=".\CWindow.h"
>
</File>
<File
RelativePath=".\disView.h"
>
</File>
<File
RelativePath=".\FirmConfig.h"
>
</File>
<File
RelativePath=".\ginfo.h"
>
</File>
<File
RelativePath=".\IORegView.h"
>
</File>
<File
RelativePath=".\lightView.h"
>
</File>
<File
RelativePath=".\mapView.h"
>
</File>
<File
RelativePath=".\matrixView.h"
>
</File>
<File
RelativePath=".\memView.h"
>
</File>
<File
RelativePath=".\oamView.h"
>
</File>
<File
RelativePath=".\palView.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\snddx.h"
>
</File>
<File
RelativePath=".\throttle.h"
>
</File>
<File
RelativePath=".\tileView.h"
>
</File>
</Filter>
<Filter
Name="core"
>
<File
RelativePath="..\ARM9.h"
>
@ -870,33 +981,13 @@
>
</File>
<File
RelativePath=".\colorconv.h"
>
</File>
<File
RelativePath=".\colorctrl.h"
>
</File>
<File
RelativePath="..\config.h"
>
</File>
<File
RelativePath=".\ConfigKeys.h"
>
</File>
<File
RelativePath=".\console.h"
RelativePath="..\common.h"
>
</File>
<File
RelativePath="..\cp15.h"
>
</File>
<File
RelativePath=".\CWindow.h"
>
</File>
<File
RelativePath="..\debug.h"
>
@ -905,10 +996,6 @@
RelativePath="..\Disassembler.h"
>
</File>
<File
RelativePath=".\disView.h"
>
</File>
<File
RelativePath="..\dscard.h"
>
@ -921,10 +1008,6 @@
RelativePath="..\FIFO.h"
>
</File>
<File
RelativePath=".\FirmConfig.h"
>
</File>
<File
RelativePath="..\fs.h"
>
@ -933,16 +1016,12 @@
RelativePath="..\gdbstub.h"
>
</File>
<File
RelativePath="..\gdbstub\gdbstub_internal.h"
>
</File>
<File
RelativePath="..\gfx3d.h"
>
</File>
<File
RelativePath=".\ginfo.h"
RelativePath="..\gl_vertex.h"
>
</File>
<File
@ -953,26 +1032,10 @@
RelativePath="..\GPU_osd.h"
>
</File>
<File
RelativePath=".\IORegView.h"
>
</File>
<File
RelativePath=".\lightView.h"
>
</File>
<File
RelativePath=".\mapView.h"
>
</File>
<File
RelativePath="..\matrix.h"
>
</File>
<File
RelativePath=".\matrixView.h"
>
</File>
<File
RelativePath="..\mc.h"
>
@ -982,7 +1045,7 @@
>
</File>
<File
RelativePath=".\memView.h"
RelativePath="..\memorystream.h"
>
</File>
<File
@ -993,16 +1056,12 @@
RelativePath="..\NDSSystem.h"
>
</File>
<File
RelativePath=".\oamView.h"
>
</File>
<File
RelativePath="..\OGLRender.h"
>
</File>
<File
RelativePath=".\palView.h"
RelativePath="..\readwrite.h"
>
</File>
<File
@ -1013,14 +1072,6 @@
RelativePath="..\render3D.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\resrc1.h"
>
</File>
<File
RelativePath="..\ROMReader.h"
>
@ -1029,26 +1080,14 @@
RelativePath="..\saves.h"
>
</File>
<File
RelativePath=".\snddx.h"
>
</File>
<File
RelativePath="..\SPU.h"
>
</File>
<File
RelativePath=".\throttle.h"
>
</File>
<File
RelativePath="..\thumb_instructions.h"
>
</File>
<File
RelativePath=".\tileView.h"
>
</File>
<File
RelativePath="..\types.h"
>
@ -1057,10 +1096,7 @@
RelativePath="..\wifi.h"
>
</File>
<File
RelativePath=".\yopyop_private.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Resource Files"
@ -1071,6 +1107,10 @@
RelativePath=".\DeSmuME.ico"
>
</File>
<File
RelativePath=".\NintendoDS(tm)_logo.bmp"
>
</File>
<File
RelativePath=".\resources.rc"
>

View File

@ -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);

View File

@ -19,13 +19,19 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include "CWindow.h"
#include "ioregview.h"
#include <commctrl.h>
#include "debug.h"
#include "resource.h"
#include "../MMU.h"
#include <stdio.h>
//////////////////////////////////////////////////////////////////////////////
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);
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -21,7 +21,8 @@
#ifndef IO_REG_H
#define IO_REG_H
#include <windows.h>
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

View File

@ -24,388 +24,29 @@
#include <stdio.h>
#include "../MMU.h"
#include "../Disassembler.h"
#include "../NDSSystem.h"
#include "../armcpu.h"
#include "disView.h"
#include <commctrl.h>
#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<lg; ++i)
{
if((tmp[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,7 +84,7 @@ LRESULT DisViewBox_OnPaint(disview_struct *win, WPARAM wParam, LPARAM lParam)
u32 i;
u32 adr;
if (win->autoup)
if (win->autoup||win->autogo)
win->curr_ligne = (win->cpu->instruct_adr >> 2) - (win->curr_ligne % nbligne) ;
adr = win->curr_ligne*4;
@ -515,8 +156,6 @@ 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;
@ -581,12 +220,9 @@ 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:
@ -595,11 +231,11 @@ LRESULT CALLBACK DisViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
return 1;
case WM_NCDESTROY:
free(win);
//free(win);
return 1;
case WM_PAINT:
DisViewBox_OnPaint(win, wParam, lParam);
DisViewBox_OnPaint(hwnd, DisView7, wParam, lParam);
return 1;
case WM_VSCROLL :
@ -620,126 +256,125 @@ LRESULT CALLBACK DisViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
switch LOWORD(wParam)
{
case SB_LINEDOWN :
win->curr_ligne = std::min<s32>(0x3FFFFF7*(1+win->cpu->CPSR.bits.T), win->curr_ligne+1);
DisView7->curr_ligne = std::min<s32>(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+1);
break;
case SB_LINEUP :
win->curr_ligne = (u32)std::max<s32>(0, (s32)win->curr_ligne-1);
DisView7->curr_ligne = (u32)std::max<s32>(0, (s32)DisView7->curr_ligne-1);
break;
case SB_PAGEDOWN :
win->curr_ligne = std::min<s32>(0x3FFFFF7*(1+win->cpu->CPSR.bits.T), win->curr_ligne+nbligne);
DisView7->curr_ligne = std::min<s32>(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+nbligne);
break;
case SB_PAGEUP :
win->curr_ligne = (u32)std::max<s32>(0, (s32)win->curr_ligne-nbligne);
DisView7->curr_ligne = (u32)std::max<s32>(0, DisView7->curr_ligne-nbligne);
break;
}
SelectObject(dc, old);
SetScrollPos(hwnd, SB_VERT, win->curr_ligne, TRUE);
SetScrollPos(hwnd, SB_VERT, DisView7->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 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)
{
case WM_INITDIALOG :
{
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);
{
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);
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;
}
return 0;
}
return 0;
}
//////////////////////////////////////////////////////////////////////////////
disview_struct *DisView_Init(HINSTANCE hInst, HWND parent, char *title, armcpu_t *CPU)
{
disview_struct *DisView=NULL;
if ((DisView = (disview_struct *)malloc(sizeof(disview_struct))) == NULL)
return DisView;
if (CWindow_Init2(DisView, hInst, parent, title, IDD_DESASSEMBLEUR_VIEWER, DisView_Proc) != 0)
case IDC_AUTO_UPDATE_SECS:
{
free(DisView);
return NULL;
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;
}
DisView->cpu = CPU;
DisView->mode = 0;
DisView->Refresh = (void (*)(void *))&DisView_Refresh;
SetWindowLong(GetDlgItem(DisView->hwnd, IDC_DES_BOX), 0, (LONG)DisView);
return DisView;
return DefWindowProc(hwnd, message, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
void DisView_Deinit(disview_struct *DisView)
// =================================================== ARM9
LRESULT CALLBACK ViewDisasm_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (DisView)
free(DisView);
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(hwnd, DisView9, wParam, lParam);
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 :
DisView9->curr_ligne = std::min<s32>(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+1);
break;
case SB_LINEUP :
DisView9->curr_ligne = (u32)std::max<s32>(0, (s32)DisView9->curr_ligne-1);
break;
case SB_PAGEDOWN :
DisView9->curr_ligne = std::min<s32>(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+nbligne);
break;
case SB_PAGEUP :
DisView9->curr_ligne = (u32)std::max<s32>(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_Refresh(disview_struct *DisView)
BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
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);
}
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<lg; ++i)
{
if((tmp[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);
}

View File

@ -22,28 +22,12 @@
#ifndef DISVIEW_H
#define DISVIEW_H
#include "../NDSSystem.h"
#include "../armcpu.h"
#include <windows.h>
#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

View File

@ -17,39 +17,23 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include <stdio.h>
#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:
LightView_OnInitDialog(hwnd);
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;
case WM_CLOSE:
LightView_OnClose(win);
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_PAINT:
LightView_OnPaint(win, hwnd, wParam, lParam);
LightView_OnPaint(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);
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;
}
return 0;
case WM_SYSCOMMAND:
switch (LOWORD (wParam))
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:
{
case IDC_AUTO_UPDATE:
CWindow_ToggleAutoUpdate(win);
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 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);
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -20,15 +20,8 @@
#ifndef LIGHTVIEW_H
#define LIGHTVIEW_H
#include "CWindow.h"
#include <windows.h>
typedef struct
{
cwindow_struct window;
} lightview_struct;
lightview_struct *LightView_Init(HINSTANCE hInst, HWND parent);
void LightView_Deinit(lightview_struct *view);
extern BOOL CALLBACK ViewLightsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
#endif

View File

@ -58,6 +58,8 @@
#include "console.h"
#include "throttle.h"
#include "../common.h"
#include "snddx.h"
#include "directx/ddraw.h"
@ -88,11 +90,27 @@ int romnum = 0;
DWORD threadID;
HWND hwnd;
HDC hdc;
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;
@ -102,7 +120,7 @@ BOOL click = FALSE;
BOOL finished = FALSE;
BOOL romloaded = FALSE;
void SetRotate(int rot);
void SetRotate(HWND hwnd, int rot);
BOOL ForceRatio = TRUE;
float DefaultWidth;
@ -120,7 +138,7 @@ const DWORD DI_tabkey[48] = {DIK_0,DIK_1,DIK_2,DIK_3,DIK_4,DIK_5,DIK_6,DIK_7,DIK
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];
//static char IniName[MAX_PATH];
int sndcoretype=SNDCORE_DIRECTX;
int sndbuffersize=735*4;
int sndvolume=100;
@ -145,6 +163,7 @@ static u32 backupmemorysize=1;
unsigned int frameCounter=0;
bool frameAdvance = false;
bool frameCounterDisplay = false;
bool FpsDisplay = false;
unsigned short windowSize = 0;
/* the firmware settings */
@ -528,7 +547,7 @@ int CreateDDrawBuffers()
if (IDirectDraw7_CreateClipper(lpDDraw, 0, &lpDDClipPrimary, NULL) != DD_OK) return -3;
if (IDirectDrawClipper_SetHWnd(lpDDClipPrimary, 0, hwnd) != DD_OK) return -4;
if (IDirectDrawClipper_SetHWnd(lpDDClipPrimary, 0, MainWindow->getHWnd()) != DD_OK) return -4;
if (IDirectDrawSurface7_SetClipper(lpPrimarySurface, lpDDClipPrimary) != DD_OK) return -5;
return 1;
@ -654,6 +673,7 @@ DWORD WINAPI run( LPVOID lpParameter)
int fpsframecount=0;
u64 fpsticks=0;
int res;
HWND hwnd = MainWindow->getHWnd();
DDCAPS hw_caps, sw_caps;
@ -723,7 +743,7 @@ DWORD WINAPI run( LPVOID lpParameter)
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);
if (FpsDisplay) osd->addFixed(10, 10, "%02d Fps", fps);
}
framesskipped = 0;
@ -892,9 +912,9 @@ void CheckLanguage(UINT id)
{
int i;
for (i = IDC_LANGENGLISH; i < IDC_LANGFRENCH+1; i++)
CheckMenuItem(menu, i, MF_BYCOMMAND | MF_UNCHECKED);
MainWindow->checkMenu(i, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(menu, id, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(id, MF_BYCOMMAND | MF_CHECKED);
}
void ChangeLanguage(int id)
@ -903,16 +923,31 @@ void ChangeLanguage(int id)
SetLanguage(id);
newmenu = LoadMenu(hAppInst, "MENU_PRINCIPAL");
SetMenu(hwnd, newmenu);
SetMenu(MainWindow->getHWnd(), newmenu);
DestroyMenu(menu);
menu = newmenu;
}
void InitCustomControls()
int RegClass(WNDPROC Proc, LPCTSTR szName)
{
ColorCtrl_Register();
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,
@ -935,34 +970,47 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
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(&section);
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;
}
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));
@ -971,44 +1019,46 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
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)
if (!MainWindow->setMenu(LoadMenu(hThisInstance, "MENU_PRINCIPAL")))
{
MessageBox(NULL,"Unable to create main window","Error",MB_OK);
return 0;
MessageBox(NULL, "Error creating main menu", "DeSmuME", MB_OK);
delete MainWindow;
exit(-1);
}
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));
MainWindow->checkMenu(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));
MainWindow->checkMenu(ID_VIEW_DISPLAYFPS, FpsDisplay ? 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));
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));
Input_Init(hwnd);
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));
hdc = GetDC(hwnd);
DragAcceptFiles(hwnd, TRUE);
DragAcceptFiles(MainWindow->getHWnd(), TRUE);
/* Make the window visible on the screen */
CWindow_Show(&MainWindow);
InitMemViewBox();
InitDesViewBox();
InitTileViewBox();
InitOAMViewBox();
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,
@ -1048,7 +1098,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
activateStub_gdb( arm7_gdb_stub, arm7_ctrl_iface);
}
#endif
GetPrivateProfileString("General", "Language", "0", text, 80, IniName);
GetPrivateProfileString("General", "Language", "0", text, 80, IniName); //================================================== ???
CheckLanguage(IDC_LANGENGLISH+atoi(text));
GetPrivateProfileString("Video", "FrameSkip", "AUTO", text, 80, IniName);
@ -1057,13 +1107,13 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
{
autoframeskipenab=1;
frameskiprate=0;
CheckMenuItem(menu, IDC_FRAMESKIPAUTO, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(IDC_FRAMESKIPAUTO, MF_BYCOMMAND | MF_CHECKED);
}
else
{
autoframeskipenab=0;
frameskiprate=atoi(text);
CheckMenuItem(menu, frameskiprate + IDC_FRAMESKIP0, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(frameskiprate + IDC_FRAMESKIP0, MF_BYCOMMAND | MF_CHECKED);
}
#ifdef BETA_VERSION
@ -1075,7 +1125,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
if (SPU_ChangeSoundCore(sndcoretype, sndbuffersize) != 0)
{
MessageBox(hwnd,"Unable to initialize DirectSound","Error",MB_OK);
MessageBox(MainWindow->getHWnd(),"Unable to initialize DirectSound","Error",MB_OK);
return -1;
}
@ -1123,7 +1173,6 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
//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);
@ -1147,16 +1196,18 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
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);
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(hwnd, hAccel, &messages) == 0)
if (TranslateAccelerator(MainWindow->getHWnd(), hAccel, &messages) == 0)
{
// Translate virtual-key messages into character messages
TranslateMessage(&messages);
@ -1174,6 +1225,20 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
#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;
@ -1198,7 +1263,7 @@ void GetWndRect(HWND hwnd)
}
//========================================================================================
void SetRotate(int rot)
void SetRotate(HWND hwnd, int rot)
{
GPU_rotation = rot;
@ -1237,10 +1302,10 @@ void SetRotate(int rot)
}
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));
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);
}
//========================================================================================
@ -1434,9 +1499,13 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
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;
@ -1647,7 +1716,15 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
}
case IDM_SOUNDSETTINGS:
{
DialogBox(GetModuleHandle(NULL), "SoundSettingsDlg", hwnd, (DLGPROC)SoundSettingsDlgProc);
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:
@ -1655,200 +1732,151 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
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);
}
//========================================================= Tools
case IDM_PAL:
ViewPalette->open();
return 0;
case IDM_TILE:
{
tileview_struct *TileView;
if ((TileView = TileView_Init(hAppInst, HWND_DESKTOP)) != NULL)
CWindow_Show(TileView);
ViewTiles->regClass("TileViewBox", TileViewBoxProc);
ViewTiles->regClass("MiniTileViewBox", MiniTileViewBoxProc, true);
if (!ViewTiles->open())
ViewTiles->unregClass();
}
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);
ViewRegisters->open();
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);
}
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:
{
disview_struct *DisView;
ViewDisasm_ARM7->regClass("DesViewBox7",ViewDisasm_ARM7BoxProc);
if (!ViewDisasm_ARM7->open())
ViewDisasm_ARM7->unregClass();
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);
}
ViewDisasm_ARM9->regClass("DesViewBox9",ViewDisasm_ARM9BoxProc);
if (!ViewDisasm_ARM9->open())
ViewDisasm_ARM9->unregClass();
return 0;
case IDM_MAP:
{
mapview_struct *MapView;
if ((MapView = MapView_Init(hAppInst, HWND_DESKTOP)) != NULL)
{
CWindow_AddToRefreshList(MapView);
CWindow_Show(MapView);
}
}
ViewMaps->open();
return 0;
case IDM_OAM:
{
oamview_struct *OamView;
if ((OamView = OamView_Init(hAppInst, HWND_DESKTOP)) != NULL)
{
CWindow_AddToRefreshList(OamView);
CWindow_Show(OamView);
}
}
ViewOAM->regClass("OAMViewBox", ViewOAMBoxProc);
if (!ViewOAM->open())
ViewOAM->unregClass();
return 0;
case IDM_MATRIX_VIEWER:
{
matrixview_struct *MatrixView;
if ((MatrixView = MatrixView_Init(hAppInst, HWND_DESKTOP)) != NULL)
{
CWindow_Show(MatrixView);
}
}
ViewMatrices->open();
return 0;
case IDM_LIGHT_VIEWER:
{
lightview_struct *LightView;
if ((LightView = LightView_Init(hAppInst, HWND_DESKTOP)) != NULL)
{
CWindow_Show(LightView);
}
}
ViewLights->open();
return 0;
//========================================================== Tools end
case IDM_MBG0 :
if(MainScreen.gpu->dispBG[0])
{
GPU_remove(MainScreen.gpu, 0);
CheckMenuItem(menu, IDM_MBG0, MF_BYCOMMAND | MF_UNCHECKED);
MainWindow->checkMenu(IDM_MBG0, MF_BYCOMMAND | MF_UNCHECKED);
}
else
{
GPU_addBack(MainScreen.gpu, 0);
CheckMenuItem(menu, IDM_MBG0, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(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);
MainWindow->checkMenu(IDM_MBG1, MF_BYCOMMAND | MF_UNCHECKED);
}
else
{
GPU_addBack(MainScreen.gpu, 1);
CheckMenuItem(menu, IDM_MBG1, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(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);
MainWindow->checkMenu(IDM_MBG2, MF_BYCOMMAND | MF_UNCHECKED);
}
else
{
GPU_addBack(MainScreen.gpu, 2);
CheckMenuItem(menu, IDM_MBG2, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(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);
MainWindow->checkMenu(IDM_MBG3, MF_BYCOMMAND | MF_UNCHECKED);
}
else
{
GPU_addBack(MainScreen.gpu, 3);
CheckMenuItem(menu, IDM_MBG3, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(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);
MainWindow->checkMenu(IDM_SBG0, MF_BYCOMMAND | MF_UNCHECKED);
}
else
{
GPU_addBack(SubScreen.gpu, 0);
CheckMenuItem(menu, IDM_SBG0, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(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);
MainWindow->checkMenu(IDM_SBG1, MF_BYCOMMAND | MF_UNCHECKED);
}
else
{
GPU_addBack(SubScreen.gpu, 1);
CheckMenuItem(menu, IDM_SBG1, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(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);
MainWindow->checkMenu(IDM_SBG2, MF_BYCOMMAND | MF_UNCHECKED);
}
else
{
GPU_addBack(SubScreen.gpu, 2);
CheckMenuItem(menu, IDM_SBG2, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(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);
MainWindow->checkMenu(IDM_SBG3, MF_BYCOMMAND | MF_UNCHECKED);
}
else
{
GPU_addBack(SubScreen.gpu, 3);
CheckMenuItem(menu, IDM_SBG3, MF_BYCOMMAND | MF_CHECKED);
MainWindow->checkMenu(IDM_SBG3, MF_BYCOMMAND | MF_CHECKED);
}
return 0;
@ -1857,28 +1885,34 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
if (emu_paused) NDS_UnPause();
else NDS_Pause();
emu_paused ^= 1;
CheckMenuItem(menu, IDM_PAUSE, emu_paused ? MF_CHECKED : MF_UNCHECKED);
MainWindow->checkMenu(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);
MainWindow->checkMenu(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);
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) \
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);
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);
@ -1911,23 +1945,31 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
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);
bool tpaused=false;
if (execute)
{
tpaused=true;
NDS_Pause();
}
InputConfig(hwnd);
if (tpaused)
NDS_UnPause();
}
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);
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:
@ -1954,18 +1996,18 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
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);
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:
@ -1993,12 +2035,17 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
case IDM_ABOUT:
{
cwindow_struct aboutBox;
bool tpaused=false;
if (execute)
{
tpaused=true;
NDS_Pause();
}
DialogBox(hAppInst,MAKEINTRESOURCE(IDD_ABOUT_BOX), hwnd, (DLGPROC) AboutBox_Proc);
if (tpaused)
NDS_UnPause();
if (CWindow_Init2(&aboutBox, hAppInst, HWND_DESKTOP, "About desmume...", IDD_ABOUT_BOX, AboutBox_Proc) == 0)
CWindow_Show(&aboutBox);
break;
return 0;
}
#ifndef BETA_VERSION
@ -2008,16 +2055,16 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
#endif
case IDC_ROTATE0:
SetRotate(0);
SetRotate(hwnd, 0);
return 0;
case IDC_ROTATE90:
SetRotate(90);
SetRotate(hwnd, 90);
return 0;
case IDC_ROTATE180:
SetRotate(180);
SetRotate(hwnd, 180);
return 0;
case IDC_ROTATE270:
SetRotate(270);
SetRotate(hwnd, 270);
return 0;
case IDC_WINDOW1X:
@ -2025,45 +2072,45 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
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));
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);
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));
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);
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));
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);
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));
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) {
CheckMenuItem(menu, IDC_FORCERATIO, MF_BYCOMMAND | MF_UNCHECKED);
MainWindow->checkMenu(IDC_FORCERATIO, MF_BYCOMMAND | MF_UNCHECKED);
ForceRatio = FALSE;
WritePrivateProfileInt("Video","Window Force Ratio",0,IniName);
}
@ -2074,7 +2121,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
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);
MainWindow->checkMenu(IDC_FORCERATIO, MF_BYCOMMAND | MF_CHECKED);
ForceRatio = TRUE;
WritePrivateProfileInt("Video","Window Force Ratio",1,IniName);
}
@ -2147,8 +2194,6 @@ LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
EndDialog(hDlg, TRUE);
NDS_Pause();
// Write Sound core type
sndcoretype = SNDCoreList[SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_GETCURSEL, 0, 0)]->id;
sprintf(tempstr, "%d", sndcoretype);
@ -2166,7 +2211,6 @@ LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
sprintf(tempstr, "%d", sndvolume);
WritePrivateProfileString("Sound", "Volume", tempstr, IniName);
SPU_SetVolume(sndvolume);
NDS_UnPause();
return TRUE;
}

View File

@ -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 <commctrl.h>
#include "../MMU.h"
#include "../NDSSystem.h"
#include "debug.h"
#include "resource.h"
#include <stdio.h>
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)
{
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,20 +241,61 @@ 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);
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -22,23 +22,8 @@
#ifndef MAPVIEW_H
#define MAPVIEW_H
#include "CWindow.h"
#include <windows.h>
typedef struct
{
HWND hwnd;
BOOL autoup;
void *prev;
void *next;
void *first;
void (*Refresh)(void *win);
u16 map;
u16 lcd;
u16 bitmap[1024*1024];
} mapview_struct;
mapview_struct *MapView_Init(HINSTANCE hInst, HWND parent);
void MapView_Deinit(mapview_struct *MapView);
extern BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
#endif

View File

@ -17,18 +17,21 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include <stdio.h>
#include "matrixView.h"
#include <commctrl.h>
#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,14 +40,122 @@ 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);
}
}
void MatrixView_OnPaintPositionMatrix(HWND hwnd)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
{
IDC_MATRIX_VIEWER_COORD_11_EDIT, IDC_MATRIX_VIEWER_COORD_12_EDIT, IDC_MATRIX_VIEWER_COORD_13_EDIT, IDC_MATRIX_VIEWER_COORD_14_EDIT,
IDC_MATRIX_VIEWER_COORD_21_EDIT, IDC_MATRIX_VIEWER_COORD_22_EDIT, IDC_MATRIX_VIEWER_COORD_23_EDIT, IDC_MATRIX_VIEWER_COORD_24_EDIT,
IDC_MATRIX_VIEWER_COORD_31_EDIT, IDC_MATRIX_VIEWER_COORD_32_EDIT, IDC_MATRIX_VIEWER_COORD_33_EDIT, IDC_MATRIX_VIEWER_COORD_34_EDIT,
IDC_MATRIX_VIEWER_COORD_41_EDIT, IDC_MATRIX_VIEWER_COORD_42_EDIT, IDC_MATRIX_VIEWER_COORD_43_EDIT, IDC_MATRIX_VIEWER_COORD_44_EDIT
};
float matrix[16];
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(hwnd, idcGroup, matrix);
}
//////////////////////////////////////////////////////////////////////////////
BOOL MatrixView_OnInitDialog(HWND hwnd)
void MatrixView_OnPaintDirectionMatrix(HWND hwnd)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
{
IDC_MATRIX_VIEWER_DIR_11_EDIT, IDC_MATRIX_VIEWER_DIR_12_EDIT, IDC_MATRIX_VIEWER_DIR_13_EDIT, IDC_MATRIX_VIEWER_DIR_14_EDIT,
IDC_MATRIX_VIEWER_DIR_21_EDIT, IDC_MATRIX_VIEWER_DIR_22_EDIT, IDC_MATRIX_VIEWER_DIR_23_EDIT, IDC_MATRIX_VIEWER_DIR_24_EDIT,
IDC_MATRIX_VIEWER_DIR_31_EDIT, IDC_MATRIX_VIEWER_DIR_32_EDIT, IDC_MATRIX_VIEWER_DIR_33_EDIT, IDC_MATRIX_VIEWER_DIR_34_EDIT,
IDC_MATRIX_VIEWER_DIR_41_EDIT, IDC_MATRIX_VIEWER_DIR_42_EDIT, IDC_MATRIX_VIEWER_DIR_43_EDIT, IDC_MATRIX_VIEWER_DIR_44_EDIT
};
float matrix[16];
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(hwnd, idcGroup, matrix);
}
//////////////////////////////////////////////////////////////////////////////
void MatrixView_OnPaintProjectionMatrix(HWND hwnd)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
{
IDC_MATRIX_VIEWER_PROJ_11_EDIT, IDC_MATRIX_VIEWER_PROJ_12_EDIT, IDC_MATRIX_VIEWER_PROJ_13_EDIT, IDC_MATRIX_VIEWER_PROJ_14_EDIT,
IDC_MATRIX_VIEWER_PROJ_21_EDIT, IDC_MATRIX_VIEWER_PROJ_22_EDIT, IDC_MATRIX_VIEWER_PROJ_23_EDIT, IDC_MATRIX_VIEWER_PROJ_24_EDIT,
IDC_MATRIX_VIEWER_PROJ_31_EDIT, IDC_MATRIX_VIEWER_PROJ_32_EDIT, IDC_MATRIX_VIEWER_PROJ_33_EDIT, IDC_MATRIX_VIEWER_PROJ_34_EDIT,
IDC_MATRIX_VIEWER_PROJ_41_EDIT, IDC_MATRIX_VIEWER_PROJ_42_EDIT, IDC_MATRIX_VIEWER_PROJ_43_EDIT, IDC_MATRIX_VIEWER_PROJ_44_EDIT
};
float mat[16];
gfx3d_glGetMatrix(0, -1, mat);
MatrixView_SetMatrix(hwnd, idcGroup, mat);
}
//////////////////////////////////////////////////////////////////////////////
void MatrixView_OnPaintTextureMatrix(HWND hwnd)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
{
IDC_MATRIX_VIEWER_TEX_11_EDIT, IDC_MATRIX_VIEWER_TEX_12_EDIT, IDC_MATRIX_VIEWER_TEX_13_EDIT, IDC_MATRIX_VIEWER_TEX_14_EDIT,
IDC_MATRIX_VIEWER_TEX_21_EDIT, IDC_MATRIX_VIEWER_TEX_22_EDIT, IDC_MATRIX_VIEWER_TEX_23_EDIT, IDC_MATRIX_VIEWER_TEX_24_EDIT,
IDC_MATRIX_VIEWER_TEX_31_EDIT, IDC_MATRIX_VIEWER_TEX_32_EDIT, IDC_MATRIX_VIEWER_TEX_33_EDIT, IDC_MATRIX_VIEWER_TEX_34_EDIT,
IDC_MATRIX_VIEWER_TEX_41_EDIT, IDC_MATRIX_VIEWER_TEX_42_EDIT, IDC_MATRIX_VIEWER_TEX_43_EDIT, IDC_MATRIX_VIEWER_TEX_44_EDIT
};
float mat[16];
gfx3d_glGetMatrix(3, -1, mat);
MatrixView_SetMatrix(hwnd, idcGroup, mat);
}
BOOL MatrixView_OnPaint( HWND hwnd, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hwnd, &ps);
MatrixView_OnPaintProjectionMatrix(hwnd);
MatrixView_OnPaintPositionMatrix(hwnd);
MatrixView_OnPaintDirectionMatrix(hwnd);
MatrixView_OnPaintTextureMatrix(hwnd);
EndPaint(hwnd, &ps);
return TRUE;
}
BOOL CALLBACK ViewMatricesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
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);
@ -64,149 +175,69 @@ BOOL MatrixView_OnInitDialog(HWND hwnd)
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)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
{
IDC_MATRIX_VIEWER_COORD_11_EDIT, IDC_MATRIX_VIEWER_COORD_12_EDIT, IDC_MATRIX_VIEWER_COORD_13_EDIT, IDC_MATRIX_VIEWER_COORD_14_EDIT,
IDC_MATRIX_VIEWER_COORD_21_EDIT, IDC_MATRIX_VIEWER_COORD_22_EDIT, IDC_MATRIX_VIEWER_COORD_23_EDIT, IDC_MATRIX_VIEWER_COORD_24_EDIT,
IDC_MATRIX_VIEWER_COORD_31_EDIT, IDC_MATRIX_VIEWER_COORD_32_EDIT, IDC_MATRIX_VIEWER_COORD_33_EDIT, IDC_MATRIX_VIEWER_COORD_34_EDIT,
IDC_MATRIX_VIEWER_COORD_41_EDIT, IDC_MATRIX_VIEWER_COORD_42_EDIT, IDC_MATRIX_VIEWER_COORD_43_EDIT, IDC_MATRIX_VIEWER_COORD_44_EDIT
};
float matrix[16];
HWND hStackCombo = GetDlgItem(win->window.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);
}
//////////////////////////////////////////////////////////////////////////////
void MatrixView_OnPaintDirectionMatrix(matrixview_struct* win)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
{
IDC_MATRIX_VIEWER_DIR_11_EDIT, IDC_MATRIX_VIEWER_DIR_12_EDIT, IDC_MATRIX_VIEWER_DIR_13_EDIT, IDC_MATRIX_VIEWER_DIR_14_EDIT,
IDC_MATRIX_VIEWER_DIR_21_EDIT, IDC_MATRIX_VIEWER_DIR_22_EDIT, IDC_MATRIX_VIEWER_DIR_23_EDIT, IDC_MATRIX_VIEWER_DIR_24_EDIT,
IDC_MATRIX_VIEWER_DIR_31_EDIT, IDC_MATRIX_VIEWER_DIR_32_EDIT, IDC_MATRIX_VIEWER_DIR_33_EDIT, IDC_MATRIX_VIEWER_DIR_34_EDIT,
IDC_MATRIX_VIEWER_DIR_41_EDIT, IDC_MATRIX_VIEWER_DIR_42_EDIT, IDC_MATRIX_VIEWER_DIR_43_EDIT, IDC_MATRIX_VIEWER_DIR_44_EDIT
};
float matrix[16];
HWND hStackCombo = GetDlgItem(win->window.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);
}
//////////////////////////////////////////////////////////////////////////////
void MatrixView_OnPaintProjectionMatrix(matrixview_struct* win)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
{
IDC_MATRIX_VIEWER_PROJ_11_EDIT, IDC_MATRIX_VIEWER_PROJ_12_EDIT, IDC_MATRIX_VIEWER_PROJ_13_EDIT, IDC_MATRIX_VIEWER_PROJ_14_EDIT,
IDC_MATRIX_VIEWER_PROJ_21_EDIT, IDC_MATRIX_VIEWER_PROJ_22_EDIT, IDC_MATRIX_VIEWER_PROJ_23_EDIT, IDC_MATRIX_VIEWER_PROJ_24_EDIT,
IDC_MATRIX_VIEWER_PROJ_31_EDIT, IDC_MATRIX_VIEWER_PROJ_32_EDIT, IDC_MATRIX_VIEWER_PROJ_33_EDIT, IDC_MATRIX_VIEWER_PROJ_34_EDIT,
IDC_MATRIX_VIEWER_PROJ_41_EDIT, IDC_MATRIX_VIEWER_PROJ_42_EDIT, IDC_MATRIX_VIEWER_PROJ_43_EDIT, IDC_MATRIX_VIEWER_PROJ_44_EDIT
};
float mat[16];
gfx3d_glGetMatrix(0, -1, mat);
MatrixView_SetMatrix(win, idcGroup, mat);
}
//////////////////////////////////////////////////////////////////////////////
void MatrixView_OnPaintTextureMatrix(matrixview_struct* win)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
{
IDC_MATRIX_VIEWER_TEX_11_EDIT, IDC_MATRIX_VIEWER_TEX_12_EDIT, IDC_MATRIX_VIEWER_TEX_13_EDIT, IDC_MATRIX_VIEWER_TEX_14_EDIT,
IDC_MATRIX_VIEWER_TEX_21_EDIT, IDC_MATRIX_VIEWER_TEX_22_EDIT, IDC_MATRIX_VIEWER_TEX_23_EDIT, IDC_MATRIX_VIEWER_TEX_24_EDIT,
IDC_MATRIX_VIEWER_TEX_31_EDIT, IDC_MATRIX_VIEWER_TEX_32_EDIT, IDC_MATRIX_VIEWER_TEX_33_EDIT, IDC_MATRIX_VIEWER_TEX_34_EDIT,
IDC_MATRIX_VIEWER_TEX_41_EDIT, IDC_MATRIX_VIEWER_TEX_42_EDIT, IDC_MATRIX_VIEWER_TEX_43_EDIT, IDC_MATRIX_VIEWER_TEX_44_EDIT
};
float mat[16];
gfx3d_glGetMatrix(3, -1, mat);
MatrixView_SetMatrix(win, idcGroup, mat);
}
//////////////////////////////////////////////////////////////////////////////
BOOL MatrixView_OnPaint(matrixview_struct* win, 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);
EndPaint(hwnd, &ps);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////
BOOL CALLBACK MatrixView_Proc(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);
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:
@ -215,44 +246,7 @@ BOOL CALLBACK MatrixView_Proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
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);
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -20,15 +20,8 @@
#ifndef MATRIXVIEW_H
#define MATRIXVIEW_H
#include "CWindow.h"
#include <windows.h>
typedef struct
{
cwindow_struct window;
} matrixview_struct;
matrixview_struct *MatrixView_Init(HINSTANCE hInst, HWND parent);
void MatrixView_Deinit(matrixview_struct *MatrixView);
extern BOOL CALLBACK ViewMatricesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
#endif

View File

@ -20,283 +20,28 @@
*/
#include <algorithm>
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include "memView.h"
#include <commctrl.h>
#include "../MMU.h"
#include "debug.h"
#include "resource.h"
LRESULT CALLBACK MemViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void InitMemViewBox()
typedef struct
{
WNDCLASSEX wc;
u32 autoup_secs;
bool autoup;
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;
s8 cpu;
u32 curr_ligne;
u8 representation;
} memview_struct;
RegisterClassEx(&wc);
}
/*
LRESULT MemViewBox_OnPaint(CMemView * win, WPARAM wParam, LPARAM lParam)
memview_struct *MemView7 = NULL;
memview_struct *MemView9 = NULL;
LRESULT MemViewBox_OnPaint(HWND hwnd, memview_struct * 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<nbligne; ++i)
{
sprintf(text, "%04X:%04X", (int)(adr>>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)
{
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;
return 1;
}
win->add2RefreshList();
win->autoup = TRUE;
return 1;
case IDC_GO :
{
char tmp[8];
int lg = GetDlgItemText(hwnd, IDC_GOTOMEM, tmp, 8);
u32 adr = 0;
for(u16 i = 0; i<lg; ++i)
{
if((tmp[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;
@ -337,6 +82,7 @@ LRESULT MemViewBox_OnPaint(memview_struct * win, WPARAM wParam, LPARAM lParam)
r.right = rect.right-3;
adr = win->curr_ligne*0x10;
printlog("curr_ligne=%i\n", win->curr_ligne);
for(i=0; i<nbligne; ++i)
{
@ -397,12 +143,9 @@ LRESULT MemViewBox_OnPaint(memview_struct * win, WPARAM wParam, LPARAM lParam)
return 1;
}
//////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK MemViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
//=================================================== ARM7
LRESULT CALLBACK ViewMem_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
memview_struct *win = (memview_struct *)GetWindowLong(hwnd, 0);
switch(msg)
{
case WM_NCCREATE:
@ -414,7 +157,7 @@ LRESULT CALLBACK MemViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
return 1;
case WM_PAINT:
MemViewBox_OnPaint(win, wParam, lParam);
MemViewBox_OnPaint(hwnd, MemView7, wParam, lParam);
return 1;
case WM_ERASEBKGND:
@ -437,77 +180,116 @@ LRESULT CALLBACK MemViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
switch LOWORD(wParam)
{
case SB_LINEDOWN :
win->curr_ligne = std::min((s32)0x0FFFFFFFF, (s32)win->curr_ligne+1);
MemView7->curr_ligne = std::min((u32)0x0FFFFFFFF, (u32)MemView7->curr_ligne+1);
break;
case SB_LINEUP :
win->curr_ligne = (u32)std::max(0l, (s32)win->curr_ligne-1);
MemView7->curr_ligne = (u32)std::max((u32)0l, (u32)MemView7->curr_ligne-1);
break;
case SB_PAGEDOWN :
win->curr_ligne = std::min((s32)0x0FFFFFFFF, (s32)win->curr_ligne+nbligne);
MemView7->curr_ligne = std::min((u32)0x0FFFFFFFF, (u32)MemView7->curr_ligne+nbligne);
break;
case SB_PAGEUP :
win->curr_ligne = (u32)std::max(0l, (s32)win->curr_ligne-nbligne);
MemView7->curr_ligne = (u32)std::max((u32)0l, (u32)MemView7->curr_ligne-nbligne);
break;
}
SelectObject(dc, old);
SetScrollPos(hwnd, SB_VERT, win->curr_ligne, TRUE);
SetScrollPos(hwnd, SB_VERT, MemView7->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)
bool CALLBACK ViewMem_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
memview_struct *win = (memview_struct *)GetWindowLong(hwnd, DWL_USER);
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_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;
MemView7->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;
MemView7->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;
MemView7->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)
if(MemView7->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_MEM7);
MemView7->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);
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_REFRESH:
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case IDC_GO :
{
@ -529,52 +311,196 @@ BOOL CALLBACK MemView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
continue;
}
}
win->curr_ligne = (adr>>4);
MemView7->curr_ligne = (adr>>4);
InvalidateRect(hwnd, NULL, FALSE);
UpdateWindow(hwnd);
}
return 1;
case IDC_FERMER :
CWindow_RemoveFromRefreshList(win);
MemView_Deinit(win);
EndDialog(hwnd, 0);
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 1;
}
return 0;
}
return 0;
return DefWindowProc(hwnd, message, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
memview_struct *MemView_Init(HINSTANCE hInst, HWND parent, char *title, u8 CPU)
//=================================================== ARM9
LRESULT CALLBACK ViewMem_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
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)
switch(msg)
{
free(MemView);
return NULL;
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;
}
MemView->cpu = CPU;
MemView->curr_ligne = 0;
MemView->representation = 0;
SelectObject(dc, old);
SetScrollPos(hwnd, SB_VERT, MemView9->curr_ligne, TRUE);
InvalidateRect(hwnd, NULL, FALSE);
UpdateWindow(hwnd);
}
return 1;
}
SetWindowLong(GetDlgItem(MemView->hwnd, IDC_MEM_BOX), 0, (LONG)MemView);
return MemView;
return DefWindowProc(hwnd, msg, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
void MemView_Deinit(memview_struct *MemView)
bool CALLBACK ViewMem_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (MemView)
free(MemView);
}
//////////////////////////////////////////////////////////////////////////////
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)
{
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;
}
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_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<lg; ++i)
{
if((tmp[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);
}

View File

@ -22,36 +22,12 @@
#ifndef MEM_VIEW_H
#define MEM_VIEW_H
#include "CWindow.h"
#include <windows.h>
/*
class CMemView : public CWindow
{
public :
CMemView(HINSTANCE hInst, HWND parent, char * titre, u8 CPU);
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);
s8 cpu;
u32 curr_ligne;
u8 representation;
};
*/
typedef struct
{
HWND hwnd;
BOOL autoup;
void *prev;
void *next;
void *first;
void (*Refresh)(void *win);
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);
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);
#endif

View File

@ -19,16 +19,26 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <tchar.h>
#include <stdio.h>
#include "oamView.h"
#include <commctrl.h>
#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)
{
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)
{
oamview_struct *win = (oamview_struct *)GetWindowLong(hwnd, DWL_USER);
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,36 +228,78 @@ 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);
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -22,25 +22,9 @@
#ifndef OAMVIEW_H
#define OAMVIEW_H
#include "CWindow.h"
#include "../GPU.h"
#include <windows.h>
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

View File

@ -3,8 +3,9 @@
#include <gl/gl.h>
#include <gl/glext.h>
#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);

View File

@ -19,13 +19,22 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include "resource.h"
#include "palView.h"
#include <commctrl.h>
#include "debug.h"
#include "resource.h"
#include "../MMU.h"
#include <stdio.h>
//////////////////////////////////////////////////////////////////////////////
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 <20>Ela creation donc la boite ne doit pas être visible a la création
palview_struct *win = (palview_struct *)GetWindowLong(hwnd, DWL_USER);
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");
@ -112,46 +125,78 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
}
return 1;
case WM_CLOSE :
CWindow_RemoveFromRefreshList(win);
PalView_Deinit(win);
EndDialog(hwnd, 0);
return 1;
{
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);
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -22,25 +22,9 @@
#ifndef PALVIEW_H
#define PALVIEW_H
#include "CWindow.h"
#include <windows.h>
#include <stdlib.h>
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);
extern BOOL CALLBACK ViewPalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
#endif

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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);

View File

@ -19,103 +19,31 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#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;
u32 autoup_secs;
bool autoup;
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;
HWND hwnd;
u8 * mem;
u16 * pal;
s16 palnum;
u16 tilenum;
u8 coul;
u32 x;
u32 y;
} tileview_struct;
RegisterClassEx(&wc);
tileview_struct *TileView = NULL;
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);
}
//////////////////////////////////////////////////////////////////////////////
LRESULT MiniTileViewBox_Paint(tileview_struct * win, WPARAM wParam, LPARAM lParam)
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_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);
}
LRESULT MiniTileViewBox_Paint(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam)
{
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:
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;
}
case WM_PAINT :
MiniTileViewBox_Paint(hwnd, TileView, wParam, lParam);
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);
}
//////////////////////////////////////////////////////////////////////////////
BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK ViewTilesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
tileview_struct * win = (tileview_struct *)GetWindowLong(hwnd, DWL_USER);
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);
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -22,29 +22,11 @@
#ifndef TILEVIEW_H
#define TILEVIEW_H
#include "CWindow.h"
#include <windows.h>
#include <stdlib.h>
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