From ebb234ba5f64dbce0d8b257cb55b0d4024ae7d51 Mon Sep 17 00:00:00 2001 From: byuu Date: Tue, 5 Jun 2007 15:50:59 +0000 Subject: [PATCH] Update to bsnes v020 01 release. [No changelog available] --- cart.db | Bin 0 -> 3276 bytes license.txt | 63 ++++ readme.txt | 88 ++++++ src/base.h | 2 +- src/lib/libbase.h | 5 +- src/lib/libco_x86.h | 12 +- src/lib/libfunctor.h | 341 ---------------------- src/lib/libui_gtk.cpp | 27 +- src/lib/libui_gtk.h | 13 +- src/lib/libui_gtk_window.cpp | 10 +- src/lib/libui_win.cpp | 8 +- src/lib/libui_win.h | 8 +- src/lib/libui_win_control.cpp | 12 +- src/lib/libui_win_window.cpp | 12 +- src/ui/lui/event.cpp | 30 +- src/ui/lui/main.cpp | 9 +- src/ui/lui/settings/ui_advanced.cpp | 11 +- src/ui/lui/settings/ui_advanced.h | 2 +- src/ui/lui/settings/ui_cheateditor.cpp | 4 +- src/ui/lui/settings/ui_cheateditor.h | 2 +- src/ui/lui/settings/ui_inputconfig.cpp | 35 ++- src/ui/lui/settings/ui_inputconfig.h | 6 +- src/ui/lui/settings/ui_rastersettings.cpp | 27 +- src/ui/lui/settings/ui_rastersettings.h | 2 +- src/ui/lui/settings/ui_settings.cpp | 14 +- src/ui/lui/settings/ui_settings.h | 2 +- src/ui/lui/ui_about.cpp | 4 +- src/ui/lui/ui_about.h | 2 +- src/ui/lui/ui_main.cpp | 94 +++--- src/ui/lui/ui_main.h | 2 +- 30 files changed, 334 insertions(+), 513 deletions(-) create mode 100644 cart.db create mode 100644 license.txt create mode 100644 readme.txt delete mode 100644 src/lib/libfunctor.h diff --git a/cart.db b/cart.db new file mode 100644 index 0000000000000000000000000000000000000000..a489d594f1d3d4ed7658ccd7646303e77a988fd6 GIT binary patch literal 3276 zcmd6py>HV%7{(9Lfdz@7OBeJ;45WjrCKX>3#CDR>Hc{2kgA9$A{TL#&37Mzz5tGL>1K)dSxPz*ZF{Q>j5P^0cu0uR@{!MC8WzwJ9Md#_n78vfe)T zR!6d0$eOz=5jY-eJ z3N~aH#AW@v^W$?QYXMm;g{rn;mN|ic46>D9dto8#lIvr4GMVqY93d%hVf<~3KM&`Z zA$Nqhx{f}1Jn}zl7yY=gu8(|rN_katAJhiqTU^w`O(btQnlMvVG>P zYn@(D&>z>S!cG8X)#5HJdVv$@gJVyiYZ20&vo4j4Odr&6&LSsB?d-GK3X?Ui!%<~J Qt0t`C$daV2ByNxW2YL}w>Hq)$ literal 0 HcmV?d00001 diff --git a/license.txt b/license.txt new file mode 100644 index 00000000..f0b192b9 --- /dev/null +++ b/license.txt @@ -0,0 +1,63 @@ +bsnes (TM) Open Source Reference License +Copyright (C) 2004 - 2007 byuu +All rights reserved + +1. Definitions + +The terms "reproduce", "reproduction", "distribute" and "distribution" have the +same meaning here as under U.S. copyright law. + +"The software" means this software package as a whole, including, but not +limited to, this license, binaries, source code, documentation, and data. + +"You" means the licensee of the software. + +"The licensor" means the copyright holder of the software, byuu. + +2. Grant of Rights + +Subject to the terms of this license, the licensor grants you a +non-transferable, non-exclusive, worldwide, royalty-free copyright license to +reproduce the software for non-commercial use only, provided the software +remains unmodified, and there is no charge for the software itself, its' use, +nor for the medium upon which the software is distributed. The reproduction of +modified or derivative works of the software is strictly prohibited, except when +transmitted solely to the licensor. + +3. Limitations + +This license does not grant you any rights to use the licensor's name, logo or +trademarks. + +The software is provided "as is", and any express or implied warranties, +including, but not limited to, the implied warranties of merchantability and +fitness for a particular purpose are disclaimed. In no event shall the licensor +be liable for any direct, indirect, incidental, special, exemplary, or +consequential damages (including, but not limited to, procurement of substitute +goods or services; loss of use, data, or profits; or business interruption) +however caused and on any theory of liability, whether in contract, strict +liability, or tort (including negligence or otherwise) arising in any way out of +the use of the software, even if advised of the possibility of such damage. + +In the event that this license is determined to be invalid or unenforceable, the +Grant of Rights will become null and void, and no rights shall be granted to the +licensee, within the scope of U.S. copyright law. + +4. Exemptions + +The software includes the work of other copyright holders, which is licensed +under different agreements, and exempt from this license. Below is a complete +list of all such software, and their respective copyright holders and licenses. +Further, respective source code files are labeled with their correct licensing +information in the header. The lack of such a header indicates said file falls +under the bsnes license. + +HQ2x Filter, author: MaxST, license: LGPL +JMA, author: NSRT Team, license: GPL * +libco, author: byuu, license: public domain +libui, author: byuu, license: public domain +NTSC Filter, author: blargg, license: LGPL +S-DD1, author: Andreas Naive, license: public domain +zlib, license: zlib license + +* bsnes has received an exemption from the copyright holder to use this work. diff --git a/readme.txt b/readme.txt new file mode 100644 index 00000000..c4154049 --- /dev/null +++ b/readme.txt @@ -0,0 +1,88 @@ +bsnes +Version 0.020 +Author: byuu + + +General: +-------- +bsnes is a Super Nintendo / Super Famicom emulator that began on +October 14th, 2004. + +The latest version can be downloaded from: +http://byuu.org/ + +Please see license.txt for important licensing information. + + +Known Limitations: +------------------ +S-CPU +- Invalid DMA / HDMA transfers (eg WRAM<>WRAM) not fully emulated +- Multiply / Divide register delays not implemented + +S-PPU +- Uses scanline-based renderer. This is very inaccurate, but very few games + rely on mid-scanline writes to function correctly +- Does not support FirstSprite+Y priority +- OAM / CGRAM accesses during active display not supported correctly +- RTO flags are not calculated on frames that are skipped when frameskipping + is enabled. This provides a major speedup, however it will cause in issues + in games that test these flags, eg the SNES Test Program Electronics Test. + Turning frameskipping off will allow RTO flag calculation on every frame + +Hardware Bugs +- CPUr1 HDMA crashing bug not emulated +- CPU<>APU communication bus conflicts not emulated + + +Unsupported Hardware: +--------------------- +SA-1 +Coprocessor used in many popular games, including: +- Dragon Ball Z Hyper Dimension +- Kirby Super Star +- Kirby's Dreamland 3 +- Marvelous +- SD Gundam G-NEXT +- Super Mario RPG + +Super FX +Coprocessor used in many popular games, including: +- Doom +- Star Fox +- Star Fox 2 (unreleased beta) +- Super Mario World 2: Yoshi's Island + +SPC7110 +Coprocessor used only by the following games: +- Far East of Eden Zero +- Far East of Eden Zero: Shounen Jump no Shou +- Momotarou Densetsu Happy +- Super Power League 4 + +DSP-3 +Coprocessor used only by SD Gundam GX + +DSP-4 +Coprocessor used only by Top Gear 3000 + +ST010 / ST011 / ST018 +SETA coprocessors used by very few games + +BS-X (Broadcast Satellite) +Add-on unit sold only in Japan that played specially-made games that were +downloaded via satellite + +BS-X Flashcart +Flash cartridge used by BS-X, as well as some standalone games by Asciisoft + +Super Gameboy +Cartridge passthrough used for playing Gameboy games + + +Unsupported Controllers: +------------------------ +Mouse +Super Scope +Justifier +Multitap (4-port and 5-port) diff --git a/src/base.h b/src/base.h index 27403a25..9fe8660d 100644 --- a/src/base.h +++ b/src/base.h @@ -1,4 +1,4 @@ -#define BSNES_VERSION "0.020" +#define BSNES_VERSION "0.020.01" #define BSNES_TITLE "bsnes v" BSNES_VERSION #define MEMCORE bMemBus diff --git a/src/lib/libbase.h b/src/lib/libbase.h index c445f575..0423c20c 100644 --- a/src/lib/libbase.h +++ b/src/lib/libbase.h @@ -1,5 +1,5 @@ /* - libbase : version 0.10 ~byuu (2007-05-27) + libbase : version 0.10 ~byuu (2007-06-04) license: public domain */ @@ -55,17 +55,14 @@ #define noinline __declspec(noinline) #define inline inline #define alwaysinline __forceinline - #define fastcall __fastcall #elif defined(__GNUC__) #define noinline __attribute__((noinline)) #define inline inline #define alwaysinline __attribute__((always_inline)) - #define fastcall __attribute__((fastcall)) #else #define noinline #define inline inline #define alwaysinline inline - #define fastcall #endif /***** diff --git a/src/lib/libco_x86.h b/src/lib/libco_x86.h index 815346ba..527f403a 100644 --- a/src/lib/libco_x86.h +++ b/src/lib/libco_x86.h @@ -1,10 +1,20 @@ /* - libco_x86 : version 0.10 ~byuu (2007-04-18) + libco_x86 : version 0.10 ~byuu (2007-06-04) + license: public domain */ #ifndef LIBCO_H #define LIBCO_H +#undef fastcall +#if defined(_MSC_VER) + #define fastcall __fastcall +#elif defined(__GNUC__) + #define fastcall __attribute__((fastcall)) +#else + #error "fastcall undefined" +#endif + #define cocall fastcall typedef void (*cothread_t); diff --git a/src/lib/libfunctor.h b/src/lib/libfunctor.h deleted file mode 100644 index be776eab..00000000 --- a/src/lib/libfunctor.h +++ /dev/null @@ -1,341 +0,0 @@ -/* - libfunctor : version 0.01 ~byuu (2007-01-04) -*/ - -#ifndef __LIBFUNCTOR -#define __LIBFUNCTOR - -template struct functor; -template struct functor_t; - -/***** - * macros - *****/ - -#define base_functor \ -functor *f; \ - virtual operator bool() const { return f && (bool)(*f); } \ - virtual functor *copy() const { return f->copy(); } \ - functor &operator=(const functor *source) { if(f) { delete f; } f = (source->f) ? source->copy() : 0; return *this; } \ - functor &operator=(const functor &source) { if(f) { delete f; } f = (source.f) ? source.copy() : 0; return *this; } \ - functor(const functor &source) { /* ........................ */ f = (source.f) ? source.copy() : 0; } \ - functor() : f(0) {} \ - ~functor() { if(f && f != this) { delete f; } } - -#define base_global_functor \ - operator bool() const { return proc; } \ - functor_t *copy() const { return new functor_t(*this); } \ - functor_t(const functor_t &source) { proc = source.proc; } - -#define base_member_functor \ - operator bool() const { return obj && proc; } \ - functor_t *copy() const { return new functor_t(*this); } \ - functor_t(const functor_t &source) { obj = source.obj; proc = source.proc; } \ -C *obj; - -/***** - * parameters = 0 - *****/ - -template -struct functor { base_functor - virtual R operator()() const { return (*f)(); } -}; - -template -struct functor_t : public functor { base_global_functor -R (*proc)(); - R operator()() const { return (*proc)(); } - functor_t(R (*_proc)()) : proc(_proc) { this->f = this; } -}; - -template -struct functor_t : public functor { base_member_functor -R (C::*proc)(); - R operator()() const { return (obj->*proc)(); } - functor_t(C *_obj, R (C::*_proc)()) : obj(_obj), proc(_proc) { this->f = this; } -}; - -template -functor_t make_functor(R (*proc)()) { - return functor_t(proc); -} - -template -functor_t make_functor(C *obj, R (C::*proc)()) { - return functor_t(obj, proc); -} - -/***** - * parameters = 1 - *****/ - -template -struct functor { base_functor - virtual R operator()(P1 p1) const { return (*f)(p1); } -}; - -template -struct functor_t : public functor { base_global_functor -R (*proc)(P1); - R operator()(P1 p1) const { return (*proc)(p1); } - functor_t(R (*_proc)(P1)) : proc(_proc) { this->f = this; } -}; - -template -struct functor_t : public functor { base_member_functor -R (C::*proc)(P1); - R operator()(P1 p1) const { return (obj->*proc)(p1); } - functor_t(C *_obj, R (C::*_proc)(P1)) : obj(_obj), proc(_proc) { this->f = this; } -}; - -template -functor_t make_functor(R (*proc)(P1)) { - return functor_t(proc); -} - -template -functor_t make_functor(C *obj, R (C::*proc)(P1)) { - return functor_t(obj, proc); -} - -/***** - * parameters = 2 - *****/ - -template -struct functor { base_functor - virtual R operator()(P1 p1, P2 p2) const { return (*f)(p1, p2); } -}; - -template -struct functor_t : public functor { base_global_functor -R (*proc)(P1, P2); - R operator()(P1 p1, P2 p2) const { return (*proc)(p1, p2); } - functor_t(R (*_proc)(P1, P2)) : proc(_proc) { this->f = this; } -}; - -template -struct functor_t : public functor { base_member_functor -R (C::*proc)(P1, P2); - R operator()(P1 p1, P2 p2) const { return (obj->*proc)(p1, p2); } - functor_t(C *_obj, R (C::*_proc)(P1, P2)) : obj(_obj), proc(_proc) { this->f = this; } -}; - -template -functor_t make_functor(R (*proc)(P1, P2)) { - return functor_t(proc); -} - -template -functor_t make_functor(C *obj, R (C::*proc)(P1, P2)) { - return functor_t(obj, proc); -} - -/***** - * parameters = 3 - *****/ - -template -struct functor { base_functor - virtual R operator()(P1 p1, P2 p2, P3 p3) const { return (*f)(p1, p2, p3); } -}; - -template -struct functor_t : public functor { base_global_functor -R (*proc)(P1, P2, P3); - R operator()(P1 p1, P2 p2, P3 p3) const { return (*proc)(p1, p2, p3); } - functor_t(R (*_proc)(P1, P2, P3)) : proc(_proc) { this->f = this; } -}; - -template -struct functor_t : public functor { base_member_functor -R (C::*proc)(P1, P2, P3); - R operator()(P1 p1, P2 p2, P3 p3) const { return (obj->*proc)(p1, p2, p3); } - functor_t(C *_obj, R (C::*_proc)(P1, P2, P3)) : obj(_obj), proc(_proc) { this->f = this; } -}; - -template -functor_t make_functor(R (*proc)(P1, P2, P3)) { - return functor_t(proc); -} - -template -functor_t make_functor(C *obj, R (C::*proc)(P1, P2, P3)) { - return functor_t(obj, proc); -} - -/***** - * parameters = 4 - *****/ - -template -struct functor { base_functor - virtual R operator()(P1 p1, P2 p2, P3 p3, P4 p4) const { return (*f)(p1, p2, p3, p4); } -}; - -template -struct functor_t : public functor { base_global_functor -R (*proc)(P1, P2, P3, P4); - R operator()(P1 p1, P2 p2, P3 p3, P4 p4) const { return (*proc)(p1, p2, p3, p4); } - functor_t(R (*_proc)(P1, P2, P3, P4)) : proc(_proc) { this->f = this; } -}; - -template -struct functor_t : public functor { base_member_functor -R (C::*proc)(P1, P2, P3, P4); - R operator()(P1 p1, P2 p2, P3 p3, P4 p4) const { return (obj->*proc)(p1, p2, p3, p4); } - functor_t(C *_obj, R (C::*_proc)(P1, P2, P3, P4)) : obj(_obj), proc(_proc) { this->f = this; } -}; - -template -functor_t make_functor(R (*proc)(P1, P2, P3, P4)) { - return functor_t(proc); -} - -template -functor_t make_functor(C *obj, R (C::*proc)(P1, P2, P3, P4)) { - return functor_t(obj, proc); -} - -/***** - * parameters = 5 - *****/ - -template -struct functor { base_functor - virtual R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const { return (*f)(p1, p2, p3, p4, p5); } -}; - -template -struct functor_t : public functor { base_global_functor -R (*proc)(P1, P2, P3, P4, P5); - R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const { return (*proc)(p1, p2, p3, p4, p5); } - functor_t(R (*_proc)(P1, P2, P3, P4, P5)) : proc(_proc) { this->f = this; } -}; - -template -struct functor_t : public functor { base_member_functor -R (C::*proc)(P1, P2, P3, P4, P5); - R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const { return (obj->*proc)(p1, p2, p3, p4, p5); } - functor_t(C *_obj, R (C::*_proc)(P1, P2, P3, P4, P5)) : obj(_obj), proc(_proc) { this->f = this; } -}; - -template -functor_t make_functor(R (*proc)(P1, P2, P3, P4, P5)) { - return functor_t(proc); -} - -template -functor_t make_functor(C *obj, R (C::*proc)(P1, P2, P3, P4, P5)) { - return functor_t(obj, proc); -} - -/***** - * parameters = 6 - *****/ - -template -struct functor { base_functor - virtual R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const { return (*f)(p1, p2, p3, p4, p5, p6); } -}; - -template -struct functor_t : public functor { base_global_functor -R (*proc)(P1, P2, P3, P4, P5, P6); - R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const { return (*proc)(p1, p2, p3, p4, p5, p6); } - functor_t(R (*_proc)(P1, P2, P3, P4, P5, P6)) : proc(_proc) { this->f = this; } -}; - -template -struct functor_t : public functor { base_member_functor -R (C::*proc)(P1, P2, P3, P4, P5, P6); - R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const { return (obj->*proc)(p1, p2, p3, p4, p5, p6); } - functor_t(C *_obj, R (C::*_proc)(P1, P2, P3, P4, P5, P6)) : obj(_obj), proc(_proc) { this->f = this; } -}; - -template -functor_t make_functor(R (*proc)(P1, P2, P3, P4, P5, P6)) { - return functor_t(proc); -} - -template -functor_t make_functor(C *obj, R (C::*proc)(P1, P2, P3, P4, P5, P6)) { - return functor_t(obj, proc); -} - -/***** - * parameters = 7 - *****/ - -template -struct functor { base_functor - virtual R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) const { return (*f)(p1, p2, p3, p4, p5, p6, p7); } -}; - -template -struct functor_t : public functor { base_global_functor -R (*proc)(P1, P2, P3, P4, P5, P6, P7); - R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) const { return (*proc)(p1, p2, p3, p4, p5, p6, p7); } - functor_t(R (*_proc)(P1, P2, P3, P4, P5, P6, P7)) : proc(_proc) { this->f = this; } -}; - -template -struct functor_t : public functor { base_member_functor -R (C::*proc)(P1, P2, P3, P4, P5, P6, P7); - R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) const { return (obj->*proc)(p1, p2, p3, p4, p5, p6, p7); } - functor_t(C *_obj, R (C::*_proc)(P1, P2, P3, P4, P5, P6, P7)) : obj(_obj), proc(_proc) { this->f = this; } -}; - -template -functor_t make_functor(R (*proc)(P1, P2, P3, P4, P5, P6, P7)) { - return functor_t(proc); -} - -template -functor_t make_functor(C *obj, R (C::*proc)(P1, P2, P3, P4, P5, P6, P7)) { - return functor_t(obj, proc); -} - -/***** - * parameters = 8 - *****/ - -template -struct functor { base_functor - virtual R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) const { return (*f)(p1, p2, p3, p4, p5, p6, p7, p8); } -}; - -template -struct functor_t : public functor { base_global_functor -R (*proc)(P1, P2, P3, P4, P5, P6, P7, P8); - R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) const { return (*proc)(p1, p2, p3, p4, p5, p6, p7, p8); } - functor_t(R (*_proc)(P1, P2, P3, P4, P5, P6, P7, P8)) : proc(_proc) { this->f = this; } -}; - -template -struct functor_t : public functor { base_member_functor -R (C::*proc)(P1, P2, P3, P4, P5, P6, P7, P8); - R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) const { return (obj->*proc)(p1, p2, p3, p4, p5, p6, p7, p8); } - functor_t(C *_obj, R (C::*_proc)(P1, P2, P3, P4, P5, P6, P7, P8)) : obj(_obj), proc(_proc) { this->f = this; } -}; - -template -functor_t make_functor(R (*proc)(P1, P2, P3, P4, P5, P6, P7, P8)) { - return functor_t(proc); -} - -template -functor_t make_functor(C *obj, R (C::*proc)(P1, P2, P3, P4, P5, P6, P7, P8)) { - return functor_t(obj, proc); -} - -/***** - * epilogue - *****/ - -#undef base_functor -#undef base_global_functor -#undef base_member_functor - -#endif diff --git a/src/lib/libui_gtk.cpp b/src/lib/libui_gtk.cpp index c790bf67..276573a5 100644 --- a/src/lib/libui_gtk.cpp +++ b/src/lib/libui_gtk.cpp @@ -40,13 +40,14 @@ uint get_screen_height() { return gdk_screen_height(); } // -noinline bool gtk_file_load(Window &owner, char *filename, const char *filter, const char *path) { +bool file_load(Window *owner, char *filename, const char *filter, const char *path) { strcpy(filename, ""); GtkWidget *dialog = gtk_file_chooser_dialog_new("Load File", - GTK_WINDOW(owner.info.window), GTK_FILE_CHOOSER_ACTION_OPEN, + owner ? GTK_WINDOW(owner->info.window) : (GtkWindow*)0, + GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, 0); + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, (const gchar*)0); if(path && strcmp(path, "")) { gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), path); @@ -62,13 +63,14 @@ GtkWidget *dialog = gtk_file_chooser_dialog_new("Load File", return strcmp(filename, ""); //return true if filename != "" } -noinline bool gtk_file_save(Window &owner, char *filename, const char *filter, const char *path) { +bool file_save(Window *owner, char *filename, const char *filter, const char *path) { strcpy(filename, ""); GtkWidget *dialog = gtk_file_chooser_dialog_new("Save File", - GTK_WINDOW(owner.info.window), GTK_FILE_CHOOSER_ACTION_SAVE, + owner ? GTK_WINDOW(owner->info.window) : (GtkWindow*)0, + GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, 0); + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, (const gchar*)0); if(path && strcmp(path, "")) { gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), path); @@ -85,19 +87,6 @@ GtkWidget *dialog = gtk_file_chooser_dialog_new("Save File", return strcmp(filename, ""); //return true if filename != "" } -//FreeBSD 6.2-amd64 bug workaround for file_load() + file_save() -//gdb reveals stack corruption when calling gtk_file_chooset_dialog_new() from inside -//a member function. however, calling function with nesting sidesteps the bug ... -//gdb shows that the corruption occurs inside a GTK+ internal library function ... - -bool file_load(Window &owner, char *filename, const char *filter, const char *path) { - return gtk_file_load(owner, filename, filter, path); -} - -bool file_save(Window &owner, char *filename, const char *filter, const char *path) { - return gtk_file_save(owner, filename, filter, path); -} - // uint16 translate_key(uint key) { diff --git a/src/lib/libui_gtk.h b/src/lib/libui_gtk.h index c97452e1..d18baea8 100644 --- a/src/lib/libui_gtk.h +++ b/src/lib/libui_gtk.h @@ -1,5 +1,5 @@ /* - libui_gtk ~byuu (2007-05-27) + libui_gtk ~byuu (2007-06-05) license: public domain */ @@ -28,8 +28,8 @@ bool events_pending(); uint get_screen_width(); uint get_screen_height(); -bool file_load(Window &owner, char *filename, const char *filter, const char *path = ""); -bool file_save(Window &owner, char *filename, const char *filter, const char *path = ""); +bool file_load(Window *owner, char *filename, const char *filter, const char *path = ""); +bool file_save(Window *owner, char *filename, const char *filter, const char *path = ""); uint16 translate_key(uint key); @@ -60,13 +60,8 @@ MenuBar menu; void resize(uint width, uint height); virtual void show(); virtual void hide(); - virtual bool close() { return true; } - virtual void keydown(uint16 key) {} - virtual void keyup(uint16 key) {} - virtual int message(uint id, void *param = 0) {} - virtual void clicked(Control&) {} - virtual void changed(Control&) {} + virtual bool message(uint id, uintptr_t param = 0) { return true; } //private: struct { diff --git a/src/lib/libui_gtk_window.cpp b/src/lib/libui_gtk_window.cpp index 86d2d157..3b3c8116 100644 --- a/src/lib/libui_gtk_window.cpp +++ b/src/lib/libui_gtk_window.cpp @@ -6,25 +6,25 @@ gint libui_window_close(GtkWidget *w, GdkEventAny *any, Window *window) { } gint libui_window_keydown(GtkWidget *w, GdkEventKey *key, Window *window) { - if(window) { window->message(Message::KeyDown, (void*)libui::translate_key(key->keyval)); } + if(window) { window->message(Message::KeyDown, libui::translate_key(key->keyval)); } return FALSE; } gint libui_window_keyup(GtkWidget *w, GdkEventKey *key, Window *window) { - if(window) { window->message(Message::KeyUp, (void*)libui::translate_key(key->keyval)); } + if(window) { window->message(Message::KeyUp, libui::translate_key(key->keyval)); } return FALSE; } void libui_control_clicked(Control *control) { - if(control && control->owner) { control->owner->message(Message::Clicked, control); } + if(control && control->owner) { control->owner->message(Message::Clicked, (uintptr_t)control); } } void libui_control_changed(Control *control) { - if(control && control->owner) { control->owner->message(Message::Changed, control); } + if(control && control->owner) { control->owner->message(Message::Changed, (uintptr_t)control); } } void libui_control_double_clicked(Control *control) { - if(control && control->owner) { control->owner->message(Message::DoubleClicked, control); } + if(control && control->owner) { control->owner->message(Message::DoubleClicked, (uintptr_t)control); } } void Window::create(uint style, uint width, uint height, const char *caption) { diff --git a/src/lib/libui_win.cpp b/src/lib/libui_win.cpp index 1e86c6d5..09954de5 100644 --- a/src/lib/libui_win.cpp +++ b/src/lib/libui_win.cpp @@ -81,7 +81,7 @@ uint get_screen_height() { return GetSystemMetrics(SM_CYSCREEN); } // -bool file_load(Window &owner, char *filename, const char *filter, const char *path) { +bool file_load(Window *owner, char *filename, const char *filter, const char *path) { string dir, f; strcpy(dir, path ? path : ""); replace(dir, "/", "\\"); @@ -111,7 +111,7 @@ OPENFILENAME ofn; strcpy(filename, ""); memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = owner.info.hwnd; + ofn.hwndOwner = owner ? owner->info.hwnd : 0; ofn.lpstrFilter = pf; ofn.lpstrInitialDir = strptr(dir); ofn.lpstrFile = filename; @@ -122,7 +122,7 @@ OPENFILENAME ofn; return GetOpenFileName(&ofn); } -bool file_save(Window &owner, char *filename, const char *filter, const char *path) { +bool file_save(Window *owner, char *filename, const char *filter, const char *path) { string dir, f; strcpy(dir, path ? path : ""); replace(dir, "/", "\\"); @@ -152,7 +152,7 @@ OPENFILENAME ofn; strcpy(filename, ""); memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = owner.info.hwnd; + ofn.hwndOwner = owner ? owner->info.hwnd : 0; ofn.lpstrFilter = pf; ofn.lpstrInitialDir = strptr(dir); ofn.lpstrFile = filename; diff --git a/src/lib/libui_win.h b/src/lib/libui_win.h index 9b400599..0f938286 100644 --- a/src/lib/libui_win.h +++ b/src/lib/libui_win.h @@ -1,5 +1,5 @@ /* - libui_win ~byuu (2007-05-28) + libui_win ~byuu (2007-06-05) license: public domain */ @@ -32,8 +32,8 @@ bool events_pending(); uint get_screen_width(); uint get_screen_height(); -bool file_load(Window &owner, char *filename, const char *filter, const char *path = ""); -bool file_save(Window &owner, char *filename, const char *filter, const char *path = ""); +bool file_load(Window *owner, char *filename, const char *filter, const char *path = ""); +bool file_save(Window *owner, char *filename, const char *filter, const char *path = ""); uint16 translate_key(uint key); @@ -65,7 +65,7 @@ MenuBar menu; virtual void show(); virtual void hide(); - virtual int message(uint id, void *param = 0) { return 0; } + virtual bool message(uint id, uintptr_t param = 0) { return true; } void move(Control &control, uint x, uint y); void attach(Control &control); diff --git a/src/lib/libui_win_control.cpp b/src/lib/libui_win_control.cpp index 406c38b5..2d5657f8 100644 --- a/src/lib/libui_win_control.cpp +++ b/src/lib/libui_win_control.cpp @@ -137,13 +137,13 @@ void MenuCheckItem::create(MenuGroup &r_owner, const char *caption) { void MenuCheckItem::check() { if(checked() == true)return; CheckMenuItem(parent, id, MF_CHECKED); - owner->message(Message::Clicked, this); + owner->message(Message::Clicked, (uintptr_t)this); } void MenuCheckItem::uncheck() { if(checked() == false)return; CheckMenuItem(parent, id, MF_UNCHECKED); - owner->message(Message::Clicked, this); + owner->message(Message::Clicked, (uintptr_t)this); } void MenuCheckItem::check(bool state) { @@ -180,7 +180,7 @@ void MenuRadioItem::check() { for(uint i = 0; i < group.count(); i++) { CheckMenuItem(parent, group[i].id, (id == group[i].id) ? MF_CHECKED : MF_UNCHECKED); } - owner->message(Message::Clicked, this); + owner->message(Message::Clicked, (uintptr_t)this); } bool MenuRadioItem::checked() { @@ -419,13 +419,13 @@ void Checkbox::create(Window &r_owner, uint style, uint x, uint y, uint width, u void Checkbox::check() { if(checked() == true)return; SendMessage(hwnd, BM_SETCHECK, (WPARAM)TRUE, 0); - owner->message(Message::Clicked, this); + owner->message(Message::Clicked, (uintptr_t)this); } void Checkbox::uncheck() { if(checked() == false)return; SendMessage(hwnd, BM_SETCHECK, (WPARAM)FALSE, 0); - owner->message(Message::Clicked, this); + owner->message(Message::Clicked, (uintptr_t)this); } void Checkbox::check(bool state) { @@ -456,7 +456,7 @@ void Radiobox::check() { for(uint i = 0; i < group.count(); i++) { SendMessage(group[i].hwnd, BM_SETCHECK, (group[i].hwnd == hwnd) ? (WPARAM)TRUE : (WPARAM)FALSE, 0); } - owner->message(Message::Clicked, this); + owner->message(Message::Clicked, (uintptr_t)this); } bool Radiobox::checked() { diff --git a/src/lib/libui_win_window.cpp b/src/lib/libui_win_window.cpp index d7176e29..4c406764 100644 --- a/src/lib/libui_win_window.cpp +++ b/src/lib/libui_win_window.cpp @@ -33,11 +33,11 @@ long Window::wndproc(HWND hwnd, uint msg, WPARAM wparam, LPARAM lparam) { } break; case WM_KEYDOWN: { - message(Message::KeyDown, (void*)libui::translate_key(wparam)); + message(Message::KeyDown, libui::translate_key(wparam)); } break; case WM_KEYUP: { - message(Message::KeyUp, (void*)libui::translate_key(wparam)); + message(Message::KeyUp, libui::translate_key(wparam)); } break; case WM_COMMAND: { @@ -68,7 +68,7 @@ long Window::wndproc(HWND hwnd, uint msg, WPARAM wparam, LPARAM lparam) { //emit Message::Clicked message directly case ControlType::MenuItem: case ControlType::Button: { - message(Message::Clicked, &control); + message(Message::Clicked, (uintptr_t)&control); } break; } @@ -84,7 +84,7 @@ long Window::wndproc(HWND hwnd, uint msg, WPARAM wparam, LPARAM lparam) { switch(control.type) { case ControlType::Slider: { - message(Message::Changed, &control); + message(Message::Changed, (uintptr_t)&control); } break; } @@ -104,12 +104,12 @@ long Window::wndproc(HWND hwnd, uint msg, WPARAM wparam, LPARAM lparam) { if(((LPNMLISTVIEW)lparam)->uChanged & LVIF_STATE) { if(ListView_GetItemState(listbox.hwnd, ((LPNMLISTVIEW)lparam)->iItem, LVIS_FOCUSED)) { if(ListView_GetItemState(listbox.hwnd, ((LPNMLISTVIEW)lparam)->iItem, LVIS_SELECTED)) { - message(Message::Changed, &control); + message(Message::Changed, (uintptr_t)&control); } } } } else if(((LPNMHDR)lparam)->code == LVN_ITEMACTIVATE) { - message(Message::DoubleClicked, &control); + message(Message::DoubleClicked, (uintptr_t)&control); } } break; diff --git a/src/ui/lui/event.cpp b/src/ui/lui/event.cpp index 4fca215a..18995993 100644 --- a/src/ui/lui/event.cpp +++ b/src/ui/lui/event.cpp @@ -1,12 +1,12 @@ -namespace event { - -void update_frame_counter() { - if(r_ppu->status.frames_updated) { - r_ppu->status.frames_updated = false; - if(bool(true) == true) { //TODO: add config file variable to toggle fps counter - window_main.set_text("%s [%d]", BSNES_TITLE, r_ppu->status.frames_executed); - } - } +namespace event { + +void update_frame_counter() { + if(r_ppu->status.frames_updated) { + r_ppu->status.frames_updated = false; + if(bool(true) == true) { //TODO: add config file variable to toggle fps counter + window_main.set_text("%s [%d]", BSNES_TITLE, r_ppu->status.frames_executed); + } + } } void update_video_settings() { @@ -57,7 +57,7 @@ stringarray dir; strcat(dir[0], dir[1]); } - return ui::file_load(window_main, fn, + return ui::file_load(&window_main, fn, "SNES images;*.smc,*.sfc,*.swc,*.fig,*.ufo,*.gd3,*.078,*.st" #if defined(GZIP_SUPPORT) ",*.gz,*.z,*.zip" @@ -70,7 +70,7 @@ stringarray dir; } void load_rom() { -char fn[4096]; +char fn[PATH_MAX]; if(load_rom(fn) == false)return; if(cartridge.loaded() == true)cartridge.unload(); @@ -81,8 +81,12 @@ char fn[4096]; } void unload_rom() { - cartridge.unload(); - uiAudio->clear_audio(); + if(cartridge.loaded() == true) { + cartridge.unload(); + uiVideo->clear_video(); + uiAudio->clear_audio(); + } + window_main.set_text(BSNES_TITLE); } void reset() { diff --git a/src/ui/lui/main.cpp b/src/ui/lui/main.cpp index a38fac38..84d81ccf 100644 --- a/src/ui/lui/main.cpp +++ b/src/ui/lui/main.cpp @@ -92,6 +92,13 @@ int main(int argc, char *argv[]) { init_snes(); ui_init(); + if(argc >= 2) { + cartridge.load_begin(Cartridge::CART_NORMAL); + cartridge.load(argv[1]); + cartridge.load_end(); + snes.power(); + } + while(_term_ == false) { while(ui::events_pending() == true) { ui::run(); } if(cartridge.loaded() == true) { @@ -100,7 +107,7 @@ int main(int argc, char *argv[]) { } } - if(cartridge.loaded() == true) { cartridge.unload(); } + event::unload_rom(); config_file.save(config::filename); term_snes(); diff --git a/src/ui/lui/settings/ui_advanced.cpp b/src/ui/lui/settings/ui_advanced.cpp index 9a7fd3a0..23f0cd9b 100644 --- a/src/ui/lui/settings/ui_advanced.cpp +++ b/src/ui/lui/settings/ui_advanced.cpp @@ -1,5 +1,6 @@ -int AdvancedWindow::message(uint id, void *param) { - if(id == ui::Message::Changed && param == &list) { +bool AdvancedWindow::message(uint id, uintptr_t param) { +ui::Control *control = (ui::Control*)param; + if(id == ui::Message::Changed && control == &list) { int pos = list.get_selection(); set_val.enable(pos >= 0); set_def.enable(pos >= 0); @@ -9,15 +10,15 @@ int AdvancedWindow::message(uint id, void *param) { config_file.list[pos]->get(val); edit_val.set_text("%s", strptr(val)); } - } else if(id == ui::Message::Clicked && param == &set_val) { + } else if(id == ui::Message::Clicked && control == &set_val) { char t[4096]; edit_val.get_text(t, sizeof(t)); update(list.get_selection(), t); - } else if(id == ui::Message::Clicked && param == &set_def) { + } else if(id == ui::Message::Clicked && control == &set_def) { update(list.get_selection(), 0); } - return 0; + return true; } void AdvancedWindow::read_config(uint pos, string &data) { diff --git a/src/ui/lui/settings/ui_advanced.h b/src/ui/lui/settings/ui_advanced.h index 564e6448..5799ba89 100644 --- a/src/ui/lui/settings/ui_advanced.h +++ b/src/ui/lui/settings/ui_advanced.h @@ -4,7 +4,7 @@ ui::Editbox desc; ui::Editbox edit_val; ui::Button set_val; ui::Button set_def; - int message(uint id, void *param); + bool message(uint id, uintptr_t param); void read_config(uint pos, string &data); void update(uint pos, const char *data); void setup(); diff --git a/src/ui/lui/settings/ui_cheateditor.cpp b/src/ui/lui/settings/ui_cheateditor.cpp index 86574a6d..55c82576 100644 --- a/src/ui/lui/settings/ui_cheateditor.cpp +++ b/src/ui/lui/settings/ui_cheateditor.cpp @@ -1,5 +1,5 @@ -int CheatEditorWindow::message(uint id, void *param) { - return 0; +bool CheatEditorWindow::message(uint id, uintptr_t param) { + return true; } void CheatEditorWindow::setup() { diff --git a/src/ui/lui/settings/ui_cheateditor.h b/src/ui/lui/settings/ui_cheateditor.h index 5f33c31b..075ed825 100644 --- a/src/ui/lui/settings/ui_cheateditor.h +++ b/src/ui/lui/settings/ui_cheateditor.h @@ -5,6 +5,6 @@ ui::Button toggle_code; ui::Button delete_code; ui::Editbox code; ui::Editbox desc; - int message(uint id, void *param); + bool message(uint id, uintptr_t param); void setup(); } window_cheat_editor; diff --git a/src/ui/lui/settings/ui_inputconfig.cpp b/src/ui/lui/settings/ui_inputconfig.cpp index b2028bbc..6e8ee15d 100644 --- a/src/ui/lui/settings/ui_inputconfig.cpp +++ b/src/ui/lui/settings/ui_inputconfig.cpp @@ -58,7 +58,7 @@ uint InputConfigWindow::get_value(uint index) { return keymap::none; } -void InputConfigWindow::set_value(uint index, uint value) { +void InputConfigWindow::set_value(uint index, uint16 value) { switch(index) { case 0: config::input.joypad1.up = keymap::find(value); break; case 1: config::input.joypad1.down = keymap::find(value); break; @@ -97,26 +97,27 @@ void InputConfigWindow::refresh_list() { list.autosize_columns(); } -int InputConfigWindow::message(uint id, void *param) { - if(id == ui::Message::Changed && param == &list) { +bool InputConfigWindow::message(uint id, uintptr_t param) { +ui::Control *control = (ui::Control*)param; + if(id == ui::Message::Changed && control == &list) { int pos = list.get_selection(); setkey.enable(pos >= 0); clrkey.enable(pos >= 0); - } else if((id == ui::Message::DoubleClicked && param == &list) || - (id == ui::Message::Clicked && param == &setkey)) { + } else if((id == ui::Message::DoubleClicked && control == &list) || + (id == ui::Message::Clicked && control == &setkey)) { int pos = list.get_selection(); - if(pos < 0) { return 0; } + if(pos < 0) { return true; } window_input_capture.index = pos; window_input_capture.label.set_text("Please press a key to assign to '%s' ...", list_index[pos]); window_input_capture.show(); window_input_capture.focus(); - } else if(id == ui::Message::Clicked && param == &clrkey) { + } else if(id == ui::Message::Clicked && control == &clrkey) { int pos = list.get_selection(); - if(pos < 0) { return 0; } + if(pos < 0) { return true; } set_value(pos, keymap::none); refresh_list(); } - return 0; + return true; } void InputConfigWindow::setup() { @@ -156,16 +157,20 @@ int x = 0, y = 0; // -int InputCaptureWindow::message(uint id, void *param) { +bool InputCaptureWindow::message(uint id, uintptr_t param) { if(id == ui::Message::Close) { hide(); return false; - } else if(id == ui::Message::KeyUp) { - hide(); - window_input_config.set_value(index, uint(param)); - window_input_config.refresh_list(); } - return 0; + + if(id == ui::Message::KeyUp) { + hide(); + window_input_config.set_value(index, param); + window_input_config.refresh_list(); + return true; + } + + return true; } void InputCaptureWindow::setup() { diff --git a/src/ui/lui/settings/ui_inputconfig.h b/src/ui/lui/settings/ui_inputconfig.h index dbe483bf..8d0f23a7 100644 --- a/src/ui/lui/settings/ui_inputconfig.h +++ b/src/ui/lui/settings/ui_inputconfig.h @@ -1,7 +1,7 @@ class InputCaptureWindow : public ui::Window { public: ui::Label label; uint index; - int message(uint id, void *param = 0); + bool message(uint id, uintptr_t param = 0); void setup(); InputCaptureWindow() : index(0) {} } window_input_capture; @@ -17,9 +17,9 @@ ui::Button clrkey; static const char list_index[][64]; - int message(uint id, void *param = 0); + bool message(uint id, uintptr_t param = 0); uint get_value(uint index); - void set_value(uint index, uint value); + void set_value(uint index, uint16 value); void refresh_list(); void setup(); } window_input_config; diff --git a/src/ui/lui/settings/ui_rastersettings.cpp b/src/ui/lui/settings/ui_rastersettings.cpp index ee94928d..d641ed00 100644 --- a/src/ui/lui/settings/ui_rastersettings.cpp +++ b/src/ui/lui/settings/ui_rastersettings.cpp @@ -1,49 +1,50 @@ -int RasterSettingsWindow::message(uint id, void *param) { +bool RasterSettingsWindow::message(uint id, uintptr_t param) { +ui::Control *control = (ui::Control*)param; if(id == ui::Message::Changed) { - if(param == &contrast) { + if(control == &contrast) { if(config::snes.contrast != contrast.get_position() - 96) { config::snes.contrast = contrast.get_position() - 96; lcontrast.set_text("Contrast: %d", int(config::snes.contrast)); snes.update_color_lookup_table(); } - } else if(param == &brightness) { + } else if(control == &brightness) { if(config::snes.brightness != brightness.get_position() - 96) { config::snes.brightness = brightness.get_position() - 96; lbrightness.set_text("Brightness: %d", int(config::snes.brightness)); snes.update_color_lookup_table(); } - } else if(param == &gamma) { + } else if(control == &gamma) { if(config::snes.gamma != gamma.get_position() + 10) { config::snes.gamma = gamma.get_position() + 10; lgamma.set_text("Gamma: %0.2f", double(config::snes.gamma) / 100.0); snes.update_color_lookup_table(); } } - return 0; + return true; } if(id == ui::Message::Clicked) { - if(param == &gamma_ramp) { + if(control == &gamma_ramp) { if(config::snes.gamma_ramp != gamma_ramp.checked()) { config::snes.gamma_ramp = gamma_ramp.checked(); snes.update_color_lookup_table(); } - } else if(param == &sepia) { + } else if(control == &sepia) { if(config::snes.sepia != sepia.checked()) { config::snes.sepia = sepia.checked(); snes.update_color_lookup_table(); } - } else if(param == &grayscale) { + } else if(control == &grayscale) { if(config::snes.grayscale != grayscale.checked()) { config::snes.grayscale = grayscale.checked(); snes.update_color_lookup_table(); } - } else if(param == &invert) { + } else if(control == &invert) { if(config::snes.invert != invert.checked()) { config::snes.invert = invert.checked(); snes.update_color_lookup_table(); } - } else if(param == &preset_optimal) { + } else if(control == &preset_optimal) { config::snes.contrast = 0; config::snes.brightness = 0; config::snes.gamma = 80; @@ -52,7 +53,7 @@ int RasterSettingsWindow::message(uint id, void *param) { config::snes.grayscale = false; config::snes.invert = false; sync_ui(); - } else if(param == &preset_standard) { + } else if(control == &preset_standard) { config::snes.contrast = 0; config::snes.brightness = 0; config::snes.gamma = 100; @@ -62,10 +63,10 @@ int RasterSettingsWindow::message(uint id, void *param) { config::snes.invert = false; sync_ui(); } - return 0; + return true; } - return 0; + return true; } //update all UI controls to match config file values ... diff --git a/src/ui/lui/settings/ui_rastersettings.h b/src/ui/lui/settings/ui_rastersettings.h index e87802ec..46e4ba4d 100644 --- a/src/ui/lui/settings/ui_rastersettings.h +++ b/src/ui/lui/settings/ui_rastersettings.h @@ -14,7 +14,7 @@ ui::Checkbox invert; ui::Button preset_optimal; ui::Button preset_standard; - int message(uint id, void *param); + bool message(uint id, uintptr_t param); void setup(); void sync_ui(); } window_raster_settings; diff --git a/src/ui/lui/settings/ui_settings.cpp b/src/ui/lui/settings/ui_settings.cpp index cbfcd331..4c830f78 100644 --- a/src/ui/lui/settings/ui_settings.cpp +++ b/src/ui/lui/settings/ui_settings.cpp @@ -3,7 +3,7 @@ void SettingsWindow::setup() { panel_list.create(*this, 0, 5, 5, 150, 355); panel_list.add_item("Raster Settings"); panel_list.add_item("Input Configuration"); -//panel_list.add_item("Cheat Code Editor"); + panel_list.add_item("Cheat Code Editor"); panel_list.add_item("Advanced"); panel.create(*this, 0, 160, 5, 475, 355); @@ -15,22 +15,22 @@ void SettingsWindow::show() { panel_list.focus(); } -int SettingsWindow::message(uint id, void *param) { +bool SettingsWindow::message(uint id, uintptr_t param) { if(id == ui::Message::Close) { hide(); return false; } - if(id == ui::Message::Changed && param == &panel_list) { + if(id == ui::Message::Changed && (ui::Control*)param == &panel_list) { switch(panel_list.get_selection()) { case 0: panel.attach(window_raster_settings); break; case 1: panel.attach(window_input_config); break; - //case 2: panel.attach(window_cheat_editor); break; - case 2: panel.attach(window_advanced); break; + case 2: panel.attach(window_cheat_editor); break; + case 3: panel.attach(window_advanced); break; } panel_list.focus(); - return 0; + return true; } - return 0; + return true; } diff --git a/src/ui/lui/settings/ui_settings.h b/src/ui/lui/settings/ui_settings.h index 0b150fd3..ff6b9eab 100644 --- a/src/ui/lui/settings/ui_settings.h +++ b/src/ui/lui/settings/ui_settings.h @@ -1,7 +1,7 @@ class SettingsWindow : public ui::Window { public: ui::Listbox panel_list; ui::Panel panel; - int message(uint id, void *param); + bool message(uint id, uintptr_t param = 0); void show(); void setup(); } window_settings; diff --git a/src/ui/lui/ui_about.cpp b/src/ui/lui/ui_about.cpp index 04e674fc..39fe2e7e 100644 --- a/src/ui/lui/ui_about.cpp +++ b/src/ui/lui/ui_about.cpp @@ -13,11 +13,11 @@ void AboutWindow::setup() { about.create(*this, 0, 5, 5, 290, 120, about_text); } -int AboutWindow::message(uint id, void *param) { +bool AboutWindow::message(uint id, uintptr_t param) { if(id == ui::Message::Close) { hide(); return false; } - return 0; + return true; } diff --git a/src/ui/lui/ui_about.h b/src/ui/lui/ui_about.h index 33be0f1b..3b8075ed 100644 --- a/src/ui/lui/ui_about.h +++ b/src/ui/lui/ui_about.h @@ -1,6 +1,6 @@ class AboutWindow : public ui::Window { public: ui::Label about; static const char about_text[4096]; - int message(uint id, void *param); + bool message(uint id, uintptr_t param); void setup(); } window_about; diff --git a/src/ui/lui/ui_main.cpp b/src/ui/lui/ui_main.cpp index 20235a77..8aada0e8 100644 --- a/src/ui/lui/ui_main.cpp +++ b/src/ui/lui/ui_main.cpp @@ -1,4 +1,5 @@ -int MainWindow::message(uint id, void *param) { +bool MainWindow::message(uint id, uintptr_t param) { +ui::Control *control = (ui::Control*)param; if(id == ui::Message::Close) { _term_ = true; hide(); @@ -7,100 +8,101 @@ int MainWindow::message(uint id, void *param) { if(id == ui::Message::Block) { if(uiAudio) { uiAudio->clear_audio(); } + return true; } if(id == ui::Message::KeyDown) { - if(uiInput) { uiInput->signal_key_down((int)param); } - return 0; + if(uiInput) { uiInput->signal_key_down(param); } + return true; } if(id == ui::Message::KeyUp) { - if(uiInput) { uiInput->signal_key_up((int)param); } - return 0; + if(uiInput) { uiInput->signal_key_up(param); } + return true; } if(id == ui::Message::Clicked) { - if(param == &menu_file_load) { + if(control == &menu_file_load) { event::load_rom(); } - if(param == &menu_file_unload) { + if(control == &menu_file_unload) { event::unload_rom(); } - if(param == &menu_file_reset) { + if(control == &menu_file_reset) { event::reset(); } - if(param == &menu_file_power) { + if(control == &menu_file_power) { event::power(); } - if(param == &menu_file_exit) { + if(control == &menu_file_exit) { message(ui::Message::Close); } - if(param == &menu_settings_videomode_1x) { config::video.multiplier = 1; event::update_video_settings(); } - if(param == &menu_settings_videomode_2x) { config::video.multiplier = 2; event::update_video_settings(); } - if(param == &menu_settings_videomode_3x) { config::video.multiplier = 3; event::update_video_settings(); } - if(param == &menu_settings_videomode_4x) { config::video.multiplier = 4; event::update_video_settings(); } - if(param == &menu_settings_videomode_5x) { config::video.multiplier = 5; event::update_video_settings(); } + if(control == &menu_settings_videomode_1x) { config::video.multiplier = 1; event::update_video_settings(); } + if(control == &menu_settings_videomode_2x) { config::video.multiplier = 2; event::update_video_settings(); } + if(control == &menu_settings_videomode_3x) { config::video.multiplier = 3; event::update_video_settings(); } + if(control == &menu_settings_videomode_4x) { config::video.multiplier = 4; event::update_video_settings(); } + if(control == &menu_settings_videomode_5x) { config::video.multiplier = 5; event::update_video_settings(); } - if(param == &menu_settings_videomode_aspect_correction) { + if(control == &menu_settings_videomode_aspect_correction) { config::video.aspect_correction = menu_settings_videomode_aspect_correction.checked(); event::update_video_settings(); } - if(param == &menu_settings_videomode_ntsc) { config::video.region = 0; event::update_raster_settings(); event::update_video_settings(); } - if(param == &menu_settings_videomode_pal) { config::video.region = 1; event::update_raster_settings(); event::update_video_settings(); } + if(control == &menu_settings_videomode_ntsc) { config::video.region = 0; event::update_raster_settings(); event::update_video_settings(); } + if(control == &menu_settings_videomode_pal) { config::video.region = 1; event::update_raster_settings(); event::update_video_settings(); } - if(param == &menu_settings_videofilter_hwpoint) { config::video.hardware_filter = 0; uiVideo->update_hardware_filter(); } - if(param == &menu_settings_videofilter_hwlinear) { config::video.hardware_filter = 1; uiVideo->update_hardware_filter(); } + if(control == &menu_settings_videofilter_hwpoint) { config::video.hardware_filter = 0; uiVideo->update_hardware_filter(); } + if(control == &menu_settings_videofilter_hwlinear) { config::video.hardware_filter = 1; uiVideo->update_hardware_filter(); } - if(param == &menu_settings_videofilter_swnone) { config::video.software_filter = 0; event::update_raster_settings(); } - if(param == &menu_settings_videofilter_swntsc) { config::video.software_filter = 1; event::update_raster_settings(); } - if(param == &menu_settings_videofilter_swhq2x) { config::video.software_filter = 2; event::update_raster_settings(); } - if(param == &menu_settings_videofilter_swscale2x) { config::video.software_filter = 3; event::update_raster_settings(); } + if(control == &menu_settings_videofilter_swnone) { config::video.software_filter = 0; event::update_raster_settings(); } + if(control == &menu_settings_videofilter_swntsc) { config::video.software_filter = 1; event::update_raster_settings(); } + if(control == &menu_settings_videofilter_swhq2x) { config::video.software_filter = 2; event::update_raster_settings(); } + if(control == &menu_settings_videofilter_swscale2x) { config::video.software_filter = 3; event::update_raster_settings(); } - if(param == &menu_settings_videoframeskip_0) { config::video.frameskip = 0; } - if(param == &menu_settings_videoframeskip_1) { config::video.frameskip = 1; } - if(param == &menu_settings_videoframeskip_2) { config::video.frameskip = 2; } - if(param == &menu_settings_videoframeskip_3) { config::video.frameskip = 3; } - if(param == &menu_settings_videoframeskip_4) { config::video.frameskip = 4; } - if(param == &menu_settings_videoframeskip_5) { config::video.frameskip = 5; } - if(param == &menu_settings_videoframeskip_6) { config::video.frameskip = 6; } - if(param == &menu_settings_videoframeskip_7) { config::video.frameskip = 7; } - if(param == &menu_settings_videoframeskip_8) { config::video.frameskip = 8; } - if(param == &menu_settings_videoframeskip_9) { config::video.frameskip = 9; } + if(control == &menu_settings_videoframeskip_0) { config::video.frameskip = 0; } + if(control == &menu_settings_videoframeskip_1) { config::video.frameskip = 1; } + if(control == &menu_settings_videoframeskip_2) { config::video.frameskip = 2; } + if(control == &menu_settings_videoframeskip_3) { config::video.frameskip = 3; } + if(control == &menu_settings_videoframeskip_4) { config::video.frameskip = 4; } + if(control == &menu_settings_videoframeskip_5) { config::video.frameskip = 5; } + if(control == &menu_settings_videoframeskip_6) { config::video.frameskip = 6; } + if(control == &menu_settings_videoframeskip_7) { config::video.frameskip = 7; } + if(control == &menu_settings_videoframeskip_8) { config::video.frameskip = 8; } + if(control == &menu_settings_videoframeskip_9) { config::video.frameskip = 9; } - if(param == &menu_settings_mute) { + if(control == &menu_settings_mute) { config::snes.mute = menu_settings_mute.checked(); } - if(param == &menu_settings_speedreg_enable) { + if(control == &menu_settings_speedreg_enable) { config::system.regulate_speed = menu_settings_speedreg_enable.checked(); } - if(param == &menu_settings_speedreg_slowest) { config::system.speed = 1; uiAudio->update_frequency(); } - if(param == &menu_settings_speedreg_slow) { config::system.speed = 2; uiAudio->update_frequency(); } - if(param == &menu_settings_speedreg_normal) { config::system.speed = 3; uiAudio->update_frequency(); } - if(param == &menu_settings_speedreg_fast) { config::system.speed = 4; uiAudio->update_frequency(); } - if(param == &menu_settings_speedreg_fastest) { config::system.speed = 5; uiAudio->update_frequency(); } + if(control == &menu_settings_speedreg_slowest) { config::system.speed = 1; uiAudio->update_frequency(); } + if(control == &menu_settings_speedreg_slow) { config::system.speed = 2; uiAudio->update_frequency(); } + if(control == &menu_settings_speedreg_normal) { config::system.speed = 3; uiAudio->update_frequency(); } + if(control == &menu_settings_speedreg_fast) { config::system.speed = 4; uiAudio->update_frequency(); } + if(control == &menu_settings_speedreg_fastest) { config::system.speed = 5; uiAudio->update_frequency(); } - if(param == &menu_settings_config) { window_settings.show(); } + if(control == &menu_settings_config) { window_settings.show(); } - if(param == &menu_misc_logaudio) { + if(control == &menu_misc_logaudio) { (menu_misc_logaudio.checked() == true) ? snes.log_audio_enable() : snes.log_audio_disable(); } - if(param == &menu_misc_about) { + if(control == &menu_misc_about) { window_about.focus(); } - return 0; + return true; } - return 0; + return true; } void MainWindow::setup() { diff --git a/src/ui/lui/ui_main.h b/src/ui/lui/ui_main.h index e4410a70..d0289eb9 100644 --- a/src/ui/lui/ui_main.h +++ b/src/ui/lui/ui_main.h @@ -60,7 +60,7 @@ ui::MenuGroup menu_misc; ui::Container view; // - int message(uint id, void *param = 0); + bool message(uint id, uintptr_t param = 0); void setup(); void setup_menu(); } window_main;