Testing font and color font

This commit is contained in:
jaby 2023-06-15 20:48:25 +02:00
parent 501ed1cd35
commit d40486a308
5 changed files with 61 additions and 12 deletions

View File

@ -1,7 +1,11 @@
#ifndef __ASSETS_HPP__
#define __ASSETS_HPP__
#include <PSX/File/Processor/cd_file_processor.hpp>
namespace Assets {
using namespace JabyEngine;
static constexpr auto FontTIM = SimpleTIM(960, 0, 960, 511);
void load_for_main();
}

View File

@ -1,7 +1,25 @@
#include "assets.hpp"
#include <PSX/GPU/gpu_primitives.hpp>
#include <PSX/GPU/gpu.hpp>
#include <stdio.h>
using namespace JabyEngine;
static auto FontPage = GPU::TexPage({Assets::FontTIM.get_texture_x(), Assets::FontTIM.get_texture_y()}, GPU::TexturePageColor::$4bit).linked();
static auto FontTest = GPU::SPRT(
GPU::AreaI16({0, 0}, {256, 96}), {GPU::PagePosition(0, 0), GPU::PageClut(Assets::FontTIM.get_clut_x(), Assets::FontTIM.get_clut_y())},
GPU::Color24::Grey()
).linked();
static auto FontTestColor = GPU::SPRT(
GPU::AreaI16({0, 96}, {256, 96}), {GPU::PagePosition(0, 0), GPU::PageClut(Assets::FontTIM.get_clut_x(), Assets::FontTIM.get_clut_y())},
GPU::Color24(0x0, 0x0, 0xA0)
).linked();
void main() {
Assets::load_for_main();
printf("Planschbecken c:\n");
FontPage.concat(FontTest).concat(FontTestColor);
while(true) {
GPU::swap_buffers_vsync(1);
GPU::render(FontPage);
}
}

View File

@ -1,5 +1,4 @@
#include "assets.hpp"
#include <PSX/File/Processor/cd_file_processor.hpp>
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
#include <stdio.h>
@ -13,6 +12,29 @@ namespace Assets {
__declare_lba_header(LBA);
void load_for_main() {
printf("Loading assets! %i\n", lba[LBA::FONT].get_lba());
static const CDFile Assets[] = {
CDFileBuilder::simple_tim(LBA::FONT, FontTIM),
};
const auto buffer_cfg = CDFileProcessor::BufferConfiguration::new_default();
CDFileProcessor file_processor;
file_processor.setup(lba, Assets, 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;
}
}
}
}

View File

@ -34,11 +34,16 @@ namespace JabyEngine {
}
template<typename T>
const T& concat(const T& obj) {
T& concat(T& obj) {
Link::set_adr(&obj);
return obj;
}
template<typename T>
const T& concat(const T& obj) {
return concat(const_cast<T&>(obj));
}
constexpr void terminate() {
this->value |= TerminationValue;
}

View File

@ -78,20 +78,20 @@ namespace JabyEngine {
return Color24(0xFF, 0xFF, 0xFF);
}
static constexpr Color24 Red() {
return Color24(0xFF, 0x0, 0x0);
static constexpr Color24 Red(uint8_t base = 0xFF) {
return Color24(base, 0x0, 0x0);
}
static constexpr Color24 Green() {
return Color24(0x0, 0xFF, 0x0);
static constexpr Color24 Green(uint8_t base = 0xFF) {
return Color24(0x0, base, 0x0);
}
static constexpr Color24 Blue() {
return Color24(0x0, 0x0, 0xFF);
static constexpr Color24 Blue(uint8_t base = 0xFF) {
return Color24(0x0, 0x0, base);
}
static constexpr Color24 Yellow() {
return Color24(0xFF, 0xFF, 0x0);
static constexpr Color24 Yellow(uint8_t base = 0xFF) {
return Color24(base, base, 0x0);
}
constexpr Color24 invert() const {