add arbitrary scaling functionality

This commit is contained in:
farisawan-2000
2020-12-11 22:51:58 -05:00
parent 871eed30af
commit a7e593f333
6 changed files with 49 additions and 29 deletions

View File

@@ -1 +1,13 @@
// jk i dont think this file is needed lol
// jk i dont think this file is needed lol
// update: it was needed :(
// hopefully I'll only need s15.16
// ^ clueless
f32 qtof(int q) {
f32 lit = (float) ((q >> 16) & 0x7FFF);
if (q < 0) lit = -lit;
f32 dec = (float) ((float)(q & 0xFFFF) / (float)2^16);
return lit + dec;
}

1
mtx.c
View File

@@ -2,6 +2,7 @@
#include <PR/gs2dex.h>
#include "stack.h"
// TODO: implement fixed point math instead of... this...
void mat2_dst_mul(uObjMtx *dst, uObjMtx *m1, uObjMtx *m2) {
int m1A = m1->m.A >> 16;
int m1B = m1->m.B >> 16;

View File

@@ -20,6 +20,7 @@ static Gfx s2d_init_dl[] = {
void setup_font(int idx) {
gDPPipeSync(gDisplayListHead++);
gDPSetTextureFilter(gDisplayListHead++, G_TF_POINT);
gSPDisplayList(gDisplayListHead++, s2d_init_dl);
gDPSetCycleType(gDisplayListHead++, G_CYC_1CYCLE);
gDPSetRenderMode(gDisplayListHead++, G_RM_XLU_SPRITE, G_RM_XLU_SPRITE2);
@@ -37,9 +38,9 @@ void mtx_pipeline(uObjMtx *m, int x, int y) {
gSPObjMatrix(gDisplayListHead++, m);
}
void print_s2d(char c) {
void draw_s2d_glyph(char c, int x, int y, uObjMtx *mt) {
setup_font(c);
mtx_pipeline(&final_mtx, 50, 50);
mtx_pipeline(mt, x, y);
// gSPObjMatrix(gDisplayListHead++, &s2d_mat);
gSPObjSprite(gDisplayListHead++, &s2d_font);
}
}

View File

@@ -10,6 +10,6 @@ extern void setup_font(int idx);
extern void mtx_pipeline(uObjMtx *m, int x, int y);
extern void print_s2d(char c);
extern void draw_s2d_glyph(char c, int x, int y, uObjMtx *mt);
#endif

View File

@@ -2,39 +2,31 @@
#include <PR/gs2dex.h>
#include "s2d_draw.h"
#include "s2d_print.h"
#define SCALE '\x80'
#define ROT '\x81'
#define TRANSLATE '\x82'
#define CH_GET_NEXT(x) (*(++x))
void s2d_parse(const char *str) {
void s2d_print(int x, int y, const char *str, uObjMtx *buf) {
char *p = str;
while (*(p++) != '\0') {
do {
char r = *p;
char s, t, x, y;
char s, rd, tx, ty;
if (*p == '\0') break;
switch (r) {
case SCALE:
case CH_SCALE:
s = CH_GET_NEXT(p);
myScale = s;
break;
case ROT:
t = CH_GET_NEXT(p);
degrees = t;
case CH_ROT:
rd = CH_GET_NEXT(p);
degrees = rd;
break;
case TRANSLATE:
x = CH_GET_NEXT(p);
y = CH_GET_NEXT(p);
case CH_TRANSLATE:
tx = CH_GET_NEXT(p);
ty = CH_GET_NEXT(p);
default:
x = 0;
// print(r);
draw_s2d_glyph(r, x += (29 * myScale), y, (buf++));
}
}
} while (*(p++) != '\0');
myScale = 1;
}

14
s2d_print.h Normal file
View File

@@ -0,0 +1,14 @@
#include <ultra64.h>
#include <PR/gs2dex.h>
#define SCALE "\x80"
#define ROT "\x81"
#define TRANSLATE "\x82"
#define CH_SCALE '\x80'
#define CH_ROT '\x81'
#define CH_TRANSLATE '\x82'
#define CH_GET_NEXT(x) (*(++x))
extern void s2d_print(int x, int y, const char *str, uObjMtx *buf);