diff --git a/bsnes.exe b/bsnes.exe new file mode 100644 index 00000000..42205172 Binary files /dev/null and b/bsnes.exe differ diff --git a/snesreader.dll b/snesreader.dll new file mode 100644 index 00000000..c9ac6a62 Binary files /dev/null and b/snesreader.dll differ diff --git a/src/base.hpp b/src/base.hpp index d0ae4b89..33397c4a 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -1,4 +1,4 @@ -static const char bsnesVersion[] = "062.07"; +static const char bsnesVersion[] = "062.08"; static const char bsnesTitle[] = "bsnes"; static const unsigned bsnesSerializerVersion = 8; diff --git a/src/cpu/core/core.hpp b/src/cpu/core/core.hpp index 71304ebf..6d1314aa 100644 --- a/src/cpu/core/core.hpp +++ b/src/cpu/core/core.hpp @@ -174,8 +174,6 @@ public: template void op_transfer_w(); void op_tcs_e(); void op_tcs_n(); - void op_tsc_e(); - void op_tsc_n(); void op_tsx_b(); void op_tsx_w(); void op_txs_e(); diff --git a/src/cpu/core/opcode_misc.cpp b/src/cpu/core/opcode_misc.cpp index 354082a5..8087fe66 100644 --- a/src/cpu/core/opcode_misc.cpp +++ b/src/cpu/core/opcode_misc.cpp @@ -153,20 +153,6 @@ L op_io_irq(); regs.s.w = regs.a.w; } -void CPUcore::op_tsc_e() { -L op_io_irq(); - regs.a.w = regs.s.w; - regs.p.n = (regs.a.l & 0x80); - regs.p.z = (regs.a.l == 0); -} - -void CPUcore::op_tsc_n() { -L op_io_irq(); - regs.a.w = regs.s.w; - regs.p.n = (regs.a.w & 0x8000); - regs.p.z = (regs.a.w == 0); -} - void CPUcore::op_tsx_b() { L op_io_irq(); regs.x.l = regs.s.l; diff --git a/src/cpu/core/table.cpp b/src/cpu/core/table.cpp index 2ed22be7..6575a4db 100644 --- a/src/cpu/core/table.cpp +++ b/src/cpu/core/table.cpp @@ -76,7 +76,7 @@ void CPUcore::initialize_opcode_table() { opAII(0x38, flag, 0x01, 0x01) opMF (0x39, read_addry, and) opMII(0x3a, adjust_imm, A, -1) - opE (0x3b, tsc) + opAII(0x3b, transfer_w, S, A) opMF (0x3c, read_addrx, bit) opMF (0x3d, read_addrx, and) opMF (0x3e, adjust_addrx, rol) diff --git a/src/lib/nall/function.hpp b/src/lib/nall/function.hpp index 58fe349f..24f698ce 100644 --- a/src/lib/nall/function.hpp +++ b/src/lib/nall/function.hpp @@ -1,190 +1,88 @@ #ifndef NALL_FUNCTION_HPP #define NALL_FUNCTION_HPP -#include - -//prologue - -#define TN typename - namespace nall { template class function; -} -//parameters = 0 - -#define cat(n) n -#define TL typename R -#define PL -#define CL - -#include "function.hpp" - -//parameters = 1 - -#define cat(n) , n -#define TL TN R, TN P1 -#define PL P1 p1 -#define CL p1 - -#include "function.hpp" - -//parameters = 2 - -#define cat(n) , n -#define TL TN R, TN P1, TN P2 -#define PL P1 p1, P2 p2 -#define CL p1, p2 - -#include "function.hpp" - -//parameters = 3 - -#define cat(n) , n -#define TL TN R, TN P1, TN P2, TN P3 -#define PL P1 p1, P2 p2, P3 p3 -#define CL p1, p2, p3 - -#include "function.hpp" - -//parameters = 4 - -#define cat(n) , n -#define TL TN R, TN P1, TN P2, TN P3, TN P4 -#define PL P1 p1, P2 p2, P3 p3, P4 p4 -#define CL p1, p2, p3, p4 - -#include "function.hpp" - -//parameters = 5 - -#define cat(n) , n -#define TL TN R, TN P1, TN P2, TN P3, TN P4, TN P5 -#define PL P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 -#define CL p1, p2, p3, p4, p5 - -#include "function.hpp" - -//parameters = 6 - -#define cat(n) , n -#define TL TN R, TN P1, TN P2, TN P3, TN P4, TN P5, TN P6 -#define PL P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6 -#define CL p1, p2, p3, p4, p5, p6 - -#include "function.hpp" - -//parameters = 7 - -#define cat(n) , n -#define TL TN R, TN P1, TN P2, TN P3, TN P4, TN P5, TN P6, TN P7 -#define PL P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7 -#define CL p1, p2, p3, p4, p5, p6, p7 - -#include "function.hpp" - -//parameters = 8 - -#define cat(n) , n -#define TL TN R, TN P1, TN P2, TN P3, TN P4, TN P5, TN P6, TN P7, TN P8 -#define PL P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8 -#define CL p1, p2, p3, p4, p5, p6, p7, p8 - -#include "function.hpp" - -//epilogue - -#undef TN -#define NALL_FUNCTION_T - -#elif !defined(NALL_FUNCTION_T) - -//function implementation template class - -namespace nall { - template - class function { + template + class function { private: - struct base1 { virtual void func1(PL) {} }; - struct base2 { virtual void func2(PL) {} }; + struct base1 { virtual void func1(P...) {} }; + struct base2 { virtual void func2(P...) {} }; struct derived : base1, virtual base2 {}; struct data_t { - R (*fn_call)(const data_t& cat(PL)); + R (*callback)(const data_t&, P...); union { - R (*fn_global)(PL); + R (*callback_global)(P...); struct { - R (derived::*fn_member)(PL); + R (derived::*callback_member)(P...); void *object; }; }; } data; - static R fn_call_global(const data_t &d cat(PL)) { - return d.fn_global(CL); + static R callback_global(const data_t &data, P... p) { + return data.callback_global(p...); } template - static R fn_call_member(const data_t &d cat(PL)) { - return (((C*)d.object)->*((R (C::*&)(PL))d.fn_member))(CL); + static R callback_member(const data_t &data, P... p) { + return (((C*)data.object)->*((R (C::*&)(P...))data.callback_member))(p...); } public: - R operator()(PL) const { return data.fn_call(data cat(CL)); } - operator bool() const { return data.fn_call; } + R operator()(P... p) const { return data.callback(data, p...); } + operator bool() const { return data.callback; } - function() { data.fn_call = 0; } - - function(void *fn) { - data.fn_call = fn ? &fn_call_global : 0; - data.fn_global = (R (*)(PL))fn; - } - - function(R (*fn)(PL)) { - data.fn_call = &fn_call_global; - data.fn_global = fn; - } - - template - function(R (C::*fn)(PL), C *obj) { - data.fn_call = &fn_call_member; - (R (C::*&)(PL))data.fn_member = fn; - assert(sizeof data.fn_member >= sizeof fn); - data.object = obj; - } - - template - function(R (C::*fn)(PL) const, C *obj) { - data.fn_call = &fn_call_member; - (R (C::*&)(PL))data.fn_member = (R (C::*&)(PL))fn; - assert(sizeof data.fn_member >= sizeof fn); - data.object = obj; - } - - function& operator=(void *fn) { return operator=(function(fn)); } function& operator=(const function &source) { memcpy(&data, &source.data, sizeof(data_t)); return *this; } - function(const function &source) { memcpy(&data, &source.data, sizeof(data_t)); } + function(const function &source) { operator=(source); } + + function() { + data.callback = 0; + } + + function(void *callback) { + data.callback = callback ? &callback_global : 0; + data.callback_global = (R (*)(P...))callback; + } + + function(R (*callback)(P...)) { + data.callback = &callback_global; + data.callback_global = callback; + } + + template + function(R (C::*callback)(P...), C *object) { + static_assert(sizeof data.callback_member >= sizeof callback, "callback_member is too small"); + data.callback = &callback_member; + (R (C::*&)(P...))data.callback_member = callback; + data.object = object; + } + + template + function(R (C::*callback)(P...) const, C *object) { + static_assert(sizeof data.callback_member >= sizeof callback, "callback_member is too small"); + data.callback = &callback_member; + (R (C::*&)(P...))data.callback_member = (R (C::*&)(P...))callback; + data.object = object; + } }; - template - function bind(R (*fn)(PL)) { - return function(fn); + template + function bind(R (*callback)(P...)) { + return function(callback); } - template - function bind(R (C::*fn)(PL), C *obj) { - return function(fn, obj); + template + function bind(R (C::*callback)(P...), C *object) { + return function(callback, object); } - template - function bind(R (C::*fn)(PL) const, C *obj) { - return function(fn, obj); + template + function bind(R (C::*callback)(P...) const, C *object) { + return function(callback, object); } } -#undef cat -#undef TL -#undef PL -#undef CL - #endif