Integrate all the progress into master #6

Merged
jaby merged 595 commits from ToolBox into main 2025-01-01 13:17:44 +00:00
2 changed files with 65 additions and 17 deletions
Showing only changes of commit b4be9de136 - Show all commits

View File

@ -15,7 +15,15 @@ namespace JabyEngine {
} }
constexpr T add(S dx, S dy) const { constexpr T add(S dx, S dy) const {
return T(static_cast<const T*>(this)->x, static_cast<const T*>(this)->y).add(dx, dy); return T::create(static_cast<const T*>(this)->x, static_cast<const T*>(this)->y).add(dx, dy);
}
constexpr T& add(const T& offset) {
return add(offset.x, offset.y);
}
constexpr T add(const T& offset) const {
return add(offset.x, offset.y);
} }
constexpr T& sub(S dx, S dy) { constexpr T& sub(S dx, S dy) {
@ -29,6 +37,14 @@ namespace JabyEngine {
return T::create(static_cast<const T*>(this)->x, static_cast<const T*>(this)->y).sub(dx, dy); return T::create(static_cast<const T*>(this)->x, static_cast<const T*>(this)->y).sub(dx, dy);
} }
constexpr T& sub(const T& offset) {
return sub(offset.x, offset.y);
}
constexpr T sub(const T& offset) const {
return sub(offset.x, offset.y);
}
constexpr T& move(S dx, S dy) { constexpr T& move(S dx, S dy) {
return this->add(dx, dy); return this->add(dx, dy);
} }
@ -160,6 +176,22 @@ namespace JabyEngine {
// Type used for primitives // Type used for primitives
typedef PositionI16 Vertex; typedef PositionI16 Vertex;
template<typename T, typename S>
static constexpr T tile_id_for(S id, S row_count, Size<S> size) {
const auto x = id%row_count;
const auto y = id/row_count;
return T::create(static_cast<S>(size.width*x), static_cast<S>(size.height*y));
}
template<typename T, typename S>
static constexpr T tile_id_for16(S id) {
const auto x = id&0xF;
const auto y = id >> 4;
return T::create(static_cast<S>(x << 4), static_cast<S>(y << 4));
}
template<typename T> template<typename T>
struct Area { struct Area {
Position<T> position; Position<T> position;
@ -201,10 +233,7 @@ namespace JabyEngine {
} }
static constexpr PageOffset from_tile_id(int16_t id, int16_t row_count, SizeI16 size) { static constexpr PageOffset from_tile_id(int16_t id, int16_t row_count, SizeI16 size) {
const auto x = id%row_count; return tile_id_for<PageOffset>(id, row_count, size);
const auto y = id/row_count;
return PageOffset::create(static_cast<int16_t>(size.width*x), static_cast<int16_t>(size.height*y));
} }
}; };

View File

@ -131,23 +131,42 @@ namespace JabyEngine {
}; };
// base: 0x8200 // base: 0x8200
// { 0 - 9 } static const RangeChar AlphaNumeric[] = {
static const auto Numbers = RangeChar{{0x50, 15}, 10}; // { 0 - 9 }
// { A - Z } {{0x50, 15}, 10},
static const auto UpperCaseLetter = RangeChar{{0x60, 32}, 26}; // { A - Z }
// { a - z } {{0x60, 32}, 26},
static const auto LowerCaseLetter = RangeChar{{0x81, 64}, 26}; // { a - z }
{{0x81, 64}, 26}
};
void load(const PositionU16& start_pos) {
static const auto get_dst_pos = [](const PositionU16& pos, uint16_t tile_id) {
return pos.add(tile_id_for16<PositionU16>(tile_id));
};
void load() {
// Linkd create here
FontBuffer font_buffer; FontBuffer font_buffer;
const auto load_special_chars = [&font_buffer]<size_t Size>(const PositionU16& pos, const SpecialChar(&special_chars)[Size]) {
for(const auto& special_char : special_chars) {
font_buffer.load_to(get_dst_pos(pos, special_char.tile_id), SysCall::Krom2RawAdd(0x8100 | special_char.base_offset));
}
};
const auto load_alpha_num = [&font_buffer]<size_t Size>(const PositionU16& pos, const RangeChar(&range_char)[Size]) {
for(const auto& range : range_char) {
const auto end_tile = range.start_char.tile_id + range.length;
auto sjis_code = 0x8200 | range.start_char.base_offset;
for(uint16_t tile_id = range.start_char.tile_id; tile_id < end_tile; tile_id++,sjis_code++) {
font_buffer.load_to(get_dst_pos(pos, tile_id), SysCall::Krom2RawAdd(sjis_code));
}
}
};
font_buffer.setup(); font_buffer.setup();
GPU::internal::DMA::Receive::prepare(); GPU::internal::DMA::Receive::prepare();
for(size_t n = 0; n < 5; n++) { load_special_chars(start_pos, Specials);
font_buffer.load_to(PositionU16::create(16*n, 0), SysCall::Krom2RawAdd(0x8200 | (UpperCaseLetter.start_char.base_offset + n))); load_alpha_num(start_pos, AlphaNumeric);
}
font_buffer.flush(); font_buffer.flush();
} }
} }
@ -186,7 +205,7 @@ namespace JabyEngine {
auto state = FileProcessor::create(&__boot_loader_end, SimpleTIM(32, 0, 0, 0)); auto state = FileProcessor::create(&__boot_loader_end, SimpleTIM(32, 0, 0, 0));
state.process(bytes_ready); state.process(bytes_ready);
SJIS::load(); SJIS::load(PositionU16::create(0, 0));
// Duplicate DisplayBuffer content // Duplicate DisplayBuffer content
::JabyEngine::GPU::internal::copy_vram_to_vram({PositionU16::create(0, Display::Height), SizeU16::create(Display::Width, Display::Height)}, PositionU16::create(0, 0)); ::JabyEngine::GPU::internal::copy_vram_to_vram({PositionU16::create(0, Display::Height), SizeU16::create(Display::Width, Display::Height)}, PositionU16::create(0, 0));