Skip to content

Commit

Permalink
Redux April 2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Admentus64 committed Apr 29, 2024
1 parent d63cff4 commit 1bd3e6f
Show file tree
Hide file tree
Showing 30 changed files with 1,283 additions and 1,206 deletions.
102 changes: 91 additions & 11 deletions ASM/c/actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ extern uint16_t CURR_ACTOR_SPAWN_INDEX;
extern uint16_t play_sfx;

uint16_t currentHealth = 0;
actor_backup_t actorBackup = { .scene = -1, .id = 0, .x = 0, .y = 0, .z = 0, .xr = 0, .yr = 0, .zr = 0, .var = 0 };

void get_health(z64_actor_t* actor) {
if (!SAVE_SHOW_HEALTH || z64_game.pause_ctxt.state != 0 || actor == NULL) {
if (!OPTION_ACTIVE(1, SAVE_SHOW_HEALTH, CFG_DEFAULT_SHOW_HEALTH) || z64_game.pause_ctxt.state != 0 || actor == NULL) {
currentHealth = 0;
return;
}
Expand Down Expand Up @@ -47,7 +48,7 @@ void get_health(z64_actor_t* actor) {
}

void draw_health(z64_disp_buf_t *db) {
if (!SAVE_SHOW_HEALTH || currentHealth == 0 || z64_file.hud_visibility_mode == 1 || !CAN_DRAW_HUD || !CAN_CONTROL_LINK || z64_textbox != 0)
if (!OPTION_ACTIVE(1, SAVE_SHOW_HEALTH, CFG_DEFAULT_SHOW_HEALTH) || currentHealth == 0 || z64_file.hud_visibility_mode == 1 || !CAN_DRAW_HUD || !CAN_CONTROL_LINK || z64_textbox != 0)
return;

uint16_t x = 70;
Expand All @@ -72,24 +73,103 @@ void draw_health(z64_disp_buf_t *db) {

gDPSetCombineMode(db->p++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
gDPSetPrimColor(db->p++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF);
sprite_load(db, &linkhead_skull_sprite, 1, 1);
sprite_draw(db, &linkhead_skull_sprite, 0, x, y, 16, 16);
sprite_load_and_draw(db, &linkhead_skull_sprite, 1, x, y, 16, 16);

for (uint8_t i=0; i<count; i++) {
sprite_load(db, &counter_digit_sprite, healthArray[count-i-1], 1);
sprite_draw(db, &counter_digit_sprite, 0, x + 16 + 8 * i, y + 1, 8, 16);
for (uint8_t i=0; i<count; i++)
sprite_load_and_draw(db, &counter_digit_sprite, healthArray[count-i-1], x + 16 + 8 * i, y + 1, 8, 16);
}

void restore_spawner_backup(z64_game_t *game) {
if (actorBackup.scene < 0 || z64_link.current_mask == PLAYER_MASK_SKULL || z64_link.current_mask == PLAYER_MASK_GORON)
return;
else if (actorBackup.scene != z64_game.scene_index)
actorBackup.scene = -1;
else {
z64_SpawnActor(&game->actor_ctxt, game, actorBackup.id, actorBackup.x, actorBackup.y, actorBackup.z, actorBackup.xr, actorBackup.yr, actorBackup.zr, actorBackup.var);
actorBackup.scene = -1;
}
}

void elite_enemies(z64_game_t *game) {
if (!SAVE_RANDOM_ENEMIES)
void remove_enemy_spawner() {
if (actorBackup.scene >= 0 || z64_link.current_mask != PLAYER_MASK_SKULL)
return;

z64_actor_t *actor = z64_game.actor_list[ACTORTYPE_PROP].first;
while (actor != NULL) {
if (actor->actor_id == EN_ENCOUNT1) {
set_actor_backup(actor);
break;
}
actor = actor->next;
}
}

void remove_falling_rocks_spawner() {
if (actorBackup.scene >= 0 || z64_link.current_mask != PLAYER_MASK_GORON)
return;

z64_actor_t *actor = z64_game.actor_list[ACTORTYPE_ENEMY].first;
while (actor != NULL) {
if (actor->actor_id == EN_ENCOUNT2) {
set_actor_backup(actor);
break;
}
actor = actor->next;
}
}

void set_actor_backup(z64_actor_t *actor) {
actorBackup.scene = z64_game.scene_index;
actorBackup.id = actor->actor_id;
actorBackup.x = actor->pos_1.x;
actorBackup.y = actor->pos_1.y;
actorBackup.z = actor->pos_1.z;
actorBackup.xr = actor->rot_init.x;
actorBackup.yr = actor->rot_init.y;
actorBackup.zr = actor->rot_init.z;
actorBackup.var = actor->variable;
z64_ActorKill(actor);
}

// #define rd_obj_idx(actor) ((int8_t*)actor)[0x90] // redead_actor->rd_obj_idx
// #define OBJECT_RD 0x0098

//typedef struct {
// char unk_00_[0x14ED]; /* 0x0000 */
// uint16_t freeze_timer; /* 0x14EE */
//} redead_data_t;

//uint8_t has_redead_actor_file(z64_actor_t* actor, z64_game_t* game) {
// //return (rd_obj_idx(actor) > 0) && ((rd_obj_idx(actor) = z64_ObjectIndex(&game->obj_ctxt, OBJECT_RD)) > 0) && z64_ObjectIsLoaded(&game->obj_ctxt, rd_obj_idx(actor));
//}

/*void set_redead_freeze() {
if (!CAN_CONTROL_LINK)
return;
z64_game_t* game = &z64_game;
int16_t index = z64_ObjectIndex(&game->obj_ctxt, OBJECT_RD);
if (index > 0) {
play_sfx = 0x4813;
uint32_t offset = (*(uint8_t*) game->obj_ctxt.objects[index].getfile.vrom_addr);
z64_file.rupees = offset;
//uint32_t test1 = (*(uint8_t*) 0x801DB0CD);
//z64_file.rupees = test1;
}
// CD869E - CD71B0 = 14EE
}*/

void elite_enemies() {
if (!OPTION_ACTIVE(2, SAVE_RANDOM_ENEMIES, CFG_DEFAULT_RANDOM_ENEMIES) || !CAN_CONTROL_LINK)
return;

z64_actor_t *enemy = z64_game.actor_list[ACTORTYPE_ENEMY].first;
while (enemy != NULL) {
if (enemy->rot_init.z < 0x8000 && enemy->health != 0) {
uint16_t id = enemy->actor_id;
if (enemy->rot_init.z < 0x8000 && enemy->health > 1 && id != EN_ST && id != EN_ANUBICE && id != EN_FZ) {
float rand = z64_Rand_ZeroOne();
if (rand >= 0.4) {
float factor = 1.5;
Expand All @@ -114,7 +194,7 @@ void elite_enemies(z64_game_t *game) {
}

z64_actor_t *replace_enemy_type(z64_actor_t *spawned) {
if (!SAVE_RANDOM_ENEMIES)
if (!OPTION_ACTIVE(2, SAVE_RANDOM_ENEMIES, CFG_DEFAULT_RANDOM_ENEMIES))
return spawned;
if (spawned->actor_type != ACTORTYPE_ENEMY)
return spawned;
Expand Down
33 changes: 32 additions & 1 deletion ASM/c/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ typedef void(*actor_after_spawn_func)(z64_actor_t* actor, uint8_t overridden);

void get_health(z64_actor_t* actor);
void draw_health(z64_disp_buf_t *db);
void elite_enemies(z64_game_t *game);
void restore_spawner_backup(z64_game_t *game);
void remove_enemy_spawner();
void remove_falling_rocks_spawner();
void set_actor_backup(z64_actor_t *actor);
//void set_redead_freeze();
void elite_enemies();
z64_actor_t *replace_enemy_type(z64_actor_t *spawned);

z64_actor_t *Actor_SpawnEntry_Hack(void *actorCtx, ActorEntry *actorEntry, z64_game_t *globalCtx);
Expand All @@ -26,6 +31,18 @@ z64_actor_t *Actor_SpawnEntry_Hack(void *actorCtx, ActorEntry *actorEntry, z64_g
#define HP_GANONDORF (*(uint8_t*) 0x8020B5CF)
#define HP_GANON (*(uint8_t*) 0x801FA2DF)

typedef struct {
int8_t scene;
uint16_t id;
int16_t x;
int16_t y;
int16_t z;
uint16_t xr;
uint16_t yr;
uint16_t zr;
uint16_t var;
} actor_backup_t;

typedef enum {
EN_TEST = 0x0002,
BOSS_DODONGO = 0x0012, // 0x0027
Expand All @@ -36,19 +53,26 @@ typedef enum {
EN_ZF = 0x0025,
EN_ST = 0x0037,
BOSS_GANONDROF = 0x0052,
EN_AM = 0x0054,
EN_FLOORMAS = 0x008E,
EN_RD = 0x0090,
EN_SW = 0x0095,
BOSS_FD = 0x0096,
EN_FD = 0x0099,
BOSS_FD2 = 0x00A2,
EN_ENCOUNT1 = 0x00A7,
EN_FW = 0x00AB,
EN_ENCOUNT2 = 0x00B4,
BOSS_VA = 0x00BA,
BOSS_MO = 0x00C4,
BOSS_TW = 0x00DC,
EN_ANUBICE = 0x00E0,
BOSS_GANON = 0x00E8,
EN_IK = 0x0113,
EN_FZ = 0x0121,
BOSS_GANON2 = 0x017A,
EN_WF = 0x01AF,
EN_CROW = 0x01C0,
} actor_id;

typedef enum {
Expand Down Expand Up @@ -122,4 +146,11 @@ typedef enum {
EN_WF_WHITE = 1,
} En_Wf;

typedef enum {
EN_ENCOUNT1_LEEVER = 0,
EN_ENCOUNT1_RED_TEKTITE = 0x800,
EN_ENCOUNT1_STALCHILD = 0x1000,
EN_ENCOUNT1_WOLFOS = 0x1800,
} En_Encount1;

#endif
3 changes: 1 addition & 2 deletions ASM/c/agony.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ void draw_agony_graphic(int hoffset, int voffset, unsigned char alpha) {
gDPPipeSync(db->p++);
gDPSetCombineMode(db->p++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
gDPSetPrimColor(db->p++, 0, 0, 0xFF, 0xFF, 0xFF, alpha);
sprite_load(db, &quest_items_sprite, 9, 1);
sprite_draw(db, &quest_items_sprite, 0, 27+hoffset, 189+voffset, 16, 16);
sprite_load_and_draw(db, &quest_items_sprite, 9, 27 + hoffset, 189 + voffset, 16, 16);
gDPPipeSync(db->p++);
}

Expand Down
4 changes: 1 addition & 3 deletions ASM/c/arrow_cycle.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "arrow_cycle.h"
#include "actor.h"

extern uint8_t CFG_OPTIONS_MENU;

extern uint16_t play_sfx;

typedef struct {
Expand Down Expand Up @@ -137,7 +135,7 @@ z64_actor_t* arrow_cycle_find_arrow(z64_link_t* player, z64_game_t* ctxt) {
}

void arrow_cycle_handle(z64_link_t* player, z64_game_t* ctxt) {
if (CFG_OPTIONS_MENU < 1 || !SAVE_ARROW_TOGGLE)
if (!OPTION_ACTIVE(1, SAVE_ARROW_TOGGLE, CFG_DEFAULT_ARROW_TOGGLE))
return;

if (g_arrow_cycle_state.frameDelay >= 1) {
Expand Down
Loading

0 comments on commit 1bd3e6f

Please sign in to comment.