deferred prints!

This commit is contained in:
farisawan-2000 committed 2021-03-13 13:06:42 -05:00
1 parent 4eed305ebc
commit 24e3e0060c
3 files changed
+46 -4

No files matched your search

+1
View File
@@ -13,5 +13,6 @@ void s2d_stop(void) {
gSPLoadUcode(gdl_head++, zex_text, zex_data);
my_rdp_init();
my_rsp_init();
s2d_reset_defer_index();
}
+39
View File
@@ -0,0 +1,39 @@
#include "config.h"
#include "s2d_error.h"
#include "s2d_print.h"
#define S2D_BUFFERSIZE 100
struct s2d_pos {
int x;
int y;
};
static struct s2d_pos s2d_positions[S2D_BUFFERSIZE];
static char *s2d_charBuffer[S2D_BUFFERSIZE];
static int s2d_charBuffer_index = 0;
void s2d_reset_defer_index(void) {
s2d_charBuffer_index = 0;
}
// TODO: these DO NOT work
// pls debug :)
void s2d_print_deferred(int x, int y, const char *str) {
s2d_charBuffer[s2d_charBuffer_index] = str;
s2d_positions[s2d_charBuffer_index].x = x;
s2d_positions[s2d_charBuffer_index].y = y;
s2d_charBuffer_index++;
}
void s2d_handle_deferred(void) {
for (int i = 0; i < s2d_charBuffer_index; i++) {
s2d_print_alloc(
s2d_positions[i].x,
s2d_positions[i].y,
ALIGN_LEFT,
s2d_charBuffer[i]
);
}
}
+6 -4
View File
@@ -19,10 +19,12 @@ Gfx s2d_text_init_dl[] = {
// IA8
// TODO: add more formats
gsDPSetCombineLERP(0, 0, 0, ENVIRONMENT,
0, 0, 0, TEXEL0,
0, 0, 0, ENVIRONMENT,
0, 0, 0, TEXEL0),
gsDPSetCombineLERP(
0, 0, 0, ENVIRONMENT,
0, 0, 0, TEXEL0,
0, 0, 0, ENVIRONMENT,
0, 0, 0, TEXEL0
),
gsSPEndDisplayList(),
};