added emulator check

This commit is contained in:
farisawan-2000
2021-05-31 03:05:52 -04:00
parent fcd621ef71
commit 78e6ee8b4e
5 changed files with 21 additions and 41 deletions

View File

@@ -13,8 +13,6 @@
* Helpful defines to change
***********/
#define DRAW_F3D
#define BASE_SCALE 1.0f
/******************************
@@ -87,10 +85,8 @@ extern char *proutSprintf(char *dst, const char *src, size_t count);
#define TEX_HEIGHT 16
#define TEX_BITDEPTH 8
#define glyph_draw draw_f3d_glyph
#define glyph_shadow draw_f3d_dropshadow
#define seg2virt segmented_to_virtual
#define IS_RUNNING_ON_EMULATOR (IO_READ(DPC_PIPEBUSY_REG) == 0)
// Texture resolution (pixels on the texture per pixel on the framebuffer)
#define TEX_RES 1

View File

@@ -1,17 +1,10 @@
#include "config.h"
#ifdef DRAW_F3D
#include <ultra64.h>
#include "mtx.h"
#include "debug.h"
float myScale = 1.0f;
int myDegrees = 0;
uObjMtx final_mtx, rot_mtx;
int s2d_red = 255, s2d_green = 255, s2d_blue = 255, s2d_alpha = 255;
int drop_shadow = FALSE;
int drop_x = 0;
int drop_y = 0;
#include "s2d_draw.h"
#define s(sprite) ((uObjSprite *)seg2virt(&sprite))
#define t(texture) ((uObjTxtr *)seg2virt(&texture))
@@ -30,7 +23,7 @@ void f3d_rdp_init(void) {
);
}
void setup_font_texture(int idx) {
void setup_f3d_texture(int idx) {
gDPPipeSync(gdl_head++);
@@ -70,7 +63,7 @@ void texrect(int x, int y, float scale) {
}
void draw_f3d_dropshadow(char c, int x, int y, uObjMtx *ds) {
setup_font_texture(c);
setup_f3d_texture(c);
if (s2d_red != 0
&& s2d_green != 0
@@ -89,7 +82,7 @@ void draw_f3d_dropshadow(char c, int x, int y, uObjMtx *ds) {
}
void draw_f3d_glyph(char c, int x, int y, uObjMtx *mt) {
setup_font_texture(c);
setup_f3d_texture(c);
texrect(x, y, myScale);
gDPPipeSync(gdl_head++);
@@ -97,5 +90,3 @@ void draw_f3d_glyph(char c, int x, int y, uObjMtx *mt) {
#undef s
#undef t
#endif

7
init.c
View File

@@ -7,19 +7,18 @@
void s2d_init(void) {
s2d_error_y = TEX_HEIGHT;
#ifdef DRAW_S2D
if (IS_RUNNING_ON_EMULATOR)
gSPLoadUcode(gdl_head++, s2d_text, s2d_data);
#endif
}
void s2d_stop(void) {
#ifdef DRAW_S2D
if (IS_RUNNING_ON_EMULATOR) {
gSPLoadUcode(gdl_head++, zex_text, zex_data);
if deinit_cond {
my_rdp_init();
my_rsp_init();
}
#endif
}
s2d_reset_defer_index();
}

View File

@@ -1,5 +1,4 @@
#include "config.h"
#ifdef DRAW_S2D
#include <ultra64.h>
#include "mtx.h"
#include "debug.h"
@@ -21,8 +20,6 @@ Gfx s2d_text_init_dl[] = {
gsDPSetAlphaCompare(G_AC_THRESHOLD),
gsDPSetBlendColor(0, 0, 0, 0x01),
// IA8
// TODO: add more formats
gsDPSetCombineLERP(
0, 0, 0, ENVIRONMENT,
0, 0, 0, TEXEL0,
@@ -44,17 +41,15 @@ void s2d_rdp_init(void) {
}
}
void setup_font_texture(int idx) {
void setup_s2d_texture(int idx) {
gDPPipeSync(gdl_head++);
gDPSetEnvColor(gdl_head++, s2d_red, s2d_green, s2d_blue, s2d_alpha);
gSPObjLoadTxtr(gdl_head++, &s2d_tex[idx]);
}
// Original Mtx Pipeline
// Distorts when rotating, but is faster
void mtx_pipeline(uObjMtx *m, int x, int y) {
// init
gDPPipeSync(gdl_head++);
mat2_ident(m, 1.0f / myScale);
mat2_translate(m, x, y);
@@ -63,9 +58,9 @@ void mtx_pipeline(uObjMtx *m, int x, int y) {
#define CLAMP_0(x) ((x < 0) ? 0 : x)
void draw_s2d_shadow(char c, int x, int y, uObjMtx *ds) {
void draw_s2d_dropshadow(char c, int x, int y, uObjMtx *ds) {
if (mtx_cond) mtx_pipeline(ds, x, y);
if (tex_cond) setup_font_texture(c);
if (tex_cond) setup_s2d_texture(c);
if (s2d_red != 0
&& s2d_green != 0
@@ -84,10 +79,8 @@ void draw_s2d_shadow(char c, int x, int y, uObjMtx *ds) {
void draw_s2d_glyph(char c, int x, int y, uObjMtx *mt) {
if (mtx_cond) mtx_pipeline(mt, x, y);
if (tex_cond) setup_font_texture(c);
// mtx_pipeline2(mt, x, y);
if (tex_cond) setup_s2d_texture(c);
if (spr_cond) gSPObjRectangleR(gdl_head++, &s2d_font);
}
#endif

View File

@@ -27,11 +27,10 @@ static int s2d_snprint(int x, int y, int align, const char *str, uObjMtx *buf, i
if (*p == '\0') return;
#ifdef DRAW_S2D
if (IS_RUNNING_ON_EMULATOR)
s2d_rdp_init();
#else
else
f3d_rdp_init();
#endif
// resets parameters
s2d_red = s2d_green = s2d_blue = 255;
@@ -166,10 +165,12 @@ static int s2d_snprint(int x, int y, int align, const char *str, uObjMtx *buf, i
if (current_char != '\0' && current_char != CH_SEPARATOR) {
char *tbl = segmented_to_virtual(s2d_kerning_table);
if (drop_shadow && mode == MODE_DRAW_DROPSHADOW) {
glyph_shadow(current_char, x + drop_x, y + drop_y, (buf++));
} else if (mode == MODE_DRAW_NORMALTEXT) {
glyph_draw(current_char, x, y, (buf++));
if (IS_RUNNING_ON_EMULATOR) {
if (drop_shadow && mode == MODE_DRAW_DROPSHADOW) {
draw_s2d_dropshadow(current_char, x + drop_x, y + drop_y, (buf++));
} else if (mode == MODE_DRAW_NORMALTEXT) {
draw_s2d_glyph(current_char, x, y, (buf++));
}
}
(x += (tbl[(int) current_char] * (BASE_SCALE * myScale)));
}