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

Add chu bag flag to multiworld progressive items state #2079

Merged
merged 1 commit into from
Sep 16, 2023
Merged
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
662 changes: 331 additions & 331 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
262 changes: 131 additions & 131 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions ASM/c/item_upgrades.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ extern uint32_t FREE_BOMBCHU_DROPS;
// The layout of this struct is part of the definition of the co-op context.
// If you change it, bump the co-op context version in coop_state.asm and update Notes/coop-ctx.md
typedef struct {
uint16_t _pad : 10; // reserved for future use
uint16_t _pad : 9; // reserved for future use
bool chu_bag : 1; // added in version 6 of the co-op context
uint8_t ocarina : 2; // 0 = no ocarina, 1 = fairy ocarina, 2 = ocarina of time
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
Expand Down Expand Up @@ -162,7 +163,7 @@ uint16_t health_upgrade_cap(z64_file_t *save, override_t override) {
}

uint16_t bombchus_to_bag(z64_file_t *save, override_t override) {
if (save->items[Z64_SLOT_BOMBCHU] == -1 && FREE_BOMBCHU_DROPS) {
if (FREE_BOMBCHU_DROPS && ((override.value.base.player == PLAYER_ID || !MW_PROGRESSIVE_ITEMS_ENABLE) ? save->items[Z64_SLOT_BOMBCHU] == -1 : !MW_PROGRESSIVE_ITEMS_STATE[override.value.base.player].chu_bag)) {
// First chu pack found, convert to bombchu bag to
// tell player about chu drops. Different bags
// to preserve original chu refill count.
Expand Down
2 changes: 1 addition & 1 deletion ASM/src/coop_state.asm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
COOP_CONTEXT:

COOP_VERSION:
.word 5 ; Increment this if layout of co-op state changes
.word 6 ; Increment this if layout of co-op state changes

PLAYER_ID:
.byte 0x00 ; Written by frontend
Expand Down
6 changes: 3 additions & 3 deletions Notes/coop-ctx.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The **co-op context** is a region of memory where a portion of the randomizer's configuration variables are stored in a versioned layout defined below. It is the interface used by emulator plugins to implement [Multiworld](https://wiki.ootrandomizer.com/index.php?title=Multiworld).

The starting address of the co-op context is listed at address `0x8040_0000` (at the start of the randomizer context). 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 co-op context and defines the layout of the remainder of the context according to the sections below. The current version is 5.
The starting address of the co-op context is listed at address `0x8040_0000` (at the start of the randomizer context). 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 co-op context and defines the layout of the remainder of the context according to the sections below. The current version is 6.

# Version 1

Expand All @@ -14,7 +14,7 @@ The starting address of the co-op context is listed at address `0x8040_0000` (at
|`0x0e`|`OUTGOING_PLAYER`|1|`0x0002`|The world number of the outgoing item's recipient, or `0` if no item is being sent. The multiworld plugin should set this to `0` after handling an outgoing item.|
|`0x10`|`PLAYER_NAMES`|1|`0x0800`|An array of 256 player names, each 8 bytes long, that must be populated by the multiworld plugin. `PLAYER_NAME_ID` is used as an index into this array, and index 0 is unused.|

# Versions 2–5
# Versions 2–6

|Offset|Name|Min version|Size|Description|
|--:|---|--:|--:|---|
Expand All @@ -29,4 +29,4 @@ The starting address of the co-op context is listed at address `0x8040_0000` (at
|`0x0012`|`OUTGOING_PLAYER`|2|`0x0002`|The world number of the outgoing item's recipient, or `0` if no item is being sent. The multiworld plugin should set this to `0` after handling an outgoing item.|
|`0x0014`|`PLAYER_NAMES`|2|`0x0800`|An array of 256 player names, each 8 bytes long, that must be populated by the multiworld plugin. `PLAYER_NAME_ID` is used as an index into this array, and index 0 is unused.|
|`0x0814`|`CFG_FILE_SELECT_HASH`|4|`0x0005`|The 5 icons displayed at the top of the file select screen, represented as indices into the `HASH_ICONS` list in Spoiler.py.|
|`0x081c`|`MW_PROGRESSIVE_ITEMS_STATE`|5|`0x0400`|The multiworld plugin can store data representing the state of progressive items of all players here. If `MW_PROGRESSIVE_ITEMS_ENABLE` is set to `1`, the game will use this to render outgoing progressive items instead of basing them on the sender's inventory. The data is an array of 256 bitfields, each 4 bytes long, with the entry at index 0 unused. For documentation of the bitflags, see `mw_progressive_items_state_t` in `item_upgrades.c`.|
|`0x081c`|`MW_PROGRESSIVE_ITEMS_STATE`|5|`0x0400`|The multiworld plugin can store data representing the state of progressive items of all players here. If `MW_PROGRESSIVE_ITEMS_ENABLE` is set to `1`, the game will use this to render outgoing progressive items instead of basing them on the sender's inventory. The data is an array of 256 bitfields, each 4 bytes long, with the entry at index 0 unused. For documentation of the bitflags, see `mw_progressive_items_state_t` in `item_upgrades.c`. Note that the `chu_bag` flag only has any effect in versions 6+ of the co-op context.|
Loading