hello_ps2/main.c

55 lines
1.4 KiB
C

#include "draw_primitives.h"
#include "graph_vram.h"
#include "gs_psm.h"
#include <tamtypes.h>
#include <sifrpc.h>
#include <debug.h>
#include <unistd.h>
#include <dma.h>
#include <graph.h>
#include <draw.h>
#ifdef DEBUG
#define DEBUG_MSG(...) scr_printf(__VA_ARGS__)
#else
#define DEBUG_MSG(...)
#endif
#define OFFSET_X 0
#define OFFSET_Y 0
int gs_init(int width, int height, int psm, int psmz, int vmode, int gmode) {
int fb_address = graph_vram_allocate(width, height, psm, GRAPH_ALIGN_PAGE);
graph_set_mode(gmode, vmode, GRAPH_MODE_FIELD, GRAPH_DISABLE);
graph_set_screen(OFFSET_X, OFFSET_Y, width, height);
graph_set_bgcolor(0, 0, 0);
graph_set_framebuffer_filtered(fb_address, width, psm, 0, 0);
graph_enable_output();
qword_t buff[20];
qword_t *q = buff;
q = draw_primitive_xyoffset(q, 0, 0, 0);
q = draw_finish(q);
dma_channel_send_normal(DMA_CHANNEL_GIF, buff, q-buff, 0, 0);
dma_wait_fast();
return 0;
}
int main() {
#ifdef DEBUG
sceSifInitRpc(0);
init_scr();
#endif
DEBUG_MSG("PS2 Initialized\n");
// initialize DMAC
dma_channel_initialize(DMA_CHANNEL_GIF, 0, 0);
dma_channel_fast_waits(DMA_CHANNEL_GIF);
DEBUG_MSG("DMA Initialized...");
// initialize graphics mode
gs_init(664, 480, GS_PSM_32, GS_PSMZ_32, GRAPH_MODE_NTSC, GRAPH_MODE_FIELD);
DEBUG_MSG("GS Initialized...");
// clear screen
// build buffer with triangle data
sleep(5);
}