start infrastructure for new text features: scrolling, typing, backgrounds

This commit is contained in:
farisawan-2000
2020-12-12 21:56:36 -05:00
parent 738c0a220e
commit ce1f5b38e7
4 changed files with 34 additions and 23 deletions

View File

@@ -1682,4 +1682,16 @@ uObjSprite impact_obj = {
0, /* imagePal */
0, /* imageFlags */
};
uObjSprite impact_bg = {
0<<2, 1<<10, 1<<5, 0, /* objX, scaleX, imageW, unused */
0<<2, 1<<10, 1<<5, 0, /* objY, scaleY, imageH, unused */
GS_PIX2TMEM(1, G_IM_SIZ_8b), /* imageStride */
GS_PIX2TMEM(0, G_IM_SIZ_8b), /* imageAdrs */
G_IM_FMT_IA, /* imageFmt */
G_IM_SIZ_8b, /* imageSiz */
0, /* imagePal */
0, /* imageFlags */
};
// 16 16

4
mtx.h
View File

@@ -1,6 +1,8 @@
#include <ultra64.h>
#include <PR/gs2dex.h>
#include <PR/gu.h>
#include "stack.h"
typedef float Mat4[4][4];
extern void mat2_dst_mul(uObjMtx *dst, uObjMtx *m1, uObjMtx *m2);
@@ -19,3 +21,5 @@ extern void get_final_mat(uObjMtx *dst);
extern void mat2_translate(uObjMtx *m, int x, int y);
extern void mat2_rotate(uObjMtx *dst, f32 degrees);
extern void mat2_translate_vec(uObjMtx *m, f32 degrees, f32 mag);

View File

@@ -5,9 +5,7 @@
int myScale = 1;
int myDegrees = 0;
uObjMtx final_mtx, rot_mtx;
#define TEX_X -8
#define TEX_Y -8
int s2d_red = 255, s2d_green = 255, s2d_blue = 255, s2d_alpha = 255;
static Gfx s2d_init_dl[] = {
gsDPPipeSync(),
@@ -24,12 +22,9 @@ static Gfx s2d_init_dl[] = {
0, 0, 0, ENVIRONMENT,
0, 0, 0, TEXEL0),
gsSPEndDisplayList(),
};
int s2d_red = 255, s2d_green = 255, s2d_blue = 255, s2d_alpha = 255;
void setup_font(int idx) {
gDPPipeSync(gdl_head++);
gDPSetTextureFilter(gdl_head++, G_TF_POINT);
@@ -41,10 +36,18 @@ void setup_font(int idx) {
gSPObjLoadTxtr(gdl_head++, &s2d_tex[idx]);
}
extern void mat2_translate_vec(uObjMtx *m, f32 degrees, f32 mag);
void draw_rect(int ulx, int uly, int drx, int dry, u32 color) {
gDPPipeSync(gdl_head++);
gDPSetRenderMode(gdl_head++, G_RM_NOOP, G_RM_NOOP2);
gDPSetCycleType(gdl_head++,G_CYC_FILL);
gDPSetFillColor(gdl_head++, color);
gDPFillRectangle(gdl_head++, ulx, uly, drx, dry);
gDPPipeSync(gdl_head++);
gDPSetCycleType(gdl_head++, G_CYC_1CYCLE);
}
// Original Mtx Pipeline
// Doesnt work with rotation, but is faster
// Distorts when rotating, but is faster
void mtx_pipeline(uObjMtx *m, int x, int y) {
// init
mat2_ident(m, 1);
@@ -52,21 +55,14 @@ void mtx_pipeline(uObjMtx *m, int x, int y) {
// create rot matrix
mat2_rotate(&rot_mtx, (myDegrees) * (M_PI / 180.0f));
// scale m
mat2_scale(m, myScale);
// mat2_copy(m, &rot_mtx);
mat2_dst_mul(m,m, &rot_mtx);
mat2_translate(m, x, y);
// yeah
gSPObjMatrix(gdl_head++, m);
}
#include <PR/gu.h>
typedef float Mat4[4][4];
// New matrix pipeline
// Works with both rotation and scale,
// but is slow due to more float operations being performed
@@ -88,7 +84,6 @@ void mtx_pipeline2(uObjMtx *m, int x, int y) {
mat2_translate_vec(m, -(myDegrees) * M_DTOR, myScale);
}
// yeah
gSPObjMatrix(gdl_head++, m);
}
@@ -96,7 +91,7 @@ void draw_s2d_glyph(char c, int x, int y, uObjMtx *mt) {
setup_font(c);
// mtx_pipeline(mt, x, y);
mtx_pipeline(mt, x, y);
mtx_pipeline2(mt, x, y);
gSPObjSprite(gdl_head++, &s2d_font);
}

View File

@@ -56,14 +56,14 @@ void s2d_print(int x, int y, const char *str, uObjMtx *buf) {
case CH_COLOR:
CH_GET_NEXT(p);
s2d_red = s2d_atoi(p, &p);
CH_GET_NEXT(p);
CH_GET_NEXT(p);
CH_GET_NEXT(p); CH_GET_NEXT(p);
s2d_green = s2d_atoi(p, &p);
CH_GET_NEXT(p);
CH_GET_NEXT(p);
CH_GET_NEXT(p); CH_GET_NEXT(p);
s2d_blue = s2d_atoi(p, &p);
CH_GET_NEXT(p);
CH_GET_NEXT(p);
CH_GET_NEXT(p); CH_GET_NEXT(p);
s2d_alpha = s2d_atoi(p, &p);
break;