Fix inconsistent EOL
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include "include/frame.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
|
||||
namespace ScreenCenter {
|
||||
#include "include/frame.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
|
||||
namespace ScreenCenter {
|
||||
}
|
@@ -1,107 +1,107 @@
|
||||
#pragma once
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/System/IOPorts/dma_io.hpp>
|
||||
|
||||
namespace ScreenCenter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
class Frame {
|
||||
private:
|
||||
struct TopBorder : public GPU::internal::LinkedElementCreator<TopBorder> {
|
||||
GPU::TILE top_left[2];
|
||||
GPU::TILE top_right[2];
|
||||
|
||||
static constexpr TopBorder::Linked create(GPU::Color24 BaseColor, GPU::SizeI16 Size) {
|
||||
TopBorder frame;
|
||||
|
||||
frame.top_left[0] = Make::TILE(Make::AreaI16(0, 0, Size.width, Size.height), BaseColor);
|
||||
frame.top_left[1] = Make::TILE(Make::AreaI16(0, 0, Size.height, Size.width), BaseColor);
|
||||
|
||||
frame.top_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, 0, Size.width, Size.height), BaseColor);
|
||||
frame.top_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, 0, Size.height, Size.width), BaseColor);
|
||||
return frame.linked();
|
||||
}
|
||||
};
|
||||
|
||||
struct BottomBorder : GPU::internal::LinkedElementCreator<BottomBorder> {
|
||||
GPU::TILE bottom_left[2];
|
||||
GPU::TILE bottom_right[2];
|
||||
|
||||
static constexpr BottomBorder::Linked create(GPU::Color24 BaseColor, GPU::SizeI16 Size) {
|
||||
BottomBorder frame;
|
||||
|
||||
frame.bottom_left[0] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor);
|
||||
frame.bottom_left[1] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor);
|
||||
|
||||
frame.bottom_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor);
|
||||
frame.bottom_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor);
|
||||
return frame.linked();
|
||||
}
|
||||
};
|
||||
|
||||
struct LineBorder : GPU::internal::LinkedElementCreator<LineBorder> {
|
||||
GPU::LINE_G_MULTI<5> border;
|
||||
|
||||
static constexpr LineBorder::Linked create(int16_t offset = 0) {
|
||||
const auto get_color = [](size_t idx, int16_t offset) -> GPU::Color24 {
|
||||
const GPU::Color24 Colors[4] = {GPU::Color24::Red(), GPU::Color24::Green(), GPU::Color24::Blue(), GPU::Color24::Yellow()};
|
||||
|
||||
return Colors[(idx + offset)%4];
|
||||
};
|
||||
const int16_t origin = 0 + offset;
|
||||
const int16_t width = GPU::Display::Width - 1 - offset;
|
||||
const int16_t height = GPU::Display::Height - 1 - offset;
|
||||
LineBorder frame;
|
||||
|
||||
frame.border = Make::LINE_G(
|
||||
GPU::ColorVertex{get_color(0, offset), Make::Vertex(origin, origin)},
|
||||
GPU::ColorVertex{get_color(1, offset), Make::Vertex(origin, height)},
|
||||
GPU::ColorVertex{get_color(2, offset), Make::Vertex(width, height)},
|
||||
GPU::ColorVertex{get_color(3, offset), Make::Vertex(width, origin)},
|
||||
GPU::ColorVertex{get_color(4, offset), Make::Vertex(origin, origin)}
|
||||
);
|
||||
return frame.linked();
|
||||
}
|
||||
};
|
||||
|
||||
struct LineCross : GPU::internal::LinkedElementCreator<LineCross> {
|
||||
GPU::LINE_G_SINGLE cross[2];
|
||||
|
||||
static constexpr LineCross::Linked create(const decltype(LineBorder::border)& border) {
|
||||
LineCross frame;
|
||||
|
||||
frame.cross[0] = Make::LINE_G(border[0], border[2]);
|
||||
frame.cross[1] = Make::LINE_G(border[3], border[1]);
|
||||
return frame.linked();
|
||||
}
|
||||
};
|
||||
|
||||
TopBorder::Linked top_border;
|
||||
BottomBorder::Linked bottom_border;
|
||||
LineBorder::Linked line_border[2];
|
||||
LineCross::Linked line_cross;
|
||||
public:
|
||||
static constexpr Frame create() {
|
||||
constexpr auto BaseColor = GPU::Color24::from_rgb(0x1D, 0xA0, 0xA3);
|
||||
constexpr auto Size = Make::SizeI16(64, 16);
|
||||
|
||||
Frame frame;
|
||||
|
||||
frame.top_border = TopBorder::create(BaseColor, Size);
|
||||
frame.bottom_border = BottomBorder::create(BaseColor, Size);
|
||||
frame.line_border[0] = LineBorder::create();
|
||||
frame.line_border[1] = LineBorder::create(1);
|
||||
frame.line_cross = LineCross::create(frame.line_border[0]->border);
|
||||
return frame;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
this->top_border.concat(this->bottom_border.concat(this->line_border[0].concat(this->line_border[1].concat(this->line_cross))));
|
||||
}
|
||||
|
||||
void render() const {
|
||||
GPU::render(this->top_border);
|
||||
}
|
||||
};
|
||||
#pragma once
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/System/IOPorts/dma_io.hpp>
|
||||
|
||||
namespace ScreenCenter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
class Frame {
|
||||
private:
|
||||
struct TopBorder : public GPU::internal::LinkedElementCreator<TopBorder> {
|
||||
GPU::TILE top_left[2];
|
||||
GPU::TILE top_right[2];
|
||||
|
||||
static constexpr TopBorder::Linked create(GPU::Color24 BaseColor, GPU::SizeI16 Size) {
|
||||
TopBorder frame;
|
||||
|
||||
frame.top_left[0] = Make::TILE(Make::AreaI16(0, 0, Size.width, Size.height), BaseColor);
|
||||
frame.top_left[1] = Make::TILE(Make::AreaI16(0, 0, Size.height, Size.width), BaseColor);
|
||||
|
||||
frame.top_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, 0, Size.width, Size.height), BaseColor);
|
||||
frame.top_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, 0, Size.height, Size.width), BaseColor);
|
||||
return frame.linked();
|
||||
}
|
||||
};
|
||||
|
||||
struct BottomBorder : GPU::internal::LinkedElementCreator<BottomBorder> {
|
||||
GPU::TILE bottom_left[2];
|
||||
GPU::TILE bottom_right[2];
|
||||
|
||||
static constexpr BottomBorder::Linked create(GPU::Color24 BaseColor, GPU::SizeI16 Size) {
|
||||
BottomBorder frame;
|
||||
|
||||
frame.bottom_left[0] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor);
|
||||
frame.bottom_left[1] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor);
|
||||
|
||||
frame.bottom_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor);
|
||||
frame.bottom_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor);
|
||||
return frame.linked();
|
||||
}
|
||||
};
|
||||
|
||||
struct LineBorder : GPU::internal::LinkedElementCreator<LineBorder> {
|
||||
GPU::LINE_G_MULTI<5> border;
|
||||
|
||||
static constexpr LineBorder::Linked create(int16_t offset = 0) {
|
||||
const auto get_color = [](size_t idx, int16_t offset) -> GPU::Color24 {
|
||||
const GPU::Color24 Colors[4] = {GPU::Color24::Red(), GPU::Color24::Green(), GPU::Color24::Blue(), GPU::Color24::Yellow()};
|
||||
|
||||
return Colors[(idx + offset)%4];
|
||||
};
|
||||
const int16_t origin = 0 + offset;
|
||||
const int16_t width = GPU::Display::Width - 1 - offset;
|
||||
const int16_t height = GPU::Display::Height - 1 - offset;
|
||||
LineBorder frame;
|
||||
|
||||
frame.border = Make::LINE_G(
|
||||
GPU::ColorVertex{get_color(0, offset), Make::Vertex(origin, origin)},
|
||||
GPU::ColorVertex{get_color(1, offset), Make::Vertex(origin, height)},
|
||||
GPU::ColorVertex{get_color(2, offset), Make::Vertex(width, height)},
|
||||
GPU::ColorVertex{get_color(3, offset), Make::Vertex(width, origin)},
|
||||
GPU::ColorVertex{get_color(4, offset), Make::Vertex(origin, origin)}
|
||||
);
|
||||
return frame.linked();
|
||||
}
|
||||
};
|
||||
|
||||
struct LineCross : GPU::internal::LinkedElementCreator<LineCross> {
|
||||
GPU::LINE_G_SINGLE cross[2];
|
||||
|
||||
static constexpr LineCross::Linked create(const decltype(LineBorder::border)& border) {
|
||||
LineCross frame;
|
||||
|
||||
frame.cross[0] = Make::LINE_G(border[0], border[2]);
|
||||
frame.cross[1] = Make::LINE_G(border[3], border[1]);
|
||||
return frame.linked();
|
||||
}
|
||||
};
|
||||
|
||||
TopBorder::Linked top_border;
|
||||
BottomBorder::Linked bottom_border;
|
||||
LineBorder::Linked line_border[2];
|
||||
LineCross::Linked line_cross;
|
||||
public:
|
||||
static constexpr Frame create() {
|
||||
constexpr auto BaseColor = GPU::Color24::from_rgb(0x1D, 0xA0, 0xA3);
|
||||
constexpr auto Size = Make::SizeI16(64, 16);
|
||||
|
||||
Frame frame;
|
||||
|
||||
frame.top_border = TopBorder::create(BaseColor, Size);
|
||||
frame.bottom_border = BottomBorder::create(BaseColor, Size);
|
||||
frame.line_border[0] = LineBorder::create();
|
||||
frame.line_border[1] = LineBorder::create(1);
|
||||
frame.line_cross = LineCross::create(frame.line_border[0]->border);
|
||||
return frame;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
this->top_border.concat(this->bottom_border.concat(this->line_border[0].concat(this->line_border[1].concat(this->line_cross))));
|
||||
}
|
||||
|
||||
void render() const {
|
||||
GPU::render(this->top_border);
|
||||
}
|
||||
};
|
||||
}
|
@@ -1,209 +1,209 @@
|
||||
#include "../../../include/shared.hpp"
|
||||
#include "include/frame.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace ScreenCenter {
|
||||
using namespace JabyEngine;
|
||||
using GenericButton = Periphery::GenericController::Button;
|
||||
|
||||
struct ButtonPulser {
|
||||
static constexpr auto StartTime = 2500_ms;
|
||||
static constexpr auto PulseTime = 100_ms;
|
||||
|
||||
enum struct State {
|
||||
WentDown,
|
||||
Pulse,
|
||||
Unkown
|
||||
};
|
||||
|
||||
SimpleTimer<uint8_t> timer;
|
||||
uint8_t pulse_time;
|
||||
|
||||
void setup() {
|
||||
this->timer.reset();
|
||||
this->pulse_time = StartTime;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
ButtonPulser::setup();
|
||||
}
|
||||
|
||||
State check(GenericButton button) {
|
||||
const auto controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
|
||||
|
||||
if(!controller.button.was_down(button)) {
|
||||
ButtonPulser::reset();
|
||||
if(controller.button.went_down(button)) {
|
||||
return State::WentDown;
|
||||
}
|
||||
}
|
||||
|
||||
if(this->timer.is_expired_for(this->pulse_time)) {
|
||||
this->pulse_time = PulseTime;
|
||||
this->timer.reset();
|
||||
|
||||
return State::Pulse;
|
||||
}
|
||||
return State::Unkown;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef JABYENGINE_PAL
|
||||
static const char TVModeStr[] = "PAL";
|
||||
static constexpr uint16_t ScanlinesV = 288;
|
||||
#else
|
||||
static const char TVModeStr[] = "NTSC";
|
||||
static constexpr uint16_t ScanlinesV = 240;
|
||||
#endif //JABYENGINE_PAL
|
||||
|
||||
namespace PSYQ {
|
||||
static const char*const Name = "PSYQ";
|
||||
|
||||
static void set_offset(uint16_t x, uint16_t y) {
|
||||
GPU::Display::set_offset(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
struct Formular {
|
||||
const char* name;
|
||||
void (*function)(uint16_t, uint16_t);
|
||||
};
|
||||
|
||||
static const Formular ScreenFormulars[] = {
|
||||
Formular{.name = PSYQ::Name, .function = PSYQ::set_offset}
|
||||
};
|
||||
|
||||
static constexpr const GPU::VRAM2VRAM background_img[] = {
|
||||
// current_id of 0 will be rendering on (0, 256)
|
||||
GPU::VRAM2VRAM::create(Make::AreaU16(384, 240, 256, 240), Make::PositionU16(32, GPU::Display::Height)),
|
||||
GPU::VRAM2VRAM::create(Make::AreaU16(384, 240, 256, 240), Make::PositionU16(32, 0)),
|
||||
};
|
||||
|
||||
static auto frame = Frame::create();
|
||||
|
||||
static ButtonPulser button_pulse[4];
|
||||
static void (*update)() = nullptr;
|
||||
static int16_t offset_x = 0;
|
||||
static int16_t offset_y = 0;
|
||||
static uint8_t formular_sel = 0;
|
||||
|
||||
static void update_interactive();
|
||||
static void reset_screen();
|
||||
|
||||
static void update_enter_state() {
|
||||
static const char IntroductionTest[] = "Press START to begin with\n";
|
||||
static constexpr auto IntroductionTestLength = BIOSFont::Info.estimate_str_render_length(IntroductionTest);
|
||||
static constexpr auto CenterPoint = Make::PositionI16((GPU::Display::Width - IntroductionTestLength)/2, (GPU::Display::Height - (2*16))/2);
|
||||
|
||||
const auto controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
|
||||
|
||||
if(controller.button.went_up(GenericButton::R1) || controller.button.went_up(GenericButton::L1)) {
|
||||
// Only one mode supported
|
||||
//formular_sel ^= 1;
|
||||
}
|
||||
|
||||
if(controller.button.went_down(GenericButton::ST)) {
|
||||
update = update_interactive;
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(CenterPoint);
|
||||
FontWriter::bios_font_writer.write(cursor, IntroductionTest, GPU::Color24::White());
|
||||
FontWriter::bios_font_writer.write(cursor, ScreenFormulars[formular_sel].name, GPU::Color24::White());
|
||||
}
|
||||
|
||||
static void update_interactive() {
|
||||
static const auto handle_button = [](ButtonPulser& button_pulse, GenericButton button, int16_t &dst, const int16_t mlp) {
|
||||
switch(button_pulse.check(button)) {
|
||||
case ButtonPulser::State::WentDown:
|
||||
dst += (1*mlp);
|
||||
break;
|
||||
|
||||
case ButtonPulser::State::Pulse:
|
||||
dst += (2*mlp);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
static const char*const ModeStr = "TV-Mode: %s\n";
|
||||
static const char*const FormularStr = "<<%s>>\n";
|
||||
static const char OffsetStr[] = "Offset: %i, %i";
|
||||
|
||||
static constexpr auto CenterLength = FontWriter::BIOSFont::Info.estimate_str_render_length(OffsetStr);
|
||||
static constexpr auto CenterPoint = Make::PositionI16((GPU::Display::Width - CenterLength)/2, (GPU::Display::Height - 3*16)/2);
|
||||
|
||||
const auto& screen_formular = ScreenFormulars[formular_sel];
|
||||
const auto controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
|
||||
|
||||
handle_button(button_pulse[0], GenericButton::Left, offset_x, -1);
|
||||
handle_button(button_pulse[1], GenericButton::Right, offset_x, 1);
|
||||
handle_button(button_pulse[2], GenericButton::Up, offset_y, -1);
|
||||
handle_button(button_pulse[3], GenericButton::Down, offset_y, 1);
|
||||
|
||||
if(controller.button.is_down(GenericButton::R1) && controller.button.is_down(GenericButton::L1)) {
|
||||
for(auto& pulse : button_pulse) {
|
||||
pulse.setup();
|
||||
}
|
||||
reset_screen();
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(CenterPoint.move(-offset_x, -offset_y));
|
||||
FontWriter::bios_font_writer.write(cursor, ModeStr, GPU::Color24::White(), TVModeStr);
|
||||
FontWriter::bios_font_writer.write(cursor, FormularStr, GPU::Color24::White(), screen_formular.name);
|
||||
FontWriter::bios_font_writer.write(cursor, OffsetStr, GPU::Color24::White(), offset_x, offset_y);
|
||||
|
||||
screen_formular.function(offset_x, offset_y);
|
||||
}
|
||||
|
||||
static void reset_screen() {
|
||||
PSYQ::set_offset(0, 0);
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
}
|
||||
|
||||
static void setup() {
|
||||
Shared::back_menu.reset();
|
||||
frame.setup();
|
||||
|
||||
for(auto& pulse : button_pulse) {
|
||||
pulse.setup();
|
||||
}
|
||||
|
||||
update = update_enter_state;
|
||||
formular_sel = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
}
|
||||
|
||||
static bool update_or_exit() {
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
update();
|
||||
return false;
|
||||
}
|
||||
|
||||
static void render() {
|
||||
GPU::render(background_img[GPU::Display::current_id]);
|
||||
frame.render();
|
||||
Shared::back_menu.render();
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
reset_screen();
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
#include "../../../include/shared.hpp"
|
||||
#include "include/frame.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace ScreenCenter {
|
||||
using namespace JabyEngine;
|
||||
using GenericButton = Periphery::GenericController::Button;
|
||||
|
||||
struct ButtonPulser {
|
||||
static constexpr auto StartTime = 2500_ms;
|
||||
static constexpr auto PulseTime = 100_ms;
|
||||
|
||||
enum struct State {
|
||||
WentDown,
|
||||
Pulse,
|
||||
Unkown
|
||||
};
|
||||
|
||||
SimpleTimer<uint8_t> timer;
|
||||
uint8_t pulse_time;
|
||||
|
||||
void setup() {
|
||||
this->timer.reset();
|
||||
this->pulse_time = StartTime;
|
||||
}
|
||||
|
||||
void reset() {
|
||||
ButtonPulser::setup();
|
||||
}
|
||||
|
||||
State check(GenericButton button) {
|
||||
const auto controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
|
||||
|
||||
if(!controller.button.was_down(button)) {
|
||||
ButtonPulser::reset();
|
||||
if(controller.button.went_down(button)) {
|
||||
return State::WentDown;
|
||||
}
|
||||
}
|
||||
|
||||
if(this->timer.is_expired_for(this->pulse_time)) {
|
||||
this->pulse_time = PulseTime;
|
||||
this->timer.reset();
|
||||
|
||||
return State::Pulse;
|
||||
}
|
||||
return State::Unkown;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef JABYENGINE_PAL
|
||||
static const char TVModeStr[] = "PAL";
|
||||
static constexpr uint16_t ScanlinesV = 288;
|
||||
#else
|
||||
static const char TVModeStr[] = "NTSC";
|
||||
static constexpr uint16_t ScanlinesV = 240;
|
||||
#endif //JABYENGINE_PAL
|
||||
|
||||
namespace PSYQ {
|
||||
static const char*const Name = "PSYQ";
|
||||
|
||||
static void set_offset(uint16_t x, uint16_t y) {
|
||||
GPU::Display::set_offset(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
struct Formular {
|
||||
const char* name;
|
||||
void (*function)(uint16_t, uint16_t);
|
||||
};
|
||||
|
||||
static const Formular ScreenFormulars[] = {
|
||||
Formular{.name = PSYQ::Name, .function = PSYQ::set_offset}
|
||||
};
|
||||
|
||||
static constexpr const GPU::VRAM2VRAM background_img[] = {
|
||||
// current_id of 0 will be rendering on (0, 256)
|
||||
GPU::VRAM2VRAM::create(Make::AreaU16(384, 240, 256, 240), Make::PositionU16(32, GPU::Display::Height)),
|
||||
GPU::VRAM2VRAM::create(Make::AreaU16(384, 240, 256, 240), Make::PositionU16(32, 0)),
|
||||
};
|
||||
|
||||
static auto frame = Frame::create();
|
||||
|
||||
static ButtonPulser button_pulse[4];
|
||||
static void (*update)() = nullptr;
|
||||
static int16_t offset_x = 0;
|
||||
static int16_t offset_y = 0;
|
||||
static uint8_t formular_sel = 0;
|
||||
|
||||
static void update_interactive();
|
||||
static void reset_screen();
|
||||
|
||||
static void update_enter_state() {
|
||||
static const char IntroductionTest[] = "Press START to begin with\n";
|
||||
static constexpr auto IntroductionTestLength = BIOSFont::Info.estimate_str_render_length(IntroductionTest);
|
||||
static constexpr auto CenterPoint = Make::PositionI16((GPU::Display::Width - IntroductionTestLength)/2, (GPU::Display::Height - (2*16))/2);
|
||||
|
||||
const auto controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
|
||||
|
||||
if(controller.button.went_up(GenericButton::R1) || controller.button.went_up(GenericButton::L1)) {
|
||||
// Only one mode supported
|
||||
//formular_sel ^= 1;
|
||||
}
|
||||
|
||||
if(controller.button.went_down(GenericButton::ST)) {
|
||||
update = update_interactive;
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(CenterPoint);
|
||||
FontWriter::bios_font_writer.write(cursor, IntroductionTest, GPU::Color24::White());
|
||||
FontWriter::bios_font_writer.write(cursor, ScreenFormulars[formular_sel].name, GPU::Color24::White());
|
||||
}
|
||||
|
||||
static void update_interactive() {
|
||||
static const auto handle_button = [](ButtonPulser& button_pulse, GenericButton button, int16_t &dst, const int16_t mlp) {
|
||||
switch(button_pulse.check(button)) {
|
||||
case ButtonPulser::State::WentDown:
|
||||
dst += (1*mlp);
|
||||
break;
|
||||
|
||||
case ButtonPulser::State::Pulse:
|
||||
dst += (2*mlp);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
static const char*const ModeStr = "TV-Mode: %s\n";
|
||||
static const char*const FormularStr = "<<%s>>\n";
|
||||
static const char OffsetStr[] = "Offset: %i, %i";
|
||||
|
||||
static constexpr auto CenterLength = FontWriter::BIOSFont::Info.estimate_str_render_length(OffsetStr);
|
||||
static constexpr auto CenterPoint = Make::PositionI16((GPU::Display::Width - CenterLength)/2, (GPU::Display::Height - 3*16)/2);
|
||||
|
||||
const auto& screen_formular = ScreenFormulars[formular_sel];
|
||||
const auto controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
|
||||
|
||||
handle_button(button_pulse[0], GenericButton::Left, offset_x, -1);
|
||||
handle_button(button_pulse[1], GenericButton::Right, offset_x, 1);
|
||||
handle_button(button_pulse[2], GenericButton::Up, offset_y, -1);
|
||||
handle_button(button_pulse[3], GenericButton::Down, offset_y, 1);
|
||||
|
||||
if(controller.button.is_down(GenericButton::R1) && controller.button.is_down(GenericButton::L1)) {
|
||||
for(auto& pulse : button_pulse) {
|
||||
pulse.setup();
|
||||
}
|
||||
reset_screen();
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(CenterPoint.move(-offset_x, -offset_y));
|
||||
FontWriter::bios_font_writer.write(cursor, ModeStr, GPU::Color24::White(), TVModeStr);
|
||||
FontWriter::bios_font_writer.write(cursor, FormularStr, GPU::Color24::White(), screen_formular.name);
|
||||
FontWriter::bios_font_writer.write(cursor, OffsetStr, GPU::Color24::White(), offset_x, offset_y);
|
||||
|
||||
screen_formular.function(offset_x, offset_y);
|
||||
}
|
||||
|
||||
static void reset_screen() {
|
||||
PSYQ::set_offset(0, 0);
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
}
|
||||
|
||||
static void setup() {
|
||||
Shared::back_menu.reset();
|
||||
frame.setup();
|
||||
|
||||
for(auto& pulse : button_pulse) {
|
||||
pulse.setup();
|
||||
}
|
||||
|
||||
update = update_enter_state;
|
||||
formular_sel = 0;
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
}
|
||||
|
||||
static bool update_or_exit() {
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
update();
|
||||
return false;
|
||||
}
|
||||
|
||||
static void render() {
|
||||
GPU::render(background_img[GPU::Display::current_id]);
|
||||
frame.render();
|
||||
Shared::back_menu.render();
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
reset_screen();
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +1,17 @@
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
|
||||
namespace ScreenCenter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(BG_IMAGE, "ASSETS/SAND.TIM"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
CDFile Assets[1] = {
|
||||
CDFileBuilder::sony_tim(LBA::BG_IMAGE, TIM::create())
|
||||
};
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
|
||||
namespace ScreenCenter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(BG_IMAGE, "ASSETS/SAND.TIM"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
CDFile Assets[1] = {
|
||||
CDFileBuilder::sony_tim(LBA::BG_IMAGE, TIM::create())
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user