Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
UpdateEnchantedBowserColors.inc.c
Go to the documentation of this file.
1#include "common.h"
2#include "sprite.h"
3
4#ifndef BOWSER_LARGE
5#define BOWSER_FLAG_TOCHECK ACTOR_EVENT_FLAG_ENCHANTED
6#else
7#define BOWSER_FLAG_TOCHECK ACTOR_EVENT_FLAG_STAR_ROD_ENCHANTED
8#endif
9
10API_CALLABLE(N(UpdateEnchantedBowserColors)) {
11 #define RGBA_BUF_SIZE 20
12 Actor* actor = get_actor(script->owner1.actorID);
13 ActorPart* part;
14 s32 i, j;
15 u8 colR[RGBA_BUF_SIZE];
16 u8 colG[RGBA_BUF_SIZE];
17 u8 colB[RGBA_BUF_SIZE];
18 s32 colorRGBA;
19 s32 temp;
20 s32 lol;
21
22 if (actor == NULL) {
23 return ApiStatus_DONE2;
24 }
25
26 part = get_actor_part(actor, 1);
27
28 if (isInitialCall) {
29 script->functionTemp[1] = 0;
30 script->functionTemp[2] = 0;
31 script->functionTemp[0] = 0;
32
33 for (i = 0; i < 10; i++) {
35 }
36 }
37
38 script->functionTemp[1] += 10;
39 if (script->functionTemp[1] >= 360) {
40 script->functionTemp[1] %= 360;
41 }
42
43 for (j = 0; j < RGBA_BUF_SIZE; j++) {
44 colR[j] = (cosine(script->functionTemp[1] + j * 25 + 120) + 1.0) * 56.0;
45 colG[j] = (cosine(script->functionTemp[1] + j * 25 + 60) + 1.0) * 56.0;
46 colB[j] = (cosine(script->functionTemp[1] + j * 25 + 180) + 1.0) * 56.0;
47 }
48
49 if (part->eventFlags & BOWSER_FLAG_TOCHECK) {
50
51 for (j = 0; j < RGBA_BUF_SIZE; j++) {
52 colorRGBA = colR[j] << 0x18 | colG[j] << 0x10 | colB[j] << 8 | 0xFF;
53 for (i = 0; i < 10; i++) {
54 set_npc_imgfx_comp(part->spriteInstanceID, i, IMGFX_COLOR_BUF_SET_MODULATE, j, colorRGBA, 0, 255, 0);
55 }
56 }
57 return ApiStatus_BLOCK;
58 } else {
59 s32 opacity = 255;
60 for (j = 0; j < RGBA_BUF_SIZE; j++) {
61 colorRGBA = 255;
62 for (i = 0; i < 10; i++) {
63 // TODO find better match for opacity
64 set_npc_imgfx_comp(part->spriteInstanceID, i, IMGFX_COLOR_BUF_SET_MODULATE, j, colorRGBA, 0, opacity & 0xFFFF, 0);
65 }
66 }
67 script->functionTemp[1] = 0;
68 script->functionTemp[2] = 0;
69 script->functionTemp[0] = 0;
70 return ApiStatus_BLOCK;
71 }
72
73 #undef RGBA_BUF_SIZE
74}
#define RGBA_BUF_SIZE
#define BOWSER_FLAG_TOCHECK
@ IMGFX_ALLOC_COLOR_BUF
Definition enums.h:5134
@ IMGFX_COLOR_BUF_SET_MODULATE
Definition enums.h:5129
#define ApiStatus_DONE2
Definition evt.h:118
#define ApiStatus_BLOCK
Definition evt.h:116
f32 cosine(s16 arg0)
Definition 43F0.c:354
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:1191
Actor * get_actor(s32 actorID)
Definition actor_api.c:155
void set_npc_imgfx_comp(s32 spriteIdx, s32 compIdx, ImgFXType imgfx, s32 imgfxArg1, s32 imgfxArg2, s32 imgfxArg3, s32 imgfxArg4, s32 imgfxArg5)
Definition sprite.c:1228