From 23f54c7d7159fd1be9936466291b86b3ece9e6b2 Mon Sep 17 00:00:00 2001 From: mtabachenko Date: Tue, 3 Feb 2009 22:26:01 +0000 Subject: [PATCH] moved timers id for Windows port in common.h :) --- desmume/src/common.h | 13 + desmume/src/windows/DeSmuME_2008.vcproj | 4 - desmume/src/windows/IORegView.cpp | 331 +++--- desmume/src/windows/disView.cpp | 1413 +++++++++++------------ desmume/src/windows/lightView.cpp | 349 +++--- desmume/src/windows/main.cpp | 1 - desmume/src/windows/mapView.cpp | 1 - desmume/src/windows/matrixView.cpp | 1 - desmume/src/windows/memView.cpp | 171 ++- desmume/src/windows/oamView.cpp | 1 - desmume/src/windows/palView.cpp | 561 +++++---- desmume/src/windows/tileView.cpp | 1255 ++++++++++---------- 12 files changed, 2050 insertions(+), 2051 deletions(-) diff --git a/desmume/src/common.h b/desmume/src/common.h index 73f421a6b..22ff59478 100644 --- a/desmume/src/common.h +++ b/desmume/src/common.h @@ -34,6 +34,19 @@ extern u8 gba_header_data_0x04[156]; #define _WINSOCKAPI_ #include + #define IDT_VIEW_DISASM7 50001 + #define IDT_VIEW_DISASM9 50002 + #define IDT_VIEW_MEM7 50003 + #define IDT_VIEW_MEM9 50004 + #define IDT_VIEW_IOREG 50005 + #define IDT_VIEW_PAL 50006 + #define IDT_VIEW_TILE 50007 + #define IDT_VIEW_MAP 50008 + #define IDT_VIEW_OAM 50009 + #define IDT_VIEW_MATRIX 50010 + #define IDT_VIEW_LIGHTS 50011 + #define IDM_EXEC 50112 + #define CLASSNAME "DeSmuME" extern HINSTANCE hAppInst; diff --git a/desmume/src/windows/DeSmuME_2008.vcproj b/desmume/src/windows/DeSmuME_2008.vcproj index d9b5a5d84..5878cf7bb 100644 --- a/desmume/src/windows/DeSmuME_2008.vcproj +++ b/desmume/src/windows/DeSmuME_2008.vcproj @@ -1056,10 +1056,6 @@ RelativePath=".\palView.h" > - - diff --git a/desmume/src/windows/IORegView.cpp b/desmume/src/windows/IORegView.cpp index e588666d8..bbfe65eb1 100644 --- a/desmume/src/windows/IORegView.cpp +++ b/desmume/src/windows/IORegView.cpp @@ -1,172 +1,171 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "ioregview.h" -#include -#include "debug.h" -#include "resource.h" -#include "res_timer_ids.h" -#include "../MMU.h" -#include "../armcpu.h" - -typedef struct -{ - u32 autoup_secs; - bool autoup; -} ioregview_struct; - -ioregview_struct *IORegView; - -LRESULT Ioreg_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - TCHAR text[80]; - - hdc = BeginPaint(hwnd, &ps); - - // ARM9 registers - sprintf(text, "0x%08X", (int)((u32 *)ARM9Mem.ARM9_DTCM)[0x3FFC>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_INTHAND9), text); - - sprintf(text, "0x%08X", (int)MMU.reg_IE[ARMCPU_ARM9]); - SetWindowText(GetDlgItem(hwnd, IDC_IE9), text); - - sprintf(text, "0x%08X", (int)MMU.reg_IF[ARMCPU_ARM9]); - SetWindowText(GetDlgItem(hwnd, IDC_IF9), text); - - sprintf(text, "0x%08X", (int)MMU.reg_IME[ARMCPU_ARM9]); - SetWindowText(GetDlgItem(hwnd, IDC_IME9), text); - - sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x0000>>1]); - SetWindowText(GetDlgItem(hwnd, IDC_DISPCNTA9), text); - - sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x0004>>1]); - SetWindowText(GetDlgItem(hwnd, IDC_DISPSTATA9), text); - - sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x1000>>1]); - SetWindowText(GetDlgItem(hwnd, IDC_DISPCNTB9), text); - - sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x1004>>1]); - SetWindowText(GetDlgItem(hwnd, IDC_DISPSTATB9), text); - - sprintf(text, "0x%08X", (int)((u32 *)ARM9Mem.ARM9_REG)[0x180>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_IPCSYNC9), text); - - sprintf(text, "0x%08X", (int)((u32 *)ARM9Mem.ARM9_REG)[0x184>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_IPCFIFO9), text); - - sprintf(text, "0x%08X", (int)((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x600>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_GXSTAT9), text); - - // ARM7 registers - sprintf(text, "0x%08X", (int)MMU.reg_IE[ARMCPU_ARM7]); - SetWindowText(GetDlgItem(hwnd, IDC_IE7), text); - - sprintf(text, "0x%08X", (int)MMU.reg_IF[ARMCPU_ARM7]); - SetWindowText(GetDlgItem(hwnd, IDC_IF7), text); - - sprintf(text, "0x%08X", (int)MMU.reg_IME[ARMCPU_ARM7]); - SetWindowText(GetDlgItem(hwnd, IDC_IME7), text); - - sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM7_REG)[0x180>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_IPCSYNC7), text); - - sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM7_REG)[0x184>>2]); - SetWindowText(GetDlgItem(hwnd, IDC_IPCFIFO7), text); - EndPaint(hwnd, &ps); - - return 0; -} - -BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - 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 : - if(IORegView->autoup) - { - KillTimer(hwnd, IDT_VIEW_IOREG); - IORegView->autoup = false; +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "ioregview.h" +#include +#include "debug.h" +#include "resource.h" +#include "../MMU.h" +#include "../armcpu.h" + +typedef struct +{ + u32 autoup_secs; + bool autoup; +} ioregview_struct; + +ioregview_struct *IORegView; + +LRESULT Ioreg_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + TCHAR text[80]; + + hdc = BeginPaint(hwnd, &ps); + + // ARM9 registers + sprintf(text, "0x%08X", (int)((u32 *)ARM9Mem.ARM9_DTCM)[0x3FFC>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_INTHAND9), text); + + sprintf(text, "0x%08X", (int)MMU.reg_IE[ARMCPU_ARM9]); + SetWindowText(GetDlgItem(hwnd, IDC_IE9), text); + + sprintf(text, "0x%08X", (int)MMU.reg_IF[ARMCPU_ARM9]); + SetWindowText(GetDlgItem(hwnd, IDC_IF9), text); + + sprintf(text, "0x%08X", (int)MMU.reg_IME[ARMCPU_ARM9]); + SetWindowText(GetDlgItem(hwnd, IDC_IME9), text); + + sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x0000>>1]); + SetWindowText(GetDlgItem(hwnd, IDC_DISPCNTA9), text); + + sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x0004>>1]); + SetWindowText(GetDlgItem(hwnd, IDC_DISPSTATA9), text); + + sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x1000>>1]); + SetWindowText(GetDlgItem(hwnd, IDC_DISPCNTB9), text); + + sprintf(text, "0x%08X", ((u16 *)ARM9Mem.ARM9_REG)[0x1004>>1]); + SetWindowText(GetDlgItem(hwnd, IDC_DISPSTATB9), text); + + sprintf(text, "0x%08X", (int)((u32 *)ARM9Mem.ARM9_REG)[0x180>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_IPCSYNC9), text); + + sprintf(text, "0x%08X", (int)((u32 *)ARM9Mem.ARM9_REG)[0x184>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_IPCFIFO9), text); + + sprintf(text, "0x%08X", (int)((u32 *)(MMU.MMU_MEM[ARMCPU_ARM9][0x40]))[0x600>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_GXSTAT9), text); + + // ARM7 registers + sprintf(text, "0x%08X", (int)MMU.reg_IE[ARMCPU_ARM7]); + SetWindowText(GetDlgItem(hwnd, IDC_IE7), text); + + sprintf(text, "0x%08X", (int)MMU.reg_IF[ARMCPU_ARM7]); + SetWindowText(GetDlgItem(hwnd, IDC_IF7), text); + + sprintf(text, "0x%08X", (int)MMU.reg_IME[ARMCPU_ARM7]); + SetWindowText(GetDlgItem(hwnd, IDC_IME7), text); + + sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM7_REG)[0x180>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_IPCSYNC7), text); + + sprintf(text, "0x%08X", (int)((u32 *)MMU.ARM7_REG)[0x184>>2]); + SetWindowText(GetDlgItem(hwnd, IDC_IPCFIFO7), text); + EndPaint(hwnd, &ps); + + return 0; +} + +BOOL CALLBACK IoregView_Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + 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 : + 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 : - 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 FALSE; -} + } + 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 : + 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 FALSE; +} diff --git a/desmume/src/windows/disView.cpp b/desmume/src/windows/disView.cpp index 97b5b361b..2454081d0 100644 --- a/desmume/src/windows/disView.cpp +++ b/desmume/src/windows/disView.cpp @@ -1,320 +1,319 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include -#include -#include -#include "../MMU.h" -#include "../Disassembler.h" -#include "../NDSSystem.h" -#include "../armcpu.h" -#include "disView.h" -#include -#include "resource.h" -#include "res_timer_ids.h" - -typedef struct -{ - BOOL autogo; - BOOL autoup; - u32 autoup_secs; - u32 curr_ligne; - armcpu_t *cpu; - u16 mode; -} disview_struct; - +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include +#include +#include +#include "../MMU.h" +#include "../Disassembler.h" +#include "../NDSSystem.h" +#include "../armcpu.h" +#include "disView.h" +#include +#include "resource.h" + +typedef struct +{ + BOOL autogo; + BOOL autoup; + u32 autoup_secs; + u32 curr_ligne; + armcpu_t *cpu; + u16 mode; +} disview_struct; + disview_struct *DisView7 = NULL; -disview_struct *DisView9 = NULL; - -static HWND DisViewWnd[2] = {NULL, NULL}; - -#define INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF)) - -LRESULT DisViewBox_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - SIZE fontsize; - TCHAR text[100]; - TCHAR txt[100]; - RECT rect; - int lg; - int ht; - HDC mem_dc; - HBITMAP mem_bmp; - u32 nbligne; - - GetClientRect(hwnd, &rect); - lg = rect.right - rect.left; - ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - mem_dc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT)); - - GetTextExtentPoint32(mem_dc, "0", 1, &fontsize); - - nbligne = ht/fontsize.cy; - - SetTextColor(mem_dc, RGB(0,0,0)); - - if((win->mode==1) || ((win->mode==0) && (win->cpu->CPSR.bits.T == 0))) - { - u32 i; - u32 adr; - - if (win->autoup||win->autogo) - win->curr_ligne = (win->cpu->instruct_adr >> 2) - (win->curr_ligne % nbligne) ; - adr = win->curr_ligne*4; - - for(i = 0; i < nbligne; ++i) - { - 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 - { /* thumb display */ - u32 i; - u32 adr; - if (win->autoup) - win->curr_ligne = (win->cpu->instruct_adr >> 1) - (win->curr_ligne % nbligne) ; - - adr = win->curr_ligne*2; - - for(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 DisViewDialog_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - TCHAR text[80]; - u32 i; - - hdc = BeginPaint(hwnd, &ps); - - for(i = 0; i < 16; ++i) - { - 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; -} - -// =================================================== ARM7 -LRESULT CALLBACK ViewDisasm_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - 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, DisView7, 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 : - DisView7->curr_ligne = std::min(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+1); - break; - case SB_LINEUP : - DisView7->curr_ligne = (u32)std::max(0, (s32)DisView7->curr_ligne-1); - break; - case SB_PAGEDOWN : - DisView7->curr_ligne = std::min(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+nbligne); - break; - case SB_PAGEUP : - DisView7->curr_ligne = (u32)std::max(0, DisView7->curr_ligne-nbligne); - break; - } - - SelectObject(dc, old); - SetScrollPos(hwnd, SB_VERT, DisView7->curr_ligne, TRUE); - InvalidateRect(hwnd, NULL, FALSE); - } - return 1; - - case WM_ERASEBKGND: - return 1; - } - return FALSE; -} - -BOOL CALLBACK ViewDisasm_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //bail out early if the dialog isnt initialized - if(!DisView7 && message != WM_INITDIALOG) - return false; - - 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); - DisViewWnd[1] = NULL; - return 1; - } - case WM_CLOSE : - { - if(DisView7->autoup) - { - KillTimer(hwnd, IDT_VIEW_DISASM7); - DisView7->autoup = false; - } +disview_struct *DisView9 = NULL; + +static HWND DisViewWnd[2] = {NULL, NULL}; + +#define INDEX(i) ((((i)>>16)&0xFF0)|(((i)>>4)&0xF)) + +LRESULT DisViewBox_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + SIZE fontsize; + TCHAR text[100]; + TCHAR txt[100]; + RECT rect; + int lg; + int ht; + HDC mem_dc; + HBITMAP mem_bmp; + u32 nbligne; + + GetClientRect(hwnd, &rect); + lg = rect.right - rect.left; + ht = rect.bottom - rect.top; + + hdc = BeginPaint(hwnd, &ps); + + mem_dc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + SelectObject(mem_dc, GetStockObject(SYSTEM_FIXED_FONT)); + + GetTextExtentPoint32(mem_dc, "0", 1, &fontsize); + + nbligne = ht/fontsize.cy; + + SetTextColor(mem_dc, RGB(0,0,0)); + + if((win->mode==1) || ((win->mode==0) && (win->cpu->CPSR.bits.T == 0))) + { + u32 i; + u32 adr; + + if (win->autoup||win->autogo) + win->curr_ligne = (win->cpu->instruct_adr >> 2) - (win->curr_ligne % nbligne) ; + adr = win->curr_ligne*4; + + for(i = 0; i < nbligne; ++i) + { + 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 + { /* thumb display */ + u32 i; + u32 adr; + if (win->autoup) + win->curr_ligne = (win->cpu->instruct_adr >> 1) - (win->curr_ligne % nbligne) ; + + adr = win->curr_ligne*2; + + for(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 DisViewDialog_OnPaint(HWND hwnd, disview_struct *win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + TCHAR text[80]; + u32 i; + + hdc = BeginPaint(hwnd, &ps); + + for(i = 0; i < 16; ++i) + { + 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; +} + +// =================================================== ARM7 +LRESULT CALLBACK ViewDisasm_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + 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, DisView7, 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 : + DisView7->curr_ligne = std::min(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+1); + break; + case SB_LINEUP : + DisView7->curr_ligne = (u32)std::max(0, (s32)DisView7->curr_ligne-1); + break; + case SB_PAGEDOWN : + DisView7->curr_ligne = std::min(0x3FFFFF7*(1+DisView7->cpu->CPSR.bits.T), DisView7->curr_ligne+nbligne); + break; + case SB_PAGEUP : + DisView7->curr_ligne = (u32)std::max(0, DisView7->curr_ligne-nbligne); + break; + } + + SelectObject(dc, old); + SetScrollPos(hwnd, SB_VERT, DisView7->curr_ligne, TRUE); + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + + case WM_ERASEBKGND: + return 1; + } + return FALSE; +} + +BOOL CALLBACK ViewDisasm_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + //bail out early if the dialog isnt initialized + if(!DisView7 && message != WM_INITDIALOG) + return false; + + 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); + DisViewWnd[1] = NULL; + return 1; + } + case WM_CLOSE : + { + if(DisView7->autoup) + { + KillTimer(hwnd, IDT_VIEW_DISASM7); + DisView7->autoup = false; + } if (DisView7!=NULL) { delete DisView7; @@ -322,243 +321,243 @@ BOOL CALLBACK ViewDisasm_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARA } DisViewWnd[1] = NULL; //INFO("Close ARM7 disassembler\n"); - PostQuitMessage(0); - return 1; - } - case WM_PAINT: - 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 : - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 0; - case IDC_AUTO_DES : - /* address to line correction */ - if ((DisView7->cpu->CPSR.bits.T) && (DisView7->mode == 1)) { - /* from arm to thumb, line * 2*/ - DisView7->curr_ligne <<= 1 ; - } else if (!(DisView7->cpu->CPSR.bits.T) && (DisView7->mode == 2)) { - /* from thumb to arm, line / 2 */ - DisView7->curr_ligne >>= 1 ; - } - DisView7->mode = 0; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - return 1; - case IDC_ARM : - /* address to line correction */ - if ((DisView7->mode==2) || ((DisView7->mode==0) && (DisView7->cpu->CPSR.bits.T))) { - DisView7->curr_ligne >>= 1 ; - } ; - DisView7->mode = 1; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - return 1; - case IDC_THUMB : - /* address to line correction */ - if ((DisView7->mode==1) || ((DisView7->mode==0) && !(DisView7->cpu->CPSR.bits.T))) { - DisView7->curr_ligne <<= 1 ; - } ; - DisView7->mode = 2; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - return 1; - case IDC_AUTO_UPDATE : - if(DisView7->autoup) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), TRUE); - 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; - } - EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), FALSE); - 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 : // TODO: draw in DD - { - int ndstep; - ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE); - NDS_exec(ndstep); - } - return 1; - case IDC_GO : - { - u16 i; - char tmp[16]; - int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 16); - u32 adr = 0; - for(i = 0; i='A')&&(tmp[i]<='F')) - { - adr = adr*16 + (tmp[i]-'A'+10); - continue; - } - if((tmp[i]>='0')&&(tmp[i]<='9')) - { - adr = adr*16 + (tmp[i]-'0'); - continue; - } - } - /* address to line correction */ - switch (DisView7->mode) { - case 0: /* auto */ - DisView7->curr_ligne = adr>>1; - if (DisView7->cpu->CPSR.bits.T) { - DisView7->curr_ligne = adr>>1; - } - break ; - case 1: /* thumb */ - DisView7->curr_ligne = adr>>2; - break ; - case 2: /* arm */ - DisView7->curr_ligne = adr>>1; - break ; - } ; - InvalidateRect(hwnd, NULL, FALSE); - } - return 1; - case IDC_REFRESH: - DisView7->autogo=true; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - DisView7->autogo=false; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - u16 t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + PostQuitMessage(0); + return 1; + } + case WM_PAINT: + 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 : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 0; + case IDC_AUTO_DES : + /* address to line correction */ + if ((DisView7->cpu->CPSR.bits.T) && (DisView7->mode == 1)) { + /* from arm to thumb, line * 2*/ + DisView7->curr_ligne <<= 1 ; + } else if (!(DisView7->cpu->CPSR.bits.T) && (DisView7->mode == 2)) { + /* from thumb to arm, line / 2 */ + DisView7->curr_ligne >>= 1 ; + } + DisView7->mode = 0; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_ARM : + /* address to line correction */ + if ((DisView7->mode==2) || ((DisView7->mode==0) && (DisView7->cpu->CPSR.bits.T))) { + DisView7->curr_ligne >>= 1 ; + } ; + DisView7->mode = 1; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_THUMB : + /* address to line correction */ + if ((DisView7->mode==1) || ((DisView7->mode==0) && !(DisView7->cpu->CPSR.bits.T))) { + DisView7->curr_ligne <<= 1 ; + } ; + DisView7->mode = 2; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + return 1; + case IDC_AUTO_UPDATE : + if(DisView7->autoup) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), TRUE); + 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; + } + EnableWindow(GetDlgItem(hwnd, IDC_AUTOUPDATE_ASM), FALSE); + 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 : // TODO: draw in DD + { + int ndstep; + ndstep = GetDlgItemInt(hwnd, IDC_SETPNUM, NULL, FALSE); + NDS_exec(ndstep); + } + return 1; + case IDC_GO : + { + u16 i; + char tmp[16]; + int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 16); + u32 adr = 0; + for(i = 0; i='A')&&(tmp[i]<='F')) + { + adr = adr*16 + (tmp[i]-'A'+10); + continue; + } + if((tmp[i]>='0')&&(tmp[i]<='9')) + { + adr = adr*16 + (tmp[i]-'0'); + continue; + } + } + /* address to line correction */ + switch (DisView7->mode) { + case 0: /* auto */ + DisView7->curr_ligne = adr>>1; + if (DisView7->cpu->CPSR.bits.T) { + DisView7->curr_ligne = adr>>1; + } + break ; + case 1: /* thumb */ + DisView7->curr_ligne = adr>>2; + break ; + case 2: /* arm */ + DisView7->curr_ligne = adr>>1; + break ; + } ; + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + case IDC_REFRESH: + DisView7->autogo=true; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + DisView7->autogo=false; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + u16 t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); if (!DisView7) { SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - 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; - case IDC_AUTOUPDATE_ASM: - { - if (DisViewWnd[1] == NULL) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), FALSE); - DisViewWnd[1] = GetDlgItem(hwnd, IDC_DES_BOX); - return 1; - } - DisViewWnd[1] = NULL; - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), TRUE); - } - return 1; - return 1; - } - return 0; - } - - return FALSE; -} - -// =================================================== ARM9 -LRESULT CALLBACK ViewDisasm_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - 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(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+1); - break; - case SB_LINEUP : - DisView9->curr_ligne = (u32)std::max(0, (s32)DisView9->curr_ligne-1); - break; - case SB_PAGEDOWN : - DisView9->curr_ligne = std::min(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+nbligne); - break; - case SB_PAGEUP : - DisView9->curr_ligne = (u32)std::max(0, DisView9->curr_ligne-nbligne); - break; - } - - SelectObject(dc, old); - SetScrollPos(hwnd, SB_VERT, DisView9->curr_ligne, TRUE); - InvalidateRect(hwnd, NULL, FALSE); - } - return 1; - - case WM_ERASEBKGND: - return 1; - } - return FALSE; -} - -BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //bail out early if the dialog isnt initialized - if(!DisView9 && message != WM_INITDIALOG) - return 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); - DisViewWnd[0] = NULL; - return 1; - } - case WM_CLOSE : - { - if(DisView9->autoup) - { - KillTimer(hwnd, IDT_VIEW_DISASM9); - DisView9->autoup = false; - } + } + 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; + case IDC_AUTOUPDATE_ASM: + { + if (DisViewWnd[1] == NULL) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), FALSE); + DisViewWnd[1] = GetDlgItem(hwnd, IDC_DES_BOX); + return 1; + } + DisViewWnd[1] = NULL; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), TRUE); + } + return 1; + return 1; + } + return 0; + } + + return FALSE; +} + +// =================================================== ARM9 +LRESULT CALLBACK ViewDisasm_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + 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(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+1); + break; + case SB_LINEUP : + DisView9->curr_ligne = (u32)std::max(0, (s32)DisView9->curr_ligne-1); + break; + case SB_PAGEDOWN : + DisView9->curr_ligne = std::min(0x3FFFFF7*(1+DisView9->cpu->CPSR.bits.T), DisView9->curr_ligne+nbligne); + break; + case SB_PAGEUP : + DisView9->curr_ligne = (u32)std::max(0, DisView9->curr_ligne-nbligne); + break; + } + + SelectObject(dc, old); + SetScrollPos(hwnd, SB_VERT, DisView9->curr_ligne, TRUE); + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + + case WM_ERASEBKGND: + return 1; + } + return FALSE; +} + +BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + //bail out early if the dialog isnt initialized + if(!DisView9 && message != WM_INITDIALOG) + return 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); + DisViewWnd[0] = NULL; + return 1; + } + case WM_CLOSE : + { + if(DisView9->autoup) + { + KillTimer(hwnd, IDT_VIEW_DISASM9); + DisView9->autoup = false; + } if (DisView9!=NULL) { delete DisView9; @@ -566,164 +565,164 @@ BOOL CALLBACK ViewDisasm_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARA } DisViewWnd[0] = NULL; //INFO("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_AUTOUPDATE_ASM), TRUE); - 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_AUTOUPDATE_ASM), FALSE); - 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); - } - return 1; - case IDC_GO : - { - u16 i; - char tmp[16]; - int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 16); - u32 adr = 0; - for(i = 0; i='A')&&(tmp[i]<='F')) - { - adr = adr*16 + (tmp[i]-'A'+10); - continue; - } - if((tmp[i]>='0')&&(tmp[i]<='9')) - { - adr = adr*16 + (tmp[i]-'0'); - continue; - } - } - /* address to line correction */ - switch (DisView9->mode) { - case 0: /* auto */ - DisView9->curr_ligne = adr>>1; - if (DisView9->cpu->CPSR.bits.T) { - DisView9->curr_ligne = adr>>1; - } - break ; - case 1: /* thumb */ - DisView9->curr_ligne = adr>>2; - break ; - case 2: /* arm */ - DisView9->curr_ligne = adr>>1; - break ; - } ; - InvalidateRect(hwnd, NULL, FALSE); - } - return 1; - case IDC_REFRESH: - DisView9->autogo=true; - InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); - DisView9->autogo=false; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_AUTO_UPDATE_SECS: - { - u16 t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); + 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_AUTOUPDATE_ASM), TRUE); + 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_AUTOUPDATE_ASM), FALSE); + 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); + } + return 1; + case IDC_GO : + { + u16 i; + char tmp[16]; + int lg = GetDlgItemText(hwnd, IDC_GOTODES, tmp, 16); + u32 adr = 0; + for(i = 0; i='A')&&(tmp[i]<='F')) + { + adr = adr*16 + (tmp[i]-'A'+10); + continue; + } + if((tmp[i]>='0')&&(tmp[i]<='9')) + { + adr = adr*16 + (tmp[i]-'0'); + continue; + } + } + /* address to line correction */ + switch (DisView9->mode) { + case 0: /* auto */ + DisView9->curr_ligne = adr>>1; + if (DisView9->cpu->CPSR.bits.T) { + DisView9->curr_ligne = adr>>1; + } + break ; + case 1: /* thumb */ + DisView9->curr_ligne = adr>>2; + break ; + case 2: /* arm */ + DisView9->curr_ligne = adr>>1; + break ; + } ; + InvalidateRect(hwnd, NULL, FALSE); + } + return 1; + case IDC_REFRESH: + DisView9->autogo=true; + InvalidateRect(GetDlgItem(hwnd, IDC_DES_BOX), NULL, FALSE); + DisView9->autogo=false; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_AUTO_UPDATE_SECS: + { + u16 t = GetDlgItemInt(hwnd, IDC_AUTO_UPDATE_SECS, FALSE, TRUE); if (!DisView9) { SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - 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; - case IDC_AUTOUPDATE_ASM: - { - if (DisViewWnd[0] == NULL) - { - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), FALSE); - DisViewWnd[0] = GetDlgItem(hwnd, IDC_DES_BOX); - return 1; - } - DisViewWnd[0] = NULL; - EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), TRUE); - } - return 1; - return 1; - } - return 0; - } - - return FALSE; -} - -void DisassemblerTools_Refresh(u8 proc) -{ - if (DisViewWnd[proc] == NULL) return; - if (proc == 0) - { - DisView9->autogo=true; - InvalidateRect(DisViewWnd[proc], NULL, FALSE); - DisView9->autogo=false; - } - else - { - DisView7->autogo=true; - InvalidateRect(DisViewWnd[proc], NULL, FALSE); - DisView7->autogo=false; - } + } + 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; + case IDC_AUTOUPDATE_ASM: + { + if (DisViewWnd[0] == NULL) + { + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), FALSE); + DisViewWnd[0] = GetDlgItem(hwnd, IDC_DES_BOX); + return 1; + } + DisViewWnd[0] = NULL; + EnableWindow(GetDlgItem(hwnd, IDC_AUTO_UPDATE), TRUE); + } + return 1; + return 1; + } + return 0; + } + + return FALSE; +} + +void DisassemblerTools_Refresh(u8 proc) +{ + if (DisViewWnd[proc] == NULL) return; + if (proc == 0) + { + DisView9->autogo=true; + InvalidateRect(DisViewWnd[proc], NULL, FALSE); + DisView9->autogo=false; + } + else + { + DisView7->autogo=true; + InvalidateRect(DisViewWnd[proc], NULL, FALSE); + DisView7->autogo=false; + } } \ No newline at end of file diff --git a/desmume/src/windows/lightView.cpp b/desmume/src/windows/lightView.cpp index 594ee7110..011bdcb14 100644 --- a/desmume/src/windows/lightView.cpp +++ b/desmume/src/windows/lightView.cpp @@ -1,185 +1,184 @@ -/* Copyright (C) 2007 Acid Burn - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "lightView.h" -#include "commctrl.h" -#include "colorctrl.h" -#include "gfx3d.h" -#include "resource.h" -#include "res_timer_ids.h" -#include "debug.h" - -// Convert B5G5R5 color format into R8G8B8 color format -unsigned int ColorConv_B5R5R5ToR8G8B8(const unsigned int color) -{ - return (((color&31)<<16)<<3) | // red - ((((color>>5)&31)<<8)<<3) | // green - (((color>>10)&31)<<3); // blue -} - -typedef struct -{ - u32 autoup_secs; - bool autoup; -} lightsview_struct; - -lightsview_struct *LightsView = NULL; - -void LightView_OnPaintLight(HWND hwnd, int index) -{ - const int idcDir[4] = - { - IDC_LIGHT_VIEWER_LIGHT0VECTOR_EDIT, IDC_LIGHT_VIEWER_LIGHT1VECTOR_EDIT, - IDC_LIGHT_VIEWER_LIGHT2VECTOR_EDIT, IDC_LIGHT_VIEWER_LIGHT3VECTOR_EDIT - }; - - const int idcColorEdit[4] = - { - IDC_LIGHT_VIEWER_LIGHT0COLOR_EDIT, IDC_LIGHT_VIEWER_LIGHT1COLOR_EDIT, - IDC_LIGHT_VIEWER_LIGHT2COLOR_EDIT, IDC_LIGHT_VIEWER_LIGHT3COLOR_EDIT - }; - - const int idcColorCtrl[4] = - { - IDC_LIGHT_VIEWER_LIGHT0COLOR_COLORCTRL, IDC_LIGHT_VIEWER_LIGHT1COLOR_COLORCTRL, - IDC_LIGHT_VIEWER_LIGHT2COLOR_COLORCTRL, IDC_LIGHT_VIEWER_LIGHT3COLOR_COLORCTRL - }; - - unsigned int color; - unsigned int direction; - ColorCtrl* colorCtrl; - char buffer[128]; - - // Get necessary information from gfx3d module - gfx3d_glGetLightColor(index, &color); - gfx3d_glGetLightDirection(index, &direction); - - // Print Light Direction - sprintf(buffer, "%.8x", direction); - SetWindowText(GetDlgItem(hwnd, idcDir[index]), buffer); - - // Print Light Color - sprintf(buffer, "%.4x", color); - SetWindowText(GetDlgItem(hwnd, idcColorEdit[index]), buffer); - - // Set Light Color in ColorDisplay component - ColorCtrl_SetColor(GetDlgItem(hwnd, idcColorCtrl[index]), ColorConv_B5R5R5ToR8G8B8(color)); -} - -////////////////////////////////////////////////////////////////////////////// - -BOOL LightView_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; - - hdc = BeginPaint(hwnd, &ps); - - LightView_OnPaintLight(hwnd, 0); - LightView_OnPaintLight(hwnd, 1); - LightView_OnPaintLight(hwnd, 2); - LightView_OnPaintLight(hwnd, 3); - - EndPaint(hwnd, &ps); - - return TRUE; -} - -BOOL CALLBACK ViewLightsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - 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; - - case WM_CLOSE: - if(LightsView->autoup) - { - KillTimer(hwnd, IDT_VIEW_LIGHTS); - LightsView->autoup = false; +/* Copyright (C) 2007 Acid Burn + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "lightView.h" +#include "commctrl.h" +#include "colorctrl.h" +#include "gfx3d.h" +#include "resource.h" +#include "debug.h" + +// Convert B5G5R5 color format into R8G8B8 color format +unsigned int ColorConv_B5R5R5ToR8G8B8(const unsigned int color) +{ + return (((color&31)<<16)<<3) | // red + ((((color>>5)&31)<<8)<<3) | // green + (((color>>10)&31)<<3); // blue +} + +typedef struct +{ + u32 autoup_secs; + bool autoup; +} lightsview_struct; + +lightsview_struct *LightsView = NULL; + +void LightView_OnPaintLight(HWND hwnd, int index) +{ + const int idcDir[4] = + { + IDC_LIGHT_VIEWER_LIGHT0VECTOR_EDIT, IDC_LIGHT_VIEWER_LIGHT1VECTOR_EDIT, + IDC_LIGHT_VIEWER_LIGHT2VECTOR_EDIT, IDC_LIGHT_VIEWER_LIGHT3VECTOR_EDIT + }; + + const int idcColorEdit[4] = + { + IDC_LIGHT_VIEWER_LIGHT0COLOR_EDIT, IDC_LIGHT_VIEWER_LIGHT1COLOR_EDIT, + IDC_LIGHT_VIEWER_LIGHT2COLOR_EDIT, IDC_LIGHT_VIEWER_LIGHT3COLOR_EDIT + }; + + const int idcColorCtrl[4] = + { + IDC_LIGHT_VIEWER_LIGHT0COLOR_COLORCTRL, IDC_LIGHT_VIEWER_LIGHT1COLOR_COLORCTRL, + IDC_LIGHT_VIEWER_LIGHT2COLOR_COLORCTRL, IDC_LIGHT_VIEWER_LIGHT3COLOR_COLORCTRL + }; + + unsigned int color; + unsigned int direction; + ColorCtrl* colorCtrl; + char buffer[128]; + + // Get necessary information from gfx3d module + gfx3d_glGetLightColor(index, &color); + gfx3d_glGetLightDirection(index, &direction); + + // Print Light Direction + sprintf(buffer, "%.8x", direction); + SetWindowText(GetDlgItem(hwnd, idcDir[index]), buffer); + + // Print Light Color + sprintf(buffer, "%.4x", color); + SetWindowText(GetDlgItem(hwnd, idcColorEdit[index]), buffer); + + // Set Light Color in ColorDisplay component + ColorCtrl_SetColor(GetDlgItem(hwnd, idcColorCtrl[index]), ColorConv_B5R5R5ToR8G8B8(color)); +} + +////////////////////////////////////////////////////////////////////////////// + +BOOL LightView_OnPaint(HWND hwnd, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; + + hdc = BeginPaint(hwnd, &ps); + + LightView_OnPaintLight(hwnd, 0); + LightView_OnPaintLight(hwnd, 1); + LightView_OnPaintLight(hwnd, 2); + LightView_OnPaintLight(hwnd, 3); + + EndPaint(hwnd, &ps); + + return TRUE; +} + +BOOL CALLBACK ViewLightsProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + 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; + + case WM_CLOSE: + if(LightsView->autoup) + { + KillTimer(hwnd, IDT_VIEW_LIGHTS); + LightsView->autoup = false; } if (LightsView!=NULL) { delete LightsView; LightsView = NULL; - } + } //INFO("Close lights viewer dialog\n"); - PostQuitMessage(0); - break; - - case WM_PAINT: - 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: - 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); + PostQuitMessage(0); + break; + + case WM_PAINT: + 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: + 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 (!LightsView) { SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - 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 FALSE; -} + } + 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 FALSE; +} diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 1752a803f..386fafe9a 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -44,7 +44,6 @@ #include "../addons.h" #endif #include "resource.h" -#include "res_timer_ids.h" #include "memView.h" #include "disView.h" #include "ginfo.h" diff --git a/desmume/src/windows/mapView.cpp b/desmume/src/windows/mapView.cpp index b9bb09d82..0fff52893 100644 --- a/desmume/src/windows/mapView.cpp +++ b/desmume/src/windows/mapView.cpp @@ -21,7 +21,6 @@ #include "mapView.h" #include "resource.h" -#include "res_timer_ids.h" #include #include "../MMU.h" diff --git a/desmume/src/windows/matrixView.cpp b/desmume/src/windows/matrixView.cpp index d1be75d28..42bdca24a 100644 --- a/desmume/src/windows/matrixView.cpp +++ b/desmume/src/windows/matrixView.cpp @@ -21,7 +21,6 @@ #include #include "debug.h" #include "resource.h" -#include "res_timer_ids.h" #include "gfx3d.h" typedef struct diff --git a/desmume/src/windows/memView.cpp b/desmume/src/windows/memView.cpp index 826dedad3..215c0b18a 100644 --- a/desmume/src/windows/memView.cpp +++ b/desmume/src/windows/memView.cpp @@ -25,13 +25,12 @@ #include "../MMU.h" #include "debug.h" #include "resource.h" -#include "res_timer_ids.h" typedef struct { - u32 autoup_secs; - bool autoup; - + u32 autoup_secs; + bool autoup; + s8 cpu; u32 curr_ligne; u8 representation; @@ -206,8 +205,8 @@ LRESULT CALLBACK ViewMem_ARM7BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM BOOL CALLBACK ViewMem_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - //bail out early if the dialog isnt initialized - if(!MemView7 && message != WM_INITDIALOG) + //bail out early if the dialog isnt initialized + if(!MemView7 && message != WM_INITDIALOG) return false; switch (message) @@ -219,19 +218,19 @@ BOOL CALLBACK ViewMem_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l 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), + 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->autoup) + { + KillTimer(hwnd, IDT_VIEW_MEM7); + MemView7->autoup = false; } if (MemView7!=NULL) @@ -243,8 +242,8 @@ BOOL CALLBACK ViewMem_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l PostQuitMessage(0); return 0; } - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); return 1; case WM_COMMAND : @@ -265,38 +264,38 @@ BOOL CALLBACK ViewMem_ARM7Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l InvalidateRect(GetDlgItem(hwnd, IDC_MEM_BOX), NULL, FALSE); UpdateWindow(GetDlgItem(hwnd, IDC_MEM_BOX)); return 1; - case IDC_AUTO_UPDATE : - if(MemView7->autoup) - { - 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; - } - 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); + case IDC_AUTO_UPDATE : + if(MemView7->autoup) + { + 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; + } + 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 (!MemView7) { SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - 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); + } + 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 : { @@ -394,8 +393,8 @@ LRESULT CALLBACK ViewMem_ARM9BoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM BOOL CALLBACK ViewMem_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - //bail out early if the dialog isnt initialized - if(!MemView9 && message != WM_INITDIALOG) + //bail out early if the dialog isnt initialized + if(!MemView9 && message != WM_INITDIALOG) return false; switch (message) @@ -407,19 +406,19 @@ BOOL CALLBACK ViewMem_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l 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), + 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 1; } case WM_CLOSE: { - if(MemView9->autoup) - { - KillTimer(hwnd, IDT_VIEW_MEM9); - MemView9->autoup = false; + if(MemView9->autoup) + { + KillTimer(hwnd, IDT_VIEW_MEM9); + MemView9->autoup = false; } if (MemView9!=NULL) @@ -431,8 +430,8 @@ BOOL CALLBACK ViewMem_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l PostQuitMessage(0); return 0; } - case WM_TIMER: - SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); + case WM_TIMER: + SendMessage(hwnd, WM_COMMAND, IDC_REFRESH, 0); return 1; case WM_COMMAND : @@ -453,38 +452,38 @@ BOOL CALLBACK ViewMem_ARM9Proc (HWND hwnd, UINT message, WPARAM wParam, LPARAM l 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); + 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 (!MemView9) { SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - 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); + } + 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 : { diff --git a/desmume/src/windows/oamView.cpp b/desmume/src/windows/oamView.cpp index 54140d367..466afb8d7 100644 --- a/desmume/src/windows/oamView.cpp +++ b/desmume/src/windows/oamView.cpp @@ -23,7 +23,6 @@ #include #include "debug.h" #include "resource.h" -#include "res_timer_ids.h" #include "../MMU.h" #include "../GPU.h" #include "../NDSSystem.h" diff --git a/desmume/src/windows/palView.cpp b/desmume/src/windows/palView.cpp index 78d2acf21..12d91d9ae 100644 --- a/desmume/src/windows/palView.cpp +++ b/desmume/src/windows/palView.cpp @@ -1,140 +1,139 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "palView.h" -#include -#include "debug.h" -#include "resource.h" -#include "res_timer_ids.h" -#include "../MMU.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) -{ - HDC hdc; - PAINTSTRUCT ps; - RECT rect; - HBRUSH brush; - u16 c; - char tmp[80]; - - rect.left = 3; - rect.top = 55; - rect.right = 13; - rect.bottom = 65; - hdc = BeginPaint(hwnd, &ps); - - if(adr) - { - u32 y; - - for(y = 0; y < 16; ++y) - { - u32 x; - - for(x = 0; x < 16; ++x) - { - c = adr[(y<<4)+x+0x100*num]; - brush = CreateSolidBrush(RGB((c&0x1F)<<3, (c&0x3E0)>>2, (c&0x7C00)>>7)); - FillRect(hdc, &rect, brush); - DeleteObject(brush); - rect.left += 11; - rect.right += 11; - } - rect.top += 11; - rect.bottom += 11; - rect.left = 3; - rect.right = 13; - } - sprintf(tmp, "Pal : %d", num); - SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), tmp); - } - else - TextOut(hdc, 3, 55, "Pas de palette", 14); - EndPaint(hwnd, &ps); - - return 0; -} - -BOOL CALLBACK ViewPalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) -{ - //bail out early if the dialog isnt initialized - if(!PalView && message != WM_INITDIALOG) - return false; - - 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"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen SPR PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen SPR PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 3"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 3"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 3"); - SendMessage(combo, CB_SETCURSEL, 0, 0); - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); - } - return 1; +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "palView.h" +#include +#include "debug.h" +#include "resource.h" +#include "../MMU.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) +{ + HDC hdc; + PAINTSTRUCT ps; + RECT rect; + HBRUSH brush; + u16 c; + char tmp[80]; + + rect.left = 3; + rect.top = 55; + rect.right = 13; + rect.bottom = 65; + hdc = BeginPaint(hwnd, &ps); + + if(adr) + { + u32 y; + + for(y = 0; y < 16; ++y) + { + u32 x; + + for(x = 0; x < 16; ++x) + { + c = adr[(y<<4)+x+0x100*num]; + brush = CreateSolidBrush(RGB((c&0x1F)<<3, (c&0x3E0)>>2, (c&0x7C00)>>7)); + FillRect(hdc, &rect, brush); + DeleteObject(brush); + rect.left += 11; + rect.right += 11; + } + rect.top += 11; + rect.bottom += 11; + rect.left = 3; + rect.right = 13; + } + sprintf(tmp, "Pal : %d", num); + SetWindowText(GetDlgItem(hwnd, IDC_PALNUM), tmp); + } + else + TextOut(hdc, 3, 55, "Pas de palette", 14); + EndPaint(hwnd, &ps); + + return 0; +} + +BOOL CALLBACK ViewPalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + //bail out early if the dialog isnt initialized + if(!PalView && message != WM_INITDIALOG) + return false; + + 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"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen SPR PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen SPR PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 3"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 3"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture pal 3"); + SendMessage(combo, CB_SETCURSEL, 0, 0); + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); + } + return 1; case WM_CLOSE : { - if(PalView->autoup) - { - KillTimer(hwnd, IDT_VIEW_DISASM7); - PalView->autoup = false; + if(PalView->autoup) + { + KillTimer(hwnd, IDT_VIEW_DISASM7); + PalView->autoup = false; } if (PalView!=NULL) @@ -145,152 +144,152 @@ BOOL CALLBACK ViewPalProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam //INFO("Close Palette view dialog\n"); PostQuitMessage(0); return 0; - } - case WM_PAINT: - 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 : - ++(PalView->palnum); - if(PalView->palnum>15) - PalView->palnum = 15; - break; - case SB_LINELEFT : - --(PalView->palnum); - if(PalView->palnum<0) - PalView->palnum = 0; - break; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_FERMER : - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 1; - case IDC_AUTO_UPDATE : - if(PalView->autoup) - { - 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; - } - 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); + } + case WM_PAINT: + 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 : + ++(PalView->palnum); + if(PalView->palnum>15) + PalView->palnum = 15; + break; + case SB_LINELEFT : + --(PalView->palnum); + if(PalView->palnum<0) + PalView->palnum = 0; + break; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + case IDC_AUTO_UPDATE : + if(PalView->autoup) + { + 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; + } + 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 (!PalView) { SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - 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)) - { - case CBN_SELCHANGE : - case CBN_CLOSEUP : - { - u32 sel = SendMessage(GetDlgItem(hwnd, IDC_PAL_SELECT), CB_GETCURSEL, 0, 0); - switch(sel) - { - case 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 : - 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 : - 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 : - PalView->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; - PalView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); - EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); - break; - case 4 : - case 5 : - case 6 : - case 7 : - 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; - case 8 : - case 9 : - case 10 : - case 11 : - 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 : - 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 : - 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; - case 16 : - case 17 : - case 18 : - case 19 : - 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; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - } - } - return 1; - } - return 0; - } - return false; -} + } + 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)) + { + case CBN_SELCHANGE : + case CBN_CLOSEUP : + { + u32 sel = SendMessage(GetDlgItem(hwnd, IDC_PAL_SELECT), CB_GETCURSEL, 0, 0); + switch(sel) + { + case 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 : + 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 : + 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 : + PalView->adr = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; + PalView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_SCROLLER), SW_HIDE); + EnableWindow(GetDlgItem(hwnd, IDC_SCROLLER), FALSE); + break; + case 4 : + case 5 : + case 6 : + case 7 : + 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; + case 8 : + case 9 : + case 10 : + case 11 : + 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 : + 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 : + 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; + case 16 : + case 17 : + case 18 : + case 19 : + 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; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + } + return 1; + } + return 0; + } + return false; +} diff --git a/desmume/src/windows/tileView.cpp b/desmume/src/windows/tileView.cpp index 5a25bf79b..5ac79289f 100644 --- a/desmume/src/windows/tileView.cpp +++ b/desmume/src/windows/tileView.cpp @@ -1,637 +1,636 @@ -/* Copyright (C) 2006 yopyop - yopyop156@ifrance.com - yopyop156.ifrance.com - - This file is part of DeSmuME - - DeSmuME is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DeSmuME is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DeSmuME; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "tileView.h" -#include "commctrl.h" -#include "resource.h" -#include "res_timer_ids.h" -#include "debug.h" -#include "../MMU.h" - -typedef struct -{ - u32 autoup_secs; - bool autoup; - - HWND hwnd; - u8 * mem; - u16 * pal; - s16 palnum; - u16 tilenum; - u8 coul; - u32 x; - u32 y; -} tileview_struct; - -tileview_struct *TileView = NULL; - -LRESULT TileViewBox_Direct(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; -// SIZE fontsize; -// TCHAR text[80]; - BITMAPV4HEADER bmi; - RECT rect; - HDC mem_dc; - HBITMAP mem_bmp; - int lg; - int ht; - - 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 = -256; - - GetClientRect(hwnd, &rect); - lg = rect.right - rect.left; - ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - mem_dc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - SetDIBitsToDevice(mem_dc, 0, 0, 256, 256, 0, 0, 0, 256, win->mem, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT TileViewBox_Pal256(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; -// SIZE fontsize; - TCHAR text[80]; - u16 bitmap[256*256]; - u16 * pal = ((u16 *)win->pal) + win->palnum*256; - BITMAPV4HEADER bmi; - RECT rect; - int lg; - int ht; - HDC mem_dc; - HBITMAP mem_bmp; - - 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 = -256; - - GetClientRect(hwnd, &rect); - lg = rect.right - rect.left; - ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - mem_dc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - if(win->pal) - { - u32 i, num2, num, y, x; - - //for(i = 0; i<256*256; ++i) - // bitmap[i] = pal[win->mem[i]]; - for(num2 = 0; num2<32; ++num2) - for(num = 0; num<32; ++num) - for(y = 0; y<8; ++y) - for(x = 0; x<8; ++x) - 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(hwnd, IDC_PALNUM), text); - } - else - TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT TileViewBox_Pal16(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) -{ - HDC hdc; - PAINTSTRUCT ps; -// SIZE fontsize; - TCHAR text[80]; - u16 bitmap[512*512]; - u16 * pal = ((u16 *)win->pal) + win->palnum*16; - BITMAPV4HEADER bmi; - RECT rect; - int lg; - int ht; - HDC mem_dc; - HBITMAP mem_bmp; - - 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 = 512; - bmi.bV4Height = -256; - - GetClientRect(hwnd, &rect); - lg = rect.right - rect.left; - ht = rect.bottom - rect.top; - - hdc = BeginPaint(hwnd, &ps); - - mem_dc = CreateCompatibleDC(hdc); - mem_bmp = CreateCompatibleBitmap(hdc, 512, 256); - SelectObject(mem_dc, mem_bmp); - - FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); - - if(win->pal) - { - u32 num2, num, y, x; - for(num2 = 0; num2<32; ++num2) - for(num = 0; num<64; ++num) - for(y = 0; y<8; ++y) - for(x = 0; x<4; ++x) - { - bitmap[(x<<1) + (y*512) + (num*8) +(num2*512*8)] = pal[win->mem[x + (y*4) + (num*32) +(num2*2048)]&0xF]; - bitmap[(x<<1)+1 + (y*512) + (num*8) +(num2*512*8)] = pal[win->mem[x + (y*4) + (num*32) +(num2*2048)]>>4]; - } - 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(hwnd, IDC_PALNUM), text); - } - else - TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); - - BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); - - DeleteDC(mem_dc); - DeleteObject(mem_bmp); - - EndPaint(hwnd, &ps); - return 0; -} - -////////////////////////////////////////////////////////////////////////////// - -LRESULT CALLBACK TileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM 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); -} - -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 : - 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) -{ - //bail out early if the dialog isnt initialized - if(!TileView && message != WM_INITDIALOG) - return false; - - 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"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen SPR PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen SPR PAL"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 3"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 3"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 0"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 1"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 2"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 3"); - SendMessage(combo, CB_SETCURSEL, 0, 0); - - combo = GetDlgItem(hwnd, IDC_MEM_SELECT); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6000000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6010000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6020000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6030000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6040000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6050000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6060000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6070000"); - - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-BG - 0x6200000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-BG - 0x6210000"); - - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6400000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6410000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6420000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6430000"); - - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-OBJ- 0x6600000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-OBJ- 0x6610000"); - - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6800000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6810000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6820000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6830000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6840000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6850000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6860000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6870000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6880000"); - SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6890000"); - SendMessage(combo, CB_SETCURSEL, 0, 0); - SendMessage(GetDlgItem(hwnd, IDC_BITMAP), BM_SETCHECK, TRUE, 0); - } - return 1; - case WM_CLOSE : - if(TileView->autoup) - { - KillTimer(hwnd, IDT_VIEW_TILE); - TileView->autoup = false; - } +/* Copyright (C) 2006 yopyop + yopyop156@ifrance.com + yopyop156.ifrance.com + + This file is part of DeSmuME + + DeSmuME is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DeSmuME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DeSmuME; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "tileView.h" +#include "commctrl.h" +#include "resource.h" +#include "debug.h" +#include "../MMU.h" + +typedef struct +{ + u32 autoup_secs; + bool autoup; + + HWND hwnd; + u8 * mem; + u16 * pal; + s16 palnum; + u16 tilenum; + u8 coul; + u32 x; + u32 y; +} tileview_struct; + +tileview_struct *TileView = NULL; + +LRESULT TileViewBox_Direct(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; +// SIZE fontsize; +// TCHAR text[80]; + BITMAPV4HEADER bmi; + RECT rect; + HDC mem_dc; + HBITMAP mem_bmp; + int lg; + int ht; + + 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 = -256; + + GetClientRect(hwnd, &rect); + lg = rect.right - rect.left; + ht = rect.bottom - rect.top; + + hdc = BeginPaint(hwnd, &ps); + + mem_dc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + SetDIBitsToDevice(mem_dc, 0, 0, 256, 256, 0, 0, 0, 256, win->mem, (BITMAPINFO*)&bmi, DIB_RGB_COLORS); + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT TileViewBox_Pal256(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; +// SIZE fontsize; + TCHAR text[80]; + u16 bitmap[256*256]; + u16 * pal = ((u16 *)win->pal) + win->palnum*256; + BITMAPV4HEADER bmi; + RECT rect; + int lg; + int ht; + HDC mem_dc; + HBITMAP mem_bmp; + + 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 = -256; + + GetClientRect(hwnd, &rect); + lg = rect.right - rect.left; + ht = rect.bottom - rect.top; + + hdc = BeginPaint(hwnd, &ps); + + mem_dc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, lg, ht); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + if(win->pal) + { + u32 i, num2, num, y, x; + + //for(i = 0; i<256*256; ++i) + // bitmap[i] = pal[win->mem[i]]; + for(num2 = 0; num2<32; ++num2) + for(num = 0; num<32; ++num) + for(y = 0; y<8; ++y) + for(x = 0; x<8; ++x) + 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(hwnd, IDC_PALNUM), text); + } + else + TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT TileViewBox_Pal16(HWND hwnd, tileview_struct * win, WPARAM wParam, LPARAM lParam) +{ + HDC hdc; + PAINTSTRUCT ps; +// SIZE fontsize; + TCHAR text[80]; + u16 bitmap[512*512]; + u16 * pal = ((u16 *)win->pal) + win->palnum*16; + BITMAPV4HEADER bmi; + RECT rect; + int lg; + int ht; + HDC mem_dc; + HBITMAP mem_bmp; + + 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 = 512; + bmi.bV4Height = -256; + + GetClientRect(hwnd, &rect); + lg = rect.right - rect.left; + ht = rect.bottom - rect.top; + + hdc = BeginPaint(hwnd, &ps); + + mem_dc = CreateCompatibleDC(hdc); + mem_bmp = CreateCompatibleBitmap(hdc, 512, 256); + SelectObject(mem_dc, mem_bmp); + + FillRect(mem_dc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH)); + + if(win->pal) + { + u32 num2, num, y, x; + for(num2 = 0; num2<32; ++num2) + for(num = 0; num<64; ++num) + for(y = 0; y<8; ++y) + for(x = 0; x<4; ++x) + { + bitmap[(x<<1) + (y*512) + (num*8) +(num2*512*8)] = pal[win->mem[x + (y*4) + (num*32) +(num2*2048)]&0xF]; + bitmap[(x<<1)+1 + (y*512) + (num*8) +(num2*512*8)] = pal[win->mem[x + (y*4) + (num*32) +(num2*2048)]>>4]; + } + 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(hwnd, IDC_PALNUM), text); + } + else + TextOut(mem_dc, 3, 3, "Il n'y a pas de palette", 23); + + BitBlt(hdc, 0, 0, lg, ht, mem_dc, 0, 0, SRCCOPY); + + DeleteDC(mem_dc); + DeleteObject(mem_bmp); + + EndPaint(hwnd, &ps); + return 0; +} + +////////////////////////////////////////////////////////////////////////////// + +LRESULT CALLBACK TileViewBoxProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM 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); +} + +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 : + 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) +{ + //bail out early if the dialog isnt initialized + if(!TileView && message != WM_INITDIALOG) + return false; + + 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"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen SPR PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen SPR PAL"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main screen ExtPAL 3"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub screen ExtPAL 3"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Main spr ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Sub spr ExtPAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 0"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 1"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 2"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"Texture PAL 3"); + SendMessage(combo, CB_SETCURSEL, 0, 0); + + combo = GetDlgItem(hwnd, IDC_MEM_SELECT); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6000000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6010000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6020000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6030000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6040000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6050000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6060000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-BG - 0x6070000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-BG - 0x6200000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-BG - 0x6210000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6400000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6410000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6420000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"A-OBJ- 0x6430000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-OBJ- 0x6600000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"B-OBJ- 0x6610000"); + + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6800000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6810000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6820000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6830000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6840000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6850000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6860000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6870000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6880000"); + SendMessage(combo, CB_ADDSTRING, 0,(LPARAM)"LCD - 0x6890000"); + SendMessage(combo, CB_SETCURSEL, 0, 0); + SendMessage(GetDlgItem(hwnd, IDC_BITMAP), BM_SETCHECK, TRUE, 0); + } + return 1; + case WM_CLOSE : + if(TileView->autoup) + { + KillTimer(hwnd, IDT_VIEW_TILE); + TileView->autoup = false; + } if (TileView!=NULL) { delete TileView; TileView = NULL; } //INFO("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 : - ++(TileView->palnum); - if(TileView->palnum>15) - TileView->palnum = 15; - break; - case SB_LINELEFT : - --(TileView->palnum); - if(TileView->palnum<0) - TileView->palnum = 0; - break; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case WM_COMMAND : - switch (LOWORD (wParam)) - { - case IDC_FERMER : - SendMessage(hwnd, WM_CLOSE, 0, 0); - return 1; - case IDC_AUTO_UPDATE : - if(TileView->autoup) - { - 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; - } - 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); + 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 : + ++(TileView->palnum); + if(TileView->palnum>15) + TileView->palnum = 15; + break; + case SB_LINELEFT : + --(TileView->palnum); + if(TileView->palnum<0) + TileView->palnum = 0; + break; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case WM_COMMAND : + switch (LOWORD (wParam)) + { + case IDC_FERMER : + SendMessage(hwnd, WM_CLOSE, 0, 0); + return 1; + case IDC_AUTO_UPDATE : + if(TileView->autoup) + { + 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; + } + 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 (!TileView) { SendMessage(hwnd, WM_INITDIALOG, 0, 0); - } - 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 : - TileView->coul = 0; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_256COUL : - TileView->coul = 1; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_16COUL : - TileView->coul = 2; - InvalidateRect(hwnd, NULL, FALSE); - return 1; - case IDC_MEM_SELECT : - switch(HIWORD(wParam)) - { - case CBN_SELCHANGE : - case CBN_CLOSEUP : - { - u32 sel = SendMessage(GetDlgItem(hwnd, IDC_MEM_SELECT), CB_GETCURSEL, 0, 0); - switch(sel) - { - case 0 : - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : - TileView->mem = ARM9Mem.ARM9_ABG + 0x10000*sel; - break; - case 8 : - case 9 : - TileView->mem = ARM9Mem.ARM9_BBG + 0x10000*(sel-8); - break; - case 10 : - case 11 : - case 12 : - case 13 : - TileView->mem = ARM9Mem.ARM9_AOBJ + 0x10000*(sel-10); - break; - case 14 : - case 15 : - TileView->mem = ARM9Mem.ARM9_BOBJ + 0x10000*(sel-14); - break; - case 16 : - case 17 : - case 18 : - case 19 : - case 20 : - case 21 : - case 22 : - case 23 : - case 24 : - case 25 : - TileView->mem = ARM9Mem.ARM9_LCD + 0x10000*(sel-16); - break; - default : - return 1; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - } - } - return 1; - case IDC_PAL_SELECT : - switch(HIWORD(wParam)) - { - case CBN_SELCHANGE : - case CBN_CLOSEUP : - { - u32 sel = SendMessage(GetDlgItem(hwnd, IDC_PAL_SELECT), CB_GETCURSEL, 0, 0); - switch(sel) - { - case 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 : - 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 : - 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 : - TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; - TileView->palnum = 0; - ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); - EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); - break; - case 4 : - case 5 : - case 6 : - case 7 : - 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(TileView->coul == 2) - { - SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); - SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); - TileView->coul = 1; - } - break; - case 8 : - case 9 : - case 10 : - case 11 : - 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(TileView->coul == 2) - { - SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); - SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); - TileView->coul = 1; - } - break; - case 12 : - case 13 : - 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); - TileView->coul = 1; - } - break; - case 14 : - case 15 : - 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); - TileView->coul = 1; - } - break; - case 16 : - case 17 : - case 18 : - case 19 : - 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; - } - InvalidateRect(hwnd, NULL, FALSE); - return 1; - } - } - } - return 0; - } - return FALSE; -} + } + 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 : + TileView->coul = 0; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_256COUL : + TileView->coul = 1; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_16COUL : + TileView->coul = 2; + InvalidateRect(hwnd, NULL, FALSE); + return 1; + case IDC_MEM_SELECT : + switch(HIWORD(wParam)) + { + case CBN_SELCHANGE : + case CBN_CLOSEUP : + { + u32 sel = SendMessage(GetDlgItem(hwnd, IDC_MEM_SELECT), CB_GETCURSEL, 0, 0); + switch(sel) + { + case 0 : + case 1 : + case 2 : + case 3 : + case 4 : + case 5 : + case 6 : + case 7 : + TileView->mem = ARM9Mem.ARM9_ABG + 0x10000*sel; + break; + case 8 : + case 9 : + TileView->mem = ARM9Mem.ARM9_BBG + 0x10000*(sel-8); + break; + case 10 : + case 11 : + case 12 : + case 13 : + TileView->mem = ARM9Mem.ARM9_AOBJ + 0x10000*(sel-10); + break; + case 14 : + case 15 : + TileView->mem = ARM9Mem.ARM9_BOBJ + 0x10000*(sel-14); + break; + case 16 : + case 17 : + case 18 : + case 19 : + case 20 : + case 21 : + case 22 : + case 23 : + case 24 : + case 25 : + TileView->mem = ARM9Mem.ARM9_LCD + 0x10000*(sel-16); + break; + default : + return 1; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + } + return 1; + case IDC_PAL_SELECT : + switch(HIWORD(wParam)) + { + case CBN_SELCHANGE : + case CBN_CLOSEUP : + { + u32 sel = SendMessage(GetDlgItem(hwnd, IDC_PAL_SELECT), CB_GETCURSEL, 0, 0); + switch(sel) + { + case 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 : + 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 : + 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 : + TileView->pal = ((u16 *)ARM9Mem.ARM9_VMEM) + 0x300; + TileView->palnum = 0; + ShowWindow(GetDlgItem(hwnd, IDC_16COUL), SW_SHOW); + EnableWindow(GetDlgItem(hwnd, IDC_16COUL), TRUE); + break; + case 4 : + case 5 : + case 6 : + case 7 : + 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(TileView->coul == 2) + { + SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); + SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); + TileView->coul = 1; + } + break; + case 8 : + case 9 : + case 10 : + case 11 : + 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(TileView->coul == 2) + { + SendMessage(GetDlgItem(hwnd, IDC_256COUL), BM_SETCHECK, TRUE, 0); + SendMessage(GetDlgItem(hwnd, IDC_16COUL), BM_SETCHECK, FALSE, 0); + TileView->coul = 1; + } + break; + case 12 : + case 13 : + 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); + TileView->coul = 1; + } + break; + case 14 : + case 15 : + 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); + TileView->coul = 1; + } + break; + case 16 : + case 17 : + case 18 : + case 19 : + 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; + } + InvalidateRect(hwnd, NULL, FALSE); + return 1; + } + } + } + return 0; + } + return FALSE; +}