Fix inconsistent EOL
This commit is contained in:
@@ -1,148 +1,148 @@
|
||||
#include "../../../include/asset_mgr.hpp"
|
||||
#include "../../../include/shared.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 <string.hpp>
|
||||
|
||||
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);
|
||||
|
||||
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) {
|
||||
const auto max = static_cast<int16_t>((strlen(str)*font_info.get_kern_size().width) - GPU::Display::Width + (TextOffset.x << 1));
|
||||
return FontSlider{
|
||||
.count = 0,
|
||||
.max = max,
|
||||
.delta = static_cast<int8_t>(max < 0 ? 0 : 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 struct {
|
||||
using BIOSStringOffset = const char*const (BIOS::Version::*);
|
||||
|
||||
const BIOSStringOffset bios_str_offset;
|
||||
const char*const display_str;
|
||||
FontSlider font_slider;
|
||||
} BIOSStringInfo[] = {
|
||||
{.bios_str_offset = &BIOS::Version::kernel_maker, .display_str = "Kernel-Maker"},
|
||||
{.bios_str_offset = &BIOS::Version::version_str, .display_str = "Version"},
|
||||
{.bios_str_offset = &BIOS::Version::gui_version, .display_str = "GUI-Version"},
|
||||
{.bios_str_offset = &BIOS::Version::copyright, .display_str = "Copyright"},
|
||||
};
|
||||
|
||||
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 NameColorPair bios_name;
|
||||
static FontSlider bios_name_slider;
|
||||
|
||||
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", GPU::Color24::White()};
|
||||
}
|
||||
}
|
||||
|
||||
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, BIOS::version.*(bios_str_info.bios_str_offset));
|
||||
}
|
||||
bios_name_slider = FontSlider::create_for(FontWriter::BIOSFont::Info, bios_name.first);
|
||||
border_tiles[0].concat(border_tiles[1]);
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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, 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.second, bios_name.first);
|
||||
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();
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
#include "../../../include/asset_mgr.hpp"
|
||||
#include "../../../include/shared.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 <string.hpp>
|
||||
|
||||
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);
|
||||
|
||||
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) {
|
||||
const auto max = static_cast<int16_t>((strlen(str)*font_info.get_kern_size().width) - GPU::Display::Width + (TextOffset.x << 1));
|
||||
return FontSlider{
|
||||
.count = 0,
|
||||
.max = max,
|
||||
.delta = static_cast<int8_t>(max < 0 ? 0 : 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 struct {
|
||||
using BIOSStringOffset = const char*const (BIOS::Version::*);
|
||||
|
||||
const BIOSStringOffset bios_str_offset;
|
||||
const char*const display_str;
|
||||
FontSlider font_slider;
|
||||
} BIOSStringInfo[] = {
|
||||
{.bios_str_offset = &BIOS::Version::kernel_maker, .display_str = "Kernel-Maker"},
|
||||
{.bios_str_offset = &BIOS::Version::version_str, .display_str = "Version"},
|
||||
{.bios_str_offset = &BIOS::Version::gui_version, .display_str = "GUI-Version"},
|
||||
{.bios_str_offset = &BIOS::Version::copyright, .display_str = "Copyright"},
|
||||
};
|
||||
|
||||
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 NameColorPair bios_name;
|
||||
static FontSlider bios_name_slider;
|
||||
|
||||
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", GPU::Color24::White()};
|
||||
}
|
||||
}
|
||||
|
||||
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, BIOS::version.*(bios_str_info.bios_str_offset));
|
||||
}
|
||||
bios_name_slider = FontSlider::create_for(FontWriter::BIOSFont::Info, bios_name.first);
|
||||
border_tiles[0].concat(border_tiles[1]);
|
||||
}
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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, 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.second, bios_name.first);
|
||||
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();
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,110 +1,110 @@
|
||||
#include "include/controller_state.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/SPU/spu.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using DigitalButton = Periphery::AnalogeController::Button;
|
||||
using namespace JabyEngine;
|
||||
|
||||
static void set_active(GPU::SPRT_16::Linked& sprt, bool is_active) {
|
||||
sprt->tex_offset.y = is_active ? 16 : 0;
|
||||
if(is_active) {
|
||||
SPU::voice[1].play_if_end();
|
||||
}
|
||||
}
|
||||
|
||||
static void set_active(GPU::POLY_FT4::Linked& poly, bool is_active) {
|
||||
poly->tex_offset0.y = is_active ? 16 : 0;
|
||||
poly->tex_offset1.y = is_active ? 16 : 0;
|
||||
poly->tex_offset2.y = is_active ? 32 : 16;
|
||||
poly->tex_offset3.y = is_active ? 32 : 16;
|
||||
|
||||
if(is_active) {
|
||||
SPU::voice[1].play_if_end();
|
||||
}
|
||||
}
|
||||
|
||||
static const char* get_type_name(Periphery::ControllerType type) {
|
||||
switch(type) {
|
||||
case Periphery::ControllerType::Unkown:
|
||||
return "Unkown";
|
||||
|
||||
case Periphery::ControllerType::Mouse:
|
||||
return "Mouse";
|
||||
|
||||
case Periphery::ControllerType::NegCon:
|
||||
return "NegCon";
|
||||
|
||||
case Periphery::ControllerType::HyperBlaster:
|
||||
return "HyperBlaster";
|
||||
|
||||
case Periphery::ControllerType::Controller:
|
||||
return "Digital Controller";
|
||||
|
||||
case Periphery::ControllerType::ArcadeFlightStick:
|
||||
return "Flight Stick";
|
||||
|
||||
case Periphery::ControllerType::GCon:
|
||||
return "GCon";
|
||||
|
||||
case Periphery::ControllerType::DualShock:
|
||||
return "DualShock";
|
||||
|
||||
case Periphery::ControllerType::MultiTap:
|
||||
return "MultiTap";
|
||||
|
||||
default:
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerState :: setup() {
|
||||
for(size_t n = 0; n < 2; n++) {
|
||||
GPU::LinkHelper::link_array(GPU::LinkHelper::link_array(&this->tex_page[n], this->buttons[n]), this->arrows[n]);
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerState :: update(const Periphery::AnalogeController* controller, JabyEngine::FontWriter& font_writer) {
|
||||
static const DigitalButton ButtonSprtMap[] = {
|
||||
DigitalButton::Triangle, DigitalButton::Circle, DigitalButton::Cross, DigitalButton::Square,
|
||||
DigitalButton::ST, DigitalButton::SEL, DigitalButton::L1, DigitalButton::L2, DigitalButton::R1, DigitalButton::R2,
|
||||
DigitalButton::L3, DigitalButton::R3
|
||||
};
|
||||
static const DigitalButton ArrowPolyMap[] = {
|
||||
DigitalButton::Up, DigitalButton::Right, DigitalButton::Down, DigitalButton::Left
|
||||
};
|
||||
|
||||
auto& cur_button_sprts = this->buttons[GPU::update_id()];
|
||||
auto& cur_arrow_poly = this->arrows[GPU::update_id()];
|
||||
|
||||
if(controller) {
|
||||
for(size_t n = 0; n < sizeof(ButtonSprtMap)/sizeof(ButtonSprtMap[0]); n++) {
|
||||
set_active(cur_button_sprts[n], controller->button.is_down(ButtonSprtMap[n]));
|
||||
}
|
||||
for(size_t n = 0; n < sizeof(ArrowPolyMap)/sizeof(ArrowPolyMap[0]); n++) {
|
||||
set_active(cur_arrow_poly[n], controller->button.is_down(ArrowPolyMap[n]));
|
||||
}
|
||||
|
||||
set_active(cur_button_sprts[12], controller->header.state == Periphery::RawController::State::Disconnected);
|
||||
|
||||
// Text stuff down here
|
||||
const auto offset_point = cur_button_sprts[1]->position;
|
||||
const auto left_stick = controller->get_left_stick_pos();
|
||||
const auto right_stick = controller->get_right_stick_pos();
|
||||
|
||||
auto cursor = Cursor::create(offset_point.move(16, 0), 0);
|
||||
font_writer.write(cursor, "Right: %i, %i\nLeft : %i, %i\n", right_stick.x, right_stick.y, left_stick.x, left_stick.y);
|
||||
font_writer.write(cursor, "[%s]", get_type_name(static_cast<Periphery::ControllerType>(controller->get_type())));
|
||||
}
|
||||
|
||||
else {
|
||||
auto cursor = Cursor::create(Make::PositionI16(cur_arrow_poly[3]->vertex0.x, cur_button_sprts[0]->position.y), 0);
|
||||
font_writer.write(cursor, "!!This Port is not\nenabled in JabyEngine!!", GPU::Color24::Red());
|
||||
this->tex_page[GPU::update_id()].terminate();
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerState :: render() {
|
||||
GPU::render(this->tex_page[GPU::render_id()]);
|
||||
}
|
||||
#include "include/controller_state.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/SPU/spu.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using DigitalButton = Periphery::AnalogeController::Button;
|
||||
using namespace JabyEngine;
|
||||
|
||||
static void set_active(GPU::SPRT_16::Linked& sprt, bool is_active) {
|
||||
sprt->tex_offset.y = is_active ? 16 : 0;
|
||||
if(is_active) {
|
||||
SPU::voice[1].play_if_end();
|
||||
}
|
||||
}
|
||||
|
||||
static void set_active(GPU::POLY_FT4::Linked& poly, bool is_active) {
|
||||
poly->tex_offset0.y = is_active ? 16 : 0;
|
||||
poly->tex_offset1.y = is_active ? 16 : 0;
|
||||
poly->tex_offset2.y = is_active ? 32 : 16;
|
||||
poly->tex_offset3.y = is_active ? 32 : 16;
|
||||
|
||||
if(is_active) {
|
||||
SPU::voice[1].play_if_end();
|
||||
}
|
||||
}
|
||||
|
||||
static const char* get_type_name(Periphery::ControllerType type) {
|
||||
switch(type) {
|
||||
case Periphery::ControllerType::Unkown:
|
||||
return "Unkown";
|
||||
|
||||
case Periphery::ControllerType::Mouse:
|
||||
return "Mouse";
|
||||
|
||||
case Periphery::ControllerType::NegCon:
|
||||
return "NegCon";
|
||||
|
||||
case Periphery::ControllerType::HyperBlaster:
|
||||
return "HyperBlaster";
|
||||
|
||||
case Periphery::ControllerType::Controller:
|
||||
return "Digital Controller";
|
||||
|
||||
case Periphery::ControllerType::ArcadeFlightStick:
|
||||
return "Flight Stick";
|
||||
|
||||
case Periphery::ControllerType::GCon:
|
||||
return "GCon";
|
||||
|
||||
case Periphery::ControllerType::DualShock:
|
||||
return "DualShock";
|
||||
|
||||
case Periphery::ControllerType::MultiTap:
|
||||
return "MultiTap";
|
||||
|
||||
default:
|
||||
return "???";
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerState :: setup() {
|
||||
for(size_t n = 0; n < 2; n++) {
|
||||
GPU::LinkHelper::link_array(GPU::LinkHelper::link_array(&this->tex_page[n], this->buttons[n]), this->arrows[n]);
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerState :: update(const Periphery::AnalogeController* controller, JabyEngine::FontWriter& font_writer) {
|
||||
static const DigitalButton ButtonSprtMap[] = {
|
||||
DigitalButton::Triangle, DigitalButton::Circle, DigitalButton::Cross, DigitalButton::Square,
|
||||
DigitalButton::ST, DigitalButton::SEL, DigitalButton::L1, DigitalButton::L2, DigitalButton::R1, DigitalButton::R2,
|
||||
DigitalButton::L3, DigitalButton::R3
|
||||
};
|
||||
static const DigitalButton ArrowPolyMap[] = {
|
||||
DigitalButton::Up, DigitalButton::Right, DigitalButton::Down, DigitalButton::Left
|
||||
};
|
||||
|
||||
auto& cur_button_sprts = this->buttons[GPU::update_id()];
|
||||
auto& cur_arrow_poly = this->arrows[GPU::update_id()];
|
||||
|
||||
if(controller) {
|
||||
for(size_t n = 0; n < sizeof(ButtonSprtMap)/sizeof(ButtonSprtMap[0]); n++) {
|
||||
set_active(cur_button_sprts[n], controller->button.is_down(ButtonSprtMap[n]));
|
||||
}
|
||||
for(size_t n = 0; n < sizeof(ArrowPolyMap)/sizeof(ArrowPolyMap[0]); n++) {
|
||||
set_active(cur_arrow_poly[n], controller->button.is_down(ArrowPolyMap[n]));
|
||||
}
|
||||
|
||||
set_active(cur_button_sprts[12], controller->header.state == Periphery::RawController::State::Disconnected);
|
||||
|
||||
// Text stuff down here
|
||||
const auto offset_point = cur_button_sprts[1]->position;
|
||||
const auto left_stick = controller->get_left_stick_pos();
|
||||
const auto right_stick = controller->get_right_stick_pos();
|
||||
|
||||
auto cursor = Cursor::create(offset_point.move(16, 0), 0);
|
||||
font_writer.write(cursor, "Right: %i, %i\nLeft : %i, %i\n", right_stick.x, right_stick.y, left_stick.x, left_stick.y);
|
||||
font_writer.write(cursor, "[%s]", get_type_name(static_cast<Periphery::ControllerType>(controller->get_type())));
|
||||
}
|
||||
|
||||
else {
|
||||
auto cursor = Cursor::create(Make::PositionI16(cur_arrow_poly[3]->vertex0.x, cur_button_sprts[0]->position.y), 0);
|
||||
font_writer.write(cursor, "!!This Port is not\nenabled in JabyEngine!!", GPU::Color24::Red());
|
||||
this->tex_page[GPU::update_id()].terminate();
|
||||
}
|
||||
}
|
||||
|
||||
void ControllerState :: render() {
|
||||
GPU::render(this->tex_page[GPU::render_id()]);
|
||||
}
|
||||
}
|
@@ -1,47 +1,47 @@
|
||||
#include "../../../include/shared.hpp"
|
||||
#include "include/controller_state.hpp"
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static auto controller_state0 = ControllerState::create(Make::PositionI16(0, 0));
|
||||
static auto controller_state1 = ControllerState::create(Make::PositionI16(0, 76));
|
||||
|
||||
static void setup() {
|
||||
Shared::back_menu.reset();
|
||||
controller_state0.setup();
|
||||
controller_state1.setup();
|
||||
}
|
||||
|
||||
static bool update_or_exit() {
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
controller_state0.update(&Periphery::get_primary_controller_as<JabyEngine::Periphery::AnalogeController>(), FontWriter::bios_font_writer);
|
||||
controller_state1.update(Periphery::PortCount > 1 ? &Periphery::get_controller_as<JabyEngine::Periphery::AnalogeController>(1, 0) : nullptr, FontWriter::bios_font_writer);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void render() {
|
||||
GPU::render(Shared::background);
|
||||
controller_state0.render();
|
||||
controller_state1.render();
|
||||
FontWriter::bios_font_writer.render();
|
||||
Shared::back_menu.render();
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
#include "../../../include/shared.hpp"
|
||||
#include "include/controller_state.hpp"
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static auto controller_state0 = ControllerState::create(Make::PositionI16(0, 0));
|
||||
static auto controller_state1 = ControllerState::create(Make::PositionI16(0, 76));
|
||||
|
||||
static void setup() {
|
||||
Shared::back_menu.reset();
|
||||
controller_state0.setup();
|
||||
controller_state1.setup();
|
||||
}
|
||||
|
||||
static bool update_or_exit() {
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
controller_state0.update(&Periphery::get_primary_controller_as<JabyEngine::Periphery::AnalogeController>(), FontWriter::bios_font_writer);
|
||||
controller_state1.update(Periphery::PortCount > 1 ? &Periphery::get_controller_as<JabyEngine::Periphery::AnalogeController>(1, 0) : nullptr, FontWriter::bios_font_writer);
|
||||
return false;
|
||||
}
|
||||
|
||||
static void render() {
|
||||
GPU::render(Shared::background);
|
||||
controller_state0.render();
|
||||
controller_state1.render();
|
||||
FontWriter::bios_font_writer.render();
|
||||
Shared::back_menu.render();
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,18 +1,18 @@
|
||||
#include "include/controller_test_assets.hpp"
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(CONT, "ASSETS/CONT/CONT.IMG"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
CDFile Assets[1] = {
|
||||
CDFileBuilder::simple_tim(LBA::CONT, ControllerButtonTIM),
|
||||
};
|
||||
}
|
||||
#include "include/controller_test_assets.hpp"
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(CONT, "ASSETS/CONT/CONT.IMG"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
CDFile Assets[1] = {
|
||||
CDFileBuilder::simple_tim(LBA::CONT, ControllerButtonTIM),
|
||||
};
|
||||
}
|
||||
|
@@ -1,67 +1,67 @@
|
||||
#pragma once
|
||||
#include "controller_test_assets.hpp"
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Periphery/controller.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
class ControllerState {
|
||||
private:
|
||||
GPU::TexPage::Linked tex_page[2];
|
||||
GPU::SPRT_16::Linked buttons[2][13];
|
||||
GPU::POLY_FT4::Linked arrows[2][4];
|
||||
|
||||
public:
|
||||
static constexpr ControllerState create(GPU::PositionI16 offset = Make::PositionI16(0, 0)) {
|
||||
ControllerState state;
|
||||
|
||||
for(auto& tex_page : state.tex_page) {
|
||||
tex_page = Make::TexPage(ControllerButtonTIM.get_texture_position(), GPU::TextureColorMode::clut4).linked();
|
||||
}
|
||||
|
||||
for(auto& buttons : state.buttons) {
|
||||
// Triangle
|
||||
buttons[0] = Make::SPRT_16(Make::Vertex(71, 0).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(0, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Circle
|
||||
buttons[1] = Make::SPRT_16(Make::Vertex(82, 12).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(1, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Cross
|
||||
buttons[2] = Make::SPRT_16(Make::Vertex(71, 23).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(2, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Square
|
||||
buttons[3] = Make::SPRT_16(Make::Vertex(60, 11).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(3, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Play
|
||||
buttons[4] = Make::SPRT_16(Make::Vertex(51, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(4, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Block
|
||||
buttons[5] = Make::SPRT_16(Make::Vertex(24, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(5, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// L1
|
||||
buttons[6] = Make::SPRT_16(Make::Vertex(7, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// L2
|
||||
buttons[7] = Make::SPRT_16(Make::Vertex(7, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// R1
|
||||
buttons[8] = Make::SPRT_16(Make::Vertex(71, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// R2
|
||||
buttons[9] = Make::SPRT_16(Make::Vertex(71, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// L3
|
||||
buttons[10] = Make::SPRT_16(Make::Vertex(24, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// R3
|
||||
buttons[11] = Make::SPRT_16(Make::Vertex(52, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Connection Symbol
|
||||
buttons[12] = Make::SPRT_16(Make::Vertex(37, 9).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(10, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
}
|
||||
|
||||
for(auto& arrows : state.arrows) {
|
||||
arrows[0] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect( Make::AreaI16(Make::PositionI16( 7, 5).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
||||
arrows[1] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect270(Make::AreaI16(Make::PositionI16(14, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
||||
arrows[2] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect180(Make::AreaI16(Make::PositionI16( 7, 17).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
||||
arrows[3] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect90( Make::AreaI16(Make::PositionI16( 0, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void setup();
|
||||
void update(const Periphery::AnalogeController* controller, JabyEngine::FontWriter& font_writer);
|
||||
void render();
|
||||
};
|
||||
#pragma once
|
||||
#include "controller_test_assets.hpp"
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Periphery/controller.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
class ControllerState {
|
||||
private:
|
||||
GPU::TexPage::Linked tex_page[2];
|
||||
GPU::SPRT_16::Linked buttons[2][13];
|
||||
GPU::POLY_FT4::Linked arrows[2][4];
|
||||
|
||||
public:
|
||||
static constexpr ControllerState create(GPU::PositionI16 offset = Make::PositionI16(0, 0)) {
|
||||
ControllerState state;
|
||||
|
||||
for(auto& tex_page : state.tex_page) {
|
||||
tex_page = Make::TexPage(ControllerButtonTIM.get_texture_position(), GPU::TextureColorMode::clut4).linked();
|
||||
}
|
||||
|
||||
for(auto& buttons : state.buttons) {
|
||||
// Triangle
|
||||
buttons[0] = Make::SPRT_16(Make::Vertex(71, 0).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(0, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Circle
|
||||
buttons[1] = Make::SPRT_16(Make::Vertex(82, 12).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(1, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Cross
|
||||
buttons[2] = Make::SPRT_16(Make::Vertex(71, 23).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(2, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Square
|
||||
buttons[3] = Make::SPRT_16(Make::Vertex(60, 11).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(3, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Play
|
||||
buttons[4] = Make::SPRT_16(Make::Vertex(51, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(4, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Block
|
||||
buttons[5] = Make::SPRT_16(Make::Vertex(24, 21).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(5, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// L1
|
||||
buttons[6] = Make::SPRT_16(Make::Vertex(7, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// L2
|
||||
buttons[7] = Make::SPRT_16(Make::Vertex(7, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// R1
|
||||
buttons[8] = Make::SPRT_16(Make::Vertex(71, 39).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(7, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// R2
|
||||
buttons[9] = Make::SPRT_16(Make::Vertex(71, 49).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(8, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// L3
|
||||
buttons[10] = Make::SPRT_16(Make::Vertex(24, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// R3
|
||||
buttons[11] = Make::SPRT_16(Make::Vertex(52, 34).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(9, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
// Connection Symbol
|
||||
buttons[12] = Make::SPRT_16(Make::Vertex(37, 9).move(offset.x, offset.y), Make::OffsetPageWithClut(GPU::PageOffset::from_tile_id16(10, Make::SizeI16(16, 16)), Make::PageClut(ControllerButtonTIM.get_clut_position()))).linked();
|
||||
}
|
||||
|
||||
for(auto& arrows : state.arrows) {
|
||||
arrows[0] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect( Make::AreaI16(Make::PositionI16( 7, 5).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
||||
arrows[1] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect270(Make::AreaI16(Make::PositionI16(14, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
||||
arrows[2] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect180(Make::AreaI16(Make::PositionI16( 7, 17).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
||||
arrows[3] = Make::POLY_FT4(__jabyengine_polyFT4_vertex_rect90( Make::AreaI16(Make::PositionI16( 0, 11).move(offset.x, offset.y), Make::SizeI16(16, 16)), Make::PositionI16(6*16, 0)), Make::TPage(ControllerButtonTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4), Make::PageClut(ControllerButtonTIM.get_clut_position())).linked();
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void setup();
|
||||
void update(const Periphery::AnalogeController* controller, JabyEngine::FontWriter& font_writer);
|
||||
void render();
|
||||
};
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static constexpr auto ControllerButtonTIM = SimpleTIM::create(384, 0, 384, 511);
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
namespace ControllerTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static constexpr auto ControllerButtonTIM = SimpleTIM::create(384, 0, 384, 511);
|
||||
}
|
@@ -1,78 +1,78 @@
|
||||
#include "../../../include/shared.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
|
||||
namespace FontCycler {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static const char*const ASCII = "!\"#$%&'()*+,-./0\n123456789:;<=>?@\nABCDEFGHIJKLMNOP\nQRSTUVWXYZ[\\]^_`\nabcdefghijklmnop\nqrstuvwxyz{|}~\n";
|
||||
|
||||
static JabyEngine::FontWriter*const FontWriters[] = {
|
||||
&FontWriter::bios_font_writer,
|
||||
&FontWriter::new_font_writer,
|
||||
};
|
||||
static constexpr auto MaxFontSelector = (sizeof(FontWriters)/sizeof(FontWriters[0])) - 1;
|
||||
static uint8_t font_selector = 0;
|
||||
|
||||
static void increment_font_selector() {
|
||||
if(font_selector == MaxFontSelector) {
|
||||
font_selector = 0;
|
||||
}
|
||||
|
||||
else {
|
||||
font_selector++;
|
||||
}
|
||||
}
|
||||
|
||||
static void decrement_font_selector() {
|
||||
if(font_selector == 0) {
|
||||
font_selector = MaxFontSelector;
|
||||
}
|
||||
|
||||
else {
|
||||
font_selector--;
|
||||
}
|
||||
}
|
||||
|
||||
static void setup() {
|
||||
Shared::back_menu.reset();
|
||||
font_selector = 0;
|
||||
}
|
||||
|
||||
static bool update_or_exit() {
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto& controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
|
||||
if(controller.button.went_up(Periphery::GenericController::Button::L1)) {
|
||||
decrement_font_selector();
|
||||
}
|
||||
if(controller.button.went_up(Periphery::GenericController::Button::R1)) {
|
||||
increment_font_selector();
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(Make::PositionI16(8, 8));
|
||||
FontWriters[font_selector]->write(cursor, ASCII);
|
||||
FontWriters[font_selector]->write(cursor, "\nPress L1 or R1 to cycle\nthrough fonts");
|
||||
return false;
|
||||
}
|
||||
|
||||
static void render() {
|
||||
FontWriters[font_selector]->render();
|
||||
Shared::back_menu.render();
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
#include "../../../include/shared.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
|
||||
namespace FontCycler {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static const char*const ASCII = "!\"#$%&'()*+,-./0\n123456789:;<=>?@\nABCDEFGHIJKLMNOP\nQRSTUVWXYZ[\\]^_`\nabcdefghijklmnop\nqrstuvwxyz{|}~\n";
|
||||
|
||||
static JabyEngine::FontWriter*const FontWriters[] = {
|
||||
&FontWriter::bios_font_writer,
|
||||
&FontWriter::new_font_writer,
|
||||
};
|
||||
static constexpr auto MaxFontSelector = (sizeof(FontWriters)/sizeof(FontWriters[0])) - 1;
|
||||
static uint8_t font_selector = 0;
|
||||
|
||||
static void increment_font_selector() {
|
||||
if(font_selector == MaxFontSelector) {
|
||||
font_selector = 0;
|
||||
}
|
||||
|
||||
else {
|
||||
font_selector++;
|
||||
}
|
||||
}
|
||||
|
||||
static void decrement_font_selector() {
|
||||
if(font_selector == 0) {
|
||||
font_selector = MaxFontSelector;
|
||||
}
|
||||
|
||||
else {
|
||||
font_selector--;
|
||||
}
|
||||
}
|
||||
|
||||
static void setup() {
|
||||
Shared::back_menu.reset();
|
||||
font_selector = 0;
|
||||
}
|
||||
|
||||
static bool update_or_exit() {
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto& controller = Periphery::get_primary_controller_as<Periphery::GenericController>();
|
||||
if(controller.button.went_up(Periphery::GenericController::Button::L1)) {
|
||||
decrement_font_selector();
|
||||
}
|
||||
if(controller.button.went_up(Periphery::GenericController::Button::R1)) {
|
||||
increment_font_selector();
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(Make::PositionI16(8, 8));
|
||||
FontWriters[font_selector]->write(cursor, ASCII);
|
||||
FontWriters[font_selector]->write(cursor, "\nPress L1 or R1 to cycle\nthrough fonts");
|
||||
return false;
|
||||
}
|
||||
|
||||
static void render() {
|
||||
FontWriters[font_selector]->render();
|
||||
Shared::back_menu.render();
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,174 +1,174 @@
|
||||
#include "../../../include/shared.hpp"
|
||||
#include "include/gpu_test_assets.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <PSX/Timer/high_res_timer.hpp>
|
||||
|
||||
namespace GPUTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
// Some default values for the objects
|
||||
static constexpr auto TriangleColor = GPU::Color24::from_rgb(0x0, 0xFF, 0xFF);
|
||||
static constexpr auto TriangleArea = Make::AreaI16(Make::PositionI16(0, 0), Make::SizeI16(64, 64));
|
||||
static constexpr auto TriangleTPage = Make::TPage(TexPageTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4);
|
||||
static constexpr auto TriangleClut = Make::PageClut(TexPageTIM.get_clut_position());
|
||||
|
||||
static constexpr auto RectangleColor = GPU::Color24::from_rgb(0x80, 0x80, 0xFF);
|
||||
static constexpr auto RectangleArea = Make::AreaI16(Make::PositionI16(0, TriangleArea.size.height), Make::SizeI16(80, 80));
|
||||
static constexpr auto RectangleTPage = Make::TPage(IconTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4);
|
||||
static constexpr auto RectangleClut = Make::PageClut(IconTIM.get_clut_position());
|
||||
|
||||
static constexpr auto LineColor = GPU::Color24::from_rgb(0xFF, 0x0, 0x0);
|
||||
|
||||
static constexpr const auto triangle1 = Make::POLY_F3({
|
||||
Make::Vertex(TriangleArea.position.x, TriangleArea.position.y),
|
||||
Make::Vertex(TriangleArea.size.width, TriangleArea.size.height),
|
||||
Make::Vertex(TriangleArea.position.x, TriangleArea.size.height)
|
||||
}, TriangleColor
|
||||
);
|
||||
static constexpr const auto triangle2 = Make::POLY_FT3({
|
||||
Make::Vertex(TriangleArea.position.x, TriangleArea.position.y),
|
||||
Make::Vertex(TriangleArea.size.width, TriangleArea.position.y),
|
||||
Make::Vertex(TriangleArea.size.width, TriangleArea.size.height)
|
||||
},{
|
||||
// Texture
|
||||
Make::PageOffset(TriangleArea.position.x, TriangleArea.position.y),
|
||||
Make::PageOffset(TriangleArea.size.width, TriangleArea.position.y),
|
||||
Make::PageOffset(TriangleArea.size.width, TriangleArea.size.height)
|
||||
}, TriangleTPage, TriangleClut, GPU::Color24::Grey()
|
||||
);
|
||||
static constexpr const auto triangle3 = Make::POLY_G3({
|
||||
{triangle1.vertex0.move(TriangleArea.size.width, 0), GPU::Color24::Red()},
|
||||
{triangle1.vertex1.move(TriangleArea.size.width, 0), GPU::Color24::Green()},
|
||||
{triangle1.vertex2.move(TriangleArea.size.width, 0), GPU::Color24::Blue()}}
|
||||
);
|
||||
static constexpr const auto triangle4 = Make::POLY_GT3({
|
||||
{triangle2.vertex0.move(TriangleArea.size.width, 0), triangle2.tex_offset0, GPU::Color24::Red()},
|
||||
{triangle2.vertex1.move(TriangleArea.size.width, 0), triangle2.tex_offset1, GPU::Color24::Blue()},
|
||||
{triangle2.vertex2.move(TriangleArea.size.width, 0), triangle2.tex_offset2, GPU::Color24::Green()}},
|
||||
TriangleTPage,
|
||||
TriangleClut
|
||||
);
|
||||
|
||||
static constexpr const auto rectangle1 = Make::POLY_F4(RectangleArea, RectangleColor);
|
||||
static constexpr const auto rectangle2 = Make::POLY_FT4(Make::AreaI16(
|
||||
RectangleArea.position.move(RectangleArea.size.width, 0), RectangleArea.size), Make::PageOffset(0, 0),
|
||||
RectangleTPage,
|
||||
RectangleClut,
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
static constexpr const auto rectangle3 = Make::POLY_G4(
|
||||
{RectangleArea.position.move(RectangleArea.size.width*2, 0), RectangleArea.size}, {
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()});
|
||||
static constexpr const auto rectangle4 = Make::POLY_GT4(Make::AreaI16(
|
||||
RectangleArea.position.move(RectangleArea.size.width*3, 0), RectangleArea.size), Make::PageOffset(0, 0),
|
||||
RectangleTPage,
|
||||
RectangleClut, {
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()}
|
||||
);
|
||||
static constexpr const auto rectangle5 = Make::POLY_GT4(Make::AreaI16(
|
||||
RectangleArea.position.move(0, RectangleArea.size.height), RectangleArea.size), Make::PageOffset(0, 0),
|
||||
RectangleTPage,
|
||||
RectangleClut, {
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()}
|
||||
).set_semi_transparent(true);
|
||||
|
||||
static constexpr const auto line1 = Make::LINE_F(LineColor,
|
||||
Make::Vertex(0, 0),
|
||||
Make::Vertex(GPU::Display::Width, GPU::Display::Height)
|
||||
);
|
||||
static constexpr const auto line2 = Make::LINE_F(LineColor.invert(),
|
||||
Make::Vertex(0, 0),
|
||||
Make::Vertex(16, 0),
|
||||
Make::Vertex(16, 16),
|
||||
Make::Vertex(0, 0)
|
||||
);
|
||||
static constexpr const auto line3 = Make::LINE_G(
|
||||
GPU::ColorVertex{LineColor, Make::Vertex(GPU::Display::Width, 0)},
|
||||
GPU::ColorVertex{LineColor.invert(), Make::Vertex(0, GPU::Display::Height)}
|
||||
);
|
||||
static constexpr const auto line4 = Make::LINE_G(
|
||||
GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)},
|
||||
GPU::ColorVertex{GPU::Color24::Green(), Make::Vertex(0, 16)},
|
||||
GPU::ColorVertex{GPU::Color24::Blue(), Make::Vertex(16, 16)},
|
||||
GPU::ColorVertex{GPU::Color24::White(), Make::Vertex(0, 0)}
|
||||
);
|
||||
|
||||
static constexpr const auto rect1 = Make::TILE(Make::AreaI16(Make::PositionI16(GPU::Display::Width - 32, GPU::Display::Height - 32), Make::SizeI16(32, 32)), GPU::Color24::Green());
|
||||
static constexpr const auto rect2 = Make::TILE_16(Make::PositionI16(GPU::Display::Width - 16, GPU::Display::Height - 16), GPU::Color24::Blue());
|
||||
static constexpr const auto rect3 = Make::TILE_8(Make::PositionI16(GPU::Display::Width - 8, GPU::Display::Height - 8), GPU::Color24::Yellow());
|
||||
static constexpr const auto rect4 = Make::TILE_1(Make::PositionI16(GPU::Display::Width - 1, GPU::Display::Height - 1), GPU::Color24::Red());
|
||||
|
||||
static constexpr const auto texpage = Make::TexPage(TexPageTIM.get_texture_position(), GPU::TextureColorMode::clut4);
|
||||
static constexpr const auto rect5 = Make::SPRT(Make::AreaI16(Make::PositionI16(0, GPU::Display::Height - 32), Make::SizeI16(32, 32)), {Make::PageOffset(0, 0), TriangleClut}, GPU::Color24::Green());
|
||||
static constexpr const auto rect6 = Make::SPRT_16(Make::Vertex(0, GPU::Display::Height - 16), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Blue());
|
||||
static constexpr const auto rect7 = Make::SPRT_8(Make::Vertex(0, GPU::Display::Height - 8), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Yellow());
|
||||
static constexpr const auto rect8 = Make::SPRT_1(Make::Vertex(0, GPU::Display::Height - 1), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Red());
|
||||
|
||||
static auto rect9 = Make::SPRT(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2), Make::SizeI16(32, 32)).centered(), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Grey()).linked();
|
||||
static auto rect10 = Make::SPRT(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2 - 32), Make::SizeI16(32, 32)).centered(), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Grey()).linked();
|
||||
|
||||
void main() {
|
||||
rect9.concat(rect10);
|
||||
Shared::back_menu.reset();
|
||||
HighResTime::enable();
|
||||
|
||||
auto start_time = HighResTime::get_time_stamp();
|
||||
auto time_passed = 0;
|
||||
while(true) {
|
||||
// Update Phase
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(Make::PositionI16((GPU::Display::Width - 160)/2, GPU::Display::Height - 32));
|
||||
FontWriter::bios_font_writer.write(cursor, "Time: %ims", GPU::Color24::Blue(), time_passed);
|
||||
|
||||
GPU::swap_buffers_vsync(1);
|
||||
const auto end_time = HighResTime::get_time_stamp();
|
||||
time_passed = start_time.milliseconds_to(end_time);
|
||||
start_time = end_time;
|
||||
|
||||
GPU::render(triangle1);
|
||||
GPU::render(triangle2);
|
||||
GPU::render(triangle3);
|
||||
GPU::render(triangle4);
|
||||
|
||||
GPU::render(rectangle1);
|
||||
GPU::render(rectangle2);
|
||||
GPU::render(rectangle3);
|
||||
GPU::render(rectangle4);
|
||||
GPU::render(rectangle5);
|
||||
|
||||
GPU::render(rect1);
|
||||
GPU::render(rect2);
|
||||
GPU::render(rect3);
|
||||
GPU::render(rect4);
|
||||
GPU::render(texpage);
|
||||
GPU::render(rect5);
|
||||
GPU::render(rect6);
|
||||
GPU::render(rect7);
|
||||
GPU::render(rect8);
|
||||
|
||||
GPU::render(line1);
|
||||
GPU::render(line2);
|
||||
GPU::render(line3);
|
||||
GPU::render(line4);
|
||||
|
||||
GPU::render(rect9);
|
||||
Shared::back_menu.render();
|
||||
}
|
||||
HighResTime::disable();
|
||||
}
|
||||
}
|
||||
#include "../../../include/shared.hpp"
|
||||
#include "include/gpu_test_assets.hpp"
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <PSX/Timer/high_res_timer.hpp>
|
||||
|
||||
namespace GPUTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
// Some default values for the objects
|
||||
static constexpr auto TriangleColor = GPU::Color24::from_rgb(0x0, 0xFF, 0xFF);
|
||||
static constexpr auto TriangleArea = Make::AreaI16(Make::PositionI16(0, 0), Make::SizeI16(64, 64));
|
||||
static constexpr auto TriangleTPage = Make::TPage(TexPageTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4);
|
||||
static constexpr auto TriangleClut = Make::PageClut(TexPageTIM.get_clut_position());
|
||||
|
||||
static constexpr auto RectangleColor = GPU::Color24::from_rgb(0x80, 0x80, 0xFF);
|
||||
static constexpr auto RectangleArea = Make::AreaI16(Make::PositionI16(0, TriangleArea.size.height), Make::SizeI16(80, 80));
|
||||
static constexpr auto RectangleTPage = Make::TPage(IconTIM.get_texture_position(), GPU::SemiTransparency::B_Half_add_F_Half, GPU::TextureColorMode::clut4);
|
||||
static constexpr auto RectangleClut = Make::PageClut(IconTIM.get_clut_position());
|
||||
|
||||
static constexpr auto LineColor = GPU::Color24::from_rgb(0xFF, 0x0, 0x0);
|
||||
|
||||
static constexpr const auto triangle1 = Make::POLY_F3({
|
||||
Make::Vertex(TriangleArea.position.x, TriangleArea.position.y),
|
||||
Make::Vertex(TriangleArea.size.width, TriangleArea.size.height),
|
||||
Make::Vertex(TriangleArea.position.x, TriangleArea.size.height)
|
||||
}, TriangleColor
|
||||
);
|
||||
static constexpr const auto triangle2 = Make::POLY_FT3({
|
||||
Make::Vertex(TriangleArea.position.x, TriangleArea.position.y),
|
||||
Make::Vertex(TriangleArea.size.width, TriangleArea.position.y),
|
||||
Make::Vertex(TriangleArea.size.width, TriangleArea.size.height)
|
||||
},{
|
||||
// Texture
|
||||
Make::PageOffset(TriangleArea.position.x, TriangleArea.position.y),
|
||||
Make::PageOffset(TriangleArea.size.width, TriangleArea.position.y),
|
||||
Make::PageOffset(TriangleArea.size.width, TriangleArea.size.height)
|
||||
}, TriangleTPage, TriangleClut, GPU::Color24::Grey()
|
||||
);
|
||||
static constexpr const auto triangle3 = Make::POLY_G3({
|
||||
{triangle1.vertex0.move(TriangleArea.size.width, 0), GPU::Color24::Red()},
|
||||
{triangle1.vertex1.move(TriangleArea.size.width, 0), GPU::Color24::Green()},
|
||||
{triangle1.vertex2.move(TriangleArea.size.width, 0), GPU::Color24::Blue()}}
|
||||
);
|
||||
static constexpr const auto triangle4 = Make::POLY_GT3({
|
||||
{triangle2.vertex0.move(TriangleArea.size.width, 0), triangle2.tex_offset0, GPU::Color24::Red()},
|
||||
{triangle2.vertex1.move(TriangleArea.size.width, 0), triangle2.tex_offset1, GPU::Color24::Blue()},
|
||||
{triangle2.vertex2.move(TriangleArea.size.width, 0), triangle2.tex_offset2, GPU::Color24::Green()}},
|
||||
TriangleTPage,
|
||||
TriangleClut
|
||||
);
|
||||
|
||||
static constexpr const auto rectangle1 = Make::POLY_F4(RectangleArea, RectangleColor);
|
||||
static constexpr const auto rectangle2 = Make::POLY_FT4(Make::AreaI16(
|
||||
RectangleArea.position.move(RectangleArea.size.width, 0), RectangleArea.size), Make::PageOffset(0, 0),
|
||||
RectangleTPage,
|
||||
RectangleClut,
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
static constexpr const auto rectangle3 = Make::POLY_G4(
|
||||
{RectangleArea.position.move(RectangleArea.size.width*2, 0), RectangleArea.size}, {
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()});
|
||||
static constexpr const auto rectangle4 = Make::POLY_GT4(Make::AreaI16(
|
||||
RectangleArea.position.move(RectangleArea.size.width*3, 0), RectangleArea.size), Make::PageOffset(0, 0),
|
||||
RectangleTPage,
|
||||
RectangleClut, {
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()}
|
||||
);
|
||||
static constexpr const auto rectangle5 = Make::POLY_GT4(Make::AreaI16(
|
||||
RectangleArea.position.move(0, RectangleArea.size.height), RectangleArea.size), Make::PageOffset(0, 0),
|
||||
RectangleTPage,
|
||||
RectangleClut, {
|
||||
GPU::Color24::Red(),
|
||||
GPU::Color24::Blue(),
|
||||
GPU::Color24::Green(),
|
||||
GPU::Color24::White()}
|
||||
).set_semi_transparent(true);
|
||||
|
||||
static constexpr const auto line1 = Make::LINE_F(LineColor,
|
||||
Make::Vertex(0, 0),
|
||||
Make::Vertex(GPU::Display::Width, GPU::Display::Height)
|
||||
);
|
||||
static constexpr const auto line2 = Make::LINE_F(LineColor.invert(),
|
||||
Make::Vertex(0, 0),
|
||||
Make::Vertex(16, 0),
|
||||
Make::Vertex(16, 16),
|
||||
Make::Vertex(0, 0)
|
||||
);
|
||||
static constexpr const auto line3 = Make::LINE_G(
|
||||
GPU::ColorVertex{LineColor, Make::Vertex(GPU::Display::Width, 0)},
|
||||
GPU::ColorVertex{LineColor.invert(), Make::Vertex(0, GPU::Display::Height)}
|
||||
);
|
||||
static constexpr const auto line4 = Make::LINE_G(
|
||||
GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)},
|
||||
GPU::ColorVertex{GPU::Color24::Green(), Make::Vertex(0, 16)},
|
||||
GPU::ColorVertex{GPU::Color24::Blue(), Make::Vertex(16, 16)},
|
||||
GPU::ColorVertex{GPU::Color24::White(), Make::Vertex(0, 0)}
|
||||
);
|
||||
|
||||
static constexpr const auto rect1 = Make::TILE(Make::AreaI16(Make::PositionI16(GPU::Display::Width - 32, GPU::Display::Height - 32), Make::SizeI16(32, 32)), GPU::Color24::Green());
|
||||
static constexpr const auto rect2 = Make::TILE_16(Make::PositionI16(GPU::Display::Width - 16, GPU::Display::Height - 16), GPU::Color24::Blue());
|
||||
static constexpr const auto rect3 = Make::TILE_8(Make::PositionI16(GPU::Display::Width - 8, GPU::Display::Height - 8), GPU::Color24::Yellow());
|
||||
static constexpr const auto rect4 = Make::TILE_1(Make::PositionI16(GPU::Display::Width - 1, GPU::Display::Height - 1), GPU::Color24::Red());
|
||||
|
||||
static constexpr const auto texpage = Make::TexPage(TexPageTIM.get_texture_position(), GPU::TextureColorMode::clut4);
|
||||
static constexpr const auto rect5 = Make::SPRT(Make::AreaI16(Make::PositionI16(0, GPU::Display::Height - 32), Make::SizeI16(32, 32)), {Make::PageOffset(0, 0), TriangleClut}, GPU::Color24::Green());
|
||||
static constexpr const auto rect6 = Make::SPRT_16(Make::Vertex(0, GPU::Display::Height - 16), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Blue());
|
||||
static constexpr const auto rect7 = Make::SPRT_8(Make::Vertex(0, GPU::Display::Height - 8), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Yellow());
|
||||
static constexpr const auto rect8 = Make::SPRT_1(Make::Vertex(0, GPU::Display::Height - 1), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Red());
|
||||
|
||||
static auto rect9 = Make::SPRT(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2), Make::SizeI16(32, 32)).centered(), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Grey()).linked();
|
||||
static auto rect10 = Make::SPRT(Make::AreaI16(Make::PositionI16(GPU::Display::Width/2, GPU::Display::Height/2 - 32), Make::SizeI16(32, 32)).centered(), Make::OffsetPageWithClut(Make::PageOffset(0, 0), TriangleClut), GPU::Color24::Grey()).linked();
|
||||
|
||||
void main() {
|
||||
rect9.concat(rect10);
|
||||
Shared::back_menu.reset();
|
||||
HighResTime::enable();
|
||||
|
||||
auto start_time = HighResTime::get_time_stamp();
|
||||
auto time_passed = 0;
|
||||
while(true) {
|
||||
// Update Phase
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(Make::PositionI16((GPU::Display::Width - 160)/2, GPU::Display::Height - 32));
|
||||
FontWriter::bios_font_writer.write(cursor, "Time: %ims", GPU::Color24::Blue(), time_passed);
|
||||
|
||||
GPU::swap_buffers_vsync(1);
|
||||
const auto end_time = HighResTime::get_time_stamp();
|
||||
time_passed = start_time.milliseconds_to(end_time);
|
||||
start_time = end_time;
|
||||
|
||||
GPU::render(triangle1);
|
||||
GPU::render(triangle2);
|
||||
GPU::render(triangle3);
|
||||
GPU::render(triangle4);
|
||||
|
||||
GPU::render(rectangle1);
|
||||
GPU::render(rectangle2);
|
||||
GPU::render(rectangle3);
|
||||
GPU::render(rectangle4);
|
||||
GPU::render(rectangle5);
|
||||
|
||||
GPU::render(rect1);
|
||||
GPU::render(rect2);
|
||||
GPU::render(rect3);
|
||||
GPU::render(rect4);
|
||||
GPU::render(texpage);
|
||||
GPU::render(rect5);
|
||||
GPU::render(rect6);
|
||||
GPU::render(rect7);
|
||||
GPU::render(rect8);
|
||||
|
||||
GPU::render(line1);
|
||||
GPU::render(line2);
|
||||
GPU::render(line3);
|
||||
GPU::render(line4);
|
||||
|
||||
GPU::render(rect9);
|
||||
Shared::back_menu.render();
|
||||
}
|
||||
HighResTime::disable();
|
||||
}
|
||||
}
|
||||
|
@@ -1,60 +1,60 @@
|
||||
#include "include/gpu_test_assets.hpp"
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
|
||||
namespace GPUTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(TEX, "ASSETS/TEX.IMG"),
|
||||
__jabyengine_request_lba_for(ICON, "ASSETS/ICON.IMG"),
|
||||
__jabyengine_request_lba_for(ALL_THE_JABY, "ASSETS/ATJ.TIM"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
CDFile Assets[2] = {
|
||||
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
|
||||
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
|
||||
};
|
||||
|
||||
CDFile LargeAssets[36] = {
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
};
|
||||
}
|
||||
#include "include/gpu_test_assets.hpp"
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
|
||||
namespace GPUTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(TEX, "ASSETS/TEX.IMG"),
|
||||
__jabyengine_request_lba_for(ICON, "ASSETS/ICON.IMG"),
|
||||
__jabyengine_request_lba_for(ALL_THE_JABY, "ASSETS/ATJ.TIM"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
CDFile Assets[2] = {
|
||||
CDFileBuilder::simple_tim(LBA::TEX, TexPageTIM),
|
||||
CDFileBuilder::simple_tim(LBA::ICON, IconTIM),
|
||||
};
|
||||
|
||||
CDFile LargeAssets[36] = {
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
CDFileBuilder::sony_tim(LBA::ALL_THE_JABY, TIM::create()),
|
||||
};
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
namespace GPUTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static constexpr auto TexPageTIM = SimpleTIM::create(384, 0, 384, 511);
|
||||
static constexpr auto IconTIM = SimpleTIM::create(384, 256, 384, 510);
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
namespace GPUTest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static constexpr auto TexPageTIM = SimpleTIM::create(384, 0, 384, 511);
|
||||
static constexpr auto IconTIM = SimpleTIM::create(384, 256, 384, 510);
|
||||
}
|
@@ -1,166 +1,166 @@
|
||||
#include "../../../include/asset_mgr.hpp"
|
||||
#include "../../../include/shared.hpp"
|
||||
#include "include/GTE_Sprite.hpp"
|
||||
#include "include/gte_test_assets.hpp"
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
|
||||
namespace GTETest {
|
||||
using namespace JabyEngine;
|
||||
using namespace GTETest;
|
||||
|
||||
namespace Jaby {
|
||||
static constexpr auto AnimationTime = 250_ms;
|
||||
static const struct {
|
||||
gte_float scale_left;
|
||||
gte_float scale_right;
|
||||
} animation[] = {
|
||||
{.scale_left = 1.0_gf, .scale_right = 1.0_gf},
|
||||
{.scale_left = 1.0_gf, .scale_right = 1.0_gf},
|
||||
|
||||
{.scale_left = 1.2_gf, .scale_right = 1.5_gf},
|
||||
{.scale_left = 1.5_gf, .scale_right = 1.2_gf},
|
||||
{.scale_left = 1.2_gf, .scale_right = 1.5_gf},
|
||||
{.scale_left = 1.5_gf, .scale_right = 1.2_gf},
|
||||
|
||||
{.scale_left = 1.8_gf, .scale_right = 2.3_gf},
|
||||
{.scale_left = 2.3_gf, .scale_right = 1.8_gf},
|
||||
{.scale_left = 1.8_gf, .scale_right = 2.3_gf},
|
||||
{.scale_left = 2.3_gf, .scale_right = 1.8_gf},
|
||||
|
||||
{.scale_left = 3.2_gf, .scale_right = 4.5_gf},
|
||||
{.scale_left = 4.5_gf, .scale_right = 3.2_gf},
|
||||
{.scale_left = 3.2_gf, .scale_right = 4.5_gf},
|
||||
{.scale_left = 4.5_gf, .scale_right = 3.2_gf},
|
||||
|
||||
{.scale_left = 1.8_gf, .scale_right = 2.3_gf},
|
||||
{.scale_left = 2.3_gf, .scale_right = 1.8_gf},
|
||||
{.scale_left = 1.8_gf, .scale_right = 2.3_gf},
|
||||
{.scale_left = 2.3_gf, .scale_right = 1.8_gf},
|
||||
|
||||
{.scale_left = 1.2_gf, .scale_right = 1.5_gf},
|
||||
{.scale_left = 1.5_gf, .scale_right = 1.2_gf},
|
||||
{.scale_left = 1.2_gf, .scale_right = 1.5_gf},
|
||||
{.scale_left = 1.5_gf, .scale_right = 1.2_gf},
|
||||
};
|
||||
static IntervalTimer<uint8_t> animation_timer;
|
||||
static auto animation_id = 0;
|
||||
static constexpr auto Position = Make::PositionI16(GPU::Display::Width - 64, GPU::Display::Height - 64);
|
||||
|
||||
static constexpr GTE_Sprite make_star_eye(GPU::PositionI16 pos) {
|
||||
return GTE_Sprite::create(Make::POLY_FT4(
|
||||
Make::AreaI16(pos, GPU::SizeI16(8, 8)),
|
||||
JabySTARTim.get_page_offset_clut4().add(0, 64),
|
||||
Make::TPage(JabySTARTim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4),
|
||||
Make::PageClut(JabySTARTim.get_clut_position()),
|
||||
GPU::Color24::Grey()
|
||||
).linked());
|
||||
}
|
||||
|
||||
static auto star_base = Make::SPRT(
|
||||
Make::AreaI16(Position, Make::SizeI16(64, 64)),
|
||||
Make::OffsetPageWithClut(JabySTARTim.get_page_offset_clut4(), Make::PageClut(JabySTARTim.get_clut_position()))
|
||||
).linked();
|
||||
|
||||
static GTE_Sprite star_eyes[2] = {
|
||||
make_star_eye(Position.add(11, 30)),
|
||||
make_star_eye(Position.add(33, 31))
|
||||
};
|
||||
}
|
||||
|
||||
namespace Background {
|
||||
static constexpr auto ColorBase = 0xC0;
|
||||
|
||||
static constexpr GPU::AreaI16 Area[2] = {
|
||||
Make::AreaI16(-30, -30, 350, 350),
|
||||
Make::AreaI16(0, 0, GPU::Display::Width, GPU::Display::Width),
|
||||
};
|
||||
static constexpr GPU::PositionI16 AreaPivot[2] = {
|
||||
Make::PositionI16(Area[0].size.width/2, Area[0].size.height/2),
|
||||
Make::PositionI16(Area[1].size.width/2, Area[1].size.height/2),
|
||||
};
|
||||
|
||||
static GPU::POLY_G4 poly[2] = {
|
||||
Make::POLY_G4(Area[0], {GPU::Color24::Blue(ColorBase), GPU::Color24::Red(ColorBase), GPU::Color24::Green(ColorBase), GPU::Color24::Purple(ColorBase)}),
|
||||
Make::POLY_G4(Area[1], {GPU::Color24::Blue(ColorBase), GPU::Color24::Red(ColorBase), GPU::Color24::Green(ColorBase), GPU::Color24::Purple(ColorBase)}),
|
||||
};
|
||||
}
|
||||
|
||||
static auto doener_fish = GTE_Sprite::create(Make::POLY_FT4(
|
||||
Make::AreaI16(Make::PositionI16(0, 0), Assets::Main::DoenerFishInfo.size),
|
||||
Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(),
|
||||
Make::TPage(Assets::Main::DoenerFishInfo.tim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4),
|
||||
Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position()),
|
||||
GPU::Color24::Grey()
|
||||
).linked());
|
||||
|
||||
static auto gbl_rotation = 0.0_deg;
|
||||
|
||||
static void setup() {
|
||||
Jaby::star_base.concat(Jaby::star_eyes[0].display.concat(Jaby::star_eyes[1].display));
|
||||
Jaby::star_eyes[0].scale = Jaby::animation[0].scale_right;
|
||||
Jaby::star_eyes[1].scale = Jaby::animation[0].scale_left;
|
||||
Jaby::animation_id = 1;
|
||||
Jaby::animation_timer = IntervalTimer<uint8_t>::create(Jaby::AnimationTime);
|
||||
|
||||
doener_fish.area.position = GPU::PositionI16::create(100, 100);
|
||||
Shared::back_menu.reset();
|
||||
|
||||
GTE::set_geom_offset(0, 0);
|
||||
GTE::set_geom_screen(256);
|
||||
}
|
||||
|
||||
static bool update_or_exit() {
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(Jaby::animation_timer.is_expired()) {
|
||||
Jaby::star_eyes[0].scale = Jaby::animation[Jaby::animation_id].scale_right;
|
||||
Jaby::star_eyes[1].scale = Jaby::animation[Jaby::animation_id].scale_left;
|
||||
|
||||
Jaby::animation_id = (Jaby::animation_id + 1)%(sizeof(Jaby::animation)/sizeof(Jaby::animation[0]));
|
||||
Jaby::animation_timer.reset();
|
||||
}
|
||||
|
||||
for(size_t n = 0; n < sizeof(Background::poly)/sizeof(Background::poly[0]); n++) {
|
||||
auto matrix = [](size_t n) -> GTE::MATRIX {
|
||||
auto matrix = GTE::MATRIX::translated(-Background::AreaPivot[n].x, -Background::AreaPivot[n].y);
|
||||
matrix.rotate(0.0_deg, 0.0_deg, (n == 0) ? gbl_rotation : -gbl_rotation);
|
||||
return matrix.translate(Background::Area[n].position.x + Background::AreaPivot[n].x, Background::Area[n].position.y + Background::AreaPivot[n].y);
|
||||
}(n);
|
||||
matrix.apply_to_area(Background::poly[n], Make::AreaI16(Make::PositionI16(), Background::Area[n].size));
|
||||
}
|
||||
|
||||
const auto matrix = GTE::MATRIX::rotated(-gbl_rotation, gbl_rotation, -gbl_rotation);
|
||||
doener_fish.apply(matrix);
|
||||
Jaby::star_eyes[0].apply();
|
||||
Jaby::star_eyes[1].apply();
|
||||
|
||||
doener_fish.angle += 25.0_deg;
|
||||
gbl_rotation += 2.5_deg;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void render() {
|
||||
for(const auto& poly : Background::poly) {
|
||||
GPU::render(poly);
|
||||
}
|
||||
doener_fish.render();
|
||||
GPU::render(Jaby::star_base);
|
||||
Shared::back_menu.render();
|
||||
GPU::wait_for_render(); //< Because we are single buffer
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1, false);
|
||||
render();
|
||||
}
|
||||
}
|
||||
#include "../../../include/asset_mgr.hpp"
|
||||
#include "../../../include/shared.hpp"
|
||||
#include "include/GTE_Sprite.hpp"
|
||||
#include "include/gte_test_assets.hpp"
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
|
||||
namespace GTETest {
|
||||
using namespace JabyEngine;
|
||||
using namespace GTETest;
|
||||
|
||||
namespace Jaby {
|
||||
static constexpr auto AnimationTime = 250_ms;
|
||||
static const struct {
|
||||
gte_float scale_left;
|
||||
gte_float scale_right;
|
||||
} animation[] = {
|
||||
{.scale_left = 1.0_gf, .scale_right = 1.0_gf},
|
||||
{.scale_left = 1.0_gf, .scale_right = 1.0_gf},
|
||||
|
||||
{.scale_left = 1.2_gf, .scale_right = 1.5_gf},
|
||||
{.scale_left = 1.5_gf, .scale_right = 1.2_gf},
|
||||
{.scale_left = 1.2_gf, .scale_right = 1.5_gf},
|
||||
{.scale_left = 1.5_gf, .scale_right = 1.2_gf},
|
||||
|
||||
{.scale_left = 1.8_gf, .scale_right = 2.3_gf},
|
||||
{.scale_left = 2.3_gf, .scale_right = 1.8_gf},
|
||||
{.scale_left = 1.8_gf, .scale_right = 2.3_gf},
|
||||
{.scale_left = 2.3_gf, .scale_right = 1.8_gf},
|
||||
|
||||
{.scale_left = 3.2_gf, .scale_right = 4.5_gf},
|
||||
{.scale_left = 4.5_gf, .scale_right = 3.2_gf},
|
||||
{.scale_left = 3.2_gf, .scale_right = 4.5_gf},
|
||||
{.scale_left = 4.5_gf, .scale_right = 3.2_gf},
|
||||
|
||||
{.scale_left = 1.8_gf, .scale_right = 2.3_gf},
|
||||
{.scale_left = 2.3_gf, .scale_right = 1.8_gf},
|
||||
{.scale_left = 1.8_gf, .scale_right = 2.3_gf},
|
||||
{.scale_left = 2.3_gf, .scale_right = 1.8_gf},
|
||||
|
||||
{.scale_left = 1.2_gf, .scale_right = 1.5_gf},
|
||||
{.scale_left = 1.5_gf, .scale_right = 1.2_gf},
|
||||
{.scale_left = 1.2_gf, .scale_right = 1.5_gf},
|
||||
{.scale_left = 1.5_gf, .scale_right = 1.2_gf},
|
||||
};
|
||||
static IntervalTimer<uint8_t> animation_timer;
|
||||
static auto animation_id = 0;
|
||||
static constexpr auto Position = Make::PositionI16(GPU::Display::Width - 64, GPU::Display::Height - 64);
|
||||
|
||||
static constexpr GTE_Sprite make_star_eye(GPU::PositionI16 pos) {
|
||||
return GTE_Sprite::create(Make::POLY_FT4(
|
||||
Make::AreaI16(pos, GPU::SizeI16(8, 8)),
|
||||
JabySTARTim.get_page_offset_clut4().add(0, 64),
|
||||
Make::TPage(JabySTARTim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4),
|
||||
Make::PageClut(JabySTARTim.get_clut_position()),
|
||||
GPU::Color24::Grey()
|
||||
).linked());
|
||||
}
|
||||
|
||||
static auto star_base = Make::SPRT(
|
||||
Make::AreaI16(Position, Make::SizeI16(64, 64)),
|
||||
Make::OffsetPageWithClut(JabySTARTim.get_page_offset_clut4(), Make::PageClut(JabySTARTim.get_clut_position()))
|
||||
).linked();
|
||||
|
||||
static GTE_Sprite star_eyes[2] = {
|
||||
make_star_eye(Position.add(11, 30)),
|
||||
make_star_eye(Position.add(33, 31))
|
||||
};
|
||||
}
|
||||
|
||||
namespace Background {
|
||||
static constexpr auto ColorBase = 0xC0;
|
||||
|
||||
static constexpr GPU::AreaI16 Area[2] = {
|
||||
Make::AreaI16(-30, -30, 350, 350),
|
||||
Make::AreaI16(0, 0, GPU::Display::Width, GPU::Display::Width),
|
||||
};
|
||||
static constexpr GPU::PositionI16 AreaPivot[2] = {
|
||||
Make::PositionI16(Area[0].size.width/2, Area[0].size.height/2),
|
||||
Make::PositionI16(Area[1].size.width/2, Area[1].size.height/2),
|
||||
};
|
||||
|
||||
static GPU::POLY_G4 poly[2] = {
|
||||
Make::POLY_G4(Area[0], {GPU::Color24::Blue(ColorBase), GPU::Color24::Red(ColorBase), GPU::Color24::Green(ColorBase), GPU::Color24::Purple(ColorBase)}),
|
||||
Make::POLY_G4(Area[1], {GPU::Color24::Blue(ColorBase), GPU::Color24::Red(ColorBase), GPU::Color24::Green(ColorBase), GPU::Color24::Purple(ColorBase)}),
|
||||
};
|
||||
}
|
||||
|
||||
static auto doener_fish = GTE_Sprite::create(Make::POLY_FT4(
|
||||
Make::AreaI16(Make::PositionI16(0, 0), Assets::Main::DoenerFishInfo.size),
|
||||
Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(),
|
||||
Make::TPage(Assets::Main::DoenerFishInfo.tim.get_texture_position(), GPU::SemiTransparency::B_add_F, GPU::TextureColorMode::clut4),
|
||||
Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position()),
|
||||
GPU::Color24::Grey()
|
||||
).linked());
|
||||
|
||||
static auto gbl_rotation = 0.0_deg;
|
||||
|
||||
static void setup() {
|
||||
Jaby::star_base.concat(Jaby::star_eyes[0].display.concat(Jaby::star_eyes[1].display));
|
||||
Jaby::star_eyes[0].scale = Jaby::animation[0].scale_right;
|
||||
Jaby::star_eyes[1].scale = Jaby::animation[0].scale_left;
|
||||
Jaby::animation_id = 1;
|
||||
Jaby::animation_timer = IntervalTimer<uint8_t>::create(Jaby::AnimationTime);
|
||||
|
||||
doener_fish.area.position = GPU::PositionI16::create(100, 100);
|
||||
Shared::back_menu.reset();
|
||||
|
||||
GTE::set_geom_offset(0, 0);
|
||||
GTE::set_geom_screen(256);
|
||||
}
|
||||
|
||||
static bool update_or_exit() {
|
||||
Periphery::query_controller();
|
||||
if(Shared::back_menu.update(Make::PositionI16(0, GPU::Display::Height - 32))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(Jaby::animation_timer.is_expired()) {
|
||||
Jaby::star_eyes[0].scale = Jaby::animation[Jaby::animation_id].scale_right;
|
||||
Jaby::star_eyes[1].scale = Jaby::animation[Jaby::animation_id].scale_left;
|
||||
|
||||
Jaby::animation_id = (Jaby::animation_id + 1)%(sizeof(Jaby::animation)/sizeof(Jaby::animation[0]));
|
||||
Jaby::animation_timer.reset();
|
||||
}
|
||||
|
||||
for(size_t n = 0; n < sizeof(Background::poly)/sizeof(Background::poly[0]); n++) {
|
||||
auto matrix = [](size_t n) -> GTE::MATRIX {
|
||||
auto matrix = GTE::MATRIX::translated(-Background::AreaPivot[n].x, -Background::AreaPivot[n].y);
|
||||
matrix.rotate(0.0_deg, 0.0_deg, (n == 0) ? gbl_rotation : -gbl_rotation);
|
||||
return matrix.translate(Background::Area[n].position.x + Background::AreaPivot[n].x, Background::Area[n].position.y + Background::AreaPivot[n].y);
|
||||
}(n);
|
||||
matrix.apply_to_area(Background::poly[n], Make::AreaI16(Make::PositionI16(), Background::Area[n].size));
|
||||
}
|
||||
|
||||
const auto matrix = GTE::MATRIX::rotated(-gbl_rotation, gbl_rotation, -gbl_rotation);
|
||||
doener_fish.apply(matrix);
|
||||
Jaby::star_eyes[0].apply();
|
||||
Jaby::star_eyes[1].apply();
|
||||
|
||||
doener_fish.angle += 25.0_deg;
|
||||
gbl_rotation += 2.5_deg;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void render() {
|
||||
for(const auto& poly : Background::poly) {
|
||||
GPU::render(poly);
|
||||
}
|
||||
doener_fish.render();
|
||||
GPU::render(Jaby::star_base);
|
||||
Shared::back_menu.render();
|
||||
GPU::wait_for_render(); //< Because we are single buffer
|
||||
}
|
||||
|
||||
void main() {
|
||||
setup();
|
||||
|
||||
while(true) {
|
||||
if(update_or_exit()) {
|
||||
break;
|
||||
}
|
||||
GPU::swap_buffers_vsync(1, false);
|
||||
render();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,15 +1,15 @@
|
||||
#include "include/gte_test_assets.hpp"
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
|
||||
namespace GTETest {
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(JABY_STAR, "ASSETS/GTE/JABY.IMG"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
CDFile Assets[1] = {
|
||||
CDFileBuilder::simple_tim(LBA::JABY_STAR, JabySTARTim),
|
||||
};
|
||||
#include "include/gte_test_assets.hpp"
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
|
||||
namespace GTETest {
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(JABY_STAR, "ASSETS/GTE/JABY.IMG"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
CDFile Assets[1] = {
|
||||
CDFileBuilder::simple_tim(LBA::JABY_STAR, JabySTARTim),
|
||||
};
|
||||
}
|
@@ -1,47 +1,47 @@
|
||||
#pragma once
|
||||
#include <PSX/GPU/gpu_primitives.hpp>
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GTE/gte.hpp>
|
||||
|
||||
#include <stdio.hpp>
|
||||
|
||||
namespace GTETest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
struct GTE_Sprite {
|
||||
GPU::AreaI16 area;
|
||||
GPU::PositionI16 pivot;
|
||||
deg_t angle;
|
||||
gte_float scale;
|
||||
GPU::POLY_FT4::Linked display;
|
||||
|
||||
static constexpr GTE_Sprite create(const GPU::POLY_FT4::Linked& base) {
|
||||
const auto rect_size = base->get_rect_size();
|
||||
return GTE_Sprite{
|
||||
.area = GPU::AreaI16::create(base->get_rect_pos(), rect_size),
|
||||
.pivot = GPU::PositionI16::create(rect_size.width/2, rect_size.height/2),
|
||||
.angle = 0.0_deg,
|
||||
.scale = 1.0_gf,
|
||||
.display = base
|
||||
};
|
||||
}
|
||||
|
||||
void apply(const GTE::MATRIX& gbl_matrix = GTE::MATRIX::identity()) {
|
||||
const auto matrix =
|
||||
GTE::MATRIX::translated(-this->pivot.x, -this->pivot.y, 0)
|
||||
.rotate(0.0_deg, 0.0_deg, this->angle)
|
||||
.scale(this->scale, this->scale)
|
||||
.translate(this->area.position.x + this->pivot.x, this->area.position.y + this->pivot.y, 0)
|
||||
.comp(gbl_matrix);
|
||||
|
||||
this->display->vertex0 = matrix.apply_to(GPU::Vertex::create(0, 0));
|
||||
this->display->vertex1 = matrix.apply_to(GPU::Vertex::create(this->area.size.width, 0));
|
||||
this->display->vertex2 = matrix.apply_to(GPU::Vertex::create(0, this->area.size.height));
|
||||
this->display->vertex3 = matrix.apply_to(GPU::Vertex::create(this->area.size.width, this->area.size.height));
|
||||
}
|
||||
|
||||
void render() {
|
||||
GPU::render(this->display);
|
||||
}
|
||||
};
|
||||
#pragma once
|
||||
#include <PSX/GPU/gpu_primitives.hpp>
|
||||
#include <PSX/GPU/gpu.hpp>
|
||||
#include <PSX/GTE/gte.hpp>
|
||||
|
||||
#include <stdio.hpp>
|
||||
|
||||
namespace GTETest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
struct GTE_Sprite {
|
||||
GPU::AreaI16 area;
|
||||
GPU::PositionI16 pivot;
|
||||
deg_t angle;
|
||||
gte_float scale;
|
||||
GPU::POLY_FT4::Linked display;
|
||||
|
||||
static constexpr GTE_Sprite create(const GPU::POLY_FT4::Linked& base) {
|
||||
const auto rect_size = base->get_rect_size();
|
||||
return GTE_Sprite{
|
||||
.area = GPU::AreaI16::create(base->get_rect_pos(), rect_size),
|
||||
.pivot = GPU::PositionI16::create(rect_size.width/2, rect_size.height/2),
|
||||
.angle = 0.0_deg,
|
||||
.scale = 1.0_gf,
|
||||
.display = base
|
||||
};
|
||||
}
|
||||
|
||||
void apply(const GTE::MATRIX& gbl_matrix = GTE::MATRIX::identity()) {
|
||||
const auto matrix =
|
||||
GTE::MATRIX::translated(-this->pivot.x, -this->pivot.y, 0)
|
||||
.rotate(0.0_deg, 0.0_deg, this->angle)
|
||||
.scale(this->scale, this->scale)
|
||||
.translate(this->area.position.x + this->pivot.x, this->area.position.y + this->pivot.y, 0)
|
||||
.comp(gbl_matrix);
|
||||
|
||||
this->display->vertex0 = matrix.apply_to(GPU::Vertex::create(0, 0));
|
||||
this->display->vertex1 = matrix.apply_to(GPU::Vertex::create(this->area.size.width, 0));
|
||||
this->display->vertex2 = matrix.apply_to(GPU::Vertex::create(0, this->area.size.height));
|
||||
this->display->vertex3 = matrix.apply_to(GPU::Vertex::create(this->area.size.width, this->area.size.height));
|
||||
}
|
||||
|
||||
void render() {
|
||||
GPU::render(this->display);
|
||||
}
|
||||
};
|
||||
}
|
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
#include "../../../../include/asset_mgr.hpp"
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
namespace GTETest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static constexpr auto JabySTARTim = SimpleTIM::create(
|
||||
// v Doenerfisch rotates so we need some space
|
||||
Assets::Main::DoenerFishInfo.tim.get_texture_x(), Assets::Main::DoenerFishInfo.tim.get_texture_y() + Assets::Main::DoenerFishInfo.size.height + 2,
|
||||
Assets::Main::DoenerFishInfo.tim.get_clut_x() + 16, Assets::Main::DoenerFishInfo.tim.get_clut_y()
|
||||
);
|
||||
#pragma once
|
||||
#include "../../../../include/asset_mgr.hpp"
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
namespace GTETest {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static constexpr auto JabySTARTim = SimpleTIM::create(
|
||||
// v Doenerfisch rotates so we need some space
|
||||
Assets::Main::DoenerFishInfo.tim.get_texture_x(), Assets::Main::DoenerFishInfo.tim.get_texture_y() + Assets::Main::DoenerFishInfo.size.height + 2,
|
||||
Assets::Main::DoenerFishInfo.tim.get_clut_x() + 16, Assets::Main::DoenerFishInfo.tim.get_clut_y()
|
||||
);
|
||||
}
|
@@ -1,38 +1,38 @@
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
namespace BIOSInfo {
|
||||
void main();
|
||||
}
|
||||
|
||||
namespace ControllerTest {
|
||||
extern const volatile JabyEngine::AutoLBAEntry lba[];
|
||||
extern JabyEngine::CDFile Assets[1];
|
||||
|
||||
void main();
|
||||
}
|
||||
|
||||
namespace GPUTest {
|
||||
extern const volatile JabyEngine::AutoLBAEntry lba[];
|
||||
extern JabyEngine::CDFile Assets[2];
|
||||
extern JabyEngine::CDFile LargeAssets[36];
|
||||
|
||||
void main();
|
||||
}
|
||||
|
||||
namespace GTETest {
|
||||
extern const volatile JabyEngine::AutoLBAEntry lba[];
|
||||
extern JabyEngine::CDFile Assets[1];
|
||||
|
||||
void main();
|
||||
}
|
||||
|
||||
namespace FontCycler {
|
||||
void main();
|
||||
}
|
||||
|
||||
namespace ScreenCenter {
|
||||
extern const volatile JabyEngine::AutoLBAEntry lba[];
|
||||
extern JabyEngine::CDFile Assets[1];
|
||||
void main();
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
namespace BIOSInfo {
|
||||
void main();
|
||||
}
|
||||
|
||||
namespace ControllerTest {
|
||||
extern const volatile JabyEngine::AutoLBAEntry lba[];
|
||||
extern JabyEngine::CDFile Assets[1];
|
||||
|
||||
void main();
|
||||
}
|
||||
|
||||
namespace GPUTest {
|
||||
extern const volatile JabyEngine::AutoLBAEntry lba[];
|
||||
extern JabyEngine::CDFile Assets[2];
|
||||
extern JabyEngine::CDFile LargeAssets[36];
|
||||
|
||||
void main();
|
||||
}
|
||||
|
||||
namespace GTETest {
|
||||
extern const volatile JabyEngine::AutoLBAEntry lba[];
|
||||
extern JabyEngine::CDFile Assets[1];
|
||||
|
||||
void main();
|
||||
}
|
||||
|
||||
namespace FontCycler {
|
||||
void main();
|
||||
}
|
||||
|
||||
namespace ScreenCenter {
|
||||
extern const volatile JabyEngine::AutoLBAEntry lba[];
|
||||
extern JabyEngine::CDFile Assets[1];
|
||||
void main();
|
||||
}
|
@@ -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