Skip to content

Commit

Permalink
Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into…
Browse files Browse the repository at this point in the history
… port-net
  • Loading branch information
fgsfdsfgs committed Nov 17, 2024
2 parents 44c5a4c + 06dcbcc commit 7721297
Show file tree
Hide file tree
Showing 55 changed files with 459 additions and 459 deletions.
2 changes: 1 addition & 1 deletion src/game/bg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@ void bgReset(s32 stagenum)
// Copy 0x40 bytes from a random location in ROM to a random
// location in RAM. The write address can be anywhere in the
// boot segment or in the lib segment up to modelRenderNodeDl.
dmaExec((void *)(PHYS_TO_K0(0x1000) + (random() & 0x1fff8)), random() & 0x1fffe, 0x40);
dmaExec((void *)(PHYS_TO_K0(0x1000) + (rngRandom() & 0x1fff8)), rngRandom() & 0x1fffe, 0x40);
}
}
#endif
Expand Down
14 changes: 7 additions & 7 deletions src/game/body.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ struct model *bodyAllocateModel(s32 bodynum, s32 headnum, u32 spawnflags)
if (spawnflags & SPAWNFLAG_FORCESUNGLASSES) {
sunglasses = true;
} else if (spawnflags & SPAWNFLAG_MAYBESUNGLASSES) {
sunglasses = random() % 2 == 0;
sunglasses = rngRandom() % 2 == 0;
}

if (spawnflags & SPAWNFLAG_FIXEDHEIGHT) {
Expand All @@ -325,7 +325,7 @@ s32 bodyChooseHead(s32 bodynum)
g_ActiveMaleHeadsIndex = 0;
}
} else if (bodynum == BODY_FEM_GUARD) {
head = g_FemGuardHeads[random() % 3];
head = g_FemGuardHeads[rngRandom() % 3];
} else {
head = g_ActiveFemaleHeads[g_ActiveFemaleHeadsIndex++];

Expand Down Expand Up @@ -493,10 +493,10 @@ void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex)
if (packed->tude != 4) {
chr->tude = packed->tude;
} else {
chr->tude = random() % 4;
chr->tude = rngRandom() % 4;
}

chr->voicebox = random() % 3;
chr->voicebox = rngRandom() % 3;

if (!g_HeadsAndBodies[chr->bodynum].ismale) {
chr->voicebox = VOICEBOX_FEMALE;
Expand All @@ -519,7 +519,7 @@ void bodyAllocateChr(s32 stagenum, struct packedchr *packed, s32 cmdindex)
chr->flags |= CHRFLAG0_AIVSAI;
}

if (random() % 5 == 0) {
if (rngRandom() % 5 == 0) {
// Make chr punch slower
chr->flags2 |= CHRFLAG1_ADJUSTPUNCHSPEED;
}
Expand Down Expand Up @@ -596,8 +596,8 @@ struct prop *bodyAllocateEyespy(struct pad *pad, RoomNum room)
chr->team = 0;
chr->squadron = 0;
chr->maxdamage = 2;
chr->tude = random() & 3;
chr->voicebox = random() % 3;
chr->tude = rngRandom() & 3;
chr->voicebox = rngRandom() % 3;
chr->naturalanim = 0;
chr->myspecial = 0;
chr->yvisang = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/game/bodyreset.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void bodiesReset(s32 stagenum)
g_HeadsAndBodies[i].modeldef = NULL;
}

var80062c80 = random() % g_NumBondBodies;
var80062c80 = rngRandom() % g_NumBondBodies;
var80062b14 = 0;
var80062b18 = 0;

Expand Down Expand Up @@ -67,7 +67,7 @@ void bodiesReset(s32 stagenum)
for (i = 0; i < g_NumActiveHeadsPerGender; i++) {
do {
done = true;
g_ActiveMaleHeads[i] = headsavailablelist[random() % headsavailablelen];
g_ActiveMaleHeads[i] = headsavailablelist[rngRandom() % headsavailablelen];

if (headsavailablelen > g_NumActiveHeadsPerGender) {
for (j = 0; j < i; j++) {
Expand Down Expand Up @@ -97,7 +97,7 @@ void bodiesReset(s32 stagenum)
for (i = 0; i < g_NumActiveHeadsPerGender; i++) {
do {
done = true;
g_ActiveFemaleHeads[i] = headsavailablelist[random() % headsavailablelen];
g_ActiveFemaleHeads[i] = headsavailablelist[rngRandom() % headsavailablelen];

if (headsavailablelen > g_NumActiveHeadsPerGender) {
for (j = 0; j < i; j++) {
Expand Down
28 changes: 14 additions & 14 deletions src/game/bondgun.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ void bgunStartAnimation(struct guncmd *cmd, s32 handnum, struct hand *hand)
if (cmd->type != GUNCMD_PLAYANIMATION) {
struct guncmd *loopcmd = cmd;
s32 done = false;
u32 rand = random() % 100;
u32 rand = rngRandom() % 100;

while (loopcmd->type != GUNCMD_END) {
if (bgun0f098884(loopcmd, &hand->gset) && !done) {
Expand Down Expand Up @@ -7220,7 +7220,7 @@ void bgunUpdateMagnum(struct hand *hand, s32 handnum, struct modeldef *modeldef,

if (modeldef != NULL) {
for (i = 0; i < hand->unk0cc8_04; i++) {
struct modelnode *node = modelGetPart(modeldef, 0x0a + random() % 6);
struct modelnode *node = modelGetPart(modeldef, 0x0a + rngRandom() % 6);

if (node) {
s32 index = modelFindNodeMtxIndex(node, 0);
Expand Down Expand Up @@ -11264,8 +11264,8 @@ struct sndstate **bgunAllocateAudioHandle(void)
void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum)
{
#if VERSION >= VERSION_NTSC_1_0
u32 rand1 = random();
u32 rand2 = random();
u32 rand1 = rngRandom();
u32 rand2 = rngRandom();
struct sndstate **handle;

if (g_Vars.lvupdate240 <= 0) {
Expand Down Expand Up @@ -11344,8 +11344,8 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum)
if (texturenum == 10000) {
soundnum = SFX_SHIELD_DAMAGE;
} else if (gset->weaponnum == WEAPON_LASER) {
if (gset->weaponfunc == FUNC_PRIMARY || ((gset->unk063a % 4) == 0 && (random() % 2))) {
if ((random() % 2) == 0) {
if (gset->weaponfunc == FUNC_PRIMARY || ((gset->unk063a % 4) == 0 && (rngRandom() % 2))) {
if ((rngRandom() % 2) == 0) {
soundnum = SFX_CLOAK_ON;
} else {
soundnum = SFX_CLOAK_OFF;
Expand Down Expand Up @@ -11409,8 +11409,8 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum)
}
}
#else
u32 rand1 = random();
u32 rand2 = random();
u32 rand1 = rngRandom();
u32 rand2 = rngRandom();
struct sndstate **handle;

if (g_Vars.lvupdate240 <= 0) {
Expand Down Expand Up @@ -11483,7 +11483,7 @@ void bgunPlayPropHitSound(struct gset *gset, struct prop *prop, s32 texturenum)
soundnum = SFX_SHIELD_DAMAGE;
} else if (gset->weaponnum == WEAPON_LASER) {
if (gset->weaponfunc == FUNC_PRIMARY || (gset->unk063a % 8) == 0) {
if ((random() % 2) == 0) {
if ((rngRandom() % 2) == 0) {
soundnum = SFX_CLOAK_ON;
} else {
soundnum = SFX_CLOAK_OFF;
Expand Down Expand Up @@ -11561,8 +11561,8 @@ void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum,
{
#if VERSION >= VERSION_NTSC_1_0
struct sndstate **handle;
u32 rand1 = random();
u32 rand2 = random();
u32 rand1 = rngRandom();
u32 rand2 = rngRandom();
bool playdefault;
s16 soundnum;
bool overridden;
Expand All @@ -11585,7 +11585,7 @@ void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum,
if (gset->weaponnum == WEAPON_LASER) {
playdefault = false;

if (gset->weaponfunc == FUNC_PRIMARY || ((gset->unk063a % 4) == 0 && (random() % 2))) {
if (gset->weaponfunc == FUNC_PRIMARY || ((gset->unk063a % 4) == 0 && (rngRandom() % 2))) {
// Laser sounds
s16 sounds[] = {SFX_CLOAK_ON, SFX_CLOAK_OFF};
soundnum = sounds[rand1 % ARRAYCOUNT(sounds)];
Expand Down Expand Up @@ -11660,8 +11660,8 @@ void bgunPlayBgHitSound(struct gset *gset, struct coord *hitpos, s32 texturenum,
}
#else
struct sndstate **handle;
u32 rand1 = random();
u32 rand2 = random();
u32 rand1 = rngRandom();
u32 rand2 = rngRandom();
s16 soundnum;
bool overridden;

Expand Down
2 changes: 1 addition & 1 deletion src/game/bondmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,7 @@ void bmoveUpdateHead(f32 arg0, f32 arg1, f32 arg2, Mtxf *arg3, f32 arg4)
}
} else {
if (g_Vars.currentplayer->startnewbonddie) {
bheadStartDeathAnimation(g_DeathAnimations[random() % g_NumDeathAnimations], random() % 2, 0, 1);
bheadStartDeathAnimation(g_DeathAnimations[rngRandom() % g_NumDeathAnimations], rngRandom() % 2, 0, 1);
g_Vars.currentplayer->startnewbonddie = false;
}

Expand Down
22 changes: 11 additions & 11 deletions src/game/bondview.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ Gfx *bviewDrawStatic(Gfx *gdl, u32 arg1, s32 arg2)
s32 viewheight = viGetViewHeight();
s32 viewwidth = viGetViewWidth();
s32 viewleft = viGetViewLeft();
u16 *fb2 = (u16 *) PHYS_TO_K0(random() & 0xfff00);
u16 *fb2 = (u16 *) PHYS_TO_K0(rngRandom() & 0xfff00);
s32 y;

gDPPipeSync(gdl++);
Expand All @@ -344,7 +344,7 @@ Gfx *bviewDrawStatic(Gfx *gdl, u32 arg1, s32 arg2)

#ifdef PLATFORM_N64
for (y = viewtop; y < viewtop + viewheight; y++) {
gdl = bviewCopyPixels(gdl, fb2, random() % 240, 5, y, 1.0f, viewleft, viewwidth);
gdl = bviewCopyPixels(gdl, fb2, rngRandom() % 240, 5, y, 1.0f, viewleft, viewwidth);
}
#else
gDPSetCombineLERP(gdl++,
Expand Down Expand Up @@ -468,8 +468,8 @@ Gfx *bviewDrawFilmInterlace(Gfx *gdl, u32 colour, u32 alpha)
}
}

if (random() % 20 == 1) {
tmpy = random() % 200;
if (rngRandom() % 20 == 1) {
tmpy = rngRandom() % 200;
}

gdl = bviewCopyPixels(gdl, fb, tmpy, 5, y, 1, viewleft, viewwidth);
Expand All @@ -490,8 +490,8 @@ Gfx *bviewDrawFilmInterlace(Gfx *gdl, u32 colour, u32 alpha)
}
}

if (random() % 20 == 1) {
tmpy += random() % 200;
if (rngRandom() % 20 == 1) {
tmpy += rngRandom() % 200;
}

gDPFillRectangle(gdl++, viewleft, tmpy, viewleft + viewwidth, tmpy + 1);
Expand Down Expand Up @@ -762,9 +762,9 @@ Gfx *bviewDrawFisheye(Gfx *gdl, u32 colour, u32 alpha, s32 shuttertime60, s8 sta

for (i = viewtop; i < viewtop + viewheight; i++) {
if (hit == EYESPYHIT_DAMAGE) {
alpha2 = (random() % 120) + 120;
alpha2 = (rngRandom() % 120) + 120;
colour = 0xff333300 | (alpha2 & 0xff);
f22 = ((random() % 32) + (f32) FBALLOC_HEIGHT) * (1.0f / 256.0f);
f22 = ((rngRandom() % 32) + (f32) FBALLOC_HEIGHT) * (1.0f / 256.0f);

gDPSetEnvColorViaWord(gdl++, colour);
} else {
Expand Down Expand Up @@ -2163,7 +2163,7 @@ Gfx *bviewDrawNvLens(Gfx *gdl)
u8 green;

if (((var8007f878 & 1) != (y & 1)) != 0) {
u8 tmp = random() % 12;
u8 tmp = rngRandom() % 12;
green = 0xff - tmp;
} else {
green = 0x94;
Expand All @@ -2181,7 +2181,7 @@ Gfx *bviewDrawNvLens(Gfx *gdl)
u8 green;

if (((var8007f878 & 1) != (y & 1)) != 0) {
u8 tmp = random() % 12;
u8 tmp = rngRandom() % 12;
green = 0xff - tmp;
} else {
green = 0x94;
Expand Down Expand Up @@ -2363,7 +2363,7 @@ Gfx *bviewDrawIrLens(Gfx *gdl)
}
#endif

red += random() % 8;
red += rngRandom() % 8;

if (red > 255) {
red = 255;
Expand Down
2 changes: 1 addition & 1 deletion src/game/bondwalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ void bwalkUpdateVertical(void)
SFX_JO_LANDING_05B7
};

psCreate(NULL, g_Vars.currentplayer->prop, sounds[random() % 3],
psCreate(NULL, g_Vars.currentplayer->prop, sounds[rngRandom() % 3],
-1, -1, PSFLAG_0400 | PSFLAG_IGNOREROOMS, 0, PSTYPE_NONE, 0, -1, NULL, -1, -1, -1, -1);
}
}
Expand Down
Loading

0 comments on commit 7721297

Please sign in to comment.