cleanup; refactoring

This commit is contained in:
farisawan-2000
2020-12-16 18:06:46 -05:00
parent 6a5e971bd2
commit 6477265539
4 changed files with 14 additions and 26 deletions

View File

@@ -25,6 +25,7 @@ extern Gfx *gdl_head;
// The frame timer that is used to time s2d_type_print
#define s2d_timer gGlobalTimer
extern u32 s2d_timer;
// The equivalent vsprintf in your game (defaults to libultra _Printf)
#define vsprintf(dst, str, fmt, args) _Printf(proutSprintf, dst, fmt, args)

View File

@@ -7,7 +7,7 @@ int myDegrees = 0;
uObjMtx final_mtx, rot_mtx;
int s2d_red = 255, s2d_green = 255, s2d_blue = 255, s2d_alpha = 255;
static Gfx s2d_init_dl[] = {
Gfx s2d_text_init_dl[] = {
gsDPPipeSync(),
gsDPSetTexturePersp(G_TP_NONE),
gsDPSetTextureLOD(G_TL_TILE),
@@ -28,7 +28,7 @@ static Gfx s2d_init_dl[] = {
void setup_font(int idx) {
gDPPipeSync(gdl_head++);
gDPSetTextureFilter(gdl_head++, G_TF_POINT);
gSPDisplayList(gdl_head++, s2d_init_dl);
gSPDisplayList(gdl_head++, s2d_text_init_dl);
gDPSetEnvColor(gdl_head++, s2d_red, s2d_green, s2d_blue, s2d_alpha);
gDPSetCycleType(gdl_head++, G_CYC_1CYCLE);
gDPSetRenderMode(gdl_head++, G_RM_XLU_SPRITE, G_RM_XLU_SPRITE2);
@@ -55,7 +55,7 @@ void mtx_pipeline(uObjMtx *m, int x, int y) {
// New matrix pipeline
// Works with both rotation and scale,
// but is slow due to more float operations being performed
// but is (probably not noticeably) slower
void mtx_pipeline2(uObjMtx *m, int x, int y) {
// init
Mat4 tmp, rot, scal, translate;

View File

@@ -9,12 +9,6 @@
#include "s2d_print.h"
#include "s2d_ustdlib.h"
int saved_degrees = 0;
int s2d_colorFrames = 0;
extern u32 gGlobalTimer;
void s2d_snprint(int x, int y, const char *str, uObjMtx *buf, int len) {
char *p = str;
int tx = 0, ty = 0;
@@ -22,25 +16,22 @@ void s2d_snprint(int x, int y, const char *str, uObjMtx *buf, int len) {
int orig_x = x;
int orig_y = y;
if (*p == '\0') return;
// resets colors
s2d_red = s2d_green = s2d_blue = 255;
s2d_alpha = 255;
if (*p == '\0') return;
do {
char r = *p;
int s, rd;
char current_char = *p;
switch (r) {
switch (current_char) {
case CH_SCALE:
CH_SKIP(p);
s = s2d_atoi(p, &p);
myScale = s;
myScale = s2d_atoi(p, &p);
break;
case CH_ROT:
CH_SKIP(p);
rd = s2d_atoi(p, &p);
saved_degrees = rd;
myDegrees = rd;
myDegrees = s2d_atoi(p, &p);
break;
case CH_TRANSLATE:
CH_SKIP(p);
@@ -50,7 +41,6 @@ void s2d_snprint(int x, int y, const char *str, uObjMtx *buf, int len) {
y = s2d_atoi(p, &p);
break;
case CH_COLOR:
s2d_colorFrames++;
CH_SKIP(p);
s2d_red = s2d_atoi(p, &p);
CH_SKIP(p); CH_SKIP(p);
@@ -75,11 +65,11 @@ void s2d_snprint(int x, int y, const char *str, uObjMtx *buf, int len) {
y += TEX_HEIGHT;
break;
default:
if (r != '\0') {
if (current_char != '\0') {
if (myDegrees == 0)
draw_s2d_glyph(r, (x += (8 * myScale)) + tx, y + ty, (buf++));
draw_s2d_glyph(current_char, (x += (8 * myScale)) + tx, y + ty, (buf++));
else
draw_s2d_glyph(r, (x += ((8 * myScale))) + tx, y + ty, (buf++));
draw_s2d_glyph(current_char, (x += ((8 * myScale))) + tx, y + ty, (buf++));
}
}
if (*p == '\0') break;

View File

@@ -1,6 +1,3 @@
// ustdlib means un-standard library
// i'm going to abuse so much of my power here lol
extern int s2d_atoi(char *s, char **s2);
extern int s2d_ilen(char *s);