Squashed 'deps/nostalgia/' changes from 671b8eda..fae1e73e
fae1e73e [nostalgia/gfx] Make getSubSheet check root subsheet name 51f2905c [nostalgia/gfx/studio] Make TileSheetEditor use export-tilesheet functions for export, fix exporting Root subsheet 0c866d1b [studio,nostalgia/gfx] Add system for adding sub-commands in Modules, add export-tilesheet command fdf39d1a [ox/std] Add Result::transformError a523a75e [ox/std] Add missing include to StringParam cdaa64ed [ox/clargs] Fix arg parsing for first '-' 37b5fcc0 [teagba] Put parentheses around all registers f5f2c3be [studio/applib] Make Studio remove files unable to be opened from open file list in config f6ef2b5a [turbine,nostalgia] Make memory regions cast to bounded ox::Arrays bf958a4a [teagba] Make memory regions cast to bounded ox::Arrays 6a70e478 [nostalgia/gfx] Cleanup git-subtree-dir: deps/nostalgia git-subtree-split: fae1e73e54a420d4b93af67e03144d5442825a11
This commit is contained in:
12
deps/ox/src/ox/clargs/clargs.cpp
vendored
12
deps/ox/src/ox/clargs/clargs.cpp
vendored
@ -15,7 +15,7 @@ ClArgs::ClArgs(int argc, const char **args) noexcept: ClArgs({args, static_cast<
|
||||
|
||||
ClArgs::ClArgs(ox::SpanView<const char*> args) noexcept {
|
||||
for (auto i = 0u; i < args.size(); ++i) {
|
||||
auto arg = StringView(args[i]);
|
||||
auto arg = StringView{args[i]};
|
||||
if (arg[0] == '-') {
|
||||
while (arg[0] == '-' && arg.len()) {
|
||||
arg = substr(arg, 1);
|
||||
@ -23,8 +23,8 @@ ClArgs::ClArgs(ox::SpanView<const char*> args) noexcept {
|
||||
m_bools[arg] = true;
|
||||
// parse additional arguments
|
||||
if (i < args.size() && args[i + 1]) {
|
||||
auto val = String(args[i + 1]);
|
||||
if (val.len() && val[i] != '-') {
|
||||
auto const val = StringView{args[i + 1]};
|
||||
if (val.len() && val[0] != '-') {
|
||||
if (val == "false") {
|
||||
m_bools[arg] = false;
|
||||
}
|
||||
@ -40,17 +40,17 @@ ClArgs::ClArgs(ox::SpanView<const char*> args) noexcept {
|
||||
}
|
||||
|
||||
bool ClArgs::getBool(ox::StringViewCR arg, bool defaultValue) const noexcept {
|
||||
auto [value, err] = m_ints.at(arg);
|
||||
auto const [value, err] = m_ints.at(arg);
|
||||
return !err ? *value : defaultValue;
|
||||
}
|
||||
|
||||
String ClArgs::getString(ox::StringViewCR arg, ox::StringView defaultValue) const noexcept {
|
||||
auto [value, err] = m_strings.at(arg);
|
||||
auto const [value, err] = m_strings.at(arg);
|
||||
return !err ? ox::String(*value) : ox::String(defaultValue);
|
||||
}
|
||||
|
||||
int ClArgs::getInt(ox::StringViewCR arg, int defaultValue) const noexcept {
|
||||
auto [value, err] = m_ints.at(arg);
|
||||
auto const [value, err] = m_ints.at(arg);
|
||||
return !err ? *value : defaultValue;
|
||||
}
|
||||
|
||||
|
7
deps/ox/src/ox/std/error.hpp
vendored
7
deps/ox/src/ox/std/error.hpp
vendored
@ -307,6 +307,13 @@ struct [[nodiscard]] Result {
|
||||
return std::move(value);
|
||||
}
|
||||
|
||||
constexpr Result transformError(ErrorCode const ec, CString const msg) && {
|
||||
if (error) {
|
||||
error = Error{ec, msg};
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
1
deps/ox/src/ox/std/stringparam.hpp
vendored
1
deps/ox/src/ox/std/stringparam.hpp
vendored
@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cstringview.hpp"
|
||||
#include "string.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
92
deps/teagba/include/teagba/addresses.hpp
vendored
92
deps/teagba/include/teagba/addresses.hpp
vendored
@ -5,103 +5,101 @@
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/array.hpp>
|
||||
#include <ox/std/types.hpp>
|
||||
#include <ox/std/units.hpp>
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Interrupt Handler
|
||||
|
||||
using interrupt_handler = void (*)();
|
||||
#define REG_ISR *reinterpret_cast<interrupt_handler*>(0x0300'7FFC)
|
||||
#define REG_IE *reinterpret_cast<volatile uint16_t*>(0x0400'0200)
|
||||
#define REG_IF *reinterpret_cast<volatile uint16_t*>(0x0400'0202)
|
||||
#define REG_IME *reinterpret_cast<volatile uint16_t*>(0x0400'0208)
|
||||
using InterruptHandler = void(*)();
|
||||
#define REG_ISR (*reinterpret_cast<InterruptHandler*>(0x0300'7FFC))
|
||||
#define REG_IE (*reinterpret_cast<volatile uint16_t*>(0x0400'0200))
|
||||
#define REG_IF (*reinterpret_cast<volatile uint16_t*>(0x0400'0202))
|
||||
#define REG_IME (*reinterpret_cast<volatile uint16_t*>(0x0400'0208))
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Display Registers
|
||||
|
||||
#define REG_DISPCTL *reinterpret_cast<volatile uint32_t*>(0x0400'0000)
|
||||
#define REG_DISPSTAT *reinterpret_cast<volatile uint32_t*>(0x0400'0004)
|
||||
#define REG_VCOUNT *reinterpret_cast<volatile uint32_t*>(0x0400'0006)
|
||||
#define REG_DISPCTL (*reinterpret_cast<volatile uint32_t*>(0x0400'0000))
|
||||
#define REG_DISPSTAT (*reinterpret_cast<volatile uint32_t*>(0x0400'0004))
|
||||
#define REG_VCOUNT (*reinterpret_cast<volatile uint32_t*>(0x0400'0006))
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Timers
|
||||
|
||||
#define REG_TIMER0 *reinterpret_cast<volatile uint16_t*>(0x0400'0100)
|
||||
#define REG_TIMER0CTL *reinterpret_cast<volatile uint16_t*>(0x0400'0102)
|
||||
#define REG_TIMER0 (*reinterpret_cast<volatile uint16_t*>(0x0400'0100))
|
||||
#define REG_TIMER0CTL (*reinterpret_cast<volatile uint16_t*>(0x0400'0102))
|
||||
|
||||
#define REG_TIMER1 *reinterpret_cast<volatile uint16_t*>(0x0400'0104)
|
||||
#define REG_TIMER1CTL *reinterpret_cast<volatile uint16_t*>(0x0400'0106)
|
||||
#define REG_TIMER1 (*reinterpret_cast<volatile uint16_t*>(0x0400'0104))
|
||||
#define REG_TIMER1CTL (*reinterpret_cast<volatile uint16_t*>(0x0400'0106))
|
||||
|
||||
#define REG_TIMER2 *reinterpret_cast<volatile uint16_t*>(0x0400'0108)
|
||||
#define REG_TIMER2CTL *reinterpret_cast<volatile uint16_t*>(0x0400'010a)
|
||||
#define REG_TIMER2 (*reinterpret_cast<volatile uint16_t*>(0x0400'0108))
|
||||
#define REG_TIMER2CTL (*reinterpret_cast<volatile uint16_t*>(0x0400'010a))
|
||||
|
||||
#define REG_TIMER3 *reinterpret_cast<volatile uint16_t*>(0x0400'010c)
|
||||
#define REG_TIMER3CTL *reinterpret_cast<volatile uint16_t*>(0x0400'010e)
|
||||
#define REG_TIMER3 (*reinterpret_cast<volatile uint16_t*>(0x0400'010c))
|
||||
#define REG_TIMER3CTL (*reinterpret_cast<volatile uint16_t*>(0x0400'010e))
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// background registers
|
||||
|
||||
// background control registers
|
||||
using BgCtl = uint16_t;
|
||||
#define REG_BG0CTL *reinterpret_cast<volatile BgCtl*>(0x0400'0008)
|
||||
#define REG_BG1CTL *reinterpret_cast<volatile BgCtl*>(0x0400'000a)
|
||||
#define REG_BG2CTL *reinterpret_cast<volatile BgCtl*>(0x0400'000c)
|
||||
#define REG_BG3CTL *reinterpret_cast<volatile BgCtl*>(0x0400'000e)
|
||||
#define REG_BG0CTL (*reinterpret_cast<volatile BgCtl*>(0x0400'0008))
|
||||
#define REG_BG1CTL (*reinterpret_cast<volatile BgCtl*>(0x0400'000a))
|
||||
#define REG_BG2CTL (*reinterpret_cast<volatile BgCtl*>(0x0400'000c))
|
||||
#define REG_BG3CTL (*reinterpret_cast<volatile BgCtl*>(0x0400'000e))
|
||||
|
||||
[[nodiscard]]
|
||||
inline volatile BgCtl ®BgCtl(uintptr_t bgIdx) noexcept {
|
||||
inline volatile BgCtl ®BgCtl(uintptr_t const bgIdx) noexcept {
|
||||
return *reinterpret_cast<volatile BgCtl*>(0x0400'0008 + 2 * bgIdx);
|
||||
}
|
||||
|
||||
// background horizontal scrolling registers
|
||||
#define REG_BG0HOFS *reinterpret_cast<volatile uint32_t*>(0x0400'0010)
|
||||
#define REG_BG1HOFS *reinterpret_cast<volatile uint32_t*>(0x0400'0014)
|
||||
#define REG_BG2HOFS *reinterpret_cast<volatile uint32_t*>(0x0400'0018)
|
||||
#define REG_BG3HOFS *reinterpret_cast<volatile uint32_t*>(0x0400'001c)
|
||||
#define REG_BG0HOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'0010))
|
||||
#define REG_BG1HOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'0014))
|
||||
#define REG_BG2HOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'0018))
|
||||
#define REG_BG3HOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'001c))
|
||||
|
||||
[[nodiscard]]
|
||||
inline volatile uint32_t ®BgHofs(auto bgIdx) noexcept {
|
||||
volatile uint32_t ®BgHofs(auto const bgIdx) noexcept {
|
||||
return *reinterpret_cast<volatile uint32_t*>(0x0400'0010 + 4 * bgIdx);
|
||||
}
|
||||
|
||||
// background vertical scrolling registers
|
||||
#define REG_BG0VOFS *reinterpret_cast<volatile uint32_t*>(0x0400'0012)
|
||||
#define REG_BG1VOFS *reinterpret_cast<volatile uint32_t*>(0x0400'0016)
|
||||
#define REG_BG2VOFS *reinterpret_cast<volatile uint32_t*>(0x0400'001a)
|
||||
#define REG_BG3VOFS *reinterpret_cast<volatile uint32_t*>(0x0400'001e)
|
||||
#define REG_BG0VOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'0012))
|
||||
#define REG_BG1VOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'0016))
|
||||
#define REG_BG2VOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'001a))
|
||||
#define REG_BG3VOFS (*reinterpret_cast<volatile uint32_t*>(0x0400'001e))
|
||||
|
||||
[[nodiscard]]
|
||||
inline volatile uint32_t ®BgVofs(auto bgIdx) noexcept {
|
||||
volatile uint32_t ®BgVofs(auto const bgIdx) noexcept {
|
||||
return *reinterpret_cast<volatile uint32_t*>(0x0400'0012 + 4 * bgIdx);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// User Input
|
||||
|
||||
#define REG_GAMEPAD *reinterpret_cast<volatile uint16_t*>(0x0400'0130)
|
||||
#define REG_GAMEPAD (*reinterpret_cast<volatile uint16_t*>(0x0400'0130))
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Memory Addresses
|
||||
|
||||
#define MEM_EWRAM_BEGIN reinterpret_cast<uint8_t*>(0x0200'0000)
|
||||
#define MEM_EWRAM_END reinterpret_cast<uint8_t*>(0x0203'FFFF)
|
||||
#define MEM_EWRAM (*reinterpret_cast<ox::Array<uint16_t, 0x0203'FFFF - 0x0200'0000>*>(0x0200'0000))
|
||||
|
||||
#define MEM_IWRAM_BEGIN reinterpret_cast<uint8_t*>(0x0300'0000)
|
||||
#define MEM_IWRAM_END reinterpret_cast<uint8_t*>(0x0300'7FFF)
|
||||
#define MEM_IWRAM (*reinterpret_cast<ox::Array<uint8_t, 0x0300'7FFF - 0x0300'0000>*>(0x0300'0000))
|
||||
|
||||
#define REG_BLNDCTL *reinterpret_cast<uint16_t*>(0x0400'0050)
|
||||
#define REG_BLNDCTL (*reinterpret_cast<uint16_t*>(0x0400'0050))
|
||||
|
||||
#define MEM_BG_PALETTE reinterpret_cast<uint16_t*>(0x0500'0000)
|
||||
#define MEM_SPRITE_PALETTE reinterpret_cast<uint16_t*>(0x0500'0200)
|
||||
using Palette = ox::Array<uint16_t, 128>;
|
||||
#define MEM_BG_PALETTE (*reinterpret_cast<::Palette*>(0x0500'0000))
|
||||
#define MEM_SPRITE_PALETTE (*reinterpret_cast<::Palette*>(0x0500'0200))
|
||||
|
||||
using BgMapTile = ox::Array<uint16_t, 8192>;
|
||||
#define MEM_BG_TILES reinterpret_cast<BgMapTile*>(0x0600'0000)
|
||||
#define MEM_BG_MAP reinterpret_cast<BgMapTile*>(0x0600'e000)
|
||||
#define MEM_BG_TILES (*reinterpret_cast<ox::Array<BgMapTile, 4>*>(0x0600'0000))
|
||||
#define MEM_BG_MAP (*reinterpret_cast<ox::Array<BgMapTile, 4>*>(0x0600'e000))
|
||||
|
||||
#define MEM_SPRITE_TILES reinterpret_cast<uint16_t*>(0x0601'0000)
|
||||
#define MEM_OAM reinterpret_cast<uint64_t*>(0x0700'0000)
|
||||
#define MEM_SPRITE_TILES (*reinterpret_cast<ox::Array<uint16_t, 32 * ox::units::KB>*>(0x0601'0000))
|
||||
#define MEM_OAM (*reinterpret_cast<ox::Array<uint64_t, 64>*>(0x0700'0000))
|
||||
|
||||
#define MEM_ROM reinterpret_cast<char*>(0x0800'0000)
|
||||
#define MEM_ROM (*reinterpret_cast<ox::Array<char, 32 * ox::units::MB>*>(0x0700'0000))
|
||||
|
||||
#define MEM_SRAM reinterpret_cast<char*>(0x0e00'0000)
|
||||
#define MEM_SRAM_SIZE 65535
|
||||
#define MEM_SRAM (*reinterpret_cast<ox::Array<char, 64 * ox::units::KB>*>(0x0e00'0000))
|
||||
|
Reference in New Issue
Block a user