Support PSYQ/No
This commit is contained in:
parent
e84f6f6323
commit
bb88f344ef
|
@ -60,14 +60,9 @@ namespace ScreenCenter {
|
||||||
static constexpr uint16_t ScanlinesV = 240;
|
static constexpr uint16_t ScanlinesV = 240;
|
||||||
#endif //JABYENGINE_PAL
|
#endif //JABYENGINE_PAL
|
||||||
|
|
||||||
static const 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;
|
|
||||||
|
|
||||||
namespace PSYQ {
|
namespace PSYQ {
|
||||||
|
static const char*const Name = "PSYQ";
|
||||||
|
|
||||||
static void set_offset(uint16_t x, uint16_t y) {
|
static void set_offset(uint16_t x, uint16_t y) {
|
||||||
x += 78;
|
x += 78;
|
||||||
y += 43;
|
y += 43;
|
||||||
|
@ -78,28 +73,53 @@ namespace ScreenCenter {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace No$PSX {
|
namespace No$PSX {
|
||||||
|
static const char*const Name = "No$PSX";
|
||||||
|
|
||||||
static void set_offset(uint16_t x, uint16_t y) {
|
static void set_offset(uint16_t x, uint16_t y) {
|
||||||
GPU_IO::GP1.write(GPU_IO::Command::HorizontalDisplayRange(x, (x + GPU::Display::Width*8)));
|
GPU_IO::GP1.write(GPU_IO::Command::HorizontalDisplayRange(x, (x + GPU::Display::Width*8)));
|
||||||
GPU_IO::GP1.write(GPU_IO::Command::VerticalDisplayRange(y - (ScanlinesV/2), y + (ScanlinesV/2)));
|
GPU_IO::GP1.write(GPU_IO::Command::VerticalDisplayRange(y - (ScanlinesV/2), y + (ScanlinesV/2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Formular {
|
||||||
|
const char* name;
|
||||||
|
void (*function)(uint16_t, uint16_t);
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Formular ScreenFormulars[] = {
|
||||||
|
Formular{.name = PSYQ::Name, .function = PSYQ::set_offset},
|
||||||
|
Formular{.name = No$PSX::Name, .function = No$PSX::set_offset}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const 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 update_interactive();
|
||||||
static void reset_screen();
|
static void reset_screen();
|
||||||
|
|
||||||
static void update_enter_state() {
|
static void update_enter_state() {
|
||||||
static const char IntroductionTest[] = "Press START to begin";
|
static const char IntroductionTest[] = "Press START to begin with\n";
|
||||||
static constexpr auto IntroductionTestLength = BIOSFont::Info.estimate_str_render_length(IntroductionTest);
|
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 - 16)/2);
|
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>();
|
const auto controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
|
||||||
|
|
||||||
|
if(controller.button.went_up(GenericButton::R1) || controller.button.went_up(GenericButton::L1)) {
|
||||||
|
formular_sel ^= 1;
|
||||||
|
}
|
||||||
|
|
||||||
if(controller.button.went_down(GenericButton::ST)) {
|
if(controller.button.went_down(GenericButton::ST)) {
|
||||||
update = update_interactive;
|
update = update_interactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cursor = FontWriter::update(CenterPoint);
|
auto cursor = FontWriter::update(CenterPoint);
|
||||||
FontWriter::bios_font_writer.write(cursor, IntroductionTest, GPU::Color24::Red());
|
FontWriter::bios_font_writer.write(cursor, IntroductionTest, GPU::Color24::Red());
|
||||||
|
FontWriter::bios_font_writer.write(cursor, ScreenFormulars[formular_sel].name, GPU::Color24::Red());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update_interactive() {
|
static void update_interactive() {
|
||||||
|
@ -116,13 +136,14 @@ namespace ScreenCenter {
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char*const ModeStr = "TV-Mode: %s\n";
|
static const char*const ModeStr = "TV-Mode: %s\n";
|
||||||
static const char*const FormularStr = "<<PSYQ>>\n";
|
static const char*const FormularStr = "<<%s>>\n";
|
||||||
static const char OffsetStr[] = "Offset: %i, %i";
|
static const char OffsetStr[] = "Offset: %i, %i";
|
||||||
|
|
||||||
static constexpr auto CenterLength = FontWriter::BIOSFont::Info.estimate_str_render_length(OffsetStr);
|
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);
|
static constexpr auto CenterPoint = Make::PositionI16((GPU::Display::Width - CenterLength)/2, (GPU::Display::Height - 3*16)/2);
|
||||||
|
|
||||||
const auto controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
|
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[0], GenericButton::Left, offset_x, -1);
|
||||||
handle_button(button_pulse[1], GenericButton::Right, offset_x, 1);
|
handle_button(button_pulse[1], GenericButton::Right, offset_x, 1);
|
||||||
|
@ -138,10 +159,10 @@ namespace ScreenCenter {
|
||||||
|
|
||||||
auto cursor = FontWriter::update(CenterPoint.move(-offset_x, -offset_y));
|
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, ModeStr, GPU::Color24::White(), TVModeStr);
|
||||||
FontWriter::bios_font_writer.write(cursor, FormularStr, GPU::Color24::White());
|
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);
|
FontWriter::bios_font_writer.write(cursor, OffsetStr, GPU::Color24::White(), offset_x, offset_y);
|
||||||
|
|
||||||
PSYQ::set_offset(offset_x, offset_y);
|
screen_formular.function(offset_x, offset_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reset_screen() {
|
static void reset_screen() {
|
||||||
|
@ -157,9 +178,10 @@ namespace ScreenCenter {
|
||||||
pulse.setup();
|
pulse.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
update = update_enter_state;
|
update = update_enter_state;
|
||||||
offset_x = 0;
|
formular_sel = 0;
|
||||||
offset_y = 0;
|
offset_x = 0;
|
||||||
|
offset_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool update_or_exit() {
|
static bool update_or_exit() {
|
||||||
|
|
Loading…
Reference in New Issue