Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
KnockDownPlayer.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "sprite.h"
3
4#ifndef KNOCK_DOWN_MAP_VAR
5#warning KNOCK_DOWN_MAP_VAR must be defined!
6#endif
7
9 KnockdownData* data = (KnockdownData*) evt_get_variable(NULL, KNOCK_DOWN_MAP_VAR);
10 ImgFXTexture ifxImg;
11 SpriteRasterInfo rasterInfo;
12 Matrix4f sp40, sp80;
13
14 gDPPipeSync(gMainGfxPos++);
15 gDPSetCycleType(gMainGfxPos++, G_CYC_1CYCLE);
16 gSPClearGeometryMode(gMainGfxPos++,
17 G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD |
18 G_SHADING_SMOOTH);
19 gSPSetGeometryMode(gMainGfxPos++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH);
20 gSPTexture(gMainGfxPos++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON);
21 gDPSetTextureLOD(gMainGfxPos++, G_TL_TILE);
22 gDPSetTexturePersp(gMainGfxPos++, G_TP_PERSP);
23 gDPSetTextureFilter(gMainGfxPos++, G_TF_BILERP);
24 gDPSetColorDither(gMainGfxPos++, G_CD_DISABLE);
25 gDPSetTextureDetail(gMainGfxPos++, G_TD_CLAMP);
26 gDPSetTextureConvert(gMainGfxPos++, G_TC_FILT);
27 gDPSetCombineKey(gMainGfxPos++, G_CK_NONE);
28 gDPSetAlphaCompare(gMainGfxPos++, G_AC_NONE);
29
30 guTranslateF(sp40, data->pos.x, data->pos.y, data->pos.z);
31 guRotateF(sp80, data->rot.y, 0.0f, 1.0f, 0.0f);
32 guMtxCatF(sp80, sp40, sp40);
33 guRotateF(sp80, data->rot.z, 0.0f, 0.0f, 1.0f);
34 guMtxCatF(sp80, sp40, sp40);
35 guRotateF(sp80, data->rot.x, 1.0f, 0.0f, 0.0f);
36 guMtxCatF(sp80, sp40, sp40);
37 guScaleF(sp80, data->scale.x, data->scale.y, data->scale.z);
38 guMtxCatF(sp80, sp40, sp40);
40 gSPMatrix(gMainGfxPos++,
41 OS_K0_TO_PHYSICAL(&gDisplayContext->matrixStack[gMatrixListPos++]),
42 G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
43
44 spr_get_player_raster_info(&rasterInfo, data->spriteIndex, data->rasterIndex);
45 ifxImg.raster = rasterInfo.raster;
46 ifxImg.palette = rasterInfo.defaultPal;
47 data->width = ifxImg.width = rasterInfo.width;
48 data->height = ifxImg.height = rasterInfo.height;
49 ifxImg.xOffset = -(s32) (rasterInfo.width * 0.5f);
50 ifxImg.yOffset = rasterInfo.height;
51 ifxImg.alpha = 255;
52
53 imgfx_appendGfx_component(data->imgfxIdx, &ifxImg, 0, sp40);
54 gSPPopMatrix(gMainGfxPos++, G_MTX_MODELVIEW);
55}
56
57API_CALLABLE(N(KnockdownCreate)) {
58 Bytecode* args = script->ptrReadPos;
59 s32 spriteIndex = evt_get_variable(script, *args++);
60 s32 rasterIndex = evt_get_variable(script, *args++);
61 KnockdownData* data = heap_malloc(sizeof(*data));
62
63 data->spriteIndex = spriteIndex;
64 data->rasterIndex = rasterIndex;
67 data->pos.x = gPlayerStatus.pos.x;
68 data->pos.y = gPlayerStatus.pos.y;
69 data->pos.z = gPlayerStatus.pos.z;
70 data->rot.x = 0.0f;
71 data->rot.y = 0.0f;
72 data->rot.z = 0.0f;
78 evt_set_variable(script, KNOCK_DOWN_MAP_VAR, (s32) data);
79 return ApiStatus_DONE2;
80}
81
82API_CALLABLE(N(KnockdownDestroy)) {
83 KnockdownData* data = (KnockdownData*) evt_get_variable(NULL, KNOCK_DOWN_MAP_VAR);
84
86 free_worker(data->workerID);
87 heap_free(data);
88 evt_set_variable(script, KNOCK_DOWN_MAP_VAR, NULL);
89 return ApiStatus_DONE2;
90}
91
92API_CALLABLE(N(KnockdownSetPos)) {
93 Bytecode* args = script->ptrReadPos;
94 s32 x = evt_get_float_variable(script, *args++);
95 s32 y = evt_get_float_variable(script, *args++);
96 s32 z = evt_get_float_variable(script, *args++);
97 KnockdownData* data = (KnockdownData*) evt_get_variable(NULL, KNOCK_DOWN_MAP_VAR);
98
99 data->pos.x = x;
100 data->pos.y = y;
101 data->pos.z = z;
102 return ApiStatus_DONE2;
103}
104
105API_CALLABLE(N(KnockdownSetRot)) {
106 Bytecode* args = script->ptrReadPos;
107 s32 x = evt_get_float_variable(script, *args++);
108 s32 y = evt_get_float_variable(script, *args++);
109 s32 z = evt_get_float_variable(script, *args++);
110 KnockdownData* data = (KnockdownData*) evt_get_variable(NULL, KNOCK_DOWN_MAP_VAR);
111
112 data->rot.x = x;
113 data->rot.y = y;
114 data->rot.z = z;
115 return ApiStatus_DONE2;
116}
117
118API_CALLABLE(N(KnockdownSetScale)) {
119 Bytecode* args = script->ptrReadPos;
120 s32 x = evt_get_float_variable(script, *args++);
121 s32 y = evt_get_float_variable(script, *args++);
122 s32 z = evt_get_float_variable(script, *args++);
123 KnockdownData* data = (KnockdownData*) evt_get_variable(NULL, KNOCK_DOWN_MAP_VAR);
124
125 data->scale.x = x;
126 data->scale.y = y;
127 data->scale.z = z;
128 return ApiStatus_DONE2;
129}
130
131API_CALLABLE(N(KnockdownSetRaster)) {
132 Bytecode* args = script->ptrReadPos;
133 s32 spriteIndex = evt_get_variable(script, *args++);
134 s32 rasterIndex = evt_get_variable(script, *args++);
135 KnockdownData* data = (KnockdownData*) evt_get_variable(NULL, KNOCK_DOWN_MAP_VAR);
136
137 data->spriteIndex = spriteIndex;
138 data->rasterIndex = rasterIndex;
139 return ApiStatus_DONE2;
140}
void N gfx_build_knocked_down_player(void)
Mtx matrixStack[0x200]
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guTranslateF
#define guMtxCatF
#define guScaleF
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
s32 create_worker_world(WorldArgs, WorldArgs)
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1690
s32 imgfx_appendGfx_component(s32, ImgFXTexture *, u32, Matrix4f)
Definition imgfx.c:704
s32 imgfx_get_free_instances(s32)
Definition imgfx.c:338
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1847
s32 heap_free(void *ptr)
Definition heap.c:42
void free_worker(s32)
Definition worker.c:176
void imgfx_release_instance(u32)
Definition imgfx.c:386
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1930
void * heap_malloc(s32 size)
Definition heap.c:34
#define SPRITE_WORLD_SCALE_F
Definition macros.h:139
void spr_get_player_raster_info(SpriteRasterInfo *out, s32 playerSpriteID, s32 rasterIndex)
Definition sprite.c:999
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
PlayerStatus gPlayerStatus
Definition 77480.c:39
DisplayContext * gDisplayContext
Definition cam_main.c:16