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,7 +61,8 @@
? Fix a bug in texture transformation mode 1 [zeromus]
- Fix the buggy auto frameskip logic which made the emu slow to a crawl. Now it runs fast! [zeromus]
- Fix resizing, rotate & aspect ration of main window. Add save window position and parameters [CrazyMax]
- Rewrite all debug tools (autoupdate work now) [CrazyMax]
0.7.3 -> 0.8
Cocoa:
- Save State As function now works. [Jeff B]

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"
@ -51,4 +46,4 @@ BOOL CALLBACK AboutBox_Proc (HWND dialog, UINT message,WPARAM wparam,LPARAM lpar
}
}
return 0;
}
}

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
#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;
if(!first)
{
WNDCLASSEX wincl; // Data structure for the windowclass
// The Window structure
wincl.hInstance = hInst;
wincl.lpszClassName = cname;
wincl.lpfnWndProc = wP; // This function is called by windows
wincl.style = CS_DBLCLKS; // Catch double-clicks
wincl.cbSize = sizeof (WNDCLASSEX);
// Use default icon and mouse-pointer
//wincl.hIcon = LoadIcon (hInst, MAKEINTRESOURCE(IconDeSmuME));//IDI_APPLICATION);
//wincl.hIconSm = LoadIcon (hInst, MAKEINTRESOURCE(IconDeSmuME));//IDI_APPLICATION);
wincl.hIcon = LoadIcon (hInst, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (hInst, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; // No menu
wincl.cbClsExtra = 0; // No extra bytes after the window class
wincl.cbWndExtra = 0; // structure or the window instance
// Use Windows's default color as the background of the window
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
// Register the window class, and if it fails quit the program
if (!RegisterClassEx (&wincl))
return -1;
win2->first=NULL;
first = TRUE;
}
clientaera.left = 0;
clientaera.top = 0;
clientaera.right = sx;
clientaera.bottom = sy;
AdjustWindowRectEx(&clientaera, style, TRUE, 0);
// The class is registered, let's create the program
win2->hwnd = CreateWindowEx (
0, // Extended possibilites for variation
cname, // Classname
title, // Title Text
style, // default window
CW_USEDEFAULT, // Windows decides the position
CW_USEDEFAULT, // where the window ends up on the screen
clientaera.right - clientaera.left, // The programs width
clientaera.bottom - clientaera.top, // and height in pixels
HWND_DESKTOP, // The window is a child-window to desktop
NULL, // No menu
hInst, // Program Instance handler
NULL // No Window Creation data
);
win2->prev = NULL;
win2->next = NULL;
win2->Refresh = &CWindow_Refresh;
return 0;
hwnd = NULL;
hmenu = NULL;
hInstance = hInst;
}
//////////////////////////////////////////////////////////////////////////////
int CWindow_Init2(void *win, HINSTANCE hInst, HWND parent, char * title, int ID, DLGPROC wP)
WINCLASS::~WINCLASS()
{
HMENU hSystemMenu;
cwindow_struct *win2=(cwindow_struct *)win;
win2->autoup = FALSE;
win2->hwnd = CreateDialog(hInst, MAKEINTRESOURCE(ID), parent, wP);
SetWindowLong(win2->hwnd, DWL_USER, (LONG)win2);
SetWindowText(win2->hwnd, title);
win2->prev = NULL;
win2->next = NULL;
win2->Refresh = &CWindow_Refresh;
// Append the "Auto Update" to the System Menu
hSystemMenu = GetSystemMenu(win2->hwnd, FALSE);
if(hSystemMenu != 0)
{
AppendMenu(hSystemMenu, MF_MENUBREAK, 0, NULL);
AppendMenu(hSystemMenu, MF_ENABLED|MF_STRING, IDC_AUTO_UPDATE, "Auto Update");
}
return 0;
}
//////////////////////////////////////////////////////////////////////////////
void CWindow_Show(void *win)
bool WINCLASS::create(LPSTR caption, int x, int y, int width, int height, int style, HMENU menu)
{
ShowWindow (((cwindow_struct *)win)->hwnd, SW_SHOW);
}
//////////////////////////////////////////////////////////////////////////////
void CWindow_Hide(void *win)
{
ShowWindow (((cwindow_struct *)win)->hwnd, SW_HIDE);
}
//////////////////////////////////////////////////////////////////////////////
void CWindow_Refresh(void *win)
{
InvalidateRect(((cwindow_struct *)win)->hwnd, NULL, FALSE);
}
//////////////////////////////////////////////////////////////////////////////
void CWindow_UpdateAutoUpdateItem(cwindow_struct *win, int check)
{
HMENU hSystemMenu;
if (hwnd != NULL) return false;
// Update the "auto update" menu item
hSystemMenu = GetSystemMenu(win->hwnd, FALSE);
if(hSystemMenu != 0)
{
const int checkState[] =
{
MF_UNCHECKED,
MF_CHECKED
};
hwnd = CreateWindow(regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL);
if (hwnd != NULL) return true;
return false;
}
CheckMenuItem(hSystemMenu, IDC_AUTO_UPDATE, checkState[check]);
bool WINCLASS::createEx(LPSTR caption, int x, int y, int width, int height, int style, int styleEx, HMENU menu)
{
if (hwnd != NULL) return false;
hwnd = CreateWindowEx(styleEx, regclass, caption, style, x, y, width, height, NULL, menu, hInstance, NULL);
if (hwnd != NULL) return true;
return false;
}
bool WINCLASS::setMenu(HMENU menu)
{
hmenu = menu;
return SetMenu(hwnd, hmenu);
}
DWORD WINCLASS::checkMenu(UINT idd, UINT check)
{
return CheckMenuItem(hmenu, idd, check);
}
HWND WINCLASS::getHWnd()
{
return hwnd;
}
void WINCLASS::Show(int mode)
{
ShowWindow(hwnd, mode);
}
void WINCLASS::Hide()
{
ShowWindow(hwnd, SW_HIDE);
}
//========================================================= Thread class
extern DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
THREADCLASS *tmp = (THREADCLASS *)lpParameter;
return tmp->ThreadFunc();
}
THREADCLASS::THREADCLASS()
{
hThread = NULL;
}
THREADCLASS::~THREADCLASS()
{
closeThread();
}
void THREADCLASS::closeThread()
{
if (hThread)
{
CloseHandle(hThread);
hThread = NULL;
}
}
//////////////////////////////////////////////////////////////////////////////
void CWindow_AddToRefreshList(void *win)
bool THREADCLASS::createThread()
{
cwindow_struct *win2=(cwindow_struct *)win;
if (hThread) return false;
EnterCriticalSection(&section);
win2->prev = NULL;
win2->next = updatewindowlist;
if(updatewindowlist)
updatewindowlist->prev = win;
updatewindowlist = (cwindow_struct *)win;
LeaveCriticalSection(&section);
CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, TRUE);
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadProc, this, 0, &threadID);
if (!hThread) return false;
//WaitForSingleObject(hThread, INFINITE);
return true;
}
//////////////////////////////////////////////////////////////////////////////
void CWindow_RemoveFromRefreshList(void *win)
//========================================================= Tools class
TOOLSCLASS::TOOLSCLASS(HINSTANCE hInst, int IDD, DLGPROC dlgproc)
{
cwindow_struct *win2=(cwindow_struct *)win;
EnterCriticalSection(&section);
if(updatewindowlist == win)
{
updatewindowlist = (cwindow_struct *)win2->next;
if(updatewindowlist) updatewindowlist->prev = NULL;
}
else
if(win2->prev)
{
((cwindow_struct *)win2->prev)->next = win2->next;
if(win2->next) ((cwindow_struct *)win2->next)->prev = win2->prev;
}
win2->next = NULL;
win2->prev = NULL;
LeaveCriticalSection(&section);
CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, FALSE);
this->dlgproc = dlgproc;
hwnd = NULL;
hInstance = hInst;
idd=IDD;
memset(class_name, 0, sizeof(class_name));
memset(class_name2, 0, sizeof(class_name2));
}
//////////////////////////////////////////////////////////////////////////////
int CWindow_ToggleAutoUpdate(void *win)
TOOLSCLASS::~TOOLSCLASS()
{
cwindow_struct *win2=(cwindow_struct *)win;
// remove window from refresh list
if(win2->autoup)
CWindow_RemoveFromRefreshList(win);
// toggle autoup variable
win2->autoup = !win2->autoup;
// add window to refresg list if autoupdate is desired
if(win2->autoup)
CWindow_AddToRefreshList(win);
// checks or unchecks the auto update item in the system menu
CWindow_UpdateAutoUpdateItem((cwindow_struct*)win, win2->autoup);
return win2->autoup;
close();
}
bool TOOLSCLASS::open()
{
if (!createThread()) return false;
return true;
}
bool TOOLSCLASS::close()
{
return true;
}
DWORD TOOLSCLASS::ThreadFunc()
{
MSG messages;
printlog("Start thread\n");
GetLastError();
hwnd = CreateDialog(hInstance, MAKEINTRESOURCE(idd), NULL, (DLGPROC) dlgproc);
if (!hwnd)
{
printlog("error creating dialog\n");
return (-2);
}
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
unregClass();
hwnd = NULL;
closeThread();
return 0;
}
void TOOLSCLASS::regClass(LPSTR class_name, WNDPROC wproc, bool SecondReg)
{
WNDCLASSEX wc;
wc.cbSize = sizeof(wc);
if (SecondReg)
strcpy(this->class_name2, class_name);
else
strcpy(this->class_name, class_name);
wc.lpszClassName = class_name;
wc.hInstance = hInstance;
wc.lpfnWndProc = wproc;
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hIcon = 0;
wc.lpszMenuName = 0;
wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE);
wc.style = 0;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hIconSm = 0;
RegisterClassEx(&wc);
}
void TOOLSCLASS::unregClass()
{
if (class_name[0])
{
UnregisterClass(class_name, hInstance);
}
if (class_name2[0])
{
UnregisterClass(class_name2, hInstance);
}
memset(class_name, 0, sizeof(class_name));
memset(class_name2, 0, sizeof(class_name2));
}

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
{
HWND hwnd;
BOOL autoup;
void *prev;
void *next;
void *first;
void (*Refresh)(void *win);
} cwindow_struct;
private:
HWND hwnd;
HMENU hmenu;
HINSTANCE hInstance;
char regclass[256];
public:
WINCLASS(LPSTR rclass, HINSTANCE hInst);
~WINCLASS();
int CWindow_Init(void *win, HINSTANCE hInst, const char * cname, const char * title, int style, int sx, int sy, WNDPROC wP);
int CWindow_Init2(void *win, HINSTANCE hInst, HWND parent, char * title, int ID, DLGPROC wP);
void CWindow_Show(void *win);
void CWindow_Hide(void *win);
void CWindow_Refresh(void *win);
void CWindow_AddToRefreshList(void *win);
void CWindow_RemoveFromRefreshList(void *win);
int CWindow_ToggleAutoUpdate(void *win);
bool create(LPSTR caption, int x, int y, int width, int height, int style,
HMENU menu);
bool createEx(LPSTR caption, int x, int y, int width, int height, int style, int styleEx,
HMENU menu);
extern cwindow_struct *updatewindowlist;
bool setMenu(HMENU menu);
DWORD checkMenu(UINT idd, UINT check);
static INLINE void CWindow_RefreshALL()
void Show(int mode);
void Hide();
HWND getHWnd();
};
class THREADCLASS
{
cwindow_struct *aux;
EnterCriticalSection(&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
//================================================================================================
//================================================================================================
@ -473,4 +443,48 @@ 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

File diff suppressed because it is too large Load Diff

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

File diff suppressed because it is too large Load Diff

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:
LightsView = new lightsview_struct;
memset(LightsView, 0, sizeof(lightsview_struct));
LightsView->autoup_secs = 5;
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETRANGE, 0, MAKELONG(99, 1));
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETPOS32, 0, LightsView->autoup_secs);
break;
switch (message)
{
case WM_INITDIALOG:
LightView_OnInitDialog(hwnd);
break;
case WM_CLOSE:
if(LightsView->autoup)
{
KillTimer(hwnd, IDT_VIEW_LIGHTS);
LightsView->autoup = false;
}
if (LightsView!=NULL)
{
delete LightsView;
LightsView = NULL;
}
//printlog("Close lights viewer dialog\n");
PostQuitMessage(0);
break;
case WM_CLOSE:
LightView_OnClose(win);
break;
case WM_PAINT:
LightView_OnPaint(hwnd, wParam, lParam);
break;
case WM_PAINT:
LightView_OnPaint(win, hwnd, wParam, lParam);
break;
case WM_TIMER:
SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0);
return 1;
case WM_COMMAND:
switch (LOWORD (wParam))
{
case IDOK:
CWindow_RemoveFromRefreshList(win);
LightView_Deinit(win);
EndDialog(hwnd, 0);
return 1;
}
return 0;
case WM_SYSCOMMAND:
switch (LOWORD (wParam))
{
case IDC_AUTO_UPDATE:
CWindow_ToggleAutoUpdate(win);
return 1;
}
return 0;
}
return 0;
case WM_COMMAND:
switch (LOWORD (wParam))
{
case IDOK:
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 1;
case IDC_AUTO_UPDATE :
if(LightsView->autoup)
{
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false);
KillTimer(hwnd, IDT_VIEW_LIGHTS);
LightsView->autoup = FALSE;
return 1;
}
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true);
LightsView->autoup = TRUE;
SetTimer(hwnd, IDT_VIEW_LIGHTS, LightsView->autoup_secs*1000, (TIMERPROC) NULL);
return 1;
case IDC_AUTO_UPDATE_SECS:
{
int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE);
if (t != LightsView->autoup_secs)
{
LightsView->autoup_secs = t;
if (LightsView->autoup)
SetTimer(hwnd, IDT_VIEW_LIGHTS,
LightsView->autoup_secs*1000, (TIMERPROC) NULL);
}
}
return 1;
case IDC_REFRESH:
InvalidateRect(hwnd, NULL, FALSE);
return 1;
}
return 0;
}
return DefWindowProc(hwnd, message, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
lightview_struct *LightView_Init(HINSTANCE hInst, HWND parent)
{
lightview_struct *LightView=NULL;
if ((LightView = (lightview_struct *)malloc(sizeof(lightview_struct))) == NULL)
return NULL;
if (CWindow_Init2(LightView, hInst, parent, "Light Viewer", IDD_LIGHT_VIEWER, LightView_Proc) != 0)
{
free(LightView);
return NULL;
}
return LightView;
}
//////////////////////////////////////////////////////////////////////////////
void LightView_Deinit(lightview_struct *LightView)
{
if (LightView)
free(LightView);
}
//////////////////////////////////////////////////////////////////////////////

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);
#endif
extern BOOL CALLBACK ViewLightsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
#endif

File diff suppressed because it is too large Load Diff

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)
switch (message)
{
case WM_INITDIALOG :
{
MapView = new mapview_struct;
memset(MapView, 0, sizeof(MapView));
MapView->autoup_secs = 5;
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETRANGE, 0, MAKELONG(99, 1));
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETPOS32, 0, MapView->autoup_secs);
HWND combo = GetDlgItem(hwnd, IDC_BG_SELECT);
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 0");
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main BackGround 1");
@ -227,21 +241,62 @@ BOOL CALLBACK MapView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
}
return 1;
case WM_CLOSE :
CWindow_RemoveFromRefreshList(win);
MapView_Deinit(win);
EndDialog(hwnd, 0);
return 1;
{
if(MapView->autoup)
{
KillTimer(hwnd, IDT_VIEW_MAP);
MapView->autoup = false;
}
if (MapView!=NULL)
{
delete MapView;
MapView = NULL;
}
//printlog("Close Map view dialog\n");
PostQuitMessage(0);
return 0;
}
case WM_PAINT:
MapView_OnPaint(win, hwnd, wParam, lParam);
MapView_OnPaint(MapView, hwnd, wParam, lParam);
return 1;
case WM_TIMER:
SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0);
return 1;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDC_FERMER :
CWindow_RemoveFromRefreshList(win);
MapView_Deinit(win);
EndDialog(hwnd, 0);
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 1;
case IDC_AUTO_UPDATE :
if(MapView->autoup)
{
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false);
KillTimer(hwnd, IDT_VIEW_MAP);
MapView->autoup = FALSE;
return 1;
}
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true);
MapView->autoup = TRUE;
SetTimer(hwnd, IDT_VIEW_MAP, MapView->autoup_secs*1000, (TIMERPROC) NULL);
return 1;
case IDC_AUTO_UPDATE_SECS:
{
int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE);
if (t != MapView->autoup_secs)
{
MapView->autoup_secs = t;
if (MapView->autoup)
SetTimer(hwnd, IDT_VIEW_MAP,
MapView->autoup_secs*1000, (TIMERPROC) NULL);
}
}
return 1;
case IDC_REFRESH:
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case IDC_BG_SELECT :
switch(HIWORD(wParam))
{
@ -255,54 +310,23 @@ BOOL CALLBACK MapView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
case 1 :
case 2 :
case 3 :
win->map = sel;
win->lcd = 0;
MapView->map = sel;
MapView->lcd = 0;
break;
case 4 :
case 5 :
case 6 :
case 7 :
win->map = sel-4;
win->lcd = 1;
MapView->map = sel-4;
MapView->lcd = 1;
break;
}
}
CWindow_Refresh(win);
InvalidateRect(hwnd, NULL, FALSE);
return 1;
}//switch et case
}//switch
return 1;
}
return 0;
return DefWindowProc(hwnd, message, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
mapview_struct *MapView_Init(HINSTANCE hInst, HWND parent)
{
mapview_struct *MapView=NULL;
if ((MapView = (mapview_struct *)malloc(sizeof(mapview_struct))) == NULL)
return MapView;
if (CWindow_Init2(MapView, hInst, parent, "Map viewer", IDD_MAP, MapView_Proc) != 0)
{
free(MapView);
return NULL;
}
MapView->map = 0;
MapView->lcd = 0;
return MapView;
}
//////////////////////////////////////////////////////////////////////////////
void MapView_Deinit(mapview_struct *MapView)
{
if (MapView)
free(MapView);
}
//////////////////////////////////////////////////////////////////////////////

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);
extern BOOL CALLBACK ViewMapsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
u16 map;
u16 lcd;
u16 bitmap[1024*1024];
} mapview_struct;
mapview_struct *MapView_Init(HINSTANCE hInst, HWND parent);
void MapView_Deinit(mapview_struct *MapView);
#endif
#endif

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,52 +40,11 @@ void MatrixView_SetMatrix(matrixview_struct* win, const int* idcs, float* matrix
{
sprintf(buffer, "%.4f", matrix[n]);
//sprintf(buffer, "%.8x", (int)(matrix[n]*4096));
SetWindowText(GetDlgItem(win->window.hwnd, idcs[n]), buffer);
SetWindowText(GetDlgItem(hwnd, idcs[n]), buffer);
}
}
//////////////////////////////////////////////////////////////////////////////
BOOL MatrixView_OnInitDialog(HWND hwnd)
{
int n;
HWND hPosCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_COORD_COMBO);
HWND hDirCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_DIR_COMBO);
// Setup position and direction matrix comboboxes with stack indices
SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)"Current");
SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)"Current");
for(n = 0; n < 32; n++)
{
char buffer[4];
sprintf(buffer, "%d", n);
SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)buffer);
SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)buffer);
}
SendMessage(hPosCombo, CB_SETCURSEL, 0, 0);
SendMessage(hDirCombo, CB_SETCURSEL, 0, 0);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////
BOOL MatrixView_OnClose(matrixview_struct* win)
{
win->window.autoup = FALSE;
CWindow_RemoveFromRefreshList(win);
EndDialog(win->window.hwnd, 0);
MatrixView_Deinit(win);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////
void MatrixView_OnPaintPositionMatrix(matrixview_struct* win)
void MatrixView_OnPaintPositionMatrix(HWND hwnd)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
@ -94,18 +56,18 @@ void MatrixView_OnPaintPositionMatrix(matrixview_struct* win)
};
float matrix[16];
HWND hStackCombo = GetDlgItem(win->window.hwnd, IDC_MATRIX_VIEWER_COORD_COMBO);
HWND hStackCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_COORD_COMBO);
int stackIndex;
stackIndex = SendMessage(hStackCombo, CB_GETCURSEL, 0, 0) - 1;
gfx3d_glGetMatrix(1, stackIndex, matrix);
MatrixView_SetMatrix(win, idcGroup, matrix);
MatrixView_SetMatrix(hwnd, idcGroup, matrix);
}
//////////////////////////////////////////////////////////////////////////////
void MatrixView_OnPaintDirectionMatrix(matrixview_struct* win)
void MatrixView_OnPaintDirectionMatrix(HWND hwnd)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
@ -117,18 +79,18 @@ void MatrixView_OnPaintDirectionMatrix(matrixview_struct* win)
};
float matrix[16];
HWND hStackCombo = GetDlgItem(win->window.hwnd, IDC_MATRIX_VIEWER_DIR_COMBO);
HWND hStackCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_DIR_COMBO);
int stackIndex;
stackIndex = SendMessage(hStackCombo, CB_GETCURSEL, 0, 0) - 1;
gfx3d_glGetMatrix(2, stackIndex, matrix);
MatrixView_SetMatrix(win, idcGroup, matrix);
MatrixView_SetMatrix(hwnd, idcGroup, matrix);
}
//////////////////////////////////////////////////////////////////////////////
void MatrixView_OnPaintProjectionMatrix(matrixview_struct* win)
void MatrixView_OnPaintProjectionMatrix(HWND hwnd)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
@ -142,12 +104,12 @@ void MatrixView_OnPaintProjectionMatrix(matrixview_struct* win)
float mat[16];
gfx3d_glGetMatrix(0, -1, mat);
MatrixView_SetMatrix(win, idcGroup, mat);
MatrixView_SetMatrix(hwnd, idcGroup, mat);
}
//////////////////////////////////////////////////////////////////////////////
void MatrixView_OnPaintTextureMatrix(matrixview_struct* win)
void MatrixView_OnPaintTextureMatrix(HWND hwnd)
{
// IDC for each matrix coefficient
const int idcGroup[16] =
@ -161,98 +123,130 @@ void MatrixView_OnPaintTextureMatrix(matrixview_struct* win)
float mat[16];
gfx3d_glGetMatrix(3, -1, mat);
MatrixView_SetMatrix(win, idcGroup, mat);
MatrixView_SetMatrix(hwnd, idcGroup, mat);
}
//////////////////////////////////////////////////////////////////////////////
BOOL MatrixView_OnPaint(matrixview_struct* win, HWND hwnd, WPARAM wParam, LPARAM lParam)
BOOL MatrixView_OnPaint( HWND hwnd, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hwnd, &ps);
MatrixView_OnPaintProjectionMatrix(win);
MatrixView_OnPaintPositionMatrix(win);
MatrixView_OnPaintDirectionMatrix(win);
MatrixView_OnPaintTextureMatrix(win);
MatrixView_OnPaintProjectionMatrix(hwnd);
MatrixView_OnPaintPositionMatrix(hwnd);
MatrixView_OnPaintDirectionMatrix(hwnd);
MatrixView_OnPaintTextureMatrix(hwnd);
EndPaint(hwnd, &ps);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////////
BOOL CALLBACK MatrixView_Proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
BOOL CALLBACK ViewMatricesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
matrixview_struct *win = (matrixview_struct *)GetWindowLong(hwnd, DWL_USER);
switch (message)
{
case WM_INITDIALOG:
return MatrixView_OnInitDialog(hwnd);
{
MatrixView = new matrixview_struct;
memset(MatrixView, 0, sizeof(matrixview_struct));
MatrixView->autoup_secs = 5;
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETRANGE, 0, MAKELONG(99, 1));
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETPOS32, 0, MatrixView->autoup_secs);
int n;
HWND hPosCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_COORD_COMBO);
HWND hDirCombo = GetDlgItem(hwnd, IDC_MATRIX_VIEWER_DIR_COMBO);
// Setup position and direction matrix comboboxes with stack indices
SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)"Current");
SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)"Current");
for(n = 0; n < 32; n++)
{
char buffer[4];
sprintf(buffer, "%d", n);
SendMessage(hPosCombo, CB_ADDSTRING, 0,(LPARAM)buffer);
SendMessage(hDirCombo, CB_ADDSTRING, 0,(LPARAM)buffer);
}
SendMessage(hPosCombo, CB_SETCURSEL, 0, 0);
SendMessage(hDirCombo, CB_SETCURSEL, 0, 0);
return 1;
}
case WM_CLOSE:
return MatrixView_OnClose(win);
{
if(MatrixView->autoup)
{
KillTimer(hwnd, IDT_VIEW_MATRIX);
MatrixView->autoup = false;
}
if (MatrixView!=NULL)
{
delete MatrixView;
MatrixView = NULL;
}
//printlog("Close Matrix view dialog\n");
PostQuitMessage(0);
return 0;
}
case WM_PAINT:
return MatrixView_OnPaint(win, hwnd, wParam, lParam);
MatrixView_OnPaint(hwnd, wParam, lParam);
return 1;
case WM_TIMER:
SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0);
return 1;
case WM_COMMAND:
switch (LOWORD (wParam))
{
case IDOK:
CWindow_RemoveFromRefreshList(win);
MatrixView_Deinit(win);
EndDialog(hwnd, 0);
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 1;
case IDC_AUTO_UPDATE :
if(MatrixView->autoup)
{
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false);
KillTimer(hwnd, IDT_VIEW_MATRIX);
MatrixView->autoup = FALSE;
return 1;
}
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true);
MatrixView->autoup = TRUE;
SetTimer(hwnd, IDT_VIEW_MATRIX, MatrixView->autoup_secs*1000, (TIMERPROC) NULL);
return 1;
case IDC_AUTO_UPDATE_SECS:
{
int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE);
if (t != MatrixView->autoup_secs)
{
MatrixView->autoup_secs = t;
if (MatrixView->autoup)
SetTimer(hwnd, IDT_VIEW_MATRIX,
MatrixView->autoup_secs*1000, (TIMERPROC) NULL);
}
}
return 1;
case IDC_REFRESH:
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case IDC_MATRIX_VIEWER_DIR_COMBO:
case IDC_MATRIX_VIEWER_COORD_COMBO:
InvalidateRect(hwnd, NULL, FALSE);
return 1;
}
return 0;
case WM_SYSCOMMAND:
switch (LOWORD (wParam))
{
case IDC_AUTO_UPDATE:
CWindow_ToggleAutoUpdate(win);
return 1;
}
return 0;
}
return 0;
return DefWindowProc(hwnd, message, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
matrixview_struct *MatrixView_Init(HINSTANCE hInst, HWND parent)
{
matrixview_struct *MatrixView=NULL;
if ((MatrixView = (matrixview_struct *)malloc(sizeof(matrixview_struct))) == NULL)
return NULL;
if (CWindow_Init2(&MatrixView->window, hInst, parent, "Matrix viewer", IDD_MATRIX_VIEWER, MatrixView_Proc) != 0)
{
free(MatrixView);
return NULL;
}
return MatrixView;
}
//////////////////////////////////////////////////////////////////////////////
void MatrixView_Deinit(matrixview_struct *MatrixView)
{
if (MatrixView)
free(MatrixView);
}
//////////////////////////////////////////////////////////////////////////////

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;
extern BOOL CALLBACK ViewMatricesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
matrixview_struct *MatrixView_Init(HINSTANCE hInst, HWND parent);
void MatrixView_Deinit(matrixview_struct *MatrixView);
#endif
#endif

File diff suppressed because it is too large Load Diff

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);
s8 cpu;
u32 curr_ligne;
u8 representation;
};
*/
extern bool CALLBACK ViewMem_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
extern LRESULT CALLBACK ViewMem_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
typedef struct
{
HWND hwnd;
BOOL autoup;
void *prev;
void *next;
void *first;
void (*Refresh)(void *win);
extern bool CALLBACK ViewMem_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
extern LRESULT CALLBACK ViewMem_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
s8 cpu;
u32 curr_ligne;
u8 representation;
} memview_struct;
void InitMemViewBox();
memview_struct *MemView_Init(HINSTANCE hInst, HWND parent, char *title, u8 CPU);
void MemView_Deinit(memview_struct *MemView);
#endif
#endif

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)
{
oamview_struct *win = (oamview_struct *)GetWindowLong(hwnd, DWL_USER);
switch (message)
switch(msg)
{
case WM_NCCREATE:
return 1;
case WM_NCDESTROY:
return 1;
case WM_PAINT:
OAMViewBox_OnPaint(hwnd, wParam, lParam);
return 1;
case WM_ERASEBKGND:
return 1;
default:
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
BOOL CALLBACK ViewOAMProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
{
OAMView = new oamview_struct;
memset(OAMView, 0, sizeof(oamview_struct));
OAMView->oam = (OAM *)(ARM9Mem.ARM9_OAM);
OAMView->gpu = MainScreen.gpu;
OAMView->autoup_secs = 5;
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETRANGE, 0, MAKELONG(99, 1));
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETPOS32, 0, OAMView->autoup_secs);
HWND combo = GetDlgItem(hwnd, IDC_SCR_SELECT);
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen sprite");
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen sprite");
@ -243,37 +228,79 @@ BOOL CALLBACK OamView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
}
return 1;
case WM_CLOSE :
CWindow_RemoveFromRefreshList(win);
OamView_Deinit(win);
EndDialog(hwnd, 0);
return 1;
{
if(OAMView->autoup)
{
KillTimer(hwnd, IDT_VIEW_OAM);
OAMView->autoup = false;
}
if (OAMView!=NULL)
{
delete OAMView;
OAMView = NULL;
}
//printlog("Close OAM viewer dialog\n");
PostQuitMessage(0);
return 0;
}
case WM_PAINT:
OamView_OnPaint(win, wParam, lParam);
OamView_OnPaint(hwnd, OAMView, wParam, lParam);
return 1;
case WM_TIMER:
SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0);
return 1;
case WM_HSCROLL :
switch LOWORD(wParam)
{
case SB_LINERIGHT :
++(win->num);
if(win->num>127)
win->num = 127;
++(OAMView->num);
if(OAMView->num>127)
OAMView->num = 127;
break;
case SB_LINELEFT :
--(win->num);
if(win->num<0)
win->num = 0;
--(OAMView->num);
if(OAMView->num<0)
OAMView->num = 0;
break;
}
CWindow_Refresh(win);
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDC_FERMER :
CWindow_RemoveFromRefreshList(win);
OamView_Deinit(win);
EndDialog(hwnd, 0);
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 1;
case IDC_AUTO_UPDATE :
if(OAMView->autoup)
{
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false);
KillTimer(hwnd, IDT_VIEW_OAM);
OAMView->autoup = FALSE;
return 1;
}
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true);
OAMView->autoup = TRUE;
SetTimer(hwnd, IDT_VIEW_OAM, OAMView->autoup_secs*1000, (TIMERPROC) NULL);
return 1;
case IDC_AUTO_UPDATE_SECS:
{
int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE);
if (t != OAMView->autoup_secs)
{
OAMView->autoup_secs = t;
if (OAMView->autoup)
SetTimer(hwnd, IDT_VIEW_OAM,
OAMView->autoup_secs*1000, (TIMERPROC) NULL);
}
}
return 1;
case IDC_REFRESH:
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case IDC_SCR_SELECT :
switch(HIWORD(wParam))
{
@ -283,56 +310,23 @@ BOOL CALLBACK OamView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
switch(sel)
{
case 0 :
win->oam = (OAM *)ARM9Mem.ARM9_OAM;
win->num = 0;
win->gpu = MainScreen.gpu;
OAMView->oam = (OAM *)ARM9Mem.ARM9_OAM;
OAMView->num = 0;
OAMView->gpu = MainScreen.gpu;
break;
case 1 :
win->oam = (OAM *)(ARM9Mem.ARM9_OAM+0x400);
win->num = 0;
win->gpu = SubScreen.gpu;
OAMView->oam = (OAM *)(ARM9Mem.ARM9_OAM+0x400);
OAMView->num = 0;
OAMView->gpu = SubScreen.gpu;
break;
}
}
CWindow_Refresh(win);
InvalidateRect(hwnd, NULL, FALSE);
return 1;
}
return 1;
}
return 0;
}
return 0;
return DefWindowProc(hwnd, message, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
oamview_struct *OamView_Init(HINSTANCE hInst, HWND parent)
{
oamview_struct *OamView=NULL;
if ((OamView = (oamview_struct *)malloc(sizeof(oamview_struct))) == NULL)
return OamView;
if (CWindow_Init2(OamView, hInst, parent, "OAM Viewer", IDD_OAM, OamView_Proc) != 0)
{
free(OamView);
return NULL;
}
OamView->oam = (OAM *)(ARM9Mem.ARM9_OAM);
OamView->num = 0;
OamView->gpu = MainScreen.gpu;
return OamView;
}
//////////////////////////////////////////////////////////////////////////////
void OamView_Deinit(oamview_struct *OamView)
{
if (OamView)
free(OamView);
}
//////////////////////////////////////////////////////////////////////////////

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)
switch (message)
{
case WM_INITDIALOG :
{
PalView = new palview_struct;
memset(PalView, 0, sizeof(palview_struct));
PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM;
PalView->autoup_secs = 5;
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETRANGE, 0, MAKELONG(99, 1));
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETPOS32, 0, PalView->autoup_secs);
HWND combo = GetDlgItem(hwnd, IDC_PAL_SELECT);
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen BG PAL");
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen BG PAL");
@ -111,48 +124,80 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE);
}
return 1;
case WM_CLOSE :
CWindow_RemoveFromRefreshList(win);
PalView_Deinit(win);
EndDialog(hwnd, 0);
return 1;
case WM_CLOSE :
{
if(PalView->autoup)
{
KillTimer(hwnd, IDT_VIEW_DISASM7);
PalView->autoup = false;
}
if (PalView!=NULL)
{
delete PalView;
PalView = NULL;
}
//printlog("Close Palette view dialog\n");
PostQuitMessage(0);
return 0;
}
case WM_PAINT:
PalView_OnPaint(win->adr, win->palnum, hwnd, wParam, lParam);
PalView_OnPaint(PalView->adr, PalView->palnum, hwnd, wParam, lParam);
return 1;
case WM_TIMER:
SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0);
return 1;
case WM_HSCROLL :
switch LOWORD(wParam)
{
case SB_LINERIGHT :
++(win->palnum);
if(win->palnum>15)
win->palnum = 15;
++(PalView->palnum);
if(PalView->palnum>15)
PalView->palnum = 15;
break;
case SB_LINELEFT :
--(win->palnum);
if(win->palnum<0)
win->palnum = 0;
--(PalView->palnum);
if(PalView->palnum<0)
PalView->palnum = 0;
break;
}
CWindow_Refresh(win);
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDC_FERMER :
CWindow_RemoveFromRefreshList(win);
PalView_Deinit(win);
EndDialog(hwnd, 0);
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 1;
case IDC_AUTO_UPDATE :
if(win->autoup)
if(PalView->autoup)
{
CWindow_RemoveFromRefreshList(win);
win->autoup = FALSE;
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false);
KillTimer(hwnd, IDT_VIEW_PAL);
PalView->autoup = FALSE;
return 1;
}
CWindow_AddToRefreshList(win);
win->autoup = TRUE;
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true);
PalView->autoup = TRUE;
SetTimer(hwnd, IDT_VIEW_PAL, PalView->autoup_secs*1000, (TIMERPROC) NULL);
return 1;
case IDC_AUTO_UPDATE_SECS:
{
int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE);
if (t != PalView->autoup_secs)
{
PalView->autoup_secs = t;
if (PalView->autoup)
SetTimer(hwnd, IDT_VIEW_PAL,
PalView->autoup_secs*1000, (TIMERPROC) NULL);
}
}
return 1;
case IDC_REFRESH:
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case IDC_PAL_SELECT :
switch(HIWORD(wParam))
{
@ -163,26 +208,26 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
switch(sel)
{
case 0 :
win->adr = (u16 *)ARM9Mem.ARM9_VMEM;
win->palnum = 0;
PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM;
PalView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE);
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE);
break;
case 1 :
win->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200;
win->palnum = 0;
PalView->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200;
PalView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE);
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE);
break;
case 2 :
win->adr = (u16 *)ARM9Mem.ARM9_VMEM + 0x100;
win->palnum = 0;
PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM + 0x100;
PalView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE);
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE);
break;
case 3 :
win->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300;
win->palnum = 0;
PalView->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300;
PalView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE);
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE);
break;
@ -190,8 +235,8 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
case 5 :
case 6 :
case 7 :
win->adr = ((u16 *)(ARM9Mem.ExtPal[0][sel-4]));
win->palnum = 0;
PalView->adr = ((u16 *)(ARM9Mem.ExtPal[0][sel-4]));
PalView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE);
break;
@ -199,22 +244,22 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
case 9 :
case 10 :
case 11 :
win->adr = ((u16 *)(ARM9Mem.ExtPal[1][sel-8]));
win->palnum = 0;
PalView->adr = ((u16 *)(ARM9Mem.ExtPal[1][sel-8]));
PalView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE);
break;
case 12 :
case 13 :
win->adr = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12]));
win->palnum = 0;
PalView->adr = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12]));
PalView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE);
break;
case 14 :
case 15 :
win->adr = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14]));
win->palnum = 0;
PalView->adr = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14]));
PalView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE);
break;
@ -222,15 +267,15 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
case 17 :
case 18 :
case 19 :
win->adr = ((u16 *)(ARM9Mem.texPalSlot[sel-16]));
win->palnum = 0;
PalView->adr = ((u16 *)(ARM9Mem.texPalSlot[sel-16]));
PalView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), TRUE);
break;
default :
return 1;
}
CWindow_Refresh(win);
InvalidateRect(hwnd, NULL, FALSE);
return 1;
}
}
@ -238,36 +283,5 @@ BOOL CALLBACK PalView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPara
}
return 0;
}
return 0;
return DefWindowProc(hwnd, message, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
palview_struct *PalView_Init(HINSTANCE hInst, HWND parent)
{
palview_struct *PalView=NULL;
if ((PalView = (palview_struct *)malloc(sizeof(palview_struct))) == NULL)
return PalView;
if (CWindow_Init2(PalView, hInst, parent, "Palette viewer", IDD_PAL, PalView_Proc) != 0)
{
free(PalView);
return NULL;
}
PalView->palnum = 0;
PalView->adr = (u16 *)ARM9Mem.ARM9_VMEM;
return PalView;
}
//////////////////////////////////////////////////////////////////////////////
void PalView_Deinit(palview_struct *PalView)
{
if (PalView)
free(PalView);
}
//////////////////////////////////////////////////////////////////////////////

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);
#endif
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;
wc.cbSize = sizeof(wc);
wc.lpszClassName = _T("TileViewBox");
wc.hInstance = GetModuleHandle(0);
wc.lpfnWndProc = TileViewBoxWndProc;
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hIcon = 0;
wc.lpszMenuName = 0;
wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE);
wc.style = 0;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(cwindow_struct *);
wc.hIconSm = 0;
RegisterClassEx(&wc);
wc.cbSize = sizeof(wc);
wc.lpszClassName = _T("MiniTileViewBox");
wc.hInstance = GetModuleHandle(0);
wc.lpfnWndProc = MiniTileViewBoxWndProc;
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
wc.hIcon = 0;
wc.lpszMenuName = 0;
wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_BTNFACE);
wc.style = 0;
wc.cbClsExtra = 0;
wc.cbWndExtra = sizeof(cwindow_struct *);
wc.hIconSm = 0;
RegisterClassEx(&wc);
}
u32 autoup_secs;
bool autoup;
//////////////////////////////////////////////////////////////////////////////
HWND hwnd;
u8 * mem;
u16 * pal;
s16 palnum;
u16 tilenum;
u8 coul;
u32 x;
u32 y;
} tileview_struct;
LRESULT MiniTileViewBox_Paint(tileview_struct * win, WPARAM wParam, LPARAM lParam)
tileview_struct *TileView = NULL;
LRESULT TileViewBox_Direct(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam)
{
HWND hwnd_dst = GetDlgItem(win->hwnd, IDC_MINI_TILE);
HWND hwnd_src = GetDlgItem(win->hwnd, IDC_Tile_BOX);
HDC hdc_src;
HDC hdc_dst;
char txt[80];
PAINTSTRUCT ps;
hdc_dst = BeginPaint(hwnd_dst, &ps);
hdc_src = GetDC(hwnd_src);
StretchBlt(hdc_dst, 0, 0, 80, 80, hdc_src, win->x, win->y, 8, 8, SRCCOPY);
sprintf(txt, "Tile num : 0x%X", win->tilenum);
SetWindowText(GetDlgItem(win->hwnd, IDC_TILENUM), txt);
EndPaint(hwnd_dst, &ps);
return 0;
}
//////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK MiniTileViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
tileview_struct * win = (tileview_struct *)GetWindowLong(hwnd, 0);
switch(msg)
{
case WM_NCCREATE:
return 1;
case WM_NCDESTROY:
return 1;
case WM_PAINT :
MiniTileViewBox_Paint(win, wParam, lParam);
return 1;
case WM_ERASEBKGND:
return 1;
default:
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
LRESULT TileViewBox_Direct(tileview_struct * win, WPARAM wParam, LPARAM lParam)
{
HWND hwnd = GetDlgItem(win->hwnd, IDC_Tile_BOX);
HDC hdc;
PAINTSTRUCT ps;
// SIZE fontsize;
@ -163,9 +91,8 @@ LRESULT TileViewBox_Direct(tileview_struct * win, WPARAM wParam, LPARAM lParam)
//////////////////////////////////////////////////////////////////////////////
LRESULT TileViewBox_Pal256(tileview_struct * win, WPARAM wParam, LPARAM lParam)
LRESULT TileViewBox_Pal256(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam)
{
HWND hwnd = GetDlgItem(win->hwnd, IDC_Tile_BOX);
HDC hdc;
PAINTSTRUCT ps;
// SIZE fontsize;
@ -215,7 +142,7 @@ LRESULT TileViewBox_Pal256(tileview_struct * win, WPARAM wParam, LPARAM lParam)
bitmap[x + (y*256) + (num*8) +(num2*256*8)] = pal[win->mem[x + (y*8) + (num*64) +(num2*2048)]];
SetDIBitsToDevice(mem_dc, 0, 0, 256, 256, 0, 0, 0, 256, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS);
sprintf(text, "Pal : %d", win->palnum);
SetWindowText(GetDlgItem(win->hwnd, IDC_PALNUM), text);
SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), text);
}
else
TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23);
@ -231,9 +158,8 @@ LRESULT TileViewBox_Pal256(tileview_struct * win, WPARAM wParam, LPARAM lParam)
//////////////////////////////////////////////////////////////////////////////
LRESULT TileViewBox_Pal16(tileview_struct * win, WPARAM wParam, LPARAM lParam)
LRESULT TileViewBox_Pal16(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam)
{
HWND hwnd = GetDlgItem(win->hwnd, IDC_Tile_BOX);
HDC hdc;
PAINTSTRUCT ps;
// SIZE fontsize;
@ -283,7 +209,7 @@ LRESULT TileViewBox_Pal16(tileview_struct * win, WPARAM wParam, LPARAM lParam)
}
SetDIBitsToDevice(mem_dc, 0, 0, 512, 256, 0, 0, 0, 256, bitmap, (BITMAPINFO*)&bmi, DIB_RGB_COLORS);
sprintf(text, "Pal : %d", win->palnum);
SetWindowText(GetDlgItem(win->hwnd, IDC_PALNUM), text);
SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), text);
}
else
TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23);
@ -299,70 +225,110 @@ LRESULT TileViewBox_Pal16(tileview_struct * win, WPARAM wParam, LPARAM lParam)
//////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK TileViewBoxWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
LRESULT CALLBACK TileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
tileview_struct * win = (tileview_struct *)GetWindowLong(hwnd, 0);
switch(msg)
{
case WM_NCCREATE:
return 1;
case WM_NCDESTROY:
return 1;
case WM_PAINT:
switch(win->coul)
{
case 0 :
TileViewBox_Direct(win, wParam, lParam);
return 1;
case 1 :
TileViewBox_Pal256(win, wParam, lParam);
return 1;
case 2 :
TileViewBox_Pal16(win, wParam, lParam);
return 1;
}
return 1;
case WM_LBUTTONDOWN :
switch(win->coul)
{
case 0 :
case 1 :
if(LOWORD(lParam)<(32*8))
{
win->x = ((LOWORD(lParam)>>3)<<3);
win->y = (HIWORD(lParam)>>3)<<3;
win->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*32;
}
break;
case 2 :
win->x = ((LOWORD(lParam)>>3)<<3);
win->y = (HIWORD(lParam)>>3)<<3;
win->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*64;
break;
}
InvalidateRect(GetDlgItem(win->hwnd, IDC_MINI_TILE), NULL, FALSE);
UpdateWindow(GetDlgItem(win->hwnd, IDC_MINI_TILE));
//CWindow_Refresh(win);
return 1;
case WM_ERASEBKGND:
return 1;
default:
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
switch(msg)
{
case WM_INITDIALOG:
return 1;
case WM_NCCREATE:
return 1;
case WM_NCDESTROY:
return 1;
case WM_PAINT:
switch(TileView->coul)
{
case 0 :
TileViewBox_Direct(hwnd, TileView, wParam, lParam);
break;
case 1 :
TileViewBox_Pal256(hwnd, TileView, wParam, lParam);
break;
case 2 :
TileViewBox_Pal16(hwnd, TileView, wParam, lParam);
break;
}
break;
case WM_LBUTTONDOWN :
switch(TileView->coul)
{
case 0 :
case 1 :
if(LOWORD(lParam)<(32*8))
{
TileView->x = ((LOWORD(lParam)>>3)<<3);
TileView->y = (HIWORD(lParam)>>3)<<3;
TileView->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*32;
}
break;
case 2 :
TileView->x = ((LOWORD(lParam)>>3)<<3);
TileView->y = (HIWORD(lParam)>>3)<<3;
TileView->tilenum = (LOWORD(lParam)>>3) + (HIWORD(lParam)>>3)*64;
break;
}
InvalidateRect(GetDlgItem(hwnd, IDC_MINI_TILE), NULL, FALSE);
return 1;
case WM_ERASEBKGND:
return 1;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
LRESULT MiniTileViewBox_Paint(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam)
{
tileview_struct * win = (tileview_struct *)GetWindowLong(hwnd, DWL_USER);
switch (message)
HWND hwnd_src = GetDlgItem(hwnd, IDC_Tile_BOX);
HDC hdc_src;
HDC hdc_dst;
char txt[80];
PAINTSTRUCT ps;
hdc_dst = BeginPaint(hwnd, &ps);
hdc_src = GetDC(hwnd_src);
StretchBlt(hdc_dst, 0, 0, 80, 80, hdc_src, win->x, win->y, 8, 8, SRCCOPY);
sprintf(txt, "Tile num : 0x%X", win->tilenum);
SetWindowText(GetDlgItem(win->hwnd, IDC_TILENUM), txt);
EndPaint(hwnd, &ps);
return 0;
}
LRESULT CALLBACK MiniTileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_NCCREATE:
return 1;
case WM_NCDESTROY:
return 1;
case WM_PAINT :
MiniTileViewBox_Paint(hwnd, TileView, wParam, lParam);
break;
case WM_ERASEBKGND:
return 1;
default:
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
BOOL CALLBACK ViewTilesProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
{
TileView = new tileview_struct;
memset(TileView, 0, sizeof(tileview_struct));
TileView->hwnd = hwnd;
TileView->mem = ARM9Mem.ARM9_ABG;
TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM);
TileView->autoup_secs = 5;
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETRANGE, 0, MAKELONG(99, 1));
SendMessage(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN),
UDM_SETPOS32, 0, TileView->autoup_secs);
HWND combo = GetDlgItem(hwnd, IDC_PAL_SELECT);
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen BG PAL");
SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen BG PAL");
@ -422,55 +388,84 @@ BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar
}
return 1;
case WM_CLOSE :
CWindow_RemoveFromRefreshList(win);
TileView_Deinit(win);
EndDialog(hwnd, 0);
if(TileView->autoup)
{
KillTimer(hwnd, IDT_VIEW_TILE);
TileView->autoup = false;
}
if (TileView!=NULL)
{
delete TileView;
TileView = NULL;
}
//printlog("Close Tile view dialog\n");
PostQuitMessage(0);
return 1;
case WM_TIMER:
SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0);
return 1;
case WM_HSCROLL :
switch LOWORD(wParam)
{
case SB_LINERIGHT :
++(win->palnum);
if(win->palnum>15)
win->palnum = 15;
++(TileView->palnum);
if(TileView->palnum>15)
TileView->palnum = 15;
break;
case SB_LINELEFT :
--(win->palnum);
if(win->palnum<0)
win->palnum = 0;
--(TileView->palnum);
if(TileView->palnum<0)
TileView->palnum = 0;
break;
}
CWindow_Refresh(win);
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case WM_COMMAND :
switch (LOWORD (wParam))
{
case IDC_FERMER :
CWindow_RemoveFromRefreshList(win);
TileView_Deinit(win);
EndDialog(hwnd, 0);
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 1;
case IDC_AUTO_UPDATE :
if(win->autoup)
if(TileView->autoup)
{
CWindow_RemoveFromRefreshList(win);
win->autoup = FALSE;
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), false);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), false);
KillTimer(hwnd, IDT_VIEW_TILE);
TileView->autoup = FALSE;
return 1;
}
CWindow_AddToRefreshList(win);
win->autoup = TRUE;
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SECS), true);
EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE_SPIN), true);
TileView->autoup = TRUE;
SetTimer(hwnd, IDT_VIEW_TILE, TileView->autoup_secs*1000, (TIMERPROC) NULL);
return 1;
case IDC_AUTO_UPDATE_SECS:
{
int t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE);
if (t != TileView->autoup_secs)
{
TileView->autoup_secs = t;
if (TileView->autoup)
SetTimer(hwnd, IDT_VIEW_TILE,
TileView->autoup_secs*1000, (TIMERPROC) NULL);
}
}
return 1;
case IDC_REFRESH:
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case IDC_BITMAP :
win->coul = 0;
CWindow_Refresh(win);
TileView->coul = 0;
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case IDC_256COUL :
win->coul = 1;
CWindow_Refresh(win);
TileView->coul = 1;
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case IDC_16COUL :
win->coul = 2;
CWindow_Refresh(win);
TileView->coul = 2;
InvalidateRect(hwnd, NULL, FALSE);
return 1;
case IDC_MEM_SELECT :
switch(HIWORD(wParam))
@ -489,21 +484,21 @@ BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar
case 5 :
case 6 :
case 7 :
win->mem = ARM9Mem.ARM9_ABG + 0x10000*sel;
TileView->mem = ARM9Mem.ARM9_ABG + 0x10000*sel;
break;
case 8 :
case 9 :
win->mem = ARM9Mem.ARM9_BBG + 0x10000*(sel-8);
TileView->mem = ARM9Mem.ARM9_BBG + 0x10000*(sel-8);
break;
case 10 :
case 11 :
case 12 :
case 13 :
win->mem = ARM9Mem.ARM9_AOBJ + 0x10000*(sel-10);
TileView->mem = ARM9Mem.ARM9_AOBJ + 0x10000*(sel-10);
break;
case 14 :
case 15 :
win->mem = ARM9Mem.ARM9_BOBJ + 0x10000*(sel-14);
TileView->mem = ARM9Mem.ARM9_BOBJ + 0x10000*(sel-14);
break;
case 16 :
case 17 :
@ -515,12 +510,12 @@ BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar
case 23 :
case 24 :
case 25 :
win->mem = ARM9Mem.ARM9_LCD + 0x10000*(sel-16);
TileView->mem = ARM9Mem.ARM9_LCD + 0x10000*(sel-16);
break;
default :
return 1;
}
CWindow_Refresh(win);
InvalidateRect(hwnd, NULL, FALSE);
return 1;
}
}
@ -535,26 +530,26 @@ BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar
switch(sel)
{
case 0 :
win->pal = (u16 *)ARM9Mem.ARM9_VMEM;
win->palnum = 0;
TileView->pal = (u16 *)ARM9Mem.ARM9_VMEM;
TileView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE);
break;
case 1 :
win->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200;
win->palnum = 0;
TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x200;
TileView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE);
break;
case 2 :
win->pal = (u16 *)ARM9Mem.ARM9_VMEM + 0x100;
win->palnum = 0;
TileView->pal = (u16 *)ARM9Mem.ARM9_VMEM + 0x100;
TileView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE);
break;
case 3 :
win->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300;
win->palnum = 0;
TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300;
TileView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE);
break;
@ -562,110 +557,72 @@ BOOL CALLBACK TileView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar
case 5 :
case 6 :
case 7 :
win->pal = ((u16 *)(ARM9Mem.ExtPal[0][sel-4]));
win->palnum = 0;
TileView->pal = ((u16 *)(ARM9Mem.ExtPal[0][sel-4]));
TileView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_HIDE);
EnableWindow(GetDlgItem(hwnd, IDC_16COUL), FALSE);
if(win->coul == 2)
if(TileView->coul == 2)
{
SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0);
SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0);
win->coul = 1;
TileView->coul = 1;
}
break;
case 8 :
case 9 :
case 10 :
case 11 :
win->pal = ((u16 *)(ARM9Mem.ExtPal[1][sel-8]));
win->palnum = 0;
TileView->pal = ((u16 *)(ARM9Mem.ExtPal[1][sel-8]));
TileView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_HIDE);
EnableWindow(GetDlgItem(hwnd, IDC_16COUL), FALSE);
if(win->coul == 2)
if(TileView->coul == 2)
{
SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0);
SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0);
win->coul = 1;
TileView->coul = 1;
}
break;
case 12 :
case 13 :
win->pal = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12]));
win->palnum = 0;
if(win->coul == 2)
TileView->pal = ((u16 *)(ARM9Mem.ObjExtPal[0][sel-12]));
TileView->palnum = 0;
if(TileView->coul == 2)
{
SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0);
SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0);
win->coul = 1;
TileView->coul = 1;
}
break;
case 14 :
case 15 :
win->pal = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14]));
win->palnum = 0;
if(win->coul == 2)
TileView->pal = ((u16 *)(ARM9Mem.ObjExtPal[1][sel-14]));
TileView->palnum = 0;
if(TileView->coul == 2)
{
SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0);
SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0);
win->coul = 1;
TileView->coul = 1;
}
break;
case 16 :
case 17 :
case 18 :
case 19 :
win->pal = ((u16 *)(ARM9Mem.texPalSlot[sel-16]));
win->palnum = 0;
TileView->pal = ((u16 *)(ARM9Mem.texPalSlot[sel-16]));
TileView->palnum = 0;
ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW);
EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE);
break;
default :
return 1;
}
CWindow_Refresh(win);
InvalidateRect(hwnd, NULL, FALSE);
return 1;
}
}
}
return 0;
}
return 0;
return DefWindowProc(hwnd, message, wParam, lParam);
}
//////////////////////////////////////////////////////////////////////////////
tileview_struct *TileView_Init(HINSTANCE hInst, HWND parent)
{
tileview_struct *TileView=NULL;
if ((TileView = (tileview_struct *)malloc(sizeof(tileview_struct))) == NULL)
return TileView;
if (CWindow_Init2(TileView, hInst, parent, "Tile viewer", IDD_TILE, TileView_Proc) != 0)
{
free(TileView);
return NULL;
}
TileView->mem = ARM9Mem.ARM9_ABG;
TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM);
TileView->palnum = 0;
TileView->coul = 0;
TileView->x = 0;
TileView->y = 0;
SetWindowLong(GetDlgItem(TileView->hwnd, IDC_Tile_BOX), 0, (LONG)TileView);
SetWindowLong(GetDlgItem(TileView->hwnd, IDC_MINI_TILE), 0, (LONG)TileView);
return TileView;
}
//////////////////////////////////////////////////////////////////////////////
void TileView_Deinit(tileview_struct *TileView)
{
if (TileView)
free(TileView);
}
//////////////////////////////////////////////////////////////////////////////

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