Skip to content

Commit 6a62810

Browse files
committed
Merge 'Move CFG_{ADULT,CHILD}_TRADE_SHUFFLE into auto-tracker context' (#2156)
2 parents 5d1aa8d + bdffd1e commit 6a62810

14 files changed

Lines changed: 37877 additions & 37873 deletions

File tree

ASM/build/asm_symbols.txt

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

ASM/build/bundle.o

0 Bytes
Binary file not shown.

ASM/c/dpad.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ extern uint8_t CFG_DPAD_ON_THE_LEFT;
3232
0x00200000 | \
3333
0x08000000)
3434

35-
extern uint16_t CFG_ADULT_TRADE_SHUFFLE;
36-
extern uint16_t CFG_CHILD_TRADE_SHUFFLE;
35+
extern uint8_t CFG_ADULT_TRADE_SHUFFLE;
36+
extern uint8_t CFG_CHILD_TRADE_SHUFFLE;
3737

3838
#define CAN_DRAW_TRADE_DPAD (z64_game.pause_ctxt.state == PAUSE_STATE_MAIN && \
3939
z64_game.pause_ctxt.screen_idx == 0 && \

ASM/c/get_items.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#include "en_item00.h"
77
#include "override.h"
88

9-
extern uint16_t CFG_ADULT_TRADE_SHUFFLE;
10-
extern uint16_t CFG_CHILD_TRADE_SHUFFLE;
9+
extern uint8_t CFG_ADULT_TRADE_SHUFFLE;
10+
extern uint8_t CFG_CHILD_TRADE_SHUFFLE;
1111

1212
void item_overrides_init();
1313
void handle_pending_items();

ASM/c/trade_quests.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "trade_quests.h"
22

3-
extern uint16_t CFG_ADULT_TRADE_SHUFFLE;
3+
extern uint8_t CFG_ADULT_TRADE_SHUFFLE;
44

55
const exchange_item_t trade_quest_items[] = {
66
{ 0, Z64_ITEM_WEIRD_EGG, Z64_EXCH_ITEM_WEIRD_EGG, PLAYER_AP_WEIRD_EGG , 0 }, // "Weird Egg"

ASM/src/config.asm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ CFG_DUNGEON_PRECOMPLETED:
264264
; Any changes made here should be documented in Notes/auto-tracker-ctx.md
265265
AUTO_TRACKER_CONTEXT:
266266
AUTO_TRACKER_VERSION:
267-
.word 4 ; Increment this if the auto-tracker context layout changes
267+
.word 5 ; Increment this if the auto-tracker context layout changes
268268

269269
CFG_DUNGEON_INFO_ENABLE:
270270
.word 0
@@ -326,4 +326,9 @@ SPECIAL_DEAL_COUNTS:
326326
CFG_DUNGEON_REWARD_AREAS:
327327
.endarea
328328

329+
CFG_ADULT_TRADE_SHUFFLE:
330+
.byte 0x00
331+
CFG_CHILD_TRADE_SHUFFLE:
332+
.byte 0x00
333+
329334
.align 4

ASM/src/shop.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ set_mask_text_hook:
272272
sw v1, 0x14(sp)
273273
sw ra, 0x18(sp)
274274

275-
lh v0, CFG_CHILD_TRADE_SHUFFLE
275+
lbu v0, CFG_CHILD_TRADE_SHUFFLE
276276
beqz v0, @@return_mask_text
277277
nop
278278
jal SaveFile_TradeItemIsOwned
@@ -295,7 +295,7 @@ set_mask_sold_out:
295295
sw a1, 0x14(sp)
296296
sw ra, 0x1C(sp)
297297

298-
lh v0, CFG_CHILD_TRADE_SHUFFLE
298+
lbu v0, CFG_CHILD_TRADE_SHUFFLE
299299
beqz v0, @@return_mask_so
300300
nop
301301

ASM/src/trade_quests.asm

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
CFG_ADULT_TRADE_SHUFFLE:
2-
.halfword 0x0000
3-
CFG_CHILD_TRADE_SHUFFLE:
4-
.halfword 0x0000
51
ADULT_ANJU_ITEM_DIALOG:
62
.word 0x00000000
73

@@ -89,7 +85,7 @@ check_skull_kid_spawn_flags:
8985
check_if_biggoron_should_cry_eye_hook:
9086
addiu sp, sp, -0x18
9187
sw ra, 0x14(sp)
92-
lh v0, CFG_ADULT_TRADE_SHUFFLE
88+
lbu v0, CFG_ADULT_TRADE_SHUFFLE
9389
beqz v0, @@vanilla_eye_hook
9490
nop
9591
jal check_if_biggoron_should_cry
@@ -108,7 +104,7 @@ check_if_biggoron_should_cry_eye_hook:
108104
check_if_biggoron_should_cry_anim_hook:
109105
addiu sp, sp, -0x18
110106
sw ra, 0x14(sp)
111-
lh v0, CFG_ADULT_TRADE_SHUFFLE
107+
lbu v0, CFG_ADULT_TRADE_SHUFFLE
112108
beqz v0, @@vanilla_anim_hook
113109
nop
114110
jal check_if_biggoron_should_cry
@@ -130,7 +126,7 @@ check_if_biggoron_should_cry_sfx_hook:
130126
addiu sp, sp, -0x18
131127
sw a3, 0x10(sp)
132128
sw ra, 0x14(sp)
133-
lh v0, CFG_ADULT_TRADE_SHUFFLE
129+
lbu v0, CFG_ADULT_TRADE_SHUFFLE
134130
beqz v0, @@vanilla_sfx_hook
135131
nop
136132
jal check_if_biggoron_should_cry
@@ -159,7 +155,7 @@ check_if_biggoron_should_cry:
159155
sw ra, 0x1C(sp)
160156

161157
; Don't change behavior if trade shuffle is off
162-
lh at, CFG_ADULT_TRADE_SHUFFLE
158+
lbu at, CFG_ADULT_TRADE_SHUFFLE
163159
beqz at, @@return_crybaby
164160
nop
165161

@@ -234,9 +230,9 @@ check_trade_item_traded:
234230

235231
; Default behavior if Adult and Child
236232
; Trade Quest Shuffles Off
237-
lh t3, CFG_ADULT_TRADE_SHUFFLE
233+
lbu t3, CFG_ADULT_TRADE_SHUFFLE
238234
bnez t3, @@check_trade_flags
239-
lh t3, CFG_CHILD_TRADE_SHUFFLE
235+
lbu t3, CFG_CHILD_TRADE_SHUFFLE
240236
beqz t3, @@return_traded
241237
nop
242238

@@ -290,7 +286,7 @@ check_if_mask_sells_out:
290286
or v1, $zero, $zero
291287

292288
; Skip giving item if partial/full mask shuffle enabled
293-
lh v1, CFG_CHILD_TRADE_SHUFFLE
289+
lbu v1, CFG_CHILD_TRADE_SHUFFLE
294290

295291
@@return_sold_out:
296292
jr ra
@@ -449,7 +445,7 @@ set_bunny_hood_traded_flag:
449445
;==================================================================================================
450446

451447
handle_child_zelda_savewarp:
452-
lh v0, CFG_CHILD_TRADE_SHUFFLE
448+
lbu v0, CFG_CHILD_TRADE_SHUFFLE
453449
bnez v0, @@return
454450
nop
455451

Notes/auto-tracker-ctx.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The **auto-tracker context** is a region of memory where a portion of the randomizer's configuration variables are stored in a versioned layout defined below. Its intent is to give some symbols added by the randomizer well-defined addresses so that auto-trackers can read them reliably without needing the symbols.json for the specific randomizer version that was used to generate the seed.
22

3-
The starting address of the auto-tracker context is listed at address `0x8040_000C` (randomizer context + `0xC`). On versions of the randomizer before this feature was added, the starting address is given as zero. At that address, a 4-byte integer can be found. This is the version number of the auto-tracker context and defines the layout of the remainder of the context according to the sections below. The current version is 4.
3+
The starting address of the auto-tracker context is listed at address `0x8040_000C` (randomizer context + `0xC`). On versions of the randomizer before this feature was added, the starting address is given as zero. At that address, a 4-byte integer can be found. This is the version number of the auto-tracker context and defines the layout of the remainder of the context according to the sections below. The current version is 5.
44

55
# Versions 1–2
66

@@ -27,24 +27,26 @@ The starting address of the auto-tracker context is listed at address `0x8040_00
2727

2828
Special care needs to be taken when working with version 3 of the auto-tracker context, since a breaking change was made in version 6.2.181 of the randomizer without an accompanying change to the auto-tracker context version. Versions 6.2.180 of the randomizer and earlier use the same layout as version 2 described above (with the addition of the `CFG_DUNGEON_REWARD_AREAS` field), while versions 6.2.181 and later use the same layout as version 4 described below. The version number at addresses 0x35–0x37 of the ROM header may be used to check for the randomizer version, but this may not be accurate for forks of the randomizer if they merged the change early.
2929

30-
# Version 4
30+
# Versions 4–5
3131

3232
|Offset|Name|Min version|Size|Description|
3333
|--:|---|--:|--:|---|
34-
|`0x04`|`CFG_DUNGEON_INFO_ENABLE`|4|`0x04`|Defines how information about dungeons will be displayed on the inventory screen on the pause menu. `0` = disabled, `1` = a single menu shown when holding A, `2` = separate menus shown when holding D-pad buttons in addition to the summary menu on A.|
35-
|`0x08`|`CFG_DUNGEON_INFO_MQ_ENABLE`|1|`0x04`|`1` if the dungeon info in the pause menu should include info about which dungeons are in Master Quest mode.|
36-
|`0x0C`|`CFG_DUNGEON_INFO_MQ_NEED_MAP`|1|`0x04`|`1` if the Master Quest info should only be displayed for dungeons whose maps have been obtained or which don't have maps.|
37-
|`0x10`|`CFG_DUNGEON_INFO_REWARD_ENABLE`|1|`0x04`|`1` if the dungeon info in the pause menu should include info about which medallions and stones are in which dungeon.|
38-
|`0x14`|`CFG_DUNGEON_INFO_REWARD_NEED_COMPASS`|1|`0x04`|Defines which item is required to display the location of a dungeon reward in the pause menu. `0` = no item required, `1` = the compass of the dungeon in which the reward is found, `2` = the compass of the reward's vanilla dungeon. For example, if the Kokiri Emerald is in the Fire Temple, `1` means the Fire Temple compass is required and `2` means the Deku Tree compass is required.|
39-
|`0x18`|`CFG_DUNGEON_INFO_REWARD_NEED_ALTAR`|1|`0x04`|`1` if the reward info should only be displayed for rewards whose Temple of Time altar text boxes have been read.|
40-
|`0x1C`|`CFG_DUNGEON_INFO_REWARD_SUMMARY_ENABLE`|4|`0x04`|`1` if the summary menu shown when holding A should display dungeon reward locations.|
41-
|`0x20`|`CFG_DUNGEON_REWARDS`|4|`0x0E`|A byte representing the medallion or stone for each dungeon. Dungeons without rewards are listed as `0xFF`, and one reward is chosen arbitrarily if the dungeon has multiple rewards. For more complete data, use `CFG_DUNGEON_REWARD_AREAS` instead.|
42-
|`0x2E`|`CFG_DUNGEON_IS_MQ`|4|`0x0E`|A byte set to `1` for each dungeon in Master Quest mode.|
43-
|`0x3C`|`RAINBOW_BRIDGE_CONDITION`|4|`0x04`|The condition for spawning the rainbow bridge. `0` = open, `1` = medallions, `2` = dungeon rewards, `3` = stones, `4` = vanilla, `5` = tokens, `6` = hearts.|
44-
|`0x40`|`LACS_CONDITION`|4|`0x04`|The condition for triggering the light arrow cutscene. `0` = vanilla, `1` = medallions, `2` = dungeons, `3` = stones, `4` = tokens, `5` = hearts.|
45-
|`0x44`|`RAINBOW_BRIDGE_COUNT`|4|`0x02`|The number of items (of the kind defined in `RAINBOW_BRIDGE_CONDITION`) required to spawn the rainbow bridge.|
46-
|`0x46`|`LACS_CONDITION_COUNT`|4|`0x02`|The number of items (of the kind defined in `LACS_CONDITION`) required to trigger the light arrow cutscene.|
47-
|`0x48`|`TRIFORCE_HUNT_ENABLED`|4|`0x02`|`1` if Triforce hunt is enabled.|
48-
|`0x4A`|`TRIFORCE_PIECES_REQUIRED`|4|`0x02`|In Triforce hunt, the total number of Triforce pieces (across all worlds) required to win the game.|
49-
|`0x4C`|`SPECIAL_DEAL_COUNTS`|4|`0x08`|A byte representing the number of special deal slots in each shop, in the following order: KF Shop, Market Bazaar, Market Potion Shop, Market Bombchu Shop, Kak Bazaar, Kak Potion Shop, GC Shop, ZD Shop.|
50-
|`0x54`|`CFG_DUNGEON_REWARD_AREAS`|4|`0xCF`|For each dungeon reward in the order of Emerald, Ruby, Sapphire, Light, Forest, Fire, Water, Shadow, and Spirit, a null-terminated `0x16`-byte (`0x17` including the null terminator) ASCII string containing the hint area of that reward, padded with spaces on the right.|
34+
|`0x0004`|`CFG_DUNGEON_INFO_ENABLE`|4|`0x04`|Defines how information about dungeons will be displayed on the inventory screen on the pause menu. `0` = disabled, `1` = a single menu shown when holding A, `2` = separate menus shown when holding D-pad buttons in addition to the summary menu on A.|
35+
|`0x0008`|`CFG_DUNGEON_INFO_MQ_ENABLE`|1|`0x04`|`1` if the dungeon info in the pause menu should include info about which dungeons are in Master Quest mode.|
36+
|`0x000C`|`CFG_DUNGEON_INFO_MQ_NEED_MAP`|1|`0x04`|`1` if the Master Quest info should only be displayed for dungeons whose maps have been obtained or which don't have maps.|
37+
|`0x0010`|`CFG_DUNGEON_INFO_REWARD_ENABLE`|1|`0x04`|`1` if the dungeon info in the pause menu should include info about which medallions and stones are in which dungeon.|
38+
|`0x0014`|`CFG_DUNGEON_INFO_REWARD_NEED_COMPASS`|1|`0x04`|Defines which item is required to display the location of a dungeon reward in the pause menu. `0` = no item required, `1` = the compass of the dungeon in which the reward is found, `2` = the compass of the reward's vanilla dungeon. For example, if the Kokiri Emerald is in the Fire Temple, `1` means the Fire Temple compass is required and `2` means the Deku Tree compass is required.|
39+
|`0x0018`|`CFG_DUNGEON_INFO_REWARD_NEED_ALTAR`|1|`0x04`|`1` if the reward info should only be displayed for rewards whose Temple of Time altar text boxes have been read.|
40+
|`0x001C`|`CFG_DUNGEON_INFO_REWARD_SUMMARY_ENABLE`|4|`0x04`|`1` if the summary menu shown when holding A should display dungeon reward locations.|
41+
|`0x0020`|`CFG_DUNGEON_REWARDS`|4|`0x0E`|A byte representing the medallion or stone for each dungeon. Dungeons without rewards are listed as `0xFF`, and one reward is chosen arbitrarily if the dungeon has multiple rewards. For more complete data, use `CFG_DUNGEON_REWARD_AREAS` instead.|
42+
|`0x002E`|`CFG_DUNGEON_IS_MQ`|4|`0x0E`|A byte set to `1` for each dungeon in Master Quest mode.|
43+
|`0x003C`|`RAINBOW_BRIDGE_CONDITION`|4|`0x04`|The condition for spawning the rainbow bridge. `0` = open, `1` = medallions, `2` = dungeon rewards, `3` = stones, `4` = vanilla, `5` = tokens, `6` = hearts.|
44+
|`0x0040`|`LACS_CONDITION`|4|`0x04`|The condition for triggering the light arrow cutscene. `0` = vanilla, `1` = medallions, `2` = dungeons, `3` = stones, `4` = tokens, `5` = hearts.|
45+
|`0x0044`|`RAINBOW_BRIDGE_COUNT`|4|`0x02`|The number of items (of the kind defined in `RAINBOW_BRIDGE_CONDITION`) required to spawn the rainbow bridge.|
46+
|`0x0046`|`LACS_CONDITION_COUNT`|4|`0x02`|The number of items (of the kind defined in `LACS_CONDITION`) required to trigger the light arrow cutscene.|
47+
|`0x0048`|`TRIFORCE_HUNT_ENABLED`|4|`0x02`|`1` if Triforce hunt is enabled.|
48+
|`0x004A`|`TRIFORCE_PIECES_REQUIRED`|4|`0x02`|In Triforce hunt, the total number of Triforce pieces (across all worlds) required to win the game.|
49+
|`0x004C`|`SPECIAL_DEAL_COUNTS`|4|`0x08`|A byte representing the number of special deal slots in each shop, in the following order: KF Shop, Market Bazaar, Market Potion Shop, Market Bombchu Shop, Kak Bazaar, Kak Potion Shop, GC Shop, ZD Shop.|
50+
|`0x0054`|`CFG_DUNGEON_REWARD_AREAS`|4|`0xCF`|For each dungeon reward in the order of Emerald, Ruby, Sapphire, Light, Forest, Fire, Water, Shadow, and Spirit, a null-terminated `0x16`-byte (`0x17` including the null terminator) ASCII string containing the hint area of that reward, padded with spaces on the right.|
51+
|`0x0123`|`CFG_ADULT_TRADE_SHUFFLE`|5|`0x01`|`1` if the item-cycling functionality for the adult trade inventory slot is enabled.|
52+
|`0x0124`|`CFG_CHILD_TRADE_SHUFFLE`|5|`0x01`|`1` if the item-cycling functionality for the child trade inventory slot is enabled.|

Patches.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,10 +763,10 @@ def set_entrance_updates(entrances: Iterable[Entrance]) -> None:
763763
rom.write_int16s(0xB6D460, [0x0030, 0x0035, 0x0036]) # Change trade items revert table to prevent all reverts
764764

765765
if world.settings.adult_trade_shuffle or world.settings.item_pool_value in ('plentiful', 'ludicrous'):
766-
rom.write_int16(rom.sym('CFG_ADULT_TRADE_SHUFFLE'), 0x0001)
766+
rom.write_byte(rom.sym('CFG_ADULT_TRADE_SHUFFLE'), 0x01)
767767
move_fado_in_lost_woods(rom)
768768
if world.settings.shuffle_child_trade or world.settings.logic_rules == 'glitched':
769-
rom.write_int16(rom.sym('CFG_CHILD_TRADE_SHUFFLE'), 0x0001)
769+
rom.write_byte(rom.sym('CFG_CHILD_TRADE_SHUFFLE'), 0x01)
770770

771771
if world.settings.shuffle_overworld_entrances:
772772
rom.write_byte(rom.sym('OVERWORLD_SHUFFLED'), 1)

0 commit comments

Comments
 (0)