Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Item : Bronze scale #2224

Draft
wants to merge 3 commits into
base: Dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,147 changes: 577 additions & 570 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
1,122 changes: 568 additions & 554 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ASM/c/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void draw_debug_menu(z64_disp_buf_t *db) {

// Shoutouts to OoTMM
z64_Play_SetupRespawnPoint(&z64_game, 1, 0xDFF);
z64_file.void_flag = 2;
z64_file.respawn_flag = 2;

z64_game.scene_load_flag = 0x14;
z64_game.fadeout_transition = 0x02;
Expand Down
32 changes: 30 additions & 2 deletions ASM/c/file_icons.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "hud_colors.h"
#include "triforce.h"
#include "ocarina_buttons.h"
#include "save.h"

#define ICON_SIZE 0x0C
#define MUSIC_WIDTH 0x06
Expand Down Expand Up @@ -172,6 +173,7 @@ static const variable_tile_data_t variable_tile_positions[NUM_VARIABLE] = {
{0, {0x4E, 0x2A}}, // Strength
{0, {0x5A, 0x2A}}, // Scale
};
static uint8_t bronze_scale_marker = 0;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a bool


typedef struct {
colorRGB8_t color;
Expand Down Expand Up @@ -380,8 +382,9 @@ static void populate_child_trade(const z64_file_t* file, variable_tile_t* tile);
static void populate_adult_trade(const z64_file_t* file, variable_tile_t* tile);
static void populate_magic(const z64_file_t* file, variable_tile_t* tile);
static void populate_upgrade_equip(const z64_file_t* file, variable_tile_t* tile, uint8_t value, uint8_t max, uint8_t base_tile);
static void populate_upgrade_scale(const z64_file_t* file, variable_tile_t* tile, uint8_t value, uint8_t base_tile);

static void populate_variable(const z64_file_t* file, variable_tile_info_t* info) {
void populate_variable(const z64_file_t* file, variable_tile_info_t* info) {
variable_tile_t* tile = info->tiles;

populate_upgrade_item( file, tile++, Z64_SLOT_OCARINA, Z64_ITEM_FAIRY_OCARINA);
Expand All @@ -390,7 +393,8 @@ static void populate_variable(const z64_file_t* file, variable_tile_info_t* info
populate_adult_trade( file, tile++);
populate_magic( file, tile++);
populate_upgrade_equip(file, tile++, file->strength_upgrade, 3, Z64_ITEM_GORONS_BRACELET);
populate_upgrade_equip(file, tile++, file->diving_upgrade, 2, Z64_ITEM_SILVER_SCALE);
extended_savecontext_static_t* extended = &(((extended_sram_file_t*)file)->additional_save_data.extended);
populate_upgrade_scale(file, tile++, extended->extended_scale, Z64_ITEM_SILVER_SCALE);
}


Expand Down Expand Up @@ -519,6 +523,11 @@ static void draw_variable(z64_disp_buf_t* db, const variable_tile_info_t* info,
color = WHITE;
color.a = color_product(color.a, alpha);
}
if (bronze_scale_marker) {
sprite_load(db, &item_digit_sprite, 0, 1);
sprite_draw(db, &item_digit_sprite, 0, get_left(variable_tile_positions[NUM_VARIABLE - 1].pos) + 4,
get_top(variable_tile_positions[NUM_VARIABLE - 1].pos) + 3, 6, 6);
}
}


Expand Down Expand Up @@ -935,3 +944,22 @@ static void populate_upgrade_equip(const z64_file_t* file, variable_tile_t* tile
tile->tile_index = base_tile + (value - 1);
}
}

static void populate_upgrade_scale(const z64_file_t* file, variable_tile_t* tile, uint8_t value, uint8_t base_tile) {
tile->tile_index = base_tile;
bronze_scale_marker = 0;
if (value == 0) {
bronze_scale_marker = 1;
tile->enabled = 0;
}
if (value == 1) {
tile->enabled = 0;
}
if (value == 2) {
tile->enabled = 1;
}
if (value == 3) {
tile->enabled = 1;
tile->tile_index++;
}
}
2 changes: 1 addition & 1 deletion ASM/c/get_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ override_key_t get_override_search_key(z64_actor_t* actor, uint8_t scene, uint8_
};
} else if (scene == 0x3E && actor->actor_id == 0x011A) {
return (override_key_t){
.scene = z64_file.grotto_id,
.scene = z64_file.respawn[RESPAWN_MODE_RETURN].data,
.type = OVR_GROTTO_SCRUB,
.flag = item_id,
};
Expand Down
32 changes: 32 additions & 0 deletions ASM/c/item_draw_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,38 @@ void draw_gi_magic_spells(z64_game_t* game, uint32_t draw_id) {
gSPDisplayList(gfx->poly_xlu.p++, item_draw_table[draw_id].args[1].dlist);
gSPDisplayList(gfx->poly_xlu.p++, item_draw_table[draw_id].args[2].dlist);
}
static Gfx gGiBronzeScaleWaterColorDL[] = {
gsDPPipeSync(),
gsDPSetPrimColor(0, 0x60, 255, 255, 255, 255),
gsDPSetEnvColor(255, 123, 0, 255),
gsSPEndDisplayList(),
};

static Gfx gGiBronzeScaleColorDL[] = {
gsDPPipeSync(),
gsDPSetPrimColor(0, 0x80, 255, 255, 255, 255),
gsDPSetEnvColor(91, 51, 18, 255),
gsSPEndDisplayList(),
};

void draw_bronze_scale(z64_game_t* game, uint32_t draw_id) {

z64_gfx_t* gfx = game->common.gfx;

append_setup_dl_25_to_xlu(gfx);
gSPSegment(gfx->poly_xlu.p++, 0x08,
gen_double_tile(gfx,
0, game->common.state_frames * 2, -(game->common.state_frames * 2), 64, 64,
1, game->common.state_frames * 4, -(game->common.state_frames * 4), 32, 32));


gSPMatrix(gfx->poly_xlu.p++, append_sys_matrix(gfx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);

gSPDisplayList(gfx->poly_xlu.p++, (Gfx*)gGiBronzeScaleColorDL);
gSPDisplayList(gfx->poly_xlu.p++, item_draw_table[draw_id].args[3].dlist);
gSPDisplayList(gfx->poly_xlu.p++, (Gfx*)gGiBronzeScaleWaterColorDL);
gSPDisplayList(gfx->poly_xlu.p++, item_draw_table[draw_id].args[0].dlist);
}

void draw_gi_scales(z64_game_t* game, uint32_t draw_id) {
z64_gfx_t* gfx = game->common.gfx;
Expand Down
1 change: 1 addition & 0 deletions ASM/c/item_draw_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void draw_gi_silver_rupee_pouch(z64_game_t* game, uint32_t draw_id);
void draw_gi_a_button(z64_game_t* game, uint32_t draw_id);
void draw_gi_c_button_vertical(z64_game_t* game, uint32_t draw_id);
void draw_gi_c_button_horizontal(z64_game_t* game, uint32_t draw_id);
void draw_bronze_scale(z64_game_t* game, uint32_t draw_id);


#endif
1 change: 1 addition & 0 deletions ASM/c/item_draw_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ item_draw_table_entry_t item_draw_table[] = {
[0x91] = { draw_gi_c_button_vertical, { 0x06000960, 0xFFA000FF, 1 } }, // Cdown button
[0x92] = { draw_gi_c_button_horizontal, { 0x06000E10, 0xFFA000FF, 1 } }, // Cleft button
[0x93] = { draw_gi_c_button_horizontal, { 0x06000E10, 0xFFA000FF, 0 } }, // Cright button
[0x94] = { draw_bronze_scale, { 0x06000AA0, 0x06000A40, 0x06000A80, 0x06000CC8 } }, // Bronze scale
};

void base_draw_gi_model(z64_game_t* game, uint32_t draw_id) {
Expand Down
17 changes: 17 additions & 0 deletions ASM/c/item_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,20 @@ void unlock_ocarina_note(z64_file_t* save, int16_t arg1, int16_t arg2) {
break;
}
}

void give_progressive_scale(z64_file_t* save, int16_t arg1, int16_t arg2) {
switch(arg1) {
case 0: // Bronze scale
extended_savectx.extended_scale = 1;
break;
case 1:
extended_savectx.extended_scale = 2;
save->diving_upgrade = 1;
break;
case 2:
extended_savectx.extended_scale = 3;
save->diving_upgrade = 2;
break;
}

}
1 change: 1 addition & 0 deletions ASM/c/item_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ void give_bombchus(z64_file_t* save, int16_t arg1, int16_t arg2);
void trade_quest_upgrade(z64_file_t* save, int16_t item_id, int16_t arg2);
extern uint8_t KEYRING_BOSSKEY_CONDITION;
void unlock_ocarina_note(z64_file_t* save, int16_t arg1, int16_t arg2);
void give_progressive_scale(z64_file_t* save, int16_t arg1, int16_t arg2);

typedef enum dungeon {
DEKU_ID = 0,
Expand Down
6 changes: 4 additions & 2 deletions ASM/c/item_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ item_row_t item_table[] = {
[0x0034] = ITEM_ROW(0x53, GILDED_CHEST, 0x4F, -1, 0x005A, 0x00BF, 0x1A, no_upgrade, no_effect, -1, -1, NULL), // Biggest Bomb Bag
[0x0035] = ITEM_ROW(0x53, GILDED_CHEST, 0x51, -1, 0x005B, 0x012D, 0x49, no_upgrade, no_effect, -1, -1, NULL), // Silver Gauntlets
[0x0036] = ITEM_ROW(0x53, GILDED_CHEST, 0x52, -1, 0x005C, 0x012D, 0x4A, no_upgrade, no_effect, -1, -1, NULL), // Golden Gauntlets
[0x0037] = ITEM_ROW(0x53, GILDED_CHEST, 0x53, -1, 0x00CD, 0x00DB, 0x2A, no_upgrade, no_effect, -1, -1, NULL), // Silver Scale
[0x0038] = ITEM_ROW(0x53, GILDED_CHEST, 0x54, -1, 0x00CE, 0x00DB, 0x2B, no_upgrade, no_effect, -1, -1, NULL), // Golden Scale
[0x0037] = ITEM_ROW(0x53, GILDED_CHEST, 0x53, -1, 0x00CD, 0x00DB, 0x2A, no_upgrade, give_progressive_scale, 1, -1, NULL), // Silver Scale
[0x0038] = ITEM_ROW(0x53, GILDED_CHEST, 0x54, -1, 0x00CE, 0x00DB, 0x2B, no_upgrade, give_progressive_scale, 2, -1, NULL), // Golden Scale
[0x0039] = ITEM_ROW(0x53, GILDED_CHEST, 0x6F, -1, 0x0068, 0x00C8, 0x21, no_upgrade, no_effect, -1, -1, NULL), // Stone of Agony
[0x003A] = ITEM_ROW(0x53, GILDED_CHEST, 0x70, -1, 0x007B, 0x00D7, 0x24, no_upgrade, no_effect, -1, -1, NULL), // Gerudo Membership Card
[0x003B] = ITEM_ROW(0x53, GILDED_CHEST, 0x41, -1, 0x004A, 0x010E, 0x46, no_upgrade, give_fairy_ocarina, -1, -1, NULL), // Fairy Ocarina
Expand Down Expand Up @@ -327,6 +327,8 @@ item_row_t item_table[] = {
[0x0116] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x00A0, 0x01A0, 0x87, no_upgrade, give_small_key, FORT_ID, -1, resolve_text_small_keys), // Thieves' Hideout Small Key
[0x0117] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x00A1, 0x01A1, 0x88, no_upgrade, give_small_key, CASTLE_ID, -1, resolve_text_small_keys), // Ganon's Castle Small Key
[0x0118] = ITEM_ROW(0x53, SILVER_CHEST, 0x41, -1, 0x00F3, 0x01A2, 0x89, no_upgrade, give_small_key, TCG_ID, -1, resolve_text_small_keys_cmg), // Small Key (Chest Game)

[0x0130] = ITEM_ROW(0x53, GILDED_CHEST, 0x41, -1, 0x90B4, 0x00DB, 0x95, no_upgrade, give_progressive_scale, 0, -1, NULL), // Bronze Scale
};

/* Determine which message to display based on the number of silver rupees collected.
Expand Down
8 changes: 5 additions & 3 deletions ASM/c/item_upgrades.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "item_upgrades.h"

#include "get_items.h"
#include "save.h"
#include "z64.h"

extern uint32_t FREE_BOMBCHU_DROPS;
Expand All @@ -15,7 +16,7 @@ typedef struct {
uint8_t magic : 2; // 0 = no magic, 1 = single magic, 2 = double magic
uint8_t sticks : 2; // 0 = no sticks, 1 = 10, 2 = 20, 3 = 30
uint8_t nuts : 2; // 0 = no nuts, 1 = 20, 2 = 30, 3 = 40
uint8_t scale : 2; // 0 = no scale, 1 = silver scale, 2 = gold scale
uint8_t scale : 3; // 0 = no scale, 1 = bronze_scale, 2 = silver scale, 3 = gold scale
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a co-op context version bump.

uint8_t wallet : 2; // 0 = 99, 1 = 200, 2 = 500, 3 = 999
uint8_t slingshot : 2; // 0 = no slingshot, 1 = 30, 2 = 40, 3 = 50
uint8_t bow : 2; // 0 = no bow, 1 = 30, 2 = 40, 3 = 50
Expand Down Expand Up @@ -82,8 +83,9 @@ uint16_t wallet_upgrade(z64_file_t* save, override_t override) {
}

uint16_t scale_upgrade(z64_file_t* save, override_t override) {
switch ((override.value.base.player == PLAYER_ID || !MW_PROGRESSIVE_ITEMS_ENABLE) ? save->diving_upgrade : MW_PROGRESSIVE_ITEMS_STATE[override.value.base.player].scale) {
case 0: return 0x37; // Silver Scale
switch ((override.value.base.player == PLAYER_ID || !MW_PROGRESSIVE_ITEMS_ENABLE) ? extended_savectx.extended_scale : MW_PROGRESSIVE_ITEMS_STATE[override.value.base.player].scale) {
case 0: return 0x130; // Bronze Scale
case 1: return 0x37; // Silver Scale
default: return 0x38; // Gold Scale
}
}
Expand Down
2 changes: 2 additions & 0 deletions ASM/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "debug.h"
#include "inputviewer.h"
#include "message.h"
#include "swim.h"

void Gameplay_InitSkybox(z64_game_t* globalCtx, int16_t skyboxId);

Expand Down Expand Up @@ -62,6 +63,7 @@ void after_game_state_update() {
debug_utilities(&(z64_ctxt.gfx->overlay));
}
give_ganon_boss_key();
manage_swim();
}

void before_skybox_init(z64_game_t* game, int16_t skyboxId) {
Expand Down
4 changes: 2 additions & 2 deletions ASM/c/obj_comb.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void obj_comb_drop_collectible(z64_actor_t* actor, int16_t params) {
uint16_t flag = actor->rot_init.z;
if (z64_game.scene_index == 0x3E) {
// We're in a grotto so offset by 2x grotto id. The Rz flags for the grottos need to be set to 0/1 beforehand.
flag = (2 * (z64_file.grotto_id & 0x1F)) + flag;
flag = (2 * (z64_file.respawn[RESPAWN_MODE_RETURN].data & 0x1F)) + flag;
// and add 0x40
flag += 0x40;
}
Expand All @@ -38,7 +38,7 @@ override_t get_beehive_override(z64_actor_t* actor, z64_game_t* game) {
uint16_t flag = actor->rot_init.z;
if (z64_game.scene_index == 0x3E) {
// We're in a grotto so offset by 2x grotto id. The Rz flags for the grottos need to be set to 0/1 beforehand.
flag = (2 * (z64_file.grotto_id & 0x1F)) + flag;
flag = (2 * (z64_file.respawn[RESPAWN_MODE_RETURN].data & 0x1F)) + flag;
// and add 0x40
flag += 0x40;
}
Expand Down
7 changes: 7 additions & 0 deletions ASM/c/save.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#ifndef SAVE_H
#define SAVE_H

#include "z64.h"

// Struct for storing additional data in SRAM. This has to always be a multiple of 2 bytes long supposedly.
typedef struct {
uint8_t silver_rupee_counts[0x16];
uint8_t extended_scale;
uint8_t pad;
} extended_savecontext_static_t __attribute__ ((aligned (8)));


Expand All @@ -20,3 +25,5 @@ extern extended_initial_save_entry EXTENDED_INITIAL_SAVE_DATA;
extern extended_savecontext_static_t extended_savectx;

void SsSram_ReadWrite_Safe(uint32_t addr, void* dramAddr, size_t size, uint32_t direction);

#endif
75 changes: 75 additions & 0 deletions ASM/c/swim.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include "swim.h"

RespawnByScene respawnsByScene[] = {
{ 0x1D9, { { -1455, -20, 1384 }, 28761 }}, // Hyrule Field to Zora River (in water)
{ 0x311, { { 5852, -20, 3725 }, -20025 }}, // Zora River to Hyrule Field (in water)
{ 0x4DA, { { 1978, -36, -855 }, -16384 }}, // Zora River to Lost Woods
{ 0x1DD, { { 4082, 860, -1018 }, -32768 }}, // Lost Woods to Zora River
{ 0x219, { { -3276, -1033, 2908 }, 11228 }}, // Gerudo Valley to Lake Hylia
{ 0x3D4, { { -2361, 0, 610 }, 32768 }}, // Ice Cavern to Zora Fountain
{ 0x21D, { { -955, -1306, 6768 }, -32768 }}, // Water Temple to Lake Hylia
{ 0x328, { { -109, 11, -9 }, -29131 }}, // Lake Hylia to Zora Domain
{ 0x560, { { -912, -1326, 3391 }, 0 }}, // Zora Domain to Lake Hylia
{ 0x10E, { { -1500, 150, 1600 }, 32768}}, // Sapphire cutscene to Zora Fountain
};

void set_new_respawn() {

uint8_t newRespawnTrue = 0;
int32_t currentEntranceIndex = z64_game.entrance_index;
for (uint8_t i = 0; i < 10; i++) {
// Ensure we always respawn at a safe location.
if (currentEntranceIndex == respawnsByScene[i].scene_index) {
z64_Play_SetupRespawnPoint(&z64_game, 0x01, 0xDFF);
z64_file.respawn[RESPAWN_MODE_RETURN].pos = respawnsByScene[i].respawnInfo.pos;
z64_file.respawn[RESPAWN_MODE_RETURN].yaw = respawnsByScene[i].respawnInfo.yaw;
z64_file.respawn_flag = 2;
z64_game.scene_load_flag = 0x14;
newRespawnTrue = 1;
break;
}
}

// Special case for Water Temple river area, so that player respawns at the start of the room.
if (z64_game.scene_index == 5 && z64_game.room_index == 21) {
z64_Play_SetupRespawnPoint(&z64_game, 0x01, 0xDFF);
z64_xyzf_t riverPos = {-3063, 380, -4066};
z64_file.respawn[RESPAWN_MODE_RETURN].pos = riverPos;
z64_file.respawn[RESPAWN_MODE_RETURN].yaw = 9010;
z64_file.respawn_flag = 2;
z64_game.scene_load_flag = 0x14;
return;
}

if (newRespawnTrue == 0) {
z64_game.entrance_index = z64_file.entrance_index;
z64_game.fadeout_transition = 0x02;
z64_file.respawn_flag = -2;
z64_game.scene_load_flag = 0x14;
}
}

void manage_swim() {

// We found the first scale.
if (extended_savectx.extended_scale > 0) {
return;
}

// Iron boots are equipped.
if (z64_file.equip_boots == 2) {
return;
}

// Always allow to swim out of water temple to avoid softlocks.
if (z64_game.scene_index == 5 &&
z64_game.room_index == 0 &&
z64_link.common.pos_world.z > 700.0) {
return;
}

if (z64_link.state_flags_1 & 0x08000000) { // Swimming state flag.
PlaySFX(0x28CD); // NA_SE_EV_WATER_CONVECTION
set_new_respawn();
}
}
19 changes: 19 additions & 0 deletions ASM/c/swim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef SWIM_H
#define SWIM_H

#include "z64.h"
#include "save.h"

typedef struct {
/* 0x00 */ z64_xyzf_t pos;
/* 0x0C */ uint16_t yaw;
} SpecialRespawnInfo; // size = 0x10

typedef struct {
int32_t scene_index;
SpecialRespawnInfo respawnInfo;
} RespawnByScene;

void manage_swim();

#endif
Loading
Loading