- implement InitOverlays, InitPercentageBar, DisplayOverlays, DrawPercentageBar, SetColourByValue

This commit is contained in:
Ilya Shurumov 2020-04-13 03:30:03 +06:00
parent fec76bcfa4
commit 9e19ac4fdd
10 changed files with 256 additions and 169 deletions

View File

@ -16,6 +16,9 @@ char sqtbl[] = {
0xA7, 0xA8, 0xAA, 0xAB, 0xAC, 0xAE, 0xAF, 0xB0, 0xB2,
0xB3, 0xB5 };
int CopsCanSeePlayer = 0;
short pedestrianFelony = 0;
// decompiled code
// original method signature:
// void /*$ra*/ InitCopState(struct _CAR_DATA *cp /*$s0*/, char *extraData /*$a1*/)

View File

@ -2,6 +2,8 @@
#define COP_AI_H
extern COP_DATA gCopData;
extern int CopsCanSeePlayer;
extern short pedestrianFelony;
extern void InitCopState(_CAR_DATA *cp, char *extraData); // 0x0002F680

View File

@ -1,6 +1,8 @@
#include "THISDUST.H"
#include "CUTSCENE.H"
int gInGameCutsceneActive = 0;
int gInGameCutsceneDelay = 0;
// decompiled code
// original method signature:

View File

@ -1,6 +1,8 @@
#ifndef CUTSCENE_H
#define CUTSCENE_H
extern int gInGameCutsceneActive;
extern int gInGameCutsceneDelay;
extern void InitInGameCutsceneVariables(); // 0x000325C0

View File

@ -2520,6 +2520,7 @@ void UpdatePlayerInformation(void)
int CurrentPlayerView = 0;
// [D]
void RenderGame2(int view)
{
DB *pDVar1;

View File

@ -3,6 +3,7 @@
extern int FrameCnt;
extern int CameraCnt;
extern int CurrentPlayerView;
typedef void(*occlFunc)(int *comp_val);

View File

@ -147,6 +147,11 @@ unsigned char reservedSlots[20]; // car slots
unsigned char playercollected[2] = { 0, 0 };
int TAIL_GETTINGCLOSE = 7000;
int TAIL_GETTINGFAR = 12900;
int TAIL_TOOCLOSE = 4000;
int TAIL_TOOFAR = 15900;
// [D]
void InitialiseMissionDefaults(void)
{

View File

@ -30,6 +30,7 @@ extern int gBatterPlayer;
extern int wantedCar[2];
extern int multiplayerregions[4];
extern int MaxPlayerDamage[2];
extern COP_DATA gCopData;
@ -39,6 +40,11 @@ extern char *MissionStrings;
extern int gMultiplayerLevels;
extern int TAIL_GETTINGCLOSE;
extern int TAIL_GETTINGFAR;
extern int TAIL_TOOCLOSE;
extern int TAIL_TOOFAR;
extern void InitialiseMissionDefaults(); // 0x0006084C
extern void LoadMission(int missionnum); // 0x00060A74

View File

@ -1,6 +1,16 @@
#include "THISDUST.H"
#include "OVERLAY.H"
#include "SYSTEM.H"
#include "MISSION.H"
#include "GLAUNCH.H"
#include "MAIN.H"
#include "PAUSE.H"
#include "DIRECTOR.H"
#include "OVERMAP.H"
#include "COP_AI.H"
#include "CUTSCENE.H"
#include "CARS.H"
#include "PRES.H"
COLOUR_BAND felonyColour[3] =
{
@ -36,43 +46,57 @@ COLOUR_BAND damageColour[2] =
/* WARNING: Unknown calling convention yet parameter storage is locked */
_PERCENTAGE_BAR PlayerDamageBar;
_PERCENTAGE_BAR Player2DamageBar;
_PERCENTAGE_BAR DamageBar;
_PERCENTAGE_BAR FelonyBar;
_PERCENTAGE_BAR ProxyBar;
// [D]
void InitOverlays(void)
{
UNIMPLEMENTED();
/*
bool bVar1;
InitPercentageBar(&PlayerDamageBar, MaxPlayerDamage, playerDamageColour, s_Danni_000aa004);
InitPercentageBar(&PlayerDamageBar, MaxPlayerDamage[0], playerDamageColour, "Damage");
PlayerDamageBar.xpos = 0x10;
PlayerDamageBar.ypos = 0x18;
bVar1 = 1 < NumPlayers;
PlayerDamageBar.active = 1;
if (bVar1) {
InitPercentageBar(&Player2DamageBar, INT_000aa714, playerDamageColour, s_Danni_000aa004);
if (bVar1)
{
InitPercentageBar(&Player2DamageBar, MaxPlayerDamage[1], playerDamageColour, "Damage");
Player2DamageBar.xpos = 0x10;
Player2DamageBar.ypos = 0x8c;
}
Player2DamageBar.active = ZEXT14(bVar1);
InitPercentageBar(&FelonyBar, 0x1000, felonyColour, s_Crimine_000aa00c);
Player2DamageBar.active = (bVar1);
InitPercentageBar(&FelonyBar, 0x1000, felonyColour, "Felony");
FelonyBar.xpos = 0x10;
FelonyBar.ypos = 0x2e;
FelonyBar.active = 0;
InitPercentageBar(&DamageBar, 1, damageColour, s_Danni_000aa004);
InitPercentageBar(&DamageBar, 1, damageColour, "Damage");
DamageBar.xpos = 0xd0;
DamageBar.ypos = 0x18;
DamageBar.flags = 1;
DamageBar.active = 0;
InitPercentageBar(&ProxyBar, TAIL_TOOFAR - TAIL_TOOCLOSE, felonyColour, &DAT_00010384);
InitPercentageBar(&ProxyBar, TAIL_TOOFAR - TAIL_TOOCLOSE, felonyColour, "Proximity");
ProxyBar.xpos = 0x10;
ProxyBar.ypos = 0x2e;
ProxyBar.active = 0;
InitOverheadMap();
if (GameType == GAME_CAPTURETHEFLAG) {
PlayerDamageBar.active = 0;
Player2DamageBar.active = 0;
gInvincibleCar = 1;
}
return;*/
}
@ -93,46 +117,56 @@ void InitOverlays(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
void DisplayOverlays(void)
{
/*
short *psVar1;
if (((NoPlayerControl == 0) && (gInGameCutsceneActive == 0)) && (gInGameCutsceneDelay == 0)) {
if (1 < NumPlayers) {
if (CurrentPlayerView == 0) {
if (((NoPlayerControl == 0) && (gInGameCutsceneActive == 0)) && (gInGameCutsceneDelay == 0))
{
if (1 < NumPlayers)
{
if (CurrentPlayerView == 0)
return;
}
SetFullscreenDrawing();
}
UpdateFlashValue();
if (gShowMap == 0) {
if (gShowMap == 0)
{
DrawPercentageBar(&PlayerDamageBar);
DrawPercentageBar(&Player2DamageBar);
DrawPercentageBar(&DamageBar);
DrawPercentageBar(&FelonyBar);
DrawDrivingGameOverlays();
FastForward = 0;
DrawOverheadMap();
if (CopsCanSeePlayer != 0) {
if ((int)player.playerCarId < 0) {
if (CopsCanSeePlayer != 0)
{
if ((int)player[0].playerCarId < 0)
{
psVar1 = &pedestrianFelony;
}
else {
psVar1 = &car_data[(int)player.playerCarId].felonyRating;
else
{
psVar1 = &car_data[(int)player[0].playerCarId].felonyRating;
}
if (0x292 < *psVar1) {
if (658 < *psVar1)
DrawCopIndicators();
}
}
}
else {
else
{
FastForward = 1;
DrawFullscreenMap();
}
}
return;
*/
}
@ -173,6 +207,7 @@ void DisplayOverlays(void)
/* WARNING: Unknown calling convention yet parameter storage is locked */
// [D]
void SetFullscreenDrawing(void)
{
DR_ENV *drenv;
@ -210,8 +245,8 @@ void SetFullscreenDrawing(void)
/* end block 3 */
// End Line: 1486
// [D]
void InitPercentageBar(_PERCENTAGE_BAR *bar, int size, COLOUR_BAND *pColourBand, char *tag)
{
bar->xpos = 0x96;
bar->ypos = 10;
@ -223,7 +258,6 @@ void InitPercentageBar(_PERCENTAGE_BAR *bar, int size, COLOUR_BAND *pColourBand,
bar->flags = 0;
bar->tag = tag;
bar->active = 0;
return;
}
@ -247,13 +281,12 @@ void InitPercentageBar(_PERCENTAGE_BAR *bar, int size, COLOUR_BAND *pColourBand,
/* end block 3 */
// End Line: 1528
// [D]
void EnablePercentageBar(_PERCENTAGE_BAR *bar, int max)
{
bar->position = 0;
bar->max = (ushort)max;
bar->active = 1;
return;
}
@ -292,168 +325,186 @@ void EnablePercentageBar(_PERCENTAGE_BAR *bar, int max)
/* end block 2 */
// End Line: 896
// [D]
void DrawPercentageBar(_PERCENTAGE_BAR *bar)
{
UNIMPLEMENTED();
/*
short sVar1;
DB *pDVar2;
uint uVar3;
uint *puVar4;
short sVar3;
uint uVar4;
POLY_G4 *poly;
POLY_G4 *poly2;
char *string;
short sVar5;
undefined2 uVar6;
undefined2 uVar7;
short uVar6;
short uVar7;
int y;
char *pcVar8;
short sVar9;
CVECTOR local_38[2];
int local_30;
CVECTOR temp;
int max_y;
if (bar->active != 0) {
if (bar->max < bar->position) {
if (bar->active != 0)
{
if (bar->max < bar->position)
{
bar->position = bar->max;
}
if (bar->max == 0) {
if (bar->max == 0)
{
sVar5 = bar->xpos;
uVar3 = bar->flags;
uVar4 = bar->flags;
sVar9 = sVar5;
}
else {
uVar3 = bar->flags;
if ((uVar3 & 1) == 0) {
else
{
uVar4 = bar->flags;
if ((uVar4 & 1) == 0)
{
sVar5 = bar->xpos;
if (bar->max == 0) {
trap(7);
//trap(7); // [A]
}
sVar9 = sVar5 + (short)((int)((int)bar->width * (uint)bar->position) / (int)(uint)bar->max);
}
else {
else
{
sVar9 = bar->xpos + bar->width;
if (bar->max == 0) {
trap(7);
//trap(7); // [A]
}
sVar5 = sVar9 - (short)((int)((int)bar->width * (uint)bar->position) / (int)(uint)bar->max);
}
}
sVar1 = bar->ypos;
local_30 = (int)sVar1 + (int)bar->height;
if ((uVar3 & 2) == 0) {
puVar4 = (uint *)current->primptr;
*(char *)((int)puVar4 + 3) = '\b';
*(char *)((int)puVar4 + 7) = '8';
sVar3 = sVar1 + bar->height;
if ((uVar4 & 2) == 0)
{
poly = (POLY_G4 *)current->primptr;
setPolyG4(poly);
if (bar->max == 0) {
trap(7);
//trap(7);// [A]
}
SetColourByValue(bar->pColourBand, (int)((uint)bar->position << 0xc) / (int)(uint)bar->max,
local_38);
*(byte *)(puVar4 + 1) = local_38[0].r;
*(byte *)((int)puVar4 + 5) = local_38[0].g;
*(byte *)((int)puVar4 + 6) = local_38[0].b;
*(byte *)(puVar4 + 3) = local_38[0].r;
*(byte *)((int)puVar4 + 0xd) = local_38[0].g;
*(byte *)((int)puVar4 + 0xe) = local_38[0].b;
local_38[0].r = local_38[0].r >> 2;
local_38[0].g = local_38[0].g >> 2;
local_38[0].b = local_38[0].b >> 2;
*(byte *)(puVar4 + 5) = local_38[0].r;
*(byte *)((int)puVar4 + 0x15) = local_38[0].g;
*(byte *)((int)puVar4 + 0x16) = local_38[0].b;
*(byte *)(puVar4 + 7) = local_38[0].r;
*(byte *)((int)puVar4 + 0x1d) = local_38[0].g;
*(short *)(puVar4 + 2) = sVar5;
*(short *)((int)puVar4 + 10) = sVar1;
*(short *)(puVar4 + 4) = sVar9;
*(short *)((int)puVar4 + 0x12) = sVar1;
*(byte *)((int)puVar4 + 0x1e) = local_38[0].b;
*(short *)(puVar4 + 6) = sVar5;
pDVar2 = current;
*(short *)(puVar4 + 8) = sVar9;
*(undefined2 *)((int)puVar4 + 0x1a) = (short)local_30;
*(undefined2 *)((int)puVar4 + 0x22) = (short)local_30;
*puVar4 = *puVar4 & 0xff000000 | pDVar2->ot[1] & 0xffffff;
pDVar2->ot[1] = pDVar2->ot[1] & 0xff000000 | (uint)puVar4 & 0xffffff;
pDVar2->primptr = pDVar2->primptr + 0x24;
SetColourByValue(bar->pColourBand, (int)((uint)bar->position << 0xc) / (int)(uint)bar->max, &temp);
poly->r0 = temp.r;
poly->g0 = temp.g;
poly->b0 = temp.b;
poly->r1 = temp.r;
poly->g1 = temp.g;
poly->b1 = temp.b;
temp.r = temp.r >> 2;
temp.g = temp.g >> 2;
temp.b = temp.b >> 2;
poly->r2 = temp.r;
poly->g2 = temp.g;
poly->b2 = temp.b;
poly->r3 = temp.r;
poly->g3 = temp.g;
poly->x0 = sVar5;
poly->y0 = sVar1;
poly->x1 = sVar9;
poly->y1 = sVar1;
poly->b3 = temp.b;
poly->x2 = sVar5;
poly->x3 = sVar9;
poly->y2 = sVar3;
poly->y3 = sVar3;
addPrim((u_long*)(current->ot + 1), poly);
current->primptr += sizeof(POLY_G4);
}
sVar5 = bar->xpos;
sVar9 = sVar5 + bar->width;
puVar4 = (uint *)current->primptr;
*(char *)((int)puVar4 + 3) = '\b';
*(short *)(puVar4 + 2) = sVar5;
*(short *)(puVar4 + 6) = sVar5;
*(char *)((int)puVar4 + 7) = ':';
*(char *)(puVar4 + 1) = '\0';
*(char *)((int)puVar4 + 5) = '\0';
*(char *)((int)puVar4 + 6) = '\0';
*(char *)(puVar4 + 3) = '\0';
*(char *)((int)puVar4 + 0xd) = '\0';
*(char *)((int)puVar4 + 0xe) = '\0';
*(char *)(puVar4 + 5) = 'd';
*(char *)((int)puVar4 + 0x15) = 'd';
*(char *)((int)puVar4 + 0x16) = 'd';
*(char *)(puVar4 + 7) = 'd';
*(char *)((int)puVar4 + 0x1d) = 'd';
*(char *)((int)puVar4 + 0x1e) = 'd';
*(short *)((int)puVar4 + 10) = sVar1;
*(short *)(puVar4 + 4) = sVar9;
*(short *)((int)puVar4 + 0x12) = sVar1;
pDVar2 = current;
*(short *)(puVar4 + 8) = sVar9;
*(undefined2 *)((int)puVar4 + 0x1a) = (short)local_30;
*(undefined2 *)((int)puVar4 + 0x22) = (short)local_30;
*puVar4 = *puVar4 & 0xff000000 | pDVar2->ot[1] & 0xffffff;
pDVar2->ot[1] = pDVar2->ot[1] & 0xff000000 | (uint)puVar4 & 0xffffff;
pcVar8 = pDVar2->primptr;
string = pcVar8 + 0x24;
pDVar2->primptr = string;
SetLineF4(string);
pcVar8[0x28] = 'P';
pcVar8[0x29] = 'P';
pcVar8[0x2a] = 'P';
pDVar2 = current;
uVar6 = (undefined2)((uint)(((int)sVar5 + -1) * 0x10000) >> 0x10);
*(undefined2 *)(pcVar8 + 0x2c) = uVar6;
uVar7 = (undefined2)((uint)(((int)sVar1 + -1) * 0x10000) >> 0x10);
*(undefined2 *)(pcVar8 + 0x2e) = uVar7;
*(short *)(pcVar8 + 0x30) = sVar9;
*(undefined2 *)(pcVar8 + 0x32) = uVar7;
*(short *)(pcVar8 + 0x34) = sVar9;
*(undefined2 *)(pcVar8 + 0x38) = uVar6;
*(short *)(pcVar8 + 0x36) = (short)local_30;
*(short *)(pcVar8 + 0x3a) = (short)local_30;
*(uint *)(pcVar8 + 0x24) = *(uint *)(pcVar8 + 0x24) & 0xff000000 | pDVar2->ot[1] & 0xffffff;
pDVar2->ot[1] = pDVar2->ot[1] & 0xff000000 | (uint)string & 0xffffff;
pcVar8 = pDVar2->primptr;
string = pcVar8 + 0x1c;
pDVar2->primptr = string;
SetLineF2(string);
pcVar8[0x20] = 'P';
pcVar8[0x21] = 'P';
pcVar8[0x22] = 'P';
pDVar2 = current;
*(undefined2 *)(pcVar8 + 0x24) = uVar6;
*(undefined2 *)(pcVar8 + 0x26) = uVar7;
*(undefined2 *)(pcVar8 + 0x28) = uVar6;
*(short *)(pcVar8 + 0x2a) = (short)local_30;
*(uint *)(pcVar8 + 0x1c) = *(uint *)(pcVar8 + 0x1c) & 0xff000000 | pDVar2->ot[1] & 0xffffff;
pDVar2->ot[1] = pDVar2->ot[1] & 0xff000000 | (uint)string & 0xffffff;
pDVar2->primptr = pDVar2->primptr + 0x10;
TransparencyOn(pDVar2->ot + 1, 0x20);
poly2 = (POLY_G4 *)current->primptr;
setPolyG4(poly2);
setSemiTrans(poly2,1);
poly2->x0 = sVar5;
poly2->x2 = sVar5;
poly2->code = ':';
poly2->r0 = '\0';
poly2->g0 = '\0';
poly2->b0 = '\0';
poly2->r1 = '\0';
poly2->g1 = '\0';
poly2->b1 = '\0';
poly2->r2 = 'd';
poly2->g2 = 'd';
poly2->b2 = 'd';
poly2->r3 = 'd';
poly2->g3 = 'd';
poly2->b3 = 'd';
poly2->y0 = sVar1;
poly2->x1 = sVar9;
poly2->y1 = sVar1;
poly2->x3 = sVar9;
poly2->y2 = sVar3;
poly2->y3 = sVar3;
addPrim((u_long*)(current->ot+1), poly2);
current->primptr += sizeof(POLY_G4);
LINE_F4* lineF4 = (LINE_F4*)current->primptr;
setLineF4(lineF4);
lineF4->r0 = 80;
lineF4->g0 = 80;
lineF4->b0 = 80;
uVar6 = ((uint)(((int)sVar5 + -1) * 0x10000) >> 0x10);
uVar7 = ((uint)(((int)sVar1 + -1) * 0x10000) >> 0x10);
lineF4->x0 = uVar6;
lineF4->y0 = uVar7;
lineF4->x1 = sVar9;
lineF4->y1 = uVar7;
lineF4->x2 = sVar9;
lineF4->x3 = uVar6;
lineF4->y2 = sVar3;
lineF4->y3 = sVar3;
addPrim((u_long*)(current->ot + 1), lineF4);
current->primptr += sizeof(LINE_F4);
LINE_F2* lineF2 = (LINE_F2*)current->primptr;
setLineF2(lineF2);
lineF2->r0 = 80;
lineF2->g0 = 80;
lineF2->b0 = 80;
lineF2->x0 = uVar6;
lineF2->y0 = uVar7;
lineF2->x1 = uVar6;
lineF2->y1 = sVar3;
addPrim((u_long*)(current->ot + 1), lineF2);
current->primptr += sizeof(LINE_F2);
//TransparencyOn((u_long*)(current->ot + 1), 0x20); // [A] temporarily disabled
string = bar->tag;
if (string != (char *)0x0) {
if (string != NULL)
{
sVar5 = bar->xpos;
y = (int)(((uint)(ushort)bar->ypos - 0xb) * 0x10000) >> 0x10;
SetTextColour(-0x80, -0x80, '@');
if ((bar->flags & 1U) == 0) {
if ((bar->flags & 1U) == 0)
PrintString(string, (int)sVar5 + 8, y);
}
else {
else
PrintStringRightAligned(string, (int)sVar5 + (int)bar->width + -8, y);
}
}
}
return;
*/
}
@ -695,44 +746,49 @@ void DrawProximityBar(_PERCENTAGE_BAR *bar)
/* end block 3 */
// End Line: 1967
char OverlayFlashValue = 0;
// [D]
void SetColourByValue(COLOUR_BAND *pColourBand, int value, CVECTOR *pOut)
{
UNIMPLEMENTED();
/*
COLOUR_BAND *pCVar1;
COLOUR_BAND *pCVar2;
int iVar3;
int iVar4;
pCVar2 = pColourBand + 1;
if (pColourBand[1].value < value) {
if (pColourBand[1].value < value)
{
pCVar1 = pColourBand + 2;
do {
pCVar2 = pCVar1;
pCVar1 = pCVar2 + 1;
} while (pCVar2->value < value);
}
if ((pCVar2->flags != 0) && (pCVar2->flags == 2)) {
iVar3 = (uint)(byte)OverlayFlashValue * (pCVar2->value - pCVar2[-1].value);
if ((pCVar2->flags != 0) && (pCVar2->flags == 2))
{
iVar3 = OverlayFlashValue * (pCVar2->value - pCVar2[-1].value);
if (iVar3 < 0) {
iVar3 = iVar3 + 7;
}
value = pCVar2[-1].value + (iVar3 >> 3);
}
iVar3 = pCVar2->value - pCVar2[-1].value;
iVar4 = ((value - pCVar2[-1].value) * 0x1000) / iVar3;
if (iVar3 == 0) {
trap(7);
//trap(7); // [A]
}
iVar3 = 0x1000 - iVar4;
pOut->r = (uchar)((int)(iVar3 * (uint)pCVar2[-1].colour.r + iVar4 * (uint)(pCVar2->colour).r) >>
0xc);
pOut->g = (uchar)((int)(iVar3 * (uint)pCVar2[-1].colour.g + iVar4 * (uint)(pCVar2->colour).g) >>
0xc);
pOut->b = (uchar)((int)(iVar3 * (uint)pCVar2[-1].colour.b + iVar4 * (uint)(pCVar2->colour).b) >>
0xc);
return;
*/
pOut->r = ((int)(iVar3 * (uint)pCVar2[-1].colour.r + iVar4 * (uint)(pCVar2->colour).r) >> 0xc);
pOut->g = ((int)(iVar3 * (uint)pCVar2[-1].colour.g + iVar4 * (uint)(pCVar2->colour).g) >> 0xc);
pOut->b = ((int)(iVar3 * (uint)pCVar2[-1].colour.b + iVar4 * (uint)(pCVar2->colour).b) >> 0xc);
}
@ -768,6 +824,16 @@ void SetColourByValue(COLOUR_BAND *pColourBand, int value, CVECTOR *pOut)
void TransparencyOn(void *potz, ushort tpage)
{
UNIMPLEMENTED();
/*
DR_TPAGE *null;
null = (DR_TPAGE*)current->primptr;
setDrawTPage(null, 0, 0, 0x9ff, 0); // [A] might be wrong
addPrim(potz, null);
current->primptr += sizeof(DR_TPAGE);
*/
/*
DB *pDVar1;
uint *puVar2;
@ -778,8 +844,7 @@ void TransparencyOn(void *potz, ushort tpage)
*puVar2 = *puVar2 & 0xff000000 | *(uint *)potz & 0xffffff;
pDVar1 = current;
*(uint *)potz = *(uint *)potz & 0xff000000 | (uint)puVar2 & 0xffffff;
pDVar1->primptr = pDVar1->primptr + 8;
return;*/
pDVar1->primptr = pDVar1->primptr + 8;*/
}

View File

@ -9,6 +9,7 @@
#include "GLAUNCH.H"
#include "SCORES.H"
#include "SOUND.H"
#include "CUTSCENE.H"
void PauseMap(int direction);
void SfxVolume(int direction);
@ -274,7 +275,6 @@ static char SfxVolumeText[8];
static char MusicVolumeText[8];
// MISSION.C
int gInGameCutsceneActive = 0;
PAUSEMODE gMissionCompletionState = PAUSEMODE_GAMEOVER;
// [D]