1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-14 21:40:03 +00:00

Decompile N64 anti-piracy checks in overlays (#2042)

* Decompile N64 anti-piracy checks in overlays

* Fix BSS splits (I think)

* Use physical address and comment on meaning

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>

---------

Co-authored-by: Tharo <17233964+Thar0@users.noreply.github.com>
This commit is contained in:
cadmic 2024-08-15 20:44:05 -07:00 committed by GitHub
parent b734a159e3
commit b82f54bb95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 50 additions and 8 deletions

8
include/cic6105.h Normal file
View file

@ -0,0 +1,8 @@
#ifndef CIC6105_H
#define CIC6105_H
#include "ultra64.h"
extern u32 B_80008EE0;
#endif

View file

@ -9,6 +9,7 @@ extern Mtx D_01000000;
extern u32 osTvType; extern u32 osTvType;
extern u32 osRomBase; extern u32 osRomBase;
extern u32 osResetType; extern u32 osResetType;
extern u32 osCicId;
extern u32 osMemSize; extern u32 osMemSize;
extern u8 osAppNMIBuffer[0x40]; extern u8 osAppNMIBuffer[0x40];

3
spec
View file

@ -20,6 +20,9 @@ beginseg
include "$(BUILD_DIR)/src/boot/z_std_dma.o" include "$(BUILD_DIR)/src/boot/z_std_dma.o"
include "$(BUILD_DIR)/src/boot/yaz0.o" include "$(BUILD_DIR)/src/boot/yaz0.o"
include "$(BUILD_DIR)/src/boot/z_locale.o" include "$(BUILD_DIR)/src/boot/z_locale.o"
#if PLATFORM_N64
include "$(BUILD_DIR)/src/boot/cic6105.o"
#endif
#if OOT_DEBUG #if OOT_DEBUG
include "$(BUILD_DIR)/src/boot/assert.o" include "$(BUILD_DIR)/src/boot/assert.o"
#endif #endif

View file

@ -1 +1,3 @@
#include "cic6105.h"
u32 B_80008EE0;

View file

@ -71,6 +71,16 @@ s32 func_808C0CC8(BgZg* this) {
} }
void func_808C0CD4(BgZg* this, PlayState* play) { void func_808C0CD4(BgZg* this, PlayState* play) {
#if PLATFORM_N64
// Anti-piracy check, bars will not open if the check fails.
// The address 0x000002E8 is near the start of RDRAM, and is written when IPL3 copies itself to
// RDRAM after RDRAM has been initialized. Specifically, this is an instruction from some
// embedded RSP code at offset 0x7F8 into IPL3 (0xC86E2000 disassembles to `lqv $v14[0], ($3)`).
if (IO_READ(0x000002E8) != 0xC86E2000) {
return;
}
#endif
if (func_808C0C98(this, play) != 0) { if (func_808C0C98(this, play) != 0) {
this->action = 1; this->action = 1;
func_808C0C50(this); func_808C0C50(this);

View file

@ -447,17 +447,25 @@ void func_80B4F230(EnZl2* this, s16 arg1, s32 arg2) {
s32 func_80B4F45C(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, Gfx** gfx) { s32 func_80B4F45C(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx, Gfx** gfx) {
s32 pad; s32 pad;
EnZl2* this = (EnZl2*)thisx; EnZl2* this = (EnZl2*)thisx;
Mtx* sp74;
MtxF sp34;
Vec3s sp2C;
s16 pad2;
s16* unk_1DC = this->unk_1DC;
if (limbIndex == 14) { if (limbIndex == 14) {
sp74 = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx) * 7); Mtx* sp74 = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx) * 7);
MtxF sp34;
Vec3s sp2C;
s16 pad2;
s16* unk_1DC = this->unk_1DC;
gSPSegment((*gfx)++, 0x0C, sp74); gSPSegment((*gfx)++, 0x0C, sp74);
Matrix_Push(); Matrix_Push();
#if PLATFORM_N64
// Anti-piracy check, Zelda's hair is misshapen if the check fails
if (osCicId != 6105) {
Matrix_Scale(2.0f, 0.5f, 2.0f, MTXMODE_APPLY);
}
#endif
Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_APPLY); Matrix_Translate(pos->x, pos->y, pos->z, MTXMODE_APPLY);
Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY); Matrix_RotateZYX(rot->x, rot->y, rot->z, MTXMODE_APPLY);
Matrix_Push(); Matrix_Push();

View file

@ -10,8 +10,11 @@
#include "assets/objects/object_fish/object_fish.h" #include "assets/objects/object_fish/object_fish.h"
#include "ichain.h" #include "ichain.h"
#include "terminal.h" #include "terminal.h"
#if PLATFORM_N64
#include "cic6105.h"
#endif
#pragma increment_block_number "gc-eu:205 gc-eu-mq:205 gc-jp:207 gc-jp-ce:207 gc-jp-mq:207 gc-us:207 gc-us-mq:207" #pragma increment_block_number "gc-eu:204 gc-eu-mq:204 gc-jp:206 gc-jp-ce:206 gc-jp-mq:206 gc-us:206 gc-us-mq:206"
#define FLAGS ACTOR_FLAG_4 #define FLAGS ACTOR_FLAG_4
@ -852,7 +855,14 @@ void Fishing_Init(Actor* thisx, PlayState* play2) {
if (thisx->params < EN_FISH_PARAM) { if (thisx->params < EN_FISH_PARAM) {
FishingGroupFish* fish; FishingGroupFish* fish;
#if PLATFORM_N64
// Anti-piracy check, if the check fails the line can't be reeled in if
// a fish is caught and the fish will always let go after 50 frames.
sReelLock = !(B_80008EE0 == 0xAD090010);
#else
sReelLock = 0; sReelLock = 0;
#endif
sFishingMain = this; sFishingMain = this;
Collider_InitJntSph(play, &sFishingMain->collider); Collider_InitJntSph(play, &sFishingMain->collider);
Collider_SetJntSph(play, &sFishingMain->collider, thisx, &sJntSphInit, sFishingMain->colliderElements); Collider_SetJntSph(play, &sFishingMain->collider, thisx, &sJntSphInit, sFishingMain->colliderElements);

View file

@ -126,7 +126,7 @@ offset,vram,.bss
72F0,80007750,src/boot/idle 72F0,80007750,src/boot/idle
7F00,80008360,src/boot/z_std_dma 7F00,80008360,src/boot/z_std_dma
8670,80008AD0,src/boot/yaz0 8670,80008AD0,src/boot/yaz0
8A80,80008EE0,src/boot/z_locale 8A80,80008EE0,src/boot/cic6105
8AA0,80008F00,src/libultra/io/driverominit 8AA0,80008F00,src/libultra/io/driverominit
8B20,80008F80,src/libultra/io/piacs 8B20,80008F80,src/libultra/io/piacs
8B40,80008FA0,src/libultra/os/initialize 8B40,80008FA0,src/libultra/os/initialize

1 offset vram .text
126 8A80 80008EE0 src/boot/z_locale src/boot/cic6105
127 8AA0 80008F00 src/libultra/io/driverominit
128 8B20 80008F80 src/libultra/io/piacs
129 8B40 80008FA0 src/libultra/os/initialize
130 8B50 80008FB0 src/libultra/io/pimgr
131 9FC0 8000A420 src/libultra/os/seteventmesg
132 A040 8000A4A0 src/libultra/os/timerintr