11#include "shadow.h"
22
3+ #include <sys/types.h>
4+ #include <libgte.h>
5+ #include <libgpu.h>
6+
37#include "common.h"
8+ #include "libgv/libgv.h"
9+ #include "libdg/libdg.h"
410#include "game/game.h"
511
6- typedef struct ShadowWork
12+ /*---------------------------------------------------------------------------*/
13+
14+ #define EXEC_LEVEL GV_ACTOR_LEVEL5
15+
16+ #define SHADOW_FLAG ( DG_FLAG_TEXT | DG_FLAG_TRANS | DG_FLAG_SHADE \
17+ | DG_FLAG_GBOUND | DG_FLAG_ONEPIECE | DG_FLAG_AMBIENT )
18+
19+ typedef struct _Work
720{
821 GV_ACT actor ;
922 CONTROL * control ;
1023 OBJECT * parent ;
1124 OBJECT_NO_ROTS object ;
1225 MATRIX light [2 ];
13- int field_8C ;
26+ int color ; // Unused
1427 int enabled ;
1528 SVECTOR indices ;
16- } ShadowWork ;
29+ } Work ;
1730
18- typedef struct _Shadow_Scratch
31+ typedef struct _SCRPAD_DATA
1932{
2033 SVECTOR iter [4 ];
2134 SVECTOR rot_in ;
2235 VECTOR rot_out ;
2336 MATRIX mtx ;
24- } Shadow_Scratch ;
37+ } SCRPAD_DATA ;
2538
26- #define EXEC_LEVEL GV_ACTOR_LEVEL5
27- #define SHADOW_FLAG ( DG_FLAG_TEXT | DG_FLAG_TRANS | DG_FLAG_GBOUND | DG_FLAG_SHADE | DG_FLAG_ONEPIECE | DG_FLAG_AMBIENT )
39+ /*---------------------------------------------------------------------------*/
2840
29- void ShadowRotate_8005FD28 ( ShadowWork * work )
41+ static void RotateShadow ( Work * work )
3042{
3143 MATRIX * pWorld ;
3244 MATRIX * pMatrix ;
@@ -46,14 +58,14 @@ void ShadowRotate_8005FD28(ShadowWork *work)
4658 int iVar16 ;
4759 int iVar17 ;
4860
49- Shadow_Scratch * pScratch = (Shadow_Scratch * )getScratchAddr (0 );
61+ SCRPAD_DATA * pScratch = (SCRPAD_DATA * )getScratchAddr (0 );
5062
5163 SVECTOR * iter1 = pScratch -> iter ;
5264 short * iter2 = (short * )& work -> indices ;
5365
54- int iters = 4 ;
66+ int i ;
5567
56- do
68+ for ( i = 4 ; i > 0 ; i -- , iter1 ++ , iter2 ++ )
5769 {
5870 pMatrix = & work -> parent -> objs -> objs [* iter2 ].world ;
5971 iter1 -> vx = pMatrix -> t [0 ];
@@ -63,11 +75,7 @@ void ShadowRotate_8005FD28(ShadowWork *work)
6375
6476 pMatrix = & work -> parent -> objs -> objs [* iter2 ].world ;
6577 iter1 -> vz = pMatrix -> t [2 ];
66-
67- iters -- ;
68- iter1 ++ ;
69- iter2 ++ ;
70- } while (0 < iters );
78+ }
7179
7280 pScratch -> mtx = work -> parent -> objs -> world ;
7381
@@ -90,9 +98,7 @@ void ShadowRotate_8005FD28(ShadowWork *work)
9098 iVar16 = 32000 ;
9199 iVar12 = 32000 ;
92100
93- iters = 4 ;
94-
95- do
101+ for (i = 4 ; i > 0 ; i -- )
96102 {
97103 pScratch -> rot_in .vx = psVar14 -> vx - lVar9 ;
98104 pScratch -> rot_in .vy = psVar14 -> vy - lVar5 ;
@@ -121,8 +127,7 @@ void ShadowRotate_8005FD28(ShadowWork *work)
121127 }
122128
123129 psVar14 ++ ;
124- iters -- ;
125- } while (iters > 0 );
130+ }
126131
127132 sVar6 = (iVar15 - iVar12 ) / 2 ;
128133 sVar7 = (iVar17 - iVar16 ) / 2 ;
@@ -144,9 +149,10 @@ void ShadowRotate_8005FD28(ShadowWork *work)
144149 pWorld -> m [2 ][2 ] = sVar7 ;
145150}
146151
147- void ShadowMove_80060028 ( ShadowWork * work )
152+ static void MoveShadow ( Work * work )
148153{
149154 DG_OBJS * objs = work -> object .objs ;
155+
150156 RotMatrixY (work -> control -> rot .vy , & objs -> world );
151157 objs -> world .t [0 ] = work -> parent -> objs -> world .t [0 ];
152158 objs -> world .t [2 ] = work -> parent -> objs -> world .t [2 ];
@@ -162,7 +168,7 @@ void ShadowMove_80060028(ShadowWork *work)
162168 }
163169}
164170
165- void ShadowAct_800600E4 ( ShadowWork * work )
171+ static void Act ( Work * work )
166172{
167173 if ((work -> parent -> objs -> flag & DG_FLAG_INVISIBLE ) || !work -> enabled )
168174 {
@@ -171,18 +177,18 @@ void ShadowAct_800600E4(ShadowWork *work)
171177 else
172178 {
173179 DG_VisibleObjs (work -> object .objs );
174- ShadowRotate_8005FD28 (work );
175- ShadowMove_80060028 (work );
180+ RotateShadow (work );
181+ MoveShadow (work );
176182 DG_GroupObjs (work -> object .objs , work -> parent -> map_name );
177183 }
178184}
179185
180- void ShadowDie_80060190 ( ShadowWork * work )
186+ static void Die ( Work * work )
181187{
182188 GM_FreeObject ((OBJECT * )& work -> object );
183189}
184190
185- int ShadowGetResources_800601B0 ( ShadowWork * work , CONTROL * control , OBJECT * parent , SVECTOR indices )
191+ static int GetResources ( Work * work , CONTROL * control , OBJECT * parent , SVECTOR indices )
186192{
187193 GM_InitObjectNoRots (& work -> object , GV_StrCode ("kage" ), SHADOW_FLAG , 0 );
188194 GM_ConfigObjectLight ((OBJECT * )& work -> object , work -> light );
@@ -203,21 +209,23 @@ int ShadowGetResources_800601B0(ShadowWork *work, CONTROL *control, OBJECT *pare
203209 work -> control = control ;
204210 work -> parent = parent ;
205211 work -> indices = indices ;
206- work -> field_8C = 0x2c484848 ;
207- work -> enabled = 1 ;
212+ work -> color = MAKE_RGBA ( 72 , 72 , 72 , 0x2C ); // POLY_FT4
213+ work -> enabled = TRUE ;
208214
209215 return 0 ;
210216}
211217
212- void * NewShadow_800602CC (CONTROL * control , OBJECT * parent , SVECTOR indices )
218+ /*---------------------------------------------------------------------------*/
219+
220+ void * NewShadow (CONTROL * control , OBJECT * parent , SVECTOR indices )
213221{
214- ShadowWork * work ;
222+ Work * work ;
215223
216- work = GV_NewActor (EXEC_LEVEL , sizeof (ShadowWork ));
217- if (work )
224+ work = GV_NewActor (EXEC_LEVEL , sizeof (Work ));
225+ if (work != NULL )
218226 {
219- GV_SetNamedActor (& work -> actor , ShadowAct_800600E4 , ShadowDie_80060190 , "shadow.c" );
220- if (ShadowGetResources_800601B0 (work , control , parent , indices ) >= 0 )
227+ GV_SetNamedActor (& work -> actor , Act , Die , "shadow.c" );
228+ if (GetResources (work , control , parent , indices ) >= 0 )
221229 {
222230 return (void * )work ;
223231 }
@@ -226,15 +234,14 @@ void *NewShadow_800602CC(CONTROL *control, OBJECT *parent, SVECTOR indices)
226234 return NULL ;
227235}
228236
229- void * NewShadow2_80060384 (CONTROL * control , OBJECT * pObj , SVECTOR indices , int * * enabled )
237+ void * NewShadow2 (CONTROL * control , OBJECT * parent , SVECTOR indices , int * * enabled )
230238{
231- ShadowWork * work ;
239+ Work * work ;
232240
233- work = (ShadowWork * )NewShadow_800602CC (control , pObj , indices );
234- if (work && enabled )
241+ work = (Work * )NewShadow (control , parent , indices );
242+ if (work != NULL && enabled != NULL )
235243 {
236244 * enabled = & work -> enabled ;
237245 }
238-
239246 return (void * )work ;
240247}
0 commit comments