Merge pull request #9 from OpenDriver2/develop-SoapyMan

Sound engine refactoring and bug fixes
This commit is contained in:
Ilya 2020-11-04 00:53:13 +06:00 committed by GitHub
commit f2c04a7fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 1553 additions and 1803 deletions

View File

@ -1,4 +1,4 @@
version: 2.6.{build}
version: 3.0.{build}
branches:
only:

View File

@ -1253,7 +1253,7 @@ int CarBuildingCollision(CAR_DATA *cp, BUILDING_BOX *building, CELL_OBJECT *cop,
if (NumPlayers > 1 && NoPlayerControl == 0)
SetPlayerOwnsChannel(chan, player_id);
Start3DSoundVolPitch(chan, 1, match->sound,
Start3DSoundVolPitch(chan, SOUND_BANK_SFX, match->sound,
collisionResult.hit.vx, -collisionResult.hit.vy, collisionResult.hit.vz,
match->volume, match->pitch + (((velocity.vx ^ velocity.vz) * (collisionResult.hit.vx ^ collisionResult.hit.vz) & 0x3ff) - 0x200));
}

View File

@ -4845,7 +4845,7 @@ void SetUpCivCollFlags(void)
else
sample = cp0->ap.model - 1;
Start3DSoundVolPitch(hornchanflag[i], 3, sample * 3 + 2, cp0->hd.where.t[0], cp0->hd.where.t[1], cp0->hd.where.t[2], -2000, 0x1000);
Start3DSoundVolPitch(hornchanflag[i], SOUND_BANK_CARS, sample * 3 + 2, cp0->hd.where.t[0], cp0->hd.where.t[1], cp0->hd.where.t[2], -2000, 0x1000);
horncarflag[i] = cp0;
channels[hornchanflag[i]].time += rnd - (rnd / 30) * 30;

View File

@ -468,7 +468,7 @@ void ControlCops(void)
else
phrase = rnd % 3;
phrase = rnd + phrase;
//phrase = rnd + phrase;
if (first_offence == 0 && last_cop_phrase != phrase && TimeSinceLastSpeech > 720)
{

View File

@ -21,6 +21,7 @@
#include "SHADOW.H"
#include "COSMETIC.H"
#include "DENTING.H"
#include "GAMESND.H"
#include "ROADBITS.H"
#include "../ASM/ASMTEST.H"
@ -5858,7 +5859,7 @@ void DoThunder(void)
ThunderTimer--;
if(ThunderTimer == 0)
StartSound(-1, 1, 12, -ThunderDistance, (rand() % 2048) + 3072);
StartSound(-1, SOUND_BANK_SFX, 12, -ThunderDistance, (rand() % 2048) + 3072);
}
}

View File

@ -12,6 +12,7 @@
#include "BCOLLIDE.H"
#include "CAMERA.H"
#include "CONVERT.H"
#include "GAMESND.H"
#include "MAP.H"
#include "SOUND.H"
#include "GLAUNCH.H"
@ -641,7 +642,7 @@ void SetSmashedCone(int cone, VECTOR *velocity, int player, int side)
SetPlayerOwnsChannel(chan, player);
pTVar4 = gTrailblazerData + cone;
Start3DSoundVolPitch(chan, 1, 5, pTVar4->x, pTVar4->y, pTVar4->z, -2000, 800);
Start3DSoundVolPitch(chan, 1, SOUND_BANK_MISSION, pTVar4->x, pTVar4->y, pTVar4->z, -2000, 800);
}
}

View File

@ -2091,6 +2091,11 @@ void StepFromToEvent(EVENT* ev)
if (ev == events.cameraEvent)
{
SetSpecialCamera(SPECIAL_CAMERA_RESET, 0);
if(direction == 16384)
{
SetMSoundVar(3, NULL);
}
}
}
}
@ -4577,7 +4582,7 @@ VECTOR* TriggerEvent(int i)
event->data = &HavanaFerryData[6];
break;
case 2:
TriggerDoor(&havanaFixed[0], stage + i, 1);
TriggerDoor(&havanaFixed[0], &stage[i], 1);
break;
case 3:
PrepareSecretCar();
@ -4591,6 +4596,8 @@ VECTOR* TriggerEvent(int i)
event[1].node++;
}
SetMSoundVar(1, &event[1].position);
event[1].timer = 0;
events.cameraEvent = &event[1];
}

View File

@ -322,7 +322,7 @@ void NoteFelony(FELONY_DATA *pFelonyData, char type, short scale)
if (first_offence == 0 && numActiveCops)
{
// say something..
rnd = Random2(1) & 0xff;
rnd = Random2(1);
dir = GetCarDirectionOfTravel(&car_data[player[0].playerCarId]);
switch (type)
@ -340,19 +340,19 @@ void NoteFelony(FELONY_DATA *pFelonyData, char type, short scale)
CopSay(5, 0);
break;
case 4:
if ((rnd - (((uint)((long long)rnd * 0xaaaaaaab >> 0x20) & 0xfffffffe) + rnd / 3) & 0xff) != 0)
if ((rnd % 3) & 0xff != 0)
break;
CopSay((rnd & 1) + 7, 0);
break;
default:
if ((rnd - (((uint)((long long)rnd * 0xf0f0f0f1 >> 0x20) & 0xfffffff0) + rnd / 17) & 0xff) == 0)
if ((rnd % 17) & 0xFF == 0)
{
if (MaxPlayerDamage[0] * 3 >> 2 < car_data[player[0].playerCarId].totalDamage)
phrase = rnd & 3;
if (MaxPlayerDamage[0] * 3 / 4 < car_data[player[0].playerCarId].totalDamage)
phrase = rnd % 4;
else
phrase = rnd - (((uint)((long long)rnd * 0xaaaaaaab >> 0x20) & 0xfffffffe) + rnd / 3) & 0xff;
phrase = rnd % 3;
if (last_cop_phrase != phrase && 0 < TimeSinceLastSpeech)
{
@ -661,7 +661,8 @@ void CheckPlayerMiscFelonies(void)
}
#if 0
printInfo("ROAD lane: %d / %d, (%d). AI drive: %d, flg: %d%d%d, dir: %d, spd: %d (wrong way: %d)\n",
printInfo("ROAD %d lane: %d / %d, (%d). AI drive: %d, flg: %d%d%d, dir: %d, spd: %d (wrong way: %d)\n",
roadInfo.surfId,
lane + 1,
((u_char)roadInfo.NumLanes & 0xF) * 2, // lane count. * 2 for both sides as roads are symmetric
IS_NARROW_ROAD(&roadInfo),

View File

@ -9,10 +9,7 @@
#include "SYSTEM.H"
#include "PAD.H"
#include "SOUND.H"
#include "FMVPLAY.H"
#include "E3STUFF.H"
#include "GAMESND.H"
#include "SCORES.H"
#include "MAIN.H"
// FMV
@ -42,7 +39,7 @@ int gNoFMV = 0;
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
void ReInitSystem(void)
{
StopCallback();
@ -50,9 +47,9 @@ void ReInitSystem(void)
ResetGraph(1);
SetVideoMode(video_mode);
InitGeom();
SetGeomOffset(0xa0, 0x80);
scr_z = 0x100;
SetGeomScreen(0x100);
SetGeomOffset(160, 128);
scr_z = 256;
SetGeomScreen(256);
MemCardInit(1);
InitControllers();
CdInit();
@ -100,16 +97,16 @@ void ReInitSystem(void)
/* end block 3 */
// End Line: 137
// [D]
// [D] [T]
void PlayFMV(unsigned char render)
{
RENDER_ARGS args;
if ((render - 16 < 13) || (render == 97))
if (render - 16U < 13 || render == 97)
{
CheckForCorrectDisc(1);
}
else if (((render - 1 & 0xff) < 0xf) || (render == 98))
else if ((render - 1U & 0xff) < 15 || render == 98)
{
CheckForCorrectDisc(0);
}
@ -121,7 +118,7 @@ void PlayFMV(unsigned char render)
PlayRender(&args);
if ((render - 1 & 0xff) < 0x62)
if ((render - 1 & 0xff) < 98)
SetPleaseWait(NULL);
}
@ -159,7 +156,7 @@ void PlayFMV(unsigned char render)
extern int FMV_main(RENDER_ARGS* args);
// [D] [A]
// [D] [T]
void PlayRender(RENDER_ARGS *args)
{
static unsigned long oldsp;

View File

@ -29,6 +29,57 @@
#include "FELONY.H"
enum SoundBankIds
{
SBK_ID_MENU = 0, // frontend, alpha 1.6 used it in ingame menu as well
SBK_ID_SFX = 1,
SBK_CAR_SOUNDS_START = 2,
SBK_ID_JERICHO = 19, // jericho_in_back
SBK_ID_JONES = 20,
SBK_CITY_EFFECTS_START = 21,
SBK_COP_PHRASES_START = 29,
SBK_ID_COUNTDOWN = 44,
// Mission banks start
// Jones banks
SBK_ID_MISSION_2 = 45, // Chase the witness
SBK_ID_MISSION_3 = 46, // Train pursuit
SBK_ID_MISSION_4 = 47,
SBK_ID_MISSION_10 = 48,
SBK_ID_MISSION_11 = 49, // Hijack the truck
SBK_ID_MISSION_13 = 50, // Steal the truck
SBK_ID_FERRY = 51, // Escape to ferry / To the docks
SBK_ID_MISSION_18 = 52, // Tail Jericho
SBK_ID_MISSION_22 = 53, // Beat the train
SBK_ID_MISSION_23 = 54, // Car bomb
SBK_ID_MISSION_24 = 55, // Stake out
SBK_ID_MISSION_27 = 56,
SBK_ID_MISSION_29 = 57, // C4 deal
SBK_ID_MISSION_30 = 58, // Destroy the yard
SBK_ID_MISSION_32 = 59, // Steal the cop car
SBK_ID_MISSION_33 = 60, // Caine's cash - UNUSED
SBK_ID_MISSION_35 = 61, // Boat jump
SBK_ID_MISSION_39 = 62, // Lenny escaping - UNUSED
SBK_ID_MISSION_40 = 63, // Lenny gets caught
SBK_ID_HAVANA_TAKEADRIVE = 64,
SBK_ID_VEGAS_TAKEADRIVE = 65,
SBK_ID_TANNER = 66,
SBK_ID_SPECIAL_SIREN1 = 67,
SBK_ID_SPECIAL_SIREN2 = 68,
SBK_COP_SIREN_START = 69,
};
typedef void(*envsoundfunc)(__envsound* ep /*$s1*/, __envsoundinfo* E /*$a1*/, int pl /*$a2*/);
void IdentifyZone(envsound* ep, envsoundinfo* E, int pl);
@ -65,7 +116,7 @@ int xm_coptrackpos_d2[8] = {
};
int xm_coptrackpos_d1[8] = {
0xC, 0xC, 0xB, 0xB, 8, 0xB, 0xF, 0xC,
0xB, 0xC, 0xB, 0xB, 8, 0xB, 0xF, 0xC,
};
int* xm_coptrackpos;
@ -426,21 +477,21 @@ void LoadLevelSFX(int missionNum)
// load car banks
do {
LoadBankFromLump(3, MapCarIndexToBank(i));
LoadBankFromLump(SOUND_BANK_CARS, MapCarIndexToBank(i));
i++;
} while (i < 3);
ShowLoading();
// load footsteps, car effects etc
LoadBankFromLump(1, 0);
LoadBankFromLump(1, 1);
LoadBankFromLump(6, 66);
LoadBankFromLump(SOUND_BANK_SFX, SBK_ID_MENU);
LoadBankFromLump(SOUND_BANK_SFX, SBK_ID_SFX);
LoadBankFromLump(SOUND_BANK_TANNER, SBK_ID_TANNER );
if (GameLevel & 2)
LoadBankFromLump(2, (GameLevel & 1) * 2 + 69);
LoadBankFromLump(SOUND_BANK_VOICES, SBK_COP_SIREN_START + (GameLevel & 1) * 2);
else
LoadBankFromLump(2, (GameLevel & 3) + 69);
LoadBankFromLump(SOUND_BANK_VOICES, SBK_COP_SIREN_START + (GameLevel & 3));
// Load cop voices except those missions
if (missionNum - 1U > 3 && missionNum != 6 && missionNum != 7 &&
@ -453,13 +504,13 @@ void LoadLevelSFX(int missionNum)
{
if (GameLevel & 2)
{
LoadBankFromLump(2, (GameLevel & 1) * 8 + (GameLevel & 1) * 2 + 29);
LoadBankFromLump(2, (GameLevel & 1) * 10 + cop_bank + 29);
LoadBankFromLump(SOUND_BANK_VOICES, SBK_COP_PHRASES_START + (GameLevel & 1) * 8 + (GameLevel & 1) * 2);
LoadBankFromLump(SOUND_BANK_VOICES, SBK_COP_PHRASES_START + (GameLevel & 1) * 10 + cop_bank);
}
else
{
LoadBankFromLump(2, (GameLevel & 3) * 4 + (GameLevel & 3) + 29);
LoadBankFromLump(2, (GameLevel & 3) * 5 + cop_bank + 29);
LoadBankFromLump(SOUND_BANK_VOICES, SBK_COP_PHRASES_START + (GameLevel & 3) * 4 + (GameLevel & 3));
LoadBankFromLump(SOUND_BANK_VOICES, SBK_COP_PHRASES_START + (GameLevel & 3) * 5 + cop_bank);
}
}
@ -469,133 +520,134 @@ void LoadLevelSFX(int missionNum)
if (NumPlayers < 2 || NoPlayerControl != 0)
{
if (GameLevel == 0)
LoadBankFromLump(4, city_night_fx + 21);
LoadBankFromLump(SOUND_BANK_ENVIRONMENT, SBK_CITY_EFFECTS_START + city_night_fx);
else if (GameLevel == 1)
LoadBankFromLump(4, city_night_fx + 23);
LoadBankFromLump(SOUND_BANK_ENVIRONMENT, SBK_CITY_EFFECTS_START + city_night_fx + 2);
else if (GameLevel == 2)
LoadBankFromLump(4, city_night_fx + 25);
LoadBankFromLump(SOUND_BANK_ENVIRONMENT, SBK_CITY_EFFECTS_START + city_night_fx + 4);
else if (GameLevel == 3)
LoadBankFromLump(4, city_night_fx + 27);
LoadBankFromLump(SOUND_BANK_ENVIRONMENT, SBK_CITY_EFFECTS_START + city_night_fx + 6);
}
// total phrases
phrase_top = 0;
if (missionNum - 2U < 3 || missionNum == 9 || missionNum == 10 || missionNum == 27)
{
LoadBankFromLump(5, 20);
LoadBankFromLump(SOUND_BANK_MISSION, SBK_ID_JONES);
phrase_top = 7;
}
else if (missionNum - 20U < 2 || missionNum == 25 || missionNum == 39)
{
LoadBankFromLump(5, 19);
LoadBankFromLump(SOUND_BANK_MISSION, SBK_ID_JERICHO);
phrase_top = 3;
}
switch (missionNum)
{
case 2:
index = 45;
index = SBK_ID_MISSION_2;
break;
case 3:
index = 46;
index = SBK_ID_MISSION_3;
break;
case 4:
index = 47;
index = SBK_ID_MISSION_4;
break;
case 10:
index = 48;
index = SBK_ID_MISSION_10;
break;
case 13:
index = 50;
index = SBK_ID_MISSION_13;
break;
case 15:
index = 51;
index = SBK_ID_FERRY;
break;
case 16:
index = 51;
index = SBK_ID_FERRY;
break;
case 18:
index = 52;
index = SBK_ID_MISSION_18;
break;
case 22:
index = 53;
index = SBK_ID_MISSION_22;
break;
case 23:
index = 54;
index = SBK_ID_MISSION_23;
break;
case 24:
index = 55;
index = SBK_ID_MISSION_24;
break;
case 27:
index = 56;
index = SBK_ID_MISSION_27;
break;
case 29:
index = 57;
index = SBK_ID_MISSION_29;
break;
case 30:
index = 58;
index = SBK_ID_MISSION_30;
break;
case 25:
case 32:
index = 59;
index = SBK_ID_MISSION_32;
break;
case 33:
index = 60;
index = SBK_ID_MISSION_33;
break;
case 35:
index = 61;
index = SBK_ID_MISSION_35;
break;
case 39:
index = 62;
index = SBK_ID_MISSION_39;
break;
case 40:
index = 63;
index = SBK_ID_MISSION_40;
break;
case 52:
case 53:
index = SBK_ID_HAVANA_TAKEADRIVE; // [A] load Havana bank again
break;
case 54:
index = 65;
break;
case 55:
index = 65;
index = SBK_ID_VEGAS_TAKEADRIVE;
break;
case 11:
case 20:
case 21:
case 52:
case 53:
case 56:
case 57:
index = 49;
index = SBK_ID_MISSION_11;
break;
default:
index = 0;
}
if (index != 0)
LoadBankFromLump(5, index);
LoadBankFromLump(SOUND_BANK_MISSION, index);
if (GameLevel == 0 || GameLevel == 3)
LoadBankFromLump(1, 67);
LoadBankFromLump(SOUND_BANK_SFX, SBK_ID_SPECIAL_SIREN1);
else if (GameLevel == 2)
LoadBankFromLump(1, 68);
LoadBankFromLump(SOUND_BANK_SFX, SBK_ID_SPECIAL_SIREN2);
LoadSoundBankDynamic(NULL, 1, 0);
LoadSoundBankDynamic(NULL, 3, 3);
if (gCurrentMissionNumber - 39 < 2)
LoadBankFromLump(3, MapCarIndexToBank(4));
LoadBankFromLump(SOUND_BANK_CARS, MapCarIndexToBank(4));
else
LoadBankFromLump(3, SpecialVehicleKludge(0));
LoadBankFromLump(SOUND_BANK_CARS, SpecialVehicleKludge(0));
if (missionNum != 24 && missionNum != 27 &&
missionNum != 29 && missionNum != 30 &&
missionNum != 35)
{
LoadBankFromLump(3, SpecialVehicleKludge(1));
LoadBankFromLump(SOUND_BANK_CARS, SpecialVehicleKludge(1));
}
if (missionNum - 50U < 16)
{
LoadBankFromLump(3, SpecialVehicleKludge(2));
LoadBankFromLump(SOUND_BANK_CARS, SpecialVehicleKludge(2));
}
// disable cop speech on specific missions (gangs)
@ -715,7 +767,7 @@ void StartGameSounds(void)
pitch = 129;
}
Start3DSoundVolPitch(channel, 3, sample * 3 + 1, cp->hd.where.t[0], cp->hd.where.t[1], cp->hd.where.t[2], -10000, pitch);
Start3DSoundVolPitch(channel, SOUND_BANK_CARS, sample * 3 + 1, cp->hd.where.t[0], cp->hd.where.t[1], cp->hd.where.t[2], -10000, pitch);
if (car_model == 4)
sample = ResidentModelsBodge() * 3;
@ -735,7 +787,7 @@ void StartGameSounds(void)
pitch = 129;
}
Start3DSoundVolPitch(channel, 3, sample, cp->hd.where.t[0], cp->hd.where.t[1], cp->hd.where.t[2], -10000, pitch);
Start3DSoundVolPitch(channel, SOUND_BANK_CARS, sample, cp->hd.where.t[0], cp->hd.where.t[1], cp->hd.where.t[2], -10000, pitch);
siren = CarHasSiren(car_model);
@ -1059,9 +1111,9 @@ void ControlCarRevs(CAR_DATA* cp)
void DoSpeech(int chan, int sound)
{
if (sound >= 100)
StartSound(chan, 5, sound - 100, 0, 4096);
StartSound(chan, SOUND_BANK_MISSION, sound - 100, 0, 4096);
else if (sound != 0)
StartSound(chan, 2, sound, -1500, 4096);
StartSound(chan, SOUND_BANK_VOICES, sound, -1500, 4096);
}
@ -1203,15 +1255,15 @@ void ControlSpeech(SPEECH_QUEUE* pSpeechQueue)
pSpeechQueue->count--;
DoSpeech(pSpeechQueue->chan, pSpeechQueue->slot[pSpeechQueue->count]);
TimeSinceLastSpeech = 0;
}
else if (SpuGetKeyStatus(SPU_VOICECH(pSpeechQueue->chan)) == 0)
{
pSpeechQueue->count--;
DoSpeech(pSpeechQueue->chan, pSpeechQueue->slot[pSpeechQueue->count]);
TimeSinceLastSpeech = 0;
}
TimeSinceLastSpeech = 0;
}
@ -1245,14 +1297,24 @@ void CopSay(int phrase, int direction)
if (cop_bank != 2 && cop_bank != 3)
return;
}
else
{
if (phrase != 15)
return;
if (cop_bank != 4)
return;
if (cop_bank != 1)
{
if (cop_bank == 2)
return;
if (cop_bank == 3)
return;
if (cop_bank != 4)
return;
}
}
PlaySpeech(&gSpeechQueue, direction + 1);
@ -1662,7 +1724,7 @@ void DoDopplerSFX(void)
else
{
// play music
siren_noise[j].chan = Start3DTrackingSound(-1, 4, 5,
siren_noise[j].chan = Start3DTrackingSound(-1, SOUND_BANK_ENVIRONMENT, 5,
(VECTOR*)car_data[car].hd.where.t,
car_data[car].st.n.linearVelocity);
}
@ -1770,7 +1832,7 @@ void DoDopplerSFX(void)
else
sample = bank * 3;
car_noise[j].chan = Start3DTrackingSound(-1, 3, sample, (VECTOR*)car_data[car].hd.where.t, car_data[car].st.n.linearVelocity);
car_noise[j].chan = Start3DTrackingSound(-1, SOUND_BANK_CARS, sample, (VECTOR*)car_data[car].hd.where.t, car_data[car].st.n.linearVelocity);
LockChannel(car_noise[j].chan);
break;
@ -1822,7 +1884,7 @@ void DoDopplerSFX(void)
else
sample = bank * 3;
car_noise[j].chan = Start3DTrackingSound(-1, 3, sample, (VECTOR*)car_data[car].hd.where.t, car_data[car].st.n.linearVelocity);
car_noise[j].chan = Start3DTrackingSound(-1, SOUND_BANK_CARS, sample, (VECTOR*)car_data[car].hd.where.t, car_data[car].st.n.linearVelocity);
LockChannel(car_noise[j].chan);
}
@ -1937,7 +1999,7 @@ void DoPoliceLoudhailer(int cars, ushort* indexlist, ulong* dist)
if (car_ptr->controlType == CONTROL_TYPE_PURSUER_AI && car_ptr->ai.p.dying == 0 &&
time < loudhail_time && rnd == (rnd / 31) * 31)
{
Start3DTrackingSound(-1, 2, rnd % 2 + 13, (VECTOR*)car_ptr->hd.where.t, car_ptr->st.n.linearVelocity);
Start3DTrackingSound(-1, SOUND_BANK_VOICES, rnd % 2 + 13, (VECTOR*)car_ptr->hd.where.t, car_ptr->st.n.linearVelocity);
loudhail_time = 0;
break;
}
@ -2066,7 +2128,7 @@ void CollisionSound(char player_id, CAR_DATA* cp, int impact, int car_car)
chan = GetFreeChannel();
SetPlayerOwnsChannel(chan, playerid);
Start3DSoundVolPitch(chan, 1, sample, cp->hd.where.t[0], cp->hd.where.t[1], cp->hd.where.t[2], -2750, impact - (impact / 1024) * 1024 + 3584);
Start3DSoundVolPitch(chan, SOUND_BANK_SFX, sample, cp->hd.where.t[0], cp->hd.where.t[1], cp->hd.where.t[2], -2750, impact - (impact / 1024) * 1024 + 3584);
player[playerid].crash_timer = 2;
@ -2177,7 +2239,7 @@ void ExplosionSound(VECTOR* pos, int type)
P.vy = pos->vy * sc1 + player[0].cameraPos.vy * sc2;
P.vz = pos->vz * sc1 + player[0].cameraPos.vz * sc2;
Start3DSoundVolPitch(-1, 5,
Start3DSoundVolPitch(-1, SOUND_BANK_MISSION,
bang, P.vx / 4, P.vy / 4, P.vz / 4,
0, ((FrameCnt * pos->vx ^ rnd * pos->vz) & 0x3ffU) + 0xe00);
}
@ -2357,7 +2419,7 @@ void SoundTasks(void)
// play engine start sound
if (cp && lcp->car_sound_timer == 4)
{
Start3DSoundVolPitch(-1, 6, 4, cp->hd.where.t[0], cp->hd.where.t[1], cp->hd.where.t[2], -2500, 3072);
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 4, cp->hd.where.t[0], cp->hd.where.t[1], cp->hd.where.t[2], -2500, 3072);
}
if (lcp->car_sound_timer == 0)
@ -2498,9 +2560,11 @@ void InitMusic(int musicnum)
char* addr;
int musicpos[3];
char* d1musicName = "SOUND\\D1MUSIC.BIN";
char* musicname = "SOUND\\MUSIC.BIN";
#ifndef PSX
char* d1musicName = "SOUND\\D1MUSIC.BIN";
// search for Driver 1 music file
if (gDriver1Music && FileExists(d1musicName))
{
@ -2508,6 +2572,7 @@ void InitMusic(int musicnum)
xm_coptrackpos = xm_coptrackpos_d1;
}
else
#endif
{
name = musicname;
xm_coptrackpos = xm_coptrackpos_d2;
@ -3601,7 +3666,6 @@ unsigned int horn_time;
void InitLeadHorn(void)
{
horn_time = 0;
return;
}
@ -3650,7 +3714,7 @@ void LeadHorn(CAR_DATA* cp)
else
carBank = cp->ap.model - 1;
Start3DTrackingSound(-1, 3, carBank * 3 + 2, (VECTOR*)cp->hd.where.t, cp->st.n.linearVelocity);
Start3DTrackingSound(-1, SOUND_BANK_CARS, carBank * 3 + 2, (VECTOR*)cp->hd.where.t, cp->st.n.linearVelocity);
horn_time = 0;
}

View File

@ -1,6 +1,14 @@
#ifndef GAMESND_H
#define GAMESND_H
// Game loaded sound banks. DO NOT EDIT!
#define SOUND_BANK_SFX 1
#define SOUND_BANK_VOICES 2
#define SOUND_BANK_CARS 3
#define SOUND_BANK_ENVIRONMENT 4
#define SOUND_BANK_MISSION 5
#define SOUND_BANK_TANNER 6
extern int gDriver1Music;
extern int TimeSinceLastSpeech;

View File

@ -2,7 +2,6 @@
#include "GLAUNCH.H"
#include "LIBETC.H"
#include "SYSTEM.H"
#include "MAIN.H"
@ -12,12 +11,13 @@
#include "REPLAYS.H"
#include "MISSION.H"
#include "GAMESND.H"
#include "SYSTEM.H"
#include "CAMERA.H"
#include "FMVPLAY.H"
#include "../FRONTEND/FEMAIN.H"
#include <string.h>
#include "LIBETC.H"
#include "STRINGS.H"
MISSION_STEP MissionLadder[68] =
{
@ -92,7 +92,9 @@ MISSION_STEP MissionLadder[68] =
};
unsigned short RecapFrameLength[19] = {
0x203, 0x2FC, 0x3C2, 0x496, 0x56D, 0x616, 0x6D4, 0x70E, 0x800, 0x8CD, 0x99A, 0x430, 0x550, 0x5E3, 0x67B, 0x96D, 0xA17, 0xAC9, 0xBB6
515, 764, 962, 1174, 1389, 1558, 1748,
1806, 2048, 2253, 2458, 1072, 1360,
1507, 1659, 2413, 2583, 2761, 2998
};
ACTIVE_CHEATS AvailableCheats = { 0 };
@ -147,13 +149,13 @@ int gFurthestMission = 0;
int gWantNight = 0;
// [D]
// [D] [T]
void GameStart(void)
{
int iVar1;
int oldVibrationMode;
int SurvivalCopSettingsBackup;
if( GameType != GAME_CONTINUEMISSION &&
if (GameType != GAME_CONTINUEMISSION &&
GameType != GAME_MISSION &&
GameType != GAME_REPLAYMISSION)
{
@ -173,7 +175,7 @@ void GameStart(void)
SurvivalCopSettingsBackup = gCopDifficultyLevel;
NewLevel = 1;
switch (GameType)
switch (GameType)
{
case GAME_MISSION:
RunMissionLadder(1);
@ -181,15 +183,17 @@ void GameStart(void)
case GAME_TAKEADRIVE:
if (NumPlayers == 1)
iVar1 = 50;
gCurrentMissionNumber = 50;
else
iVar1 = 58;
gCurrentMissionNumber = 58;
gCurrentMissionNumber += GameLevel * 2 + gWantNight + gSubGameNumber * 440;
gCurrentMissionNumber = iVar1 + GameLevel * 2 + gWantNight + gSubGameNumber * 440;
LaunchGame();
break;
case GAME_IDLEDEMO:
iVar1 = gVibration;
oldVibrationMode = gVibration;
if (LoadAttractReplay(gCurrentMissionNumber))
{
gVibration = 0;
@ -199,50 +203,58 @@ void GameStart(void)
LaunchGame();
gLoadedReplay = 0;
gVibration = iVar1;
gVibration = oldVibrationMode;
}
break;
case GAME_PURSUIT:
gCurrentMissionNumber = GameLevel * 8 + 70 + gWantNight * 4 + gSubGameNumber;
gCurrentMissionNumber = 70 + GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
LaunchGame();
break;
case GAME_GETAWAY:
gCurrentMissionNumber = GameLevel * 8 + 102 + gWantNight * 4 + gSubGameNumber;
gCurrentMissionNumber = 102 + GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
LaunchGame();
break;
case GAME_GATERACE:
if (NumPlayers == 1)
iVar1 = 134;
gCurrentMissionNumber = 134;
else
iVar1 = 164;
gCurrentMissionNumber = 164;
gCurrentMissionNumber = iVar1 + GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
gCurrentMissionNumber += GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
LaunchGame();
break;
case GAME_CHECKPOINT:
if (NumPlayers == 1)
iVar1 = 196;
gCurrentMissionNumber = 196;
else
iVar1 = 228;
gCurrentMissionNumber = 228;
gCurrentMissionNumber = iVar1 + GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
gCurrentMissionNumber += GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
LaunchGame();
break;
case GAME_TRAILBLAZER:
gCurrentMissionNumber = GameLevel * 8 + 260 + gWantNight * 4 + gSubGameNumber;
LaunchGame();
break;
case GAME_SURVIVAL:
gCopDifficultyLevel = 2;
if (NumPlayers == 1)
iVar1 = 292;
else
iVar1 = 324;
gCurrentMissionNumber = iVar1 + GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
if (NumPlayers == 1)
gCurrentMissionNumber = 292;
else
gCurrentMissionNumber = 324;
gCurrentMissionNumber += GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
LaunchGame();
gCopDifficultyLevel = SurvivalCopSettingsBackup;
break;
case GAME_REPLAYMISSION:
GameType = GAME_MISSION;
@ -251,34 +263,42 @@ void GameStart(void)
RunMissionLadder(0);
GameType = GAME_REPLAYMISSION;
break;
case GAME_COPSANDROBBERS:
gCurrentMissionNumber = GameLevel * 8 + 420 + gWantNight * 4 + gSubGameNumber;
gCurrentMissionNumber = 420 + GameLevel * 8 + gWantNight * 4 + gSubGameNumber;
LaunchGame();
break;
case GAME_CAPTURETHEFLAG:
gCurrentMissionNumber = GameLevel * 8 + 352 + gSubGameNumber;
gCurrentMissionNumber = 352 + GameLevel * 8 + gSubGameNumber;
LaunchGame();
break;
case GAME_SECRET:
if (NumPlayers == 1)
iVar1 = 480;
gCurrentMissionNumber = 480;
else
iVar1 = 484;
gCurrentMissionNumber = 484;
gCurrentMissionNumber = iVar1 + gWantNight + gSubGameNumber;
gCurrentMissionNumber += gWantNight + gSubGameNumber;
LaunchGame();
break;
case GAME_CONTINUEMISSION:
GameType = GAME_MISSION;
RunMissionLadder(0);
break;
case GAME_LOADEDREPLAY:
CurrentGameMode = GAMEMODE_DIRECTOR;
gLoadedReplay = 1;
GameType = StoredGameType;
LaunchGame();
gLoadedReplay = 0;
break;
}
@ -305,7 +325,7 @@ void GameStart(void)
/* end block 2 */
// End Line: 2538
// [D]
// [D] [T]
void StartRender(int renderNum)
{
PlayFMV(renderNum);
@ -349,7 +369,7 @@ void StartRender(int renderNum)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
void ReInitFrontend(void)
{
RECT16 rect;
@ -360,14 +380,18 @@ void ReInitFrontend(void)
EnableDisplay();
DrawSync(0);
VSync(0);
gInFrontend = 1;
SetDispMask(0);
StopDualShockMotors();
FreeXM();
SpuSetReverbVoice(0, 0xffffff);
SpuSetReverbVoice(0, SPU_ALLCH);
UnPauseSound();
LoadSoundBankDynamic((char *)0x0, 0, 0);
LoadSoundBankDynamic((char*)0x0, 0, 0);
LoadBankFromLump(1, 0);
#ifdef PSX
@ -378,7 +402,7 @@ void ReInitFrontend(void)
DrawSync(0);
EnableDisplay();
setRECT16(&rect, 0,0, 320, 512);
setRECT16(&rect, 0, 0, 320, 512);
ClearImage(&rect, 0, 0, 0);
DrawSync(0);
@ -386,12 +410,14 @@ void ReInitFrontend(void)
ReInitScreens();
DrawSync(0);
VSync(0);
ClearOTagR((u_long*)MPBuff[0][0].ot, 0x1080);
ClearOTagR((u_long*)MPBuff[0][1].ot, 0x1080);
ClearOTagR((u_long*)MPBuff[0][0].ot, OTSIZE);
ClearOTagR((u_long*)MPBuff[0][1].ot, OTSIZE);
SetDispMask(1);
//LoadedLevel = 0xff;
bRedrawFrontend = 1;
return;
}
@ -461,11 +487,11 @@ void ReInitFrontend(void)
/* end block 4 */
// End Line: 2250
// [D]
// [D] [T]
void RunMissionLadder(int newgame)
{
bool quit;
MISSION_STEP *CurrentStep;
MISSION_STEP* CurrentStep;
RENDER_ARGS RenderArgs;
quit = false;
@ -484,16 +510,17 @@ void RunMissionLadder(int newgame)
RenderArgs.Args[0].credits = 0;
RenderArgs.Args[0].recap = RecapFrameLength[CurrentStep->recap - 1];
RenderArgs.nRenders = 1;
}
do {
if (CurrentStep->disc == 0)
CheckForCorrectDisc(0);
else
else
CheckForCorrectDisc(1);
if (RenderArgs.nRenders == 4)
if (RenderArgs.nRenders == 4)
{
SetPleaseWait(NULL);
PlayRender(&RenderArgs);
@ -505,7 +532,7 @@ void RunMissionLadder(int newgame)
if (CurrentStep->flags == 2)
{
if (RenderArgs.nRenders != 0)
if (RenderArgs.nRenders != 0)
{
SetPleaseWait(NULL);
PlayRender(&RenderArgs);
@ -516,12 +543,12 @@ void RunMissionLadder(int newgame)
gCurrentMissionNumber = CurrentStep->data;
LaunchGame();
if (WantedGameMode == GAMEMODE_NEXTMISSION)
if (WantedGameMode == GAMEMODE_NEXTMISSION)
{
if (gFurthestMission < gCurrentMissionNumber)
if (gFurthestMission < gCurrentMissionNumber)
gFurthestMission = gCurrentMissionNumber;
}
else
else
{
quit = true;
}
@ -591,9 +618,11 @@ void RunMissionLadder(int newgame)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
void GetRandomChase(void)
{
int bump;
// [A] debug
if (gChaseNumber != 0)
{
@ -601,18 +630,16 @@ void GetRandomChase(void)
return;
}
int bump = 0;
if (gLoadedReplay == 0)
{
gRandomChase = VSync(-1) % 0xd + 2;
if (gRandomChase == gLastChase)
bump = 0;
while (gRandomChase == gLastChase)
{
do {
gRandomChase = (VSync(-1) + bump) % 13 + 2;
bump++;
} while (gRandomChase == gLastChase);
gRandomChase = (VSync(-1) + bump) % 13 + 2;
bump++;
}
gLastChase = gRandomChase;
@ -647,10 +674,10 @@ void GetRandomChase(void)
/* end block 4 */
// End Line: 3008
// [D]
// [D] [T]
int FindPrevMissionFromLadderPos(int pos)
{
MISSION_STEP *step = &MissionLadder[pos];
MISSION_STEP* step = &MissionLadder[pos];
while (pos-- > 0)
{
if (step->flags == 2)
@ -662,7 +689,7 @@ int FindPrevMissionFromLadderPos(int pos)
return 1;
}
step--;
}
@ -719,9 +746,12 @@ int lead_car = 0;
MISSION_DATA MissionStartData;
MISSION_DATA MissionEndData;
// [D]
// [D] [T]
void LaunchGame(void)
{
int quit;
RECT16 rect{ 0, 0, 512, 512 };
fakeOtherPlayer = 0;
ResetGraph(1);
@ -737,12 +767,12 @@ void LaunchGame(void)
if (gLoadedReplay == 0)
GetRandomChase();
if (CurrentGameMode == GAMEMODE_DIRECTOR)
if (CurrentGameMode == GAMEMODE_DIRECTOR)
{
AttractMode = 0;
NoPlayerControl = 1;
}
else
else
{
AttractMode = 0;
NoPlayerControl = 0;
@ -766,7 +796,7 @@ void LaunchGame(void)
AutoDirect = 0;
NewLevel = 1;
bool quit = false;
quit = 0;
do {
GameInit();
@ -778,26 +808,29 @@ void LaunchGame(void)
case GAMEMODE_QUIT:
case GAMEMODE_DEMO:
{
FadeScreen(0xff);
quit = true;
FadeScreen(255);
quit = 1;
break;
}
case GAMEMODE_RESTART:
{
FadeScreen(0xff);
FadeScreen(255);
NoPlayerControl = 0;
quick_replay = 0;
AutoDirect = 0;
WantedGameMode = GAMEMODE_NORMAL;
NewLevel = 0;
GetRandomChase();
break;
}
case GAMEMODE_REPLAY:
case GAMEMODE_DIRECTOR:
{
if (CurrentGameMode < GAMEMODE_NEXTMISSION)
FadeScreen(0xff);
FadeScreen(255);
NoPlayerControl = 1;
AutoDirect = (WantedGameMode == GAMEMODE_REPLAY);
@ -809,13 +842,16 @@ void LaunchGame(void)
{
MissionStartData = MissionEndData;
gHaveStoredData = 1;
FadeScreen(0xff);
quit = true;
FadeScreen(255);
quit = 1;
NoPlayerControl = 0;
quick_replay = 0;
AutoDirect = 0;
}
}
CurrentGameMode = WantedGameMode;
} while (!quit);
@ -824,7 +860,6 @@ void LaunchGame(void)
SetDispMask(0);
EnableDisplay();
RECT16 rect { 0, 0, 512, 512 };
ClearImage(&rect, 0, 0, 0);
DrawSync(0);
@ -860,35 +895,37 @@ void LaunchGame(void)
/* end block 4 */
// End Line: 3337
// [D]
// [D] [T]
int FindMissionLadderPos(int mission)
{
MISSION_STEP *step = MissionLadder;
MISSION_STEP* step = MissionLadder;
int pos = 0;
bool end = false;
do {
switch (step->flags) {
case 1:
case 6:
switch (step->flags)
{
case 1:
case 6:
{
step++;
pos++;
} break;
case 2:
break;
}
case 2:
{
if (step->data == mission)
{
if (pos > 0) {
if (pos > 0)
{
step--;
if (step->flags != 2)
{
do {
if (--pos <= 0)
break;
step--;
} while (step->flags != 2);
while (step->flags != 2)
{
if (--pos <= 0)
break;
step--;
}
}
@ -898,14 +935,15 @@ int FindMissionLadderPos(int mission)
step++;
pos++;
} break;
case 4:
// end of ladder
end = true;
break;
default:
// unhandled
return 0;
break;
}
case 4:
// end of ladder
end = true;
break;
default:
// unhandled
return 0;
}
} while (!end);

View File

@ -723,6 +723,12 @@ void GlobalTimeStep(void)
int m2;
int strength;
int carsDentedThisFrame;
short *felony;
if (player[0].playerCarId < 0)
felony = &pedestrianFelony;
else
felony = &car_data[player[0].playerCarId].felonyRating;
StepCars();
CheckCarToCarCollisions();
@ -944,7 +950,9 @@ void GlobalTimeStep(void)
}
// wake up cops if they've ben touched
if (numCopCars < 4 && numActiveCops < maxCopCars && GameType != GAME_GETAWAY)
// [A] check player felony.
// If player touch them without felony player will be charged with felony (hit cop car)
if (numCopCars < 4 && numActiveCops < maxCopCars && GameType != GAME_GETAWAY && *felony >= FELONY_MIN_VALUE)
{
if (cp->controlType == CONTROL_TYPE_PLAYER && IS_ROADBLOCK_CAR(c1))
{
@ -2400,7 +2408,7 @@ void CheckCarEffects(CAR_DATA* cp, int player_id)
if (player[player_id].skidding.sound > -1)
{
channel = StartSound(-1, 1, player[player_id].skidding.sound, skidsound - 10000, 0x1000);
channel = StartSound(-1, SOUND_BANK_SFX, player[player_id].skidding.sound, skidsound - 10000, 0x1000);
player[player_id].skidding.chan = channel;
LockChannel(channel);
@ -2459,7 +2467,7 @@ void CheckCarEffects(CAR_DATA* cp, int player_id)
if (player[player_id].wheelnoise.sound > -1)
{
channel = StartSound(-1, 1, player[player_id].wheelnoise.sound, -200, 4096);
channel = StartSound(-1, SOUND_BANK_SFX, player[player_id].wheelnoise.sound, -200, 4096);
player[player_id].wheelnoise.chan = channel;
LockChannel(channel);

View File

@ -323,7 +323,7 @@ int LoadReplayFromFile(char* fileName)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
int CalcReplayDataSize(void)
{
return SaveReplayToBuffer(NULL);
@ -362,7 +362,7 @@ int CalcReplayDataSize(void)
/* end block 5 */
// End Line: 305
// [D]
// [D] [T]
int SaveReplayData(char* buffer)
{
return SaveReplayToBuffer(buffer);
@ -389,7 +389,7 @@ int SaveReplayData(char* buffer)
/* end block 3 */
// End Line: 319
// [D]
// [D] [T]
int LoadReplayData(char* buffer)
{
return LoadReplayFromBuffer(buffer);
@ -413,7 +413,7 @@ int LoadReplayData(char* buffer)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
int CalcGameDataSize(void)
{
return sizeof(GAME_SAVE_HEADER);
@ -437,7 +437,7 @@ int CalcGameDataSize(void)
/* end block 2 */
// End Line: 344
// [D]
// [D] [T]
int SaveGameData(char* buffer)
{
GAME_SAVE_HEADER* saveHeader;
@ -484,7 +484,7 @@ int SaveGameData(char* buffer)
/* end block 4 */
// End Line: 387
// [D]
// [D] [T]
int LoadGameData(char* buffer)
{
GAME_SAVE_HEADER* header;
@ -527,7 +527,7 @@ int LoadGameData(char* buffer)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
int CalcConfigDataSize(void)
{
return sizeof(CONFIG_SAVE_HEADER);
@ -554,7 +554,7 @@ int CalcConfigDataSize(void)
/* end block 2 */
// End Line: 219
// [D]
// [D] [T]
int SaveConfigData(char* buffer)
{
CONFIG_SAVE_HEADER* header;
@ -618,6 +618,7 @@ int SaveConfigData(char* buffer)
/* end block 4 */
// End Line: 316
// [D] [T]
int LoadConfigData(char* buffer)
{
CONFIG_SAVE_HEADER* header;

View File

@ -51,43 +51,43 @@ int loading_bar_pos = 0;
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
void ShowLoading(void)
{
POLY_G4 poly;
if (NewLevel != 0 || gInFrontend != 0)
{
int col = (VERTTYPE)(++loading_bar_pos * load_steps);
if (NewLevel == 0 && gInFrontend == 0)
return;
int col = (VERTTYPE)(++loading_bar_pos * load_steps);
if (col > 120)
col = 120;
if (col > 120)
col = 120;
SetPolyG4(&poly);
SetPolyG4(&poly);
setRGB0(&poly, 30, 11, 11);
setRGB1(&poly, 122, 11, 11);
setRGB2(&poly, 30, 11, 11);
setRGB3(&poly, 122, 11, 11);
setRGB0(&poly, 30, 11, 11);
setRGB1(&poly, 122, 11, 11);
setRGB2(&poly, 30, 11, 11);
setRGB3(&poly, 122, 11, 11);
setXYWH(&poly, 176, 435, col, 25);
setXYWH(&poly, 176, 435, col, 25);
DrawPrim(&poly);
VSync(0);
DrawSync(0);
PutDrawEnv(&load_draw);
PutDispEnv(&load_disp);
DrawPrim(&poly);
VSync(0);
DrawSync(0);
PutDrawEnv(&load_draw);
PutDispEnv(&load_disp);
DrawPrim(&poly);
VSync(0);
DrawSync(0);
PutDrawEnv(&load_draw);
PutDispEnv(&load_disp);
DrawPrim(&poly);
VSync(0);
DrawSync(0);
PutDrawEnv(&load_draw);
PutDispEnv(&load_disp);
#ifndef PSX
Emulator_EndScene();
Emulator_EndScene();
#endif
}
}
@ -122,7 +122,7 @@ int screen_fade_start = 0;
int screen_fade_end = 0;
int screen_fade_speed = 0;
// [D]
// [D] [T]
void SetupScreenFade(int start, int end, int speed)
{
screen_fade_value = start;
@ -161,7 +161,7 @@ void SetupScreenFade(int start, int end, int speed)
/* end block 2 */
// End Line: 566
// [D]
// [D] [T]
void FadeGameScreen(int flag, int speed)
{
static POLY_F4 poly; // offset 0x0
@ -257,35 +257,32 @@ void FadeGameScreen(int flag, int speed)
/* end block 4 */
// End Line: 704
// [D]
// [D] [T]
void ShowLoadingScreen(char *screen_name, int effect, int loading_steps)
{
bool bVar1;
char local_a0_424;
uint uVar2;
SPRT *pSVar3;
SPRT *pSVar4;
POLY_FT3 *pPVar5;
POLY_FT3 *pPVar6;
uint uVar7;
int iVar8;
int iVar9;
int iVar10;
unsigned char uVar11;
int iVar12;
int done;
SPRT *sprt;
POLY_FT3 *null;
uint tp;
int i;
int j;
int fade;
RECT16 dest;
SPRT prims[4];
POLY_FT3 nulls[4];
int fade_step;
iVar12 = 0xff;
fade_step = -4;
if (effect == 1) {
if (effect == 1)
SetDispMask(0);
}
SetupDefDrawEnv(&load_draw, 0, 0, 320, 512);
SetupDefDispEnv(&load_disp, 0, 0, 320, 512);
load_draw.dfe = '\x01';
load_draw.dfe = 1;
PutDispEnv(&load_disp);
PutDrawEnv(&load_draw);
@ -299,103 +296,109 @@ void ShowLoadingScreen(char *screen_name, int effect, int loading_steps)
DrawSync(0);
bVar1 = false;
iVar8 = 0;
pSVar4 = prims + 2;
pPVar6 = nulls + 2;
uVar7 = 320;
pPVar5 = nulls;
pSVar3 = prims;
do {
uVar2 = uVar7 & 0x3ff;
uVar7 = uVar7 + 0x80;
setSprt(pSVar3);
pSVar3->x0 = (short)(iVar8 << 8);
pSVar3->y0 = 0;
pSVar3->u0 = '\0';
pSVar3->v0 = '\0';
pSVar3->w = 0x100;
pSVar3->h = 0x100;
pSVar3->clut = 0x7fd4;
done = 0;
tp = 320;
null = nulls;
sprt = prims;
setPolyFT3(pPVar5);
pPVar5->x0 = -1;
pPVar5->y0 = -1;
pPVar5->x1 = -1;
pPVar5->y1 = -1;
pPVar5->x2 = -1;
pPVar5->y2 = -1;
pPVar5->tpage = (ushort)((int)uVar2 >> 6) | 0x80;
pPVar5 = pPVar5 + 1;
iVar8 = iVar8 + 1;
pSVar3 = pSVar3 + 1;
} while (iVar8 < 2);
i = 0;
while (i < 2)
{
setSprt(sprt);
sprt->x0 = (i << 8);
sprt->y0 = 0;
sprt->u0 = 0;
sprt->v0 = 0;
sprt->w = 256;
sprt->h = 256;
sprt->clut = getClut(320, 511);
iVar8 = 0;
uVar7 = 0x140;
setPolyFT3(null);
null->x0 = -1;
null->y0 = -1;
null->x1 = -1;
null->y1 = -1;
null->x2 = -1;
null->y2 = -1;
null->tpage = getTPage(1, 0, tp, 0);
null++;
sprt++;
do {
uVar2 = uVar7 & 0x3ff;
uVar7 = uVar7 + 0x80;
setSprt(pSVar4);
pSVar4->x0 = (short)(iVar8 << 8);
pSVar4->y0 = 0x100;
pSVar4->u0 = '\0';
pSVar4->v0 = '\0';
pSVar4->w = 0x100;
pSVar4->h = 0x100;
pSVar4->clut = 0x7fd4;
tp += 128;
setPolyFT3(pPVar6);
pPVar6->x0 = -1;
pPVar6->y0 = -1;
pPVar6->x1 = -1;
pPVar6->y1 = -1;
pPVar6->x2 = -1;
pPVar6->y2 = -1;
pPVar6->tpage = (ushort)((int)uVar2 >> 6) | 0x90;
pPVar6 = pPVar6 + 1;
iVar8 = iVar8 + 1;
pSVar4 = pSVar4 + 1;
} while (iVar8 < 2);
i++;
}
if (effect == 1) {
iVar12 = 8;
i = 0;
tp = 320;
while (i < 2)
{
setSprt(sprt);
sprt->x0 = (i << 8);
sprt->y0 = 256;
sprt->u0 = 0;
sprt->v0 = 0;
sprt->w = 256;
sprt->h = 256;
sprt->clut = getClut(320, 511);
setPolyFT3(null);
null->x0 = -1;
null->y0 = -1;
null->x1 = -1;
null->y1 = -1;
null->x2 = -1;
null->y2 = -1;
null->tpage = getTPage(1, 0, tp, 256);
null++;
sprt++;
tp += 128;
i++;
}
if (effect == 1)
{
fade = 8;
fade_step = 2;
}
else {
if (effect == 2) {
iVar12 = 128;
fade_step = -2;
}
else if (effect == 2)
{
fade = 128;
fade_step = -2;
}
iVar8 = 0;
else
{
fade = 255;
fade_step = -4;
}
i = 0;
do {
if (iVar8 == 2) {
if (i == 2)
SetDispMask(1);
i++;
for (j = 0; j < 4; j++)
{
prims[j].r0 = fade;
prims[j].g0 = fade;
prims[j].b0 = fade;
}
for (j = 0; j < 4; j++)
{
DrawPrim(&nulls[j]);
DrawPrim(&prims[j]);
}
pPVar5 = nulls;
pSVar4 = prims;
iVar8 = iVar8 + 1;
iVar9 = 3;
iVar10 = iVar12 + fade_step;
pSVar3 = pSVar4;
do {
uVar11 = (unsigned char)iVar12;
pSVar3->r0 = uVar11;
pSVar3->g0 = uVar11;
pSVar3->b0 = uVar11;
iVar9 = iVar9 + -1;
pSVar3 = pSVar3 + 1;
} while (-1 < iVar9);
iVar12 = 3;
do {
DrawPrim(pPVar5);
DrawPrim(pSVar4);
pSVar4 = pSVar4 + 1;
iVar12 = iVar12 + -1;
pPVar5 = pPVar5 + 1;
} while (-1 < iVar12);
DrawSync(0);
VSync(0);
@ -406,24 +409,28 @@ void ShowLoadingScreen(char *screen_name, int effect, int loading_steps)
PutDispEnv(&load_disp);
PutDrawEnv(&load_draw);
if (effect == 1) {
if (0x7f < iVar10) {
bVar1 = true;
}
fade += fade_step;
if (effect == 1)
{
if (fade > 127)
done = 1;
}
else {
if ((effect == 2) && (iVar10 < 0)) {
bVar1 = true;
}
else if (effect == 2)
{
if(fade < 0)
done = 1;
}
iVar12 = iVar10;
} while (!bVar1);
load_steps = 0x18;
if (gInFrontend == 0) {
} while (!done);
load_steps = 24;
if (gInFrontend == 0)
load_steps = 20;
}
loading_bar_pos = 0;
return;
}
@ -448,7 +455,7 @@ void ShowLoadingScreen(char *screen_name, int effect, int loading_steps)
/* end block 2 */
// End Line: 1501
// [D]
// [D] [T]
void CloseShutters(int speed, int width, int height)
{
bool done;
@ -482,8 +489,8 @@ void CloseShutters(int speed, int width, int height)
} while (!done);
ClearOTagR((u_long*)current->ot, 0x1080);
ClearOTagR((u_long*)last->ot, 0x1080);
ClearOTagR((u_long*)current->ot, OTSIZE);
ClearOTagR((u_long*)last->ot, OTSIZE);
SetDispMask(0);
}
@ -531,10 +538,12 @@ POLY_GT4 fade_gt4[2];
static int fadeVal = 0xFF;
static int bWantFade = 0;
// [D]
// [D] [T]
void SetupFadePolys(void)
{
for (int i = 0; i < 2; i++)
int i;
for (i = 0; i < 2; i++)
{
setPolyG4(&fade_g4[i]);
setSemiTrans(&fade_g4[i], 1);
@ -544,7 +553,7 @@ void SetupFadePolys(void)
setXYWH(&fade_gt4[i], -1, -1, 1, 1);
setTPage(&fade_gt4[i], 0, 2, 0, 0);
};
}
bWantFade = 1;
fadeVal = 255;
@ -583,7 +592,7 @@ void SetupFadePolys(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
void DrawFadePoly(void)
{
if (fadeVal < 0)
@ -651,7 +660,7 @@ void DrawFadePoly(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
void DisplayMissionTitle(void)
{
if (bWantFade != 0 && CameraCnt == 1)
@ -663,9 +672,23 @@ void DisplayMissionTitle(void)
if (bMissionTitleFade != 0 && pauseflag == 0)
{
fadeVal -= 6;
if (NoPlayerControl == 0)
if (NoPlayerControl != 0)
{
if (gMissionTitle != (char *)0x0)
if (fadeVal < 0)
{
bMissionTitleFade = 0;
if (gInGameCutsceneActive == 0)
gStopPadReads = 0;
gShowMap = 0;
fadeVal = 0;
}
}
else
{
if (gMissionTitle)
{
#ifdef PSX
gShowMap = 1;
@ -674,24 +697,12 @@ void DisplayMissionTitle(void)
gShowMap = 0;
#else
SetTextColour(124, 108, 40);
PrintStringCentred(gMissionTitle, 0x78);
PrintStringCentred(gMissionTitle, 120);
#endif
}
DrawFadePoly();
}
else
{
if (fadeVal < 0)
{
bMissionTitleFade = 0;
if (gInGameCutsceneActive == 0)
gStopPadReads = 0;
gShowMap = 0;
fadeVal = 0;
}
}
}
}

View File

@ -767,6 +767,28 @@ void GameInit(void)
PauseSound();
ThisMotion = 0;
// [A] Driver 1 music support
#ifndef PSX
if (gDriver1Music)
{
if (GameType == GAME_TAKEADRIVE)
{
if(GameLevel == 0)
gMusicType = 0 + (gCurrentMissionNumber & 1);
else if (GameLevel == 1)
gMusicType = 5 + (gCurrentMissionNumber & 1);
else if (GameLevel == 2)
gMusicType = 2 + (gCurrentMissionNumber & 1) * 5;
else if (GameLevel == 3)
gMusicType = 3 + (gCurrentMissionNumber & 1);
}
else
{
gMusicType = gCurrentMissionNumber % 8;
}
}
else
#endif
if (GameLevel == 1)
{
gMusicType = 1;
@ -3316,11 +3338,11 @@ void DealWithHorn(char* hr, int i)
channel = i != 0 ? 5 : 2;
Start3DSoundVolPitch(channel, 3, modelId * 3 + 2,
Start3DSoundVolPitch(channel, SOUND_BANK_CARS, modelId * 3 + 2,
car->hd.where.t[0],
car->hd.where.t[1],
car->hd.where.t[2], -10000,
0x1000);
4096);
if (NumPlayers > 1 && NoPlayerControl == 0)
{
@ -3331,7 +3353,7 @@ void DealWithHorn(char* hr, int i)
channel = i != 0 ? 5 : 2;
SetChannelPosition3(channel, (VECTOR*)car->hd.where.t, car->st.n.linearVelocity, -2000, i * 8 + 0x1000, 0);
SetChannelPosition3(channel, (VECTOR*)car->hd.where.t, car->st.n.linearVelocity, -2000, i * 8 + 4096, 0);
}
*hr = (*hr + 1) % 3;

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@
#include "FELONY.H"
#include "JOB_FX.H"
#include "BCOLLIDE.H"
#include "GAMESND.H"
#include "MAP.H"
#include "SYSTEM.H"
#include "HANDLING.H"
@ -1067,7 +1068,7 @@ int ActivatePlayerPedestrian(CAR_DATA* pCar, char* padId, int direction, LONGVEC
else
{
MakeTheCarShutUp(playerId);
Start3DSoundVolPitch(-1, 6, 2, lp->pos[0], lp->pos[1], lp->pos[2], 0, 0x1000);
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 2, lp->pos[0], lp->pos[1], lp->pos[2], 0, 0x1000);
SetupGetOutCar(pedptr, pCar, side);
//pedptr->padId = 0;
@ -2430,7 +2431,7 @@ void SetupGetInCar(PEDESTRIAN* pPed)
// HEY!
CreatePedAtLocation(&pos, 8);
Start3DSoundVolPitch(-1, 6, 5, pos[0], pos[1], pos[2], 0, 0x1000);
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 5, pos[0], pos[1], pos[2], 0, 0x1000);
carToGetIn->controlFlags |= CONTROL_FLAG_WAS_PARKED;
}
@ -2509,6 +2510,7 @@ void SetupPressButton(PEDESTRIAN* pPed)
pPed->type = PED_ACTION_PRESSBUTTON;
SetupPedMotionData(pPed);
pPed->dir.vz = 0;
pPed->speed = 0;
pPed->frame1 = 0;
pPed->fpAgitatedState = PedPressButton;
@ -2559,6 +2561,7 @@ void SetupTannerSitDown(PEDESTRIAN* pPed)
pPed->type = PED_ACTION_SIT;
SetupPedMotionData(pPed);
pPed->dir.vz = 0;
pPed->speed = 0;
pPed->frame1 = 0;
pPed->fpAgitatedState = TannerSitDown;
@ -2890,10 +2893,10 @@ void AnimatePed(PEDESTRIAN* pPed)
if (surfId != 4 && surfId != 6 && surfId != 11 && surfId != 9)
{
if (pPed->frame1 == 3)
Start3DSoundVolPitch(-1, 6, 0, pPed->position.vx, -pPed->position.vy, pPed->position.vz, -5000, 0x1000);
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 0, pPed->position.vx, -pPed->position.vy, pPed->position.vz, -5000, 0x1000);
if (pPed->frame1 == 11)
Start3DSoundVolPitch(-1, 6, 1, pPed->position.vx, -pPed->position.vy, pPed->position.vz, -5000, 0x1000);
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 1, pPed->position.vx, -pPed->position.vy, pPed->position.vz, -5000, 0x1000);
}
}
@ -2969,7 +2972,7 @@ void DeActivatePlayerPedestrian(PEDESTRIAN* pPed)
pPed->type = PED_ACTION_GETINCAR;
pPed->fpAgitatedState = PedGetInCar;
Start3DSoundVolPitch(-1, 6, 2, player[0].pos[0], player[0].pos[1], player[0].pos[2], 0, 0x1000);
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 2, player[0].pos[0], player[0].pos[1], player[0].pos[2], 0, 0x1000);
SetupPedestrian(pPed);
SetupGetInCar(pPed);
}

View File

@ -165,7 +165,7 @@ void ChangeCarPlayerToPed(int playerID)
StopChannel(player[playerID].wheelnoise.chan);
UnlockChannel(player[playerID].wheelnoise.chan);
Start3DSoundVolPitch(-1, 6, 3, lcp->hd.where.t[0], lcp->hd.where.t[1], lcp->hd.where.t[2], 0, 0x1000);
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 3, lcp->hd.where.t[0], lcp->hd.where.t[1], lcp->hd.where.t[2], 0, 0x1000);
first_offence = 1;
@ -274,7 +274,7 @@ void ChangePedPlayerToCar(int playerID, CAR_DATA *newCar)
}
// door close sound
Start3DSoundVolPitch(-1, 6, 3, newCar->hd.where.t[0], newCar->hd.where.t[1], newCar->hd.where.t[2], 0, 0x1000);
Start3DSoundVolPitch(-1, SOUND_BANK_TANNER, 3, newCar->hd.where.t[0], newCar->hd.where.t[1], newCar->hd.where.t[2], 0, 0x1000);
if (newCar->ap.model == 4)
carSampleId = ResidentModelsBodge();
@ -285,11 +285,11 @@ void ChangePedPlayerToCar(int playerID, CAR_DATA *newCar)
// start idle sound
channel = playerID == 0 ? 1 : 4;
Start3DSoundVolPitch(channel, 3, carSampleId * 3 + 1, newCar->hd.where.t[0], newCar->hd.where.t[1], newCar->hd.where.t[2], -10000, 0x1000);
Start3DSoundVolPitch(channel, SOUND_BANK_CARS, carSampleId * 3 + 1, newCar->hd.where.t[0], newCar->hd.where.t[1], newCar->hd.where.t[2], -10000, 0x1000);
// rev sound
channel = playerID == 0 ? 0 : 3;
Start3DSoundVolPitch(channel, 3, carSampleId * 3, newCar->hd.where.t[0], newCar->hd.where.t[1], newCar->hd.where.t[2], -10000, 0x1000);
Start3DSoundVolPitch(channel, SOUND_BANK_CARS, carSampleId * 3, newCar->hd.where.t[0], newCar->hd.where.t[1], newCar->hd.where.t[2], -10000, 0x1000);
if (siren != 0)
{

File diff suppressed because it is too large Load Diff

View File

@ -79,7 +79,7 @@ extern void StopXM(); // 0x0007B050
extern void SetXMVolume(int volume); // 0x0007B074
extern int GetFreeChannel(); // 0x00079E04
extern int GetFreeChannel(int force = 1); // 0x00079E04
extern void UpdateVolumeAttributesS(int channel, int proximity); // 0x00079F38

View File

@ -1253,7 +1253,7 @@ void SendTPage(void)
if (nTPchunks == 0)
{
if (slot != tpageloaded[tpage2send]-1)
if (slot != tpageloaded[tpage2send] - 1)
{
npalettes = *(int *)(model_spool_buffer + 0xE000);
@ -1316,6 +1316,9 @@ void SendTPage(void)
}
}
}
//extern void Emulator_SaveVRAM(const char* outputFileName, int x, int y, int width, int height, int bReadFromFrameBuffer);
//Emulator_SaveVRAM("VRAM_CLUTS_TPAGES.TGA", 0, 0, 1024, 512, 1);
}
@ -1404,66 +1407,53 @@ void LoadInAreaTSets(int area)
tpages = AreaTPages + area * 16;
ntpages_to_load = AreaData[area].num_tpages;
if (!ntpages_to_load)
return;
loadaddr = model_spool_buffer + 0xA000;
navailable = 0;
slot = slotsused;
while (slot < 19)
// get available slots
for (slot = slotsused; slot < 19; slot++)
{
offset = 0;
if (tpageslots[slot] == 0xff) // [A]
// use free slot immediately
if (tpageslots[slot] == 0xff)
{
availableslots[navailable++] = slot;
continue;
}
else
for (i = 0; i < ntpages_to_load; i++)
{
i = 0;
while (tpageslots[slot] != tpages[i]) // [A]
{
if (ntpages_to_load <= i)
break;
i++;
};
if (i == ntpages_to_load)
// check if needed tpages are not already loaded
if (tpageslots[slot] != tpages[i])
{
availableslots[navailable++] = slot;
break;
}
}
slot++;
}
offset = AreaData[area].gfx_offset;
if (!ntpages_to_load)
return;
i = 0;
while (--navailable >= 0)
for (slot = 0; slot < navailable; slot++)
{
tsetinfo[tsetcounter * 2 + 1] = availableslots[navailable];
while (i < ntpages_to_load)
if (i < ntpages_to_load)
{
tsetinfo[tsetcounter * 2 + 1] = availableslots[slot];
tsetinfo[tsetcounter * 2] = tpages[i];
RequestSpool(1, 0, offset, 17, loadaddr, SendTPage);
offset += 17;
i++;
tsetinfo[tsetcounter * 2] = *tpages;
tsetcounter++;
tpages++;
if (tpageloaded[*tpages] == 0)
break;
tsetinfo[tsetcounter * 2 + 1] = tpageloaded[*tpages] - 1;
i++;
}
else
break;
}
}
@ -1848,11 +1838,11 @@ void CheckLoadAreaData(int cellx, int cellz)
new_area_location = load;
// [A] bounds?
if (load == 0 && (32-force_load_boundary < cellz))
if (load == 0 && (cellz > MAP_REGION_SIZE - force_load_boundary))
{
break;
}
else if (load == 1 && (32-force_load_boundary < cellx))
else if (load == 1 && (cellx > MAP_REGION_SIZE - force_load_boundary))
{
break;
}

View File

@ -17,15 +17,15 @@
#include <string.h>
// Initialized in redriver2_main
char* _overlay_buffer = NULL; // 0x1C0000
char* _frontend_buffer = NULL; // 0xFB400
char* _other_buffer = NULL; // 0xF3000
char* _other_buffer2 = NULL; // 0xE7000
OTTYPE* _OT1 = NULL; // 0xF3000
OTTYPE* _OT2 = NULL; // 0xF7200
char* _primTab1 = NULL; // 0xFB400
char* _primTab2 = NULL; // 0x119400
char* _replay_buffer = NULL; // 0x1FABBC
char* _overlay_buffer = NULL; // 0x1C0000
char* _frontend_buffer = NULL; // 0xFB400
char* _other_buffer = NULL; // 0xF3000
char* _other_buffer2 = NULL; // 0xE7000
OTTYPE* _OT1 = NULL; // 0xF3000
OTTYPE* _OT2 = NULL; // 0xF7200
char* _primTab1 = NULL; // 0xFB400
char* _primTab2 = NULL; // 0x119400
char* _replay_buffer = NULL; // 0x1FABBC
char gDataFolder[32] = "DRIVER2\\";
#ifdef USE_CRT_MALLOC
@ -38,7 +38,7 @@ int g_numDynamicAllocs = 0;
char* sys_malloc(int size, char* funcname, int line)
{
if(g_numDynamicAllocs & 0x10000)
if (g_numDynamicAllocs & 0x10000)
sys_tempfree();
#ifdef _DEBUG
@ -54,7 +54,7 @@ char* sys_malloc(int size, char* funcname, int line)
void sys_freeall()
{
int numAlloc = g_numDynamicAllocs & 0xfff;
for (int i = 0; i < numAlloc; i++)
{
free(g_dynamicAllocs[i]);
@ -66,15 +66,15 @@ void sys_freeall()
char* sys_tempalloc(int size)
{
if(g_numDynamicAllocs & 0x10000)
if (g_numDynamicAllocs & 0x10000)
{
printError("sys_tempalloc: another alloc in use!\n");
trap(1000);
return NULL;
}
char* tmp_ptr = (char*)malloc(size);
g_dynamicAllocs[g_numDynamicAllocs] = tmp_ptr;
g_numDynamicAllocs |= 0x10000;
@ -167,38 +167,38 @@ char g_CurrentLevelFileName[64];
/* end block 4 */
// End Line: 2274
// [D]
void ClearMem(char *mem, int size)
// [D] [T]
void ClearMem(char* mem, int size)
{
// 16 bit aligned clear
#ifndef PSX
memset(mem, 0, size);
#else
char *end;
char* end;
end = mem + size;
while ((((uint)mem & 3) != 0 && (mem < end))) {
*mem = 0;
mem = (char *)((int)mem + 1);
mem = (char*)((int)mem + 1);
}
while (mem <= end + -0x10) {
*(uint *)mem = 0;
((uint *)mem)[1] = 0;
((uint *)mem)[2] = 0;
((uint *)mem)[3] = 0;
mem = (char *)((uint *)mem + 4);
*(uint*)mem = 0;
((uint*)mem)[1] = 0;
((uint*)mem)[2] = 0;
((uint*)mem)[3] = 0;
mem = (char*)((uint*)mem + 4);
}
while (mem <= end + -4) {
*(uint *)mem = 0;
mem = (char *)((uint *)mem + 1);
*(uint*)mem = 0;
mem = (char*)((uint*)mem + 1);
}
while (mem < end) {
*mem = 0;
mem = (char *)((int)mem + 1);
}
mem = (char*)((int)mem + 1);
}
#endif // !PSX
}
@ -228,8 +228,8 @@ void ClearMem(char *mem, int size)
/* end block 3 */
// End Line: 2347
// [D]
void setMem8(unsigned char *mem, unsigned char val, int size)
// [D] [T]
void setMem8(unsigned char* mem, unsigned char val, int size)
{
while (--size > 0)
*mem++ = val;
@ -263,7 +263,8 @@ void setMem8(unsigned char *mem, unsigned char val, int size)
/* end block 3 */
// End Line: 2436
void setMem16(ushort *mem, ushort val, int size)
// [D] [T]
void setMem16(ushort* mem, ushort val, int size)
{
while (--size > 0)
*mem++ = val;
@ -289,11 +290,13 @@ void setMem16(ushort *mem, ushort val, int size)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [T]
void Init_FileSystem(void)
{
CdInit();
VSync(3);
return;
// Driver 1 were looking up level files on CD...
}
@ -331,21 +334,16 @@ void Init_FileSystem(void)
int gNumCDRetries = 0;
// [D]
// [D] [T]
void DoCDRetry(void)
{
bool bVar1;
int iVar2;
iVar2 = gNumCDRetries + 1;
bVar1 = 9 < gNumCDRetries;
gNumCDRetries = iVar2;
if (bVar1) {
if (gNumCDRetries++ > 9)
{
CdInit();
VSync(3);
gNumCDRetries = 0;
}
return;
}
// decompiled code
@ -369,11 +367,12 @@ void DoCDRetry(void)
// End Line: 1293
// loads whole file into buffer
int Loadfile(char *name, char *addr)
// [D] [T]
int Loadfile(char* name, char* addr)
{
char namebuffer[64];
#ifndef PSX
int fileSize = 0;
int fileSize;
sprintf(namebuffer, "%s%s", gDataFolder, name);
@ -399,7 +398,7 @@ int Loadfile(char *name, char *addr)
fclose(fptr);
//SDL_Delay(200); // [A] PSX-like CD delay
return numRead;
#else // PSX
int nread;
@ -456,7 +455,8 @@ int Loadfile(char *name, char *addr)
// loads file partially into buffer
int LoadfileSeg(char *name, char *addr, int offset, int loadsize)
// [D] [T]
int LoadfileSeg(char* name, char* addr, int offset, int loadsize)
{
char namebuffer[64];
#ifndef PSX
@ -493,15 +493,15 @@ int LoadfileSeg(char *name, char *addr, int offset, int loadsize)
return numRead;
#else // PSX
int iVar1;
int iVar3;
char* pcVar4;
int iVar5;
int iVar6;
int uVar7;
unsigned char result[8];
char* pcVar2;
int first;
int i;
int sector;
int toload;
int nsectors;
char namebuffer[64];
u_char result[8];
char sectorbuffer[2048];
CdlFILE info;
CdlLOC pos;
sprintf(namebuffer, "\\%s%s;1", gDataFolder, name);
@ -511,88 +511,82 @@ int LoadfileSeg(char *name, char *addr, int offset, int loadsize)
strcpy(currentfilename, namebuffer);
while (CdSearchFile(&currentfileinfo, namebuffer) == NULL)
{
DoCDRetry();
}
}
iVar3 = (offset >> 0xb) + CdPosToInt((CdlLOC*)&currentfileinfo);
uVar7 = offset & 0x7ff;
iVar1 = loadsize;
sector = offset / 2048 + CdPosToInt((CdlLOC*)&currentfileinfo);
nsectors = offset & 0x7ff;
toload = loadsize;
if (uVar7 != 0)
if (nsectors != 0)
{
CdIntToPos(iVar3, &pos);
do {
CdIntToPos(sector, &pos);
do
{
if (CdDiskReady(0) != 2)
DoCDRetry();
} while (CdControlB(CdlSetloc, (u_char*)&pos, 0) == 0 ||
CdRead(1, (u_long*)sectorbuffer, CdlModeSpeed) == 0 ||
CdReadSync(0, result) != 0);
} while(CdControlB(2, (u_char*)&pos, 0) == 0 ||
CdRead(1, (u_long*)sectorbuffer, 0x80) == 0 ||
CdReadSync(0, result) != 0);
if (loadsize <= (0x800 - uVar7))
if (loadsize <= 2048 - nsectors)
{
iVar1 = uVar7 + loadsize;
while (uVar7 < iVar1)
while (nsectors < nsectors + loadsize)
{
pcVar4 = sectorbuffer + uVar7;
uVar7 = uVar7 + 1;
*addr = *pcVar4;
addr = addr + 1;
*addr++ = sectorbuffer[nsectors++];
}
return loadsize;
}
iVar1 = loadsize - (0x800 - uVar7);
iVar3 = iVar3 + 1;
if (uVar7 < 0x800)
toload = loadsize - (2048 - nsectors);
sector++;
while (nsectors < 2048)
{
do {
pcVar4 = sectorbuffer + uVar7;
uVar7 = uVar7 + 1;
*addr = *pcVar4;
addr = addr + 1;
} while ((int)uVar7 < 0x800);
*addr++ = sectorbuffer[nsectors++];
}
}
iVar6 = iVar1;
first = toload / 2048;
iVar6 = iVar6 >> 0xb;
if (iVar6 != 0)
if (first != 0)
{
CdIntToPos(iVar3, &pos);
iVar3 = iVar3 + iVar6;
do {
CdIntToPos(sector, &pos);
sector = sector + first;
do
{
if (CdDiskReady(0) != 2)
DoCDRetry();
} while (CdControlB(CdlSetloc, (u_char*)&pos, 0) == 0 ||
CdRead(first, (u_long*)addr, CdlModeSpeed) == 0 ||
CdReadSync(0, result) != 0);
} while(CdControlB(2, (u_char*)&pos, 0) == 0 ||
CdRead(iVar6, (u_long*)addr, 0x80) == 0 ||
CdReadSync(0, result) != 0);
addr += iVar6 * 0x800;
iVar1 -= iVar6 * -0x800;
addr += first * 2048;
toload -= first * 2048;
}
if (iVar1 > 0)
if (toload > 0)
{
CdIntToPos(iVar3, &pos);
do {
CdIntToPos(sector, &pos);
do
{
if (CdDiskReady(0) != 2)
DoCDRetry();
} while (CdControlB(2, (u_char*)&pos, 0) == 0 ||
CdRead(1, (u_long*)sectorbuffer, 0x80) == 0 ||
CdReadSync(0, result) != 0);
i = 0;
} while (CdControlB(2, (u_char*)&pos, 0) == 0 ||
CdRead(1, (u_long*)sectorbuffer, 0x80) == 0 ||
CdReadSync(0, result) != 0);
iVar3 = 0;
while (iVar3 < iVar1)
*addr++ = sectorbuffer[iVar3++];
while (i < toload)
{
*addr++ = sectorbuffer[i++];
}
}
return loadsize;
#endif // PSX
@ -623,19 +617,19 @@ int LoadfileSeg(char *name, char *addr, int offset, int loadsize)
/* end block 3 */
// End Line: 4892
// [D]
// [D] [T]
void ReportMode(int on)
{
static unsigned char param[8];
if (XAPrepared() == 0)
{
param[0] = 0x80;
if (on != 0)
param[0] = 0x84;
param[0] = CdlModeSpeed | CdlModeRept;
else
param[0] = CdlModeSpeed;
CdControlB(0xe, param, 0);
CdControlB(CdlSetmode, param, 0);
}
}
@ -665,15 +659,14 @@ void ReportMode(int on)
static unsigned char endread = 0;
static unsigned char load_complete = 0;
// [D]
// [D] [T]
void data_ready(void)
{
if (endread != 0)
if (endread != 0)
{
CdDataCallback(0);
load_complete = 1;
}
return;
}
@ -704,42 +697,40 @@ void data_ready(void)
// End Line: 5565
static int current_sector = 0; // offset 0xAB27C
static char *current_address = NULL; // offset 0xAB288
static char* current_address = NULL; // offset 0xAB288
static int sectors_left = 0; // offset 0xAB280
static int sectors_read = 0; // offset 0xAB284
static int sectors_this_chunk = 0; // offset 0xAB174
static int sectors_to_read = 0; // offset 0xAB170
// [D]
void sector_ready(unsigned char intr, unsigned char *result)
// [D] [T]
void sector_ready(unsigned char intr, unsigned char* result)
{
int iVar1;
CdlLOC p;
if (intr == '\x01')
if (intr == 1)
{
CdGetSector(current_address, 0x200);
CdGetSector(current_address, 512); // and then it's multiplied by 4
current_address = current_address + 0x800;
current_address = current_address + 2048;
current_sector = current_sector + 1;
sectors_left = sectors_left + -1;
if (sectors_left == 0)
{
endread = '\x01';
endread = 1;
CdReadyCallback(0);
CdControlF(CdlPause, 0);
}
}
else
else
{
if ((*result & 0x10) != 0)
if ((*result & CdlStatShellOpen) != 0)
{
CdReadyCallback(0);
do {
iVar1 = CdDiskReady(1);
} while (iVar1 != 2);
} while (CdDiskReady(1) != 2);
CdReadyCallback(sector_ready);
}
@ -774,7 +765,8 @@ void sector_ready(unsigned char intr, unsigned char *result)
/* end block 3 */
// End Line: 5027
#ifdef PSX
void loadsectors(char *addr, int sector, int nsectors)
// [D] [T]
void loadsectors(char* addr, int sector, int nsectors)
{
CdlLOC pos;
@ -791,9 +783,9 @@ void loadsectors(char *addr, int sector, int nsectors)
CdReadyCallback(sector_ready);
do {
} while (load_complete == '\0');
} while (load_complete == 0);
ShowLoading();
return;
}
#else
// It has to be this way
@ -818,7 +810,7 @@ void loadsectorsPC(char* filename, char* addr, int sector, int nsectors)
}
fseek(fp, sector * CDSECTOR_SIZE, SEEK_SET);
int numRead = fread(addr, CDSECTOR_SIZE, nsectors, fp);
fread(addr, CDSECTOR_SIZE, nsectors, fp);
fclose(fp);
@ -863,15 +855,15 @@ void loadsectorsPC(char* filename, char* addr, int sector, int nsectors)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
void EnableDisplay(void)
{
int i;
for (i = 0; i < NumPlayers; i++) // [A]
{
ClearOTagR((u_long*)MPBuff[i][0].ot, 0x1080);
ClearOTagR((u_long*)MPBuff[i][1].ot, 0x1080);
ClearOTagR((u_long*)MPBuff[i][0].ot, OTSIZE);
ClearOTagR((u_long*)MPBuff[i][1].ot, OTSIZE);
}
}
@ -898,10 +890,10 @@ void EnableDisplay(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D] [T]
void DisableDisplay(void)
{
SetDispMask(0);
return;
}
@ -943,13 +935,14 @@ int DoNotSwap = 0;
DB* MPlast[2];
DB* MPcurrent[2];
// [A]
void ClearCurrentDrawBuffers()
{
ClearOTagR((u_long*)current->ot, 0x1080);
ClearOTagR((u_long*)current->ot, OTSIZE);
current->primptr = current->primtab;
}
// [D]
// [D] [T]
void SwapDrawBuffers(void)
{
DrawSync(0);
@ -964,7 +957,7 @@ void SwapDrawBuffers(void)
PutDrawEnv(&current->draw);
DrawOTag((u_long*)(current->ot + 0x107f));
if ((FrameCnt & 1U) == 0)
if ((FrameCnt & 1U) == 0)
{
current = &MPBuff[0][1];
last = &MPBuff[0][0];
@ -1003,10 +996,10 @@ void SwapDrawBuffers(void)
/* end block 3 */
// End Line: 2654
// [D]
// [D] [T]
void SwapDrawBuffers2(int player)
{
uint uVar1;
int toggle;
DrawSync(0);
@ -1019,20 +1012,20 @@ void SwapDrawBuffers2(int player)
if (player == 1)
{
uVar1 = FrameCnt & 1;
toggle = FrameCnt & 1;
// [A] i guess it should work as intended
MPcurrent[0] = &MPBuff[0][-uVar1 + 1];
MPlast[0] = &MPBuff[0][uVar1];
MPcurrent[0] = &MPBuff[0][-toggle + 1];
MPlast[0] = &MPBuff[0][toggle];
MPcurrent[1] = &MPBuff[1][-uVar1 + 1];
MPlast[1] = &MPBuff[1][uVar1];
MPcurrent[1] = &MPBuff[1][-toggle + 1];
MPlast[1] = &MPBuff[1][toggle];
}
current = MPcurrent[1 - player];
last = MPlast[1 - player];
ClearOTagR((u_long*)current->ot, 0x1080);
ClearOTagR((u_long*)current->ot, OTSIZE);
current->primptr = current->primtab;
}
@ -1057,7 +1050,7 @@ void SwapDrawBuffers2(int player)
short paddp;
short padd;
// [D]
// [D] [T]
void UpdatePadData(void)
{
ReadControllers();
@ -1104,18 +1097,15 @@ void UpdatePadData(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
void SetupDrawBuffers(void)
{
DB *pDVar1;
int iVar2;
DB **ppDVar3;
DB *pDVar4;
DB **ppDVar5;
int i;
RECT16 rect;
SetDefDispEnv(&MPBuff[0][0].disp, 0, 256, 320, 256);
SetDefDispEnv(&MPBuff[0][1].disp, 0, 0, 320, 256);
MPBuff[0][0].disp.screen.h = 256;
MPBuff[0][1].disp.screen.h = 256;
MPBuff[0][0].disp.screen.x = draw_mode.framex;
@ -1128,26 +1118,20 @@ void SetupDrawBuffers(void)
else
SetupDrawBufferData(1);
ppDVar5 = MPlast;
pDVar1 = MPBuff[0];
pDVar4 = MPBuff[0] + 1;
ppDVar3 = MPcurrent;
iVar2 = 1;
do {
*ppDVar5 = pDVar4;
ppDVar5 = ppDVar5 + 1;
pDVar4 = pDVar4 + 2;
*ppDVar3 = pDVar1;
ppDVar3 = ppDVar3 + 1;
iVar2 = iVar2 + -1;
pDVar1 = pDVar1 + 2;
} while (-1 < iVar2);
rect.w = 0x140;
for (i = 0; i < 2; i++)
{
MPlast[i] = &MPBuff[i][1];
MPcurrent[i] = &MPBuff[i][0];
}
rect.w = 320;
rect.h = 512;
rect.x = 0;
rect.y = 0;
rect.h = 0x200;
current = MPcurrent[0];
last = MPlast[0];
ClearImage(&rect, 0, 0, 0);
DrawSync(0);
}
@ -1185,7 +1169,7 @@ void SetupDrawBuffers(void)
/* end block 3 */
// End Line: 2935
// [D]
// [D] [T]
void SetupDrawBufferData(int num_players)
{
int i;
@ -1195,7 +1179,7 @@ void SetupDrawBufferData(int num_players)
int height;
int toggle;
if (num_players == 1)
if (num_players == 1)
{
height = 256;
x[0] = 0;
@ -1219,16 +1203,16 @@ void SetupDrawBufferData(int num_players)
}
SetGeomOffset(160, height / 2);
toggle = 0;
for (i = 0; i < 2; i++)
{
for (j = 0; j < num_players; j++)
{
u_long *otpt;
unsigned char *primpt;
unsigned char *PRIMpt;
u_long* otpt;
unsigned char* primpt;
unsigned char* PRIMpt;
if (toggle)
{
@ -1278,8 +1262,8 @@ void SetupDrawBufferData(int num_players)
/* end block 2 */
// End Line: 5091
// [D]
void InitaliseDrawEnv(DB *pBuff, int x, int y, int w, int h)
// [D] [T]
void InitaliseDrawEnv(DB* pBuff, int x, int y, int w, int h)
{
SetDefDrawEnv(&pBuff[0].draw, x, y + 256, w, h);
SetDefDrawEnv(&pBuff[1].draw, x, y, w, h);
@ -1314,7 +1298,7 @@ void InitaliseDrawEnv(DB *pBuff, int x, int y, int w, int h)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
// [D] [T]
void ResetCityType(void)
{
lasttype = (CITYTYPE)-1;
@ -1356,23 +1340,14 @@ void ResetCityType(void)
/* end block 4 */
// End Line: 3318
// [D]
// [D] [T]
void SetCityType(CITYTYPE type)
{
int *piVar1;
CdlFILE *pCVar2;
int levOfs;
int iVar3;
XYPAIR *cdp;
char *format;
int *piVar4;
CdlFILE fp;
char* format;
char filename[64];
unsigned char result[8];
if ((type == lasttype) && (GameLevel == (uint)lastcity))
if (type == lasttype && GameLevel == lastcity)
return;
lastcity = GameLevel;
@ -1425,59 +1400,58 @@ void SetCityType(CITYTYPE type)
fclose(levFp);
#else
CdlFILE cdfile;
XYPAIR* info;
int i;
int sector;
int* data;
switch (type)
{
case CITYTYPE_NIGHT:
format = "\\%sN%s;1";
break;
case CITYTYPE_MULTI_DAY:
format = "\\%sM%s;1";
break;
case CITYTYPE_MULTI_NIGHT:
format = "\\%sMN%s;1";
break;
default:
format = "\\%s%s;1";
break;
case CITYTYPE_NIGHT:
format = "\\%sN%s;1";
break;
case CITYTYPE_MULTI_DAY:
format = "\\%sM%s;1";
break;
case CITYTYPE_MULTI_NIGHT:
format = "\\%sMN%s;1";
break;
default:
format = "\\%s%s;1";
break;
}
sprintf(filename, format, gDataFolder, LevelFiles[GameLevel]);
LAB_0007f244:
pCVar2 = CdSearchFile(&fp, filename);
while (pCVar2 == NULL)
while (CdSearchFile(&cdfile, filename) == NULL)
{
DoCDRetry();
pCVar2 = CdSearchFile(&fp, filename);
}
levOfs = CdPosToInt((CdlLOC *)&fp);
citystart[GameLevel] = levOfs;
sector = CdPosToInt((CdlLOC*)&cdfile);
citystart[GameLevel] = sector;
do {
do {
iVar3 = CdDiskReady(0);
if (iVar3 != 2) {
if (CdDiskReady(0) != 2)
DoCDRetry();
}
iVar3 = CdControlB(2, (u_char*)&fp, 0);
} while ((iVar3 == 0) || (iVar3 = CdRead(1, (u_long*)_other_buffer, 0x80), iVar3 == 0));
iVar3 = CdReadSync(0, result);
} while (iVar3 != 0);
iVar3 = 3;
cdp = citylumps[GameLevel];
} while (CdControlB(2, (u_char*)&cdfile, 0) == 0 ||
CdRead(1, (u_long*)_OT1, 0x80) == 0);
piVar4 = (int*)(_other_buffer + 8);
do {
iVar3 = iVar3 + -1;
cdp->x = *piVar4 + levOfs * 0x800;
piVar1 = piVar4 + 1;
piVar4 = piVar4 + 2;
cdp->y = *piVar1;
cdp = cdp + 1;
} while (-1 < iVar3);
} while (CdReadSync(0, result) != 0);
data = (int*)_OT1 + 2;
for (i = 0; i < 4; i++)
{
citylumps[GameLevel][i].x = data[0] + sector * 2048;
citylumps[GameLevel][i].y = data[1];
data += 2;
}
#endif // PSX
}
@ -1504,25 +1478,26 @@ LAB_0007f244:
/* end block 2 */
// End Line: 4862
// [D]
int FileExists(char *filename)
// [D] [T]
int FileExists(char* filename)
{
#ifdef PSX
CdlFILE *pCVar1;
int retries;
CdlFILE cdfile;
char namebuffer[128];
sprintf(namebuffer, "\\%s%s;1", gDataFolder, filename);
retries = 9;
do {
pCVar1 = CdSearchFile(&cdfile, namebuffer);
if (pCVar1 != (CdlFILE *)0x0) {
if (CdSearchFile(&cdfile, namebuffer) != NULL)
return 1;
}
retries--;
DoCDRetry();
} while (retries != -1);
} while (retries >= 0);
return 0;
#else
char namebuffer[128];
@ -1570,47 +1545,44 @@ int FileExists(char *filename)
/* end block 3 */
// End Line: 4951
// [D]
CDTYPE DiscSwapped(char *filename)
// [D] [T]
CDTYPE DiscSwapped(char* filename)
{
#ifndef PSX
return CDTYPE_CORRECTDISC;
#else
CDTYPE ret;
int iVar1;
CdlFILE cdfile;
iVar1 = CdDiskReady(1);
if (iVar1 == 2)
switch(CdDiskReady(1))
{
iVar1 = CdGetDiskType();
if (iVar1 != 1)
case CdlStatStandby:
{
if (iVar1 < 2)
switch(CdGetDiskType())
{
if (iVar1 != 0)
return CDTYPE_DISCERROR;
return CDTYPE_NODISC;
case CdlStatNoDisk:
ret = CDTYPE_NODISC;
break;
case CdlOtherFormat:
ret = CDTYPE_WRONGDISC;
break;
case CdlCdromFormat:
{
if (CdSearchFile(&cdfile, filename) != NULL)
ret = CDTYPE_CORRECTDISC;
else
ret = CDTYPE_DISCERROR;
break;
}
}
if (iVar1 != 2)
goto LAB_0007f66c;
if (CdSearchFile(&cdfile, filename) != NULL)
return CDTYPE_CORRECTDISC;
break;
}
ret = CDTYPE_WRONGDISC;
}
else
{
LAB_0007f66c:
ret = CDTYPE_DISCERROR;
if (iVar1 == 0x10)
case CdlStatShellOpen:
ret = CDTYPE_SHELLOPEN;
break;
default:
ret = CDTYPE_DISCERROR;
}
return ret;

View File

@ -84,8 +84,7 @@ extern DB MPBuff[2][2];
extern DB* last;
extern DB* current;
#define OTLEN 13
#define OTSIZE (1<<OTLEN) /* ordering table size */
#define OTSIZE 0x1080 /* ordering table size */
#ifdef USE_32_BIT_ADDR
# define PRIMTAB_SIZE 0x50000

View File

@ -764,8 +764,6 @@ void LoadPermanentTPages(int *sector)
IncrementTPageNum(&tpage);
clutpos.y += 8;
}
//Emulator_SaveVRAM("VRAM_CLUTS_TPAGES.TGA", 0, 0, VRAM_WIDTH, VRAM_HEIGHT, TRUE);
}

View File

@ -919,12 +919,15 @@ void AddWheelForcesDriver1(CAR_DATA* cp, CAR_LOCALS* cl)
{
if (ABS(newCompression - oldCompression) > 12 && (i & 1U) != 0)
{
chan = GetFreeChannel();
if (NumPlayers > 1 && NoPlayerControl == 0)
SetPlayerOwnsChannel(chan, player_id);
chan = GetFreeChannel(0);
if(chan > -1)
{
if (NumPlayers > 1 && NoPlayerControl == 0)
SetPlayerOwnsChannel(chan, player_id);
Start3DSoundVolPitch(chan, 1, 5, cp->hd.where.t[0], cp->hd.where.t[1], cp->hd.where.t[2], -2500, 400);
SetChannelPosition3(chan, (VECTOR*)cp->hd.where.t, NULL, -2500, 400, 0);
Start3DSoundVolPitch(chan, SOUND_BANK_SFX, 5, cp->hd.where.t[0], cp->hd.where.t[1], cp->hd.where.t[2], -2500, 400);
SetChannelPosition3(chan, (VECTOR*)cp->hd.where.t, NULL, -2500, 400, 0);
}
}
if (newCompression >= 85)

View File

@ -1,7 +1,7 @@
#ifndef VERSION_H
#define VERSION_H
#define GAME_VERSION_N "2.6 alpha"
#define GAME_VERSION_N "3.0 alpha"
#define GAME_TITLE "REDRIVER2"
#define GAME_VERSION GAME_TITLE " " GAME_VERSION_N