47 lines
877 B
C
47 lines
877 B
C
#include <gfx.h>
|
|
#include <psxgpu.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
static union gfx_sznext *first, *last;
|
|
|
|
static void add_to_list(union gfx_sznext *const p)
|
|
{
|
|
p->next = 0;
|
|
|
|
if (!first)
|
|
first = p;
|
|
else if (last)
|
|
last->next = (uint32_t)p;
|
|
|
|
last = p;
|
|
}
|
|
|
|
void gfx_sprite_sort(struct gfx_sprite *const s)
|
|
{
|
|
add_to_list(&s->sznext);
|
|
}
|
|
|
|
void gfx_draw(void)
|
|
{
|
|
/* Wait for the GPU to finish drawing primitives. */
|
|
while (!(GPU_CONTROL_PORT & (1 << 0x1a)))
|
|
;
|
|
|
|
/* Wait for the GPU to be free. */
|
|
while (!(GPU_CONTROL_PORT & (1 << 0x1c)))
|
|
;
|
|
|
|
static uint32_t term = 0xffffff;
|
|
|
|
add_to_list((union gfx_sznext *)&term);
|
|
|
|
void gpu_ctrl(unsigned int command, unsigned int param);
|
|
|
|
gpu_ctrl(4, 2);
|
|
D2_MADR = (uint32_t)first;
|
|
D2_BCR = 0;
|
|
D2_CHCR = (1 << 0xa) | 1 | (1 << 0x18);
|
|
first = NULL;
|
|
}
|