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);
14 s32 i, j;
19
20 if (actor == nullptr) {
21 return ApiStatus_DONE2;
22 }
23
24 part = get_actor_part(actor, 1);
25
26 if (isInitialCall) {
27 script->functionTemp[1] = 0;
28 script->functionTemp[2] = 0;
29 script->functionTemp[0] = 0;
30
31 for (i = 0; i < 10; i++) {
32 set_npc_imgfx_comp(part->spriteInstanceID, i, IMGFX_ALLOC_COLOR_BUF, 20, 0, 0, 255, 0);
33 }
34 }
35
36 script->functionTemp[1] += 10;
37 if (script->functionTemp[1] >= 360) {
38 script->functionTemp[1] %= 360;
39 }
40
41 for (j = 0; j < RGBA_BUF_SIZE; j++) {
42 colR[j] = (cosine(script->functionTemp[1] + j * 25 + 120) + 1.0) * 56.0;
43 colG[j] = (cosine(script->functionTemp[1] + j * 25 + 60) + 1.0) * 56.0;
44 colB[j] = (cosine(script->functionTemp[1] + j * 25 + 180) + 1.0) * 56.0;
45 }
46
47 if (part->eventFlags & BOWSER_FLAG_TOCHECK) {
48
49 for (j = 0; j < RGBA_BUF_SIZE; j++) {
50 colorRGBA = colR[j] << 0x18 | colG[j] << 0x10 | colB[j] << 8 | 0xFF;
51 for (i = 0; i < 10; i++) {
52 set_npc_imgfx_comp(part->spriteInstanceID, i, IMGFX_COLOR_BUF_SET_MODULATE, j, colorRGBA, 0, 255, 0);
53 }
54 }
55 return ApiStatus_BLOCK;
56 } else {
57 s32 opacity = 255;
58 for (j = 0; j < RGBA_BUF_SIZE; j++) {
59 colorRGBA = 255;
60 for (i = 0; i < 10; i++) {
61 // TODO find better match for opacity
62 set_npc_imgfx_comp(part->spriteInstanceID, i, IMGFX_COLOR_BUF_SET_MODULATE, j, colorRGBA, 0, opacity & 0xFFFF, 0);
63 }
64 }
65 script->functionTemp[1] = 0;
66 script->functionTemp[2] = 0;
67 script->functionTemp[0] = 0;
68 return ApiStatus_BLOCK;
69 }
70
71 #undef RGBA_BUF_SIZE
72}
BSS s32 PopupMenu_SelectedIndex
#define RGBA_BUF_SIZE
#define BOWSER_FLAG_TOCHECK
@ IMGFX_ALLOC_COLOR_BUF
Definition enums.h:4719
@ IMGFX_COLOR_BUF_SET_MODULATE
Definition enums.h:4714
#define ApiStatus_DONE2
Definition evt.h:119
#define ApiStatus_BLOCK
Definition evt.h:117
f32 cosine(s16 arg0)
Definition 43F0.c:352
ActorPart * get_actor_part(Actor *actor, s32 partID)
Definition 190B20.c:923
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:1212