2020-03-27 21:47:29 +01:00
# include "THISDUST.H"
2020-04-10 01:29:12 +02:00
2020-04-11 17:04:02 +02:00
# ifndef PSX
# include <SDL.h>
# endif // !PSX
# include <STRINGS.H>
2020-04-10 01:29:12 +02:00
# include "LIBETC.H"
2020-04-10 13:56:11 +02:00
# include "PAD.H"
2020-03-27 21:47:29 +01:00
# include "SPOOL.H"
2020-04-09 19:15:54 +02:00
# include "MAP.H"
2020-04-05 23:04:50 +02:00
# include "SYSTEM.H"
2020-04-09 20:22:38 +02:00
# include "MAIN.H"
2020-04-09 20:50:21 +02:00
# include "XAPLAY.H"
# include "DIRECTOR.H"
2020-04-10 01:29:12 +02:00
# include "SOUND.H"
# include "TEXTURE.H"
# include "MODELS.H"
# include "OBJANIM.H"
# include "GLAUNCH.H"
2020-04-10 01:37:20 +02:00
# include "CARS.H"
2020-04-10 01:52:35 +02:00
# include "COSMETIC.H"
# include "DENTING.H"
# include "HANDLING.H"
# include "MISSION.H"
2020-04-10 13:56:11 +02:00
# include "CIV_AI.H"
2020-04-16 21:14:56 +02:00
# include "CAMERA.H"
2020-04-20 07:14:19 +02:00
# include "DR2ROADS.H"
2020-03-27 21:47:29 +01:00
int date_date = 0xA11 ;
int date_time = 0x27220B ;
int SpecialByRegion [ 4 ] [ 20 ] = {
{ 5 , 1 , 3 , 3 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 1 , 1 , 1 , 2 , 3 , 2 , 2 , 3 , 0 } ,
{ 2 , 4 , 1 , 1 , 4 , 4 , 3 , 3 , 3 , 3 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ 2 , 4 , 1 , 1 , 1 , 1 , 1 , 1 , 4 , 2 , 3 , 3 , 5 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ,
{ 2 , 5 , 4 , 1 , 2 , 1 , 4 , 3 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 0 , 0 , 0 , 0 , 0 } ,
} ;
2020-04-09 19:10:34 +02:00
char * model_spool_buffer = NULL ;
int cell_objects_add [ 5 ] ;
int cell_slots_add [ 5 ] ;
SXYPAIR * Music_And_AmbientOffsets ;
AreaDataStr * AreaData ;
2020-05-14 10:45:42 +02:00
unsigned char * AreaTPages ; // 16 per area
2020-04-09 19:10:34 +02:00
int NumAreas ;
char * RegionSpoolInfo ;
unsigned short * spoolinfo_offsets ;
2020-04-09 17:36:53 +02:00
char * specmallocptr ;
char * specLoadBuffer ;
2020-04-09 19:10:34 +02:00
int doSpooling = 1 ;
short loading_region [ 4 ] ;
int regions_unpacked [ 4 ] ;
int spool_regioncounter ;
int spoolerror ; // UNUSED
int spool_regionpos ;
2020-04-12 13:41:42 +02:00
volatile int spoolactive ; // volatile is required at least for PC
2020-04-12 18:15:14 +02:00
volatile int quickSpool ;
2020-04-09 19:10:34 +02:00
int models_ready ;
2020-05-13 11:57:51 +02:00
short specspooldata [ 3 ] = { 20 , 10 , 4 } ;
2020-04-12 17:29:49 +02:00
2020-04-09 19:10:34 +02:00
int tsetcounter ;
int tsetpos ;
int spoolcounter ;
int spoolseek ; // Probably UNUSED
int loadbank_read ;
int loadbank_write ;
int spoolpos ;
int spoolpos_reading ;
int spoolpos_writing ;
2020-04-10 13:56:11 +02:00
int allowSpecSpooling ;
int startSpecSpool ;
2020-04-09 19:10:34 +02:00
int unpack_roadmap_flag ;
int unpack_cellptr_flag ;
2020-04-09 19:45:55 +02:00
char * packed_cell_pointers ;
SPL_REGIONINFO spool_regioninfo [ 8 ] ;
2020-04-10 01:29:12 +02:00
static int sectors_this_chunk ;
2020-04-20 06:55:53 +02:00
static volatile int sectors_to_read ;
2020-04-10 01:29:12 +02:00
static char * target_address ;
static int nTPchunks ;
static int nTPchunks_reading ;
static int nTPchunks_writing ;
static int ntpages ;
static int current_sector ;
static int switch_spooltype ;
static int endchunk ;
int send_bank ;
int sample_chunk ;
int chunk_complete ;
2020-04-10 13:56:11 +02:00
int new_area_location ;
int LoadingArea = 0 ;
unsigned short * newmodels ;
2020-04-10 01:29:12 +02:00
struct SPOOLQ spooldata [ 48 ] ;
2020-05-12 10:39:31 +02:00
# if !defined(PSX) && !defined(SIMPLE_SPOOL)
2020-04-11 17:04:02 +02:00
# include <assert.h>
typedef void ( * data_callbackFn ) ( void ) ;
typedef void ( * ready_callbackFn ) ( unsigned char intr , unsigned char * result ) ;
data_callbackFn g_dataCallbackPC = NULL ;
ready_callbackFn g_readyCallbackPC = NULL ;
char g_sectorData [ 2048 ] = { 0 } ;
bool g_isSectorDataRead = false ;
2020-04-12 17:48:56 +02:00
bool g_spoolDoneFlag = false ;
2020-04-11 17:04:02 +02:00
extern char g_CurrentLevelFileName [ 64 ] ;
2020-04-12 17:48:56 +02:00
SDL_Thread * levelSpoolerPCThread = NULL ;
SDL_mutex * levelSpoolerPCMutex = NULL ;
2020-04-19 12:53:18 +02:00
volatile int levelSpoolerSeekCmd = 0 ;
2020-04-12 17:48:56 +02:00
2020-04-11 17:04:02 +02:00
//-----------------------------------------------------
// copies read sector data to addr
//-----------------------------------------------------
void getLevSectorPC ( char * dest , int count )
{
2020-04-11 18:03:57 +02:00
count * = 4 ;
2020-04-20 06:55:53 +02:00
# ifdef _DEBUG
SPOOLQ * which = & spooldata [ spoolpos_reading ] ;
sectors_this_chunk ;
current_sector ;
sectors_to_read ;
# endif // _DEBUG
2020-04-11 17:04:02 +02:00
assert ( count < = 2048 ) ;
2020-04-20 06:55:53 +02:00
assert ( dest ) ;
assert ( sectors_to_read > 0 ) ;
2020-04-11 17:04:02 +02:00
2020-05-12 10:39:31 +02:00
//SDL_LockMutex(levelSpoolerPCMutex);
2020-04-11 17:04:02 +02:00
2020-04-12 17:48:56 +02:00
memcpy ( dest , g_sectorData , count ) ;
2020-04-11 17:04:02 +02:00
g_isSectorDataRead = true ;
2020-04-12 17:48:56 +02:00
2020-05-12 10:39:31 +02:00
//SDL_UnlockMutex(levelSpoolerPCMutex);
2020-04-11 17:04:02 +02:00
}
2020-04-19 12:53:18 +02:00
void levelSpoolerPCDataCallback ( data_callbackFn cb )
{
SDL_LockMutex ( levelSpoolerPCMutex ) ;
g_dataCallbackPC = cb ;
SDL_UnlockMutex ( levelSpoolerPCMutex ) ;
}
void levelSpoolerPCReadyCallback ( ready_callbackFn cb )
{
SDL_LockMutex ( levelSpoolerPCMutex ) ;
g_readyCallbackPC = cb ;
SDL_UnlockMutex ( levelSpoolerPCMutex ) ;
}
2020-04-12 17:48:56 +02:00
// Main spooler thread function
2020-04-11 17:04:02 +02:00
int levelSpoolerPCFunc ( void * data )
{
//Print incoming data
2020-05-14 08:57:20 +02:00
printWarning ( " Running SPOOL thread... \n " ) ;
2020-04-11 17:04:02 +02:00
2020-04-12 15:56:52 +02:00
g_spoolDoneFlag = false ;
g_isSectorDataRead = false ;
2020-04-11 17:04:02 +02:00
ready_callbackFn readyCb = g_readyCallbackPC ;
2020-04-11 20:15:11 +02:00
data_callbackFn dataCb = g_dataCallbackPC ;
2020-04-11 17:04:02 +02:00
FILE * fp = fopen ( g_CurrentLevelFileName , " rb " ) ;
if ( ! fp )
{
char errPrint [ 1024 ] ;
sprintf ( errPrint , " Cannot open '%s' \n " , g_CurrentLevelFileName ) ;
SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_ERROR , " ERROR " , errPrint , NULL ) ;
if ( readyCb )
readyCb ( 0 , { 0x0 } ) ;
return - 1 ;
}
do
{
2020-04-19 12:53:18 +02:00
SDL_LockMutex ( levelSpoolerPCMutex ) ;
2020-04-11 17:04:02 +02:00
if ( levelSpoolerSeekCmd ! = 0 )
{
int sector = levelSpoolerSeekCmd ;
if ( sector = = - 1 )
{
2020-05-14 08:57:20 +02:00
printInfo ( " SPOOL thread recieved 'CdlPause' \n " , sector ) ;
2020-04-12 17:48:56 +02:00
2020-04-11 17:04:02 +02:00
levelSpoolerSeekCmd = 0 ;
2020-04-12 17:29:49 +02:00
g_spoolDoneFlag = true ;
2020-04-11 17:04:02 +02:00
}
2020-04-12 17:29:49 +02:00
else
{
2020-05-14 08:57:20 +02:00
printInfo ( " SPOOL thread recieved 'CdlReadS' at %d \n " , sector ) ;
2020-04-11 17:04:02 +02:00
2020-04-12 17:29:49 +02:00
// seek
fseek ( fp , sector * 2048 , SEEK_SET ) ;
levelSpoolerSeekCmd = 0 ;
}
2020-04-11 17:04:02 +02:00
}
2020-04-19 14:32:14 +02:00
dataCb = g_dataCallbackPC ;
readyCb = g_readyCallbackPC ;
2020-04-12 17:48:56 +02:00
SDL_UnlockMutex ( levelSpoolerPCMutex ) ;
2020-04-11 17:04:02 +02:00
// clear sector before proceed
ClearMem ( g_sectorData , sizeof ( g_sectorData ) ) ;
fread ( g_sectorData , 1 , 2048 , fp ) ;
g_isSectorDataRead = false ;
if ( readyCb )
{
2020-05-12 10:39:31 +02:00
readyCb ( 1 , { 0x0 } ) ;
2020-04-11 20:15:11 +02:00
if ( g_isSectorDataRead & & dataCb )
dataCb ( ) ;
2020-04-11 17:04:02 +02:00
}
else
break ;
2020-04-19 14:32:14 +02:00
2020-04-12 17:29:49 +02:00
} while ( ! g_spoolDoneFlag ) ;
2020-04-11 17:04:02 +02:00
2020-05-14 08:57:20 +02:00
printInfo ( " SPOOLER thread work done. \n " ) ;
2020-04-11 17:04:02 +02:00
fclose ( fp ) ;
return 0 ;
}
//-----------------------------------------------------
// reads sector from LEV file
//-----------------------------------------------------
void startReadLevSectorsPC ( int sector )
{
2020-04-12 17:48:56 +02:00
if ( ! levelSpoolerPCMutex )
levelSpoolerPCMutex = SDL_CreateMutex ( ) ;
SDL_LockMutex ( levelSpoolerPCMutex ) ;
2020-04-11 17:04:02 +02:00
levelSpoolerSeekCmd = sector ;
2020-04-12 17:48:56 +02:00
SDL_UnlockMutex ( levelSpoolerPCMutex ) ;
2020-04-11 17:04:02 +02:00
2020-04-12 15:56:52 +02:00
if ( levelSpoolerPCThread & & g_spoolDoneFlag )
2020-04-11 17:04:02 +02:00
{
int returnValue ;
SDL_WaitThread ( levelSpoolerPCThread , & returnValue ) ;
levelSpoolerPCThread = NULL ;
}
if ( ! levelSpoolerPCThread )
{
levelSpoolerPCThread = SDL_CreateThread ( levelSpoolerPCFunc , " Spooler " , NULL ) ;
if ( NULL = = levelSpoolerPCThread )
{
2020-05-14 08:57:20 +02:00
printError ( " SDL_CreateThread failed: %s \n " , SDL_GetError ( ) ) ;
2020-04-11 17:04:02 +02:00
}
}
}
# endif // !PSX
2020-03-27 21:47:29 +01:00
// decompiled code
// original method signature:
// void /*$ra*/ test_changemode()
// line 532, offset 0x0007b228
/* begin block 1 */
// Start line: 534
// Start offset: 0x0007B228
// Variables:
// struct SPOOLQ *current; // $a3
/* end block 1 */
// End offset: 0x0007B3B4
// End Line: 588
/* begin block 2 */
// Start line: 1064
/* end block 2 */
// End Line: 1065
/* begin block 3 */
// Start line: 1065
/* end block 3 */
// End Line: 1066
/* begin block 4 */
// Start line: 1067
/* end block 4 */
// End Line: 1068
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void test_changemode ( void )
{
2020-05-12 10:39:31 +02:00
# ifndef SIMPLE_SPOOL
2020-04-10 01:29:12 +02:00
char bVar1 ;
2020-04-04 06:49:28 +02:00
2020-05-12 10:39:31 +02:00
SPOOLQ * current = & spooldata [ spoolpos_reading ] ;
2020-04-10 01:29:12 +02:00
if ( spoolpos_reading = = spoolcounter )
{
2020-04-04 06:49:28 +02:00
switch_spooltype = 0 ;
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-04 06:49:28 +02:00
CdReadyCallback ( 0 ) ;
2020-04-11 13:21:25 +02:00
CdControlF ( CdlPause , 0 ) ;
2020-04-11 17:04:02 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCReadyCallback ( NULL ) ;
2020-04-11 17:04:02 +02:00
levelSpoolerSeekCmd = - 1 ;
# endif // PSX
2020-04-04 06:49:28 +02:00
}
2020-05-12 10:39:31 +02:00
else if ( current_sector = = current - > sector )
2020-04-10 01:29:12 +02:00
{
2020-05-12 10:39:31 +02:00
target_address = current - > addr ;
bVar1 = current - > type ;
2020-04-10 01:29:12 +02:00
switch_spooltype = 1 ;
if ( bVar1 = = 0 )
{
sectors_to_read = spool_regioninfo [ spool_regionpos + 1 ] . nsectors ;
2020-05-12 10:39:31 +02:00
sectors_this_chunk = ( current - > nsectors ) ;
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-10 01:29:12 +02:00
CdReadyCallback ( ready_cb_regions ) ;
2020-04-11 17:04:02 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCReadyCallback ( ready_cb_regions ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:29:12 +02:00
else if ( bVar1 = = 1 )
{
2020-05-11 20:34:38 +02:00
sectors_to_read = 17 ;
target_address + = 0x4000 ;
2020-04-10 01:29:12 +02:00
nTPchunks_reading = 0 ;
nTPchunks_writing = 0 ;
ntpages = tsetcounter ;
sectors_this_chunk = ( uint ) bVar1 ;
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-10 01:29:12 +02:00
CdReadyCallback ( ready_cb_textures ) ;
2020-04-11 17:04:02 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCReadyCallback ( ready_cb_textures ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-04-10 01:29:12 +02:00
}
else if ( bVar1 = = 2 )
{
2020-05-12 10:39:31 +02:00
sectors_to_read = ( current - > nsectors ) ;
send_bank = ( current - > data ) ;
2020-04-10 01:29:12 +02:00
sample_chunk = 0 ;
nTPchunks_reading = 0 ;
nTPchunks_writing = 0 ;
target_address = target_address + ( loadbank_read & 1U ) * 0x1000 ;
sectors_this_chunk = ( uint ) bVar1 ;
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-10 01:29:12 +02:00
CdReadyCallback ( ready_cb_soundbank ) ;
2020-04-11 17:04:02 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCReadyCallback ( ready_cb_soundbank ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-04-10 01:29:12 +02:00
}
else if ( bVar1 = = 3 )
{
2020-05-12 10:39:31 +02:00
sectors_to_read = ( current - > nsectors ) ;
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-10 01:29:12 +02:00
CdReadyCallback ( ready_cb_misc ) ;
2020-04-11 17:04:02 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCReadyCallback ( ready_cb_misc ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-04-04 06:49:28 +02:00
}
}
2020-04-10 01:29:12 +02:00
else
{
switch_spooltype = 0 ;
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-10 01:29:12 +02:00
CdReadyCallback ( 0 ) ;
2020-04-11 17:04:02 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCReadyCallback ( NULL ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-04-10 01:29:12 +02:00
}
2020-05-12 10:39:31 +02:00
# endif // SIMPLE_SPOOL
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ changemode(struct SPOOLQ *current /*$a0*/)
// line 591, offset 0x0007e1a8
/* begin block 1 */
// Start line: 1182
/* end block 1 */
// End Line: 1183
/* begin block 2 */
// Start line: 5397
/* end block 2 */
// End Line: 5398
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void changemode ( SPOOLQ * current )
{
2020-05-12 10:39:31 +02:00
# ifndef SIMPLE_SPOOL
2020-04-04 06:49:28 +02:00
switch_spooltype = 0 ;
endchunk = 0 ;
2020-04-10 01:29:12 +02:00
2020-05-12 10:39:31 +02:00
switch ( current - > type )
2020-04-10 01:29:12 +02:00
{
2020-05-12 10:39:31 +02:00
case 0 :
{
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-05-12 10:39:31 +02:00
CdDataCallback ( data_cb_regions ) ;
2020-04-11 17:04:02 +02:00
# else
2020-05-12 10:39:31 +02:00
levelSpoolerPCDataCallback ( data_cb_regions ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-05-12 10:39:31 +02:00
break ;
}
case 1 :
{
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-05-12 10:39:31 +02:00
CdDataCallback ( data_cb_textures ) ;
2020-04-11 17:04:02 +02:00
# else
2020-05-12 10:39:31 +02:00
levelSpoolerPCDataCallback ( data_cb_textures ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-05-12 10:39:31 +02:00
break ;
}
case 2 :
{
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-05-12 10:39:31 +02:00
CdDataCallback ( data_cb_soundbank ) ;
2020-04-11 17:04:02 +02:00
# else
2020-05-12 10:39:31 +02:00
levelSpoolerPCDataCallback ( data_cb_soundbank ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-05-12 10:39:31 +02:00
break ;
}
case 3 :
{
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-05-12 10:39:31 +02:00
CdDataCallback ( data_cb_misc ) ;
2020-04-11 17:04:02 +02:00
# else
2020-05-12 10:39:31 +02:00
levelSpoolerPCDataCallback ( data_cb_misc ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-05-12 10:39:31 +02:00
break ;
}
2020-04-04 06:49:28 +02:00
}
2020-05-12 10:39:31 +02:00
# endif // SIMPLE_SPOOL
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// int /*$ra*/ check_regions_present()
// line 625, offset 0x0007b3c4
/* begin block 1 */
// Start line: 627
// Start offset: 0x0007B3C4
// Variables:
// struct AREA_LOAD_INFO regions_to_unpack[3]; // stack offset -160
// int leftright_unpack; // $a2
// int topbottom_unpack; // $a3
// int num_regions_to_unpack; // $a1
// int x; // $v1
// int z; // $v0
// int loop; // $t1
// int retval; // $a3
// int region_to_unpack; // $a0
// int barrel_region; // $v1
// char textbuf[128]; // stack offset -136
/* end block 1 */
// End offset: 0x0007B6C4
// End Line: 771
/* begin block 2 */
// Start line: 1267
/* end block 2 */
// End Line: 1268
/* begin block 3 */
// Start line: 1268
/* end block 3 */
// End Line: 1269
/* begin block 4 */
// Start line: 1269
/* end block 4 */
// End Line: 1270
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 13:56:11 +02:00
// [D]
2020-03-27 21:47:29 +01:00
int check_regions_present ( void )
{
2020-04-10 13:56:11 +02:00
AREA_LOAD_INFO * pAVar1 ;
2020-04-04 06:49:28 +02:00
int iVar2 ;
int iVar3 ;
int iVar4 ;
int iVar5 ;
2020-04-10 13:56:11 +02:00
AREA_LOAD_INFO * pAVar6 ;
AREA_LOAD_INFO region_to_unpack [ 3 ] ;
char textbuf [ 128 ] ;
2020-04-04 06:49:28 +02:00
2020-04-10 13:56:11 +02:00
pAVar6 = region_to_unpack ;
2020-04-04 06:49:28 +02:00
iVar4 = 0 ;
iVar5 = 0 ;
iVar3 = 0 ;
if ( current_barrel_region_xcell < 9 ) {
2020-04-10 13:56:11 +02:00
region_to_unpack [ 0 ] . xoffset = - 1 ;
2020-04-04 06:49:28 +02:00
if ( region_x ! = 0 ) {
iVar4 = 1 ;
LAB_0007b44c :
iVar3 = 1 ;
2020-04-10 13:56:11 +02:00
region_to_unpack [ 0 ] . zoffset = 0 ;
2020-04-04 06:49:28 +02:00
}
}
else {
if ( 0x17 < current_barrel_region_xcell ) {
iVar2 = cells_across ;
if ( cells_across < 0 ) {
iVar2 = cells_across + 0x1f ;
}
2020-04-10 13:56:11 +02:00
region_to_unpack [ 0 ] . xoffset = 1 ;
2020-04-04 06:49:28 +02:00
if ( region_x < iVar2 > > 5 ) {
iVar4 = 2 ;
goto LAB_0007b44c ;
}
}
}
if ( current_barrel_region_zcell < 9 ) {
if ( region_z = = 0 ) goto LAB_0007b4e0 ;
iVar5 = 1 ;
2020-04-10 13:56:11 +02:00
region_to_unpack [ iVar3 ] . xoffset = 0 ;
2020-04-04 06:49:28 +02:00
iVar2 = - 1 ;
}
else {
if ( ( current_barrel_region_zcell < 0x18 ) | | ( region_z = = 0 ) ) goto LAB_0007b4e0 ;
iVar5 = 2 ;
2020-04-10 13:56:11 +02:00
region_to_unpack [ iVar3 ] . xoffset = 0 ;
2020-04-04 06:49:28 +02:00
iVar2 = 1 ;
}
2020-04-10 13:56:11 +02:00
pAVar1 = region_to_unpack + iVar3 ;
2020-04-04 06:49:28 +02:00
iVar3 = iVar3 + 1 ;
2020-04-10 13:56:11 +02:00
pAVar1 - > zoffset = iVar2 ;
2020-03-27 21:47:29 +01:00
LAB_0007b4e0 :
2020-04-04 06:49:28 +02:00
if ( iVar3 = = 2 ) {
if ( iVar5 = = 1 ) {
iVar3 = 3 ;
if ( iVar4 = = 1 ) {
2020-04-10 13:56:11 +02:00
region_to_unpack [ 2 ] . xoffset = - 1 ;
region_to_unpack [ 2 ] . zoffset = - 1 ;
2020-04-04 06:49:28 +02:00
}
else {
2020-04-10 13:56:11 +02:00
region_to_unpack [ 2 ] . xoffset = 1 ;
region_to_unpack [ 2 ] . zoffset = - 1 ;
2020-04-04 06:49:28 +02:00
}
}
else {
iVar3 = 3 ;
if ( iVar4 = = 1 ) {
2020-04-10 13:56:11 +02:00
region_to_unpack [ 2 ] . xoffset = - 1 ;
2020-04-04 06:49:28 +02:00
}
else {
2020-04-10 13:56:11 +02:00
region_to_unpack [ 2 ] . xoffset = 1 ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 13:56:11 +02:00
region_to_unpack [ 2 ] . zoffset = 1 ;
2020-04-04 06:49:28 +02:00
}
}
iVar4 = 0 ;
while ( iVar3 ! = 0 ) {
iVar5 = cells_across ;
if ( cells_across < 0 ) {
iVar5 = cells_across + 0x1f ;
}
2020-04-10 13:56:11 +02:00
iVar5 = current_region + * ( int * ) pAVar6 + ( ( int * ) pAVar6 ) [ 1 ] * ( iVar5 > > 5 ) ;
if ( ( ( ( int ) loading_region [ ( region_x + * ( int * ) pAVar6 & 1U ) + ( region_z + ( ( int * ) pAVar6 ) [ 1 ] & 1U ) * 2 ] ! =
- 1 ) & & ( spoolinfo_offsets [ iVar5 ] ! = 0xffff ) ) & &
( ( int ) loading_region
[ ( region_x + * ( int * ) pAVar6 & 1U ) + ( region_z + ( ( int * ) pAVar6 ) [ 1 ] & 1U ) * 2 ] = =
iVar5 ) ) {
2020-04-04 06:49:28 +02:00
iVar4 = iVar4 + 1 ;
}
iVar3 = iVar3 + - 1 ;
2020-04-10 13:56:11 +02:00
pAVar6 = ( AREA_LOAD_INFO * ) ( ( int * ) pAVar6 + 2 ) ;
2020-04-04 06:49:28 +02:00
}
if ( LoadingArea ! = 0 ) {
if ( new_area_location = = 1 ) {
if ( 0x1a < current_barrel_region_xcell ) {
iVar4 = iVar4 + 1 ;
}
}
else {
if ( new_area_location < 2 ) {
if ( ( new_area_location = = 0 ) & & ( 0x1a < current_barrel_region_zcell ) ) {
iVar4 = iVar4 + 1 ;
}
}
else {
iVar3 = current_barrel_region_zcell ;
if ( ( ( new_area_location = = 2 ) | |
( iVar3 = current_barrel_region_xcell , new_area_location = = 3 ) ) & & ( iVar3 < 6 ) ) {
iVar4 = iVar4 + 1 ;
}
}
}
}
2020-04-10 13:56:11 +02:00
return iVar4 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ stopgame()
// line 818, offset 0x0007e958
/* begin block 1 */
// Start line: 822
// Start offset: 0x0007E958
/* end block 1 */
// End offset: 0x0007E9A0
// End Line: 827
/* begin block 2 */
// Start line: 1636
/* end block 2 */
// End Line: 1637
/* begin block 3 */
// Start line: 8809
/* end block 3 */
// End Line: 8810
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 13:56:11 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void stopgame ( void )
{
2020-04-04 06:49:28 +02:00
StopPadVibration ( 0 ) ;
StopPadVibration ( 1 ) ;
PauseSFX ( ) ;
DrawSync ( 0 ) ;
PutDrawEnv ( & last - > draw ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ startgame()
// line 829, offset 0x0007e9a0
/* begin block 1 */
// Start line: 831
// Start offset: 0x0007E9A0
/* end block 1 */
// End offset: 0x0007E9D0
// End Line: 833
/* begin block 2 */
// Start line: 8825
/* end block 2 */
// End Line: 8826
/* begin block 3 */
// Start line: 8828
/* end block 3 */
// End Line: 8829
/* begin block 4 */
// Start line: 8829
/* end block 4 */
// End Line: 8830
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 13:56:11 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void startgame ( void )
{
2020-04-04 06:49:28 +02:00
PutDrawEnv ( & current - > draw ) ;
UnPauseSFX ( ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ DrawCDicon()
// line 836, offset 0x0007e24c
/* begin block 1 */
// Start line: 838
// Start offset: 0x0007E24C
// Variables:
// unsigned short *palette; // $a1
// int temp; // $a2
// int i; // $a0
// struct RECT dest; // stack offset -16
/* end block 1 */
// End offset: 0x0007E2CC
// End Line: 856
/* begin block 2 */
// Start line: 5885
/* end block 2 */
// End Line: 5886
/* begin block 3 */
// Start line: 5886
/* end block 3 */
// End Line: 5887
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 13:56:11 +02:00
extern POLY_FT4 cd_sprite ;
extern unsigned short cd_icon [ 288 ] ;
// [D]
2020-03-27 21:47:29 +01:00
void DrawCDicon ( void )
{
2020-04-10 13:56:11 +02:00
ushort * puVar1 ;
2020-04-04 06:49:28 +02:00
int iVar2 ;
2020-04-10 13:56:11 +02:00
RECT16 local_10 ;
2020-04-04 06:49:28 +02:00
2020-04-10 13:56:11 +02:00
cd_icon [ 23 ] = cd_icon [ 11 ] ;
2020-04-04 06:49:28 +02:00
iVar2 = 0xb ;
2020-04-10 13:56:11 +02:00
puVar1 = cd_icon + 10 ;
2020-04-04 06:49:28 +02:00
do {
iVar2 = iVar2 + - 1 ;
puVar1 [ 1 ] = puVar1 [ 2 ] ;
puVar1 = puVar1 + 1 ;
} while ( - 1 < iVar2 ) ;
2020-04-10 13:56:11 +02:00
local_10 . x = 960 ;
local_10 . y = 433 ;
local_10 . w = 16 ;
local_10 . h = 1 ;
LoadImage ( & local_10 , ( u_long * ) ( cd_icon + 10 ) ) ;
2020-04-04 06:49:28 +02:00
DrawPrim ( & cd_sprite ) ;
DrawSync ( 0 ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ CheckValidSpoolData()
// line 859, offset 0x0007e2cc
/* begin block 1 */
// Start line: 861
// Start offset: 0x0007E2CC
// Variables:
// struct RECT dest; // stack offset -16
/* end block 1 */
// End offset: 0x0007E35C
// End Line: 918
/* begin block 2 */
// Start line: 5946
/* end block 2 */
// End Line: 5947
/* begin block 3 */
// Start line: 5950
/* end block 3 */
// End Line: 5951
/* begin block 4 */
// Start line: 5951
/* end block 4 */
// End Line: 5952
/* begin block 5 */
// Start line: 5962
/* end block 5 */
// End Line: 5963
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void CheckValidSpoolData ( void )
{
2020-05-16 14:33:44 +02:00
if ( models_ready ! = 0 )
2020-04-04 06:49:28 +02:00
init_spooled_models ( ) ;
2020-04-10 01:29:12 +02:00
if ( spoolactive ! = 0 )
{
2020-05-16 14:33:44 +02:00
if ( check_regions_present ( ) ! = 0 )
2020-04-10 01:29:12 +02:00
{
stopgame ( ) ;
while ( spoolactive ! = 0 )
{
DrawCDicon ( ) ;
VSync ( 0 ) ;
}
startgame ( ) ;
2020-04-19 12:53:18 +02:00
2020-04-10 01:29:12 +02:00
PutDrawEnv ( & current - > draw ) ;
UnPauseSFX ( ) ;
2020-04-04 06:49:28 +02:00
}
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ UpdateSpool()
// line 925, offset 0x0007b6c4
/* begin block 1 */
// Start line: 927
// Start offset: 0x0007B6C4
// Variables:
// struct SPOOLQ *current; // $s0
// struct CdlLOC pos; // stack offset -16
/* end block 1 */
// End offset: 0x0007B87C
// End Line: 977
/* begin block 2 */
// Start line: 1793
/* end block 2 */
// End Line: 1794
/* begin block 3 */
// Start line: 1903
/* end block 3 */
// End Line: 1904
/* begin block 4 */
// Start line: 1904
/* end block 4 */
// End Line: 1905
/* begin block 5 */
// Start line: 1908
/* end block 5 */
// End Line: 1909
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-09 20:50:21 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void UpdateSpool ( void )
{
2020-05-12 10:39:31 +02:00
# ifdef SIMPLE_SPOOL
extern char g_CurrentLevelFileName [ 64 ] ;
FILE * fp = fopen ( g_CurrentLevelFileName , " rb " ) ;
2020-05-13 11:57:51 +02:00
if ( ! fp )
{
char errPrint [ 1024 ] ;
sprintf ( errPrint , " Cannot open '%s' \n " , g_CurrentLevelFileName ) ;
SDL_ShowSimpleMessageBox ( SDL_MESSAGEBOX_ERROR , " ERROR " , errPrint , NULL ) ;
return ;
}
2020-05-12 10:39:31 +02:00
for ( ; spoolpos_reading < spoolcounter ; spoolpos_reading + + )
{
SPOOLQ * current = & spooldata [ spoolpos_reading ] ;
# ifdef _DEBUG
char * nameType ;
switch ( current - > type )
{
case 0 : // regions
2020-05-13 19:37:09 +02:00
nameType = " REGION " ;
2020-05-12 10:39:31 +02:00
break ;
case 1 : // textures
nameType = " TPAGE " ;
break ;
case 2 : // sbk
nameType = " SBK " ;
break ;
case 3 : // misc
nameType = " MISC " ;
break ;
}
2020-05-14 08:57:20 +02:00
printWarning ( " spool type=%s cb=%d sec=%d cnt=%d id=%d \n " , nameType , current - > func ? 1 : 0 , current - > sector , current - > nsectors , spoolpos_reading ) ;
2020-05-12 10:39:31 +02:00
# endif // _DEBUG
// seek to required sector
fseek ( fp , current - > sector * 2048 , SEEK_SET ) ;
switch ( current - > type )
{
case 0 : // regions
fread ( current - > addr , 2048 , current - > nsectors , fp ) ;
if ( current - > func )
current - > func ( ) ;
break ;
case 1 : // textures
// read cluts
nTPchunks = 0 ;
fread ( current - > addr + 0x4000 , 2048 , 1 , fp ) ;
SendTPage ( ) ;
nTPchunks + + ;
// read tpage (4 sectors 4 times = 16)
for ( int i = 0 ; i < 4 ; i + + )
{
fread ( current - > addr + ( loadbank_write & 1U ) * TPAGE_WIDTH * 32 , 2048 , 4 , fp ) ;
SendTPage ( ) ;
nTPchunks + + ;
}
break ;
case 2 : // sbk
// nothing to do with this
break ;
case 3 : // misc
fread ( current - > addr , 2048 , current - > nsectors , fp ) ;
if ( current - > func )
current - > func ( ) ;
break ;
}
}
spoolcounter = 0 ;
spoolpos_reading = 0 ;
spoolactive = 0 ;
2020-05-13 11:57:51 +02:00
fclose ( fp ) ;
2020-05-12 10:39:31 +02:00
# else
2020-04-09 20:50:21 +02:00
char bVar1 ;
2020-04-04 06:49:28 +02:00
int iVar3 ;
2020-04-09 20:50:21 +02:00
CdlLOC pos ;
2020-04-04 06:49:28 +02:00
iVar3 = XAPrepared ( ) ;
2020-04-09 20:50:21 +02:00
2020-05-12 10:39:31 +02:00
SPOOLQ * current = & spooldata [ spoolpos_reading ] ;
2020-04-09 20:50:21 +02:00
if ( iVar3 ! = 1 )
{
2020-05-12 10:39:31 +02:00
target_address = current - > addr ;
bVar1 = current - > type ;
2020-04-09 20:50:21 +02:00
if ( bVar1 = = 0 ) // SPOOLTYPE_REGIONS
{
2020-05-12 10:39:31 +02:00
sectors_this_chunk = ( current - > nsectors ) ;
2020-04-09 20:50:21 +02:00
sectors_to_read = spool_regioninfo [ spool_regionpos ] . nsectors ;
2020-04-04 06:49:28 +02:00
spoolseek = 5 ;
2020-04-09 21:32:19 +02:00
# ifdef PSX
2020-04-09 20:50:21 +02:00
CdDataCallback ( data_cb_regions ) ;
CdReadyCallback ( ready_cb_regions ) ;
2020-04-09 21:32:19 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCDataCallback ( data_cb_regions ) ;
levelSpoolerPCReadyCallback ( ready_cb_regions ) ;
2020-04-09 21:32:19 +02:00
# endif // PSX
2020-04-09 20:50:21 +02:00
}
else if ( bVar1 = = 1 ) // SPOOLTYPE_TEXTURES
{
spoolseek = 5 ;
2020-04-04 06:49:28 +02:00
nTPchunks_reading = 0 ;
nTPchunks_writing = 0 ;
2020-04-11 17:04:02 +02:00
sectors_to_read = 17 ;
2020-04-04 06:49:28 +02:00
ntpages = tsetcounter ;
sectors_this_chunk = ( uint ) bVar1 ;
2020-04-09 20:50:21 +02:00
2020-04-09 21:32:19 +02:00
# ifdef PSX
2020-04-04 06:49:28 +02:00
CdDataCallback ( data_cb_textures ) ;
CdReadyCallback ( ready_cb_textures ) ;
2020-04-11 17:04:02 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCDataCallback ( data_cb_textures ) ;
levelSpoolerPCReadyCallback ( ready_cb_textures ) ;
2020-04-09 21:32:19 +02:00
# endif // PSX
2020-04-09 20:50:21 +02:00
2020-04-04 06:49:28 +02:00
target_address = target_address + 0x4000 ;
}
2020-04-09 20:50:21 +02:00
else if ( bVar1 = = 2 ) // SPOOLTYPE_SOUNDBANK
{
2020-05-12 10:39:31 +02:00
sectors_to_read = ( current - > nsectors ) ;
2020-04-09 20:50:21 +02:00
2020-05-12 10:39:31 +02:00
send_bank = ( current - > data ) ;
2020-04-09 20:50:21 +02:00
spoolseek = 5 ;
sample_chunk = 0 ;
nTPchunks_reading = 0 ;
nTPchunks_writing = 0 ;
sectors_this_chunk = ( uint ) bVar1 ;
2020-04-09 21:32:19 +02:00
# ifdef PSX
2020-04-09 20:50:21 +02:00
CdDataCallback ( data_cb_soundbank ) ;
CdReadyCallback ( ready_cb_soundbank ) ;
2020-04-09 21:32:19 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCDataCallback ( data_cb_soundbank ) ;
levelSpoolerPCReadyCallback ( ready_cb_soundbank ) ;
2020-04-09 21:32:19 +02:00
# endif // PSX
2020-04-09 20:50:21 +02:00
target_address = target_address + ( loadbank_read & 1U ) * 0x1000 ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:29:12 +02:00
else if ( bVar1 = = 3 ) // SPOOLTYPE_MISC
2020-04-09 20:50:21 +02:00
{
2020-05-12 10:39:31 +02:00
sectors_to_read = ( current - > nsectors ) ;
2020-04-09 20:50:21 +02:00
spoolseek = 5 ;
2020-04-09 21:32:19 +02:00
# ifdef PSX
2020-04-09 20:50:21 +02:00
CdDataCallback ( data_cb_misc ) ;
CdReadyCallback ( ready_cb_misc ) ;
2020-04-09 21:32:19 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCDataCallback ( data_cb_misc ) ;
levelSpoolerPCReadyCallback ( ready_cb_misc ) ;
2020-04-09 21:32:19 +02:00
# endif // PSX
2020-04-09 20:50:21 +02:00
}
2020-05-12 10:39:31 +02:00
current_sector = current - > sector ;
2020-04-04 06:49:28 +02:00
endchunk = 0 ;
switch_spooltype = 0 ;
2020-04-09 20:50:21 +02:00
2020-04-11 17:04:02 +02:00
// run sector reading
2020-04-09 21:32:19 +02:00
# ifdef PSX
2020-04-09 20:50:21 +02:00
CdIntToPos ( current_sector , & pos ) ;
2020-04-11 13:21:25 +02:00
CdControlF ( CdlReadS , ( u_char * ) & pos ) ;
# else
2020-04-11 17:04:02 +02:00
startReadLevSectorsPC ( current_sector ) ;
2020-04-09 21:32:19 +02:00
# endif // PSX
2020-04-04 06:49:28 +02:00
}
2020-05-12 10:39:31 +02:00
# endif
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ RequestSpool(int type /*$a0*/, int data /*$a1*/, int offset /*$a2*/, int loadsize /*$a3*/, char *address /*stack 16*/, TDRFuncPtr_RequestSpool5func func /*stack 20*/)
// line 1104, offset 0x0007e36c
/* begin block 1 */
// Start line: 1105
// Start offset: 0x0007E36C
// Variables:
// struct SPOOLQ *next; // $t0
// int sector; // $v0
/* end block 1 */
// End offset: 0x0007E3E4
// End Line: 1126
/* begin block 2 */
// Start line: 6440
/* end block 2 */
// End Line: 6441
/* begin block 3 */
// Start line: 6447
/* end block 3 */
// End Line: 6448
2020-04-09 20:50:21 +02:00
// [D]
2020-04-20 06:55:53 +02:00
# ifdef _DEBUG
void _RequestSpool ( int type , int data , int offset , int loadsize , char * address , spooledFuncPtr func , const char * requestby , int line )
2020-05-12 06:13:05 +02:00
# define RequestSpool(type, data, offset, loadsize, loadaddr, func) _RequestSpool(type, data, offset, loadsize, loadaddr, func, __FUNCTION__, __LINE__)
2020-04-20 06:55:53 +02:00
# else
2020-04-04 06:49:28 +02:00
void RequestSpool ( int type , int data , int offset , int loadsize , char * address , spooledFuncPtr func )
2020-04-20 06:55:53 +02:00
# endif _DEBUG
2020-03-27 21:47:29 +01:00
{
2020-05-13 08:20:21 +02:00
if ( ! ( spoolcounter < 48 ) )
trap ( 0x400 ) ;
2020-05-11 20:34:38 +02:00
SPOOLQ * next ;
2020-04-09 20:50:21 +02:00
next = & spooldata [ spoolcounter ] ;
2020-05-11 20:34:38 +02:00
next - > type = type ;
next - > data = data ;
2020-05-13 11:57:51 +02:00
next - > sector = ( citylumps [ GameLevel ] [ CITYLUMP_SPOOL ] . x / 2048 ) + offset ;
2020-05-11 20:34:38 +02:00
next - > nsectors = loadsize ;
2020-04-09 20:50:21 +02:00
next - > addr = address ;
next - > func = func ;
2020-04-20 06:55:53 +02:00
# ifdef _DEBUG
next - > requestby = requestby ;
next - > requestbyline = line ;
# endif // _DEBUG
2020-04-09 20:50:21 +02:00
spoolcounter + + ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ InitSpooling()
// line 1129, offset 0x0007e494
/* begin block 1 */
// Start line: 1131
// Start offset: 0x0007E494
// Variables:
// int i; // $s0
// char namebuffer[128]; // stack offset -152
// struct CdlLOC pos; // stack offset -24
/* end block 1 */
// End offset: 0x0007E528
// End Line: 1158
/* begin block 2 */
// Start line: 7099
/* end block 2 */
// End Line: 7100
/* begin block 3 */
// Start line: 2258
/* end block 3 */
// End Line: 2259
/* begin block 4 */
// Start line: 7100
/* end block 4 */
// End Line: 7101
/* begin block 5 */
// Start line: 7105
/* end block 5 */
// End Line: 7106
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-09 19:10:34 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void InitSpooling ( void )
{
2020-04-04 06:49:28 +02:00
int target_region ;
target_region = 0 ;
2020-04-09 19:10:34 +02:00
2020-04-04 06:49:28 +02:00
do {
2020-05-11 20:34:38 +02:00
loading_region [ target_region ] = - 1 ;
2020-04-04 06:49:28 +02:00
ClearRegion ( target_region ) ;
2020-05-11 20:34:38 +02:00
target_region + + ;
2020-04-04 06:49:28 +02:00
} while ( target_region < 4 ) ;
2020-04-09 19:10:34 +02:00
2020-05-16 14:33:44 +02:00
newmodels = NULL ;
2020-04-04 06:49:28 +02:00
spool_regioncounter = 0 ;
spoolerror = 0 ;
spool_regionpos = 0 ;
spoolactive = 0 ;
tsetcounter = 0 ;
models_ready = 0 ;
tsetpos = 0 ;
spoolcounter = 0 ;
loadbank_read = 0 ;
spoolpos = 0 ;
unpack_roadmap_flag = 0 ;
loadbank_write = 0 ;
spoolseek = 0 ;
unpack_cellptr_flag = 0 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ SendTPage()
// line 1161, offset 0x0007b88c
/* begin block 1 */
// Start line: 1163
// Start offset: 0x0007B88C
// Variables:
// int tpage2send; // $s2
// int slot; // $s0
// int old; // $v1
// char *tpageaddress; // $t0
/* begin block 1.1 */
// Start line: 1176
// Start offset: 0x0007B900
// Variables:
// struct RECT cluts; // stack offset -32
// int npalettes; // $s1
// int i; // $a3
// unsigned long *clutptr; // $a1
/* end block 1.1 */
// End offset: 0x0007BA24
// End Line: 1208
/* end block 1 */
// End offset: 0x0007BB14
// End Line: 1235
/* begin block 2 */
// Start line: 2385
/* end block 2 */
// End Line: 2386
/* begin block 3 */
// Start line: 2386
/* end block 3 */
// End Line: 2387
/* begin block 4 */
// Start line: 2390
/* end block 4 */
// End Line: 2391
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
int tsetinfo [ 32 ] ;
// [D]
2020-03-27 21:47:29 +01:00
void SendTPage ( void )
{
2020-04-10 01:29:12 +02:00
unsigned char bVar1 ;
2020-05-12 06:46:52 +02:00
ulong * clutptr ;
2020-04-04 06:49:28 +02:00
int iVar5 ;
2020-05-12 06:46:52 +02:00
int npalettes ;
2020-04-04 06:49:28 +02:00
int iVar7 ;
2020-04-10 01:29:12 +02:00
RECT16 cluts ;
2020-04-04 06:49:28 +02:00
iVar7 = tsetinfo [ tsetpos * 2 ] ;
2020-05-12 06:46:52 +02:00
iVar5 = tsetinfo [ tsetpos * 2 + 1 ] ;
2020-04-10 01:29:12 +02:00
2020-05-12 10:39:31 +02:00
if ( iVar7 = = 0xFF | | iVar5 = = 0xFF ) // [A] bug fix
return ;
2020-04-10 01:29:12 +02:00
if ( nTPchunks = = 0 )
{
2020-05-12 10:39:31 +02:00
if ( iVar5 ! = tpageloaded [ iVar7 ] - 1 )
2020-04-10 01:29:12 +02:00
{
2020-05-12 06:46:52 +02:00
npalettes = * ( int * ) ( model_spool_buffer + 0xE000 ) ;
2020-04-10 01:29:12 +02:00
tpage . w = 64 ;
tpage . h = 64 ;
cluts . w = 64 ;
2020-05-12 06:46:52 +02:00
tpage . x = slot_tpagepos [ iVar5 ] . vx ;
2020-04-10 01:29:12 +02:00
tpage . y = slot_tpagepos [ iVar5 ] . vy ;
2020-05-12 06:46:52 +02:00
2020-04-10 01:29:12 +02:00
cluts . y = slot_clutpos [ iVar5 ] . vy ;
cluts . x = slot_clutpos [ iVar5 ] . vx ;
2020-05-12 06:46:52 +02:00
cluts . h = npalettes / 4 + 1 ;
LoadImage ( & cluts , ( u_long * ) ( model_spool_buffer + 0xE000 + 4 ) ) ;
2020-04-10 01:29:12 +02:00
2020-05-12 06:46:52 +02:00
clutptr = ( ulong * ) ( texture_cluts [ iVar7 ] ) ;
2020-04-04 06:49:28 +02:00
iVar5 = 0 ;
2020-04-10 01:29:12 +02:00
2020-05-12 06:46:52 +02:00
if ( 0 < npalettes )
2020-04-10 01:29:12 +02:00
{
2020-04-04 06:49:28 +02:00
do {
2020-05-12 06:46:52 +02:00
//int test1 = (uVar3 | iVar2 + 0x10 >> 4 & 0x3fU) << 0x10 | uVar3 | (int)((uint)cluts.x << 0x10) >> 0x14 & 0x3fU;
//int test2 = (uVar3 | iVar2 + 0x30 >> 4 & 0x3fU) << 0x10 | uVar3 | iVar2 + 0x20 >> 4 & 0x3fU;
2020-04-10 01:29:12 +02:00
2020-05-12 06:46:52 +02:00
clutptr [ 0 ] = getClut ( cluts . x + 16 , cluts . y ) < < 0x10 | getClut ( cluts . x , cluts . y ) ;
clutptr [ 1 ] = getClut ( cluts . x + 48 , cluts . y ) < < 0x10 | getClut ( cluts . x + 32 , cluts . y ) ;
2020-04-10 01:29:12 +02:00
2020-05-12 06:46:52 +02:00
clutptr + = 2 ;
cluts . y + + ;
iVar5 + = 4 ; ;
} while ( iVar5 < npalettes ) ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:29:12 +02:00
2020-05-12 06:46:52 +02:00
texture_pages [ iVar7 ] = getTPage ( 0 , 0 , tpage . x , tpage . y ) ;
// OLD VALUE: (short)(tpage.y & 0x100U) >> 4 | (ushort)(((uint)(ushort)tpage.x & 0x3ff) >> 6) | (ushort)(((uint)(ushort)tpage.y & 0x200) << 2);
// please check me if above is correct
2020-04-04 06:49:28 +02:00
}
}
2020-04-10 01:29:12 +02:00
else
{
2020-05-12 06:46:52 +02:00
if ( iVar5 ! = tpageloaded [ iVar7 ] - 1 )
2020-04-10 01:29:12 +02:00
{
2020-05-12 10:39:31 +02:00
LoadImage ( & tpage , ( u_long * ) ( model_spool_buffer + 0xA000 + ( loadbank_write % 2 ) * TPAGE_WIDTH * 32 ) ) ;
2020-04-04 06:49:28 +02:00
tpage . y = tpage . y + tpage . h ;
}
2020-04-10 01:29:12 +02:00
2020-04-11 18:34:29 +02:00
if ( nTPchunks = = 4 )
2020-04-10 01:29:12 +02:00
{
2020-04-11 18:34:29 +02:00
bVar1 = tpageslots [ iVar5 ] ;
2020-05-12 06:46:52 +02:00
tpageslots [ iVar5 ] = iVar7 ;
2020-04-10 01:29:12 +02:00
2020-05-12 06:46:52 +02:00
if ( bVar1 ! = 0xFF ) // [A] bug fix
tpageloaded [ bVar1 ] = 0 ;
2020-04-11 18:34:29 +02:00
2020-05-12 06:46:52 +02:00
tpageloaded [ iVar7 ] = iVar5 + 1 ;
2020-04-11 18:34:29 +02:00
tsetpos + + ;
2020-05-12 06:46:52 +02:00
if ( tsetpos = = tsetcounter )
{
2020-04-04 06:49:28 +02:00
tsetcounter = 0 ;
tsetpos = 0 ;
}
}
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ SpoolSYNC()
// line 1239, offset 0x0007e528
/* begin block 1 */
// Start line: 7247
/* end block 1 */
// End Line: 7248
/* begin block 2 */
// Start line: 7329
/* end block 2 */
// End Line: 7330
/* begin block 3 */
// Start line: 7345
/* end block 3 */
// End Line: 7346
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SpoolSYNC ( void )
{
2020-04-04 06:49:28 +02:00
do {
} while ( spoolactive ! = 0 ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ LoadInAreaTSets(int area /*$t4*/)
// line 1262, offset 0x0007bb14
/* begin block 1 */
// Start line: 1263
// Start offset: 0x0007BB14
// Variables:
// unsigned char *tpages; // $s1
// int ntpages_to_load; // $s3
// int i; // $s0
// int slot; // $a0
// int j; // $a1
// int offset; // $s4
// int availableslots[16]; // stack offset -104
// int navailable; // $s2
// char *loadaddr; // $fp
/* end block 1 */
// End offset: 0x0007BD84
// End Line: 1333
/* begin block 2 */
// Start line: 2620
/* end block 2 */
// End Line: 2621
/* begin block 3 */
// Start line: 2648
/* end block 3 */
// End Line: 2649
/* begin block 4 */
// Start line: 2660
/* end block 4 */
// End Line: 2661
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void LoadInAreaTSets ( int area )
{
2020-04-04 06:49:28 +02:00
bool bVar1 ;
2020-05-12 06:13:05 +02:00
2020-04-04 06:49:28 +02:00
uint uVar3 ;
int iVar4 ;
2020-05-12 06:13:05 +02:00
int offset ;
2020-04-04 06:49:28 +02:00
int * piVar5 ;
2020-05-12 06:13:05 +02:00
int i ;
int slot ;
unsigned char * tpages ;
int ntpages_to_load ;
int navailable ;
char * loadaddr ;
2020-04-10 01:29:12 +02:00
int availableslots [ 16 ] ;
2020-04-04 06:49:28 +02:00
2020-05-12 06:13:05 +02:00
tpages = AreaTPages + area * 16 ;
ntpages_to_load = AreaData [ area ] . num_tpages ;
2020-04-11 18:03:57 +02:00
2020-05-12 06:59:42 +02:00
loadaddr = model_spool_buffer + 0xA000 ;
2020-05-12 06:13:05 +02:00
navailable = 0 ;
2020-04-11 18:03:57 +02:00
2020-05-12 06:13:05 +02:00
if ( slotsused < 19 )
2020-04-11 18:03:57 +02:00
{
2020-04-10 01:29:12 +02:00
piVar5 = availableslots ;
2020-05-12 06:13:05 +02:00
slot = slotsused ;
2020-04-04 06:49:28 +02:00
do {
offset = 0 ;
2020-04-10 01:29:12 +02:00
2020-05-12 06:13:05 +02:00
if ( tpageslots [ slot ] = = 0xff ) // [A]
2020-04-10 01:29:12 +02:00
{
2020-05-12 06:13:05 +02:00
* piVar5 + + = slot ;
navailable + + ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:29:12 +02:00
else
{
2020-05-12 06:13:05 +02:00
if ( ntpages_to_load ! = 0 & & tpageslots [ slot ] ! = * tpages ) // [A]
2020-04-10 01:29:12 +02:00
{
2020-04-04 06:49:28 +02:00
uVar3 = 1 ;
do {
offset = uVar3 ;
2020-05-11 20:34:38 +02:00
2020-05-12 06:13:05 +02:00
if ( ntpages_to_load < = offset )
2020-05-11 20:34:38 +02:00
break ;
2020-04-04 06:49:28 +02:00
uVar3 = offset + 1 ;
2020-05-12 06:13:05 +02:00
} while ( tpageslots [ slot ] ! = tpages [ offset ] ) ; // [A]
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:29:12 +02:00
2020-05-12 06:13:05 +02:00
if ( offset = = ntpages_to_load )
2020-04-10 01:29:12 +02:00
{
2020-05-12 06:13:05 +02:00
* piVar5 + + = slot ;
navailable + + ;
2020-04-04 06:49:28 +02:00
}
}
2020-05-12 06:13:05 +02:00
slot + + ;
} while ( slot < 19 ) ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:29:12 +02:00
2020-05-12 06:13:05 +02:00
offset = AreaData [ area ] . gfx_offset ;
i = 0 ;
2020-04-10 01:29:12 +02:00
2020-05-12 06:13:05 +02:00
if ( ntpages_to_load ! = 0 )
2020-04-10 01:29:12 +02:00
{
2020-05-12 06:13:05 +02:00
uVar3 = * tpages ;
2020-04-10 01:29:12 +02:00
2020-05-12 06:13:05 +02:00
if ( tpageloaded [ uVar3 ] ! = 0 ) // weird goto lol
{
2020-04-10 01:29:12 +02:00
goto LAB_0007bc94 ;
2020-05-12 06:13:05 +02:00
}
2020-04-10 01:29:12 +02:00
2020-05-12 06:13:05 +02:00
bVar1 = 0 < navailable ;
navailable - - ;
2020-04-10 01:29:12 +02:00
if ( bVar1 )
{
2020-05-12 06:13:05 +02:00
iVar4 = availableslots [ navailable ] ;
2020-04-10 01:29:12 +02:00
while ( true )
{
2020-05-12 06:13:05 +02:00
tsetinfo [ tsetcounter * 2 + 1 ] = iVar4 ;
2020-04-10 01:29:12 +02:00
while ( true )
{
2020-05-12 06:13:05 +02:00
RequestSpool ( 1 , 0 , offset , 17 , loadaddr , SendTPage ) ;
offset + = 17 ;
2020-04-11 17:04:02 +02:00
2020-05-12 06:13:05 +02:00
i + + ;
tsetinfo [ tsetcounter * 2 ] = * tpages ;
2020-04-11 17:04:02 +02:00
2020-05-12 06:13:05 +02:00
tsetcounter + + ;
tpages + + ;
if ( ntpages_to_load < = i )
2020-04-04 06:49:28 +02:00
return ;
2020-04-11 17:04:02 +02:00
2020-05-12 06:13:05 +02:00
uVar3 = * tpages ;
2020-04-11 17:04:02 +02:00
2020-05-12 06:13:05 +02:00
if ( tpageloaded [ uVar3 ] = = 0 )
2020-04-11 17:04:02 +02:00
break ;
2020-05-12 06:13:05 +02:00
2020-04-04 06:49:28 +02:00
LAB_0007bc94 :
2020-05-12 06:13:05 +02:00
tsetinfo [ tsetcounter * 2 + 1 ] = tpageloaded [ uVar3 ] - 1 ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:29:12 +02:00
2020-05-12 06:13:05 +02:00
if ( navailable < 1 )
break ;
navailable - - ;
iVar4 = availableslots [ navailable ] ;
2020-04-04 06:49:28 +02:00
}
}
2020-04-11 18:03:57 +02:00
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ SendSBK()
// line 1337, offset 0x0007bd84
/* begin block 1 */
// Start line: 1339
// Start offset: 0x0007BD84
// Variables:
// char *address; // $s0
// int slength; // $s1
// int i; // $a1
// unsigned long *source; // $v0
// unsigned long *dest; // $a0
/* end block 1 */
// End offset: 0x0007BEBC
// End Line: 1380
/* begin block 2 */
// Start line: 2921
/* end block 2 */
// End Line: 2922
/* begin block 3 */
// Start line: 2926
/* end block 3 */
// End Line: 2927
/* begin block 4 */
// Start line: 2927
/* end block 4 */
// End Line: 2928
/* WARNING: Unknown calling convention yet parameter storage is locked */
void SendSBK ( void )
{
2020-04-04 06:49:28 +02:00
UNIMPLEMENTED ( ) ;
/*
ulong uVar1 ;
uint uVar2 ;
SAMPLE_DATA * pSVar3 ;
ulong * puVar4 ;
uint uVar5 ;
int * piVar6 ;
int iVar7 ;
piVar6 = ( int * ) ( model_spool_buffer + ( loadbank_write & 1U ) * 0x1000 + 0x8000 ) ;
if ( sample_chunk = = 0 ) {
if ( Song_ID ! = - 1 ) {
StopXM ( ) ;
FreeXM ( ) ;
}
uVar5 = 0 ;
pSVar3 = samples ;
num_samples = piVar6 [ 1 ] ;
uVar2 = num_samples < < 2 ;
puVar4 = ( ulong * ) ( piVar6 + 2 ) ;
if ( uVar2 ! = 0 ) {
do {
uVar1 = * puVar4 ;
puVar4 = puVar4 + 1 ;
uVar5 = uVar5 + 1 ;
pSVar3 - > address = uVar1 ;
pSVar3 = ( SAMPLE_DATA * ) & pSVar3 - > length ;
} while ( uVar5 < uVar2 ) ;
}
piVar6 = piVar6 + 1 + num_samples * 4 + 1 ;
spuaddress = ( & bankaddr ) [ send_bank ] ;
iVar7 = num_samples * - 0x10 + 0xff8 ;
}
else {
iVar7 = 0x1000 ;
}
SpuSetTransferMode ( 0 ) ;
SpuSetTransferStartAddr ( spuaddress ) ;
SpuWrite ( piVar6 , iVar7 + 0x3fU & 0xffffffc0 ) ;
spuaddress = spuaddress + iVar7 ;
sample_chunk = sample_chunk + 1 ;
return ;
*/
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ init_spooled_models()
// line 1484, offset 0x0007bebc
/* begin block 1 */
// Start line: 1486
// Start offset: 0x0007BEBC
// Variables:
// int i; // $s1
// int nmodels; // $s4
// int size; // $s2
// int model_number; // $a1
// char *addr; // $s0
// struct MODEL *parentmodel; // $a1
/* begin block 1.1 */
// Start line: 1519
// Start offset: 0x0007BFBC
/* end block 1.1 */
// End offset: 0x0007BFD0
// End Line: 1521
/* begin block 1.2 */
// Start line: 1528
// Start offset: 0x0007C004
/* end block 1.2 */
// End offset: 0x0007C048
// End Line: 1536
/* end block 1 */
// End offset: 0x0007C08C
// End Line: 1543
/* begin block 2 */
// Start line: 3131
/* end block 2 */
// End Line: 3132
/* begin block 3 */
// Start line: 3236
/* end block 3 */
// End Line: 3237
/* begin block 4 */
// Start line: 3237
/* end block 4 */
// End Line: 3238
/* begin block 5 */
// Start line: 3246
/* end block 5 */
// End Line: 3247
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void init_spooled_models ( void )
{
2020-05-11 20:10:50 +02:00
int nmodels ;
ushort lod ;
int model_number ;
2020-04-10 01:29:12 +02:00
MODEL * parentmodel ;
2020-05-11 20:10:50 +02:00
char * addr ;
MODEL * model ;
int i ;
int size ;
2020-04-04 06:49:28 +02:00
2020-05-11 20:10:50 +02:00
addr = model_spool_buffer ;
2020-04-04 06:49:28 +02:00
models_ready = 0 ;
2020-04-10 01:29:12 +02:00
2020-05-16 14:33:44 +02:00
nmodels = * newmodels ;
2020-04-10 01:29:12 +02:00
2020-05-16 14:33:44 +02:00
printInfo ( " loading %d model slots \n " , nmodels ) ;
//for (i = 0; i < 1536; i++)
//{
// if (addr <= (char*)&modelpointers[i])
// modelpointers[i] = &dummyModel;
//}
unsigned short * new_model_numbers = newmodels + 1 ;
2020-04-10 01:29:12 +02:00
2020-05-13 19:37:09 +02:00
for ( i = 0 ; i < nmodels ; i + + )
2020-04-10 01:29:12 +02:00
{
2020-05-16 14:33:44 +02:00
model_number = new_model_numbers [ i ] ;
2020-04-10 01:29:12 +02:00
2020-05-13 19:37:09 +02:00
size = * ( int * ) addr ;
model = ( MODEL * ) ( addr + 4 ) ;
2020-04-10 01:29:12 +02:00
2020-05-13 19:37:09 +02:00
modelpointers [ model_number ] = model ;
pLodModels [ model_number ] = model ;
2020-04-10 01:29:12 +02:00
2020-05-13 19:37:09 +02:00
lod = Low2LowerDetailTable [ model_number ] ;
2020-04-10 01:29:12 +02:00
2020-05-13 19:37:09 +02:00
if ( lod ! = 0xffff & & lod ! = model_number )
pLodModels [ model_number ] = modelpointers [ lod ] ;
2020-05-11 20:10:50 +02:00
2020-05-13 19:37:09 +02:00
if ( model - > instance_number = = - 1 )
{
if ( model - > collision_block ! = 0 )
model - > collision_block + = ( int ) model ;
2020-04-10 01:29:12 +02:00
2020-05-13 19:37:09 +02:00
model - > vertices + = ( int ) model ;
model - > normals + = ( int ) model ;
model - > point_normals + = ( int ) model ;
2020-04-10 01:29:12 +02:00
2020-05-13 19:37:09 +02:00
InitSpooledAnimObj ( model_number ) ;
}
else
{
parentmodel = modelpointers [ model - > instance_number ] ;
2020-04-10 01:29:12 +02:00
2020-05-13 19:37:09 +02:00
if ( parentmodel - > collision_block ! = 0 )
model - > collision_block = parentmodel - > collision_block ;
2020-04-10 01:29:12 +02:00
2020-05-13 19:37:09 +02:00
model - > vertices = parentmodel - > vertices ;
model - > normals = parentmodel - > normals ;
model - > point_normals = parentmodel - > point_normals ;
2020-05-11 20:10:50 +02:00
2020-05-13 19:37:09 +02:00
InitSpooledAnimObj ( parentmodel - > instance_number ) ;
}
model - > poly_block + = ( int ) model ;
2020-04-10 01:29:12 +02:00
2020-05-13 19:37:09 +02:00
addr + = size + 4 ;
2020-04-04 06:49:28 +02:00
}
2020-05-13 19:37:09 +02:00
2020-04-04 06:49:28 +02:00
LoadingArea = 0 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ SetupModels()
// line 1545, offset 0x0007e540
/* begin block 1 */
// Start line: 7941
/* end block 1 */
// End Line: 7942
/* begin block 2 */
// Start line: 7945
/* end block 2 */
// End Line: 7946
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SetupModels ( void )
{
2020-05-11 20:34:38 +02:00
if ( old_region = = - 1 )
2020-04-04 06:49:28 +02:00
init_spooled_models ( ) ;
2020-05-11 20:34:38 +02:00
else
2020-04-04 06:49:28 +02:00
models_ready = 1 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ LoadInAreaModels(int area /*$a0*/)
// line 1559, offset 0x0007e580
/* begin block 1 */
// Start line: 1561
// Start offset: 0x0007E580
// Variables:
// int offset; // $a2
// int length; // $a3
/* end block 1 */
// End offset: 0x0007E5DC
// End Line: 1571
/* begin block 2 */
// Start line: 7969
/* end block 2 */
// End Line: 7970
/* begin block 3 */
// Start line: 7970
/* end block 3 */
// End Line: 7971
/* begin block 4 */
// Start line: 7974
/* end block 4 */
// End Line: 7975
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void LoadInAreaModels ( int area )
{
2020-05-16 14:33:44 +02:00
if ( newmodels )
{
// clear old model ids
int nmodels = * newmodels ;
unsigned short * new_model_numbers = newmodels + 1 ;
// set old model ids to dummy
for ( int i = 0 ; i < nmodels ; i + + )
{
2020-05-16 15:20:58 +02:00
int model_number = new_model_numbers [ i ] ;
2020-05-16 14:33:44 +02:00
modelpointers [ model_number ] = & dummyModel ;
}
printInfo ( " freed %d model slots \n " , nmodels ) ;
}
2020-05-11 20:34:38 +02:00
int length = AreaData [ area ] . model_size ;
2020-05-16 14:33:44 +02:00
newmodels = ( ushort * ) ( model_spool_buffer + ( length - 1 ) * 2048 ) ;
2020-04-10 01:29:12 +02:00
2020-05-11 20:34:38 +02:00
RequestSpool ( 3 , 0 , AreaData [ area ] . model_offset , length , model_spool_buffer , SetupModels ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ CheckLoadAreaData(int cellx /*$t9*/, int cellz /*$a1*/)
// line 1574, offset 0x0007c08c
/* begin block 1 */
// Start line: 1575
// Start offset: 0x0007C08C
// Variables:
// int i; // $a2
// int nAreas; // $t0
// struct Spool *spoolptr; // $t1
// int load; // $a3
// int force_load_boundary; // $a0
/* end block 1 */
// End offset: 0x0007C27C
// End Line: 1666
/* begin block 2 */
// Start line: 3485
/* end block 2 */
// End Line: 3486
/* begin block 3 */
// Start line: 3517
/* end block 3 */
// End Line: 3518
/* begin block 4 */
// Start line: 3522
/* end block 4 */
// End Line: 3523
2020-05-16 18:44:07 +02:00
// [D]
2020-04-04 06:49:28 +02:00
void CheckLoadAreaData ( int cellx , int cellz )
2020-03-27 21:47:29 +01:00
{
2020-05-13 08:20:21 +02:00
int nAreas ;
int load ;
int force_load_boundary ;
2020-05-12 10:39:31 +02:00
int i ;
2020-04-10 01:29:12 +02:00
Spool * spoolptr ;
2020-04-04 06:49:28 +02:00
2020-05-12 10:39:31 +02:00
if ( spoolinfo_offsets [ current_region ] = = 0xffff )
return ;
spoolptr = ( Spool * ) ( RegionSpoolInfo + spoolinfo_offsets [ current_region ] ) ;
2020-05-16 18:44:07 +02:00
# ifndef PSX
if ( LoadedArea ! = spoolptr - > super_region & & spoolptr - > super_region ! = 0xFF & & old_region ! = - 1 )
{
LoadedArea = spoolptr - > super_region ;
}
else
# endif
2020-05-13 08:20:21 +02:00
if ( old_region = = - 1 & & spoolptr - > super_region ! = 0xFF )
2020-05-12 10:39:31 +02:00
{
2020-05-13 08:20:21 +02:00
// just load the area if no
2020-05-12 10:39:31 +02:00
LoadedArea = spoolptr - > super_region ;
}
else
2020-04-10 01:29:12 +02:00
{
2020-05-12 10:39:31 +02:00
nAreas = spoolptr - > num_connected_areas ;
2020-04-10 01:29:12 +02:00
2020-05-12 10:39:31 +02:00
if ( old_region = = - 1 )
2020-04-10 01:29:12 +02:00
{
2020-05-13 08:20:21 +02:00
LoadedArea = - 1 ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:29:12 +02:00
else
{
2020-05-13 08:20:21 +02:00
//if (spoolptr->super_region == 0xFF) // [A] if this is on, it stops spool. You still may want to load connected areas
// return;
2020-05-12 06:13:05 +02:00
2020-05-12 10:39:31 +02:00
if ( nAreas = = 0 )
return ;
}
2020-04-10 01:29:12 +02:00
2020-05-13 08:20:21 +02:00
force_load_boundary = ( lead_car = = 0 ) ? 15 : 13 ;
2020-04-10 01:29:12 +02:00
2020-05-13 08:20:21 +02:00
// check area bounds
for ( i = 0 ; i < nAreas ; i + + )
2020-05-12 10:39:31 +02:00
{
2020-05-13 08:20:21 +02:00
load = spoolptr - > connected_areas [ i ] > > 6 ;
2020-04-10 01:29:12 +02:00
2020-05-13 08:20:21 +02:00
if ( LoadedArea ! = ( spoolptr - > connected_areas [ i ] & 0x3f ) )
{
new_area_location = load ;
2020-05-12 06:13:05 +02:00
2020-05-13 08:20:21 +02:00
// [A] bounds?
if ( load = = 0 & & ( 32 - force_load_boundary < cellz ) )
2020-05-12 10:39:31 +02:00
{
2020-05-13 08:20:21 +02:00
break ;
2020-05-12 10:39:31 +02:00
}
2020-05-13 08:20:21 +02:00
else if ( load = = 1 & & ( 32 - force_load_boundary < cellx ) )
{
2020-05-12 10:39:31 +02:00
break ;
2020-05-13 08:20:21 +02:00
}
else if ( load = = 2 & & ( cellz < force_load_boundary ) )
{
break ;
}
else if ( load = = 3 & & ( cellx < force_load_boundary ) )
{
break ;
}
}
2020-05-12 10:39:31 +02:00
}
2020-04-10 01:29:12 +02:00
2020-05-12 10:39:31 +02:00
if ( nAreas = = i )
{
if ( LoadedArea ! = - 1 )
return ;
2020-04-10 01:29:12 +02:00
2020-05-12 10:39:31 +02:00
LoadedArea = initarea ;
2020-04-10 01:29:12 +02:00
2020-05-12 10:39:31 +02:00
if ( initarea = = - 1 )
return ;
2020-04-04 06:49:28 +02:00
}
2020-05-12 10:39:31 +02:00
else
{
2020-05-13 08:20:21 +02:00
LoadedArea = spoolptr - > connected_areas [ i ] & 0x3f ;
2020-05-12 10:39:31 +02:00
}
}
2020-04-10 01:29:12 +02:00
2020-05-12 10:39:31 +02:00
LoadingArea = 1 ;
2020-04-19 14:44:26 +02:00
2020-05-12 10:39:31 +02:00
LoadInAreaTSets ( LoadedArea ) ;
LoadInAreaModels ( LoadedArea ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ ClearRegion(int target_region /*$a0*/)
// line 1670, offset 0x0007e3e4
/* begin block 1 */
// Start line: 1671
// Start offset: 0x0007E3E4
// Variables:
// int loop; // $a1
// unsigned short *cell_ptrs_s; // $v1
// unsigned long *pvsptr; // $v0
/* end block 1 */
// End offset: 0x0007E494
// End Line: 1711
/* begin block 2 */
// Start line: 7049
/* end block 2 */
// End Line: 7050
/* begin block 3 */
// Start line: 7594
/* end block 3 */
// End Line: 7595
/* begin block 4 */
// Start line: 7604
/* end block 4 */
// End Line: 7605
2020-04-09 19:15:54 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void ClearRegion ( int target_region )
{
2020-04-28 08:56:10 +02:00
long * pvsptr ;
2020-04-09 19:15:54 +02:00
ushort * cell_ptrs_s ;
2020-04-27 09:11:19 +02:00
int loop ;
2020-04-09 19:15:54 +02:00
2020-04-27 09:11:19 +02:00
loop = 1024 ;
cell_ptrs_s = cell_ptrs + target_region * 1024 ;
2020-04-28 08:56:10 +02:00
pvsptr = ( long * ) PVS_Buffers [ target_region ] ;
2020-04-09 19:15:54 +02:00
2020-04-04 06:49:28 +02:00
do {
2020-04-27 09:11:19 +02:00
* cell_ptrs_s + + = 0xffff ;
2020-04-28 08:56:10 +02:00
* pvsptr + + = 0 ;
} while ( - - loop ! = 0 ) ;
2020-04-09 19:15:54 +02:00
2020-04-27 09:11:19 +02:00
ClearMem ( PVS_Buffers [ target_region ] - 4 , pvsSize [ target_region ] ) ;
2020-05-14 10:45:42 +02:00
2020-04-28 08:56:10 +02:00
RoadMapDataRegions [ target_region ] = ( short * ) PVS_Buffers [ 0 ] ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// int /*$ra*/ LoadRegionData(int region /*$s4*/, int target_region /*$s5*/)
// line 1713, offset 0x0007c28c
/* begin block 1 */
// Start line: 1714
// Start offset: 0x0007C28C
// Variables:
// int offset; // $s0
// char *target_unpacked_data; // $t1
// struct Spool *spoolptr; // $s1
// char *roadmap_buffer; // $s6
// char *cell_buffer; // $s3
/* end block 1 */
// End offset: 0x0007C464
// End Line: 1776
/* begin block 2 */
// Start line: 3836
/* end block 2 */
// End Line: 3837
2020-04-09 19:45:55 +02:00
// [D]
2020-04-04 06:49:28 +02:00
int LoadRegionData ( int region , int target_region )
2020-03-27 21:47:29 +01:00
{
2020-04-09 19:45:55 +02:00
char * cell_buffer ;
2020-04-26 14:19:33 +02:00
ushort * spofs ;
2020-04-04 06:49:28 +02:00
int offset ;
2020-04-09 19:45:55 +02:00
Spool * spoolptr ;
2020-04-09 20:16:26 +02:00
char * roadmap_buffer ; // D1 leftover?
roadmap_buffer = NULL ; // [A]
2020-04-04 06:49:28 +02:00
2020-04-26 14:19:33 +02:00
spofs = ( spoolinfo_offsets + region ) ;
2020-04-09 19:45:55 +02:00
2020-04-27 01:27:02 +02:00
if ( * spofs = = 0xFFFF ) // has region offset?
return 0 ;
2020-04-26 14:19:33 +02:00
2020-04-27 01:27:02 +02:00
loading_region [ target_region ] = region ;
cell_buffer = packed_cell_pointers ;
spoolptr = ( Spool * ) ( RegionSpoolInfo + * spofs ) ;
offset = spoolptr - > offset ;
2020-04-26 14:19:33 +02:00
//#define HAVANA_AUGUST_DEMO // uncomment to load August Demo HAVANA.LEV
# ifdef HAVANA_AUGUST_DEMO
2020-04-27 01:27:02 +02:00
RequestSpool ( 0 , 0 , offset , spoolptr - > roadm_size , PVS_Buffers [ target_region ] , NULL ) ;
offset + = spoolptr - > roadm_size ;
2020-04-26 14:19:33 +02:00
2020-04-27 01:27:02 +02:00
RequestSpool ( 0 , 0 , offset , spoolptr - > cell_data_size [ 1 ] , packed_cell_pointers , NULL ) ;
offset + = spoolptr - > cell_data_size [ 1 ] ;
2020-04-26 14:19:33 +02:00
2020-04-27 01:27:02 +02:00
RequestSpool ( 0 , 0 , offset , spoolptr - > cell_data_size [ 0 ] , ( char * ) ( cells + cell_slots_add [ target_region ] ) , NULL ) ;
offset + = spoolptr - > cell_data_size [ 0 ] ;
2020-04-09 19:45:55 +02:00
2020-04-27 01:27:02 +02:00
RequestSpool ( 0 , 0 , offset , spoolptr - > cell_data_size [ 2 ] , ( char * ) ( cell_objects + num_straddlers + cell_objects_add [ target_region ] ) , GotRegion ) ;
offset + = spoolptr - > cell_data_size [ 2 ] ;
2020-04-09 19:45:55 +02:00
2020-04-27 01:27:02 +02:00
//offset -= spoolptr->roadm_size; // [A] if PVS_Buffers loading temporarily disabled this should be uncommented
2020-04-09 19:45:55 +02:00
2020-04-27 01:27:02 +02:00
spool_regioninfo [ spool_regioncounter ] . nsectors = offset - spoolptr - > offset ;
2020-04-26 14:19:33 +02:00
# else
2020-04-27 12:52:30 +02:00
extern bool gDriver1Level ;
if ( gDriver1Level )
{
2020-04-09 19:45:55 +02:00
2020-04-27 12:52:30 +02:00
}
else
{
RequestSpool ( 0 , 0 , offset , spoolptr - > cell_data_size [ 1 ] , packed_cell_pointers , NULL ) ;
offset + = spoolptr - > cell_data_size [ 1 ] ;
2020-04-09 19:45:55 +02:00
2020-04-27 12:52:30 +02:00
RequestSpool ( 0 , 0 , offset , spoolptr - > cell_data_size [ 0 ] , ( char * ) ( cells + cell_slots_add [ target_region ] ) , NULL ) ;
offset + = spoolptr - > cell_data_size [ 0 ] ;
2020-04-09 19:45:55 +02:00
2020-04-27 12:52:30 +02:00
RequestSpool ( 0 , 0 , offset , spoolptr - > cell_data_size [ 2 ] , ( char * ) ( cell_objects + num_straddlers + cell_objects_add [ target_region ] ) , NULL ) ;
offset + = spoolptr - > cell_data_size [ 2 ] ;
RequestSpool ( 0 , 0 , offset , spoolptr - > roadm_size , PVS_Buffers [ target_region ] - 4 , GotRegion ) ;
offset + = spoolptr - > roadm_size ;
}
2020-04-09 19:45:55 +02:00
2020-04-27 01:27:02 +02:00
spool_regioninfo [ spool_regioncounter ] . nsectors = offset - spoolptr - > offset ;
2020-04-26 14:19:33 +02:00
# endif
2020-04-09 19:45:55 +02:00
2020-04-27 01:27:02 +02:00
spool_regioninfo [ spool_regioncounter ] . region_to_unpack = region ;
spool_regioninfo [ spool_regioncounter ] . target_barrel_region = target_region ;
spool_regioninfo [ spool_regioncounter ] . cell_addr = cell_buffer ;
spool_regioninfo [ spool_regioncounter ] . roadm_addr = roadmap_buffer ;
2020-04-09 19:45:55 +02:00
2020-04-27 01:27:02 +02:00
return 1 ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ UnpackRegion(int region_to_unpack /*$s1*/, int target_barrel_region /*$s0*/)
// line 1779, offset 0x0007e5dc
/* begin block 1 */
// Start line: 1780
// Start offset: 0x0007E5DC
/* end block 1 */
// End offset: 0x0007E658
// End Line: 1812
/* begin block 2 */
// Start line: 8208
/* end block 2 */
// End Line: 8209
/* begin block 3 */
// Start line: 8417
/* end block 3 */
// End Line: 8418
2020-04-09 19:45:25 +02:00
int RoadMapRegions [ 4 ] ;
2020-04-09 19:45:55 +02:00
// [D]
2020-04-04 06:49:28 +02:00
void UnpackRegion ( int region_to_unpack , int target_barrel_region )
2020-03-27 21:47:29 +01:00
{
2020-04-09 19:45:55 +02:00
if ( loading_region [ target_barrel_region ] = = - 1 )
{
2020-04-27 01:27:02 +02:00
if ( LoadRegionData ( region_to_unpack , target_barrel_region ) )
2020-05-11 20:34:38 +02:00
spool_regioncounter + + ;
2020-04-09 19:45:25 +02:00
2020-04-04 06:49:28 +02:00
regions_unpacked [ target_barrel_region ] = region_to_unpack ;
RoadMapRegions [ target_barrel_region ] = region_to_unpack ;
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ ProcessSpoolInfoLump(char *lump_ptr /*$a2*/, int lump_size /*$a1*/)
// line 1815, offset 0x0007c464
/* begin block 1 */
// Start line: 1816
// Start offset: 0x0007C464
// Variables:
// int i; // $t2
// int size; // $v1
// int slots_count; // $t0
// int objects_count; // $t1
// int num_of_regions; // $v0
// char *alloclist; // $a3
/* end block 1 */
// End offset: 0x0007C5C0
// End Line: 1918
/* begin block 2 */
// Start line: 4141
/* end block 2 */
// End Line: 4142
/* begin block 3 */
// Start line: 4181
/* end block 3 */
// End Line: 4182
2020-05-14 10:45:42 +02:00
inline int _getIntAdv ( char * * ptr )
{
int value = * ( int * ) * ptr ;
* ptr + = 4 ;
return value ;
}
# define getIntAdv(ptr) _getIntAdv(&ptr)
2020-04-05 23:04:50 +02:00
// [D]
2020-04-04 06:49:28 +02:00
void ProcessSpoolInfoLump ( char * lump_ptr , int lump_size )
2020-03-27 21:47:29 +01:00
{
2020-04-27 09:11:19 +02:00
int i ;
int size ;
2020-05-14 10:45:42 +02:00
char * alloclist ;
2020-04-04 06:49:28 +02:00
pvsSize [ 0 ] = 0 ;
pvsSize [ 1 ] = 0 ;
pvsSize [ 2 ] = 0 ;
pvsSize [ 3 ] = 0 ;
2020-04-05 23:04:50 +02:00
2020-05-14 10:45:42 +02:00
char * ptr = lump_ptr ;
2020-04-05 23:04:50 +02:00
2020-05-14 10:45:42 +02:00
size = getIntAdv ( ptr ) * 2048 ;
2020-04-05 23:04:50 +02:00
2020-05-14 08:57:20 +02:00
if ( size < 0x10000 )
2020-05-14 10:45:42 +02:00
size = 0x10000 ; // smaller still should be fixed to 64k
2020-04-05 23:04:50 +02:00
2020-05-14 10:45:42 +02:00
MALLOC_BEGIN ( ) ;
model_spool_buffer = D_MALLOC ( size ) ;
2020-05-14 08:57:20 +02:00
MALLOC_END ( ) ;
2020-04-04 06:49:28 +02:00
cell_slots_add [ 4 ] = 0 ;
cell_objects_add [ 4 ] = 0 ;
2020-04-05 23:04:50 +02:00
2020-05-14 10:45:42 +02:00
int music_and_ambients_size = getIntAdv ( ptr ) ;
Music_And_AmbientOffsets = ( SXYPAIR * ) ptr ; // [A] seems to be UNUSED
ptr + = music_and_ambients_size ;
2020-04-05 23:04:50 +02:00
2020-05-14 10:45:42 +02:00
NumAreas = getIntAdv ( ptr ) ;
AreaData = ( AreaDataStr * ) ptr ;
ptr + = sizeof ( AreaDataStr ) * NumAreas ;
2020-04-05 23:04:50 +02:00
2020-05-14 10:45:42 +02:00
AreaTPages = ( unsigned char * ) ptr ;
ptr + = NumAreas * 16 ;
2020-04-05 23:04:50 +02:00
2020-05-14 10:45:42 +02:00
// get the pointers
int * slots_add = ( int * ) ptr ;
ptr + = sizeof ( int ) * 4 ;
int * objects_add = ( int * ) ptr ;
ptr + = sizeof ( int ) * 4 ;
int * pvsSizes = ( int * ) ptr ;
ptr + = sizeof ( int ) * 4 ;
for ( i = 0 ; i < 4 ; i + + )
{
int slots_count = slots_add [ i ] ;
int objects_count = objects_add [ i ] ;
// set last totals
2020-04-27 09:11:19 +02:00
cell_objects_add [ i ] = cell_objects_add [ 4 ] ;
cell_slots_add [ i ] = cell_slots_add [ 4 ] ;
2020-05-14 10:45:42 +02:00
// increment totals
cell_slots_add [ 4 ] + = slots_count ;
cell_objects_add [ 4 ] + = objects_count ;
2020-04-27 09:11:19 +02:00
2020-05-14 10:45:42 +02:00
// by the fact it's a roadmap size + pvs size
pvsSize [ i ] = pvsSizes [ i ] + 0x7ffU & 0xfffff800 ;
2020-04-27 09:11:19 +02:00
2020-05-14 10:45:42 +02:00
MALLOC_BEGIN ( ) ;
alloclist = D_MALLOC ( pvsSize [ i ] ) ;
2020-05-14 08:57:20 +02:00
MALLOC_END ( ) ;
2020-04-27 09:11:19 +02:00
2020-05-14 10:45:42 +02:00
PVS_Buffers [ i ] = alloclist + 4 ; // +4 for -1 cases
}
int num_of_regions = getIntAdv ( ptr ) ;
spoolinfo_offsets = ( ushort * ) ptr ;
ptr + = sizeof ( ushort ) * num_of_regions ;
2020-04-05 23:04:50 +02:00
2020-05-14 10:45:42 +02:00
int spoolinfo_size = getIntAdv ( ptr ) ;
RegionSpoolInfo = ptr ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ WaitCloseLid()
// line 1928, offset 0x0007e66c
/* begin block 1 */
// Start line: 1930
// Start offset: 0x0007E66C
// Variables:
// void (*old)(); // $s1
/* end block 1 */
// End offset: 0x0007E6D8
// End Line: 1942
/* begin block 2 */
// Start line: 8731
/* end block 2 */
// End Line: 8732
/* begin block 3 */
// Start line: 8732
/* end block 3 */
// End Line: 8733
/* begin block 4 */
// Start line: 8733
/* end block 4 */
// End Line: 8734
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void WaitCloseLid ( void )
{
2020-04-10 01:29:12 +02:00
# ifdef PSX
void ( * old ) ( ) ;
2020-04-27 09:11:19 +02:00
int loop ;
2020-04-04 06:49:28 +02:00
2020-04-10 01:29:12 +02:00
old = ( void ( * ) ( ) ) CdReadyCallback ( 0 ) ;
2020-04-04 06:49:28 +02:00
stopgame ( ) ;
2020-04-10 01:29:12 +02:00
2020-04-27 09:11:19 +02:00
while ( loop = CdDiskReady ( 1 ) , loop ! = 2 )
2020-04-10 01:29:12 +02:00
{
2020-04-04 06:49:28 +02:00
DrawCDicon ( ) ;
VSync ( 0 ) ;
}
2020-04-10 01:29:12 +02:00
2020-04-04 06:49:28 +02:00
startgame ( ) ;
2020-04-10 01:29:12 +02:00
CdReadyCallback ( ( CdlCB ) old ) ;
# endif // PSX
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ FoundError(char *name /*$a0*/, unsigned char intr /*$a1*/, unsigned char *result /*$a2*/)
// line 1945, offset 0x0007e6d8
/* begin block 1 */
// Start line: 1947
// Start offset: 0x0007E6D8
// Variables:
// struct CdlLOC p; // stack offset -16
/* end block 1 */
// End offset: 0x0007E724
// End Line: 1963
/* begin block 2 */
// Start line: 8761
/* end block 2 */
// End Line: 8762
/* begin block 3 */
// Start line: 8765
/* end block 3 */
// End Line: 8766
/* begin block 4 */
// Start line: 8766
/* end block 4 */
// End Line: 8767
/* begin block 5 */
// Start line: 8768
/* end block 5 */
// End Line: 8769
2020-04-10 01:29:12 +02:00
// [D]
2020-04-04 06:49:28 +02:00
void FoundError ( char * name , unsigned char intr , unsigned char * result )
2020-03-27 21:47:29 +01:00
{
2020-05-12 10:39:31 +02:00
# ifndef SIMPLE_SPOOL
2020-04-10 01:29:12 +02:00
CdlLOC p ;
2020-04-04 06:49:28 +02:00
2020-04-10 01:29:12 +02:00
if ( ( * result & 0x10 ) ! = 0 )
{
2020-04-04 06:49:28 +02:00
WaitCloseLid ( ) ;
}
2020-04-10 01:29:12 +02:00
# ifdef _DEBUG
2020-05-14 08:57:20 +02:00
printError ( " FoundError: %s, intr: %d \n " , name , intr ) ;
2020-04-10 01:29:12 +02:00
# endif // _DEBUG
2020-04-04 06:49:28 +02:00
spoolerror = 0x3c ;
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-10 01:29:12 +02:00
CdIntToPos ( current_sector , & p ) ;
2020-04-11 13:21:25 +02:00
CdControlF ( CdlReadS , ( u_char * ) & p ) ;
2020-04-11 17:04:02 +02:00
# else
UNIMPLEMENTED ( ) ;
# endif
2020-05-12 10:39:31 +02:00
# endif // SIMPLE_SPOOL
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ GotRegion()
// line 1970, offset 0x0007d9cc
/* begin block 1 */
// Start line: 1972
// Start offset: 0x0007D9CC
// Variables:
// int cbr; // $a1
/* end block 1 */
// End offset: 0x0007DA60
// End Line: 1990
/* begin block 2 */
// Start line: 6109
/* end block 2 */
// End Line: 6110
/* begin block 3 */
// Start line: 3940
/* end block 3 */
// End Line: 3941
/* begin block 4 */
// Start line: 6110
/* end block 4 */
// End Line: 6111
/* begin block 5 */
// Start line: 6113
/* end block 5 */
// End Line: 6114
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-09 20:22:38 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void GotRegion ( void )
{
2020-04-04 06:49:28 +02:00
uint target_barrel_reg ;
Unpack_CellPtrs ( ) ;
2020-04-09 20:22:38 +02:00
2020-06-01 22:12:42 +02:00
target_barrel_reg = spool_regioninfo [ spool_regionpos ] . target_barrel_region ;
2020-04-09 20:22:38 +02:00
spool_regionpos + + ;
2020-04-19 14:32:14 +02:00
char * pvs = PVS_Buffers [ target_barrel_reg ] ;
2020-04-04 06:49:28 +02:00
loading_region [ target_barrel_reg ] = - 1 ;
2020-04-09 20:22:38 +02:00
2020-04-19 14:32:14 +02:00
int cbr = * ( int * ) ( pvs - 4 ) ;
RoadMapDataRegions [ target_barrel_reg ] = ( short * ) ( pvs + cbr ) ;
2020-04-09 20:22:38 +02:00
if ( spool_regionpos = = spool_regioncounter )
{
2020-04-04 06:49:28 +02:00
spool_regioncounter = 0 ;
spool_regionpos = 0 ;
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ data_cb_textures()
// line 1993, offset 0x0007df64
/* begin block 1 */
// Start line: 1995
// Start offset: 0x0007DF64
/* begin block 1.1 */
// Start line: 1997
// Start offset: 0x0007DF78
/* end block 1.1 */
// End offset: 0x0007E068
// End Line: 2033
/* end block 1 */
// End offset: 0x0007E078
// End Line: 2034
/* begin block 2 */
// Start line: 6680
/* end block 2 */
// End Line: 6681
/* begin block 3 */
// Start line: 3986
/* end block 3 */
// End Line: 3987
/* begin block 4 */
// Start line: 6681
/* end block 4 */
// End Line: 6682
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void data_cb_textures ( void )
{
2020-05-12 10:39:31 +02:00
# ifndef SIMPLE_SPOOL
//printf("data_cb_textures remaining: %d\n", sectors_to_read);
2020-04-11 20:15:11 +02:00
2020-04-10 01:29:12 +02:00
if ( chunk_complete ! = 0 )
{
2020-04-04 06:49:28 +02:00
chunk_complete = 0 ;
nTPchunks = nTPchunks_writing ;
2020-04-10 01:29:12 +02:00
2020-04-04 06:49:28 +02:00
SendTPage ( ) ;
2020-04-10 01:29:12 +02:00
if ( nTPchunks ! = 0 )
2020-05-12 06:59:42 +02:00
loadbank_write + + ;
2020-04-10 01:29:12 +02:00
2020-05-12 06:59:42 +02:00
nTPchunks_writing + + ;
2020-04-10 01:29:12 +02:00
if ( nTPchunks_writing = = 5 )
{
2020-04-04 06:49:28 +02:00
nTPchunks_writing = 0 ;
2020-05-12 06:59:42 +02:00
spoolpos_writing + + ;
2020-04-10 01:29:12 +02:00
if ( ntpages = = 0 )
{
if ( switch_spooltype = = 0 )
{
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-04 06:49:28 +02:00
CdDataCallback ( 0 ) ;
2020-04-11 17:04:02 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCDataCallback ( NULL ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-04-10 01:29:12 +02:00
if ( spoolpos_writing = = spoolcounter )
{
2020-05-14 08:57:20 +02:00
printWarning ( " All SPOOL requests (%d) completed successfully on TEXTURES \n " , spoolcounter ) ; // [A]
2020-04-19 14:32:14 +02:00
2020-04-04 06:49:28 +02:00
spoolcounter = 0 ;
spoolpos_writing = 0 ;
spoolpos_reading = 0 ;
spoolactive = 0 ;
}
2020-04-10 01:29:12 +02:00
else
{
2020-04-04 06:49:28 +02:00
UpdateSpool ( ) ;
}
}
2020-04-10 01:29:12 +02:00
else
{
2020-04-04 06:49:28 +02:00
changemode ( spooldata + spoolpos_writing ) ;
}
}
}
}
2020-05-12 10:39:31 +02:00
# endif // SIMPLE_SPOOL
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ ready_cb_textures(unsigned char intr /*$s0*/, unsigned char *result /*$a2*/)
// line 2036, offset 0x0007e078
/* begin block 1 */
// Start line: 2037
// Start offset: 0x0007E078
/* begin block 1.1 */
// Start line: 2050
// Start offset: 0x0007E0D8
// Variables:
// struct SPOOLQ *current; // $a2
/* end block 1.1 */
// End offset: 0x0007E188
// End Line: 2080
/* end block 1 */
// End offset: 0x0007E198
// End Line: 2086
/* begin block 2 */
// Start line: 6770
/* end block 2 */
// End Line: 6771
/* begin block 3 */
// Start line: 6773
/* end block 3 */
// End Line: 6774
2020-04-10 01:29:12 +02:00
// [D]
2020-04-04 06:49:28 +02:00
void ready_cb_textures ( unsigned char intr , unsigned char * result )
2020-03-27 21:47:29 +01:00
{
2020-05-12 10:39:31 +02:00
# ifndef SIMPLE_SPOOL
2020-05-11 20:34:38 +02:00
if ( intr = = 1 )
2020-04-10 01:29:12 +02:00
{
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-04 06:49:28 +02:00
CdGetSector ( target_address , 0x200 ) ;
2020-04-11 17:04:02 +02:00
# else
getLevSectorPC ( target_address , 0x200 ) ;
# endif // PSX
2020-04-10 01:29:12 +02:00
2020-04-04 06:49:28 +02:00
target_address = target_address + 0x800 ;
2020-04-20 06:55:53 +02:00
sectors_this_chunk - - ;
current_sector + + ;
sectors_to_read - - ;
2020-04-10 01:29:12 +02:00
if ( sectors_this_chunk = = 0 )
{
if ( nTPchunks_reading ! = 0 )
2020-05-11 20:34:38 +02:00
loadbank_read + + ;
2020-04-10 01:29:12 +02:00
2020-05-11 20:34:38 +02:00
nTPchunks_reading + + ;
chunk_complete = intr ;
2020-04-10 01:29:12 +02:00
if ( sectors_to_read = = 0 )
{
2020-05-12 10:39:31 +02:00
ntpages - - ;
2020-04-10 01:29:12 +02:00
if ( ntpages = = 0 )
{
2020-05-11 20:34:38 +02:00
spoolpos_reading + + ;
2020-04-04 06:49:28 +02:00
test_changemode ( ) ;
}
2020-04-10 01:29:12 +02:00
else
{
2020-04-04 06:49:28 +02:00
nTPchunks_reading = 0 ;
2020-04-11 17:04:02 +02:00
sectors_to_read = 17 ;
2020-05-11 20:34:38 +02:00
2020-04-04 06:49:28 +02:00
target_address = spooldata [ spoolpos_reading ] . addr + 0x4000 ;
2020-05-11 20:34:38 +02:00
spoolpos_reading + + ;
sectors_this_chunk = intr ;
2020-04-04 06:49:28 +02:00
}
}
2020-04-10 01:29:12 +02:00
else
{
2020-04-04 06:49:28 +02:00
sectors_this_chunk = 4 ;
target_address = spooldata [ spoolpos_reading ] . addr + ( loadbank_read & 1U ) * 0x2000 ;
}
}
}
2020-04-10 01:29:12 +02:00
else
FoundError ( " ready_cb_textures " , intr , result ) ;
2020-05-12 10:39:31 +02:00
# endif // SIMPLE_SPOOL
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ ready_cb_regions(unsigned char intr /*$s0*/, unsigned char *result /*$a2*/)
// line 2090, offset 0x0007de90
/* begin block 1 */
// Start line: 2091
// Start offset: 0x0007DE90
/* begin block 1.1 */
// Start line: 2110
// Start offset: 0x0007DF08
// Variables:
// struct SPOOLQ *current; // $v1
/* end block 1.1 */
// End offset: 0x0007DF08
// End Line: 2110
/* end block 1 */
// End offset: 0x0007DF64
// End Line: 2129
/* begin block 2 */
// Start line: 6728
/* end block 2 */
// End Line: 6729
/* begin block 3 */
// Start line: 4180
/* end block 3 */
// End Line: 4181
2020-04-04 06:49:28 +02:00
void ready_cb_regions ( unsigned char intr , unsigned char * result )
2020-03-27 21:47:29 +01:00
{
2020-05-12 10:39:31 +02:00
# ifndef SIMPLE_SPOOL
2020-05-11 20:34:38 +02:00
if ( intr = = 1 )
2020-04-10 01:29:12 +02:00
{
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-04 06:49:28 +02:00
CdGetSector ( target_address , 0x200 ) ;
2020-04-11 17:04:02 +02:00
# else
getLevSectorPC ( target_address , 0x200 ) ;
# endif // PSX
2020-04-04 06:49:28 +02:00
target_address = target_address + 0x800 ;
2020-04-20 06:55:53 +02:00
sectors_this_chunk - - ;
current_sector + + ;
sectors_to_read - - ;
2020-04-10 01:29:12 +02:00
if ( sectors_this_chunk = = 0 )
{
2020-05-11 20:34:38 +02:00
spoolpos_reading + + ;
chunk_complete = intr ;
2020-04-10 01:29:12 +02:00
if ( sectors_to_read = = 0 )
{
2020-05-11 20:34:38 +02:00
endchunk = intr ;
2020-04-04 06:49:28 +02:00
test_changemode ( ) ;
}
2020-04-10 01:29:12 +02:00
else
{
2020-04-04 06:49:28 +02:00
target_address = spooldata [ spoolpos_reading ] . addr ;
2020-04-10 01:29:12 +02:00
sectors_this_chunk = ( spooldata [ spoolpos_reading ] . nsectors ) ;
2020-04-04 06:49:28 +02:00
}
}
}
2020-05-11 20:34:38 +02:00
else
2020-04-10 01:29:12 +02:00
FoundError ( " ready_cb_regions " , intr , result ) ;
2020-05-12 10:39:31 +02:00
# endif // SIMPLE_SPOOL
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ data_cb_regions()
// line 2132, offset 0x0007dda8
/* begin block 1 */
// Start line: 2134
// Start offset: 0x0007DDA8
/* begin block 1.1 */
// Start line: 2136
// Start offset: 0x0007DDBC
// Variables:
// struct SPOOLQ *current; // $v0
/* end block 1.1 */
// End offset: 0x0007DE80
// End Line: 2167
/* end block 1 */
// End offset: 0x0007DE90
// End Line: 2168
/* begin block 2 */
// Start line: 4264
/* end block 2 */
// End Line: 4265
/* begin block 3 */
// Start line: 6733
/* end block 3 */
// End Line: 6734
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void data_cb_regions ( void )
{
2020-05-12 10:39:31 +02:00
# ifndef SIMPLE_SPOOL
2020-04-11 20:33:58 +02:00
//printf("data_cb_regions remaining: %d\n", sectors_to_read);
2020-04-11 20:15:11 +02:00
2020-05-12 10:39:31 +02:00
SPOOLQ * current = & spooldata [ spoolpos_writing ] ;
2020-04-10 01:29:12 +02:00
if ( chunk_complete ! = 0 )
{
2020-04-04 06:49:28 +02:00
chunk_complete = 0 ;
2020-04-10 01:29:12 +02:00
2020-05-12 10:39:31 +02:00
if ( current - > func ! = NULL )
( current - > func ) ( ) ;
2020-04-10 01:29:12 +02:00
2020-05-11 20:34:38 +02:00
spoolpos_writing + + ;
2020-04-10 01:29:12 +02:00
if ( endchunk ! = 0 )
{
if ( switch_spooltype = = 0 )
{
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-04 06:49:28 +02:00
CdDataCallback ( 0 ) ;
2020-04-11 17:04:02 +02:00
# else
2020-04-19 12:53:18 +02:00
levelSpoolerPCDataCallback ( NULL ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-04-10 01:29:12 +02:00
if ( spoolpos_writing = = spoolcounter )
{
2020-05-14 08:57:20 +02:00
printWarning ( " All SPOOL requests (%d) completed successfully on REGIONS \n " , spoolcounter ) ; // [A]
2020-04-19 14:32:14 +02:00
2020-04-04 06:49:28 +02:00
spoolcounter = 0 ;
spoolpos_writing = 0 ;
spoolpos_reading = 0 ;
spoolactive = 0 ;
}
2020-04-10 01:29:12 +02:00
else
{
2020-04-04 06:49:28 +02:00
UpdateSpool ( ) ;
}
}
2020-04-10 01:29:12 +02:00
else
{
2020-05-12 10:39:31 +02:00
changemode ( & spooldata [ spoolpos_writing ] ) ;
2020-04-04 06:49:28 +02:00
}
}
}
2020-05-12 10:39:31 +02:00
# endif // SIMPLE_SPOOL
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ data_cb_soundbank()
// line 2171, offset 0x0007dbcc
/* begin block 1 */
// Start line: 2173
// Start offset: 0x0007DBCC
/* begin block 1.1 */
// Start line: 2175
// Start offset: 0x0007DBE0
/* end block 1.1 */
// End offset: 0x0007DC94
// End Line: 2200
/* end block 1 */
// End offset: 0x0007DCA4
// End Line: 2201
/* begin block 2 */
// Start line: 4342
/* end block 2 */
// End Line: 4343
/* begin block 3 */
// Start line: 6666
/* end block 3 */
// End Line: 6667
/* WARNING: Unknown calling convention yet parameter storage is locked */
void data_cb_soundbank ( void )
{
2020-04-04 06:49:28 +02:00
UNIMPLEMENTED ( ) ;
/*
if ( chunk_complete ! = 0 ) {
chunk_complete = 0 ;
SendSBK ( ) ;
loadbank_write = loadbank_write + 1 ;
if ( endchunk ! = 0 ) {
spoolpos_writing = spoolpos_writing + 1 ;
if ( switch_spooltype = = 0 ) {
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-04 06:49:28 +02:00
CdDataCallback ( 0 ) ;
2020-04-11 17:04:02 +02:00
# else
UNIMPLEMENTED ( ) ;
# endif // PSX
2020-04-04 06:49:28 +02:00
if ( spoolpos_writing = = spoolcounter ) {
spoolcounter = 0 ;
spoolpos_writing = 0 ;
spoolpos_reading = 0 ;
spoolactive = 0 ;
}
else {
UpdateSpool ( ) ;
}
}
else {
changemode ( spooldata + spoolpos_writing ) ;
}
}
}
return ; */
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ ready_cb_soundbank(unsigned char intr /*$s0*/, unsigned char *result /*$a2*/)
// line 2203, offset 0x0007dca4
/* begin block 1 */
// Start line: 2204
// Start offset: 0x0007DCA4
/* begin block 1.1 */
// Start line: 2217
// Start offset: 0x0007DD04
// Variables:
// struct SPOOLQ *current; // $a0
/* end block 1.1 */
// End offset: 0x0007DD70
// End Line: 2237
/* end block 1 */
// End offset: 0x0007DD98
// End Line: 2244
/* begin block 2 */
// Start line: 6729
/* end block 2 */
// End Line: 6730
/* begin block 3 */
// Start line: 6732
/* end block 3 */
// End Line: 6733
2020-04-04 06:49:28 +02:00
void ready_cb_soundbank ( unsigned char intr , unsigned char * result )
2020-03-27 21:47:29 +01:00
{
2020-04-04 06:49:28 +02:00
UNIMPLEMENTED ( ) ;
/*
uint uVar1 ;
uVar1 = ( uint ) intr ;
if ( intr = = ' \x01 ' ) {
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-04 06:49:28 +02:00
CdGetSector ( target_address , 0x200 ) ;
2020-04-11 17:04:02 +02:00
# else
getLevSectorPC ( target_address , 0x200 ) ;
# endif // PSX
2020-04-04 06:49:28 +02:00
target_address = target_address + 0x800 ;
2020-04-20 06:55:53 +02:00
sectors_this_chunk - - ;
current_sector + + ;
sectors_to_read - - ;
2020-04-04 06:49:28 +02:00
if ( sectors_this_chunk = = 0 ) {
loadbank_read = loadbank_read + 1 ;
nTPchunks_reading = nTPchunks_reading + 1 ;
chunk_complete = uVar1 ;
if ( sectors_to_read = = 0 ) {
spoolpos_reading = spoolpos_reading + 1 ;
endchunk = uVar1 ;
test_changemode ( ) ;
}
else {
sectors_this_chunk = 2 ;
if ( sectors_to_read < 2 ) {
sectors_this_chunk = sectors_to_read ;
}
target_address = spooldata [ spoolpos_reading ] . addr + ( loadbank_read & 1U ) * 0x1000 ;
}
}
}
else {
FoundError ( s_ready_cb_soundbank_00011d5c , intr , result ) ;
}
return ; */
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ data_cb_misc()
// line 2246, offset 0x0007da60
/* begin block 1 */
// Start line: 2248
// Start offset: 0x0007DA60
/* begin block 1.1 */
// Start line: 2250
// Start offset: 0x0007DA74
// Variables:
// struct SPOOLQ *current; // $v0
/* end block 1.1 */
// End offset: 0x0007DB28
// End Line: 2275
/* end block 1 */
// End offset: 0x0007DB38
// End Line: 2276
/* begin block 2 */
// Start line: 6421
/* end block 2 */
// End Line: 6422
/* begin block 3 */
// Start line: 6678
/* end block 3 */
// End Line: 6679
/* begin block 4 */
// Start line: 6679
/* end block 4 */
// End Line: 6680
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void data_cb_misc ( void )
{
2020-05-12 10:39:31 +02:00
# ifndef SIMPLE_SPOOL
2020-04-11 20:33:58 +02:00
//printf("data_cb_misc remaining: %d\n", sectors_to_read);
2020-04-11 20:15:11 +02:00
2020-05-12 10:39:31 +02:00
SPOOLQ * current = & spooldata [ spoolpos_writing ] ;
2020-04-10 01:29:12 +02:00
if ( chunk_complete ! = 0 )
{
2020-04-04 06:49:28 +02:00
chunk_complete = 0 ;
2020-04-10 01:29:12 +02:00
2020-05-12 10:39:31 +02:00
if ( current - > func ! = NULL )
2020-04-10 01:29:12 +02:00
{
2020-05-12 10:39:31 +02:00
( * current - > func ) ( ) ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:29:12 +02:00
2020-05-11 20:34:38 +02:00
spoolpos_writing + + ;
2020-04-10 01:29:12 +02:00
if ( switch_spooltype = = 0 )
{
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-04 06:49:28 +02:00
CdDataCallback ( 0 ) ;
2020-04-11 17:04:02 +02:00
# else
2020-04-19 14:32:14 +02:00
levelSpoolerPCDataCallback ( NULL ) ;
2020-04-11 17:04:02 +02:00
# endif // PSX
2020-04-10 01:29:12 +02:00
if ( spoolpos_writing = = spoolcounter )
{
2020-05-14 08:57:20 +02:00
printWarning ( " All SPOOL requests (%d) completed successfully on MISC \n " , spoolcounter ) ; // [A]
2020-04-19 14:32:14 +02:00
2020-04-04 06:49:28 +02:00
spoolcounter = 0 ;
spoolpos_writing = 0 ;
spoolpos_reading = 0 ;
spoolactive = 0 ;
}
2020-04-10 01:29:12 +02:00
else
{
2020-04-04 06:49:28 +02:00
UpdateSpool ( ) ;
}
}
2020-04-10 01:29:12 +02:00
else
{
2020-04-04 06:49:28 +02:00
changemode ( spooldata + spoolpos_writing ) ;
}
}
2020-05-12 10:39:31 +02:00
# endif // SIMPLE_SPOOL
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ ready_cb_misc(unsigned char intr /*$s0*/, unsigned char *result /*$a2*/)
// line 2278, offset 0x0007db38
/* begin block 1 */
// Start line: 6744
/* end block 1 */
// End Line: 6745
/* begin block 2 */
// Start line: 6747
/* end block 2 */
// End Line: 6748
2020-04-10 01:29:12 +02:00
// [D]
2020-04-04 06:49:28 +02:00
void ready_cb_misc ( unsigned char intr , unsigned char * result )
2020-03-27 21:47:29 +01:00
{
2020-05-12 10:39:31 +02:00
# ifndef SIMPLE_SPOOL
2020-05-11 20:34:38 +02:00
if ( intr = = 1 )
2020-04-10 01:29:12 +02:00
{
2020-04-11 17:04:02 +02:00
# ifdef PSX
2020-04-04 06:49:28 +02:00
CdGetSector ( target_address , 0x200 ) ;
2020-04-11 17:04:02 +02:00
# else
getLevSectorPC ( target_address , 0x200 ) ;
# endif // PSX
2020-04-10 01:29:12 +02:00
2020-04-04 06:49:28 +02:00
target_address = target_address + 0x800 ;
2020-04-20 06:55:53 +02:00
sectors_to_read - - ;
current_sector + + ;
2020-04-10 01:29:12 +02:00
if ( sectors_to_read = = 0 )
{
2020-05-11 20:34:38 +02:00
spoolpos_reading + + ;
chunk_complete = intr ;
2020-04-04 06:49:28 +02:00
test_changemode ( ) ;
}
}
2020-04-10 01:29:12 +02:00
else
{
FoundError ( " ready_cb_misc " , intr , result ) ;
2020-04-04 06:49:28 +02:00
}
2020-05-12 10:39:31 +02:00
# endif // SIMPLE_SPOOL
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ StartSpooling()
// line 2302, offset 0x0007e724
/* begin block 1 */
// Start line: 2304
// Start offset: 0x0007E724
/* end block 1 */
// End offset: 0x0007E7B0
// End Line: 2321
/* begin block 2 */
// Start line: 9140
/* end block 2 */
// End Line: 9141
/* begin block 3 */
// Start line: 9480
/* end block 3 */
// End Line: 9481
/* begin block 4 */
// Start line: 9481
/* end block 4 */
// End Line: 9482
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-09 20:50:21 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void StartSpooling ( void )
{
2020-04-09 20:50:21 +02:00
static unsigned char param [ 8 ] ;
static unsigned char result [ 8 ] ;
2020-04-04 06:49:28 +02:00
int iVar1 ;
2020-04-09 20:50:21 +02:00
if ( ( spoolcounter ! = 0 ) & & ( spoolactive = = 0 ) )
{
iVar1 = XAPrepared ( ) ;
if ( iVar1 = = 0 )
{
# ifdef PSX
param [ 0 ] = - 0x80 ;
CdControlB ( 0xe , param , result ) ;
if ( ( result [ 0 ] & 0x15 ) ! = 0 )
{
WaitCloseLid ( ) ;
}
# endif // PSX
spoolactive = 1 ;
UpdateSpool ( ) ;
if ( FastForward ! = 0 )
{
SpoolSYNC ( ) ;
}
2020-04-04 06:49:28 +02:00
}
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ unpack_cellpointers()
// line 2351, offset 0x0007c5c0
/* begin block 1 */
// Start line: 2353
// Start offset: 0x0007C5C0
// Variables:
// int target_barrel_region; // $t0
// char *source_packed_data; // $v0
// int bitpos; // $a3
// int loop; // $a2
// int packtype; // $a0
// unsigned short cell; // $a0
// unsigned short *short_ptr; // $a1
// unsigned short pcode; // $t1
/* end block 1 */
// End offset: 0x0007C74C
// End Line: 2437
/* begin block 2 */
// Start line: 4939
/* end block 2 */
// End Line: 4940
/* begin block 3 */
// Start line: 5373
/* end block 3 */
// End Line: 5374
/* begin block 4 */
// Start line: 5374
/* end block 4 */
// End Line: 5375
/* begin block 5 */
// Start line: 5383
/* end block 5 */
// End Line: 5384
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-20 06:55:53 +02:00
// [D] [A] - altered declaration
void unpack_cellpointers ( int region_to_unpack , int target_barrel_region , char * cell_addr )
2020-03-27 21:47:29 +01:00
{
2020-04-04 06:49:28 +02:00
ushort * puVar1 ;
ushort * puVar2 ;
ushort uVar3 ;
2020-05-14 19:39:16 +02:00
int loop ;
2020-04-04 06:49:28 +02:00
uint uVar6 ;
uint uVar7 ;
2020-05-14 19:39:16 +02:00
int packtype ;
2020-04-04 06:49:28 +02:00
unpack_cellptr_flag = 0 ;
2020-05-14 19:39:16 +02:00
packtype = * ( int * ) ( cell_addr + 4 ) ;
2020-04-20 06:55:53 +02:00
puVar1 = ( ushort * ) ( cell_addr + 8 ) ;
2020-04-09 20:22:38 +02:00
2020-05-14 19:39:16 +02:00
if ( packtype = = 0 )
2020-04-09 20:22:38 +02:00
{
2020-05-14 19:39:16 +02:00
puVar1 = cell_ptrs + target_barrel_region * 1024 ;
for ( loop = 0 ; loop < 1024 ; loop + + )
* puVar1 + + = 0xffff ;
2020-04-04 06:49:28 +02:00
}
2020-05-14 19:39:16 +02:00
else if ( packtype = = 1 )
{
puVar2 = cell_ptrs + target_barrel_region * 1024 ;
for ( loop = 0 ; loop < 1024 ; loop + + )
2020-04-09 20:22:38 +02:00
{
2020-05-14 19:39:16 +02:00
uVar3 = * puVar1 + + ;
if ( uVar3 ! = 0xffff )
uVar3 + = cell_slots_add [ target_barrel_region ] ;
* puVar2 + + = uVar3 ;
2020-04-04 06:49:28 +02:00
}
2020-05-14 19:39:16 +02:00
}
else if ( packtype = = 2 )
{
uVar6 = 0x8000 ;
uVar7 = ( uint ) * puVar1 ;
puVar2 = ( ushort * ) ( cell_addr + 10 ) ;
puVar1 = cell_ptrs + target_barrel_region * 1024 ;
2020-04-09 20:22:38 +02:00
2020-05-14 19:39:16 +02:00
for ( loop = 0 ; loop < 1024 ; loop + + )
2020-04-09 20:22:38 +02:00
{
2020-05-14 19:39:16 +02:00
if ( uVar7 & uVar6 )
{
uVar3 = * puVar2 + + ;
uVar3 + = cell_slots_add [ target_barrel_region ] ;
2020-04-09 20:22:38 +02:00
2020-05-14 19:39:16 +02:00
}
else
uVar3 = 0xffff ;
uVar6 > > = 1 ;
* puVar1 + + = uVar3 ;
2020-04-09 20:22:38 +02:00
2020-05-14 19:39:16 +02:00
if ( uVar6 = = 0 )
{
uVar6 = 0x8000 ;
uVar7 = * puVar2 + + ;
}
}
}
else
{
2020-04-09 20:22:38 +02:00
if ( FrameCnt ! = 0x78654321 )
{
2020-04-04 06:49:28 +02:00
do {
2020-04-19 14:32:14 +02:00
trap ( 0x400 ) ;
2020-04-04 06:49:28 +02:00
} while ( FrameCnt ! = 0x78654321 ) ;
2020-04-09 20:22:38 +02:00
2020-04-04 06:49:28 +02:00
unpack_cellptr_flag = 0 ;
}
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ Unpack_CellPtrs()
// line 2442, offset 0x0007d978
/* begin block 1 */
// Start line: 2444
// Start offset: 0x0007D978
// Variables:
// int region_to_unpack; // $a1
// int target_barrel_region; // $a1
// char *source_packed_data; // $v1
/* end block 1 */
// End offset: 0x0007D9CC
// End Line: 2469
/* begin block 2 */
// Start line: 4884
/* end block 2 */
// End Line: 4885
/* begin block 3 */
// Start line: 6539
/* end block 3 */
// End Line: 6540
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-20 06:55:53 +02:00
// [D] [A] altered unpack_cellpointers
2020-03-27 21:47:29 +01:00
void Unpack_CellPtrs ( void )
{
2020-04-20 06:55:53 +02:00
SPL_REGIONINFO * spool = & spool_regioninfo [ spool_regionpos ] ;
2020-04-09 19:45:25 +02:00
2020-04-20 06:55:53 +02:00
unpack_cellpointers ( spool - > region_to_unpack , spool - > target_barrel_region , spool - > cell_addr ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ SpecClutsSpooled()
// line 2509, offset 0x0007c74c
/* begin block 1 */
// Start line: 2511
// Start offset: 0x0007C74C
// Variables:
// char *loadaddr; // $s4
// int i; // $s1
// int j; // $s2
// int tpage; // $s0
// struct RECT specCluts; // stack offset -48
/* begin block 1.1 */
// Start line: 2522
// Start offset: 0x0007C7F4
// Variables:
// int index; // $a3
/* begin block 1.1.1 */
// Start line: 2537
// Start offset: 0x0007C91C
/* end block 1.1.1 */
// End offset: 0x0007C91C
// End Line: 2537
/* end block 1.1 */
// End offset: 0x0007C95C
// End Line: 2542
/* end block 1 */
// End offset: 0x0007C9B8
// End Line: 2546
/* begin block 2 */
// Start line: 5647
/* end block 2 */
// End Line: 5648
/* begin block 3 */
// Start line: 5720
/* end block 3 */
// End Line: 5721
/* begin block 4 */
// Start line: 5721
/* end block 4 */
// End Line: 5722
/* begin block 5 */
// Start line: 5730
/* end block 5 */
// End Line: 5731
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SpecClutsSpooled ( void )
{
2020-04-10 01:29:12 +02:00
unsigned char bVar1 ;
2020-04-04 06:49:28 +02:00
short sVar2 ;
short sVar3 ;
u_short uVar4 ;
int iVar5 ;
int iVar6 ;
uint uVar7 ;
2020-04-15 16:15:54 +02:00
ushort * puVar8 ;
2020-04-04 06:49:28 +02:00
int iVar9 ;
int iVar10 ;
char * pcVar11 ;
2020-04-10 01:29:12 +02:00
RECT16 specCluts ;
2020-04-04 06:49:28 +02:00
iVar9 = 0 ;
2020-04-10 01:29:12 +02:00
specCluts . x = slot_clutpos [ specialSlot ] . vx ;
specCluts . y = slot_clutpos [ specialSlot ] . vy ;
specCluts . w = 16 ;
specCluts . h = 1 ;
2020-04-04 06:49:28 +02:00
pcVar11 = specLoadBuffer ;
do {
iVar5 = 7 ;
2020-05-13 12:31:17 +02:00
if ( iVar9 = = 0 )
2020-04-04 06:49:28 +02:00
iVar5 = 6 ;
2020-05-13 12:31:17 +02:00
2020-04-04 06:49:28 +02:00
iVar10 = 0 ;
2020-05-13 12:31:17 +02:00
2020-04-04 06:49:28 +02:00
iVar6 = specialSlot + iVar9 ;
2020-04-10 01:29:12 +02:00
2020-05-13 12:31:17 +02:00
int tpage = specTpages [ GameLevel ] [ ( specspooldata [ 2 ] - 1 ) * 2 + iVar9 ] ;
carTpages [ GameLevel ] [ iVar5 ] = tpageslots [ iVar6 ] = tpage ;
tpageloaded [ tpage ] = specialSlot + iVar9 + 1 ;
slot_tpagepos [ iVar6 ] . vx = tpagepos [ iVar6 ] . x ;
slot_tpagepos [ iVar6 ] . vy = tpagepos [ iVar6 ] . y ;
2020-04-10 01:29:12 +02:00
2020-05-13 12:31:17 +02:00
texture_pages [ tpage ] = GetTPage ( 0 , 0 , slot_tpagepos [ iVar6 ] . vx , slot_tpagepos [ iVar6 ] . vy ) ;
2020-04-10 01:29:12 +02:00
2020-05-13 12:31:17 +02:00
if ( 0 < tpage_texamts [ tpage ] )
2020-04-10 01:29:12 +02:00
{
2020-05-13 12:31:17 +02:00
puVar8 = texture_cluts [ tpage ] ;
2020-04-12 17:29:49 +02:00
2020-04-04 06:49:28 +02:00
do {
2020-04-10 01:29:12 +02:00
LoadImage2 ( & specCluts , ( u_long * ) pcVar11 ) ;
2020-05-13 12:31:17 +02:00
pcVar11 + = 32 ;
2020-04-10 01:29:12 +02:00
2020-05-13 12:31:17 +02:00
* puVar8 + + = GetClut ( specCluts . x , specCluts . y ) ;
2020-04-10 01:29:12 +02:00
IncrementClutNum ( & specCluts ) ;
2020-05-13 12:31:17 +02:00
iVar10 + + ;
} while ( iVar10 < tpage_texamts [ tpage ] ) ;
2020-04-04 06:49:28 +02:00
}
2020-05-13 12:31:17 +02:00
iVar9 + + ;
2020-04-04 06:49:28 +02:00
} while ( iVar9 < 2 ) ;
2020-04-10 01:29:12 +02:00
if ( quickSpool ! = 1 )
{
2020-04-04 06:49:28 +02:00
DrawSyncCallback ( SpecialStartNextBlock ) ;
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ CleanModelSpooled()
// line 2549, offset 0x0007c9b8
/* begin block 1 */
// Start line: 2552
// Start offset: 0x0007C9B8
// Variables:
// int *loadaddr; // $a1
// int *mem; // $a3
/* begin block 1.1 */
// Start line: 2576
// Start offset: 0x0007CA80
/* end block 1.1 */
// End offset: 0x0007CAD0
// End Line: 2587
/* end block 1 */
// End offset: 0x0007CAFC
// End Line: 2591
/* begin block 2 */
// Start line: 5870
/* end block 2 */
// End Line: 5871
/* begin block 3 */
// Start line: 5874
/* end block 3 */
// End Line: 5875
/* begin block 4 */
// Start line: 5876
/* end block 4 */
// End Line: 5877
/* begin block 5 */
// Start line: 5880
/* end block 5 */
// End Line: 5881
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:37:20 +02:00
int * modelMemory ;
int lengthLowBlock ;
int lastCleanBlock ;
int lengthDamBlock ;
int firstLowBlock ;
int firstDamBlock ;
int specBlocksToLoad = 0 ;
int specialState = 0 ;
char specModelValid = 1 ;
int specSpoolComplete ;
// [D]
2020-03-27 21:47:29 +01:00
void CleanModelSpooled ( void )
{
2020-04-04 06:49:28 +02:00
int * piVar1 ;
ushort * puVar2 ;
int iVar4 ;
int * piVar5 ;
int * in_a3 ;
piVar5 = ( int * ) specLoadBuffer ;
2020-05-11 20:10:50 +02:00
if ( specBlocksToLoad = = lastCleanBlock - 1 )
{
piVar5 = ( int * ) ( specLoadBuffer + 12 ) ;
2020-04-04 06:49:28 +02:00
modelMemory = ( int * ) specmallocptr ;
2020-04-10 01:37:20 +02:00
gCarCleanModelPtr [ 4 ] = ( MODEL * ) specmallocptr ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:37:20 +02:00
2020-05-13 20:10:01 +02:00
// memcpy
while ( piVar5 < ( int * ) ( specLoadBuffer + 0x800 ) )
* modelMemory + + = * piVar5 + + ;
2020-04-10 01:37:20 +02:00
2020-05-13 12:37:30 +02:00
in_a3 = ( int * ) ( ( int ) gCarCleanModelPtr [ 4 ] + gCarCleanModelPtr [ 4 ] - > poly_block ) ; // [A] pls check, might be invalid
2020-04-10 01:37:20 +02:00
2020-05-13 11:57:51 +02:00
if ( specBlocksToLoad = = 0 | | in_a3 < modelMemory )
2020-04-10 01:37:20 +02:00
{
2020-05-11 20:10:50 +02:00
specBlocksToLoad = 0 ;
2020-04-04 06:49:28 +02:00
modelMemory = in_a3 ;
2020-05-13 11:57:51 +02:00
gCarCleanModelPtr [ 4 ] - > vertices + = ( int ) gCarCleanModelPtr [ 4 ] ;
gCarCleanModelPtr [ 4 ] - > normals + = ( int ) gCarCleanModelPtr [ 4 ] ;
gCarCleanModelPtr [ 4 ] - > point_normals + = ( int ) gCarCleanModelPtr [ 4 ] ;
gCarCleanModelPtr [ 4 ] - > poly_block + = ( int ) gCarCleanModelPtr [ 4 ] ;
NewCarModel [ 4 ] . nlist = ( SVECTOR * ) gCarCleanModelPtr [ 4 ] - > point_normals ;
2020-05-11 20:10:50 +02:00
NewCarModel [ 4 ] . vlist = ( SVECTOR * ) gCarCleanModelPtr [ 4 ] - > vertices ;
2020-04-04 06:49:28 +02:00
}
2020-05-11 20:10:50 +02:00
2020-04-10 01:37:20 +02:00
if ( quickSpool ! = 1 )
2020-04-04 06:49:28 +02:00
DrawSyncCallback ( SpecialStartNextBlock ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ DamagedModelSpooled()
// line 2594, offset 0x0007cafc
/* begin block 1 */
// Start line: 2596
// Start offset: 0x0007CAFC
// Variables:
// int *loadaddr; // $a1
// int *mem; // $a3
/* begin block 1.1 */
// Start line: 2620
// Start offset: 0x0007CBC0
/* end block 1.1 */
// End offset: 0x0007CBF8
// End Line: 2629
/* end block 1 */
// End offset: 0x0007CC24
// End Line: 2633
/* begin block 2 */
// Start line: 5981
/* end block 2 */
// End Line: 5982
/* begin block 3 */
// Start line: 5985
/* end block 3 */
// End Line: 5986
/* begin block 4 */
// Start line: 5986
/* end block 4 */
// End Line: 5987
/* begin block 5 */
// Start line: 5990
/* end block 5 */
// End Line: 5991
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:37:32 +02:00
int damOffset ;
// [D]
2020-03-27 21:47:29 +01:00
void DamagedModelSpooled ( void )
{
2020-04-04 06:49:28 +02:00
MODEL * pMVar1 ;
int iVar2 ;
int * piVar3 ;
int * in_a3 ;
piVar3 = ( int * ) specLoadBuffer ;
2020-04-10 01:37:32 +02:00
if ( specBlocksToLoad = = lengthDamBlock + - 1 )
{
2020-04-04 06:49:28 +02:00
piVar3 = ( int * ) ( specLoadBuffer + damOffset ) ;
2020-04-10 01:37:32 +02:00
gCarDamModelPtr [ 4 ] = ( MODEL * ) modelMemory ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:37:32 +02:00
2020-05-13 20:10:01 +02:00
// memcpy
while ( piVar3 < ( int * ) ( specLoadBuffer + 0x800 ) )
* modelMemory + + = * piVar3 + + ;
2020-04-10 01:37:32 +02:00
2020-05-13 12:37:30 +02:00
in_a3 = ( int * ) ( ( int ) gCarDamModelPtr [ 4 ] + gCarDamModelPtr [ 4 ] - > poly_block ) ; // [A] pls check, might be invalid
2020-04-10 01:37:32 +02:00
2020-05-13 11:57:51 +02:00
if ( specBlocksToLoad = = 0 | | in_a3 < modelMemory )
2020-04-10 01:37:32 +02:00
{
piVar3 = & gCarDamModelPtr [ 4 ] - > normals ;
2020-04-04 06:49:28 +02:00
specBlocksToLoad = 0 ;
modelMemory = in_a3 ;
2020-05-13 11:57:51 +02:00
gCarDamModelPtr [ 4 ] - > vertices + = ( int ) gCarDamModelPtr [ 4 ] ;
gCarDamModelPtr [ 4 ] - > normals + = ( int ) gCarDamModelPtr [ 4 ] ;
gCarDamModelPtr [ 4 ] - > poly_block + = ( int ) gCarDamModelPtr [ 4 ] ;
gCarDamModelPtr [ 4 ] - > point_normals + = ( int ) gCarDamModelPtr [ 4 ] ;
2020-04-04 06:49:28 +02:00
}
2020-05-13 11:57:51 +02:00
if ( quickSpool ! = 1 )
2020-04-04 06:49:28 +02:00
DrawSyncCallback ( SpecialStartNextBlock ) ;
2020-05-13 11:57:51 +02:00
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ LowModelSpooled()
// line 2635, offset 0x0007cc24
/* begin block 1 */
// Start line: 2637
// Start offset: 0x0007CC24
// Variables:
// int *loadaddr; // $a1
// int *mem; // $a3
/* begin block 1.1 */
// Start line: 2661
// Start offset: 0x0007CCE8
/* end block 1.1 */
// End offset: 0x0007CD38
// End Line: 2672
/* end block 1 */
// End offset: 0x0007CD64
// End Line: 2676
/* begin block 2 */
// Start line: 6081
/* end block 2 */
// End Line: 6082
/* begin block 3 */
// Start line: 6084
/* end block 3 */
// End Line: 6085
/* begin block 4 */
// Start line: 6085
/* end block 4 */
// End Line: 6086
/* begin block 5 */
// Start line: 6089
/* end block 5 */
// End Line: 6090
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:42:04 +02:00
int lowOffset ;
// [D]
2020-03-27 21:47:29 +01:00
void LowModelSpooled ( void )
{
2020-04-04 06:49:28 +02:00
int * piVar1 ;
ushort * puVar2 ;
int iVar4 ;
int * piVar5 ;
int * in_a3 ;
piVar5 = ( int * ) specLoadBuffer ;
2020-05-13 11:57:51 +02:00
if ( specBlocksToLoad = = lengthLowBlock + - 1 )
{
2020-04-04 06:49:28 +02:00
piVar5 = ( int * ) ( specLoadBuffer + lowOffset ) ;
2020-04-10 01:42:04 +02:00
gCarLowModelPtr [ 4 ] = ( MODEL * ) modelMemory ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:42:04 +02:00
2020-05-13 20:10:01 +02:00
// memcpy
while ( piVar5 < ( int * ) ( specLoadBuffer + 0x800 ) )
* modelMemory + + = * piVar5 + + ;
2020-04-10 01:42:04 +02:00
2020-05-13 12:37:30 +02:00
in_a3 = ( int * ) ( ( int ) gCarLowModelPtr [ 4 ] + gCarLowModelPtr [ 4 ] - > poly_block ) ; // [A] pls check, might be invalid
2020-04-10 01:42:04 +02:00
2020-05-13 11:57:51 +02:00
if ( ( specBlocksToLoad = = 0 ) | | ( in_a3 < modelMemory ) )
{
2020-04-04 06:49:28 +02:00
specBlocksToLoad = 0 ;
modelMemory = in_a3 ;
2020-05-13 11:57:51 +02:00
gCarLowModelPtr [ 4 ] - > vertices + = ( int ) gCarLowModelPtr [ 4 ] ;
gCarLowModelPtr [ 4 ] - > normals + = ( int ) gCarLowModelPtr [ 4 ] ;
gCarLowModelPtr [ 4 ] - > poly_block + = ( int ) gCarLowModelPtr [ 4 ] ;
gCarLowModelPtr [ 4 ] - > point_normals + = ( int ) gCarLowModelPtr [ 4 ] ;
NewLowCarModel [ 4 ] . nlist = ( SVECTOR * ) gCarLowModelPtr [ 4 ] - > point_normals ;
NewLowCarModel [ 4 ] . vlist = ( SVECTOR * ) gCarLowModelPtr [ 4 ] - > vertices ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:42:04 +02:00
2020-04-04 06:49:28 +02:00
if ( quickSpool ! = 1 ) {
DrawSyncCallback ( SpecialStartNextBlock ) ;
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ CleanSpooled()
// line 2680, offset 0x0007cd64
/* begin block 1 */
// Start line: 2683
// Start offset: 0x0007CD64
// Variables:
// char *loadaddr; // $a1
/* begin block 1.1 */
// Start line: 2702
// Start offset: 0x0007CE8C
// Variables:
// struct MODEL *tempModel; // $a1
/* end block 1.1 */
// End offset: 0x0007CEE0
// End Line: 2713
/* end block 1 */
// End offset: 0x0007CF0C
// End Line: 2717
/* begin block 2 */
// Start line: 6189
/* end block 2 */
// End Line: 6190
/* begin block 3 */
// Start line: 6194
/* end block 3 */
// End Line: 6195
/* begin block 4 */
// Start line: 6196
/* end block 4 */
// End Line: 6197
/* begin block 5 */
// Start line: 6198
/* end block 5 */
// End Line: 6199
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:42:16 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void CleanSpooled ( void )
{
2020-04-04 06:49:28 +02:00
int * piVar1 ;
char * pcVar2 ;
int iVar3 ;
int iVar4 ;
MODEL * model ;
2020-04-10 01:42:16 +02:00
if ( specBlocksToLoad = = 6 )
{
2020-04-04 06:49:28 +02:00
lastCleanBlock = * ( int * ) specmallocptr + 0x80b ;
lastCleanBlock = lastCleanBlock > > 0xb ;
2020-05-13 08:20:21 +02:00
2020-04-04 06:49:28 +02:00
firstLowBlock = * ( int * ) specmallocptr + * ( int * ) ( specmallocptr + 4 ) + 0xc ;
firstLowBlock = firstLowBlock > > 0xb ;
2020-05-13 08:20:21 +02:00
2020-04-04 06:49:28 +02:00
iVar4 = * ( int * ) specmallocptr + * ( int * ) ( specmallocptr + 4 ) + * ( int * ) ( specmallocptr + 8 ) ;
2020-05-13 08:20:21 +02:00
2020-04-04 06:49:28 +02:00
iVar3 = iVar4 + 0x80b ;
lengthLowBlock = ( iVar3 > > 0xb ) - firstLowBlock ;
2020-05-13 08:20:21 +02:00
2020-05-13 11:57:51 +02:00
lowOffset = ( * ( int * ) specmallocptr + * ( int * ) ( specmallocptr + 4 ) ) - ( firstLowBlock * 0x800 + - 12 ) ;
2020-05-13 08:20:21 +02:00
2020-05-13 11:57:51 +02:00
firstDamBlock = * ( int * ) specmallocptr + 12 ;
2020-04-04 06:49:28 +02:00
firstDamBlock = firstDamBlock > > 0xb ;
2020-05-13 08:20:21 +02:00
2020-04-04 06:49:28 +02:00
iVar3 = * ( int * ) specmallocptr + * ( int * ) ( specmallocptr + 4 ) + 0x80b ;
2020-05-13 08:20:21 +02:00
2020-04-04 06:49:28 +02:00
lengthDamBlock = ( iVar3 > > 0xb ) - firstDamBlock ;
2020-05-13 11:57:51 +02:00
damOffset = * ( int * ) specmallocptr - ( firstDamBlock * 0x800 + - 12 ) ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:42:16 +02:00
2020-05-13 08:20:21 +02:00
model = ( MODEL * ) ( specmallocptr + 12 ) ;
2020-04-10 01:42:16 +02:00
2020-05-13 08:20:21 +02:00
if ( specBlocksToLoad = = 7 - lastCleanBlock )
2020-04-20 06:55:53 +02:00
{
2020-05-13 11:57:51 +02:00
model - > vertices + = ( int ) model ;
model - > poly_block + = ( int ) model ;
model - > normals + = ( int ) model ;
model - > point_normals + = ( int ) model ;
2020-05-13 08:20:21 +02:00
2020-04-04 06:49:28 +02:00
whichCP = baseSpecCP ;
2020-04-20 06:55:53 +02:00
2020-05-13 08:20:21 +02:00
buildNewCarFromModel ( & NewCarModel [ 4 ] , model , 0 ) ;
2020-04-04 06:49:28 +02:00
specBlocksToLoad = 0 ;
}
2020-04-20 06:55:53 +02:00
2020-05-13 08:20:21 +02:00
if ( quickSpool ! = 1 )
2020-04-04 06:49:28 +02:00
DrawSyncCallback ( SpecialStartNextBlock ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ LowSpooled()
// line 2720, offset 0x0007e7c0
/* begin block 1 */
// Start line: 2723
// Start offset: 0x0007E7C0
// Variables:
// char *loadaddr; // $v1
/* begin block 1.1 */
// Start line: 2728
// Start offset: 0x0007E7D8
// Variables:
// struct MODEL *tempModel; // $a1
/* end block 1.1 */
// End offset: 0x0007E820
// End Line: 2737
/* end block 1 */
// End offset: 0x0007E84C
// End Line: 2741
/* begin block 2 */
// Start line: 10317
/* end block 2 */
// End Line: 10318
/* begin block 3 */
// Start line: 10319
/* end block 3 */
// End Line: 10320
/* begin block 4 */
// Start line: 10321
/* end block 4 */
// End Line: 10322
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:42:16 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void LowSpooled ( void )
{
2020-04-04 06:49:28 +02:00
MODEL * model ;
2020-04-10 01:42:16 +02:00
if ( specBlocksToLoad = = 0 )
{
2020-04-04 06:49:28 +02:00
model = ( MODEL * ) ( specmallocptr + lowOffset ) ;
2020-04-10 01:42:16 +02:00
2020-05-13 11:57:51 +02:00
model - > vertices + = ( int ) model ;
model - > normals + = ( int ) model ;
model - > poly_block + = ( int ) model ;
model - > point_normals + = ( int ) model ;
2020-04-10 01:42:16 +02:00
2020-05-13 08:20:21 +02:00
buildNewCarFromModel ( & NewLowCarModel [ 4 ] , model , 0 ) ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:42:16 +02:00
if ( quickSpool ! = 1 )
2020-04-04 06:49:28 +02:00
DrawSyncCallback ( SpecialStartNextBlock ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ Tada()
// line 2744, offset 0x0007cf0c
/* begin block 1 */
// Start line: 2746
// Start offset: 0x0007CF0C
// Variables:
// char *loadaddr; // $s1
/* begin block 1.1 */
// Start line: 2751
// Start offset: 0x0007CF60
// Variables:
// struct RECT tpage; // stack offset -32
// int spec_tpage; // $a0
/* end block 1.1 */
// End offset: 0x0007D018
// End Line: 2764
/* begin block 1.2 */
// Start line: 2767
// Start offset: 0x0007D018
// Variables:
// struct RECT tpage; // stack offset -24
// int spec_tpage; // $a0
/* end block 1.2 */
// End offset: 0x0007D0EC
// End Line: 2780
/* begin block 1.3 */
// Start line: 2783
// Start offset: 0x0007D0EC
/* end block 1.3 */
// End offset: 0x0007D130
// End Line: 2789
/* end block 1 */
// End offset: 0x0007D144
// End Line: 2793
/* begin block 2 */
// Start line: 6312
/* end block 2 */
// End Line: 6313
/* begin block 3 */
// Start line: 6340
/* end block 3 */
// End Line: 6341
/* begin block 4 */
// Start line: 6341
/* end block 4 */
// End Line: 6342
/* begin block 5 */
// Start line: 6342
/* end block 5 */
// End Line: 6343
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:52:35 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void Tada ( void )
{
2020-05-13 08:20:21 +02:00
int spec_tpage ;
RECT16 tpagerect ;
2020-04-04 06:49:28 +02:00
2020-04-10 01:52:35 +02:00
if ( specialState = = 2 )
{
2020-05-13 08:20:21 +02:00
tpagerect . w = 64 ;
tpagerect . h = 16 ;
2020-04-12 17:29:49 +02:00
2020-05-13 08:20:21 +02:00
spec_tpage = specialSlot + 1 ;
tpagerect . x = tpagepos [ spec_tpage ] . x ;
tpagerect . y = tpagepos [ spec_tpage ] . y + ( 15 - specBlocksToLoad ) * 16 ;
2020-04-12 17:29:49 +02:00
2020-05-13 08:20:21 +02:00
if ( specBlocksToLoad = = 15 )
update_slotinfo ( specTpages [ GameLevel ] [ specspooldata [ 2 ] - 1 ] , specialSlot , & tpagerect ) ;
LoadImage ( & tpagerect , ( u_long * ) specLoadBuffer ) ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:52:35 +02:00
else
{
if ( 2 < specialState )
{
if ( specialState ! = 4 )
2020-04-04 06:49:28 +02:00
return ;
2020-04-10 01:52:35 +02:00
2020-04-04 06:49:28 +02:00
SetupSpecCosmetics ( specLoadBuffer ) ;
2020-05-13 08:20:21 +02:00
FixCarCos ( & car_cosmetics [ 4 ] , MissionHeader - > residentModels [ 4 ] ) ;
2020-05-13 11:57:51 +02:00
SetupSpecDenting ( specLoadBuffer + sizeof ( CAR_COSMETICS ) ) ;
2020-04-10 01:52:35 +02:00
if ( quickSpool = = 1 )
2020-04-04 06:49:28 +02:00
return ;
2020-04-10 01:52:35 +02:00
2020-04-04 06:49:28 +02:00
DrawSyncCallback ( SpecialStartNextBlock ) ;
return ;
}
2020-05-13 08:20:21 +02:00
2020-04-10 01:52:35 +02:00
if ( specialState ! = 1 )
2020-04-04 06:49:28 +02:00
return ;
2020-04-10 01:52:35 +02:00
2020-05-13 08:20:21 +02:00
spec_tpage = specialSlot ;
tpagerect . w = 64 ;
tpagerect . h = 16 ;
tpagerect . x = tpagepos [ spec_tpage ] . x ;
tpagerect . y = tpagepos [ spec_tpage ] . y + ( 15 - specBlocksToLoad ) * 16 ;
2020-04-10 01:52:35 +02:00
2020-04-12 17:29:49 +02:00
if ( specBlocksToLoad = = 15 )
2020-05-13 08:20:21 +02:00
update_slotinfo ( specTpages [ GameLevel ] [ specspooldata [ 2 ] - 1 ] , spec_tpage , & tpagerect ) ;
2020-04-10 01:52:35 +02:00
2020-05-13 08:20:21 +02:00
LoadImage ( & tpagerect , ( u_long * ) specLoadBuffer ) ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:52:35 +02:00
if ( quickSpool ! = 1 )
2020-04-04 06:49:28 +02:00
DrawSyncCallback ( SpecialStartNextBlock ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ SpecialStartNextBlock()
// line 2799, offset 0x0007d144
/* begin block 1 */
// Start line: 2801
// Start offset: 0x0007D144
// Variables:
// char *loadaddr; // $s0
// int fileSector; // $t0
/* end block 1 */
// End offset: 0x0007D4D0
// End Line: 2925
/* begin block 2 */
// Start line: 6482
/* end block 2 */
// End Line: 6483
/* begin block 3 */
// Start line: 6489
/* end block 3 */
// End Line: 6490
/* begin block 4 */
// Start line: 6490
/* end block 4 */
// End Line: 6491
/* begin block 5 */
// Start line: 6493
/* end block 5 */
// End Line: 6494
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 01:29:12 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void SpecialStartNextBlock ( void )
{
2020-05-13 08:20:21 +02:00
char * loadaddr ;
int fileSector ;
2020-04-10 01:29:12 +02:00
spooledFuncPtr spoolFunc ;
2020-04-04 06:49:28 +02:00
2020-05-13 08:20:21 +02:00
loadaddr = specLoadBuffer ;
2020-04-04 06:49:28 +02:00
DrawSyncCallback ( 0 ) ;
2020-04-10 01:29:12 +02:00
2020-05-13 11:57:51 +02:00
// if previous state blocks are fully loaded, start next state
2020-05-13 08:20:21 +02:00
if ( specBlocksToLoad = = 0 )
2020-04-10 01:29:12 +02:00
{
2020-05-13 08:20:21 +02:00
switch ( specialState )
2020-04-10 01:29:12 +02:00
{
2020-05-13 08:20:21 +02:00
case 0 :
case 1 :
specBlocksToLoad = 16 ;
break ;
case 2 :
case 3 :
specBlocksToLoad = 1 ;
break ;
case 4 :
specBlocksToLoad = 7 ;
break ;
case 5 :
case 8 :
specBlocksToLoad = lengthLowBlock ;
break ;
case 6 :
specBlocksToLoad = lastCleanBlock ;
break ;
case 7 :
specBlocksToLoad = lengthDamBlock ;
break ;
default :
specBlocksToLoad = 0 ;
2020-04-04 06:49:28 +02:00
}
2020-05-13 11:57:51 +02:00
specialState + + ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 01:29:12 +02:00
2020-05-13 11:57:51 +02:00
fileSector = 0x1400 + ( citystart [ GameLevel ] - citylumps [ GameLevel ] [ CITYLUMP_SPOOL ] . x / 2048 ) + ( specspooldata [ 2 ] - 1 ) * 42 ;
2020-05-13 08:20:21 +02:00
2020-04-10 01:29:12 +02:00
switch ( specialState )
{
case 1 :
spoolFunc = Tada ;
2020-05-13 08:20:21 +02:00
fileSector + = ( 17 - specBlocksToLoad ) ;
2020-04-10 01:29:12 +02:00
break ;
case 2 :
spoolFunc = Tada ;
2020-05-13 08:20:21 +02:00
fileSector + = ( 33 - specBlocksToLoad ) ;
2020-04-10 01:29:12 +02:00
break ;
case 3 :
spoolFunc = SpecClutsSpooled ;
break ;
case 4 :
2020-05-13 08:20:21 +02:00
fileSector + = 33 ;
2020-04-10 01:29:12 +02:00
spoolFunc = Tada ;
break ;
case 5 :
spoolFunc = CleanSpooled ;
2020-05-13 08:20:21 +02:00
fileSector + = ( 41 - specBlocksToLoad ) ;
loadaddr = specmallocptr + ( 7 - specBlocksToLoad ) * 2048 ;
break ;
2020-04-10 01:29:12 +02:00
case 6 :
spoolFunc = LowSpooled ;
2020-05-13 08:20:21 +02:00
fileSector + = ( ( firstLowBlock + lengthLowBlock ) - specBlocksToLoad ) + 34 ;
loadaddr = specmallocptr + ( lengthLowBlock - specBlocksToLoad ) * 2048 ;
2020-04-10 01:29:12 +02:00
break ;
case 7 :
spoolFunc = CleanModelSpooled ;
2020-05-13 08:20:21 +02:00
fileSector + = ( lastCleanBlock - specBlocksToLoad ) + 34 ;
2020-04-10 01:29:12 +02:00
break ;
case 8 :
spoolFunc = DamagedModelSpooled ;
2020-05-13 08:20:21 +02:00
fileSector + = ( ( firstDamBlock + lengthDamBlock ) - specBlocksToLoad ) + 34 ;
2020-04-10 01:29:12 +02:00
break ;
case 9 :
spoolFunc = LowModelSpooled ;
2020-05-13 08:20:21 +02:00
fileSector + = ( ( firstLowBlock + lengthLowBlock ) - specBlocksToLoad ) + 34 ;
2020-04-10 01:29:12 +02:00
break ;
default :
2020-05-13 08:20:21 +02:00
if ( quickSpool = = 1 )
{
specModelValid = 1 ;
specialState = 0 ;
quickSpool = 0 ;
specSpoolComplete = 0 ;
return ;
}
specSpoolComplete = 1 ;
return ;
2020-04-10 01:29:12 +02:00
}
2020-05-13 08:20:21 +02:00
RequestSpool ( 3 , 0 , fileSector , 1 , loadaddr , spoolFunc ) ;
2020-04-20 06:55:53 +02:00
specBlocksToLoad - - ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ CheckSpecialSpool()
// line 2956, offset 0x0007d4e0
/* begin block 1 */
// Start line: 2958
// Start offset: 0x0007D4E0
// Variables:
// struct _CAR_DATA *lcp; // $a0
// int ret; // $a3
/* begin block 1.1 */
// Start line: 2965
// Start offset: 0x0007D51C
/* end block 1.1 */
// End offset: 0x0007D53C
// End Line: 2969
/* end block 1 */
// End offset: 0x0007D6C8
// End Line: 3022
/* begin block 2 */
// Start line: 6827
/* end block 2 */
// End Line: 6828
/* begin block 3 */
// Start line: 6828
/* end block 3 */
// End Line: 6829
/* begin block 4 */
// Start line: 6831
/* end block 4 */
// End Line: 6832
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 13:56:11 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void CheckSpecialSpool ( void )
{
2020-05-13 11:57:51 +02:00
int ret ;
2020-04-04 06:49:28 +02:00
int iVar2 ;
2020-04-10 13:56:11 +02:00
_CAR_DATA * lcp ;
2020-04-04 06:49:28 +02:00
2020-05-13 08:20:21 +02:00
if ( startSpecSpool ! = - 1 & & startSpecSpool + 400 < CameraCnt )
2020-04-10 13:56:11 +02:00
{
2020-05-13 11:57:51 +02:00
while ( specSpoolComplete = = 0 )
2020-04-10 13:56:11 +02:00
{
2020-05-13 11:57:51 +02:00
SpoolSYNC ( ) ;
2020-04-10 13:56:11 +02:00
2020-05-13 11:57:51 +02:00
if ( DrawSync ( 1 ) = = 0 )
SpecialStartNextBlock ( ) ;
2020-04-10 13:56:11 +02:00
2020-05-13 11:57:51 +02:00
StartSpooling ( ) ;
2020-04-04 06:49:28 +02:00
}
2020-05-13 08:20:21 +02:00
specModelValid = 1 ;
2020-04-04 06:49:28 +02:00
specialState = 0 ;
specBlocksToLoad = 0 ;
specSpoolComplete = 0 ;
startSpecSpool = - 1 ;
}
2020-04-10 13:56:11 +02:00
2020-05-13 08:20:21 +02:00
if ( allowSpecSpooling & &
specSpoolComplete ! = 1 & &
GameType ! = GAME_PURSUIT & &
LoadedArea ! = - 1 & &
SpecialByRegion [ GameLevel ] [ LoadedArea ] ! = MissionHeader - > residentModels [ 4 ] - 7 )
2020-04-10 13:56:11 +02:00
{
lcp = car_data ;
2020-05-13 11:57:51 +02:00
// if there are cars that still using special models, deny spooling
2020-04-10 13:56:11 +02:00
do // [A]
{
2020-05-13 11:57:51 +02:00
if ( MissionHeader - > residentModels [ lcp - > ap . model ] > 4 )
return ;
2020-04-10 13:56:11 +02:00
lcp + + ;
2020-05-15 13:38:32 +02:00
} while ( lcp < = & car_data [ 20 ] ) ;
2020-04-10 13:56:11 +02:00
2020-05-13 11:57:51 +02:00
specModelValid = 0 ;
startSpecSpool = CameraCnt ;
2020-04-10 13:56:11 +02:00
2020-05-13 11:57:51 +02:00
gCarDamModelPtr [ 4 ] = NULL ;
gCarCleanModelPtr [ 4 ] = NULL ;
gCarLowModelPtr [ 4 ] = NULL ;
2020-04-10 13:56:11 +02:00
2020-05-13 11:57:51 +02:00
specspooldata [ 2 ] = SpecialByRegion [ GameLevel ] [ LoadedArea ] ;
MissionHeader - > residentModels [ 4 ] = SpecialByRegion [ GameLevel ] [ LoadedArea ] + 7 ;
if ( specialState = = 0 )
SpecialStartNextBlock ( ) ;
2020-04-04 06:49:28 +02:00
}
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ QuickSpoolSpecial()
// line 3025, offset 0x0007e84c
/* begin block 1 */
// Start line: 10949
/* end block 1 */
// End Line: 10950
/* begin block 2 */
// Start line: 10950
/* end block 2 */
// End Line: 10951
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 13:56:11 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void QuickSpoolSpecial ( void )
{
2020-04-04 06:49:28 +02:00
quickSpool = 1 ;
specialState = 0 ;
specBlocksToLoad = 0 ;
2020-04-10 13:56:11 +02:00
gCarCleanModelPtr [ 4 ] = NULL ;
gCarDamModelPtr [ 4 ] = NULL ;
gCarLowModelPtr [ 4 ] = NULL ;
2020-05-13 11:57:51 +02:00
specspooldata [ 2 ] = MissionHeader - > residentModels [ 4 ] - 7 ;
2020-04-10 13:56:11 +02:00
2020-04-04 06:49:28 +02:00
do {
SpoolSYNC ( ) ;
DrawSync ( 0 ) ;
SpecialStartNextBlock ( ) ;
StartSpooling ( ) ;
} while ( quickSpool = = 1 ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ PrepareSecretCar()
// line 3046, offset 0x0007e8dc
/* begin block 1 */
// Start line: 11011
/* end block 1 */
// End Line: 11012
/* begin block 2 */
// Start line: 11012
/* end block 2 */
// End Line: 11013
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 13:56:11 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void PrepareSecretCar ( void )
{
2020-04-04 06:49:28 +02:00
allowSpecSpooling = 0 ;
PingOutAllSpecialCivCars ( ) ;
2020-04-10 13:56:11 +02:00
gCarDamModelPtr [ 4 ] = NULL ;
gCarCleanModelPtr [ 4 ] = NULL ;
gCarLowModelPtr [ 4 ] = NULL ;
specspooldata [ 2 ] = 5 ;
2020-05-13 11:57:51 +02:00
specModelValid = 0 ;
2020-04-04 06:49:28 +02:00
startSpecSpool = CameraCnt ;
2020-05-13 11:57:51 +02:00
MissionHeader - > residentModels [ 4 ] = 12 ;
2020-04-04 06:49:28 +02:00
specialState = 0 ;
specBlocksToLoad = 0 ;
SpecialStartNextBlock ( ) ;
2020-03-27 21:47:29 +01:00
}
// decompiled code
// original method signature:
// void /*$ra*/ InitSpecSpool()
// line 3063, offset 0x0007d6d8
/* begin block 1 */
// Start line: 7058
/* end block 1 */
// End Line: 7059
/* begin block 2 */
// Start line: 7059
/* end block 2 */
// End Line: 7060
/* begin block 3 */
// Start line: 7064
/* end block 3 */
// End Line: 7065
/* WARNING: Unknown calling convention yet parameter storage is locked */
2020-04-10 13:56:11 +02:00
// [D]
2020-03-27 21:47:29 +01:00
void InitSpecSpool ( void )
{
2020-05-29 18:44:33 +02:00
switch ( gCurrentMissionNumber )
2020-04-10 13:56:11 +02:00
{
2020-05-29 18:44:33 +02:00
case 2 :
case 4 :
case 6 :
case 7 :
case 10 :
case 11 :
case 12 :
case 13 :
case 16 :
case 18 :
case 19 :
case 20 :
case 24 :
case 26 :
case 27 :
case 29 :
case 30 :
case 31 :
case 33 :
case 35 :
case 38 :
case 39 :
case 40 :
case 58 :
case 59 :
case 60 :
case 61 :
case 62 :
case 63 :
case 64 :
case 65 :
case 70 :
case 78 :
case 86 :
case 94 :
case 228 :
case 229 :
case 236 :
case 237 :
case 244 :
case 245 :
case 252 :
case 253 :
case 352 :
case 353 :
case 360 :
case 169 :
case 368 :
case 369 :
case 376 :
case 377 :
case 420 :
case 421 :
case 428 :
case 429 :
case 436 :
case 437 :
case 444 :
case 445 :
case 480 :
case 481 :
case 482 :
case 483 :
case 484 :
case 485 :
case 486 :
case 487 :
case 498 :
case 499 :
case 500 :
case 501 :
case 502 :
case 503 :
case 504 :
case 505 :
allowSpecSpooling = 0 ;
break ;
default :
allowSpecSpooling = 1 ;
2020-04-04 06:49:28 +02:00
}
2020-04-10 13:56:11 +02:00
specModelValid = 1 ;
2020-04-04 06:49:28 +02:00
specialState = 0 ;
specBlocksToLoad = 0 ;
quickSpool = 0 ;
specSpoolComplete = 0 ;
startSpecSpool = - 1 ;
2020-03-27 21:47:29 +01:00
}