33#include "z64.h"
44#include "item_draw_table.h"
55#include "sys_matrix.h"
6+ #include "rainbow.h"
67
78typedef Gfx * (* append_setup_dl_fn )(Gfx * gfx , uint32_t dl_index );
89typedef void (* append_setup_dl_26_to_opa_fn )(z64_gfx_t * gfx );
@@ -18,6 +19,7 @@ typedef Gfx* (*gen_double_tile_fn)(z64_gfx_t* gfx, int32_t tile1, uint32_t x1, u
1819#define gen_double_tile ((gen_double_tile_fn)0x8007EB84)
1920
2021extern z64_actor_t * curr_drawn_actor ;
22+ extern Gfx sSetupDL [71 ][6 ];
2123
2224void draw_gi_bombchu_and_masks (z64_game_t * game , uint32_t draw_id ) {
2325 z64_gfx_t * gfx = game -> common .gfx ;
@@ -114,6 +116,13 @@ void draw_gi_silver_rupee_pouch(z64_game_t* game, uint32_t draw_id) {
114116 gSPDisplayList (gfx -> poly_opa .p ++ , item_draw_table [draw_id ].args [6 ].dlist ); // gGiAdultWalletRupeeInnerColorDL
115117 gSPDisplayList (gfx -> poly_opa .p ++ , item_draw_table [draw_id ].args [7 ].dlist ); // gGiWalletRupeeInnerDL
116118}
119+ void draw_gi_various_xlu0 (z64_game_t * game , uint32_t draw_id ) {
120+ z64_gfx_t * gfx = game -> common .gfx ;
121+
122+ append_setup_dl_25_to_xlu (gfx );
123+ gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
124+ gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [0 ].dlist );
125+ }
117126
118127void draw_gi_various_xlu01 (z64_game_t * game , uint32_t draw_id ) {
119128 z64_gfx_t * gfx = game -> common .gfx ;
@@ -365,7 +374,7 @@ void draw_gi_blue_fire_candle(z64_game_t* game, uint32_t draw_id) {
365374 1 , game -> common .state_frames * 1 , - (game -> common .state_frames * 8 ), 16 , 32 ));
366375 duplicate_sys_matrix ();
367376 translate_sys_matrix (-8.0f , -2.0f , 0.0f , 1 );
368- update_sys_matrix (game -> mf_11DA0 );
377+ update_sys_matrix (game -> billboard_mtx );
369378 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
370379 gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [1 ].dlist );
371380 pop_sys_matrix ();
@@ -386,7 +395,7 @@ void draw_gi_fairy_lantern(z64_game_t* game, uint32_t draw_id) {
386395 0 , 0 , 0 , 32 , 32 ,
387396 1 , game -> common .state_frames , - (game -> common .state_frames * 6 ), 32 , 32 ));
388397 duplicate_sys_matrix ();
389- update_sys_matrix (game -> mf_11DA0 );
398+ update_sys_matrix (game -> billboard_mtx );
390399 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
391400 gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [2 ].dlist );
392401 pop_sys_matrix ();
@@ -401,7 +410,7 @@ void draw_gi_fairy(z64_game_t* game, uint32_t draw_id) {
401410 0 , 0 , 0 , 32 , 32 ,
402411 1 , game -> common .state_frames , - (game -> common .state_frames * 6 ), 32 , 32 ));
403412 duplicate_sys_matrix ();
404- update_sys_matrix (game -> mf_11DA0 );
413+ update_sys_matrix (game -> billboard_mtx );
405414 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
406415 // Not sure how much of this is required but these are called from the bottle DL. Not including them causes it to draw weird
407416 gDPSetRenderMode (gfx -> poly_xlu .p ++ , G_RM_PASS , G_RM_AA_ZB_XLU_SURF2 );
@@ -428,7 +437,7 @@ void draw_gi_poe_bottles(z64_game_t* game, uint32_t draw_id) {
428437 0 , 0 , 0 , 16 , 32 ,
429438 1 , game -> common .state_frames * 1 , - (game -> common .state_frames * 6 ), 16 , 32 ));
430439 duplicate_sys_matrix ();
431- update_sys_matrix (game -> mf_11DA0 );
440+ update_sys_matrix (game -> billboard_mtx );
432441 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
433442 gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [3 ].dlist );
434443 gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [2 ].dlist );
@@ -721,13 +730,13 @@ void draw_gi_magic_meter(z64_game_t* game, uint32_t draw_id) {
721730 z64_gfx_t * gfx = game -> common .gfx ;
722731
723732 // Magic
724- colorRGBA8_t prim_color = item_draw_table [draw_id ].args [5 ].color ;
733+ colorRGBA8_t prim_color = item_draw_table [draw_id ].args [4 ].color ;
725734 if (CFG_CORRECT_MODEL_COLORS ) {
726735 prim_color .r = CFG_MAGIC_COLOR .r ;
727736 prim_color .g = CFG_MAGIC_COLOR .g ;
728737 prim_color .b = CFG_MAGIC_COLOR .b ;
729738 }
730- colorRGBA8_t env_color = item_draw_table [draw_id ].args [6 ].color ;
739+ colorRGBA8_t env_color = item_draw_table [draw_id ].args [5 ].color ;
731740
732741 uint8_t alpha = 0x80 ;
733742 if (curr_drawn_actor != NULL && curr_drawn_actor -> actor_id == 21 ) {// En_Item00
@@ -736,28 +745,87 @@ void draw_gi_magic_meter(z64_game_t* game, uint32_t draw_id) {
736745 }
737746 }
738747
739- // Writing
748+ // Rainbow smoke effect
749+ colorRGBA8_t rainbow_color ;
750+ rainbow_color .a = 0xFF ;
751+ rainbow_color .color = get_rainbow_color (game -> gameplay_frames , 10 );
752+ z64_xyzf_t translation = { .x = 0.0 , .y = -35.0f , .z = 0.0f };
753+ z64_xyzf_t scale = { .x = .0125f , .y = .0075f , .z = .01f };
754+ draw_gi_flame (& gfx -> poly_xlu , game , rainbow_color , rainbow_color , translation , scale );
755+
756+ // Parchment
740757 append_setup_dl_25_to_xlu (gfx );
741758 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
742- gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [4 ].dlist );
743- // Shine
759+ gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [2 ].dlist );
760+
761+ // Writing
744762 append_setup_dl_25_to_xlu (gfx );
745763 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
746- gDPSetPrimColor (gfx -> poly_xlu .p ++ , 0 , 0x80 , prim_color .r , prim_color .g , prim_color .b , alpha );
747- gDPSetEnvColor (gfx -> poly_xlu .p ++ , env_color .r , env_color .g , env_color .b , env_color .a );
748- gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [2 ].dlist );
764+ gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [3 ].dlist );
765+
749766 // Jar
750767 append_setup_dl_25_to_xlu (gfx );
751768 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
752769 gDPSetPrimColor (gfx -> poly_xlu .p ++ , 0 , 0x80 , prim_color .r , prim_color .g , prim_color .b , alpha );
753770 gDPSetEnvColor (gfx -> poly_xlu .p ++ , env_color .r , env_color .g , env_color .b , env_color .a );
754771 gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [0 ].dlist );
772+
755773 // Label
756774 append_setup_dl_25_to_xlu (gfx );
757775 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
758776 gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [1 ].dlist );
759- // Parchment
760- append_setup_dl_25_to_opa (gfx );
761- gSPMatrix (gfx -> poly_opa .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
762- gSPDisplayList (gfx -> poly_opa .p ++ , item_draw_table [draw_id ].args [3 ].dlist );
777+ }
778+
779+ void draw_gi_flame (z64_disp_buf_t * dl , z64_game_t * game , colorRGBA8_t prim , colorRGBA8_t env , z64_xyzf_t translation , z64_xyzf_t scale ) {
780+ z64_gfx_t * gfx = game -> common .gfx ;
781+ static const uint32_t kFlameDlist = 0x52a10 ; // Offset of gEffFire1DL in gameplay_keep
782+ duplicate_sys_matrix (); // Push the matrix stack. Do this so we can apply the smoke before the rest of the model
783+ update_sys_matrix (game -> billboard_mtx ); // Set the rotation to use the billboard matrix
784+ translate_sys_matrix (translation .x , translation .y , translation .z , 1 ); // Translate by the amount specified
785+ scale_sys_matrix (scale .x , scale .y , scale .z , 1 ); // Scale by the amount specified
786+ gSPMatrix (dl -> p ++ , append_sys_matrix (gfx ), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW ); // Apply the matrix
787+
788+ // Draw the flame effect
789+ gSPDisplayList (dl -> p ++ , sSetupDL [25 ]);
790+ gDPSetEnvColor (dl -> p ++ , env .r , env .g , env .b , 0 );
791+ gDPSetPrimColor (dl -> p ++ , 0x0 , 0x80 , prim .r , prim .g , prim .b , 255 );
792+
793+ gSPSegment (dl -> p ++ , 0x08 ,
794+ gen_double_tile (gfx , G_TX_RENDERTILE , 0 , 0 , 0x20 , 0x40 , 1 , 0 ,
795+ (- game -> gameplay_frames & 0x7F ) << 2 , 0x20 , 0x80 ));
796+
797+ gSPDisplayList (dl -> p ++ , 0x04000000 | kFlameDlist );
798+ pop_sys_matrix (); // Pop the matrix stack
799+ }
800+
801+ /* void draw_gi_opa_with_rainbow_flame(z64_game_t* game, uint32_t draw_id) {
802+ draw_gi_various_xlu01(game, draw_id);
803+ colorRGBA8_t rainbow_color;
804+ rainbow_color.a = 0xFF;
805+ rainbow_color.color = get_rainbow_color(game->gameplay_frames, 10);
806+
807+ z64_xyzf_t translation = { .x = 0, .y = -35.0f, .z = -10.0f };
808+ z64_xyzf_t scale = { .x = .0125f, .y = .0075f, .z = .01f };
809+ draw_gi_flame(game, rainbow_color, rainbow_color, translation, scale);
810+ }
811+ */
812+
813+ void draw_gi_xlu_with_flame (z64_game_t * game , uint32_t draw_id ) {
814+ z64_gfx_t * gfx = game -> common .gfx ;
815+
816+ z64_xyzf_t translation = { .x = 0 , .y = -35.0f , .z = 0.0f };
817+ z64_xyzf_t scale = { .x = .0125f , .y = .0075f , .z = .01f };
818+ draw_gi_flame (& gfx -> poly_xlu , game , item_draw_table [draw_id ].args [1 ].color , item_draw_table [draw_id ].args [2 ].color , translation , scale );
819+
820+ draw_gi_various_xlu0 (game , draw_id );
821+ }
822+
823+ void draw_gi_deku_nut_with_flame (z64_game_t * game , uint32_t draw_id ) {
824+ z64_gfx_t * gfx = game -> common .gfx ;
825+
826+ z64_xyzf_t translation = { .x = 0 , .y = -35.0f , .z = -10.0f };
827+ z64_xyzf_t scale = { .x = .0125f , .y = .0075f , .z = .01f };
828+ draw_gi_flame (& gfx -> poly_xlu , game , item_draw_table [draw_id ].args [1 ].color , item_draw_table [draw_id ].args [2 ].color , translation , scale );
829+
830+ draw_gi_deku_nut (game , draw_id );
763831}
0 commit comments