Skip to content

Commit 4700ba3

Browse files
committed
Rob and Kirox's Extended Save Context Adventure
1 parent dbd63eb commit 4700ba3

11 files changed

Lines changed: 24819 additions & 58405 deletions

File tree

ASM/build/asm_symbols.txt

Lines changed: 577 additions & 570 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ASM/build/bundle.o

2.61 KB
Binary file not shown.

ASM/build/c_symbols.txt

Lines changed: 568 additions & 554 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ASM/c/file_icons.c

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "hud_colors.h"
55
#include "triforce.h"
66
#include "ocarina_buttons.h"
7+
#include "save.h"
78

89
#define ICON_SIZE 0x0C
910
#define MUSIC_WIDTH 0x06
@@ -172,6 +173,7 @@ static const variable_tile_data_t variable_tile_positions[NUM_VARIABLE] = {
172173
{0, {0x4E, 0x2A}}, // Strength
173174
{0, {0x5A, 0x2A}}, // Scale
174175
};
176+
static uint8_t bronze_scale_marker = 0;
175177

176178
typedef struct {
177179
colorRGB8_t color;
@@ -380,8 +382,9 @@ static void populate_child_trade(const z64_file_t* file, variable_tile_t* tile);
380382
static void populate_adult_trade(const z64_file_t* file, variable_tile_t* tile);
381383
static void populate_magic(const z64_file_t* file, variable_tile_t* tile);
382384
static void populate_upgrade_equip(const z64_file_t* file, variable_tile_t* tile, uint8_t value, uint8_t max, uint8_t base_tile);
385+
static void populate_upgrade_scale(const z64_file_t* file, variable_tile_t* tile, uint8_t value, uint8_t base_tile);
383386

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

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

396400

@@ -519,6 +523,11 @@ static void draw_variable(z64_disp_buf_t* db, const variable_tile_info_t* info,
519523
color = WHITE;
520524
color.a = color_product(color.a, alpha);
521525
}
526+
if (bronze_scale_marker) {
527+
sprite_load(db, &item_digit_sprite, 0, 1);
528+
sprite_draw(db, &item_digit_sprite, 0, get_left(variable_tile_positions[NUM_VARIABLE - 1].pos) + 4,
529+
get_top(variable_tile_positions[NUM_VARIABLE - 1].pos) + 3, 6, 6);
530+
}
522531
}
523532

524533

@@ -935,3 +944,22 @@ static void populate_upgrade_equip(const z64_file_t* file, variable_tile_t* tile
935944
tile->tile_index = base_tile + (value - 1);
936945
}
937946
}
947+
948+
static void populate_upgrade_scale(const z64_file_t* file, variable_tile_t* tile, uint8_t value, uint8_t base_tile) {
949+
tile->tile_index = base_tile;
950+
bronze_scale_marker = 0;
951+
if (value == 0) {
952+
bronze_scale_marker = 1;
953+
tile->enabled = 0;
954+
}
955+
if (value == 1) {
956+
tile->enabled = 0;
957+
}
958+
if (value == 2) {
959+
tile->enabled = 1;
960+
}
961+
if (value == 3) {
962+
tile->enabled = 1;
963+
tile->tile_index++;
964+
}
965+
}

ASM/c/item_effects.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,14 @@ void unlock_ocarina_note(z64_file_t* save, int16_t arg1, int16_t arg2) {
271271
void give_progressive_scale(z64_file_t* save, int16_t arg1, int16_t arg2) {
272272
switch(arg1) {
273273
case 0: // Bronze scale
274-
extended_savectx.extended_scale[0] = 1;
274+
extended_savectx.extended_scale = 1;
275275
break;
276276
case 1:
277-
extended_savectx.extended_scale[0] = 2;
277+
extended_savectx.extended_scale = 2;
278278
save->diving_upgrade = 1;
279279
break;
280280
case 2:
281-
extended_savectx.extended_scale[0] = 3;
281+
extended_savectx.extended_scale = 3;
282282
save->diving_upgrade = 2;
283283
break;
284284
}

ASM/c/item_upgrades.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ uint16_t wallet_upgrade(z64_file_t* save, override_t override) {
8383
}
8484

8585
uint16_t scale_upgrade(z64_file_t* save, override_t override) {
86-
switch ((override.value.base.player == PLAYER_ID || !MW_PROGRESSIVE_ITEMS_ENABLE) ? extended_savectx.extended_scale[0] : MW_PROGRESSIVE_ITEMS_STATE[override.value.base.player].scale) {
86+
switch ((override.value.base.player == PLAYER_ID || !MW_PROGRESSIVE_ITEMS_ENABLE) ? extended_savectx.extended_scale : MW_PROGRESSIVE_ITEMS_STATE[override.value.base.player].scale) {
8787
case 0: return 0x119; // Bronze Scale
8888
case 1: return 0x37; // Silver Scale
8989
default: return 0x38; // Gold Scale

ASM/c/save.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
// Struct for storing additional data in SRAM. This has to always be a multiple of 2 bytes long supposedly.
77
typedef struct {
88
uint8_t silver_rupee_counts[0x16];
9-
uint8_t extended_scale[0x2];
9+
uint8_t extended_scale;
10+
uint8_t pad;
1011
} extended_savecontext_static_t __attribute__ ((aligned (8)));
1112

1213

ASM/c/swim.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void set_new_respawn() {
5252
void manage_swim() {
5353

5454
// We found the first scale.
55-
if (extended_savectx.extended_scale[0] > 0) {
55+
if (extended_savectx.extended_scale > 0) {
5656
return;
5757
}
5858

@@ -62,11 +62,14 @@ void manage_swim() {
6262
}
6363

6464
// 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) {
65+
if (z64_game.scene_index == 5 &&
66+
z64_game.room_index == 0 &&
67+
z64_link.common.pos_world.z > 700.0) {
6668
return;
6769
}
6870

6971
if (z64_link.state_flags_1 & 0x08000000) { // Swimming state flag.
72+
PlaySFX(0x28CD); // NA_SE_EV_WATER_CONVECTION
7073
set_new_respawn();
7174
}
7275
}

ASM/c/z64.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "z64_math.h"
66
#include "color.h"
77
#include "z64collision_check.h"
8+
#include "save.h"
89

910
#define Z64_OOT10 0x00
1011
#define Z64_OOT11 0x01
@@ -796,7 +797,10 @@ typedef struct {
796797
} SramContext; // size = 0x4
797798

798799
typedef struct {
799-
uint8_t data[0xBA8];
800+
union {
801+
uint8_t data[0xBA8];
802+
extended_savecontext_static_t extended;
803+
};
800804
} extended_save_data_t;
801805

802806
typedef struct {

0 commit comments

Comments
 (0)