Introduce internal and normal GPU functions

This commit is contained in:
jaby 2022-09-11 10:10:51 +02:00
parent 679899279d
commit a8f0bddc89
7 changed files with 73 additions and 12 deletions

17
include/PSX/GPU/GPU.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef __JABYENGINE_GPU_H__
#define __JABYENGINE_GPU_H__
#include "../System/IOPorts/GPU_IO.hpp"
namespace GPU {
namespace Display {
static void enable() {
Port::GP1.write(Port::Command::GP1::SetDisplayState(Port::DisplayState::On));
}
static void disable() {
Port::GP1.write(Port::Command::GP1::SetDisplayState(Port::DisplayState::Off));
}
}
}
#endif //!__JABYENGINE_GPU_H__

View File

@ -16,6 +16,32 @@ namespace GPU {
return ((this->blue << 16) | (this->green << 8) | this->red);
}
};
template<typename T>
struct Position {
T x = 0;
T y = 0;
constexpr Position() = default;
constexpr Position(T x, T y) : x(x), y(y) {
}
};
template<typename T>
struct Size {
T width = 0;
T height = 0;
constexpr Size() = default;
constexpr Size(T w, T h) : width(w), height(h) {
}
};
typedef Position<int16_t> PositionI16;
typedef Position<uint16_t> PositionU16;
typedef Size<int16_t> SizeI16;
typedef Size<uint16_t> SizeU16;
}
#endif //!__JABYENGINE_GPU_TYPES_HPP__

View File

@ -55,7 +55,7 @@ namespace GPU {
}
static constexpr GP0 WidthHeight(uint16_t w, uint16_t h) {
return {(h << 16) | h};
return {(h << 16) | w};
}
};

View File

@ -2,6 +2,7 @@
#define BOOT_LOADER_HPP
namespace GPU {
void display_logo();
void setup();
}

View File

@ -0,0 +1,14 @@
#ifndef __JABYENGINE_INTERNAL_GPU_HPP__
#define __JABYENGINE_INTERNAL_GPU_HPP__
#include <PSX/GPU/GPU_Types.hpp>
#include <PSX/System/IOPorts/GPU_IO.hpp>
namespace GPU {
static void quick_fill_fast(const Color& color, const PositionU16& pos, const SizeU16& size) {
Port::GP0.write(Port::Command::GP0::QuickFill(color));
Port::GP0.write(Port::Command::GP0::TopLeftPosition(pos.x, pos.y));
Port::GP0.write(Port::Command::GP0::WidthHeight(size.width, size.height));
}
}
#endif //!__JABYENGINE_INTERNAL_GPU_HPP__

View File

@ -1,14 +1,16 @@
#include <PSX/System/IOPorts/GPU_IO.hpp>
#include "../../include/GPU/GPU.h"
#include <PSX/GPU/GPU.h>
namespace GPU {
void display_logo() {
Display::disable();
quick_fill_fast(Color(0x0, 0x80, 0x80), PositionU16(0, 0), SizeU16(640, 480));
Display::enable();
}
void setup() {
//Port::GP1.write(Port::Command::GP1::Reset());
Port::GP1.write(Port::Command::GP1::Reset());
//Quickfill
Port::GP0.write(Port::Command::GP0::QuickFill(Color(0xFF, 0x0, 0x0)));
Port::GP0.write(Port::Command::GP0::TopLeftPosition(8, 8));
Port::GP0.write(Port::Command::GP0::WidthHeight(32, 32));
//Port::GP1.write(Port::Command::GP1::SetDisplayState(Port::DisplayState::On));
quick_fill_fast(Color(0x0, 0x0, 0x0), PositionU16(0, 0), SizeU16(640, 480));
}
}

View File

@ -4,14 +4,15 @@
namespace JabyEngine {
void start() {
printf("Hello Planschbecken\n");
//We key off the voices
SPU::stop_voices();
GPU::display_logo();
//Load picture here
//Pause??
//Do the real setup
GPU::setup();
//Do not setup GPU for now
//GPU::setup();
SPU::setup();
printf("Setup done!\n");
}