Fix inconsistent EOL
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
OVERLAY_CONFIG = Overlays.json
|
||||
|
||||
include $(JABY_ENGINE_DIR)/mkfile/common/Wildcard.mk
|
||||
SRCS = $(call rwildcard, src, c cpp)
|
||||
|
||||
INCLUDES += -I$(JABY_ENGINE_DIR)/support/include -I$(JABY_ENGINE_DIR)/include
|
||||
CCFLAGS += -save-temps=obj
|
||||
|
||||
SUPPORT_LIBS += FontWriter
|
||||
|
||||
include $(JABY_ENGINE_DIR)/mkfile/Makefile
|
||||
OVERLAY_CONFIG = Overlays.json
|
||||
|
||||
include $(JABY_ENGINE_DIR)/mkfile/common/Wildcard.mk
|
||||
SRCS = $(call rwildcard, src, c cpp)
|
||||
|
||||
INCLUDES += -I$(JABY_ENGINE_DIR)/support/include -I$(JABY_ENGINE_DIR)/include
|
||||
CCFLAGS += -save-temps=obj
|
||||
|
||||
SUPPORT_LIBS += FontWriter
|
||||
|
||||
include $(JABY_ENGINE_DIR)/mkfile/Makefile
|
||||
include $(JABY_ENGINE_DIR)/mkfile/PSEXETarget.mk
|
@@ -1,22 +1,22 @@
|
||||
{
|
||||
"slot_0": {
|
||||
"bios_info": {
|
||||
"pattern": "bin/*/src/Overlay/BIOSInfo/*.o"
|
||||
},
|
||||
"controller_tests": {
|
||||
"pattern": "bin/*/src/Overlay/ControllerTest/*.o"
|
||||
},
|
||||
"gpu_tests": {
|
||||
"pattern": "bin/*/src/Overlay/GPUTest/*.o"
|
||||
},
|
||||
"gte_tests": {
|
||||
"pattern": "bin/*/src/Overlay/GTETest/*.o"
|
||||
},
|
||||
"font_cycler": {
|
||||
"pattern": "bin/*/src/Overlay/FontCycler/*.o"
|
||||
},
|
||||
"screen_center": {
|
||||
"pattern": "bin/*/src/Overlay/ScreenCenter/*.o"
|
||||
}
|
||||
}
|
||||
{
|
||||
"slot_0": {
|
||||
"bios_info": {
|
||||
"pattern": "bin/*/src/Overlay/BIOSInfo/*.o"
|
||||
},
|
||||
"controller_tests": {
|
||||
"pattern": "bin/*/src/Overlay/ControllerTest/*.o"
|
||||
},
|
||||
"gpu_tests": {
|
||||
"pattern": "bin/*/src/Overlay/GPUTest/*.o"
|
||||
},
|
||||
"gte_tests": {
|
||||
"pattern": "bin/*/src/Overlay/GTETest/*.o"
|
||||
},
|
||||
"font_cycler": {
|
||||
"pattern": "bin/*/src/Overlay/FontCycler/*.o"
|
||||
},
|
||||
"screen_center": {
|
||||
"pattern": "bin/*/src/Overlay/ScreenCenter/*.o"
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,41 +1,41 @@
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
namespace Assets {
|
||||
using namespace JabyEngine;
|
||||
|
||||
namespace Main {
|
||||
struct ImageInfo {
|
||||
SimpleTIM tim;
|
||||
GPU::SizeI16 size;
|
||||
};
|
||||
|
||||
static constexpr auto PacoTIM = SimpleTIM::create(896, 0, 960, 510);
|
||||
static constexpr auto DoenerFishInfo = ImageInfo{
|
||||
.tim = SimpleTIM::create(896 + 30, 0, 960 + 16, 510),
|
||||
.size = GPU::SizeI16::create(128, 64)
|
||||
};
|
||||
|
||||
namespace JabyLoader {
|
||||
static constexpr auto TIMLoaction = SimpleTIM::create(PacoTIM.get_texture_x(), PacoTIM.get_texture_y() + 128, 960 + 48, 510);
|
||||
static constexpr auto JabyFrame = GPU::AreaI16::create(0, 0, 32, 44);
|
||||
static constexpr auto FontFrame = GPU::AreaI16::create(0, 45, 186, 32);
|
||||
};
|
||||
|
||||
void load();
|
||||
}
|
||||
|
||||
namespace Overlay {
|
||||
void load_bios_info();
|
||||
void load_controller_test();
|
||||
void load_gpu_test();
|
||||
void load_large_gpu_test();
|
||||
void load_gte_test();
|
||||
void load_font_cycler();
|
||||
void load_screen_center();
|
||||
}
|
||||
|
||||
namespace XAAudio {
|
||||
void play_mix();
|
||||
}
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
namespace Assets {
|
||||
using namespace JabyEngine;
|
||||
|
||||
namespace Main {
|
||||
struct ImageInfo {
|
||||
SimpleTIM tim;
|
||||
GPU::SizeI16 size;
|
||||
};
|
||||
|
||||
static constexpr auto PacoTIM = SimpleTIM::create(896, 0, 960, 510);
|
||||
static constexpr auto DoenerFishInfo = ImageInfo{
|
||||
.tim = SimpleTIM::create(896 + 30, 0, 960 + 16, 510),
|
||||
.size = GPU::SizeI16::create(128, 64)
|
||||
};
|
||||
|
||||
namespace JabyLoader {
|
||||
static constexpr auto TIMLoaction = SimpleTIM::create(PacoTIM.get_texture_x(), PacoTIM.get_texture_y() + 128, 960 + 48, 510);
|
||||
static constexpr auto JabyFrame = GPU::AreaI16::create(0, 0, 32, 44);
|
||||
static constexpr auto FontFrame = GPU::AreaI16::create(0, 45, 186, 32);
|
||||
};
|
||||
|
||||
void load();
|
||||
}
|
||||
|
||||
namespace Overlay {
|
||||
void load_bios_info();
|
||||
void load_controller_test();
|
||||
void load_gpu_test();
|
||||
void load_large_gpu_test();
|
||||
void load_gte_test();
|
||||
void load_font_cycler();
|
||||
void load_screen_center();
|
||||
}
|
||||
|
||||
namespace XAAudio {
|
||||
void play_mix();
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include "../src/include/menu.hpp"
|
||||
#include "../src/include/font_writer.hpp"
|
||||
#include <PSX/GPU/gpu_types.hpp>
|
||||
|
||||
namespace Shared {
|
||||
extern Menu::BackMenu back_menu;
|
||||
extern JabyEngine::GPU::POLY_G4 background;
|
||||
extern bool load_test;
|
||||
#pragma once
|
||||
#include "../src/include/menu.hpp"
|
||||
#include "../src/include/font_writer.hpp"
|
||||
#include <PSX/GPU/gpu_types.hpp>
|
||||
|
||||
namespace Shared {
|
||||
extern Menu::BackMenu back_menu;
|
||||
extern JabyEngine::GPU::POLY_G4 background;
|
||||
extern bool load_test;
|
||||
}
|
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
enum struct FileType : JabyEngine::CDFileType_t {
|
||||
Jingle,
|
||||
};
|
||||
|
||||
struct CustomCDFileBuilder {
|
||||
static constexpr JabyEngine::CDFile jingle(uint32_t sfx_id) {
|
||||
// v we reload Paco
|
||||
return JabyEngine::CDFile::custom(0, FileType::Jingle, sfx_id);
|
||||
}
|
||||
#pragma once
|
||||
#include <PSX/File/cd_file_types.hpp>
|
||||
|
||||
enum struct FileType : JabyEngine::CDFileType_t {
|
||||
Jingle,
|
||||
};
|
||||
|
||||
struct CustomCDFileBuilder {
|
||||
static constexpr JabyEngine::CDFile jingle(uint32_t sfx_id) {
|
||||
// v we reload Paco
|
||||
return JabyEngine::CDFile::custom(0, FileType::Jingle, sfx_id);
|
||||
}
|
||||
};
|
@@ -1,26 +1,26 @@
|
||||
#include "custom_files.hpp"
|
||||
#include <PSX/File/file_processor_helper.hpp>
|
||||
#include <stdio.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace FileProcessor {
|
||||
struct JingleState {
|
||||
uint32_t sfx_id;
|
||||
};
|
||||
|
||||
static Progress parse_jingle(State::CDDataProcessor& data_proc, JingleState& jingle) {
|
||||
SPU::voice[jingle.sfx_id].play();
|
||||
return Progress::Done;
|
||||
}
|
||||
|
||||
State create_custom(const uint32_t* data_adr, const CDFileType_t& file_type, const CDFile::Payload& payload) {
|
||||
switch(static_cast<FileType>(file_type)) {
|
||||
case FileType::Jingle:
|
||||
return State::from(JingleState{.sfx_id = payload.raw}, data_adr, parse_jingle);
|
||||
|
||||
default:
|
||||
return FileProcessor::create(data_adr, Nothing());
|
||||
}
|
||||
}
|
||||
}
|
||||
#include "custom_files.hpp"
|
||||
#include <PSX/File/file_processor_helper.hpp>
|
||||
#include <stdio.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
namespace FileProcessor {
|
||||
struct JingleState {
|
||||
uint32_t sfx_id;
|
||||
};
|
||||
|
||||
static Progress parse_jingle(State::CDDataProcessor& data_proc, JingleState& jingle) {
|
||||
SPU::voice[jingle.sfx_id].play();
|
||||
return Progress::Done;
|
||||
}
|
||||
|
||||
State create_custom(const uint32_t* data_adr, const CDFileType_t& file_type, const CDFile::Payload& payload) {
|
||||
switch(static_cast<FileType>(file_type)) {
|
||||
case FileType::Jingle:
|
||||
return State::from(JingleState{.sfx_id = payload.raw}, data_adr, parse_jingle);
|
||||
|
||||
default:
|
||||
return FileProcessor::create(data_adr, Nothing());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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())
|
||||
};
|
||||
}
|
@@ -1,299 +1,299 @@
|
||||
#include "../include/asset_mgr.hpp"
|
||||
#include "include/font_writer.hpp"
|
||||
#include "include/menu.hpp"
|
||||
#include "include/paco.hpp"
|
||||
#include "Overlay/Overlays.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
#include <PSX/Audio/CDDA.hpp>
|
||||
#include <PSX/Audio/CDXA.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <stdio.hpp>
|
||||
|
||||
using namespace JabyEngine;
|
||||
using DigitalButton = Periphery::GenericController::Button;
|
||||
|
||||
struct CDPlayer {
|
||||
static constexpr auto MaxChannels = 2;
|
||||
|
||||
uint8_t channel;
|
||||
bool is_xa;
|
||||
|
||||
static constexpr CDPlayer create() {
|
||||
return CDPlayer{.channel = 0, .is_xa = true};
|
||||
}
|
||||
|
||||
void play() {
|
||||
if(this->is_xa) {
|
||||
Assets::XAAudio::play_mix();
|
||||
}
|
||||
|
||||
else {
|
||||
const auto [first_track, last_track] = CDDA::get_tracks();
|
||||
CDDA::play(first_track);
|
||||
}
|
||||
}
|
||||
|
||||
void stop() {
|
||||
if(this->is_xa) {
|
||||
CDXA::stop();
|
||||
}
|
||||
|
||||
else {
|
||||
CDDA::stop();
|
||||
}
|
||||
}
|
||||
|
||||
void change_channel(int8_t step) {
|
||||
if(this->is_xa) {
|
||||
this->channel = static_cast<uint8_t>((this->channel + step))%MaxChannels;
|
||||
CDXA::set_channel(this->channel);
|
||||
}
|
||||
}
|
||||
|
||||
void change_audio() {
|
||||
CDPlayer::stop();
|
||||
this->is_xa = !this->is_xa;
|
||||
CDPlayer::play();
|
||||
}
|
||||
|
||||
void push() {
|
||||
if(this->is_xa) {
|
||||
CDXA::push_play();
|
||||
}
|
||||
|
||||
else {
|
||||
CDDA::push_play();
|
||||
}
|
||||
}
|
||||
|
||||
void pop() {
|
||||
if(this->is_xa) {
|
||||
CDXA::pop_play();
|
||||
}
|
||||
|
||||
else {
|
||||
CDDA::pop_play();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct StateChange {
|
||||
void (*asset_load)();
|
||||
void (*main)();
|
||||
|
||||
static constexpr StateChange empty() {
|
||||
return StateChange{.asset_load = nullptr, .main = nullptr};
|
||||
}
|
||||
|
||||
void clear() {
|
||||
this->asset_load = nullptr;
|
||||
this->main = nullptr;
|
||||
}
|
||||
|
||||
bool contains_state() const {
|
||||
return this->main;
|
||||
}
|
||||
|
||||
auto operator<=>(const StateChange&) const = default;
|
||||
};
|
||||
|
||||
static const Menu::SimpleMenu::Entry MenuEntries[] = {
|
||||
{"Controller Test"},
|
||||
{"GPU Test"},
|
||||
{"GTE Test"},
|
||||
{"Font Cycler"},
|
||||
{"Screen Center"},
|
||||
{"BIOS Information"}
|
||||
};
|
||||
|
||||
static const auto doener_fish = Make::SPRT(
|
||||
Make::AreaI16(Make::PositionI16(8, GPU::Display::Height - Assets::Main::DoenerFishInfo.size.height), Assets::Main::DoenerFishInfo.size), // v this needs to be nicer! Has to be
|
||||
Make::OffsetPageWithClut(Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(), Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position())),
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
|
||||
static CDPlayer cd_player = CDPlayer::create();
|
||||
static object::Paco paco;
|
||||
static Menu::SimpleMenu menu;
|
||||
static StateChange state_changer;
|
||||
static StateChange old_state_changer;
|
||||
|
||||
namespace Shared {
|
||||
Menu::BackMenu back_menu;
|
||||
JabyEngine::GPU::POLY_G4 background = Make::POLY_G4(
|
||||
Make::AreaI16(0, 0, GPU::Display::Width, GPU::Display::Height),
|
||||
{GPU::Color24::Red(0xA0), GPU::Color24::Green(0xA0), GPU::Color24::Blue(0xA0), GPU::Color24::Black()}
|
||||
);
|
||||
bool load_test = false;
|
||||
}
|
||||
|
||||
static void setup() {
|
||||
Assets::Main::load();
|
||||
FontWriter::setup();
|
||||
paco.setup();
|
||||
Shared::back_menu.setup(&FontWriter::bios_font_writer);
|
||||
|
||||
menu.setup([](uint32_t selection) {
|
||||
switch(selection) {
|
||||
case 0:
|
||||
state_changer.asset_load = Assets::Overlay::load_controller_test;
|
||||
state_changer.main = ControllerTest::main;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
state_changer.asset_load = Assets::Overlay::load_gpu_test;
|
||||
state_changer.main = GPUTest::main;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
state_changer.asset_load = Assets::Overlay::load_gte_test;
|
||||
state_changer.main = GTETest::main;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
state_changer.asset_load = Assets::Overlay::load_font_cycler;
|
||||
state_changer.main = FontCycler::main;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
state_changer.asset_load = Assets::Overlay::load_screen_center;
|
||||
state_changer.main = ScreenCenter::main;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
state_changer.asset_load = Assets::Overlay::load_bios_info;
|
||||
state_changer.main = BIOSInfo::main;
|
||||
break;
|
||||
}
|
||||
},MenuEntries);
|
||||
cd_player.play();
|
||||
}
|
||||
|
||||
namespace NormalScene {
|
||||
static void update() {
|
||||
static const char Title[] = ">> Pool Box <<";
|
||||
static const char Version[] = "Ver. 0.9.0";
|
||||
static constexpr auto TitleLength = DefaultFont::Info.estimate_str_render_length(Title);
|
||||
static constexpr auto VersionLength = DefaultFont::Info.estimate_str_render_length(Version);
|
||||
|
||||
Periphery::query_controller();
|
||||
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
|
||||
if(controller.is_connected()) {
|
||||
if(controller.button.went_down(DigitalButton::SEL)) {
|
||||
cd_player.change_audio();
|
||||
}
|
||||
|
||||
if(controller.button.went_down(DigitalButton::R1)) {
|
||||
cd_player.change_channel(1);
|
||||
}
|
||||
|
||||
if(controller.button.went_down(DigitalButton::L1)) {
|
||||
cd_player.change_channel(-1);
|
||||
}
|
||||
|
||||
// Trigger load test
|
||||
if(controller.button.is_down(DigitalButton::R2) && controller.button.is_down(DigitalButton::L2) && controller.button.is_down(DigitalButton::ST)) {
|
||||
Shared::load_test = true;
|
||||
}
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(Make::PositionI16((GPU::Display::Width-TitleLength)/2, 16));
|
||||
paco.update();
|
||||
|
||||
FontWriter::new_font_writer.write(cursor, Title, GPU::Color24::Yellow(0xD0), &FontWriter::wiggle);
|
||||
FontWriter::new_font_writer.write(cursor.change_position(Make::PositionI16((GPU::Display::Width-VersionLength)/2, 16 + DefaultFont::Info.get_kern_size().height)), Version, GPU::Color24::Green(0xD0), &FontWriter::wiggle);
|
||||
menu.update(FontWriter::bios_font_writer, cursor, Make::PositionI16(8, 64));
|
||||
|
||||
cursor.change_position(Make::PositionI16(doener_fish.position.x + doener_fish.size.width, GPU::Display::Height - 48));
|
||||
FontWriter::bios_font_writer.write(cursor, "Audio:\n%s\n(SEL/R1/R2)", cd_player.is_xa ? "CD-XA" : "CD-DA");
|
||||
|
||||
if(Shared::load_test) {
|
||||
// Force state change if we are in the load_test state
|
||||
state_changer.asset_load = Assets::Overlay::load_large_gpu_test;
|
||||
state_changer.main = GPUTest::main;
|
||||
}
|
||||
}
|
||||
|
||||
static void render() {
|
||||
GPU::render(Shared::background);
|
||||
FontWriter::new_font_writer.render();
|
||||
FontWriter::bios_font_writer.render();
|
||||
paco.render();
|
||||
GPU::render(doener_fish);
|
||||
}
|
||||
|
||||
static void run() {
|
||||
update();
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
namespace LoadingScene {
|
||||
static SimpleTimer<uint8_t> jaby_timer;
|
||||
static uint8_t jaby_frame_offset;
|
||||
|
||||
static void update() {
|
||||
jaby_timer.reset();
|
||||
jaby_frame_offset = 0;
|
||||
}
|
||||
|
||||
static void vsync_render() {
|
||||
static constexpr auto StartPosition = Make::PositionI16(24, 64);
|
||||
const auto load_font = Make::SPRT(
|
||||
Make::AreaI16(StartPosition.move(Assets::Main::JabyLoader::JabyFrame.size.width + 8, 0), Assets::Main::JabyLoader::FontFrame.size),
|
||||
Make::OffsetPageWithClut(Assets::Main::JabyLoader::TIMLoaction.get_page_offset_clut4().move(Assets::Main::JabyLoader::FontFrame.position.x, Assets::Main::JabyLoader::FontFrame.position.y), Make::PageClut(Assets::Main::JabyLoader::TIMLoaction.get_clut_position())),
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
auto jaby_sprt = Make::SPRT(
|
||||
Make::AreaI16(StartPosition, Assets::Main::JabyLoader::JabyFrame.size),
|
||||
Make::OffsetPageWithClut(Assets::Main::JabyLoader::TIMLoaction.get_page_offset_clut4(), Make::PageClut(Assets::Main::JabyLoader::TIMLoaction.get_clut_position())),
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
|
||||
if(jaby_timer.is_expired_for(500_ms)) {
|
||||
jaby_frame_offset = jaby_frame_offset ? 0 : 32;
|
||||
jaby_timer.reset();
|
||||
}
|
||||
jaby_sprt.tex_offset.add(jaby_frame_offset, 0);
|
||||
|
||||
GPU::swap_buffers(!Shared::load_test);
|
||||
GPU::render(jaby_sprt);
|
||||
GPU::render(load_font);
|
||||
jaby_sprt.position.move(Assets::Main::JabyLoader::FontFrame.size.width + Assets::Main::JabyLoader::JabyFrame.size.width + 8, 0);
|
||||
GPU::render(jaby_sprt);
|
||||
}
|
||||
|
||||
static void run() {
|
||||
if(Shared::load_test || old_state_changer != state_changer) {
|
||||
GPU::set_vsync_callback(vsync_render);
|
||||
|
||||
cd_player.push();
|
||||
state_changer.asset_load();
|
||||
old_state_changer = state_changer;
|
||||
cd_player.pop();
|
||||
|
||||
GPU::set_vsync_callback(nullptr);
|
||||
}
|
||||
|
||||
state_changer.main();
|
||||
state_changer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
|
||||
setup();
|
||||
while(true) {
|
||||
if(state_changer.contains_state()) {
|
||||
LoadingScene::run();
|
||||
}
|
||||
|
||||
else {
|
||||
NormalScene::run();
|
||||
}
|
||||
}
|
||||
#include "../include/asset_mgr.hpp"
|
||||
#include "include/font_writer.hpp"
|
||||
#include "include/menu.hpp"
|
||||
#include "include/paco.hpp"
|
||||
#include "Overlay/Overlays.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
#include <PSX/Audio/CDDA.hpp>
|
||||
#include <PSX/Audio/CDXA.hpp>
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <stdio.hpp>
|
||||
|
||||
using namespace JabyEngine;
|
||||
using DigitalButton = Periphery::GenericController::Button;
|
||||
|
||||
struct CDPlayer {
|
||||
static constexpr auto MaxChannels = 2;
|
||||
|
||||
uint8_t channel;
|
||||
bool is_xa;
|
||||
|
||||
static constexpr CDPlayer create() {
|
||||
return CDPlayer{.channel = 0, .is_xa = true};
|
||||
}
|
||||
|
||||
void play() {
|
||||
if(this->is_xa) {
|
||||
Assets::XAAudio::play_mix();
|
||||
}
|
||||
|
||||
else {
|
||||
const auto [first_track, last_track] = CDDA::get_tracks();
|
||||
CDDA::play(first_track);
|
||||
}
|
||||
}
|
||||
|
||||
void stop() {
|
||||
if(this->is_xa) {
|
||||
CDXA::stop();
|
||||
}
|
||||
|
||||
else {
|
||||
CDDA::stop();
|
||||
}
|
||||
}
|
||||
|
||||
void change_channel(int8_t step) {
|
||||
if(this->is_xa) {
|
||||
this->channel = static_cast<uint8_t>((this->channel + step))%MaxChannels;
|
||||
CDXA::set_channel(this->channel);
|
||||
}
|
||||
}
|
||||
|
||||
void change_audio() {
|
||||
CDPlayer::stop();
|
||||
this->is_xa = !this->is_xa;
|
||||
CDPlayer::play();
|
||||
}
|
||||
|
||||
void push() {
|
||||
if(this->is_xa) {
|
||||
CDXA::push_play();
|
||||
}
|
||||
|
||||
else {
|
||||
CDDA::push_play();
|
||||
}
|
||||
}
|
||||
|
||||
void pop() {
|
||||
if(this->is_xa) {
|
||||
CDXA::pop_play();
|
||||
}
|
||||
|
||||
else {
|
||||
CDDA::pop_play();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct StateChange {
|
||||
void (*asset_load)();
|
||||
void (*main)();
|
||||
|
||||
static constexpr StateChange empty() {
|
||||
return StateChange{.asset_load = nullptr, .main = nullptr};
|
||||
}
|
||||
|
||||
void clear() {
|
||||
this->asset_load = nullptr;
|
||||
this->main = nullptr;
|
||||
}
|
||||
|
||||
bool contains_state() const {
|
||||
return this->main;
|
||||
}
|
||||
|
||||
auto operator<=>(const StateChange&) const = default;
|
||||
};
|
||||
|
||||
static const Menu::SimpleMenu::Entry MenuEntries[] = {
|
||||
{"Controller Test"},
|
||||
{"GPU Test"},
|
||||
{"GTE Test"},
|
||||
{"Font Cycler"},
|
||||
{"Screen Center"},
|
||||
{"BIOS Information"}
|
||||
};
|
||||
|
||||
static const auto doener_fish = Make::SPRT(
|
||||
Make::AreaI16(Make::PositionI16(8, GPU::Display::Height - Assets::Main::DoenerFishInfo.size.height), Assets::Main::DoenerFishInfo.size), // v this needs to be nicer! Has to be
|
||||
Make::OffsetPageWithClut(Assets::Main::DoenerFishInfo.tim.get_page_offset_clut4(), Make::PageClut(Assets::Main::DoenerFishInfo.tim.get_clut_position())),
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
|
||||
static CDPlayer cd_player = CDPlayer::create();
|
||||
static object::Paco paco;
|
||||
static Menu::SimpleMenu menu;
|
||||
static StateChange state_changer;
|
||||
static StateChange old_state_changer;
|
||||
|
||||
namespace Shared {
|
||||
Menu::BackMenu back_menu;
|
||||
JabyEngine::GPU::POLY_G4 background = Make::POLY_G4(
|
||||
Make::AreaI16(0, 0, GPU::Display::Width, GPU::Display::Height),
|
||||
{GPU::Color24::Red(0xA0), GPU::Color24::Green(0xA0), GPU::Color24::Blue(0xA0), GPU::Color24::Black()}
|
||||
);
|
||||
bool load_test = false;
|
||||
}
|
||||
|
||||
static void setup() {
|
||||
Assets::Main::load();
|
||||
FontWriter::setup();
|
||||
paco.setup();
|
||||
Shared::back_menu.setup(&FontWriter::bios_font_writer);
|
||||
|
||||
menu.setup([](uint32_t selection) {
|
||||
switch(selection) {
|
||||
case 0:
|
||||
state_changer.asset_load = Assets::Overlay::load_controller_test;
|
||||
state_changer.main = ControllerTest::main;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
state_changer.asset_load = Assets::Overlay::load_gpu_test;
|
||||
state_changer.main = GPUTest::main;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
state_changer.asset_load = Assets::Overlay::load_gte_test;
|
||||
state_changer.main = GTETest::main;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
state_changer.asset_load = Assets::Overlay::load_font_cycler;
|
||||
state_changer.main = FontCycler::main;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
state_changer.asset_load = Assets::Overlay::load_screen_center;
|
||||
state_changer.main = ScreenCenter::main;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
state_changer.asset_load = Assets::Overlay::load_bios_info;
|
||||
state_changer.main = BIOSInfo::main;
|
||||
break;
|
||||
}
|
||||
},MenuEntries);
|
||||
cd_player.play();
|
||||
}
|
||||
|
||||
namespace NormalScene {
|
||||
static void update() {
|
||||
static const char Title[] = ">> Pool Box <<";
|
||||
static const char Version[] = "Ver. 0.9.0";
|
||||
static constexpr auto TitleLength = DefaultFont::Info.estimate_str_render_length(Title);
|
||||
static constexpr auto VersionLength = DefaultFont::Info.estimate_str_render_length(Version);
|
||||
|
||||
Periphery::query_controller();
|
||||
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
|
||||
if(controller.is_connected()) {
|
||||
if(controller.button.went_down(DigitalButton::SEL)) {
|
||||
cd_player.change_audio();
|
||||
}
|
||||
|
||||
if(controller.button.went_down(DigitalButton::R1)) {
|
||||
cd_player.change_channel(1);
|
||||
}
|
||||
|
||||
if(controller.button.went_down(DigitalButton::L1)) {
|
||||
cd_player.change_channel(-1);
|
||||
}
|
||||
|
||||
// Trigger load test
|
||||
if(controller.button.is_down(DigitalButton::R2) && controller.button.is_down(DigitalButton::L2) && controller.button.is_down(DigitalButton::ST)) {
|
||||
Shared::load_test = true;
|
||||
}
|
||||
}
|
||||
|
||||
auto cursor = FontWriter::update(Make::PositionI16((GPU::Display::Width-TitleLength)/2, 16));
|
||||
paco.update();
|
||||
|
||||
FontWriter::new_font_writer.write(cursor, Title, GPU::Color24::Yellow(0xD0), &FontWriter::wiggle);
|
||||
FontWriter::new_font_writer.write(cursor.change_position(Make::PositionI16((GPU::Display::Width-VersionLength)/2, 16 + DefaultFont::Info.get_kern_size().height)), Version, GPU::Color24::Green(0xD0), &FontWriter::wiggle);
|
||||
menu.update(FontWriter::bios_font_writer, cursor, Make::PositionI16(8, 64));
|
||||
|
||||
cursor.change_position(Make::PositionI16(doener_fish.position.x + doener_fish.size.width, GPU::Display::Height - 48));
|
||||
FontWriter::bios_font_writer.write(cursor, "Audio:\n%s\n(SEL/R1/R2)", cd_player.is_xa ? "CD-XA" : "CD-DA");
|
||||
|
||||
if(Shared::load_test) {
|
||||
// Force state change if we are in the load_test state
|
||||
state_changer.asset_load = Assets::Overlay::load_large_gpu_test;
|
||||
state_changer.main = GPUTest::main;
|
||||
}
|
||||
}
|
||||
|
||||
static void render() {
|
||||
GPU::render(Shared::background);
|
||||
FontWriter::new_font_writer.render();
|
||||
FontWriter::bios_font_writer.render();
|
||||
paco.render();
|
||||
GPU::render(doener_fish);
|
||||
}
|
||||
|
||||
static void run() {
|
||||
update();
|
||||
GPU::swap_buffers_vsync(1);
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
namespace LoadingScene {
|
||||
static SimpleTimer<uint8_t> jaby_timer;
|
||||
static uint8_t jaby_frame_offset;
|
||||
|
||||
static void update() {
|
||||
jaby_timer.reset();
|
||||
jaby_frame_offset = 0;
|
||||
}
|
||||
|
||||
static void vsync_render() {
|
||||
static constexpr auto StartPosition = Make::PositionI16(24, 64);
|
||||
const auto load_font = Make::SPRT(
|
||||
Make::AreaI16(StartPosition.move(Assets::Main::JabyLoader::JabyFrame.size.width + 8, 0), Assets::Main::JabyLoader::FontFrame.size),
|
||||
Make::OffsetPageWithClut(Assets::Main::JabyLoader::TIMLoaction.get_page_offset_clut4().move(Assets::Main::JabyLoader::FontFrame.position.x, Assets::Main::JabyLoader::FontFrame.position.y), Make::PageClut(Assets::Main::JabyLoader::TIMLoaction.get_clut_position())),
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
auto jaby_sprt = Make::SPRT(
|
||||
Make::AreaI16(StartPosition, Assets::Main::JabyLoader::JabyFrame.size),
|
||||
Make::OffsetPageWithClut(Assets::Main::JabyLoader::TIMLoaction.get_page_offset_clut4(), Make::PageClut(Assets::Main::JabyLoader::TIMLoaction.get_clut_position())),
|
||||
GPU::Color24::Grey()
|
||||
);
|
||||
|
||||
if(jaby_timer.is_expired_for(500_ms)) {
|
||||
jaby_frame_offset = jaby_frame_offset ? 0 : 32;
|
||||
jaby_timer.reset();
|
||||
}
|
||||
jaby_sprt.tex_offset.add(jaby_frame_offset, 0);
|
||||
|
||||
GPU::swap_buffers(!Shared::load_test);
|
||||
GPU::render(jaby_sprt);
|
||||
GPU::render(load_font);
|
||||
jaby_sprt.position.move(Assets::Main::JabyLoader::FontFrame.size.width + Assets::Main::JabyLoader::JabyFrame.size.width + 8, 0);
|
||||
GPU::render(jaby_sprt);
|
||||
}
|
||||
|
||||
static void run() {
|
||||
if(Shared::load_test || old_state_changer != state_changer) {
|
||||
GPU::set_vsync_callback(vsync_render);
|
||||
|
||||
cd_player.push();
|
||||
state_changer.asset_load();
|
||||
old_state_changer = state_changer;
|
||||
cd_player.pop();
|
||||
|
||||
GPU::set_vsync_callback(nullptr);
|
||||
}
|
||||
|
||||
state_changer.main();
|
||||
state_changer.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
|
||||
setup();
|
||||
while(true) {
|
||||
if(state_changer.contains_state()) {
|
||||
LoadingScene::run();
|
||||
}
|
||||
|
||||
else {
|
||||
NormalScene::run();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,135 +1,135 @@
|
||||
#include "../include/asset_mgr.hpp"
|
||||
#include "Custom/custom_files.hpp"
|
||||
#include "Overlay/Overlays.hpp"
|
||||
#include <PSX/Audio/CDXA.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <stdio.hpp>
|
||||
|
||||
extern "C" uint32_t __bios_info_start;
|
||||
extern "C" uint32_t __controller_tests_start;
|
||||
extern "C" uint32_t __gpu_tests_start;
|
||||
extern "C" uint32_t __gte_tests_start;
|
||||
extern "C" uint32_t __font_cycler_start;
|
||||
extern "C" uint32_t __screen_center_start;
|
||||
|
||||
namespace Assets {
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(PACO, "ASSETS/MAIN/PACO.IMG"),
|
||||
__jabyengine_request_lba_for(DFISH, "ASSETS/MAIN/DFISH.IMG"),
|
||||
__jabyengine_request_lba_for(JABY_LOAD, "ASSETS/MAIN/LOAD.IMG"),
|
||||
__jabyengine_request_lba_for(APPLE_SFX, "SFX/APPLE.VAG"),
|
||||
__jabyengine_request_lba_for(BLUBB_SFX, "SFX/BLUBB.VAG"),
|
||||
__jabyengine_request_lba_for(FRIEND_SFX, "SFX/FRIEND.VAG"),
|
||||
__jabyengine_request_lba_for(MIX_XA, "XAAUDIO/MIX.XA"),
|
||||
__jabyengine_request_lba_for(BIOS_INFO_OVL, "BIO.BIN"),
|
||||
__jabyengine_request_lba_for(GPU_TEST_OVL, "GTO.BIN"),
|
||||
__jabyengine_request_lba_for(GTE_TEST_OVL, "GTE.BIN"),
|
||||
__jabyengine_request_lba_for(CONT_TEST_OVL, "CTO.BIN"),
|
||||
__jabyengine_request_lba_for(FONT_CYC_OVL, "FCO.BIN"),
|
||||
__jabyengine_request_lba_for(SCREEN_CENT_OVL, "SCO.BIN"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
static void load(const volatile AutoLBAEntry* lba, const CDFile* assets, size_t size) {
|
||||
const auto buffer_cfg = CDFileProcessor::BufferConfiguration::new_default();
|
||||
CDFileProcessor file_processor;
|
||||
|
||||
file_processor.setup(lba, CDFileProcessor::JobArray{assets, size}, buffer_cfg);
|
||||
while(true) {
|
||||
switch(file_processor.process()) {
|
||||
case Progress::InProgress:
|
||||
break;
|
||||
|
||||
case Progress::Done:
|
||||
if(!file_processor.next(lba, buffer_cfg)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case Progress::Error:
|
||||
printf("Error detected! Aborting load\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
file_processor.shutdown();
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
static void load(const volatile AutoLBAEntry* lba, const CDFile (&files)[N]) {
|
||||
return load(lba, files, N);
|
||||
}
|
||||
|
||||
namespace Main {
|
||||
using SPU::operator""_vol;
|
||||
|
||||
static const CDFile Files[] = {
|
||||
CDFileBuilder::simple_tim(LBA::PACO, PacoTIM),
|
||||
CDFileBuilder::simple_tim(LBA::DFISH, DoenerFishInfo.tim),
|
||||
CDFileBuilder::simple_tim(LBA::JABY_LOAD, JabyLoader::TIMLoaction),
|
||||
CDFileBuilder::sony_vag(LBA::APPLE_SFX, VAG::create(0, 1.0_vol)),
|
||||
CDFileBuilder::sony_vag(LBA::BLUBB_SFX, VAG::create(1, 1.0_vol)),
|
||||
CDFileBuilder::sony_vag(LBA::FRIEND_SFX, VAG::create(2, 1.0_vol)),
|
||||
CustomCDFileBuilder::jingle(2),
|
||||
};
|
||||
|
||||
void load() {
|
||||
::Assets::load(lba, Files);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Overlay {
|
||||
static void load(const CDFile& overlay_file, const volatile AutoLBAEntry* overlay_lba, const CDFile* overlay_assets, size_t size) {
|
||||
::Assets::load(lba, &overlay_file, 1);
|
||||
if(overlay_lba) {
|
||||
::Assets::load(overlay_lba, overlay_assets, size);
|
||||
}
|
||||
}
|
||||
|
||||
static void load(const CDFile& overlay_file) {
|
||||
load(overlay_file, nullptr, nullptr, 0ull);
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
static void load(const CDFile& overlay_file, const volatile AutoLBAEntry* overlay_lba, const CDFile (&overlay_assets)[N]) {
|
||||
load(overlay_file, overlay_lba, overlay_assets, N);
|
||||
}
|
||||
|
||||
void load_bios_info() {
|
||||
load(CDFileBuilder::overlay(LBA::BIOS_INFO_OVL, &__bios_info_start));
|
||||
}
|
||||
|
||||
void load_controller_test() {
|
||||
load(CDFileBuilder::overlay(LBA::CONT_TEST_OVL, &__controller_tests_start), ControllerTest::lba, ControllerTest::Assets);
|
||||
}
|
||||
|
||||
void load_gpu_test() {
|
||||
load(CDFileBuilder::overlay(LBA::GPU_TEST_OVL, &__gpu_tests_start), GPUTest::lba, GPUTest::Assets);
|
||||
}
|
||||
|
||||
void load_large_gpu_test() {
|
||||
load(CDFileBuilder::overlay(LBA::GPU_TEST_OVL, &__gpu_tests_start), GPUTest::lba, GPUTest::LargeAssets);
|
||||
}
|
||||
|
||||
void load_gte_test() {
|
||||
load(CDFileBuilder::overlay(LBA::GTE_TEST_OVL, &__gte_tests_start), GTETest::lba, GTETest::Assets);
|
||||
}
|
||||
|
||||
void load_font_cycler() {
|
||||
load(CDFileBuilder::overlay(LBA::FONT_CYC_OVL, &__font_cycler_start));
|
||||
}
|
||||
|
||||
void load_screen_center() {
|
||||
load(CDFileBuilder::overlay(LBA::SCREEN_CENT_OVL, &__screen_center_start), ScreenCenter::lba, ScreenCenter::Assets);
|
||||
}
|
||||
}
|
||||
|
||||
namespace XAAudio {
|
||||
void play_mix() {
|
||||
CDXA::play(lba, MIX_XA, 0, false);
|
||||
}
|
||||
}
|
||||
#include "../include/asset_mgr.hpp"
|
||||
#include "Custom/custom_files.hpp"
|
||||
#include "Overlay/Overlays.hpp"
|
||||
#include <PSX/Audio/CDXA.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba.hpp>
|
||||
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp>
|
||||
#include <stdio.hpp>
|
||||
|
||||
extern "C" uint32_t __bios_info_start;
|
||||
extern "C" uint32_t __controller_tests_start;
|
||||
extern "C" uint32_t __gpu_tests_start;
|
||||
extern "C" uint32_t __gte_tests_start;
|
||||
extern "C" uint32_t __font_cycler_start;
|
||||
extern "C" uint32_t __screen_center_start;
|
||||
|
||||
namespace Assets {
|
||||
enum LBA {
|
||||
__jabyengine_start_lba_request
|
||||
__jabyengine_request_lba_for(PACO, "ASSETS/MAIN/PACO.IMG"),
|
||||
__jabyengine_request_lba_for(DFISH, "ASSETS/MAIN/DFISH.IMG"),
|
||||
__jabyengine_request_lba_for(JABY_LOAD, "ASSETS/MAIN/LOAD.IMG"),
|
||||
__jabyengine_request_lba_for(APPLE_SFX, "SFX/APPLE.VAG"),
|
||||
__jabyengine_request_lba_for(BLUBB_SFX, "SFX/BLUBB.VAG"),
|
||||
__jabyengine_request_lba_for(FRIEND_SFX, "SFX/FRIEND.VAG"),
|
||||
__jabyengine_request_lba_for(MIX_XA, "XAAUDIO/MIX.XA"),
|
||||
__jabyengine_request_lba_for(BIOS_INFO_OVL, "BIO.BIN"),
|
||||
__jabyengine_request_lba_for(GPU_TEST_OVL, "GTO.BIN"),
|
||||
__jabyengine_request_lba_for(GTE_TEST_OVL, "GTE.BIN"),
|
||||
__jabyengine_request_lba_for(CONT_TEST_OVL, "CTO.BIN"),
|
||||
__jabyengine_request_lba_for(FONT_CYC_OVL, "FCO.BIN"),
|
||||
__jabyengine_request_lba_for(SCREEN_CENT_OVL, "SCO.BIN"),
|
||||
__jabyengine_end_lba_request
|
||||
};
|
||||
__declare_lba_header(LBA);
|
||||
|
||||
static void load(const volatile AutoLBAEntry* lba, const CDFile* assets, size_t size) {
|
||||
const auto buffer_cfg = CDFileProcessor::BufferConfiguration::new_default();
|
||||
CDFileProcessor file_processor;
|
||||
|
||||
file_processor.setup(lba, CDFileProcessor::JobArray{assets, size}, buffer_cfg);
|
||||
while(true) {
|
||||
switch(file_processor.process()) {
|
||||
case Progress::InProgress:
|
||||
break;
|
||||
|
||||
case Progress::Done:
|
||||
if(!file_processor.next(lba, buffer_cfg)) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case Progress::Error:
|
||||
printf("Error detected! Aborting load\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
file_processor.shutdown();
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
static void load(const volatile AutoLBAEntry* lba, const CDFile (&files)[N]) {
|
||||
return load(lba, files, N);
|
||||
}
|
||||
|
||||
namespace Main {
|
||||
using SPU::operator""_vol;
|
||||
|
||||
static const CDFile Files[] = {
|
||||
CDFileBuilder::simple_tim(LBA::PACO, PacoTIM),
|
||||
CDFileBuilder::simple_tim(LBA::DFISH, DoenerFishInfo.tim),
|
||||
CDFileBuilder::simple_tim(LBA::JABY_LOAD, JabyLoader::TIMLoaction),
|
||||
CDFileBuilder::sony_vag(LBA::APPLE_SFX, VAG::create(0, 1.0_vol)),
|
||||
CDFileBuilder::sony_vag(LBA::BLUBB_SFX, VAG::create(1, 1.0_vol)),
|
||||
CDFileBuilder::sony_vag(LBA::FRIEND_SFX, VAG::create(2, 1.0_vol)),
|
||||
CustomCDFileBuilder::jingle(2),
|
||||
};
|
||||
|
||||
void load() {
|
||||
::Assets::load(lba, Files);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Overlay {
|
||||
static void load(const CDFile& overlay_file, const volatile AutoLBAEntry* overlay_lba, const CDFile* overlay_assets, size_t size) {
|
||||
::Assets::load(lba, &overlay_file, 1);
|
||||
if(overlay_lba) {
|
||||
::Assets::load(overlay_lba, overlay_assets, size);
|
||||
}
|
||||
}
|
||||
|
||||
static void load(const CDFile& overlay_file) {
|
||||
load(overlay_file, nullptr, nullptr, 0ull);
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
static void load(const CDFile& overlay_file, const volatile AutoLBAEntry* overlay_lba, const CDFile (&overlay_assets)[N]) {
|
||||
load(overlay_file, overlay_lba, overlay_assets, N);
|
||||
}
|
||||
|
||||
void load_bios_info() {
|
||||
load(CDFileBuilder::overlay(LBA::BIOS_INFO_OVL, &__bios_info_start));
|
||||
}
|
||||
|
||||
void load_controller_test() {
|
||||
load(CDFileBuilder::overlay(LBA::CONT_TEST_OVL, &__controller_tests_start), ControllerTest::lba, ControllerTest::Assets);
|
||||
}
|
||||
|
||||
void load_gpu_test() {
|
||||
load(CDFileBuilder::overlay(LBA::GPU_TEST_OVL, &__gpu_tests_start), GPUTest::lba, GPUTest::Assets);
|
||||
}
|
||||
|
||||
void load_large_gpu_test() {
|
||||
load(CDFileBuilder::overlay(LBA::GPU_TEST_OVL, &__gpu_tests_start), GPUTest::lba, GPUTest::LargeAssets);
|
||||
}
|
||||
|
||||
void load_gte_test() {
|
||||
load(CDFileBuilder::overlay(LBA::GTE_TEST_OVL, &__gte_tests_start), GTETest::lba, GTETest::Assets);
|
||||
}
|
||||
|
||||
void load_font_cycler() {
|
||||
load(CDFileBuilder::overlay(LBA::FONT_CYC_OVL, &__font_cycler_start));
|
||||
}
|
||||
|
||||
void load_screen_center() {
|
||||
load(CDFileBuilder::overlay(LBA::SCREEN_CENT_OVL, &__screen_center_start), ScreenCenter::lba, ScreenCenter::Assets);
|
||||
}
|
||||
}
|
||||
|
||||
namespace XAAudio {
|
||||
void play_mix() {
|
||||
CDXA::play(lba, MIX_XA, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,35 +1,35 @@
|
||||
#include "include/font_writer.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp> //< only for __heap_start D:
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace FontWriter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static constexpr auto LibraryFontTIM = SimpleTIM::create(320, 0, 320, DefaultFont::Info.texture_size.height);
|
||||
|
||||
static FontPrimitive font_buffer[2*256];
|
||||
Wiggle wiggle = {Make::PositionI8(0, 0), Make::PositionI8(1, -2), Make::PositionI8(0, -4), Make::PositionI8(-1, -2), Make::PositionI8(0, 0), Make::PositionI8(1, 2), Make::PositionI8(0, 4), Make::PositionI8(-1, 2)};
|
||||
JabyEngine::FontWriter new_font_writer = JabyEngine::FontWriter::empty();
|
||||
JabyEngine::FontWriter bios_font_writer = JabyEngine::FontWriter::empty();
|
||||
static SimpleTimer<uint8_t> timer;
|
||||
uint8_t wiggle_count = 0;
|
||||
|
||||
void setup() {
|
||||
JabyEngine::DefaultFont::load(&__heap_start, LibraryFontTIM);
|
||||
JabyEngine::GlobalFontPrimitivePool::setup(font_buffer);
|
||||
|
||||
new_font_writer.setup(LibraryFontTIM, JabyEngine::DefaultFont::Info);
|
||||
bios_font_writer.setup(JabyEngine::BIOSFont::TIM, JabyEngine::BIOSFont::Info);
|
||||
timer.reset();
|
||||
}
|
||||
|
||||
Cursor update(const GPU::PositionI16& start) {
|
||||
if(timer.is_expired_for(50_ms)) {
|
||||
timer.reset();
|
||||
wiggle_count++;
|
||||
}
|
||||
|
||||
return Cursor::create(start, wiggle_count);
|
||||
}
|
||||
#include "include/font_writer.hpp"
|
||||
#include <FontWriter/fonts.hpp>
|
||||
#include <PSX/File/Processor/cd_file_processor.hpp> //< only for __heap_start D:
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace FontWriter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
static constexpr auto LibraryFontTIM = SimpleTIM::create(320, 0, 320, DefaultFont::Info.texture_size.height);
|
||||
|
||||
static FontPrimitive font_buffer[2*256];
|
||||
Wiggle wiggle = {Make::PositionI8(0, 0), Make::PositionI8(1, -2), Make::PositionI8(0, -4), Make::PositionI8(-1, -2), Make::PositionI8(0, 0), Make::PositionI8(1, 2), Make::PositionI8(0, 4), Make::PositionI8(-1, 2)};
|
||||
JabyEngine::FontWriter new_font_writer = JabyEngine::FontWriter::empty();
|
||||
JabyEngine::FontWriter bios_font_writer = JabyEngine::FontWriter::empty();
|
||||
static SimpleTimer<uint8_t> timer;
|
||||
uint8_t wiggle_count = 0;
|
||||
|
||||
void setup() {
|
||||
JabyEngine::DefaultFont::load(&__heap_start, LibraryFontTIM);
|
||||
JabyEngine::GlobalFontPrimitivePool::setup(font_buffer);
|
||||
|
||||
new_font_writer.setup(LibraryFontTIM, JabyEngine::DefaultFont::Info);
|
||||
bios_font_writer.setup(JabyEngine::BIOSFont::TIM, JabyEngine::BIOSFont::Info);
|
||||
timer.reset();
|
||||
}
|
||||
|
||||
Cursor update(const GPU::PositionI16& start) {
|
||||
if(timer.is_expired_for(50_ms)) {
|
||||
timer.reset();
|
||||
wiggle_count++;
|
||||
}
|
||||
|
||||
return Cursor::create(start, wiggle_count);
|
||||
}
|
||||
}
|
@@ -1,14 +1,14 @@
|
||||
#pragma once
|
||||
#include <FontWriter/Type/types.hpp>
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
|
||||
namespace FontWriter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
extern Wiggle wiggle;
|
||||
extern JabyEngine::FontWriter new_font_writer;
|
||||
extern JabyEngine::FontWriter bios_font_writer;
|
||||
|
||||
void setup();
|
||||
Cursor update(const GPU::PositionI16& start);
|
||||
#pragma once
|
||||
#include <FontWriter/Type/types.hpp>
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
|
||||
namespace FontWriter {
|
||||
using namespace JabyEngine;
|
||||
|
||||
extern Wiggle wiggle;
|
||||
extern JabyEngine::FontWriter new_font_writer;
|
||||
extern JabyEngine::FontWriter bios_font_writer;
|
||||
|
||||
void setup();
|
||||
Cursor update(const GPU::PositionI16& start);
|
||||
}
|
@@ -1,50 +1,50 @@
|
||||
#pragma once
|
||||
#include "font_writer.hpp"
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace Menu {
|
||||
using namespace JabyEngine;
|
||||
|
||||
class SimpleMenu {
|
||||
public:
|
||||
struct Entry {
|
||||
const char* name;
|
||||
};
|
||||
|
||||
typedef void (*Callback)(uint32_t selection);
|
||||
|
||||
private:
|
||||
Callback selection_callback;
|
||||
const Entry* entries;
|
||||
size_t size;
|
||||
uint8_t cur_selection;
|
||||
|
||||
public:
|
||||
void setup(Callback callback, const Entry* entries, size_t size);
|
||||
|
||||
template<size_t N>
|
||||
void setup(Callback callback, const Entry (&entries)[N]) {
|
||||
SimpleMenu::setup(callback, entries, N);
|
||||
}
|
||||
|
||||
void update(JabyEngine::FontWriter& font_writer, Cursor& cursor, const GPU::PositionI16& start);
|
||||
};
|
||||
|
||||
class BackMenu {
|
||||
private:
|
||||
JabyEngine::FontWriter* font_writer;
|
||||
SimpleTimer<uint32_t> timeout;
|
||||
bool waiting;
|
||||
|
||||
public:
|
||||
void setup(JabyEngine::FontWriter* font_writer);
|
||||
void reset() {
|
||||
this->timeout.reset();
|
||||
this->waiting = false;
|
||||
}
|
||||
|
||||
bool update(const GPU::PositionI16& position, bool auto_clear = true);
|
||||
void render();
|
||||
};
|
||||
#pragma once
|
||||
#include "font_writer.hpp"
|
||||
#include <FontWriter/font_writer.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace Menu {
|
||||
using namespace JabyEngine;
|
||||
|
||||
class SimpleMenu {
|
||||
public:
|
||||
struct Entry {
|
||||
const char* name;
|
||||
};
|
||||
|
||||
typedef void (*Callback)(uint32_t selection);
|
||||
|
||||
private:
|
||||
Callback selection_callback;
|
||||
const Entry* entries;
|
||||
size_t size;
|
||||
uint8_t cur_selection;
|
||||
|
||||
public:
|
||||
void setup(Callback callback, const Entry* entries, size_t size);
|
||||
|
||||
template<size_t N>
|
||||
void setup(Callback callback, const Entry (&entries)[N]) {
|
||||
SimpleMenu::setup(callback, entries, N);
|
||||
}
|
||||
|
||||
void update(JabyEngine::FontWriter& font_writer, Cursor& cursor, const GPU::PositionI16& start);
|
||||
};
|
||||
|
||||
class BackMenu {
|
||||
private:
|
||||
JabyEngine::FontWriter* font_writer;
|
||||
SimpleTimer<uint32_t> timeout;
|
||||
bool waiting;
|
||||
|
||||
public:
|
||||
void setup(JabyEngine::FontWriter* font_writer);
|
||||
void reset() {
|
||||
this->timeout.reset();
|
||||
this->waiting = false;
|
||||
}
|
||||
|
||||
bool update(const GPU::PositionI16& position, bool auto_clear = true);
|
||||
void render();
|
||||
};
|
||||
}
|
@@ -1,35 +1,35 @@
|
||||
#pragma once
|
||||
#include "../../include/asset_mgr.hpp"
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace object {
|
||||
using namespace JabyEngine;
|
||||
|
||||
class Paco {
|
||||
private:
|
||||
static constexpr auto Size = Make::SizeI16(120, 128);
|
||||
static const GPU::Color24 Colors[];
|
||||
|
||||
GPU::TexPage::Linked tex_page;
|
||||
GPU::SPRT::Linked sprite;
|
||||
SimpleTimer<uint8_t> timer;
|
||||
uint8_t color_idx;
|
||||
|
||||
public:
|
||||
constexpr Paco() :
|
||||
tex_page(Make::TexPage(Make::PositionU16(
|
||||
Assets::Main::PacoTIM.get_texture_x(), Assets::Main::PacoTIM.get_texture_y()),
|
||||
GPU::TextureColorMode::clut4).linked()),
|
||||
sprite(Make::SPRT(
|
||||
Make::AreaI16(Make::PositionI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height), Size),
|
||||
Make::OffsetPageWithClut(Make::PageOffset(0, 0), Make::PageClut(Assets::Main::PacoTIM.get_clut_x(), Assets::Main::PacoTIM.get_clut_y())),
|
||||
GPU::Color24::Blue()).linked()),
|
||||
timer(),
|
||||
color_idx(0) {}
|
||||
|
||||
void setup();
|
||||
void update();
|
||||
void render();
|
||||
};
|
||||
#pragma once
|
||||
#include "../../include/asset_mgr.hpp"
|
||||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
#include <PSX/Timer/frame_timer.hpp>
|
||||
|
||||
namespace object {
|
||||
using namespace JabyEngine;
|
||||
|
||||
class Paco {
|
||||
private:
|
||||
static constexpr auto Size = Make::SizeI16(120, 128);
|
||||
static const GPU::Color24 Colors[];
|
||||
|
||||
GPU::TexPage::Linked tex_page;
|
||||
GPU::SPRT::Linked sprite;
|
||||
SimpleTimer<uint8_t> timer;
|
||||
uint8_t color_idx;
|
||||
|
||||
public:
|
||||
constexpr Paco() :
|
||||
tex_page(Make::TexPage(Make::PositionU16(
|
||||
Assets::Main::PacoTIM.get_texture_x(), Assets::Main::PacoTIM.get_texture_y()),
|
||||
GPU::TextureColorMode::clut4).linked()),
|
||||
sprite(Make::SPRT(
|
||||
Make::AreaI16(Make::PositionI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height), Size),
|
||||
Make::OffsetPageWithClut(Make::PageOffset(0, 0), Make::PageClut(Assets::Main::PacoTIM.get_clut_x(), Assets::Main::PacoTIM.get_clut_y())),
|
||||
GPU::Color24::Blue()).linked()),
|
||||
timer(),
|
||||
color_idx(0) {}
|
||||
|
||||
void setup();
|
||||
void update();
|
||||
void render();
|
||||
};
|
||||
}
|
@@ -1,81 +1,81 @@
|
||||
#include "../include/shared.hpp"
|
||||
#include "include/menu.hpp"
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <PSX/SPU/spu.hpp>
|
||||
|
||||
namespace Menu {
|
||||
using DigitalButton = Periphery::GenericController::Button;
|
||||
|
||||
void SimpleMenu :: setup(Callback callback, const Entry* entries, size_t size) {
|
||||
this->selection_callback = callback;
|
||||
this->entries = entries;
|
||||
this->size = size;
|
||||
this->cur_selection = 0;
|
||||
}
|
||||
|
||||
void SimpleMenu :: update(JabyEngine::FontWriter& font_writer, Cursor& cursor, const GPU::PositionI16& start) {
|
||||
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
|
||||
if(controller.button.went_down(DigitalButton::Up) && this->cur_selection > 0) {
|
||||
this->cur_selection -= 1;
|
||||
}
|
||||
|
||||
if(controller.button.went_down(DigitalButton::Down) && this->cur_selection < (this->size - 1)) {
|
||||
this->cur_selection += 1;
|
||||
}
|
||||
|
||||
if(controller.button.went_down(DigitalButton::Cross)) {
|
||||
SPU::voice[0].play();
|
||||
this->selection_callback(this->cur_selection);
|
||||
}
|
||||
|
||||
cursor.pos = Make::PositionI16(8, 64);
|
||||
for(size_t n = 0; n < this->size; n++) {
|
||||
const auto& cur_entry = this->entries[n];
|
||||
|
||||
if(this->cur_selection == n) {
|
||||
FontWriter::bios_font_writer.write(cursor, ">%s<\n", cur_entry.name);
|
||||
}
|
||||
|
||||
else {
|
||||
FontWriter::bios_font_writer.write(cursor, "%s\n", cur_entry.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BackMenu :: setup(JabyEngine::FontWriter* font_writer) {
|
||||
this->font_writer = font_writer;
|
||||
this->timeout.reset();
|
||||
this->waiting = false;
|
||||
}
|
||||
|
||||
bool BackMenu :: update(const GPU::PositionI16& position, bool auto_clear) {
|
||||
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
|
||||
if(Shared::load_test || controller.button.is_down(DigitalButton::Circle)) {
|
||||
this->waiting = true;
|
||||
if(this->timeout.is_expired_for(2500_ms)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
this->waiting = false;
|
||||
this->timeout.reset();
|
||||
}
|
||||
|
||||
if(this->waiting) {
|
||||
auto cursor = JabyEngine::Cursor::create(position);
|
||||
this->font_writer->write(cursor, "Press and hold O\nto get back", GPU::Color24::Red(0xD0));
|
||||
}
|
||||
|
||||
else if(auto_clear) {
|
||||
this->font_writer->clear();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BackMenu :: render() {
|
||||
this->font_writer->render();
|
||||
}
|
||||
#include "../include/shared.hpp"
|
||||
#include "include/menu.hpp"
|
||||
#include <PSX/Periphery/periphery.hpp>
|
||||
#include <PSX/SPU/spu.hpp>
|
||||
|
||||
namespace Menu {
|
||||
using DigitalButton = Periphery::GenericController::Button;
|
||||
|
||||
void SimpleMenu :: setup(Callback callback, const Entry* entries, size_t size) {
|
||||
this->selection_callback = callback;
|
||||
this->entries = entries;
|
||||
this->size = size;
|
||||
this->cur_selection = 0;
|
||||
}
|
||||
|
||||
void SimpleMenu :: update(JabyEngine::FontWriter& font_writer, Cursor& cursor, const GPU::PositionI16& start) {
|
||||
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
|
||||
if(controller.button.went_down(DigitalButton::Up) && this->cur_selection > 0) {
|
||||
this->cur_selection -= 1;
|
||||
}
|
||||
|
||||
if(controller.button.went_down(DigitalButton::Down) && this->cur_selection < (this->size - 1)) {
|
||||
this->cur_selection += 1;
|
||||
}
|
||||
|
||||
if(controller.button.went_down(DigitalButton::Cross)) {
|
||||
SPU::voice[0].play();
|
||||
this->selection_callback(this->cur_selection);
|
||||
}
|
||||
|
||||
cursor.pos = Make::PositionI16(8, 64);
|
||||
for(size_t n = 0; n < this->size; n++) {
|
||||
const auto& cur_entry = this->entries[n];
|
||||
|
||||
if(this->cur_selection == n) {
|
||||
FontWriter::bios_font_writer.write(cursor, ">%s<\n", cur_entry.name);
|
||||
}
|
||||
|
||||
else {
|
||||
FontWriter::bios_font_writer.write(cursor, "%s\n", cur_entry.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BackMenu :: setup(JabyEngine::FontWriter* font_writer) {
|
||||
this->font_writer = font_writer;
|
||||
this->timeout.reset();
|
||||
this->waiting = false;
|
||||
}
|
||||
|
||||
bool BackMenu :: update(const GPU::PositionI16& position, bool auto_clear) {
|
||||
const auto& controller = Periphery::get_primary_controller_as<JabyEngine::Periphery::GenericController>();
|
||||
|
||||
if(Shared::load_test || controller.button.is_down(DigitalButton::Circle)) {
|
||||
this->waiting = true;
|
||||
if(this->timeout.is_expired_for(2500_ms)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
this->waiting = false;
|
||||
this->timeout.reset();
|
||||
}
|
||||
|
||||
if(this->waiting) {
|
||||
auto cursor = JabyEngine::Cursor::create(position);
|
||||
this->font_writer->write(cursor, "Press and hold O\nto get back", GPU::Color24::Red(0xD0));
|
||||
}
|
||||
|
||||
else if(auto_clear) {
|
||||
this->font_writer->clear();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BackMenu :: render() {
|
||||
this->font_writer->render();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user