@@ -2351,6 +2351,44 @@ char GetCarPalIndex(int tpage)
23512351}
23522352
23532353
2354+ // decompiled code
2355+ // original method signature:
2356+ // void /*$ra*/ ProcessPalletLump(char *lump_ptr /*$a0*/, int lump_size /*$a1*/)
2357+ // line 1970, offset 0x00019f44
2358+ /* begin block 1 */
2359+ // Start line: 1971
2360+ // Start offset: 0x00019F44
2361+ // Variables:
2362+ // int total_cluts; // $v0
2363+ // int clutValue; // $s1
2364+ // int tpageindex; // $s2
2365+ // int texnum; // $s3
2366+ // int palette; // $s4
2367+ // int clut_number; // $v1
2368+ // unsigned short clutTable[320]; // stack offset -680
2369+ // char *buffPtr; // $s0
2370+
2371+ /* begin block 1.1 */
2372+ // Start line: 2013
2373+ // Start offset: 0x00019FD0
2374+ /* end block 1.1 */
2375+ // End offset: 0x00019FD0
2376+ // End Line: 2013
2377+ /* end block 1 */
2378+ // End offset: 0x0001A094
2379+ // End Line: 2034
2380+
2381+ /* begin block 2 */
2382+ // Start line: 8209
2383+ /* end block 2 */
2384+ // End Line: 8210
2385+
2386+ /* begin block 3 */
2387+ // Start line: 3940
2388+ /* end block 3 */
2389+ // End Line: 3941
2390+
2391+
23542392// [D]
23552393void ProcessPalletLump (char * lump_ptr , int lump_size )
23562394{
@@ -2367,41 +2405,40 @@ void ProcessPalletLump(char *lump_ptr, int lump_size)
23672405 int total_cluts ;
23682406 int clut_number ;
23692407
2370- if (* (int * )lump_ptr == 0 || * (int * )(lump_ptr + 4 ) == -1 )
2408+ total_cluts = * (int * )lump_ptr ;
2409+
2410+ if (total_cluts == 0 )
23712411 return ;
23722412
23732413 buffPtr = (int * )(lump_ptr + 4 );
23742414 clutTablePtr = (u_short * )clutTable ;
23752415
2376- do
2416+ while ( * buffPtr != -1 )
23772417 {
23782418 palette = buffPtr [0 ];
23792419 texnum = buffPtr [1 ];
23802420 tpageindex = buffPtr [2 ];
2381- total_cluts = buffPtr [3 ];
2421+ clut_number = buffPtr [3 ];
23822422
2383- clut_number = GetCarPalIndex (tpageindex );
2384-
2385- if (total_cluts == -1 )
2423+ if (clut_number == -1 )
23862424 {
2425+ // store clut
23872426 LoadImage (& clutpos , (u_long * )(buffPtr + 4 ));
23882427
23892428 clutValue = GetClut (clutpos .x , clutpos .y );
2390-
2391- * clutTablePtr = clutValue ;
2392- clutTablePtr += 1 ;
2429+ * clutTablePtr ++ = clutValue ;
23932430
23942431 IncrementClutNum (& clutpos );
23952432
23962433 buffPtr += 12 ;
23972434 }
23982435 else
23992436 {
2400- clutValue = clutTable [total_cluts ];
2437+ // use stored clut
2438+ clutValue = clutTable [clut_number ];
24012439 buffPtr += 4 ;
24022440 }
24032441
2404- civ_clut [clut_number ][texnum ][palette + 1 ] = clutValue ;
2442+ civ_clut [GetCarPalIndex ( tpageindex ) ][texnum ][palette + 1 ] = clutValue ;
24052443 }
2406- while (* buffPtr != -1 );
24072444}
0 commit comments