@@ -88,6 +88,14 @@ struct LEAF
8888 char sin_addition2 ;
8989};
9090
91+ struct BIRD
92+ {
93+ VECTOR_NOPAD position ;
94+ SVECTOR_NOPAD direction ;
95+ short life ;
96+ short step ;
97+ };
98+
9199struct TRI_POINT
92100{
93101 BVECTOR v0 ;
@@ -389,6 +397,9 @@ LEAF leaf[MAX_LEAVES];
389397SVECTOR debris_rotvec ;
390398DEBRIS debris [MAX_DEBRIS ];
391399
400+ BIRD birds [MAX_BIRDS ];
401+ int gNumBirds = 0 ;
402+
392403int StreakCount1 = 0 ;
393404int main_cop_light_pos = 0 ;
394405int NextDamagedLamp = 0 ;
@@ -755,6 +766,174 @@ void AddLeaf(VECTOR *Position, int num_leaves, int Type)
755766 }
756767}
757768
769+ // [D] [T]
770+ void CreateBirds (VECTOR * pos , int count )
771+ {
772+ BIRD * bird ;
773+ int i ;
774+
775+ if (bird_texture1 .tpageid == 0 || bird_texture2 .tpageid == 0 )
776+ {
777+ return ;
778+ }
779+
780+ if (count >= MAX_BIRDS )
781+ count = MAX_BIRDS - 1 ;
782+
783+ if (birds [0 ].life != 0 )
784+ {
785+ return ;
786+ }
787+
788+ gNumBirds = count ;
789+ for (i = 0 ; i < count ; ++ i )
790+ {
791+ bird = & birds [i ];
792+ bird -> position .vx = pos -> vx - 32 + (rand () & 63 );
793+ bird -> position .vy = pos -> vy - 32 + (rand () & 63 );
794+ bird -> position .vz = pos -> vz - 32 + (rand () & 63 );
795+ bird -> direction .vx = (rand () & 63 ) - 32 ;
796+ bird -> direction .vy = -10 - (rand () & 16 );
797+ bird -> direction .vz = (rand () & 63 ) - 32 ;
798+ bird -> life = 120 ;
799+ bird -> step = rand () & 7 ;
800+ }
801+ }
802+
803+ // [D] [T]
804+ void HandleBirds ()
805+ {
806+ BIRD * bird ;
807+ POLY_FT4 * primptr ;
808+ VECTOR pos ;
809+ SVECTOR vertPos [4 ];
810+ u_short clutid ;
811+ short sizeX ;
812+ short sizeY ;
813+ int i ;
814+ int z ;
815+ int bright ;
816+
817+ if (birds [0 ].life == 0 || gNumBirds == 0 )
818+ {
819+ return ;
820+ }
821+
822+ gte_SetRotMatrix (& identity );
823+
824+ bright = 128 ;
825+ if (gNight != 0 )
826+ bright = 64 ;
827+
828+ for (i = 0 ; i < gNumBirds ; ++ i )
829+ {
830+ bird = & birds [i ];
831+ if (bird -> life <= 0 )
832+ {
833+ continue ;
834+ }
835+
836+ pos .vx = bird -> position .vx - camera_position .vx ;
837+ pos .vy = bird -> position .vy - camera_position .vy ;
838+ pos .vz = bird -> position .vz - camera_position .vz ;
839+ Apply_Inv_CameraMatrix (& pos );
840+
841+ gte_SetTransVector (& pos );
842+
843+ if (pauseflag == 0 && pos .vz > 13500 )
844+ {
845+ bird -> life = 0 ;
846+ return ;
847+ }
848+
849+ sizeX = 40 ;
850+ if (bird -> step < 4 )
851+ {
852+ sizeY = 19 ;
853+ }
854+ else
855+ {
856+ sizeX = 64 ;
857+ sizeY = 24 ;
858+ }
859+ vertPos [0 ].vy = - sizeY ;
860+ vertPos [1 ].vy = - sizeY ;
861+ vertPos [0 ].vx = - sizeX ;
862+ vertPos [0 ].vz = 0 ;
863+ vertPos [1 ].vx = sizeX ;
864+ vertPos [1 ].vz = 0 ;
865+ vertPos [2 ].vx = - sizeX ;
866+ vertPos [2 ].vy = sizeY ;
867+ vertPos [2 ].vz = 0 ;
868+ vertPos [3 ].vx = sizeX ;
869+ vertPos [3 ].vy = sizeY ;
870+ vertPos [3 ].vz = 0 ;
871+
872+ gte_ldv3 (& vertPos [0 ], & vertPos [1 ], & vertPos [2 ]);
873+ gte_rtpt ();
874+
875+ primptr = (POLY_FT4 * )current -> primptr ;
876+ if (bird -> step < 4 )
877+ {
878+ primptr -> u0 = bird_texture2 .coords .u0 ;
879+ primptr -> v0 = bird_texture2 .coords .v0 ;
880+ primptr -> u1 = bird_texture2 .coords .u1 ;
881+ primptr -> v1 = bird_texture2 .coords .v1 ;
882+ primptr -> u2 = bird_texture2 .coords .u2 ;
883+ primptr -> v2 = bird_texture2 .coords .v2 ;
884+ primptr -> u3 = bird_texture2 .coords .u3 ;
885+ primptr -> v3 = bird_texture2 .coords .v3 ;
886+ primptr -> tpage = bird_texture2 .tpageid ;
887+ clutid = bird_texture2 .clutid ;
888+ }
889+ else
890+ {
891+ primptr -> u0 = bird_texture1 .coords .u0 ;
892+ primptr -> v0 = bird_texture1 .coords .v0 ;
893+ primptr -> u1 = bird_texture1 .coords .u1 ;
894+ primptr -> v1 = bird_texture1 .coords .v1 ;
895+ primptr -> u2 = bird_texture1 .coords .u2 ;
896+ primptr -> v2 = bird_texture1 .coords .v2 ;
897+ primptr -> u3 = bird_texture1 .coords .u3 ;
898+ primptr -> v3 = bird_texture1 .coords .v3 ;
899+ primptr -> tpage = bird_texture1 .tpageid ;
900+ clutid = bird_texture1 .clutid ;
901+ }
902+
903+ primptr -> clut = clutid ;
904+ setPolyFT4 (primptr );
905+ primptr -> r0 = bright ;
906+ primptr -> g0 = bright ;
907+ primptr -> b0 = bright ;
908+
909+ gte_stsz (& z );
910+ if (z < 150 )
911+ continue ;
912+
913+ gte_stsxy3 (& primptr -> x0 , & primptr -> x1 , & primptr -> x2 );
914+
915+ gte_ldv0 (& vertPos [3 ]);
916+ gte_rtps ();
917+
918+ gte_stsxy (& primptr -> x3 );
919+
920+ addPrim (current -> ot + (z >> 3 ), primptr );
921+
922+ current -> primptr += sizeof (POLY_FT4 );
923+
924+ if (pauseflag == 0 )
925+ {
926+ bird -> position .vx += bird -> direction .vx ;
927+ bird -> position .vy += bird -> direction .vy ;
928+ bird -> position .vz = bird -> position .vz + bird -> direction .vz ;
929+
930+ if (-- bird -> step == -1 )
931+ bird -> step = 8 ;
932+ -- bird -> life ;
933+ }
934+ }
935+ }
936+
758937// [D] [T]
759938void SwirlLeaves (CAR_DATA * cp )
760939{
@@ -801,8 +980,8 @@ void InitDebrisNames(void)
801980 GetTextureDetails ("SKID" , & gTyreTexture );
802981 GetTextureDetails ("FLARE" , & flare_texture );
803982 GetTextureDetails ("SPLASH" , & sea_texture );
804- GetTextureDetails ("SWBIRD1" , & bird_texture1 );
805- GetTextureDetails ("SWBIRD2" , & bird_texture2 );
983+ GetTextureDetails ("SWBIRD1" , & bird_texture1 , 0 );
984+ GetTextureDetails ("SWBIRD2" , & bird_texture2 , 0 );
806985 GetTextureDetails ("LENSFLR" , & lensflare_texture );
807986 GetTextureDetails ("SKYSUN" , & sun_texture );
808987 GetTextureDetails ("SKYMOON" , & moon_texture );
@@ -933,6 +1112,8 @@ void InitDebris(void)
9331112 }
9341113 }
9351114
1115+ birds [0 ].life = 0 ;
1116+
9361117 for (i = 0 ; i < MAX_SMOKE ; i ++ )
9371118 {
9381119 smoke_alloc [i ] = i ;
@@ -3135,7 +3316,7 @@ void HandleDebris(void)
31353316 GetSmokeDrift (& Drift );
31363317
31373318 MoveHubcap ();
3138-
3319+ HandleBirds ();
31393320 SetRotMatrix (& inv_camera_matrix );
31403321
31413322 gte_SetTransVector (& dummy );
@@ -3530,7 +3711,7 @@ void DrawRainDrops(void)
35303711 bright = 50 ;
35313712
35323713 if (gNight != 0 )
3533- bright -= - 15 ;
3714+ bright -= 15 ;
35343715
35353716 col = bright >> 1 | (bright >> 1 ) << 8 ;
35363717 col |= col | col << 0x10 ;
0 commit comments