Skip to content

Commit

Permalink
fix crash with sa1 ram exposure
Browse files Browse the repository at this point in the history
  • Loading branch information
CasualPokePlayer committed Oct 1, 2024
1 parent f9d4737 commit 5ad12db
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
Binary file modified Assets/dll/libsnes.wbx.zst
Binary file not shown.
1 change: 1 addition & 0 deletions waterbox/libsnes/bsnes/snes/chip/sa1/sa1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ void SA1::trigger_irq() {
}

void SA1::init() {
iram.init();
}

void SA1::load() {
Expand Down
6 changes: 4 additions & 2 deletions waterbox/libsnes/bsnes/snes/memory/memory-inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ void StaticRAM::write(unsigned addr, uint8 n) { data_[addr] = n; }
uint8& StaticRAM::operator[](unsigned addr) { return data_[addr]; }
const uint8& StaticRAM::operator[](unsigned addr) const { return data_[addr]; }

StaticRAM::StaticRAM(unsigned n, const char* name) : size_(n) {
if(name) data_ = (uint8*)interface()->allocSharedMemory(name, size_);
StaticRAM::StaticRAM(unsigned n, const char* name) : size_(n), name_(name) {
if(name_) data_ = nullptr; // data_ alloc must be deferred (static ctor is not in a cothread!)
else data_ = new uint8[size_]();
}
StaticRAM::~StaticRAM() { abort(); }

void StaticRAM::init() { if(name_ && !data_) data_ = (uint8*)interface()->allocSharedMemory(name_, size_); }

//MappedRAM

void MappedRAM::reset() {
Expand Down
3 changes: 3 additions & 0 deletions waterbox/libsnes/bsnes/snes/memory/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ struct StaticRAM : Memory {
inline StaticRAM(unsigned size, const char* name = NULL);
inline ~StaticRAM();

inline void init();

private:
uint8 *data_;
unsigned size_;
const char* name_;
};

struct MappedRAM : Memory {
Expand Down

0 comments on commit 5ad12db

Please sign in to comment.