Finish detecting BIOS type
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
#include "../../../include/asset_mgr.hpp"
|
||||
#include "../../../include/shared.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <PSX/Auxiliary/types.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <PSX/System/syscalls.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -11,6 +12,8 @@ namespace BIOSInfo {
|
||||
using namespace JabyEngine;
|
||||
static constexpr auto TextOffset = Make::PositionI16(16, 16);
|
||||
|
||||
using NameColorPair = pair<const char*, GPU::Color24>;
|
||||
|
||||
struct FontSlider {
|
||||
static constexpr auto MoveTimeout = static_cast<uint8_t>(300_ms);
|
||||
static constexpr auto WaitTimeout = static_cast<uint8_t>(1000_ms);
|
||||
@@ -60,52 +63,46 @@ namespace BIOSInfo {
|
||||
{.bios_str_offset = &BIOS::Version::copyright, .display_str = "Copyright"},
|
||||
};
|
||||
|
||||
static GPU::TILE::Linked border_tiles[2] = {
|
||||
static GPU::TILE::Linked border_tiles[2] = {
|
||||
Make::TILE(Make::AreaI16(0, 0, TextOffset.x, GPU::Display::Height - 32), GPU::Color24::Black()).linked(),
|
||||
Make::TILE(Make::AreaI16(GPU::Display::Width - TextOffset.x, 0, TextOffset.x, GPU::Display::Height - 32), GPU::Color24::Black()).linked()
|
||||
};
|
||||
|
||||
static const char* bios_name = nullptr;
|
||||
static FontSlider bios_name_slider;
|
||||
static NameColorPair bios_name;
|
||||
static FontSlider bios_name_slider;
|
||||
|
||||
static const char* get_bios_name() {
|
||||
switch(BIOS::type) {
|
||||
case BIOS::Type::Devboard:
|
||||
return "DevBoard";
|
||||
case BIOS::Type::PS1:
|
||||
return "PS1";
|
||||
case BIOS::Type::PS2:
|
||||
return "PS2";
|
||||
case BIOS::Type::PS3:
|
||||
return "PS3";
|
||||
case BIOS::Type::PSCompatible:
|
||||
return "Unkown PS compatible BIOS";
|
||||
case BIOS::Type::No$psx:
|
||||
return "NO$PSX";
|
||||
case BIOS::Type::XEBRA:
|
||||
return "XEBRA";
|
||||
static NameColorPair get_bios_name() {
|
||||
switch(BIOS::version.type) {
|
||||
case BIOS::Version::Devboard:
|
||||
return {"DevBoard", GPU::Color24::Green()};
|
||||
case BIOS::Version::PS1:
|
||||
return {"PS1", GPU::Color24::Red()};
|
||||
case BIOS::Version::PS2:
|
||||
return {"PS2", GPU::Color24::Blue()};
|
||||
case BIOS::Version::PS3:
|
||||
return {"PS3", GPU::Color24::Yellow()};
|
||||
case BIOS::Version::PSCompatible:
|
||||
return {"Unkown PS compatible BIOS", GPU::Color24::Grey()};
|
||||
case BIOS::Version::No$psx:
|
||||
return {"NO$PSX", GPU::Color24::Purple()};
|
||||
case BIOS::Version::XEBRA:
|
||||
return {"XEBRA", GPU::Color24::Turquoise()};
|
||||
default:
|
||||
return "Unkown";
|
||||
return {"Unkown", GPU::Color24::White()};
|
||||
}
|
||||
}
|
||||
|
||||
static BIOS::Version setup() {
|
||||
const auto result = BIOS::get_bios_version();
|
||||
|
||||
if(!bios_name) {
|
||||
bios_name = get_bios_name();
|
||||
}
|
||||
|
||||
static void setup() {
|
||||
bios_name = get_bios_name();
|
||||
Shared::back_menu.reset();
|
||||
for(auto& bios_str_info : BIOSStringInfo) {
|
||||
bios_str_info.font_slider = FontSlider::create_for(FontWriter::BIOSFont::Info, result.*(bios_str_info.bios_str_offset));
|
||||
bios_str_info.font_slider = FontSlider::create_for(FontWriter::BIOSFont::Info, BIOS::version.*(bios_str_info.bios_str_offset));
|
||||
}
|
||||
bios_name_slider = FontSlider::create_for(FontWriter::BIOSFont::Info, bios_name);
|
||||
bios_name_slider = FontSlider::create_for(FontWriter::BIOSFont::Info, bios_name.first);
|
||||
border_tiles[0].concat(border_tiles[1]);
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool update_or_exit(const BIOS::Version& bios_version) {
|
||||
static bool update_or_exit() {
|
||||
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;
|
||||
@@ -117,17 +114,17 @@ namespace BIOSInfo {
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(TextOffset);
|
||||
FontWriter::bios_font_writer.write(cursor, "BIOS INFORMATION\n----------------\nDate (day/month/year):\n%i/%i/%i\n", bios_version.date.day, bios_version.date.month, bios_version.date.year);
|
||||
FontWriter::bios_font_writer.write(cursor, "BIOS INFORMATION\n----------------\nDate (day/month/year):\n%i/%i/%i\n", BIOS::version.date.day, BIOS::version.date.month, BIOS::version.date.year);
|
||||
|
||||
const auto old_pos_x = cursor.pos.x;
|
||||
for(auto& bios_str_info : BIOSStringInfo) {
|
||||
bios_str_info.font_slider.advance();
|
||||
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, 0, old_pos_x), "%s:\n", bios_str_info.display_str);
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, bios_str_info.font_slider.count, old_pos_x), "%s\n", bios_version.*(bios_str_info.bios_str_offset));
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, bios_str_info.font_slider.count, old_pos_x), "%s\n", BIOS::version.*(bios_str_info.bios_str_offset));
|
||||
}
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, 0, old_pos_x), "BIOS Type:\n");
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, bios_name_slider.count, old_pos_x), "%s\n", bios_name);
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, bios_name_slider.count, old_pos_x), "%s\n", bios_name.second, bios_name.first);
|
||||
FontWriter::bios_font_writer.write(move_cursor(cursor, 0, old_pos_x), "----------------\n");
|
||||
|
||||
return false;
|
||||
@@ -140,9 +137,9 @@ namespace BIOSInfo {
|
||||
}
|
||||
|
||||
void main() {
|
||||
const auto bios_version = setup();
|
||||
setup();
|
||||
while(true) {
|
||||
if(update_or_exit(bios_version)) {
|
||||
if(update_or_exit()) {
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1);
|
||||
|
Reference in New Issue
Block a user