Skip to content

Commit

Permalink
Merge branch 'Dev' into dev-fenhl
Browse files Browse the repository at this point in the history
# Conflicts:
#	ASM/build/asm_symbols.txt
#	ASM/build/bundle.o
#	ASM/build/c_symbols.txt
#	ASM/c/actor.h
#	ASM/c/en_item00.c
#	ASM/c/en_item00.h
#	ASM/c/en_wonderitem.c
#	ASM/c/get_items.c
#	ASM/c/get_items.h
#	ASM/c/item_draw_functions.c
#	ASM/c/item_draw_table.c
#	ASM/src/build.asm
#	ASM/src/drop_overrides/obj_mure3.asm
#	ASM/src/hacks/ovl_bg_spot18_basket.asm
#	CI.py
#	LocationList.py
#	Patches.py
#	Rom.py
#	SaveContext.py
#	data/generated/rom_patch.txt
#	data/generated/symbols.json
  • Loading branch information
fenhl committed Jun 19, 2024
2 parents 8426d56 + b192e39 commit 571e4bf
Show file tree
Hide file tree
Showing 27 changed files with 355 additions and 392 deletions.
19 changes: 9 additions & 10 deletions ASM/c/actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void Actor_StoreChestType(z64_actor_t* actor, z64_game_t* game) {
pChestType = &(((ObjKibako*)actor)->chest_type);
} else if (actor->actor_id == OBJ_COMB) {
override = get_newflag_override(flag);
pChestType = &(((ObjComb *)actor)->chest_type);
pChestType = &(((ObjComb*)actor)->chest_type);
}
if (override.key.all != 0 && pChestType != NULL) { // If we don't have an override key, then either this item doesn't have an override entry, or it has already been collected.
if (POTCRATE_TEXTURES_MATCH_CONTENTS == PTMC_UNCHECKED && override.key.all > 0) { // For "unchecked" PTMC setting: Check if we have an override which means it wasn't collected.
Expand Down Expand Up @@ -193,11 +193,11 @@ bool spawn_override_silver_rupee(ActorEntry* actorEntry, z64_game_t* globalCtx,
*overridden = false;
if (SHUFFLE_SILVER_RUPEES) { // Check if silver rupee shuffle is enabled.
xflag_t flag = {
.scene = globalCtx->scene_index,
.setup = curr_scene_setup,
.room = globalCtx->room_index,
.flag = CURR_ACTOR_SPAWN_INDEX,
.subflag = 0
.scene = globalCtx->scene_index,
.setup = curr_scene_setup,
.room = globalCtx->room_index,
.flag = CURR_ACTOR_SPAWN_INDEX,
.subflag = 0,
};

flag = resolve_alternative_flag(&flag);
Expand Down Expand Up @@ -240,10 +240,9 @@ z64_actor_t* Player_SpawnEntry_Hack(void* actorCtx, ActorEntry* playerEntry, z64
}

// This is our entrypoint back into Actor_Spawn. Call/return this to spawn the actor
extern z64_actor_t *Actor_Spawn_Continue(void* actorCtx, z64_game_t* globalCtx, int16_t actorId, float posX, float posY, float posZ, int16_t rotX, int16_t rotY, int16_t rotZ, int16_t params);
extern z64_actor_t* Actor_Spawn_Continue(void* actorCtx, z64_game_t* globalCtx, int16_t actorId, float posX, float posY, float posZ, int16_t rotX, int16_t rotY, int16_t rotZ, int16_t params);

z64_actor_t * Actor_Spawn_Hook(void* actorCtx, z64_game_t* globalCtx, int16_t actorId,
float posX, float posY, float posZ, int16_t rotX, int16_t rotY, int16_t rotZ, int16_t params) {
z64_actor_t* Actor_Spawn_Hook(void* actorCtx, z64_game_t* globalCtx, int16_t actorId, float posX, float posY, float posZ, int16_t rotX, int16_t rotY, int16_t rotZ, int16_t params) {
bool continue_spawn = true;

ActorEntry entry;
Expand All @@ -256,7 +255,7 @@ z64_actor_t * Actor_Spawn_Hook(void* actorCtx, z64_game_t* globalCtx, int16_t ac
entry.rot.y = rotY;
entry.rot.z = rotZ;

if(continue_spawn) {
if (continue_spawn) {
z64_actor_t* spawned = Actor_Spawn_Continue(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params);
if (spawned) {
if (spawn_actor_with_flag) {
Expand Down
2 changes: 1 addition & 1 deletion ASM/c/demo_effect.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "demo_effect.h"
#include "models.h"

extern void DemoEffect_DrawJewel(z64_actor_t* this, z64_game_t* globalCtx, void* func);
extern void DemoEffect_DrawJewel(DemoEffect* this, z64_game_t* globalCtx, void* func);
extern void* DemoEffect_DrawJewel_AfterHook;

extern override_key_t CFG_BIGOCTO_OVERRIDE_KEY;
Expand Down
2 changes: 2 additions & 0 deletions ASM/c/demo_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ typedef struct {
/* 0x00 */ uint8_t timer;
} DemoEffectDust;

struct DemoEffect;

typedef void (*DemoEffectFunc)(struct DemoEffect*, z64_game_t*);

typedef struct DemoEffect {
Expand Down
4 changes: 1 addition & 3 deletions ASM/c/en_item00.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,15 @@ bool EnItem00_ProximityCheck_Hack(EnItem00* this, z64_game_t* GlobalCtx) {
extern void EnItem00_Init(EnItem00* this, z64_game_t* globalCtx);
extern void en_item00_update(EnItem00* this, z64_game_t* globalCtx);


void EnItem00_Init_Hook(EnItem00* this, z64_game_t* globalCtx) {
EnItem00_Init(this, globalCtx);
// Reset the scale for overridden collectibles
if(this->override.key.all) {
if (this->override.key.all) {
this->scale = this->actor.scale.x = this->actor.scale.y = this->actor.scale.z = 0.015f;
this->actor.yOffset = 750.0f;
}
}


void en_item00_update_hook(EnItem00* this, z64_game_t* globalCtx) {
xflag_t* flag = &(Actor_GetAdditionalData(&this->actor)->flag);
if (this->override.key.type != OVR_DELAYED && Get_NewFlag(flag) && !(collectible_mutex == this || this->actor.dropFlag == 1)) {
Expand Down
6 changes: 3 additions & 3 deletions ASM/c/en_item00.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ typedef struct EnItem00 {
float scale; // 0x014C
ColliderCylinder collider; // 0x0150 size = 4C
override_t override; // 0x019C
bool is_silver_rupee; // 0x????
bool is_silver_rupee; // 0x????
bool dropped;
model_t model;
} EnItem00;

void EnItem00_OutgoingAction(EnItem00* this, z64_game_t* globalCtx);

typedef void (*z64_EnItem00ActionFunc)(struct EnItem00*, z64_game_t*);
typedef EnItem00 *(*z64_Item_DropCollectible_proc)(z64_game_t* globalCtx, z64_xyzf_t* spawnPos, int16_t params);
typedef EnItem00 *(*z64_Item_DropCollectibleRandom_proc)(z64_game_t* globalCtx, z64_actor_t* fromActor, z64_xyzf_t* spawnPos, int16_t params);
typedef EnItem00*(*z64_Item_DropCollectible_proc)(z64_game_t* globalCtx, z64_xyzf_t* spawnPos, int16_t params);
typedef EnItem00*(*z64_Item_DropCollectibleRandom_proc)(z64_game_t* globalCtx, z64_actor_t* fromActor, z64_xyzf_t* spawnPos, int16_t params);

#endif
16 changes: 9 additions & 7 deletions ASM/c/en_wonderitem.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ void EnWonderitem_AfterInitHack(z64_actor_t* this, z64_game_t* globalCtx) {
void EnWonderItem_Multitag_DrawHack(z64_xyzf_t* tags, uint32_t index, EnWonderItem* this) {
if (this->overridden) {
colorRGBA8_t* color = &sEffectPrimColorBlue;
if(this->wonderMode == WONDERITEM_MULTITAG_ORDERED)
if (this->wonderMode == WONDERITEM_MULTITAG_ORDERED) {
color = &sEffectPrimColorCyan;
}
z64_xyzf_t pos = tags[index];
// if(this->wonderMode != WONDERITEM_INTERACT_SWITCH)
// pos.y += 20.0;
z64_EffectSsKiraKira_SpawnSmall(&z64_game, &pos, &sEffectVelocity, &sEffectAccel, color, &sEffectEnvColor);
}
}
Expand Down Expand Up @@ -105,17 +104,20 @@ void EnWonderItem_Update_Hack(EnWonderItem* this) {
colorRGBA8_t* color = NULL;
if (this->overridden) {
switch (this->wonderMode) {
case (WONDERITEM_PROXIMITY_DROP): {
case WONDERITEM_PROXIMITY_DROP:
{
color = &sEffectPrimColorYellow;
break;
}
case (WONDERITEM_INTERACT_SWITCH):
case (WONDERITEM_BOMB_SOLDIER): {
case WONDERITEM_INTERACT_SWITCH:
case WONDERITEM_BOMB_SOLDIER:
{
color = &sEffectPrimColorRed;
break;
}
default:
default: {
break;
}
}
if (color) {
z64_EffectSsKiraKira_SpawnSmall(&z64_game, &(this->actor.pos_world), &sEffectVelocity, &sEffectAccel, color, &sEffectEnvColor);
Expand Down
87 changes: 29 additions & 58 deletions ASM/c/get_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ void item_overrides_init() {
}

override_key_t get_override_search_key_by_newflag(xflag_t* flag) {
if(flag > 0)
{
if (flag > 0) {
override_key_t key = {
.scene = flag->scene,
.type = OVR_NEWFLAGCOLLECTIBLE,
.pad = 0,
.flag = flag->all,
.scene = flag->scene,
.type = OVR_NEWFLAGCOLLECTIBLE,
.pad = 0,
.flag = flag->all,
};
return resolve_alternative_override(key);
}
Expand Down Expand Up @@ -152,8 +151,7 @@ override_key_t get_override_search_key(z64_actor_t* actor, uint8_t scene, uint8_
.pad = 0,
.flag = item_id,
};
}
else {
} else {
return (override_key_t) {
.scene = scene,
.type = OVR_BASE_ITEM,
Expand Down Expand Up @@ -211,8 +209,7 @@ override_key_t resolve_alternative_override(override_key_t override_key) {
return override_key;
}

xflag_t resolve_alternative_flag(xflag_t* flag)
{
xflag_t resolve_alternative_flag(xflag_t* flag) {
override_key_t key;
key.scene = flag->scene;
key.type = 0x06;
Expand Down Expand Up @@ -330,6 +327,7 @@ void push_pending_item(override_t override) {
break;
}
if (extended_savectx.incoming_queue[i].key.all == override.key.all) {
// Prevent duplicate entries
break;
}
}
Expand Down Expand Up @@ -432,8 +430,7 @@ inline uint32_t link_is_ready() {
(z64_event_state_1 & 0x20) == 0 &&
(z64_game.camera_2 == 0)) {
satisfied_pending_frames++;
}
else {
} else {
satisfied_pending_frames = 0;
}
if (satisfied_pending_frames >= 2) {
Expand All @@ -446,7 +443,7 @@ inline uint32_t link_is_ready() {
void try_pending_item() {
override_t override = extended_savectx.incoming_queue[0];

if(override.key.all == 0) {
if (override.key.all == 0) {
return;
}
uint16_t resolved_item_id = resolve_upgrades(override);
Expand All @@ -460,17 +457,16 @@ void try_pending_item() {
return;
}

if(item_row->collectible >= 0 && override.key.flag == 0xFF) {
if (item_row->collectible >= 0 && override.key.flag == 0xFF) {
// This is an incoming collectible junk item so speed it up by spawning a give immediate collectible
EnItem00 *collectible = (EnItem00*)z64_SpawnActor(&z64_game.actor_ctxt, &z64_game, 0x0015, z64_link.common.pos_world.x, z64_link.common.pos_world.y, z64_link.common.pos_world.z, 0,0,0, 0x8000 | item_row->collectible);
EnItem00* collectible = (EnItem00*)z64_SpawnActor(&z64_game.actor_ctxt, &z64_game, 0x0015, z64_link.common.pos_world.x, z64_link.common.pos_world.y, z64_link.common.pos_world.z, 0, 0, 0, 0x8000 | item_row->collectible);
collectible->override = override;
collectible->scale = collectible->actor.scale.x = collectible->actor.scale.y = collectible->actor.scale.z = 0.015f;
collectible->actor.yOffset = 750.0f;
lookup_model_by_override(&collectible->model,collectible->override);
lookup_model_by_override(&collectible->model, collectible->override);
pop_pending_item();
after_key_received(override.key);
}
else {
} else {
activate_override(override);
z64_link.incoming_item_actor = dummy_actor;
z64_link.incoming_item_id = active_item_row->base_item_id;
Expand Down Expand Up @@ -614,18 +610,17 @@ void reset_collectible_mutex() {

// New EnItem00 function that freezes Link until the messagebox is closed. Similar to how skulls work.
void Collectible_WaitForMessageBox(EnItem00* this, z64_game_t* game) {
// Put the item above link's head and keep it spinning like the normal action function
// Put the item above Link's head and keep it spinning like the normal action function
this->actor.rot_2.y += 960;
this->actor.pos_world = z64_link.common.pos_world;
this->actor.pos_world.y += 40.0f;
if(z64_file.link_age == 0) // link is adult so move it up another 20.0f
{
if (z64_file.link_age == 0) { // Link is adult so move it up another 20.0f
this->actor.pos_world.y += 20.0f;
}

// Check message state:
if (z64_MessageGetState(((uint8_t*)(&z64_game)) + 0x20D8) == 0) {
// Make sure link was frozen for the minimum amount of time
// Make sure Link was frozen for the minimum amount of time
if (this->timeToLive == 0) {
reset_collectible_mutex(); // release the mutex
// Kill the actor
Expand Down Expand Up @@ -656,48 +651,45 @@ uint16_t get_xflag_bit_offset(xflag_t* flag) {
uint32_t test_scene_room_setup;

// Check if we're in a grotto because we calculate grotto scene/room/setup differently because grottos are dumb
if(is_grotto) {
if (is_grotto) {
test_scene_room_setup = (flag->scene << 24) + (flag->grotto.grotto_id << 8) + (flag->grotto.room);
}
else {
} else {
test_scene_room_setup = (flag->scene << 24) + (flag->setup << 6) + (flag->room);
}

// Check if we have this scene/room/setup cached already
if(test_scene_room_setup != loaded_scene_room_setup)
{
if (test_scene_room_setup != loaded_scene_room_setup) {
// Not cached so load it using the xflag tables
loaded_room_bit_offset = -1;
loaded_scene_room_setup = -1;

// Get the offset into xflag_room_table for the current scene.
uint16_t room_table_index = xflag_scene_table[flag->scene];
if(room_table_index == 0xffff) {
if (room_table_index == 0xffff) {
return 0xffff;
}

// First byte in the xflag_room_table block for this scene is the number of rooms/setups
room_setup_count = xflag_room_table[room_table_index++];

// Loop through all of the rooms/setups to find the one for this flag
for(i = 0; i < room_setup_count; i++) {
for (i = 0; i < room_setup_count; i++) {
// Get the setup/room from the entry
if(flag->scene == 0x3E) {
if (flag->scene == 0x3E) {
// If we're in a the room/setup entries are stored differently because we need 2 bytes to represent them
setup_id_temp = (xflag_room_table[room_table_index++]);
room_id_temp = xflag_room_table[room_table_index++];
room_id = flag->grotto.room;
setup_id = flag->grotto.grotto_id;
}
else {
} else {
setup_id_temp = (xflag_room_table[room_table_index] & 0xC0) >> 6;
room_id_temp = xflag_room_table[room_table_index++] & 0x3F;
room_id = flag->room;
setup_id = flag->setup;
}

// Test if the setup/room matches the flag
if((room_id_temp == room_id) && setup_id_temp == setup_id) {
if ((room_id_temp == room_id) && setup_id_temp == setup_id) {
// Match. Read the next 2 bytes which contains the byte offset into the xflag_room_blob table
room_byte_offset = (xflag_room_table[room_table_index] << 8) + xflag_room_table[room_table_index+1];
break;
Expand All @@ -706,7 +698,7 @@ uint16_t get_xflag_bit_offset(xflag_t* flag) {
room_table_index += 2;
}
// If we get here and room_byte_offset is still 0xFFFF then the room/setup combination for this flag wasn't found in the table. Just return 0xFFFF
if(room_byte_offset == 0xFFFF) {
if (room_byte_offset == 0xFFFF) {
return 0xFFFF;
}

Expand Down Expand Up @@ -748,15 +740,12 @@ uint16_t get_xflag_bit_offset(xflag_t* flag) {
// Substract 1 from the value in room_flags because we use 0 to indicate that there is no flag for that actor.
if (loaded_room_bit_offset != -1) {
if (is_grotto) {
if (room_flags[flag->grotto.flag]) {
return loaded_room_bit_offset + room_flags[flag->grotto.flag] - 1 + flag->grotto.subflag;
}
if (room_flags[flag->grotto.flag]) return loaded_room_bit_offset + room_flags[flag->grotto.flag] - 1 + flag->grotto.subflag;
} else if (room_flags[flag->flag]) {
return loaded_room_bit_offset + room_flags[flag->flag] - 1 + flag->subflag;
}
}
return 0xFFFF;

}

// Check if the new collectible flag for an actor is set.
Expand Down Expand Up @@ -816,13 +805,12 @@ bool Item00_KillActorIfFlagIsSet(z64_actor_t* actor) {
flag = drop_collectible_override_flag;
} else if (CURR_ACTOR_SPAWN_INDEX) {
flag.scene = z64_game.scene_index;
if(z64_game.scene_index == 0x3E) {
if (z64_game.scene_index == 0x3E) {
flag.grotto.room = actor->room_index;
flag.grotto.grotto_id = z64_file.grotto_id & 0x1F;
flag.grotto.flag = CURR_ACTOR_SPAWN_INDEX;
flag.grotto.subflag = 0;
}
else {
} else {
flag.room = actor->room_index;
flag.setup = curr_scene_setup;
flag.flag = CURR_ACTOR_SPAWN_INDEX;
Expand All @@ -842,23 +830,6 @@ bool Item00_KillActorIfFlagIsSet(z64_actor_t* actor) {
extra->flag = (xflag_t) { 0 };
}

/*
// Pots with overridden fairy drops just spawn the fairy like they normally do and set the collectible flag
if(this->override.value.base.item_id == 0x0119 && drop_collectible_override_flag.all)
{
Set_NewOverrideFlag(&flag);
z64_SpawnActor(&(z64_game.actor_ctxt), &z64_game, 24, this->actor.pos_world.x, this->actor.pos_world.y, this->actor.pos_world.z, 0,0,0, 6);
z64_ActorKill(actor);
return 1;
}
// Pots with nothing drops don't drop anything and just set the collectible flag.
if(this->override.value.base.item_id == 0x011A) {
Set_NewOverrideFlag(&flag);
z64_ActorKill(actor);
return 1;
}*/

if (this->override.key.all) { // If an override exists and we haven't already collected it
extra->flag = flag;
return 0; // Return 0 to continue spawning the actor
Expand Down
1 change: 0 additions & 1 deletion ASM/c/item_draw_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,5 +748,4 @@ void draw_gi_fairy(z64_game_t* game, uint32_t draw_id) {
}

void draw_gi_nothing(z64_game_t* game, uint32_t draw_id) {

}
2 changes: 1 addition & 1 deletion ASM/c/models.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void collectible_draw_other(z64_actor_t* actor, z64_game_t* game) {
draw_model(model, actor, game, 10.0);
return;
}
base_collectable_draw(actor,game);
base_collectable_draw(actor, game);
}

void heart_container_draw(z64_actor_t* actor, z64_game_t* game) {
Expand Down
Loading

0 comments on commit 571e4bf

Please sign in to comment.