Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
demo_api.c
Go to the documentation of this file.
1#include "common.h"
2#include "ld_addrs.h"
3
5
8 /* 0x00 */ s8 flags;
9 /* 0x01 */ Color_RGB8 rgb;
10 /* 0x04 */ Vec3s pos;
11 /* 0x0A */ f32 falloff;
12 /* 0x0E */ s8 unk_14;
13 /* 0x0F */ char pad_0F[0x1];
17typedef struct PackedShadingProfile {
18 /* 0x00 */ u8 count;
19 /* 0x01 */ char pad_01[0x1];
20 /* 0x02 */ Color_RGB8 ambientColor;
21 /* 0x05 */ u8 ambientPower;
22 /* 0x06 */ PackedShadingLightSource sources[7];
23 /* 0x76 */ char pad_86[0xA];
24} __attribute__((packed)) PackedShadingProfile; // size = 0x100
25
28
29API_CALLABLE(SetSpriteShading) {
30 Bytecode* args = script->ptrReadPos;
31 s32 profileID = evt_get_variable(script, *args++);
32 s32 shadingGroupOffset = (profileID >> 0x10) * 8;
33 s32 shadingProfileOffset = (profileID & 0xFFFF) * 4;
35 s32 romBase;
36 s32 groupProfiles;
37 s32 groupStart;
38 s32 profileStart;
39 s32 dataOffset;
40 s32 i;
41
42 if (profileID == SHADING_NONE) {
43 return ApiStatus_DONE2;
44 }
45
46 // load shading group data
49
50 // load offset to shading data
55
56 // load shading profile
60
62 profile->ambientColor.r = PackedShadingData.ambientColor.r;
63 profile->ambientColor.g = PackedShadingData.ambientColor.g;
64 profile->ambientColor.b = PackedShadingData.ambientColor.b;
65 profile->ambientPower = PackedShadingData.ambientPower;
66
67 for (i = 0; i < PackedShadingData.count; i++) {
69 source->flags = PackedShadingData.sources[i].flags;
70 source->rgb.r = PackedShadingData.sources[i].rgb.r;
71 source->rgb.g = PackedShadingData.sources[i].rgb.g;
72 source->rgb.b = PackedShadingData.sources[i].rgb.b;
73 source->pos.x = PackedShadingData.sources[i].pos.x;
74 source->pos.y = PackedShadingData.sources[i].pos.y;
75 source->pos.z = PackedShadingData.sources[i].pos.z;
76 source->falloff = PackedShadingData.sources[i].falloff;
77 source->unk_14 = PackedShadingData.sources[i].unk_14;
78 }
80
81 return ApiStatus_DONE2;
82}
83
84API_CALLABLE(EnableSpriteShading) {
85 Bytecode* args = script->ptrReadPos;
86 s32 enabled = evt_get_variable(script, *args++);
87
88 if (enabled) {
90 } else {
92 }
93 return ApiStatus_DONE2;
94}
95
96API_CALLABLE(GetDemoState) {
98 return ApiStatus_DONE2;
99}
100
101API_CALLABLE(DemoPressButton) {
103 return ApiStatus_DONE2;
104}
105
106API_CALLABLE(DemoReleaseButton) {
108 return ApiStatus_DONE2;
109}
110
111API_CALLABLE(DemoSetButtons) {
113 return ApiStatus_DONE2;
114}
115
116API_CALLABLE(DemoJoystickRadial) {
117 Bytecode* args = script->ptrReadPos;
118 f32 mag = evt_get_float_variable(script, *args++);
120
123
124 return ApiStatus_DONE2;
125}
126
127API_CALLABLE(DemoJoystickXY) {
128 Bytecode* args = script->ptrReadPos;
129 f32 x = evt_get_float_variable(script, *args++);
130 f32 y = evt_get_float_variable(script, *args++);
131
134
135 return ApiStatus_DONE2;
136}
BSS s32 PopupMenu_SelectedIndex
SpriteShadingLightSource sources[7]
Addr sprite_shading_profiles_data_ROM_START
struct PackedShadingLightSource __attribute__((packed))
Packed equivalent of SpriteShadingLightSource as baked into the ROM, smaller due to packed position v...
Definition demo_api.c:14
Packed equivalent of SpriteShadingLightSource as baked into the ROM, smaller due to packed position v...
Definition demo_api.c:7
#define sin_deg
#define cos_deg
@ SPR_SHADING_FLAG_ENABLED
Definition enums.h:5206
#define ApiStatus_DONE2
Definition evt.h:118
s32 Bytecode
Definition evt.h:7
s32 evt_get_variable(Evt *script, Bytecode var)
Definition evt.c:1689
u32 dma_copy(Addr romStart, Addr romEnd, void *vramDest)
Definition 43F0.c:443
s32 evt_set_variable(Evt *script, Bytecode var, s32 value)
Definition evt.c:1846
f32 evt_get_float_variable(Evt *script, Bytecode var)
Definition evt.c:1929
ApiStatus SetSpriteShading(Evt *script, b32 isInitialCall)
ApiStatus GetDemoState(Evt *script, b32 isInitialCall)
ApiStatus DemoJoystickXY(Evt *script, b32 isInitialCall)
ApiStatus EnableSpriteShading(Evt *script, b32 isInitialCall)
ApiStatus DemoReleaseButton(Evt *script, b32 isInitialCall)
ApiStatus DemoJoystickRadial(Evt *script, b32 isInitialCall)
ApiStatus DemoPressButton(Evt *script, b32 isInitialCall)
ApiStatus DemoSetButtons(Evt *script, b32 isInitialCall)
u8 Addr[]
Linker symbol address, as in ld_addrs.h.
Definition types.h:16
GameStatus gGameStatus
Definition main_loop.c:21
GameStatus * gGameStatusPtr
Definition main_loop.c:32
SpriteShadingProfile * gSpriteShadingProfile