Compare commits
5 Commits
dd50bd0249
...
151d7c5736
Author | SHA1 | Date | |
---|---|---|---|
151d7c5736 | |||
4e4d8d2c3f | |||
03d1fd2857 | |||
6701decc91 | |||
6cff526647 |
4
deps/gbabuildcore/base.cmake
vendored
4
deps/gbabuildcore/base.cmake
vendored
@ -1,8 +1,8 @@
|
|||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/modules)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/modules)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc++")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-unwind-tables")
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-unwind-tables")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb-interwork")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthumb-interwork")
|
||||||
|
27
deps/ox/src/ox/std/assert.cpp
vendored
27
deps/ox/src/ox/std/assert.cpp
vendored
@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fmt.hpp"
|
#include "fmt.hpp"
|
||||||
|
#include "realstd.hpp"
|
||||||
#include "stacktrace.hpp"
|
#include "stacktrace.hpp"
|
||||||
#include "trace.hpp"
|
#include "trace.hpp"
|
||||||
|
|
||||||
@ -14,7 +15,7 @@
|
|||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
void panic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err) noexcept {
|
void panic(StringViewCR file, int const line, StringViewCR panicMsg, Error const&err) noexcept {
|
||||||
oxErrf("\033[31;1;1mPANIC:\033[0m [{}:{}]: {}\n", file, line, panicMsg);
|
oxErrf("\033[31;1;1mPANIC:\033[0m [{}:{}]: {}\n", file, line, panicMsg);
|
||||||
if (err.msg) {
|
if (err.msg) {
|
||||||
oxErrf("\tError Message:\t{}\n", err.msg);
|
oxErrf("\tError Message:\t{}\n", err.msg);
|
||||||
@ -32,16 +33,19 @@ void panic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void panic(const char *file, int line, const char *panicMsg, const Error &err) noexcept {
|
void panic(const char *file, int const line, char const*panicMsg, Error const&err) noexcept {
|
||||||
panic(StringView{file}, line, StringView{panicMsg}, err);
|
panic(StringView{file}, line, StringView{panicMsg}, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertFailFuncRuntime(StringViewCR file, int line, StringViewCR assertTxt, StringViewCR msg) noexcept {
|
void assertFailFuncRuntime(
|
||||||
|
StringViewCR file,
|
||||||
|
int const line,
|
||||||
|
StringViewCR assertTxt,
|
||||||
|
StringViewCR msg) noexcept {
|
||||||
#ifdef OX_USE_STDLIB
|
#ifdef OX_USE_STDLIB
|
||||||
auto output = sfmt("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, msg);
|
auto const st = genStackTrace(2);
|
||||||
output += genStackTrace(2);
|
oxTracef("assert", "Failed assert: {} ({}) [{}:{}]:\n{}", msg, assertTxt, file, line, st);
|
||||||
oxTracef("assert", "Failed assert: {} ({}) [{}:{}]", msg, assertTxt, file, line);
|
abort();
|
||||||
std::abort();
|
|
||||||
#else
|
#else
|
||||||
oxErrf("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, msg);
|
oxErrf("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, msg);
|
||||||
oxTracef("assert", "Failed assert: {} ({}) [{}:{}]", msg, assertTxt, file, line);
|
oxTracef("assert", "Failed assert: {} ({}) [{}:{}]", msg, assertTxt, file, line);
|
||||||
@ -49,7 +53,12 @@ void assertFailFuncRuntime(StringViewCR file, int line, StringViewCR assertTxt,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertFailFuncRuntime(StringViewCR file, int line, [[maybe_unused]] const Error &err, StringViewCR, StringViewCR assertMsg) noexcept {
|
void assertFailFuncRuntime(
|
||||||
|
StringViewCR file,
|
||||||
|
int const line,
|
||||||
|
[[maybe_unused]] Error const&err,
|
||||||
|
StringViewCR,
|
||||||
|
StringViewCR assertMsg) noexcept {
|
||||||
#if defined(OX_USE_STDLIB)
|
#if defined(OX_USE_STDLIB)
|
||||||
auto msg = sfmt("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, assertMsg);
|
auto msg = sfmt("\n\033[31;1;1mASSERT FAILURE:\033[0m [{}:{}]: {}\n", file, line, assertMsg);
|
||||||
if (err.msg) {
|
if (err.msg) {
|
||||||
@ -62,7 +71,7 @@ void assertFailFuncRuntime(StringViewCR file, int line, [[maybe_unused]] const E
|
|||||||
msg += genStackTrace(2);
|
msg += genStackTrace(2);
|
||||||
oxErr(msg);
|
oxErr(msg);
|
||||||
oxTracef("assert", "Failed assert: {} [{}:{}]", assertMsg, file, line);
|
oxTracef("assert", "Failed assert: {} [{}:{}]", assertMsg, file, line);
|
||||||
std::abort();
|
abort();
|
||||||
#else
|
#else
|
||||||
constexprPanic(file, line, assertMsg);
|
constexprPanic(file, line, assertMsg);
|
||||||
#endif
|
#endif
|
||||||
|
43
deps/ox/src/ox/std/assert.hpp
vendored
43
deps/ox/src/ox/std/assert.hpp
vendored
@ -22,9 +22,15 @@
|
|||||||
|
|
||||||
namespace ox {
|
namespace ox {
|
||||||
|
|
||||||
void panic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err = ox::Error(0)) noexcept;
|
[[noreturn]]
|
||||||
|
void panic(StringViewCR file, int line, StringViewCR panicMsg, Error const&err = {}) noexcept;
|
||||||
|
|
||||||
constexpr void constexprPanic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err = ox::Error(0)) noexcept {
|
[[noreturn]]
|
||||||
|
constexpr void constexprPanic(
|
||||||
|
StringViewCR file,
|
||||||
|
int const line,
|
||||||
|
StringViewCR panicMsg,
|
||||||
|
Error const&err = {}) noexcept {
|
||||||
if (!std::is_constant_evaluated()) {
|
if (!std::is_constant_evaluated()) {
|
||||||
panic(file, line, panicMsg, err);
|
panic(file, line, panicMsg, err);
|
||||||
} else {
|
} else {
|
||||||
@ -32,10 +38,24 @@ constexpr void constexprPanic(StringViewCR file, int line, StringViewCR panicMsg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertFailFuncRuntime(StringViewCR file, int line, StringViewCR assertTxt, StringViewCR msg) noexcept;
|
void assertFailFuncRuntime(
|
||||||
void assertFailFuncRuntime(StringViewCR file, int line, const Error &err, StringViewCR, StringViewCR assertMsg) noexcept;
|
StringViewCR file,
|
||||||
|
int line,
|
||||||
|
StringViewCR assertTxt,
|
||||||
|
StringViewCR msg) noexcept;
|
||||||
|
void assertFailFuncRuntime(
|
||||||
|
StringViewCR file,
|
||||||
|
int line,
|
||||||
|
Error const&err,
|
||||||
|
StringViewCR,
|
||||||
|
StringViewCR assertMsg) noexcept;
|
||||||
|
|
||||||
constexpr void assertFunc(StringViewCR file, int line, bool pass, [[maybe_unused]]StringViewCR assertTxt, [[maybe_unused]]StringViewCR msg) noexcept {
|
constexpr void assertFunc(
|
||||||
|
StringViewCR file,
|
||||||
|
int const line,
|
||||||
|
bool const pass,
|
||||||
|
[[maybe_unused]]StringViewCR assertTxt,
|
||||||
|
[[maybe_unused]]StringViewCR msg) noexcept {
|
||||||
if (!pass) {
|
if (!pass) {
|
||||||
if (!std::is_constant_evaluated()) {
|
if (!std::is_constant_evaluated()) {
|
||||||
assertFailFuncRuntime(file, line, assertTxt, msg);
|
assertFailFuncRuntime(file, line, assertTxt, msg);
|
||||||
@ -45,7 +65,12 @@ constexpr void assertFunc(StringViewCR file, int line, bool pass, [[maybe_unused
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void assertFunc(StringViewCR file, int line, const Error &err, StringViewCR, StringViewCR assertMsg) noexcept {
|
constexpr void assertFunc(
|
||||||
|
StringViewCR file,
|
||||||
|
int const line,
|
||||||
|
Error const&err,
|
||||||
|
StringViewCR,
|
||||||
|
StringViewCR assertMsg) noexcept {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (!std::is_constant_evaluated()) {
|
if (!std::is_constant_evaluated()) {
|
||||||
assertFailFuncRuntime(file, line, err, {}, assertMsg);
|
assertFailFuncRuntime(file, line, err, {}, assertMsg);
|
||||||
@ -55,7 +80,11 @@ constexpr void assertFunc(StringViewCR file, int line, const Error &err, StringV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void expect(StringViewCR file, int line, const auto &actual, const auto &expected) noexcept {
|
constexpr void expect(
|
||||||
|
StringViewCR file,
|
||||||
|
int const line,
|
||||||
|
auto const&actual,
|
||||||
|
auto const&expected) noexcept {
|
||||||
if (actual != expected) {
|
if (actual != expected) {
|
||||||
if (!std::is_constant_evaluated()) {
|
if (!std::is_constant_evaluated()) {
|
||||||
#if defined(OX_USE_STDLIB)
|
#if defined(OX_USE_STDLIB)
|
||||||
|
7
deps/ox/src/ox/std/error.hpp
vendored
7
deps/ox/src/ox/std/error.hpp
vendored
@ -80,13 +80,13 @@ struct Exception: public std::exception {
|
|||||||
ox::CString msg = nullptr;
|
ox::CString msg = nullptr;
|
||||||
ErrorCode errCode = 0;
|
ErrorCode errCode = 0;
|
||||||
|
|
||||||
explicit inline Exception(
|
explicit Exception(
|
||||||
ErrorCode const errCode,
|
ErrorCode const errCode,
|
||||||
std::source_location const&src = std::source_location::current()) noexcept:
|
std::source_location const&src = std::source_location::current()) noexcept:
|
||||||
src{src},
|
src{src},
|
||||||
errCode{errCode} {}
|
errCode{errCode} {}
|
||||||
|
|
||||||
explicit inline Exception(
|
explicit Exception(
|
||||||
ErrorCode const errCode,
|
ErrorCode const errCode,
|
||||||
ox::CString msg,
|
ox::CString msg,
|
||||||
std::source_location const&src = std::source_location::current()) noexcept:
|
std::source_location const&src = std::source_location::current()) noexcept:
|
||||||
@ -94,7 +94,7 @@ struct Exception: public std::exception {
|
|||||||
msg{msg},
|
msg{msg},
|
||||||
errCode{errCode} {}
|
errCode{errCode} {}
|
||||||
|
|
||||||
explicit inline Exception(Error const&err) noexcept:
|
explicit Exception(Error const&err) noexcept:
|
||||||
src{err.src},
|
src{err.src},
|
||||||
msg{err.msg ? err.msg : ""},
|
msg{err.msg ? err.msg : ""},
|
||||||
errCode{err.errCode} {}
|
errCode{err.errCode} {}
|
||||||
@ -109,6 +109,7 @@ struct Exception: public std::exception {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[[noreturn]]
|
||||||
void panic(char const*file, int line, char const*panicMsg, Error const&err) noexcept;
|
void panic(char const*file, int line, char const*panicMsg, Error const&err) noexcept;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
9
deps/ox/src/ox/std/realstd.hpp
vendored
9
deps/ox/src/ox/std/realstd.hpp
vendored
@ -12,4 +12,13 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#else
|
#else
|
||||||
#define assert(e) while (!(e));
|
#define assert(e) while (!(e));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __has_include(<cstdlib>)
|
||||||
|
#include <cstdlib>
|
||||||
|
#else
|
||||||
|
extern "C" {
|
||||||
|
[[noreturn]]
|
||||||
|
void abort();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
21
deps/teagba/src/cstartup.cpp
vendored
21
deps/teagba/src/cstartup.cpp
vendored
@ -4,17 +4,20 @@
|
|||||||
|
|
||||||
#include <ox/std/heapmgr.hpp>
|
#include <ox/std/heapmgr.hpp>
|
||||||
|
|
||||||
|
#include <teagba/bios.hpp>
|
||||||
|
#include <teagba/registers.hpp>
|
||||||
|
|
||||||
namespace mgba {
|
namespace mgba {
|
||||||
void initConsole();
|
void initConsole();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MEM_EWRAM_BEGIN reinterpret_cast<char*>(0x02000000)
|
#define MEM_HEAP_BEGIN reinterpret_cast<char*>(0x02000000)
|
||||||
#define MEM_EWRAM_END reinterpret_cast<char*>(0x0203FFFF)
|
#define MEM_HEAP_END reinterpret_cast<char*>(0x0203FFFF)
|
||||||
|
|
||||||
#define HEAP_BEGIN reinterpret_cast<char*>(MEM_EWRAM_BEGIN)
|
#define HEAP_BEGIN reinterpret_cast<char*>(MEM_HEAP_BEGIN)
|
||||||
// set size to half of EWRAM
|
// set size to half of EWRAM
|
||||||
#define HEAP_SIZE ((MEM_EWRAM_END - MEM_EWRAM_BEGIN) / 2)
|
#define HEAP_SIZE ((MEM_HEAP_END - MEM_HEAP_BEGIN) / 2)
|
||||||
#define HEAP_END reinterpret_cast<char*>(MEM_EWRAM_BEGIN + HEAP_SIZE)
|
#define HEAP_END reinterpret_cast<char*>(MEM_HEAP_BEGIN + HEAP_SIZE)
|
||||||
|
|
||||||
extern void (*__preinit_array_start[]) (void);
|
extern void (*__preinit_array_start[]) (void);
|
||||||
extern void (*__preinit_array_end[]) (void);
|
extern void (*__preinit_array_end[]) (void);
|
||||||
@ -25,6 +28,14 @@ int main(int argc, const char **argv);
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
void abort() {
|
||||||
|
REG_IE = 0;
|
||||||
|
teagba::intrwait(0, 0);
|
||||||
|
while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *__gxx_personality_v0{};
|
||||||
|
|
||||||
void __libc_init_array() {
|
void __libc_init_array() {
|
||||||
auto preInits = __preinit_array_end - __preinit_array_start;
|
auto preInits = __preinit_array_end - __preinit_array_start;
|
||||||
for (decltype(preInits) i = 0; i < preInits; i++) {
|
for (decltype(preInits) i = 0; i < preInits; i++) {
|
||||||
|
@ -99,10 +99,10 @@ ox::Error loadBgTileSheet(
|
|||||||
size_t const tileCnt) noexcept {
|
size_t const tileCnt) noexcept {
|
||||||
size_t const bppMod = ts.bpp == 4;
|
size_t const bppMod = ts.bpp == 4;
|
||||||
size_t const bytesPerTile = PixelsPerTile >> bppMod;
|
size_t const bytesPerTile = PixelsPerTile >> bppMod;
|
||||||
auto const pixCnt = tileCnt * bytesPerTile;
|
auto const cnt = (tileCnt * bytesPerTile) / 2;
|
||||||
auto const srcPxIdx = srcTileIdx * bytesPerTile;
|
auto const srcPxIdx = srcTileIdx * bytesPerTile;
|
||||||
auto const dstPxIdx = (dstTileIdx * bytesPerTile) / 2;
|
auto const dstPxIdx = (dstTileIdx * bytesPerTile) / 2;
|
||||||
for (size_t i = 0; i < pixCnt; ++i) {
|
for (size_t i = 0; i < cnt; ++i) {
|
||||||
auto const srcIdx = srcPxIdx + i * 2;
|
auto const srcIdx = srcPxIdx + i * 2;
|
||||||
auto const p1 = static_cast<uint16_t>(ts.pixels[srcIdx]);
|
auto const p1 = static_cast<uint16_t>(ts.pixels[srcIdx]);
|
||||||
auto const p2 = static_cast<uint16_t>(ts.pixels[srcIdx + 1]);
|
auto const p2 = static_cast<uint16_t>(ts.pixels[srcIdx + 1]);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <ox/std/def.hpp>
|
#include <ox/std/def.hpp>
|
||||||
|
#include <ox/std/realstd.hpp>
|
||||||
|
|
||||||
#include <keel/media.hpp>
|
#include <keel/media.hpp>
|
||||||
#include <turbine/turbine.hpp>
|
#include <turbine/turbine.hpp>
|
||||||
@ -51,9 +52,7 @@ OX_ALLOW_UNSAFE_BUFFERS_END
|
|||||||
if (err.src.file_name() != nullptr) {
|
if (err.src.file_name() != nullptr) {
|
||||||
oxErrf("\tError Location:\t{}:{}\n", err.src.file_name(), err.src.line());
|
oxErrf("\tError Location:\t{}:{}\n", err.src.file_name(), err.src.line());
|
||||||
}
|
}
|
||||||
// disable all interrupt handling and IntrWait on no interrupts
|
abort();
|
||||||
REG_IE = 0;
|
|
||||||
teagba::intrwait(0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user