[nostalgia/core/sdl] Switch from MC to Claw
This commit is contained in:
parent
880e6e49d6
commit
9a49761c01
@ -9,6 +9,7 @@ find_package(sdl2 REQUIRED)
|
|||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
NostalgiaCore-SDL PUBLIC
|
NostalgiaCore-SDL PUBLIC
|
||||||
sdl2::sdl2
|
sdl2::sdl2
|
||||||
|
OxClaw
|
||||||
OxFS
|
OxFS
|
||||||
OxStd
|
OxStd
|
||||||
NostalgiaCore-Userspace
|
NostalgiaCore-Userspace
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include <ox/mc/read.hpp>
|
#include <ox/claw/read.hpp>
|
||||||
|
|
||||||
#include <nostalgia/core/gfx.hpp>
|
#include <nostalgia/core/gfx.hpp>
|
||||||
|
|
||||||
@ -31,20 +31,20 @@ struct SdlImplData {
|
|||||||
uint64_t draws = 0;
|
uint64_t draws = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] static ox::ValErr<ox::Vector<uint8_t>> readFile(Context *ctx, const ox::FileAddress &file) {
|
[[nodiscard]] static ox::ValErr<ox::Vector<char>> readFile(Context *ctx, const ox::FileAddress &file) {
|
||||||
auto [stat, err] = ctx->rom->stat(file);
|
auto [stat, err] = ctx->rom->stat(file);
|
||||||
oxReturnError(err);
|
oxReturnError(err);
|
||||||
ox::Vector<uint8_t> buff(stat.size);
|
ox::Vector<char> buff(stat.size);
|
||||||
oxReturnError(ctx->rom->read(file, buff.data(), buff.size()));
|
oxReturnError(ctx->rom->read(file, buff.data(), buff.size()));
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
[[nodiscard]] ox::ValErr<T> readMC(Context *ctx, const ox::FileAddress &file) {
|
[[nodiscard]] ox::ValErr<T> readObj(Context *ctx, const ox::FileAddress &file) {
|
||||||
auto [buff, err] = readFile(ctx, file);
|
auto [buff, err] = readFile(ctx, file);
|
||||||
oxReturnError(err);
|
oxReturnError(err);
|
||||||
T t;
|
T t;
|
||||||
oxReturnError(ox::readMC(buff.data(), buff.size(), &t));
|
oxReturnError(ox::readClaw(buff.data(), buff.size(), &t));
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,13 +97,13 @@ ox::Error loadTileSheet(Context *ctx,
|
|||||||
ox::FileAddress tilesheetPath,
|
ox::FileAddress tilesheetPath,
|
||||||
ox::FileAddress palettePath) {
|
ox::FileAddress palettePath) {
|
||||||
auto id = ctx->implData<SdlImplData>();
|
auto id = ctx->implData<SdlImplData>();
|
||||||
auto [tilesheet, tserr] = readMC<NostalgiaGraphic>(ctx, tilesheetPath);
|
auto [tilesheet, tserr] = readObj<NostalgiaGraphic>(ctx, tilesheetPath);
|
||||||
oxReturnError(tserr);
|
oxReturnError(tserr);
|
||||||
NostalgiaPalette palette;
|
NostalgiaPalette palette;
|
||||||
if (!palettePath) {
|
if (!palettePath) {
|
||||||
palettePath = tilesheet.defaultPalette;
|
palettePath = tilesheet.defaultPalette;
|
||||||
}
|
}
|
||||||
oxReturnError(readMC<NostalgiaPalette>(ctx, palettePath).get(&palette));
|
oxReturnError(readObj<NostalgiaPalette>(ctx, palettePath).get(&palette));
|
||||||
|
|
||||||
const unsigned bytesPerTile = tilesheet.bpp == 8 ? 64 : 32;
|
const unsigned bytesPerTile = tilesheet.bpp == 8 ? 64 : 32;
|
||||||
const auto tiles = tilesheet.tiles.size() / bytesPerTile;
|
const auto tiles = tilesheet.tiles.size() / bytesPerTile;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user