Start to display BIOS information
This commit is contained in:
parent
3d51ad1137
commit
f2e5bbe369
|
@ -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);
|
||||
|
||||
static void setup() {
|
||||
Shared::back_menu.reset();
|
||||
printf("Planschbecken!\n");
|
||||
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)
|
||||
};
|
||||
}
|
||||
|
||||
static bool update_or_exit() {
|
||||
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();
|
||||
|
||||
Shared::back_menu.reset();
|
||||
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(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);
|
||||
|
|
|
@ -55,6 +55,14 @@ namespace JabyEngine {
|
|||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct BIOSVersion {
|
||||
uint32_t date_bcd;
|
||||
const char* kernel_maker;
|
||||
const char* gui_version;
|
||||
};
|
||||
|
||||
BIOSVersion get_bios_version();
|
||||
|
||||
#define __syscall_function_cast(table, ...) reinterpret_cast<__VA_ARGS__>(table)
|
||||
|
||||
static __always_inline void* memcpy(void *dst, const void *src, size_t len) {
|
||||
|
|
|
@ -27,6 +27,13 @@ namespace JabyEngine {
|
|||
public:
|
||||
constexpr SimpleTimer() = default;
|
||||
|
||||
static SimpleTimer create() {
|
||||
SimpleTimer timer;
|
||||
|
||||
timer.reset();
|
||||
return timer;
|
||||
}
|
||||
|
||||
bool is_expired_for(T time) const {
|
||||
return static_cast<T>((MasterTime::read_as<T>() - this->value)) >= time;
|
||||
}
|
||||
|
@ -46,6 +53,14 @@ namespace JabyEngine {
|
|||
constexpr IntervalTimer(T interval) : SimpleTimer<T>(), interval(interval) {
|
||||
}
|
||||
|
||||
static constexpr IntervalTimer create(T interval) {
|
||||
IntervalTimer timer;
|
||||
|
||||
static_cast<SimpleTimer<T>&>(timer) = SimpleTimer<T>::create();
|
||||
timer.interval = interval;
|
||||
return timer;
|
||||
}
|
||||
|
||||
void set_interval(T interval) {
|
||||
this->interval = interval;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef __STRING__H
|
||||
#define __STRING__H
|
||||
#include "PSX/jabyengine_defines.h"
|
||||
|
||||
START_C_FUNCTIONS
|
||||
size_t strlen(const char* str);
|
||||
END_C_FUNCTIONS
|
||||
|
||||
#endif // !__STRING__H
|
|
@ -0,0 +1,10 @@
|
|||
#include <string.h>
|
||||
|
||||
START_C_FUNCTIONS
|
||||
size_t strlen(const char *str) {
|
||||
const char* end = str;
|
||||
|
||||
for(; *end; ++end);
|
||||
return(end - str);
|
||||
}
|
||||
END_C_FUNCTIONS
|
|
@ -0,0 +1,14 @@
|
|||
#include <PSX/System/syscalls.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace SysCall {
|
||||
BIOSVersion get_bios_version() {
|
||||
BIOSVersion version;
|
||||
|
||||
version.date_bcd = *reinterpret_cast<uint32_t*>(0xBFC00100);
|
||||
version.kernel_maker = reinterpret_cast<const char*>(0xBFC00108);
|
||||
version.gui_version = reinterpret_cast<const char*>(0xBFC7FF32);
|
||||
return version;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue