From 3651c4c405e5feb57170ecb63e768839f2ec809f Mon Sep 17 00:00:00 2001 From: Jaby Date: Thu, 21 Dec 2023 11:43:24 -0500 Subject: [PATCH] First draft for LookUpColor8 --- include/PSX/GPU/gpu_types.hpp | 24 ++++++++++++++++++++++++ src/Library/src/BootLoader/gpu_boot.cpp | 24 ++++++++++++++++++++---- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/include/PSX/GPU/gpu_types.hpp b/include/PSX/GPU/gpu_types.hpp index 7c899f03..3871e663 100644 --- a/include/PSX/GPU/gpu_types.hpp +++ b/include/PSX/GPU/gpu_types.hpp @@ -153,6 +153,30 @@ namespace JabyEngine { } }; + struct LookUpColor8 { + static constexpr BitRange LUPosition[] = { + BitRange::from_to(0, 7), + BitRange::from_to(8, 15) + }; + uint8_t lu_id[2]; + + static constexpr LookUpColor8 from_ids(uint8_t px0, uint8_t px1) { + return {{px0, px1}}; + } + + constexpr uint8_t get_lu_id(size_t at) const { + return this->lu_id[at]; + } + + constexpr void set_lu_id(uint8_t new_lu_id, size_t at) { + this->lu_id[at] = new_lu_id; + } + + uint16_t force_read() const { + return *const_cast(reinterpret_cast(this->lu_id)); + } + }; + template struct Position : public internal::XYMovement, T> { T x; diff --git a/src/Library/src/BootLoader/gpu_boot.cpp b/src/Library/src/BootLoader/gpu_boot.cpp index 7df4500f..8ff9dd8d 100644 --- a/src/Library/src/BootLoader/gpu_boot.cpp +++ b/src/Library/src/BootLoader/gpu_boot.cpp @@ -32,10 +32,9 @@ namespace JabyEngine { const CLUT clut { .cmd = CPU2VRAM::create(AreaU16::create(dst_cord, GPU::SizeU16::create(16, 1))), .data = { - Color::Blue(), Color::White(), - Color::Blue(), Color::White(), Color::Blue(), Color::White(), Color::Blue(), Color::White(), - Color::Blue(), Color::White(), - Color::Blue(), Color::White(), Color::Blue(), Color::White(), Color::Blue(), Color::White(), + Color::Grey(), Color::White(), + Color::Black(), Color::Black(), Color::Black(), Color::Black(), Color::Black(), Color::Black(), Color::Black(), + Color::Black(), Color::Black(), Color::Black(), Color::Black(), Color::Black(), Color::Black(), Color::Black(), } }; @@ -93,6 +92,23 @@ namespace JabyEngine { } void setup() { + asm("# Planschi1"); + auto test = LookUpColor8::from_ids(0xAA, 0xBB); + test.force_read(); + asm("# Planschi2"); + test.set_lu_id(0xCC, 0); + test.set_lu_id(0xDD, 1); + test.force_read(); + asm("# Planschi3"); + test.set_lu_id(*reinterpret_cast(0xAA), 0); + test.set_lu_id(*reinterpret_cast(0xDD), 1); + test.force_read(); + asm("# Planschi4"); + test.set_lu_id(*reinterpret_cast(0xAA), *reinterpret_cast(0xAE)); + test.set_lu_id(*reinterpret_cast(0xDD), *reinterpret_cast(0xDE)); + test.force_read(); + asm("# Planschi5"); + GPU_IO::GP1.write(GPU_IO::Command::Reset()); configurate_display(); ::JabyEngine::GPU::internal::Display::exchange_buffer_and_display();