Load BIOS font
This commit is contained in:
parent
3996680e7e
commit
6568bfcd7d
|
@ -15,7 +15,15 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -29,6 +37,14 @@ namespace JabyEngine {
|
|||
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) {
|
||||
return this->add(dx, dy);
|
||||
}
|
||||
|
@ -160,6 +176,22 @@ namespace JabyEngine {
|
|||
// Type used for primitives
|
||||
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>
|
||||
struct Area {
|
||||
Position<T> position;
|
||||
|
@ -201,10 +233,7 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
static constexpr PageOffset from_tile_id(int16_t id, int16_t row_count, SizeI16 size) {
|
||||
const auto x = id%row_count;
|
||||
const auto y = id/row_count;
|
||||
|
||||
return PageOffset::create(static_cast<int16_t>(size.width*x), static_cast<int16_t>(size.height*y));
|
||||
return tile_id_for<PageOffset>(id, row_count, size);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -131,23 +131,42 @@ namespace JabyEngine {
|
|||
};
|
||||
|
||||
// base: 0x8200
|
||||
// { 0 - 9 }
|
||||
static const auto Numbers = RangeChar{{0x50, 15}, 10};
|
||||
// { A - Z }
|
||||
static const auto UpperCaseLetter = RangeChar{{0x60, 32}, 26};
|
||||
// { a - z }
|
||||
static const auto LowerCaseLetter = RangeChar{{0x81, 64}, 26};
|
||||
static const RangeChar AlphaNumeric[] = {
|
||||
// { 0 - 9 }
|
||||
{{0x50, 15}, 10},
|
||||
// { A - Z }
|
||||
{{0x60, 32}, 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;
|
||||
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();
|
||||
|
||||
GPU::internal::DMA::Receive::prepare();
|
||||
for(size_t n = 0; n < 5; n++) {
|
||||
font_buffer.load_to(PositionU16::create(16*n, 0), SysCall::Krom2RawAdd(0x8200 | (UpperCaseLetter.start_char.base_offset + n)));
|
||||
}
|
||||
load_special_chars(start_pos, Specials);
|
||||
load_alpha_num(start_pos, AlphaNumeric);
|
||||
font_buffer.flush();
|
||||
}
|
||||
}
|
||||
|
@ -186,7 +205,7 @@ namespace JabyEngine {
|
|||
auto state = FileProcessor::create(&__boot_loader_end, SimpleTIM(32, 0, 0, 0));
|
||||
state.process(bytes_ready);
|
||||
|
||||
SJIS::load();
|
||||
SJIS::load(PositionU16::create(0, 0));
|
||||
|
||||
// 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));
|
||||
|
|
Loading…
Reference in New Issue