Skip to content

Commit

Permalink
Fix set events and missables
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Aug 22, 2024
1 parent 5747701 commit 9fe4eac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pokemonred_puffer/data/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2594,8 +2594,9 @@ def set_event(self, event_name: str, value: bool):
idx = [x[0] for x in self.b._fields_].index(event_name)
addr = EVENT_FLAGS_START + idx // 8
bit = idx % 8
mask = int(value) << bit

self.emu.memory[addr] = self.emu.memory[addr] & int(value) << bit
self.emu.memory[addr] = (self.emu.memory[addr] & ~mask) | mask
setattr(self.b, event_name, int(value))


Expand Down
3 changes: 2 additions & 1 deletion pokemonred_puffer/data/missable_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def set_missable(self, missable: str, value: bool):
idx = [x[0] for x in self.b._fields_].index(missable)
addr = 0xD5A6 + idx // 8
bit = idx % 8
mask = int(value) << bit

self.emu.memory[addr] = self.emu.memory[addr] & int(value) << bit
self.emu.memory[addr] = (self.emu.memory[addr] & ~mask) | mask
setattr(self.b, missable, int(value))

0 comments on commit 9fe4eac

Please sign in to comment.