This sample program draws dot, line and rectangle.
#include <psx.h> #include <stdio.h> unsigned int prim_list[0x4000]; unsigned short padbuf; volatile int display_is_old = 1; volatile int time_counter = 0; int dbuf=0, hx=0, hy=0; void prog_vblank_handler() { display_is_old = 1; time_counter++; } int main() { PSX_Init(); GsInit(); GsSetList(prim_list); GsClearMem(); GsSetVideoMode(320, 240, EXAMPLES_VMODE); SetVBlankHandler(prog_vblank_handler); while(1) { if(display_is_old) { dbuf=!dbuf; GsSetDispEnvSimple(0, dbuf ? 0 : 256); GsSetDrawEnvSimple(0, dbuf ? 256 : 0, 320, 240); GsSortCls(0,0,0); // paint start // draw dot GsDot dot; dot.r = 255; dot.g = 255; dot.b = 255; dot.x = 10; dot.y = 10; dot.attribute = 0; GsSortDot(&dot); // draw line GsLine line; line.r = 255; line.g = 255; line.b = 255; line.x[0] = 10; line.y[0] = 15; line.x[1] = 200; line.y[1] = 35; line.attribute = 0; GsSortLine(&line); // draw rectangle GsRectangle rectangle; rectangle.r = 255; rectangle.g = 255; rectangle.b = 255; rectangle.x = 10; rectangle.y = 60; rectangle.w = 50; rectangle.h = 50; rectangle.attribute = 0; GsSortRectangle(&rectangle); // paint end GsDrawList(); while(GsIsDrawing()); display_is_old=0; } } return 0; }