2023-06-17 16:51:03 -04:00
|
|
|
#include "s2d_config.h"
|
2021-05-31 01:32:58 -04:00
|
|
|
|
|
|
|
|
#include <ultra64.h>
|
|
|
|
|
#include "mtx.h"
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
|
2021-05-31 03:05:52 -04:00
|
|
|
#include "s2d_draw.h"
|
2021-05-31 01:32:58 -04:00
|
|
|
|
2021-05-31 02:37:39 -04:00
|
|
|
#define s(sprite) ((uObjSprite *)seg2virt(&sprite))
|
|
|
|
|
#define t(texture) ((uObjTxtr *)seg2virt(&texture))
|
|
|
|
|
|
|
|
|
|
void f3d_rdp_init(void) {
|
|
|
|
|
gDPPipeSync(gdl_head++);
|
|
|
|
|
gDPSetCycleType(gdl_head++, G_CYC_1CYCLE);
|
2021-05-31 03:00:18 -04:00
|
|
|
gDPSetRenderMode(gdl_head++, G_RM_XLU_SPRITE, G_RM_XLU_SPRITE2);
|
|
|
|
|
gDPSetTextureLUT(gdl_head++, G_TT_NONE);
|
|
|
|
|
gDPSetTexturePersp(gdl_head++, G_TP_NONE);
|
2021-05-31 02:37:39 -04:00
|
|
|
gDPSetCombineLERP(gdl_head++,
|
2021-05-31 01:32:58 -04:00
|
|
|
0, 0, 0, ENVIRONMENT,
|
|
|
|
|
0, 0, 0, TEXEL0,
|
|
|
|
|
0, 0, 0, ENVIRONMENT,
|
|
|
|
|
0, 0, 0, TEXEL0
|
2021-05-31 02:37:39 -04:00
|
|
|
);
|
2021-05-31 01:32:58 -04:00
|
|
|
}
|
|
|
|
|
|
2021-05-31 03:05:52 -04:00
|
|
|
void setup_f3d_texture(int idx) {
|
2021-05-31 01:32:58 -04:00
|
|
|
gDPPipeSync(gdl_head++);
|
|
|
|
|
|
|
|
|
|
|
2021-05-31 02:37:39 -04:00
|
|
|
gDPSetEnvColor(gdl_head++, s2d_red, s2d_green, s2d_blue, s2d_alpha);
|
|
|
|
|
|
|
|
|
|
gDPLoadTextureBlock(
|
|
|
|
|
gdl_head++,
|
|
|
|
|
t(s2d_tex[idx])->block.image,
|
|
|
|
|
s(s2d_font)->s.imageFmt,
|
|
|
|
|
G_IM_SIZ_8b,
|
|
|
|
|
s(s2d_font)->s.imageW >> 5,
|
|
|
|
|
s(s2d_font)->s.imageH >> 5,
|
|
|
|
|
s(s2d_font)->s.imagePal,
|
2021-05-31 03:00:18 -04:00
|
|
|
G_TX_WRAP,
|
|
|
|
|
G_TX_WRAP,
|
2021-05-31 02:37:39 -04:00
|
|
|
G_TX_NOMASK,
|
|
|
|
|
G_TX_NOMASK,
|
|
|
|
|
G_TX_NOLOD,
|
|
|
|
|
G_TX_NOLOD);
|
|
|
|
|
gDPLoadSync(gdl_head++);
|
2021-05-31 01:32:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define CLAMP_0(x) ((x < 0) ? 0 : x)
|
|
|
|
|
|
2021-05-31 03:00:18 -04:00
|
|
|
void texrect(int x, int y, float scale) {
|
|
|
|
|
#define qs510(n) ((s16)((n)*0x0400))
|
|
|
|
|
gSPScisTextureRectangle (
|
|
|
|
|
gdl_head++,
|
|
|
|
|
x << 2,
|
|
|
|
|
y << 2,
|
|
|
|
|
(u32)(x + ((f32) ((s(s2d_font)->s.imageW >> 5) - 1) * scale)) << 2,
|
|
|
|
|
(u32)(y + ((f32) ((s(s2d_font)->s.imageH >> 5) - 1) * scale)) << 2,
|
|
|
|
|
G_TX_RENDERTILE,
|
|
|
|
|
0,
|
|
|
|
|
0,
|
|
|
|
|
qs510(1.0f / myScale), qs510(1.0f / myScale));
|
2021-05-31 02:37:39 -04:00
|
|
|
}
|
|
|
|
|
|
2023-06-17 16:51:03 -04:00
|
|
|
void draw_f3d_dropshadow(char c, int x, int y, UNUSED uObjMtx *ds) {
|
2021-05-31 03:05:52 -04:00
|
|
|
setup_f3d_texture(c);
|
2021-05-31 01:32:58 -04:00
|
|
|
|
|
|
|
|
if (s2d_red != 0
|
|
|
|
|
&& s2d_green != 0
|
|
|
|
|
&& s2d_blue != 0
|
2021-05-31 02:37:39 -04:00
|
|
|
) {
|
2021-05-31 01:32:58 -04:00
|
|
|
gDPPipeSync(gdl_head++);
|
|
|
|
|
gDPSetEnvColor(gdl_head++,
|
|
|
|
|
CLAMP_0(s2d_red - 100),
|
|
|
|
|
CLAMP_0(s2d_green - 100),
|
|
|
|
|
CLAMP_0(s2d_blue - 100),
|
|
|
|
|
s2d_alpha);
|
2021-05-31 03:00:18 -04:00
|
|
|
texrect(x, y, myScale);
|
2021-05-31 02:37:39 -04:00
|
|
|
gDPPipeSync(gdl_head++);
|
2021-05-31 01:32:58 -04:00
|
|
|
gDPSetEnvColor(gdl_head++, s2d_red, s2d_green, s2d_blue, s2d_alpha);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-17 16:51:03 -04:00
|
|
|
void draw_f3d_glyph(char c, int x, int y, UNUSED uObjMtx *mt) {
|
2021-05-31 03:05:52 -04:00
|
|
|
setup_f3d_texture(c);
|
2021-05-31 01:32:58 -04:00
|
|
|
|
2021-05-31 03:00:18 -04:00
|
|
|
texrect(x, y, myScale);
|
2021-05-31 02:37:39 -04:00
|
|
|
gDPPipeSync(gdl_head++);
|
2021-05-31 01:32:58 -04:00
|
|
|
}
|
|
|
|
|
|
2021-05-31 02:37:39 -04:00
|
|
|
#undef s
|
|
|
|
|
#undef t
|