Skip to content

Commit

Permalink
Merge branch 'dev' into ui_edits
Browse files Browse the repository at this point in the history
  • Loading branch information
Killklli authored Apr 12, 2022
2 parents d117f81 + f44c76e commit 27fd21b
Show file tree
Hide file tree
Showing 24 changed files with 324 additions and 162 deletions.
1 change: 1 addition & 0 deletions base-hack/.avoid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cross_kong
7 changes: 7 additions & 0 deletions base-hack/Build/adjust_exits.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
"y": 115,
"z": 2026,
},
{
# Mill Rear PPunch Door
"exit_index": 5,
"x": 4550,
"y": 162,
"z": 3646,
},
],
},
{
Expand Down
11 changes: 11 additions & 0 deletions base-hack/Build/convertSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def modify(file_name, map_index):
for x in range(model2_count):
byte_stream = byte_read[read_location : read_location + 0x30]
_type = int.from_bytes(byte_read[read_location + 0x28 : read_location + 0x2A], "big")
_id = int.from_bytes(byte_read[read_location + 0x2A : read_location + 0x2C], "big")
if _type == 0x2AC and map_index != 0x2A:
base_stream = byte_stream
_x = int.from_bytes(byte_read[read_location + 0 : read_location + 4], "big")
Expand Down Expand Up @@ -95,6 +96,16 @@ def modify(file_name, map_index):
}
)
model2_index += 1
if map_index == 7 and _id == 0x1A:
# Type 0x94
_type = 0xCE
repl_byte = b""
for x in range(0x29):
repl_byte += byte_stream[x].to_bytes(1, "big")
repl_byte += _type.to_bytes(1, "big")
for x in range(0x30 - 0x2A):
repl_byte += byte_stream[x + 0x2A].to_bytes(1, "big")
byte_stream = repl_byte
data = {
"stream": byte_stream,
"type": _type,
Expand Down
9 changes: 0 additions & 9 deletions base-hack/asm/boot.asm
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ TagPermaLossSetHook:
TagPermaLossDisplayHook:
J permaLossTagDisplayCheck
NOP
DisableBossKongHook:
J disableBossKongCheckCode
NOP
TagPreventHook:
J tagPreventCode
NOP
Expand Down Expand Up @@ -366,12 +363,6 @@ loadExtraHooks:
SW r0, 0x40C8 (t4) // Store NOP

loadExtraHooks_1:
//LUI t3, hi(DisableBossKongHook)
//LW t3, lo(DisableBossKongHook) (t3)
//LUI t4, 0x8065
//SW t3, 0xEBF4 (t4) // Store Hook
//SW r0, 0xEBF8 (t4) // Store NOP

LUI t3, hi(TagPreventHook)
LW t3, lo(TagPreventHook) (t3)
LUI t4, 0x8069
Expand Down
14 changes: 3 additions & 11 deletions base-hack/asm/hookcode.asm
Original file line number Diff line number Diff line change
Expand Up @@ -460,17 +460,6 @@ START_HOOK:
J 0x806840e0
NOP

disableBossKongCheckCode:
LUI t7, hi(disableBossKongCheck)
LBU t7, lo(disableBossKongCheck) (t7)
BNEZ t7, disableBossKongCheckCode_disabled
ADDIU v0, r0, 1
SLTIU v0, v0, 1

disableBossKongCheckCode_disabled:
J 0x8064EBFC
ANDI t7, v0, 0xFF

tagPreventCode:
LUI a1, hi(preventTagSpawn)
LBU a1, lo(preventTagSpawn) (a1)
Expand All @@ -484,6 +473,9 @@ START_HOOK:
ADDIU t8, r0, 136
BEQ a1, t8, tagPreventCode_Prevent
NOP
ADDIU t8, r0, 137
BEQ a1, t8, tagPreventCode_Prevent
NOP

tagPreventCode_Vanilla:
LH a1, 0x0 (s1)
Expand Down
2 changes: 1 addition & 1 deletion base-hack/asm/symbols.asm
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@

.definelabel cancelPausedCutscene, 0x8061CB08
.definelabel pauseCutscene, 0x8061CAD8
.definelabel hasTurnedInEnoughCBs, 0x805FF0C8

.definelabel setArcadeTextXY, 0x80024508
.definelabel spawnArcadeText, 0x8002451C
Expand Down Expand Up @@ -271,7 +272,6 @@
.definelabel WarpToIslesEnabled, 0x807FFFEE // u8
.definelabel SkipDance, 0x807FFFED // u8
.definelabel permaLossMode, 0x807FFFEC // u8
.definelabel disableBossKongCheck, 0x807FFFEB // u8
.definelabel preventTagSpawn, 0x807FFFEA // u8
.definelabel bonusAutocomplete, 0x807FFFE9 // u8
.definelabel Rando, 0x807FF800 // 0x200
Expand Down
4 changes: 3 additions & 1 deletion base-hack/include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ typedef struct playerData {
/* 0x0E8 */ short skew_angle;
/* 0x0EA */ char unk_EA[0xEE - 0xEA];
/* 0x0EE */ short next_facing_angle;
/* 0x0F0 */ char unk_F0[0x110 - 0xF0];
/* 0x0F0 */ char unk_F0[0x10C - 0xF0];
/* 0x10C */ short standing_on_index;
/* 0x10E */ char unk_10E[0x110-0x10E];
/* 0x110 */ char touching_object;
/* 0x111 */ char unk_111[0x128 - 0x111];
/* 0x128 */ short strong_kong_value;
Expand Down
2 changes: 1 addition & 1 deletion base-hack/include/dk64.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ extern int* textDraw(int* dl, int style, int x, int y, char* str);
extern void cancelPausedCutscene(void);
extern void pauseCutscene(void);

extern int hasTurnedInEnoughCBs(void);
extern int getWorld(int map, int unk2);
extern void displayImageOnObject(int obj_id, int position, int image_index, int unk4);
extern void drawNumberObject(int model, int unk2, int image_index, int unk4);
Expand Down Expand Up @@ -297,6 +298,5 @@ extern settingsData StoredSettings;
extern char WarpToIslesEnabled;
extern char SkipDance;
extern char permaLossMode;
extern char disableBossKongCheck;
extern char preventTagSpawn;
extern char bonusAutocomplete;
1 change: 1 addition & 0 deletions base-hack/include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ extern void forceBossKong(void);

extern void writeJetpacMedalReq(void);
extern void resetMapContainer(void);
extern void correctDKPortal(void);

extern int* drawTri(int* dl, short x1, short y1, short x2, short y2, short x3, short y3, int red, int green, int blue, int alpha);
extern int* drawImage(int* dl, int text_index, codecs codec_index, int img_width, int img_height, int x, int y, float xScale, float yScale, int opacity);
Expand Down
2 changes: 2 additions & 0 deletions base-hack/src/fixes/parent.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ void callParentMapFilter(void) {
if (!banned) {
resetMapContainer();
}
} else if (ObjectModel2Timer < 2) {
correctDKPortal();
}
}
}
1 change: 1 addition & 0 deletions base-hack/src/fixes/quality_fixes.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ void qualityOfLife_fixes(void) {
}
setPermFlag(0x309); // Cranky FTT
setPermFlag(0x17F); // Training Barrels Spawned
setPermFlag(300); // Giant Kosha Dead
fixkey8();
}
}
Expand Down
55 changes: 49 additions & 6 deletions base-hack/src/fixes/tag_anywhere.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ static const unsigned char banned_maps[] = {
35, // K. Rool Barrel: DK's Target Game
37, // Jungle Japes: Barrel Blast // Note: The barrels don't work as other kongs so not much point enabling it on this map
41, // Angry Aztec: Barrel Blast
42, // Troff 'n' Scoff
50, // K. Rool Barrel: Tiny's Mushroom Game
54, // Gloomy Galleon: Barrel Blast
55, // Fungi Forest: Minecart
Expand Down Expand Up @@ -159,15 +158,38 @@ static const unsigned char bad_movement_states[] = {
};

static const short kong_flags[] = {0x181,0x6,0x46,0x42,0x75};
static unsigned char tag_countdown = 0;

void tagAnywhere(int prev_crystals) {
if (Rando.tag_anywhere) {
if (Player) {
char hud_items[] = {0,1,5,8,10,12,13,14};
if (HUD) {
for (int i = 0; i < sizeof(hud_items); i++) {
if (HUD->item[(int)hud_items[i]].hud_state) {
return;
if (tag_countdown > 0) {
tag_countdown -= 1;
}
if (CurrentMap != 0x2A) {
char hud_items[] = {0,1,5,8,10,12,13,14};
if (HUD) {
for (int i = 0; i < sizeof(hud_items); i++) {
if (HUD->item[(int)hud_items[i]].hud_state) {
return;
}
}
}
} else {
if (tag_countdown == 2) {
HUD->item[0].hud_state = 1;
if (Player->control_state == 108) {
int world = getWorld(CurrentMap,0);
if (MovesBase[(int)Character].cb_count[world] > 0) {
HUD->item[0].hud_state = 0;
}
}
} else if (tag_countdown == 1) {
if (Player->control_state == 108) {
int world = getWorld(CurrentMap,0);
if (MovesBase[(int)Character].cb_count[world] > 0) {
HUD->item[0].hud_state = 1;
}
}
}
}
Expand All @@ -183,8 +205,22 @@ void tagAnywhere(int prev_crystals) {
if (CutsceneActive) {
return;
}
if (CurrentMap == 0x2A) {
if (MapState & 0x10) {
return;
}
if (hasTurnedInEnoughCBs()) {
if (Player->zPos < 560.0f) {
// Too close to boss door
return;
}
}
}
if (TBVoidByte & 3) {
return;
}
if (tag_countdown != 0) {
return;
}
if (Character < TAG_ANYWHERE_KONG_LIMIT) {
int change = 0;
Expand Down Expand Up @@ -243,6 +279,13 @@ void tagAnywhere(int prev_crystals) {
Player->hand_state = 3;
}
};
if (CurrentMap == 0x2A) {
if (!hasTurnedInEnoughCBs()) {
tag_countdown = 3;
HUD->item[0].hud_state_timer = 0x100;
HUD->item[0].hud_state = 0;
}
}
tagKong(next_character + 2);
clearTagSlide(Player);
Player->new_kong = next_character + 2;
Expand Down
4 changes: 3 additions & 1 deletion base-hack/src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ void initHack(void) {
DamageMultiplier = Rando.damage_multiplier;
WarpToIslesEnabled = Rando.warp_to_isles_enabled;
permaLossMode = Rando.perma_lose_kongs;
disableBossKongCheck = Rando.disable_boss_kong_check;
preventTagSpawn = Rando.prevent_tag_spawn;
bonusAutocomplete = Rando.resolve_bonus;
changeCharSpawnerFlag(0x14, 2, 93); // Tie llama spawn to lanky help me cutscene flag
Expand Down Expand Up @@ -94,6 +93,9 @@ void initHack(void) {
priceTransplant();
}
}
if (Rando.disable_boss_kong_check) {
*(int*)(0x8064EC00) = 0x24020001;
}
fixMusicRando();
// Disable Sniper Scope Overlay
int asm_code = 0x00801025; // OR $v0, $a0, $r0
Expand Down
30 changes: 30 additions & 0 deletions base-hack/src/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,34 @@ void resetMapContainer(void) {
for (int i = 0; i < 0x12; i++) {
SubmapData[i].slot_populated = 0;
}
}

static const unsigned char dk_portal_maps[] = {0x07,0x26,0x1A,0x1E,0x30,0x48,0x57,0xA9,0xAD,0xAF,0xAE,0xB2,0xC2,0xC1};
void correctDKPortal(void) {
int is_portal_map = 0;
for (int i = 0; i < sizeof(dk_portal_maps); i++) {
if (dk_portal_maps[i] == CurrentMap) {
is_portal_map = 1;
}
}
if (is_portal_map) {
int portal_exit = isLobby(CurrentMap);
int exit = DestExit;
int portal_state = 2;
if (portal_exit == exit) {
portal_state = 0;
}
int _count = ObjectModel2Count;
int* m2location = ObjectModel2Pointer;
for (int i = 0; i < _count; i++) {
ModelTwoData* _object = getObjectArrayAddr(m2location,0x90,i);
if (_object->object_type == 0x2AD) {
behaviour_data* behav = _object->behaviour_pointer;
if (behav) {
behav->current_state = portal_state;
//behav->next_state = portal_state;
}
}
}
}
}
62 changes: 62 additions & 0 deletions base-hack/src/randomizers/cross_kong.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "../../include/common.h"
/*
Kong is going to be stored in the 0x4 slot of the purchase struct
Price is changed to a byte, changed to 0x5 slot
struct {
short type;
short value
unsigned char kong;
unsigned char price;
}
*/

void crossKongInit(void) {
// Change target kong (Progressive)
*(int*)(0x80025EA0) = 0x90850004; // LBU a1, 0x4 (a0)
// Change target kong (Bitfield)
*(int*)(0x80025E80) = 0x90850004; // LBU a1, 0x4 (a0)
// Change price check
*(int*)(0x80026200) = 0x90CF0005; // LBU t7, 0x5 (a2)
}

/*
HOOKCODE
Placement_80026140:
// Stores price & kong correctly
LH v0, 0x4 (a1)
SH v0, 0x4 (s2)
ANDI t8, v0, 0xFF
J 0x8002614C
SH t8, 0x0 (t2)
Placement_80025FC0:
// Replaces param2 with the start of the character collectable base
OR s2, a0, r0
LUI a1, hi(MovesBase)
ADDIU a1, a1, lo(MovesBase)
J 0x80025FC8
OR s3, a1, r0
Placement_800260F0:
// Sets the move base to the correct kong (Bitfield)
LH t4, 0x2 (a1)
ADDU t8, s3, a0
LBU t9, 0x4 (a1)
ADDIU t6, r0, 0x5E
MULT t9, t6
MFLO t9
J 0x800260F8
ADDU t8, t8, t9
Placement_8002611C:
// Sets the move base to the correct kong (Progressive)
LBU t6, 0x4 (a1)
ADDIU t5, r0, 0x5E
MULT t6, t5
MFLO t6
ADDU t4, t4, t6
LBU t6, 0x0 (t4)
J 0x80026124
LH t5, 0x2 (a1)
*/
5 changes: 5 additions & 0 deletions base-hack/src/randomizers/misc_requirements.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

void writeJetpacMedalReq(void) {
if (Rando.jetpac_medal_requirement) {
if (Rando.jetpac_medal_requirement < 4) {
Rando.jetpac_medal_requirement = 4;
} else if (Rando.jetpac_medal_requirement > 15) {
Rando.jetpac_medal_requirement = 15;
}
*(unsigned char*)(0x80026513) = Rando.jetpac_medal_requirement; // Actual requirement
*(unsigned char*)(0x8002644B) = Rando.jetpac_medal_requirement; // Text variable
}
Expand Down
3 changes: 3 additions & 0 deletions randomizer/ApplyRandomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ def patching_response(responded_data):
ROM().seek(sav + 0x13F)
ROM().write(1)

ROM().seek(sav + 0x140)
ROM().write(spoiler.jetpac_medals_required)

# Currently crashing most of the time
# randomize_dktv(spoiler)
randomize_music(spoiler)
Expand Down
2 changes: 1 addition & 1 deletion randomizer/CollectibleLogicFiles/AngryAztec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

Collectible(Collectibles.coin, Kongs.donkey, lambda l: True, None, 2), # Llama cage
Collectible(Collectibles.coin, Kongs.donkey, lambda l: l.coconut and l.strongKong, None, 3), # DK BP room
Collectible(Collectibles.coin, Kongs.any, lambda l: True, None, 1), # Oasis
Collectible(Collectibles.coin, Kongs.any, lambda l: l.shockwave, None, 1), # Oasis
Collectible(Collectibles.coin, Kongs.diddy, lambda l: True, None, 5), # W2
Collectible(Collectibles.coin, Kongs.tiny, lambda l: True, None, 4), # Oasis
Collectible(Collectibles.coin, Kongs.chunky, lambda l: True, None, 4), # Outside Tiny Temple
Expand Down
Loading

0 comments on commit 27fd21b

Please sign in to comment.