Merge commit '1bfb7f99c215e2c74556bd3281f44962b8faaa96'
All checks were successful
Build / build (push) Successful in 1m35s
All checks were successful
Build / build (push) Successful in 1m35s
This commit is contained in:
@@ -238,6 +238,10 @@ void setBgCbb(Context &ctx, unsigned bgIdx, unsigned cbbIdx) noexcept;
|
||||
|
||||
void setBgPriority(Context &ctx, uint_t bgIdx, uint_t priority) noexcept;
|
||||
|
||||
void setBgOffset(Context &ctx, uint16_t bg, int16_t x, int16_t y) noexcept;
|
||||
|
||||
void scrollBgOffset(Context &ctx, uint16_t bg, int16_t x, int16_t y) noexcept;
|
||||
|
||||
void hideSprite(Context &ctx, unsigned) noexcept;
|
||||
|
||||
void showSprite(Context &ctx, unsigned) noexcept;
|
||||
@@ -260,8 +264,8 @@ constexpr ox::CStringView GlslVersion = "#version 330";
|
||||
[[nodiscard]]
|
||||
ox::Size drawSize(int scale = 5) noexcept;
|
||||
|
||||
void draw(gfx::Context &ctx, ox::Size const &renderSz) noexcept;
|
||||
void draw(Context &ctx, ox::Size const &renderSz) noexcept;
|
||||
|
||||
void draw(gfx::Context&, int scale = 5) noexcept;
|
||||
void draw(Context&, int scale = 5) noexcept;
|
||||
|
||||
}
|
||||
|
@@ -169,8 +169,8 @@ ox::Error loadBgTileSheet(
|
||||
unsigned const cbb,
|
||||
CompactTileSheet const &ts,
|
||||
ox::Optional<unsigned> const &paletteBank) noexcept {
|
||||
auto const cnt = (ts.pixels.size() * PixelsPerTile) / (1 + (ts.bpp == 4));
|
||||
for (size_t i = 0; i < cnt; ++i) {
|
||||
auto const cnt = ts.pixels.size() >> (ts.bpp == 4);
|
||||
for (size_t i{}; i < cnt; ++i) {
|
||||
auto const srcIdx = i * 2;
|
||||
auto const p1 = static_cast<uint16_t>(ts.pixels[srcIdx]);
|
||||
auto const p2 = static_cast<uint16_t>(ts.pixels[srcIdx + 1]);
|
||||
@@ -218,10 +218,11 @@ ox::Error loadSpriteTileSheet(
|
||||
Context &ctx,
|
||||
CompactTileSheet const &ts,
|
||||
bool const loadDefaultPalette) noexcept {
|
||||
for (size_t i = 0; i < ts.pixels.size(); i += 2) {
|
||||
uint16_t v = ts.pixels[i];
|
||||
v |= static_cast<uint16_t>(ts.pixels[i + 1] << 8);
|
||||
MEM_SPRITE_TILES[i] = v;
|
||||
for (size_t i{}; i < ts.pixels.size(); i += 2) {
|
||||
MEM_SPRITE_TILES[i >> 1] =
|
||||
static_cast<uint16_t>(
|
||||
ts.pixels[i] |
|
||||
(static_cast<uint16_t>(ts.pixels[i + 1]) << 8));
|
||||
}
|
||||
if (loadDefaultPalette && ts.defaultPalette) {
|
||||
OX_RETURN_ERROR(loadSpritePalette(ctx, ts.defaultPalette));
|
||||
@@ -294,6 +295,14 @@ void setBgPriority(Context&, uint_t const bgIdx, uint_t const priority) noexcept
|
||||
bgCtl = (bgCtl & 0b1111'1111'1111'1100u) | (priority & 0b11);
|
||||
}
|
||||
|
||||
void setBgOffset(Context&, uint16_t const bg, int16_t const x, int16_t const y) noexcept {
|
||||
teagba::setBgOffset(bg, x, y);
|
||||
}
|
||||
|
||||
void scrollBgOffset(Context&, uint16_t const bg, int16_t const x, int16_t const y) noexcept {
|
||||
teagba::scrollBgOffset(bg, x, y);
|
||||
}
|
||||
|
||||
void hideSprite(Context&, unsigned const idx) noexcept {
|
||||
//oxAssert(g_spriteUpdates < config::GbaSpriteBufferLen, "Sprite update buffer overflow");
|
||||
teagba::addSpriteUpdate({
|
||||
|
@@ -249,7 +249,7 @@ void setBgTile(
|
||||
}
|
||||
|
||||
ox::Error initConsole(Context &ctx) noexcept {
|
||||
constexpr ox::FileAddress TilesheetAddr = ox::StringLiteral("/TileSheets/Charset.ng");
|
||||
constexpr ox::FileAddress TilesheetAddr = ox::StringLiteral("/TileSheets/Charset.nts");
|
||||
constexpr ox::FileAddress PaletteAddr = ox::StringLiteral("/Palettes/Charset.npal");
|
||||
setBgStatus(ctx, 0b0001);
|
||||
setBgCbb(ctx, 0, 0);
|
||||
|
@@ -19,6 +19,9 @@ else()
|
||||
endif()
|
||||
|
||||
add_subdirectory(applib)
|
||||
#if(NOT APPLE)
|
||||
# add_subdirectory(hull)
|
||||
#endif()
|
||||
add_subdirectory(keel)
|
||||
add_subdirectory(turbine)
|
||||
if(${OLYMPIC_BUILD_STUDIO})
|
||||
|
12
src/olympic/hull/CMakeLists.txt
Normal file
12
src/olympic/hull/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
add_library(Hull)
|
||||
target_sources(
|
||||
Hull PUBLIC
|
||||
FILE_SET CXX_MODULES FILES
|
||||
hull.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(
|
||||
Hull PUBLIC
|
||||
OxStd
|
||||
)
|
98
src/olympic/hull/hull.cpp
Normal file
98
src/olympic/hull/hull.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
module;
|
||||
|
||||
#include <ox/std/string.hpp>
|
||||
|
||||
export module hull;
|
||||
|
||||
namespace hull {
|
||||
|
||||
export
|
||||
template<typename Str = ox::String, size_t SmallVecSz = 0>
|
||||
constexpr ox::Result<ox::Vector<Str, SmallVecSz>> parseCmd(ox::StringViewCR cmd) noexcept
|
||||
requires(ox::is_same_v<Str, ox::String> || ox::is_same_v<Str, ox::StringView>) {
|
||||
auto const tokens = split(cmd, ' ');
|
||||
ox::Vector<Str, SmallVecSz> args;
|
||||
char waitingFor{};
|
||||
auto const handleString = [&waitingFor, &args](
|
||||
ox::StringViewCR token,
|
||||
char const delimiter) {
|
||||
if (endsWith(token, delimiter)) {
|
||||
args.emplace_back(substr(token, 1, token.size() - 1));
|
||||
} else {
|
||||
waitingFor = delimiter;
|
||||
args.emplace_back(substr(token, 1));
|
||||
}
|
||||
};
|
||||
for (auto const &token : tokens) {
|
||||
if (waitingFor) {
|
||||
if (endsWith(token, waitingFor)) {
|
||||
waitingFor = 0;
|
||||
}
|
||||
auto &tgt = *args.back().value;
|
||||
if constexpr (ox::is_same_v<Str, ox::String>) {
|
||||
tgt += substr(token, 0, token.size() - 1);
|
||||
} else {
|
||||
tgt = {tgt.data(), tgt.size() + token.size() - 1};
|
||||
}
|
||||
} else if (beginsWith(token, '"')) {
|
||||
handleString(token, '"');
|
||||
} else if (beginsWith(token, '\'')) {
|
||||
handleString(token, '\'');
|
||||
} else {
|
||||
args.emplace_back(token);
|
||||
}
|
||||
}
|
||||
if (waitingFor) {
|
||||
return ox::Error{1, "unterminated string"};
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
template<typename Str = ox::String>
|
||||
[[nodiscard]]
|
||||
static constexpr bool testParse(ox::StringViewCR cmd, std::initializer_list<ox::StringView> const &expected) noexcept {
|
||||
auto const [args, err] = parseCmd<Str>(cmd);
|
||||
static constexpr auto equals = [](auto const &a, auto const &b) {
|
||||
if (a.size() != b.size()) {
|
||||
return false;
|
||||
}
|
||||
for (auto i = 0u; i < a.size(); ++i) {
|
||||
if (a[i] != b[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
return !err && equals(args, ox::Vector(expected));
|
||||
}
|
||||
|
||||
static_assert(testParse("echo asdf", {"echo", "asdf"}));
|
||||
static_assert(testParse<ox::String>("echo asdf", {"echo", "asdf"}));
|
||||
|
||||
static_assert(testParse("echo \"asdf\"", {"echo", "asdf"}));
|
||||
static_assert(testParse<ox::String>("echo \"asdf\"", {"echo", "asdf"}));
|
||||
|
||||
static_assert(testParse("echo 'asdf'", {"echo", "asdf"}));
|
||||
static_assert(testParse<ox::String>("echo 'asdf'", {"echo", "asdf"}));
|
||||
|
||||
static_assert(testParse("echo 'asdf' aoue", {"echo", "asdf", "aoue"}));
|
||||
static_assert(testParse<ox::String>("echo 'asdf' aoue", {"echo", "asdf", "aoue"}));
|
||||
|
||||
export class Prompt {
|
||||
|
||||
private:
|
||||
ox::String m_cmd;
|
||||
ox::String m_workingDir{"/"};
|
||||
ox::Vector<ox::String> m_prevCmds;
|
||||
|
||||
public:
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
Reference in New Issue
Block a user