[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/vr/ - Retro Games


View post   

File: 53 KB, 636x441, 40086-Perfect_Dark_(USA)-8.jpg [View same] [iqdb] [saucenao] [google]
6274121 No.6274121 [Reply] [Original]

The Perfect Dark decompilation project has revealed that Perfect Dark has anti-piracy checks in its code. I've never heard of this before. Does anyone know exactly what these do?

https://github.com/n64decomp/perfect_dark/search?q=PIRACYCHECKS&unscoped_q=PIRACYCHECKS

For instance...

void alertNearbyChrsToNoise(f32 *radius, struct coord *noisepos)
{
u32 stack[2];
s32 *end = (s32 *)&func0f084e58;
s32 i;

for (i = 0; i < g_NumChrsA; i++) {
if (g_ChrsA[i].animdata
&& chrGetTargetProp(&g_ChrsA[i]) == g_Vars.currentplayer->prop
&& g_ChrsA[i].prop
&& g_ChrsA[i].prop->type == PROPTYPE_CHR
&& (g_ChrsA[i].prop->flags & 4)) {
f32 distance = chrGetDistanceToCoord(&g_ChrsA[i], noisepos);

if (distance == 0) {
distance = 2;
} else {
distance = (10.0f * *radius * g_ChrsA[i].hearingscale) / distance;
}

if (distance > 1) {
chrRecordLastHearTargetTime(&g_ChrsA[i]);
}
}
}

#if PIRACYCHECKS
{
u32 checksum = 0;
s32 *ptr = (s32 *)&func0f084cf0;

while (ptr < end) {
checksum ^= *ptr;
checksum <<= 1;
ptr++;
}

if (checksum != 0xa17a4ca0) {
struct explosiontype *type = &g_ExplosionTypes[0];
s32 i;

for (i = 0; i != NUM_EXPLOSIONTYPES - 1; i++) {
type->rangeh = 80;
type->rangev = 60;
type->changerateh = 15;
type->changeratev = 5;
type->innersize = 1500;
type->blastradius = 200;
type->damageradius = 3600;
type++;
}
}
}
#endif
}

>> No.6274126

man i just realized I suck at coding

>> No.6274137

There's also some eeprom fuckery going on. It kinda looks like it calls this on initial setup. https://github.com/n64decomp/perfect_dark/blob/bb371eaa68a2c636419d848782ce5e150ddcee1b/src/game/game_167ae0.c#L276

#if PIRACYCHECKS
{
u32 checksum = 0;
s32 *i = (s32 *)&getEffectiveSlowMotion;
s32 *end = (s32 *)&func0f16b96c;

while (i < end) {
checksum += *i;
i++;
}

if (checksum != 0xfa4223f2) {
u32 address = 0;
u32 buffer[4];
buffer[0] = 0xbb8b80bd;
buffer[1] = 0xffffffff;
buffer[2] = 0x020f0100;
buffer[3] = 0xcd31100b;
osEepromLongWrite(&var80099e78, address, (u8 *)&buffer, 0x10);
var800a316c[2] = 0;
}
}
#endif

>> No.6274142

It seems like Perfect Dark didn't like Flash RAM based memory paks. https://www.vintex64.com/n64-cpak-faq.html

I kinda wonder if the infamous "buffer overflow" that wiped EEPROM in the original US version of Perfect Dark in one of the challenges was actually anti-piracy playing up.

>> No.6274478

I vaguely remember applying a ppf patch to the ROM to make it run on my V64.

>> No.6274526

>>6274121
So they nerf explosions if you pirate? I don't understand

>> No.6276163

>>6274121
> if (g_ChrsA[i].animdata
> && chrGetTargetProp(&g_ChrsA[i]) == g_Vars.currentplayer->prop
> && g_ChrsA[i].prop
> && g_ChrsA[i].prop->type == PROPTYPE_CHR
> && (g_ChrsA[i].prop->flags & 4))
Haha long boi

>> No.6277402

>>6274526
It looks like it makes them all hugely damaging and oversized if the checksum fails.

>> No.6280310

Reminder that once Perfect Dark is fully decompiled, we'll likely get a native PC port. Someone will have to write a new renderer and probably audio system, but it'll be pretty fucking kino. Not to mention the source code will make fixing bugs and improving balancing way easier.

There are some odd bugs in the PD source code. For instance, it is supposed to check whether a squad of enemies has been killed. Except it only checks whether the last member in the group has been killed.

When you destroy the wine bottles in Carrington's cellar, it has a giant-ass switch statement. What can happen is that if you don't destroy the last bottle in the list, but destroy every bottle before that one, it is performing a huge list of checks every 5 frames, hindering performance.

>> No.6280330

>>6280310
If that does happen, I'd love to see someone port over the HD assets.
I'd also like to see some goddamn lip sync.

>> No.6280393

>>6280310
There are a number of obscure Perfect Dark technical issues that could potentially be explained once the source is decompiled. For example, the Janus Bug causes enemy NPCs to become friendly. Nobody knows why.
https://www.youtube.com/watch?v=IXPtObezAQU

>> No.6280818
File: 644 KB, 1280x720, ss-perfect-dark-xbla-007.jpg [View same] [iqdb] [saucenao] [google]
6280818

>>6280330
>I'd love to see someone port over the HD assets.
yeah those weren't faithful at all

>> No.6282586

>>6280818

the HD assets looked great you nostalgiablind autist

>> No.6282605

>>6280393
i'm curious if there's code to kill a player in combat sim to save the game from crashing
i can't remember the community term for it but there were unexplained deaths blamed on a ghost

>> No.6282703

>>6282605
The 1.0 NTSC version of Perfect Dark had a very nasty coding error that triggers a crash bug in the Challenges, often preceded by the textures going berserk. But lead programmer Mark Edmonds noted that the memory overwritten is random, and could feasibly cause unpredictable effects. The rumour of a "ghost", typically carrying a crossbow, and/or being invisible have been around for years, and are probably grounded in something. Perfect Dark is an incredibly complex game by late 90s standards, and subtle errors can accumulate and cascade.