Skip to content

Commit efd6b94

Browse files
committed
Bronze scale
1 parent 7fbc0db commit efd6b94

34 files changed

Lines changed: 39663 additions & 116 deletions

ASM/c/item_draw_functions.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,38 @@ void draw_gi_magic_spells(z64_game_t* game, uint32_t draw_id) {
292292
gSPDisplayList(gfx->poly_xlu.p++, item_draw_table[draw_id].args[1].dlist);
293293
gSPDisplayList(gfx->poly_xlu.p++, item_draw_table[draw_id].args[2].dlist);
294294
}
295+
static Gfx gGiBronzeScaleWaterColorDL[] = {
296+
gsDPPipeSync(),
297+
gsDPSetPrimColor(0, 0x60, 255, 255, 255, 255),
298+
gsDPSetEnvColor(255, 123, 0, 255),
299+
gsSPEndDisplayList(),
300+
};
301+
302+
static Gfx gGiBronzeScaleColorDL[] = {
303+
gsDPPipeSync(),
304+
gsDPSetPrimColor(0, 0x80, 255, 255, 255, 255),
305+
gsDPSetEnvColor(91, 51, 18, 255),
306+
gsSPEndDisplayList(),
307+
};
308+
309+
void draw_bronze_scale(z64_game_t* game, uint32_t draw_id) {
310+
311+
z64_gfx_t* gfx = game->common.gfx;
312+
313+
append_setup_dl_25_to_xlu(gfx);
314+
gSPSegment(gfx->poly_xlu.p++, 0x08,
315+
gen_double_tile(gfx,
316+
0, game->common.state_frames * 2, -(game->common.state_frames * 2), 64, 64,
317+
1, game->common.state_frames * 4, -(game->common.state_frames * 4), 32, 32));
318+
319+
320+
gSPMatrix(gfx->poly_xlu.p++, append_sys_matrix(gfx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
321+
322+
gSPDisplayList(gfx->poly_xlu.p++, (Gfx*)gGiBronzeScaleColorDL);
323+
gSPDisplayList(gfx->poly_xlu.p++, item_draw_table[draw_id].args[3].dlist);
324+
gSPDisplayList(gfx->poly_xlu.p++, (Gfx*)gGiBronzeScaleWaterColorDL);
325+
gSPDisplayList(gfx->poly_xlu.p++, item_draw_table[draw_id].args[0].dlist);
326+
}
295327

296328
void draw_gi_scales(z64_game_t* game, uint32_t draw_id) {
297329
z64_gfx_t* gfx = game->common.gfx;

ASM/c/item_draw_functions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ void draw_gi_flame(z64_disp_buf_t* dl, z64_game_t *game, colorRGBA8_t prim, colo
5656
void draw_gi_xlu_with_flame(z64_game_t *game, uint32_t draw_id);
5757
void draw_gi_deku_nut_with_flame(z64_game_t* game, uint32_t draw_id);
5858
void draw_ice_trap(z64_game_t* game, uint32_t draw_id);
59+
void draw_bronze_scale(z64_game_t* game, uint32_t draw_id);
5960

6061
#endif

ASM/c/item_draw_table.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ item_draw_table_entry_t item_draw_table[] = {
179179
[0xA1] = { draw_gi_deku_nut_with_flame, { 0x06000E90, 0xC0C0C0FF, 0xC0C0C0FF } }, // Deku Nut Upgrade w/ Smoke Effect
180180
[0xA2] = { draw_gi_magic_meter, { 0x06000000, 0x06000CC0, 0x06000F08, 0x060014E8, 0x286428FF, 0x000000FF } }, // Magic Meter Scroll 2
181181
[0xA3] = { draw_ice_trap, { 0x04034380 } }, // Ice trap
182+
[0x94] = { draw_bronze_scale, { 0x06000AA0, 0x06000A40, 0x06000A80, 0x06000CC8 } }, // Bronze scale
182183
};
183184

184185
void base_draw_gi_model(z64_game_t* game, uint32_t draw_id) {

ASM/c/item_effects.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,20 @@ void unlock_ocarina_note(z64_file_t* save, int16_t arg1, int16_t arg2) {
283283
break;
284284
}
285285
}
286+
287+
void give_progressive_scale(z64_file_t* save, int16_t arg1, int16_t arg2) {
288+
switch(arg1) {
289+
case 0: // Bronze scale
290+
extended_savectx.extended_scale[0] = 1;
291+
break;
292+
case 1:
293+
extended_savectx.extended_scale[0] = 2;
294+
save->diving_upgrade = 1;
295+
break;
296+
case 2:
297+
extended_savectx.extended_scale[0] = 3;
298+
save->diving_upgrade = 2;
299+
break;
300+
}
301+
302+
}

ASM/c/item_effects.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void give_bombchus(z64_file_t* save, int16_t arg1, int16_t arg2);
3131
void trade_quest_upgrade(z64_file_t* save, int16_t item_id, int16_t arg2);
3232
extern uint8_t KEYRING_BOSSKEY_CONDITION;
3333
void unlock_ocarina_note(z64_file_t* save, int16_t arg1, int16_t arg2);
34+
void give_progressive_scale(z64_file_t* save, int16_t arg1, int16_t arg2);
3435

3536
typedef enum dungeon {
3637
DEKU_ID = 0,

ASM/c/item_upgrades.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "get_items.h"
44
#include "item_table.h"
5+
#include "save.h"
56
#include "z64.h"
67

78
extern uint32_t FREE_BOMBCHU_DROPS;
@@ -17,7 +18,7 @@ typedef struct {
1718
uint8_t magic : 2; // 0 = no magic, 1 = single magic, 2 = double magic
1819
uint8_t sticks : 2; // 0 = no sticks, 1 = 10, 2 = 20, 3 = 30
1920
uint8_t nuts : 2; // 0 = no nuts, 1 = 20, 2 = 30, 3 = 40
20-
uint8_t scale : 2; // 0 = no scale, 1 = silver scale, 2 = gold scale
21+
uint8_t scale : 3; // 0 = no scale, 1 = bronze_scale, 2 = silver scale, 3 = gold scale
2122
uint8_t wallet : 2; // 0 = 99, 1 = 200, 2 = 500, 3 = 999
2223
uint8_t slingshot : 2; // 0 = no slingshot, 1 = 30, 2 = 40, 3 = 50
2324
uint8_t bow : 2; // 0 = no bow, 1 = 30, 2 = 40, 3 = 50

ASM/c/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "debug.h"
2525
#include "inputviewer.h"
2626
#include "message.h"
27+
#include "swim.h"
2728

2829
void Gameplay_InitSkybox(z64_game_t* globalCtx, int16_t skyboxId);
2930

@@ -69,6 +70,7 @@ void after_game_state_update() {
6970
}
7071
close_rando_display_buffer();
7172
give_sage_gifts();
73+
manage_swim();
7274
}
7375

7476
void before_skybox_init(z64_game_t* game, int16_t skyboxId) {

ASM/c/save.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ typedef struct {
99
bool collected_dungeon_rewards[8];
1010
override_t incoming_queue[3];
1111
uint8_t password[6];
12+
uint8_t extended_scale[0x2];
1213
} extended_savecontext_static_t __attribute__ ((aligned (8)));
1314

1415

ASM/c/swim.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#include "swim.h"
2+
3+
RespawnByScene respawnsByScene[] = {
4+
{ 0x1D9, { { -1455, -20, 1384 }, 28761 }}, // Hyrule Field to Zora River (in water)
5+
{ 0x311, { { 5852, -20, 3725 }, -20025 }}, // Zora River to Hyrule Field (in water)
6+
{ 0x4DA, { { 1978, -36, -855 }, -16384 }}, // Zora River to Lost Woods
7+
{ 0x1DD, { { 4082, 860, -1018 }, -32768 }}, // Lost Woods to Zora River
8+
{ 0x219, { { -3276, -1033, 2908 }, 11228 }}, // Gerudo Valley to Lake Hylia
9+
{ 0x3D4, { { -2361, 0, 610 }, 32768 }}, // Ice Cavern to Zora Fountain
10+
{ 0x21D, { { -955, -1306, 6768 }, -32768 }}, // Water Temple to Lake Hylia
11+
{ 0x328, { { -109, 11, -9 }, -29131 }}, // Lake Hylia to Zora Domain
12+
{ 0x560, { { -912, -1326, 3391 }, 0 }}, // Zora Domain to Lake Hylia
13+
{ 0x10E, { { -1500, 150, 1600 }, 32768}}, // Sapphire cutscene to Zora Fountain
14+
};
15+
16+
void set_new_respawn() {
17+
18+
uint8_t newRespawnTrue = 0;
19+
int32_t currentEntranceIndex = z64_game.entrance_index;
20+
for (uint8_t i = 0; i < 10; i++) {
21+
// Ensure we always respawn at a safe location.
22+
if (currentEntranceIndex == respawnsByScene[i].scene_index) {
23+
z64_Play_SetupRespawnPoint(&z64_game, 0x01, 0xDFF);
24+
z64_file.respawn[RESPAWN_MODE_RETURN].pos = respawnsByScene[i].respawnInfo.pos;
25+
z64_file.respawn[RESPAWN_MODE_RETURN].yaw = respawnsByScene[i].respawnInfo.yaw;
26+
z64_file.respawn_flag = 2;
27+
z64_game.scene_load_flag = 0x14;
28+
newRespawnTrue = 1;
29+
break;
30+
}
31+
}
32+
33+
// Special case for Water Temple river area, so that player respawns at the start of the room.
34+
if (z64_game.scene_index == 5 && z64_game.room_index == 21) {
35+
z64_Play_SetupRespawnPoint(&z64_game, 0x01, 0xDFF);
36+
z64_xyzf_t riverPos = {-3063, 380, -4066};
37+
z64_file.respawn[RESPAWN_MODE_RETURN].pos = riverPos;
38+
z64_file.respawn[RESPAWN_MODE_RETURN].yaw = 9010;
39+
z64_file.respawn_flag = 2;
40+
z64_game.scene_load_flag = 0x14;
41+
return;
42+
}
43+
44+
if (newRespawnTrue == 0) {
45+
z64_game.entrance_index = z64_file.entrance_index;
46+
z64_game.fadeout_transition = 0x02;
47+
z64_file.respawn_flag = -2;
48+
z64_game.scene_load_flag = 0x14;
49+
}
50+
}
51+
52+
void manage_swim() {
53+
54+
// We found the first scale.
55+
if (extended_savectx.extended_scale[0] > 0) {
56+
return;
57+
}
58+
59+
// Iron boots are equipped.
60+
if (z64_file.equip_boots == 2) {
61+
return;
62+
}
63+
64+
// Always allow to swim out of water temple to avoid softlocks.
65+
if (z64_game.scene_index == 5 && z64_link.common.pos_world.z > 700.0) {
66+
return;
67+
}
68+
69+
if (z64_link.state_flags_1 & 0x08000000) { // Swimming state flag.
70+
set_new_respawn();
71+
}
72+
}

ASM/c/swim.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef SWIM_H
2+
#define SWIM_H
3+
4+
#include "z64.h"
5+
#include "save.h"
6+
7+
typedef struct {
8+
/* 0x00 */ z64_xyzf_t pos;
9+
/* 0x0C */ uint16_t yaw;
10+
} SpecialRespawnInfo; // size = 0x10
11+
12+
typedef struct {
13+
int32_t scene_index;
14+
SpecialRespawnInfo respawnInfo;
15+
} RespawnByScene;
16+
17+
void manage_swim();
18+
19+
#endif

0 commit comments

Comments
 (0)