Files
pikuma_ps1/code/graphics_hello_psyq/hello_gpu.c
T
ed e04bcb91b4 got gp_screen_init working on the assembler side!
Will not be doing most of the course in assembly for now.
Assemblers are missing a bunch of ergonomics not related to to instruction abstraction. Mostly related to offset and data typw width calulations and how to ergonomically utilize those symbols within the assembly syntax. The GNU gas macros are terrible and struct member resolution must be done manually.
There is no utilities for doing stack allocations with alignment in mind either, no way to get info on the system's calling convention for foreign symbols (not even as a diagnostic, etc).

C is a terrible for inline assembly, and gas doesn't support grabbing C struct info from header files (even though they are part of the same toolchain collection).
There is no utilities for doing stack allocations with alignment in mind either, no way to get info on the system's calling convention for foreign symbols (not even as a diagnostic, etc).

Low-level dev really is in a catch 22 of bad tooling.
2025-09-13 21:49:10 -04:00

70 lines
1.9 KiB
C

// #include <stdlib.h>
#include "duffle/dsl.h"
#include "duffle/math.h"
#include "duffle/gp.h"
#include "hello_gpu.h"
#include "libgpu.h"
#include "libetc.h"
DoubleBuffer screen_buffer;
S16 active_screen_buffer;
void gp_screen_init_c11(void)
{
ResetGraph(0);
SetDispMask(1); // gp_DisplayEnabled
// Just setting env data, not interacting with console hw.
// First buffer area
SetDefDispEnv((DISPENV*)& screen_buffer.display[0], 0, 0, ScreenRes_X, ScreenRes_Y);
SetDefDrawEnv((DRAWENV*)& screen_buffer.draw [0], 0, ScreenRes_Y, ScreenRes_X, ScreenRes_Y);
// Second buffer area
SetDefDispEnv((DISPENV*)& screen_buffer.display[1], 0, ScreenRes_Y, ScreenRes_X, ScreenRes_Y);
SetDefDrawEnv((DRAWENV*)& screen_buffer.draw [1], 0, 0, ScreenRes_X, ScreenRes_Y);
// Set the back/drawing buffer
screen_buffer.draw[0].enable_auto_clear = true;
screen_buffer.draw[1].enable_auto_clear = true;
// Set the background clear color
screen_buffer.draw[0].initial_bg_color = (RGB8){ .r = 63, .g = 0, .b = 127 };
screen_buffer.draw[1].initial_bg_color = (RGB8){ .r = 127, .g = 63, .b = 0 };
// Set the current initial buffer
active_screen_buffer = 0;
PutDispEnv((DISPENV*)& screen_buffer.display[active_screen_buffer]);
DRAWENV* wtf = (DRAWENV*)& screen_buffer.draw [active_screen_buffer];
PutDrawEnv(wtf);
// Initialize and setup the GTE geometry offsets
InitGeom();
SetGeomOffset(ScreenRes_CenterX, ScreenRes_CenterY);
SetGeomScreen(ScreenRes_CenterX);
}
void gp_display_frame(void) {
DrawSync(0);
VSync(0);
PutDispEnv((DISPENV*)& screen_buffer.display[active_screen_buffer]);
PutDrawEnv((DRAWENV*)& screen_buffer.draw [active_screen_buffer]);
{
// TODO: Sort objects in ordering table
}
active_screen_buffer = !active_screen_buffer; // Swap current buffer
}
void render(void) {
}
int main(void)
{
gp_screen_init();
while (1)
{
render();
gp_display_frame();
};
return 0;
}