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 );
@@ -736,16 +745,31 @@ void draw_gi_magic_meter(z64_game_t* game, uint32_t draw_id) {
736745 }
737746 }
738747
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, .y = -35.0f, .z = -20.0f };
753+ z64_xyzf_t translation = { .x = 0.0 , .y = -35.0f , .z = 0.0f };
754+ z64_xyzf_t scale = { .x = .0125f , .y = .0075f , .z = .01f };
755+ draw_gi_flame (& gfx -> poly_xlu , game , rainbow_color , rainbow_color , translation , scale );
756+ // Parchment
757+ append_setup_dl_25_to_xlu (gfx );
758+ gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
759+ gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [3 ].dlist );
739760 // Writing
740761 append_setup_dl_25_to_xlu (gfx );
741762 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
742763 gSPDisplayList (gfx -> poly_xlu .p ++ , item_draw_table [draw_id ].args [4 ].dlist );
764+
743765 // Shine
744- append_setup_dl_25_to_xlu (gfx );
766+ /* append_setup_dl_25_to_xlu(gfx);
745767 gSPMatrix(gfx->poly_xlu.p++, append_sys_matrix(gfx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
746768 gDPSetPrimColor(gfx->poly_xlu.p++, 0, 0x80, prim_color.r, prim_color.g, prim_color.b, alpha);
747769 gDPSetEnvColor(gfx->poly_xlu.p++, env_color.r, env_color.g, env_color.b, env_color.a);
748770 gSPDisplayList(gfx->poly_xlu.p++, item_draw_table[draw_id].args[2].dlist);
771+ */
772+
749773 // Jar
750774 append_setup_dl_25_to_xlu (gfx );
751775 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
@@ -756,8 +780,58 @@ void draw_gi_magic_meter(z64_game_t* game, uint32_t draw_id) {
756780 append_setup_dl_25_to_xlu (gfx );
757781 gSPMatrix (gfx -> poly_xlu .p ++ , append_sys_matrix (gfx ), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH );
758782 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 );
783+ }
784+
785+ 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 ) {
786+ z64_gfx_t * gfx = game -> common .gfx ;
787+ static const uint32_t kFlameDlist = 0x52a10 ; // Offset of gEffFire1DL in gameplay_keep
788+ duplicate_sys_matrix (); // Push the matrix stack. Do this so we can apply the smoke before the rest of the model
789+ update_sys_matrix (game -> billboard_mtx ); // Set the rotation to use the billboard matrix
790+ translate_sys_matrix (translation .x , translation .y , translation .z , 1 ); // Translate by the amount specified
791+ scale_sys_matrix (scale .x , scale .y , scale .z , 1 ); // Scale by the amount specified
792+ gSPMatrix (dl -> p ++ , append_sys_matrix (gfx ), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW ); // Apply the matrix
793+
794+ // Draw the flame effect
795+ gSPDisplayList (dl -> p ++ , sSetupDL [25 ]);
796+ gDPSetEnvColor (dl -> p ++ , env .r , env .g , env .b , 0 );
797+ gDPSetPrimColor (dl -> p ++ , 0x0 , 0x80 , prim .r , prim .g , prim .b , 255 );
798+
799+ gSPSegment (dl -> p ++ , 0x08 ,
800+ gen_double_tile (gfx , G_TX_RENDERTILE , 0 , 0 , 0x20 , 0x40 , 1 , 0 ,
801+ (- game -> gameplay_frames & 0x7F ) << 2 , 0x20 , 0x80 ));
802+
803+ gSPDisplayList (dl -> p ++ , 0x04000000 | kFlameDlist );
804+ pop_sys_matrix (); // Pop the matrix stack
805+ }
806+
807+ /* void draw_gi_opa_with_rainbow_flame(z64_game_t* game, uint32_t draw_id) {
808+ draw_gi_various_xlu01(game, draw_id);
809+ colorRGBA8_t rainbow_color;
810+ rainbow_color.a = 0xFF;
811+ rainbow_color.color = get_rainbow_color(game->gameplay_frames, 10);
812+
813+ z64_xyzf_t translation = { .x = 0, .y = -35.0f, .z = -10.0f };
814+ z64_xyzf_t scale = { .x = .0125f, .y = .0075f, .z = .01f };
815+ draw_gi_flame(game, rainbow_color, rainbow_color, translation, scale);
816+ }
817+ */
818+
819+ void draw_gi_xlu_with_flame (z64_game_t * game , uint32_t draw_id ) {
820+ z64_gfx_t * gfx = game -> common .gfx ;
821+
822+ z64_xyzf_t translation = { .x = 0 , .y = -35.0f , .z = 0.0f };
823+ z64_xyzf_t scale = { .x = .0125f , .y = .0075f , .z = .01f };
824+ 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 );
825+
826+ draw_gi_various_xlu0 (game , draw_id );
827+ }
828+
829+ void draw_gi_deku_nut_with_flame (z64_game_t * game , uint32_t draw_id ) {
830+ z64_gfx_t * gfx = game -> common .gfx ;
831+
832+ z64_xyzf_t translation = { .x = 0 , .y = -35.0f , .z = -10.0f };
833+ z64_xyzf_t scale = { .x = .0125f , .y = .0075f , .z = .01f };
834+ 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 );
835+
836+ draw_gi_deku_nut (game , draw_id );
763837}
0 commit comments