From 3adabb8bf32d483f57195e43401c7da57d4b3ffe Mon Sep 17 00:00:00 2001 From: Sharpy Date: Wed, 12 Jul 2017 16:01:59 +0100 Subject: [PATCH] Revert "Revert "awjackson"" --- bsnes/nall/input.hpp | 33 ++++++++++++--------------------- bsnes/snes/alt/dsp/SPC_DSP.cpp | 3 ++- bsnes/snes/dsp/dsp.cpp | 1 + snesfilter/nall/input.hpp | 33 ++++++++++++--------------------- snesreader/nall/input.hpp | 33 ++++++++++++--------------------- supergameboy/nall/input.hpp | 33 ++++++++++++--------------------- 6 files changed, 51 insertions(+), 85 deletions(-) diff --git a/bsnes/nall/input.hpp b/bsnes/nall/input.hpp index 1fd680f..4b4b79b 100644 --- a/bsnes/nall/input.hpp +++ b/bsnes/nall/input.hpp @@ -11,7 +11,7 @@ namespace nall { struct Keyboard; -Keyboard& keyboard(unsigned = 0); +Keyboard keyboard(unsigned = 0); static const char KeyboardScancodeName[][64] = { "Escape", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", @@ -122,12 +122,9 @@ struct Keyboard { Keyboard(unsigned ID_) : ID(ID_) {} }; -inline Keyboard& keyboard(unsigned id) { - static Keyboard kb0(0), kb1(1), kb2(2), kb3(3), kb4(4), kb5(5), kb6(6), kb7(7); - switch(id) { default: - case 0: return kb0; case 1: return kb1; case 2: return kb2; case 3: return kb3; - case 4: return kb4; case 5: return kb5; case 6: return kb6; case 7: return kb7; - } +inline Keyboard keyboard(unsigned id) { + assert(id < Keyboard::Count); + return Keyboard(id); } static const char MouseScancodeName[][64] = { @@ -136,7 +133,7 @@ static const char MouseScancodeName[][64] = { }; struct Mouse; -Mouse& mouse(unsigned = 0); +Mouse mouse(unsigned = 0); struct Mouse { const unsigned ID; @@ -220,12 +217,9 @@ struct Mouse { Mouse(unsigned ID_) : ID(ID_) {} }; -inline Mouse& mouse(unsigned id) { - static Mouse ms0(0), ms1(1), ms2(2), ms3(3), ms4(4), ms5(5), ms6(6), ms7(7); - switch(id) { default: - case 0: return ms0; case 1: return ms1; case 2: return ms2; case 3: return ms3; - case 4: return ms4; case 5: return ms5; case 6: return ms6; case 7: return ms7; - } +inline Mouse mouse(unsigned id) { + assert(id < Mouse::Count); + return Mouse(id); } static const char JoypadScancodeName[][64] = { @@ -239,7 +233,7 @@ static const char JoypadScancodeName[][64] = { }; struct Joypad; -Joypad& joypad(unsigned = 0); +Joypad joypad(unsigned = 0); struct Joypad { const unsigned ID; @@ -345,12 +339,9 @@ struct Joypad { Joypad(unsigned ID_) : ID(ID_) {} }; -inline Joypad& joypad(unsigned id) { - static Joypad jp0(0), jp1(1), jp2(2), jp3(3), jp4(4), jp5(5), jp6(6), jp7(7); - switch(id) { default: - case 0: return jp0; case 1: return jp1; case 2: return jp2; case 3: return jp3; - case 4: return jp4; case 5: return jp5; case 6: return jp6; case 7: return jp7; - } +inline Joypad joypad(unsigned id) { + assert(id < Joypad::Count); + return Joypad(id); } struct Scancode { diff --git a/bsnes/snes/alt/dsp/SPC_DSP.cpp b/bsnes/snes/alt/dsp/SPC_DSP.cpp index b012140..9b64e48 100644 --- a/bsnes/snes/alt/dsp/SPC_DSP.cpp +++ b/bsnes/snes/alt/dsp/SPC_DSP.cpp @@ -40,7 +40,7 @@ static BOOST::uint8_t const initial_regs [SPC_DSP::register_count] = 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00, // 0x45,0x8B,0x5A,0x9A,0xE4,0x82,0x1B,0x78,0x00,0x00,0xAA,0x96,0x89,0x0E,0xE0,0x80, // 0x2A,0x49,0x3D,0xBA,0x14,0xA0,0xAC,0xC5,0x00,0x00,0x51,0xBB,0x9C,0x4E,0x7B,0xFF, @@ -856,6 +856,7 @@ void SPC_DSP::soft_reset_common() void SPC_DSP::soft_reset() { REG(flg) = 0xE0; + REG(endx) = 0xFF; soft_reset_common(); } diff --git a/bsnes/snes/dsp/dsp.cpp b/bsnes/snes/dsp/dsp.cpp index 38b2c2f..9ba446d 100644 --- a/bsnes/snes/dsp/dsp.cpp +++ b/bsnes/snes/dsp/dsp.cpp @@ -337,6 +337,7 @@ void DSP::reset() { #endif REG(flg) = 0xe0; + REG(endx) = 0xff; state.noise = 0x4000; state.echo_hist_pos = 0; diff --git a/snesfilter/nall/input.hpp b/snesfilter/nall/input.hpp index 83c4a48..a104883 100644 --- a/snesfilter/nall/input.hpp +++ b/snesfilter/nall/input.hpp @@ -11,7 +11,7 @@ namespace nall { struct Keyboard; -Keyboard& keyboard(unsigned = 0); +Keyboard keyboard(unsigned = 0); static const char KeyboardScancodeName[][64] = { "Escape", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", @@ -122,12 +122,9 @@ struct Keyboard { Keyboard(unsigned ID_) : ID(ID_) {} }; -inline Keyboard& keyboard(unsigned id) { - static Keyboard kb0(0), kb1(1), kb2(2), kb3(3), kb4(4), kb5(5), kb6(6), kb7(7); - switch(id) { default: - case 0: return kb0; case 1: return kb1; case 2: return kb2; case 3: return kb3; - case 4: return kb4; case 5: return kb5; case 6: return kb6; case 7: return kb7; - } +inline Keyboard keyboard(unsigned id) { + assert(id < Keyboard::Count); + return Keyboard(id); } static const char MouseScancodeName[][64] = { @@ -136,7 +133,7 @@ static const char MouseScancodeName[][64] = { }; struct Mouse; -Mouse& mouse(unsigned = 0); +Mouse mouse(unsigned = 0); struct Mouse { const unsigned ID; @@ -220,12 +217,9 @@ struct Mouse { Mouse(unsigned ID_) : ID(ID_) {} }; -inline Mouse& mouse(unsigned id) { - static Mouse ms0(0), ms1(1), ms2(2), ms3(3), ms4(4), ms5(5), ms6(6), ms7(7); - switch(id) { default: - case 0: return ms0; case 1: return ms1; case 2: return ms2; case 3: return ms3; - case 4: return ms4; case 5: return ms5; case 6: return ms6; case 7: return ms7; - } +inline Mouse mouse(unsigned id) { + assert(id < Mouse::Count); + return Mouse(id); } static const char JoypadScancodeName[][64] = { @@ -239,7 +233,7 @@ static const char JoypadScancodeName[][64] = { }; struct Joypad; -Joypad& joypad(unsigned = 0); +Joypad joypad(unsigned = 0); struct Joypad { const unsigned ID; @@ -345,12 +339,9 @@ struct Joypad { Joypad(unsigned ID_) : ID(ID_) {} }; -inline Joypad& joypad(unsigned id) { - static Joypad jp0(0), jp1(1), jp2(2), jp3(3), jp4(4), jp5(5), jp6(6), jp7(7); - switch(id) { default: - case 0: return jp0; case 1: return jp1; case 2: return jp2; case 3: return jp3; - case 4: return jp4; case 5: return jp5; case 6: return jp6; case 7: return jp7; - } +inline Joypad joypad(unsigned id) { + assert(id < Joypad::Count); + return Joypad(id); } struct Scancode { diff --git a/snesreader/nall/input.hpp b/snesreader/nall/input.hpp index 83c4a48..a104883 100644 --- a/snesreader/nall/input.hpp +++ b/snesreader/nall/input.hpp @@ -11,7 +11,7 @@ namespace nall { struct Keyboard; -Keyboard& keyboard(unsigned = 0); +Keyboard keyboard(unsigned = 0); static const char KeyboardScancodeName[][64] = { "Escape", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", @@ -122,12 +122,9 @@ struct Keyboard { Keyboard(unsigned ID_) : ID(ID_) {} }; -inline Keyboard& keyboard(unsigned id) { - static Keyboard kb0(0), kb1(1), kb2(2), kb3(3), kb4(4), kb5(5), kb6(6), kb7(7); - switch(id) { default: - case 0: return kb0; case 1: return kb1; case 2: return kb2; case 3: return kb3; - case 4: return kb4; case 5: return kb5; case 6: return kb6; case 7: return kb7; - } +inline Keyboard keyboard(unsigned id) { + assert(id < Keyboard::Count); + return Keyboard(id); } static const char MouseScancodeName[][64] = { @@ -136,7 +133,7 @@ static const char MouseScancodeName[][64] = { }; struct Mouse; -Mouse& mouse(unsigned = 0); +Mouse mouse(unsigned = 0); struct Mouse { const unsigned ID; @@ -220,12 +217,9 @@ struct Mouse { Mouse(unsigned ID_) : ID(ID_) {} }; -inline Mouse& mouse(unsigned id) { - static Mouse ms0(0), ms1(1), ms2(2), ms3(3), ms4(4), ms5(5), ms6(6), ms7(7); - switch(id) { default: - case 0: return ms0; case 1: return ms1; case 2: return ms2; case 3: return ms3; - case 4: return ms4; case 5: return ms5; case 6: return ms6; case 7: return ms7; - } +inline Mouse mouse(unsigned id) { + assert(id < Mouse::Count); + return Mouse(id); } static const char JoypadScancodeName[][64] = { @@ -239,7 +233,7 @@ static const char JoypadScancodeName[][64] = { }; struct Joypad; -Joypad& joypad(unsigned = 0); +Joypad joypad(unsigned = 0); struct Joypad { const unsigned ID; @@ -345,12 +339,9 @@ struct Joypad { Joypad(unsigned ID_) : ID(ID_) {} }; -inline Joypad& joypad(unsigned id) { - static Joypad jp0(0), jp1(1), jp2(2), jp3(3), jp4(4), jp5(5), jp6(6), jp7(7); - switch(id) { default: - case 0: return jp0; case 1: return jp1; case 2: return jp2; case 3: return jp3; - case 4: return jp4; case 5: return jp5; case 6: return jp6; case 7: return jp7; - } +inline Joypad joypad(unsigned id) { + assert(id < Joypad::Count); + return Joypad(id); } struct Scancode { diff --git a/supergameboy/nall/input.hpp b/supergameboy/nall/input.hpp index 1fd680f..4b4b79b 100644 --- a/supergameboy/nall/input.hpp +++ b/supergameboy/nall/input.hpp @@ -11,7 +11,7 @@ namespace nall { struct Keyboard; -Keyboard& keyboard(unsigned = 0); +Keyboard keyboard(unsigned = 0); static const char KeyboardScancodeName[][64] = { "Escape", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", @@ -122,12 +122,9 @@ struct Keyboard { Keyboard(unsigned ID_) : ID(ID_) {} }; -inline Keyboard& keyboard(unsigned id) { - static Keyboard kb0(0), kb1(1), kb2(2), kb3(3), kb4(4), kb5(5), kb6(6), kb7(7); - switch(id) { default: - case 0: return kb0; case 1: return kb1; case 2: return kb2; case 3: return kb3; - case 4: return kb4; case 5: return kb5; case 6: return kb6; case 7: return kb7; - } +inline Keyboard keyboard(unsigned id) { + assert(id < Keyboard::Count); + return Keyboard(id); } static const char MouseScancodeName[][64] = { @@ -136,7 +133,7 @@ static const char MouseScancodeName[][64] = { }; struct Mouse; -Mouse& mouse(unsigned = 0); +Mouse mouse(unsigned = 0); struct Mouse { const unsigned ID; @@ -220,12 +217,9 @@ struct Mouse { Mouse(unsigned ID_) : ID(ID_) {} }; -inline Mouse& mouse(unsigned id) { - static Mouse ms0(0), ms1(1), ms2(2), ms3(3), ms4(4), ms5(5), ms6(6), ms7(7); - switch(id) { default: - case 0: return ms0; case 1: return ms1; case 2: return ms2; case 3: return ms3; - case 4: return ms4; case 5: return ms5; case 6: return ms6; case 7: return ms7; - } +inline Mouse mouse(unsigned id) { + assert(id < Mouse::Count); + return Mouse(id); } static const char JoypadScancodeName[][64] = { @@ -239,7 +233,7 @@ static const char JoypadScancodeName[][64] = { }; struct Joypad; -Joypad& joypad(unsigned = 0); +Joypad joypad(unsigned = 0); struct Joypad { const unsigned ID; @@ -345,12 +339,9 @@ struct Joypad { Joypad(unsigned ID_) : ID(ID_) {} }; -inline Joypad& joypad(unsigned id) { - static Joypad jp0(0), jp1(1), jp2(2), jp3(3), jp4(4), jp5(5), jp6(6), jp7(7); - switch(id) { default: - case 0: return jp0; case 1: return jp1; case 2: return jp2; case 3: return jp3; - case 4: return jp4; case 5: return jp5; case 6: return jp6; case 7: return jp7; - } +inline Joypad joypad(unsigned id) { + assert(id < Joypad::Count); + return Joypad(id); } struct Scancode {