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)
This commit is contained in:
Tim Allen
2010-09-22 22:49:49 +10:00
parent 697f23d45c
commit 4163059b21
16 changed files with 60 additions and 57 deletions

View File

@@ -24,7 +24,7 @@ else ifeq ($(platform),osx)
else ifeq ($(platform),win) else ifeq ($(platform),win)
link += -mwindows link += -mwindows
# link += -mconsole # 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 link += -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc
else else
unknown_platform: help; unknown_platform: help;

View File

@@ -43,7 +43,7 @@ namespace nall {
inline string& operator=(const string&); inline string& operator=(const string&);
inline string& operator=(string&&); inline string& operator=(string&&);
template<typename... Args> inline string(Args... args); template<typename... Args> inline string(Args&&... args);
inline string(const string&); inline string(const string&);
inline string(string&&); inline string(string&&);
inline ~string(); inline ~string();
@@ -135,7 +135,7 @@ namespace nall {
inline string strdouble(double value); inline string strdouble(double value);
//variadic.hpp //variadic.hpp
template<typename... Args> inline void print(Args... args); template<typename... Args> inline void print(Args&&... args);
}; };
#endif #endif

View File

@@ -72,16 +72,16 @@ static void istring(string &output) {
} }
template<typename T, typename... Args> template<typename T, typename... Args>
static void istring(string &output, T value, Args... args) { static void istring(string &output, const T &value, Args&&... args) {
output.append(value); output.append(value);
istring(output, args...); istring(output, std::forward<Args>(args)...);
} }
template<typename... Args> string::string(Args... args) { template<typename... Args> string::string(Args&&... args) {
size = 64; size = 64;
data = (char*)malloc(size + 1); data = (char*)malloc(size + 1);
*data = 0; *data = 0;
istring(*this, args...); istring(*this, std::forward<Args>(args)...);
} }
string::string(const string &value) { string::string(const string &value) {

View File

@@ -3,8 +3,8 @@
namespace nall { namespace nall {
template<typename... Args> inline void print(Args... args) { template<typename... Args> inline void print(Args&&... args) {
printf("%s", (const char*)string(args...)); printf("%s", (const char*)string(std::forward<Args>(args)...));
} }
} }

View File

@@ -62,6 +62,9 @@ namespace nall {
delete[] buffer; delete[] buffer;
} }
utf8_t(const utf8_t&) = delete;
utf8_t& operator=(const utf8_t&) = delete;
private: private:
char *buffer; char *buffer;
}; };

View File

@@ -13,7 +13,7 @@ void Canvas::create(Window &parent, unsigned x, unsigned y, unsigned width, unsi
canvas->bmi.bmiHeader.biSizeImage = canvas->pitch * canvas->height; canvas->bmi.bmiHeader.biSizeImage = canvas->pitch * canvas->height;
widget->window = CreateWindow( widget->window = CreateWindow(
L"phoenix_window", L"", L"phoenix_canvas", L"",
WS_CHILD | WS_VISIBLE, WS_CHILD | WS_VISIBLE,
x, y, width, height, x, y, width, height,
parent.widget->window, (HMENU)object->id, GetModuleHandle(0), 0 parent.widget->window, (HMENU)object->id, GetModuleHandle(0), 0
@@ -42,3 +42,19 @@ Canvas::~Canvas() {
delete[] canvas->buffer; delete[] canvas->buffer;
delete canvas; 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<Canvas*>(object_ptr)) {
Canvas &canvas = (Canvas&)*object_ptr;
canvas.redraw();
}
}
}
}
return DefWindowProc(hwnd, msg, wparam, lparam);
}

View File

@@ -15,7 +15,7 @@ void Label::setText(const char *text) {
} }
//all of this for want of a STATIC SS_VCENTER flag ... //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); Window *window_ptr = (Window*)GetWindowLongPtr(GetParent(hwnd), GWLP_USERDATA);
if(!window_ptr) return DefWindowProc(hwnd, msg, wparam, lparam); if(!window_ptr) return DefWindowProc(hwnd, msg, wparam, lparam);
Label *label_ptr = (Label*)GetWindowLongPtr(hwnd, GWLP_USERDATA); Label *label_ptr = (Label*)GetWindowLongPtr(hwnd, GWLP_USERDATA);

View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="phoenix" version="1.0.0.0" processorArchitecture="AMD64"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="AMD64" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
</assembly>

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="phoenix" version="1.0.0.0" processorArchitecture="x86"/> <assemblyIdentity type="win32" name="phoenix" version="1.0.0.0" processorArchitecture="*"/>
<dependency> <dependency>
<dependentAssembly> <dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*"/> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly> </dependentAssembly>
</dependency> </dependency>
</assembly> </assembly>

View File

@@ -1,7 +1 @@
#ifdef ARCH_X86 1 24 "phoenix.Manifest"
1 24 "phoenix-x86.Manifest"
#endif
#ifdef ARCH_AMD64
1 24 "phoenix-amd64.Manifest"
#endif

View File

@@ -23,7 +23,7 @@ void Window::setDefaultFont(Font &font) {
} }
void Window::setFont(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) { void Window::setGeometry(unsigned x, unsigned y, unsigned width, unsigned height) {

View File

@@ -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) { static LRESULT CALLBACK OS_windowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
Window *window_ptr = (Window*)GetWindowLongPtr(hwnd, GWLP_USERDATA); Object *object_ptr = (Object*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if(!window_ptr) return DefWindowProc(hwnd, msg, wparam, lparam); if(!object_ptr || !dynamic_cast<Window*>(object_ptr)) return DefWindowProc(hwnd, msg, wparam, lparam);
Window &window = *window_ptr; Window &window = (Window&)*object_ptr;
switch(msg) { switch(msg) {
case WM_CLOSE: { 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<Canvas*>(object_ptr)) {
Canvas &canvas = (Canvas&)*object_ptr;
canvas.redraw();
}
}
}
case WM_COMMAND: { case WM_COMMAND: {
unsigned id = LOWORD(wparam); unsigned id = LOWORD(wparam);
HWND control = GetDlgItem(window.widget->window, id); HWND control = GetDlgItem(window.widget->window, id);
@@ -369,6 +359,9 @@ Object* OS::findObject(unsigned id) {
} }
OS::OS() { OS::OS() {
InitCommonControls();
CoInitialize(0);
os = new OS::Data; os = new OS::Data;
os->proportionalFont = Font_createFont("Tahoma", 8, false, false); os->proportionalFont = Font_createFont("Tahoma", 8, false, false);
os->monospaceFont = Font_createFont("Courier New", 8, false, false); os->monospaceFont = Font_createFont("Courier New", 8, false, false);
@@ -386,13 +379,25 @@ OS::OS() {
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc); 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.cbClsExtra = 0;
wc.cbWndExtra = 0; wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hIcon = LoadIcon(0, IDI_APPLICATION); wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hInstance = GetModuleHandle(0); wc.hInstance = GetModuleHandle(0);
wc.lpfnWndProc = Label_WindowProc; wc.lpfnWndProc = Label_windowProc;
wc.lpszClassName = L"phoenix_label"; wc.lpszClassName = L"phoenix_label";
wc.lpszMenuName = 0; wc.lpszMenuName = 0;
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;

View File

@@ -1,7 +1,7 @@
namespace SNES { namespace SNES {
namespace Info { namespace Info {
static const char Name[] = "bsnes"; static const char Name[] = "bsnes";
static const char Version[] = "068.19"; static const char Version[] = "068.20";
static const unsigned SerializerVersion = 13; static const unsigned SerializerVersion = 13;
} }
} }

View File

@@ -19,7 +19,6 @@ else ifeq ($(platform),osx)
link += $(if $(findstring audio.openal,$(ruby)),-framework OpenAL) link += $(if $(findstring audio.openal,$(ruby)),-framework OpenAL)
else ifeq ($(platform),win) else ifeq ($(platform),win)
arch := -DARCH_X86
flags += -DPHOENIX_WINDOWS flags += -DPHOENIX_WINDOWS
link += link +=
@@ -65,7 +64,7 @@ obj/ruby.o: ruby/ruby.cpp $(call rwildcard,ruby/*)
obj/phoenix.o: phoenix/phoenix.cpp $(call rwildcard,phoenix/*) obj/phoenix.o: phoenix/phoenix.cpp $(call rwildcard,phoenix/*)
obj/resource.o: $(ui)/resource.rc obj/resource.o: $(ui)/resource.rc
windres $(ui)/resource.rc obj/resource.o $(arch) windres $(ui)/resource.rc obj/resource.o
# targets # targets
ui_build:; ui_build:;

View File

@@ -4,7 +4,7 @@ Application application;
#if defined(PLATFORM_WIN) #if defined(PLATFORM_WIN)
static string VideoDriver = "Direct3D"; static string VideoDriver = "Direct3D";
static string AudioDriver = "XAudio2"; static string AudioDriver = "DirectSound";
static string InputDriver = "RawInput"; static string InputDriver = "RawInput";
#elif defined(PLATFORM_X) #elif defined(PLATFORM_X)
static string VideoDriver = "OpenGL"; static string VideoDriver = "OpenGL";
@@ -73,7 +73,9 @@ void Application::main(int argc, char **argv) {
while(os.pending()) os.run(); while(os.pending()) os.run();
SNES::system.term(); SNES::system.term();
exit(0); video.term();
audio.term();
input.term();
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {

View File

@@ -1,9 +1,2 @@
#ifdef ARCH_X86 1 24 "../phoenix/windows/phoenix.Manifest"
1 24 "../phoenix/windows/phoenix-x86.Manifest"
#endif
#ifdef ARCH_AMD64
1 24 "../phoenix/windows/phoenix-amd64.Manifest"
#endif
2 ICON DISCARDABLE "data/bsnes.ico" 2 ICON DISCARDABLE "data/bsnes.ico"