diff --git a/project/vc2008_mfc/VBA2008.vcproj b/project/vc2008_mfc/VBA2008.vcproj index 091fe658..e099539c 100644 --- a/project/vc2008_mfc/VBA2008.vcproj +++ b/project/vc2008_mfc/VBA2008.vcproj @@ -1451,7 +1451,7 @@ diff --git a/src/Globals.cpp b/src/Globals.cpp index 1812cfaf..a930dc7a 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -52,6 +52,11 @@ bool cheatsEnabled = true; bool mirroringEnable = false; bool skipSaveGameBattery = false; +// this is an optional hack to change the backdrop/background color: +// -1: disabled +// 0x0000 to 0x7FFF: set custom 15 bit color +int customBackdropColor = -1; + u8 *bios = NULL; u8 *rom = NULL; u8 *internalRAM = NULL; diff --git a/src/Globals.h b/src/Globals.h index 209145e6..8f55fa8e 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -61,6 +61,7 @@ extern int cpuSaveType; extern bool cheatsEnabled; extern bool mirroringEnable; extern bool skipSaveGameBattery; +extern int customBackdropColor; extern u8 *bios; extern u8 *rom; diff --git a/src/Mode0.cpp b/src/Mode0.cpp index adf7d2bc..a7a0a34a 100644 --- a/src/Mode0.cpp +++ b/src/Mode0.cpp @@ -49,7 +49,12 @@ void mode0RenderLine() gfxDrawSprites(lineOBJ); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = backdrop; @@ -156,7 +161,12 @@ void mode0RenderLineNoWindow() gfxDrawSprites(lineOBJ); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } int effect = (BLDMOD >> 6) & 3; @@ -349,7 +359,12 @@ void mode0RenderLineAll() gfxDrawSprites(lineOBJ); gfxDrawOBJWin(lineOBJWin); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } u8 inWin0Mask = WININ & 0xFF; u8 inWin1Mask = WININ >> 8; diff --git a/src/Mode1.cpp b/src/Mode1.cpp index 954fabb9..c294e078 100644 --- a/src/Mode1.cpp +++ b/src/Mode1.cpp @@ -51,7 +51,12 @@ void mode1RenderLine() gfxDrawSprites(lineOBJ); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = backdrop; @@ -153,7 +158,12 @@ void mode1RenderLineNoWindow() gfxDrawSprites(lineOBJ); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = backdrop; @@ -330,7 +340,12 @@ void mode1RenderLineAll() gfxDrawSprites(lineOBJ); gfxDrawOBJWin(lineOBJWin); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } u8 inWin0Mask = WININ & 0xFF; u8 inWin1Mask = WININ >> 8; diff --git a/src/Mode2.cpp b/src/Mode2.cpp index e8b67857..d21285af 100644 --- a/src/Mode2.cpp +++ b/src/Mode2.cpp @@ -54,7 +54,12 @@ void mode2RenderLine() gfxDrawSprites(lineOBJ); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = backdrop; @@ -150,7 +155,12 @@ void mode2RenderLineNoWindow() gfxDrawSprites(lineOBJ); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = backdrop; @@ -316,7 +326,12 @@ void mode2RenderLineAll() gfxDrawSprites(lineOBJ); gfxDrawOBJWin(lineOBJWin); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } u8 inWin0Mask = WININ & 0xFF; u8 inWin1Mask = WININ >> 8; diff --git a/src/Mode3.cpp b/src/Mode3.cpp index 8047aee0..643bb076 100644 --- a/src/Mode3.cpp +++ b/src/Mode3.cpp @@ -47,7 +47,12 @@ void mode3RenderLine() gfxDrawSprites(lineOBJ); - u32 background = (READ16LE(&palette[0]) | 0x30000000); + u32 background; + if(customBackdropColor == -1) { + background = (READ16LE(&palette[0]) | 0x30000000); + } else { + background = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = background; @@ -124,7 +129,12 @@ void mode3RenderLineNoWindow() gfxDrawSprites(lineOBJ); - u32 background = (READ16LE(&palette[0]) | 0x30000000); + u32 background; + if(customBackdropColor == -1) { + background = (READ16LE(&palette[0]) | 0x30000000); + } else { + background = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = background; @@ -269,7 +279,12 @@ void mode3RenderLineAll() u8 inWin1Mask = WININ >> 8; u8 outMask = WINOUT & 0xFF; - u32 background = (READ16LE(&palette[0]) | 0x30000000); + u32 background; + if(customBackdropColor == -1) { + background = (READ16LE(&palette[0]) | 0x30000000); + } else { + background = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = background; diff --git a/src/Mode4.cpp b/src/Mode4.cpp index d4766bf8..1f1d21ee 100644 --- a/src/Mode4.cpp +++ b/src/Mode4.cpp @@ -46,7 +46,12 @@ void mode4RenderLine() gfxDrawSprites(lineOBJ); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = backdrop; @@ -122,7 +127,12 @@ void mode4RenderLineNoWindow() gfxDrawSprites(lineOBJ); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = backdrop; @@ -262,7 +272,12 @@ void mode4RenderLineAll() gfxDrawSprites(lineOBJ); gfxDrawOBJWin(lineOBJWin); - u32 backdrop = (READ16LE(&palette[0]) | 0x30000000); + u32 backdrop; + if(customBackdropColor == -1) { + backdrop = (READ16LE(&palette[0]) | 0x30000000); + } else { + backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000); + } u8 inWin0Mask = WININ & 0xFF; u8 inWin1Mask = WININ >> 8; diff --git a/src/Mode5.cpp b/src/Mode5.cpp index 65ae69ea..41c8d34f 100644 --- a/src/Mode5.cpp +++ b/src/Mode5.cpp @@ -47,7 +47,12 @@ void mode5RenderLine() gfxDrawSprites(lineOBJ); - u32 background = (READ16LE(&palette[0]) | 0x30000000); + u32 background; + if(customBackdropColor == -1) { + background = (READ16LE(&palette[0]) | 0x30000000); + } else { + background = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = background; @@ -124,7 +129,12 @@ void mode5RenderLineNoWindow() gfxDrawSprites(lineOBJ); - u32 background = ( READ16LE(&palette[0]) | 0x30000000); + u32 background; + if(customBackdropColor == -1) { + background = (READ16LE(&palette[0]) | 0x30000000); + } else { + background = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = background; @@ -269,7 +279,12 @@ void mode5RenderLineAll() u8 inWin1Mask = WININ >> 8; u8 outMask = WINOUT & 0xFF; - u32 background = (READ16LE(&palette[0]) | 0x30000000); + u32 background; + if(customBackdropColor == -1) { + background = (READ16LE(&palette[0]) | 0x30000000); + } else { + background = ((customBackdropColor & 0x7FFF) | 0x30000000); + } for(int x = 0; x < 240; x++) { u32 color = background; diff --git a/src/win32/PaletteView.cpp b/src/win32/PaletteView.cpp index 69911151..114a8041 100644 --- a/src/win32/PaletteView.cpp +++ b/src/win32/PaletteView.cpp @@ -80,7 +80,8 @@ BEGIN_MESSAGE_MAP(PaletteView, CDialog) ON_BN_CLICKED(IDC_CLOSE, OnClose) //}}AFX_MSG_MAP ON_MESSAGE(WM_PALINFO, OnPalInfo) - END_MESSAGE_MAP() + ON_BN_CLICKED(IDC_CHANGE_BACKDROP, &PaletteView::OnBnClickedChangeBackdrop) +END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // PaletteView message handlers @@ -190,6 +191,7 @@ void PaletteView::OnAutoUpdate() } else { theApp.winRemoveUpdateListener(this); } + (CButton*)GetDlgItem(IDC_REFRESH2)->EnableWindow(!autoUpdate); } void PaletteView::OnClose() @@ -243,3 +245,21 @@ void PaletteView::PostNcDestroy() { delete this; } + +void PaletteView::OnBnClickedChangeBackdrop() +{ + CColorDialog cdlg; + COLORREF color; + switch( cdlg.DoModal() ) { + case IDOK: + color = cdlg.GetColor(); + customBackdropColor = + ( ( GetBValue( color ) >> 3 ) << 10 ) | + ( ( GetGValue( color ) >> 3 ) << 5 ) | + ( GetRValue( color ) >> 3 ); + break; + case IDCANCEL: + customBackdropColor = -1; // disable hack + break; + } +} diff --git a/src/win32/PaletteView.h b/src/win32/PaletteView.h index aee3a4cb..e61ffe5f 100644 --- a/src/win32/PaletteView.h +++ b/src/win32/PaletteView.h @@ -82,7 +82,9 @@ class PaletteView : public ResizeDlg, IUpdateListener afx_msg void OnClose(); //}}AFX_MSG DECLARE_MESSAGE_MAP() - }; +public: + afx_msg void OnBnClickedChangeBackdrop(); +}; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/src/win32/VBA.rc b/src/win32/VBA.rc index 9d069531..9e2ec185 100644 --- a/src/win32/VBA.rc +++ b/src/win32/VBA.rc @@ -577,15 +577,15 @@ BEGIN LTEXT "",IDC_PALETTE_NUM,130,135,53,8,SS_NOPREFIX END -IDD_PALETTE_VIEW DIALOG 0, 0, 316, 266 +IDD_PALETTE_VIEW DIALOGEX 0, 0, 316, 266 STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME CAPTION "Palette View" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - PUSHBUTTON "Save BG...",IDC_SAVE_BG,30,245,50,14 - PUSHBUTTON "Save OBJ...",IDC_SAVE_OBJ,98,245,50,14 - PUSHBUTTON "&Refresh",IDC_REFRESH2,166,245,50,14 - PUSHBUTTON "&Close",IDC_CLOSE,234,245,50,14 + PUSHBUTTON "Save BG...",IDC_SAVE_BG,102,246,50,14 + PUSHBUTTON "Save OBJ...",IDC_SAVE_OBJ,162,246,50,14 + PUSHBUTTON "&Refresh",IDC_REFRESH2,6,246,50,14 + PUSHBUTTON "&Close",IDC_CLOSE,260,246,50,14 LTEXT "",IDC_ADDRESS,53,168,50,8,SS_NOPREFIX LTEXT "",IDC_R,53,180,50,8,SS_NOPREFIX LTEXT "",IDC_G,53,192,50,8,SS_NOPREFIX @@ -604,6 +604,7 @@ BEGIN LTEXT "Value:",IDC_STATIC,7,216,38,8 LTEXT "Click on a color for more information",IDC_STATIC,7,7,302,8 CONTROL "Automatic update",IDC_AUTO_UPDATE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,229,71,10 + PUSHBUTTON "Change backdrop color...",IDC_CHANGE_BACKDROP,102,228,108,14 END IDD_MEM_VIEWER DIALOG 0, 0, 380, 178 diff --git a/src/win32/resource.h b/src/win32/resource.h index b690005b..33675830 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -392,6 +392,8 @@ #define IDC_MAP_VIEW_ZOOM 1138 #define IDS_MOVIE_PLAY 1138 #define IDC_VIEWER 1140 +#define IDC_SAVE_BG2 1140 +#define IDC_CHANGE_BACKDROP 1140 #define IDC_ADDRESSES 1141 #define IDC_GO 1143 #define IDC_8_BIT 1144