From dd4556e4e1c6861125968d5bf5ea097c4cdbb2c8 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Fri, 13 Oct 2017 10:53:19 -0500 Subject: [PATCH] Add custom new to GBA build --- src/nostalgia/core/CMakeLists.txt | 1 + src/nostalgia/core/gba/mem.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/nostalgia/core/gba/mem.cpp diff --git a/src/nostalgia/core/CMakeLists.txt b/src/nostalgia/core/CMakeLists.txt index 9439d4c0..62546d1c 100644 --- a/src/nostalgia/core/CMakeLists.txt +++ b/src/nostalgia/core/CMakeLists.txt @@ -6,6 +6,7 @@ if(NOSTALGIA_BUILD_TYPE STREQUAL "GBA") CPP gba/gfx.cpp gba/media.cpp + gba/mem.cpp ) elseif(NOSTALGIA_BUILD_TYPE STREQUAL "Native") set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/src/nostalgia/core/gba/mem.cpp b/src/nostalgia/core/gba/mem.cpp new file mode 100644 index 00000000..3483927b --- /dev/null +++ b/src/nostalgia/core/gba/mem.cpp @@ -0,0 +1,31 @@ +/* + * Copyright 2016-2017 gtalent2@gmail.com + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "addresses.hpp" + +namespace nostalgia { +namespace core { + +static uint8_t *_heapPtr = MEM_WRAM_END; + +void clearHeap() { + _heapPtr = MEM_WRAM_END; +} + +} +} + +using namespace nostalgia::core; + +void *operator new(size_t sz) { + return _heapPtr -= sz; +} + +void operator delete(void *ptr) { +} +