Start to display BIOS information
This commit is contained in:
@@ -1,34 +1,104 @@
|
||||
#include "../../../include/asset_mgr.hpp"
|
||||
#include "../../../include/shared.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <PSX/System/syscalls.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace BIOSInfo {
|
||||
using namespace JabyEngine;
|
||||
static constexpr auto TextOffset = Make::PositionI16(16, 16);
|
||||
|
||||
struct FontSlider {
|
||||
static constexpr auto MoveTimeout = static_cast<uint8_t>(300_ms);
|
||||
static constexpr auto WaitTimeout = static_cast<uint8_t>(1000_ms);
|
||||
|
||||
int16_t count;
|
||||
int16_t max;
|
||||
int8_t delta;
|
||||
IntervalTimer<uint8_t> wait_timer;
|
||||
|
||||
static FontSlider create_for(const FontWriter::FontInfo& font_info, const char* str) {
|
||||
return FontSlider{
|
||||
.count = 0,
|
||||
.max = static_cast<int16_t>((strlen(str)*font_info.get_kern_size().width) - GPU::Display::Width + (TextOffset.x << 1)),
|
||||
.delta = static_cast<int8_t>(font_info.get_kern_size().width/2),
|
||||
.wait_timer = IntervalTimer<uint8_t>::create(FontSlider::MoveTimeout)
|
||||
};
|
||||
}
|
||||
|
||||
void advance() {
|
||||
if(this->wait_timer.is_expired()) {
|
||||
this->wait_timer.reset();
|
||||
this->count += delta;
|
||||
|
||||
if(this->count <= 0 || this->count >= this->max) {
|
||||
this->delta *= -1;
|
||||
this->wait_timer.set_interval(FontSlider::WaitTimeout);
|
||||
}
|
||||
|
||||
else {
|
||||
this->wait_timer.set_interval(FontSlider::MoveTimeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static FontSlider font_sliders[2];
|
||||
static GPU::TILE::Linked border_tiles[2] = {
|
||||
Make::TILE(Make::AreaI16(0, 0, TextOffset.x, GPU::Display::Height), GPU::Color24::Black()).linked(),
|
||||
Make::TILE(Make::AreaI16(GPU::Display::Width - TextOffset.x, 0, TextOffset.x, GPU::Display::Height), GPU::Color24::Black()).linked()
|
||||
};
|
||||
|
||||
static SysCall::BIOSVersion setup() {
|
||||
const auto result = SysCall::get_bios_version();
|
||||
|
||||
static void setup() {
|
||||
Shared::back_menu.reset();
|
||||
printf("Planschbecken!\n");
|
||||
font_sliders[0] = FontSlider::create_for(FontWriter::BIOSFont::Info, result.kernel_maker);
|
||||
font_sliders[1] = FontSlider::create_for(FontWriter::BIOSFont::Info, result.gui_version);
|
||||
border_tiles[0].concat(border_tiles[1]);
|
||||
return SysCall::get_bios_version();
|
||||
}
|
||||
|
||||
static bool update_or_exit() {
|
||||
static bool update_or_exit(const SysCall::BIOSVersion& bios_version) {
|
||||
static const auto move_cursor = [](JabyEngine::Cursor& cursor, int16_t dx, int16_t old_x) -> JabyEngine::Cursor& {
|
||||
cursor.pos.x = (old_x - dx);
|
||||
return cursor;
|
||||
};
|
||||
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for(auto& font_slider : font_sliders) {
|
||||
font_slider.advance();
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(TextOffset);
|
||||
FontWriter::bios_font_writer.write(cursor, "BIOS INFORMATION\n----------------\nDate:\n%X\nKernel-Maker:\n", bios_version.date_bcd);
|
||||
|
||||
const auto old_pos_x = cursor.pos.x;
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, font_sliders[0].count, old_pos_x), "%s\n", bios_version.kernel_maker);
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, 0, old_pos_x), "GUI-Version:\n");
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, font_sliders[1].count, old_pos_x), "%s\n", bios_version.gui_version);
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, 0, old_pos_x), "----------------\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void render() {
|
||||
Shared::back_menu.render();
|
||||
FontWriter::bios_font_writer.render();
|
||||
GPU::render(border_tiles[0]);
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
const auto bios_version = setup();
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
if(update_or_exit(bios_version)) {
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1);
|
||||
|
Reference in New Issue
Block a user