From 4163059b21a7291f261efbe6a911cab62f3abdd8 Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Wed, 22 Sep 2010 22:49:49 +1000 Subject: [PATCH] Update to v068r20 release. byuu says: Changelog: - fixed window casting crash in phoenix - added perfect forwarding to nall::string variadic templates to fix file load dialog crash in phoenix - disabled copy constructors in utf8_t to prevent this problem from occurring again in the future - separated canvas window proc by creating a separate class for it (ironically it was a desktop window causing the first crash) - use processorArchitecture="*" to make compilation easier - fixed status bar font assignment in phoenix/Windows - added InitCommonControls + CoInitialize for XAudio2 on XP - had to use DirectSound for audio; XAudio2 is crashing on exit which breaks the profiling (only a problem because you can't change the drivers without recompiling, there's really no reason to profile XAudio2 anyway) --- bsnes/Makefile | 2 +- bsnes/nall/string/base.hpp | 4 +-- bsnes/nall/string/core.hpp | 8 ++--- bsnes/nall/string/variadic.hpp | 4 +-- bsnes/nall/utf8.hpp | 3 ++ bsnes/phoenix/windows/canvas.cpp | 18 +++++++++- bsnes/phoenix/windows/label.cpp | 2 +- bsnes/phoenix/windows/phoenix-amd64.Manifest | 9 ----- ...{phoenix-x86.Manifest => phoenix.Manifest} | 4 +-- bsnes/phoenix/windows/phoenix.rc | 8 +---- bsnes/phoenix/windows/window.cpp | 2 +- bsnes/phoenix/windows/windows.cpp | 33 +++++++++++-------- bsnes/snes/snes.hpp | 2 +- bsnes/ui-phoenix/Makefile | 3 +- bsnes/ui-phoenix/main.cpp | 6 ++-- bsnes/ui-phoenix/resource.rc | 9 +---- 16 files changed, 60 insertions(+), 57 deletions(-) delete mode 100755 bsnes/phoenix/windows/phoenix-amd64.Manifest rename bsnes/phoenix/windows/{phoenix-x86.Manifest => phoenix.Manifest} (71%) diff --git a/bsnes/Makefile b/bsnes/Makefile index 67c50eac..81a01fd8 100755 --- a/bsnes/Makefile +++ b/bsnes/Makefile @@ -24,7 +24,7 @@ else ifeq ($(platform),osx) else ifeq ($(platform),win) link += -mwindows # link += -mconsole - link += -mthreads -s -luuid -lkernel32 -luser32 -lgdi32 -lshell32 + link += -mthreads -s -luuid -lkernel32 -luser32 -lgdi32 -lcomctl32 -lcomdlg32 -lshell32 -lole32 link += -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc else unknown_platform: help; diff --git a/bsnes/nall/string/base.hpp b/bsnes/nall/string/base.hpp index 6feb51f6..fbdcc3c9 100755 --- a/bsnes/nall/string/base.hpp +++ b/bsnes/nall/string/base.hpp @@ -43,7 +43,7 @@ namespace nall { inline string& operator=(const string&); inline string& operator=(string&&); - template inline string(Args... args); + template inline string(Args&&... args); inline string(const string&); inline string(string&&); inline ~string(); @@ -135,7 +135,7 @@ namespace nall { inline string strdouble(double value); //variadic.hpp - template inline void print(Args... args); + template inline void print(Args&&... args); }; #endif diff --git a/bsnes/nall/string/core.hpp b/bsnes/nall/string/core.hpp index 12245378..3ce361a6 100755 --- a/bsnes/nall/string/core.hpp +++ b/bsnes/nall/string/core.hpp @@ -72,16 +72,16 @@ static void istring(string &output) { } template -static void istring(string &output, T value, Args... args) { +static void istring(string &output, const T &value, Args&&... args) { output.append(value); - istring(output, args...); + istring(output, std::forward(args)...); } -template string::string(Args... args) { +template string::string(Args&&... args) { size = 64; data = (char*)malloc(size + 1); *data = 0; - istring(*this, args...); + istring(*this, std::forward(args)...); } string::string(const string &value) { diff --git a/bsnes/nall/string/variadic.hpp b/bsnes/nall/string/variadic.hpp index 387add29..6c027fc8 100755 --- a/bsnes/nall/string/variadic.hpp +++ b/bsnes/nall/string/variadic.hpp @@ -3,8 +3,8 @@ namespace nall { -template inline void print(Args... args) { - printf("%s", (const char*)string(args...)); +template inline void print(Args&&... args) { + printf("%s", (const char*)string(std::forward(args)...)); } } diff --git a/bsnes/nall/utf8.hpp b/bsnes/nall/utf8.hpp index c66c341a..5def74e0 100755 --- a/bsnes/nall/utf8.hpp +++ b/bsnes/nall/utf8.hpp @@ -62,6 +62,9 @@ namespace nall { delete[] buffer; } + utf8_t(const utf8_t&) = delete; + utf8_t& operator=(const utf8_t&) = delete; + private: char *buffer; }; diff --git a/bsnes/phoenix/windows/canvas.cpp b/bsnes/phoenix/windows/canvas.cpp index 39fd3c05..783d7042 100755 --- a/bsnes/phoenix/windows/canvas.cpp +++ b/bsnes/phoenix/windows/canvas.cpp @@ -13,7 +13,7 @@ void Canvas::create(Window &parent, unsigned x, unsigned y, unsigned width, unsi canvas->bmi.bmiHeader.biSizeImage = canvas->pitch * canvas->height; widget->window = CreateWindow( - L"phoenix_window", L"", + L"phoenix_canvas", L"", WS_CHILD | WS_VISIBLE, x, y, width, height, parent.widget->window, (HMENU)object->id, GetModuleHandle(0), 0 @@ -42,3 +42,19 @@ Canvas::~Canvas() { delete[] canvas->buffer; delete canvas; } + +static LRESULT CALLBACK Canvas_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { + switch(msg) { + case WM_PAINT: { + Object *object_ptr = (Object*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if(object_ptr) { + if(dynamic_cast(object_ptr)) { + Canvas &canvas = (Canvas&)*object_ptr; + canvas.redraw(); + } + } + } + } + + return DefWindowProc(hwnd, msg, wparam, lparam); +} diff --git a/bsnes/phoenix/windows/label.cpp b/bsnes/phoenix/windows/label.cpp index d21850d7..924c57d7 100755 --- a/bsnes/phoenix/windows/label.cpp +++ b/bsnes/phoenix/windows/label.cpp @@ -15,7 +15,7 @@ void Label::setText(const char *text) { } //all of this for want of a STATIC SS_VCENTER flag ... -LRESULT CALLBACK Label_WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { +LRESULT CALLBACK Label_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { Window *window_ptr = (Window*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA); if(!window_ptr) return DefWindowProc(hwnd, msg, wparam, lparam); Label *label_ptr = (Label*)GetWindowLongPtr(hwnd, GWLP_USERDATA); diff --git a/bsnes/phoenix/windows/phoenix-amd64.Manifest b/bsnes/phoenix/windows/phoenix-amd64.Manifest deleted file mode 100755 index 9be6de2b..00000000 --- a/bsnes/phoenix/windows/phoenix-amd64.Manifest +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/bsnes/phoenix/windows/phoenix-x86.Manifest b/bsnes/phoenix/windows/phoenix.Manifest similarity index 71% rename from bsnes/phoenix/windows/phoenix-x86.Manifest rename to bsnes/phoenix/windows/phoenix.Manifest index 42876834..71013ffe 100755 --- a/bsnes/phoenix/windows/phoenix-x86.Manifest +++ b/bsnes/phoenix/windows/phoenix.Manifest @@ -1,9 +1,9 @@ - + - + diff --git a/bsnes/phoenix/windows/phoenix.rc b/bsnes/phoenix/windows/phoenix.rc index e511903c..89fb8dc2 100755 --- a/bsnes/phoenix/windows/phoenix.rc +++ b/bsnes/phoenix/windows/phoenix.rc @@ -1,7 +1 @@ -#ifdef ARCH_X86 -1 24 "phoenix-x86.Manifest" -#endif - -#ifdef ARCH_AMD64 -1 24 "phoenix-amd64.Manifest" -#endif +1 24 "phoenix.Manifest" diff --git a/bsnes/phoenix/windows/window.cpp b/bsnes/phoenix/windows/window.cpp index 2cab0ad9..1d952bbd 100755 --- a/bsnes/phoenix/windows/window.cpp +++ b/bsnes/phoenix/windows/window.cpp @@ -23,7 +23,7 @@ void Window::setDefaultFont(Font &font) { } void Window::setFont(Font &font) { - SendMessage(window->status, WM_SETFONT, (WPARAM)window->defaultFont, 0); + SendMessage(window->status, WM_SETFONT, (WPARAM)font.font->font, 0); } void Window::setGeometry(unsigned x, unsigned y, unsigned width, unsigned height) { diff --git a/bsnes/phoenix/windows/windows.cpp b/bsnes/phoenix/windows/windows.cpp index 97194fcc..8076d993 100755 --- a/bsnes/phoenix/windows/windows.cpp +++ b/bsnes/phoenix/windows/windows.cpp @@ -195,9 +195,9 @@ string OS::fileSave(Window &parent, const char *filter, const char *path) { } static LRESULT CALLBACK OS_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { - Window *window_ptr = (Window*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if(!window_ptr) return DefWindowProc(hwnd, msg, wparam, lparam); - Window &window = *window_ptr; + Object *object_ptr = (Object*)GetWindowLongPtr(hwnd, GWLP_USERDATA); + if(!object_ptr || !dynamic_cast(object_ptr)) return DefWindowProc(hwnd, msg, wparam, lparam); + Window &window = (Window&)*object_ptr; switch(msg) { case WM_CLOSE: { @@ -226,16 +226,6 @@ static LRESULT CALLBACK OS_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM } } - case WM_PAINT: { - Object *object_ptr = (Object*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if(object_ptr) { - if(dynamic_cast(object_ptr)) { - Canvas &canvas = (Canvas&)*object_ptr; - canvas.redraw(); - } - } - } - case WM_COMMAND: { unsigned id = LOWORD(wparam); HWND control = GetDlgItem(window.widget->window, id); @@ -369,6 +359,9 @@ Object* OS::findObject(unsigned id) { } OS::OS() { + InitCommonControls(); + CoInitialize(0); + os = new OS::Data; os->proportionalFont = Font_createFont("Tahoma", 8, false, false); os->monospaceFont = Font_createFont("Courier New", 8, false, false); @@ -386,13 +379,25 @@ OS::OS() { wc.style = CS_HREDRAW | CS_VREDRAW; RegisterClass(&wc); + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hbrBackground = CreateSolidBrush(RGB(0, 0, 0)); + wc.hCursor = LoadCursor(0, IDC_ARROW); + wc.hIcon = LoadIcon(0, IDI_APPLICATION); + wc.hInstance = GetModuleHandle(0); + wc.lpfnWndProc = Canvas_windowProc; + wc.lpszClassName = L"phoenix_canvas"; + wc.lpszMenuName = 0; + wc.style = CS_HREDRAW | CS_VREDRAW; + RegisterClass(&wc); + wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hIcon = LoadIcon(0, IDI_APPLICATION); wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = Label_WindowProc; + wc.lpfnWndProc = Label_windowProc; wc.lpszClassName = L"phoenix_label"; wc.lpszMenuName = 0; wc.style = CS_HREDRAW | CS_VREDRAW; diff --git a/bsnes/snes/snes.hpp b/bsnes/snes/snes.hpp index 92c662ea..1bbef1e7 100755 --- a/bsnes/snes/snes.hpp +++ b/bsnes/snes/snes.hpp @@ -1,7 +1,7 @@ namespace SNES { namespace Info { static const char Name[] = "bsnes"; - static const char Version[] = "068.19"; + static const char Version[] = "068.20"; static const unsigned SerializerVersion = 13; } } diff --git a/bsnes/ui-phoenix/Makefile b/bsnes/ui-phoenix/Makefile index 51791800..8fd9e41b 100755 --- a/bsnes/ui-phoenix/Makefile +++ b/bsnes/ui-phoenix/Makefile @@ -19,7 +19,6 @@ else ifeq ($(platform),osx) link += $(if $(findstring audio.openal,$(ruby)),-framework OpenAL) else ifeq ($(platform),win) - arch := -DARCH_X86 flags += -DPHOENIX_WINDOWS link += @@ -65,7 +64,7 @@ obj/ruby.o: ruby/ruby.cpp $(call rwildcard,ruby/*) obj/phoenix.o: phoenix/phoenix.cpp $(call rwildcard,phoenix/*) obj/resource.o: $(ui)/resource.rc - windres $(ui)/resource.rc obj/resource.o $(arch) + windres $(ui)/resource.rc obj/resource.o # targets ui_build:; diff --git a/bsnes/ui-phoenix/main.cpp b/bsnes/ui-phoenix/main.cpp index ea06263a..a8b45e1c 100755 --- a/bsnes/ui-phoenix/main.cpp +++ b/bsnes/ui-phoenix/main.cpp @@ -4,7 +4,7 @@ Application application; #if defined(PLATFORM_WIN) static string VideoDriver = "Direct3D"; -static string AudioDriver = "XAudio2"; +static string AudioDriver = "DirectSound"; static string InputDriver = "RawInput"; #elif defined(PLATFORM_X) static string VideoDriver = "OpenGL"; @@ -73,7 +73,9 @@ void Application::main(int argc, char **argv) { while(os.pending()) os.run(); SNES::system.term(); - exit(0); + video.term(); + audio.term(); + input.term(); } int main(int argc, char **argv) { diff --git a/bsnes/ui-phoenix/resource.rc b/bsnes/ui-phoenix/resource.rc index f8b1b389..af394337 100755 --- a/bsnes/ui-phoenix/resource.rc +++ b/bsnes/ui-phoenix/resource.rc @@ -1,9 +1,2 @@ -#ifdef ARCH_X86 -1 24 "../phoenix/windows/phoenix-x86.Manifest" -#endif - -#ifdef ARCH_AMD64 -1 24 "../phoenix/windows/phoenix-amd64.Manifest" -#endif - +1 24 "../phoenix/windows/phoenix.Manifest" 2 ICON DISCARDABLE "data/bsnes.ico"