From c7ee0eb4c9738328f91a0aabebde4156a24e1bc7 Mon Sep 17 00:00:00 2001 From: thatguy11325 <148832074+thatguy11325@users.noreply.github.com> Date: Wed, 28 Aug 2024 11:58:01 -0400 Subject: [PATCH] Add in new status flags file --- pokemonred_puffer/data/status_flags.py | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 pokemonred_puffer/data/status_flags.py diff --git a/pokemonred_puffer/data/status_flags.py b/pokemonred_puffer/data/status_flags.py new file mode 100644 index 0000000..7e5fa42 --- /dev/null +++ b/pokemonred_puffer/data/status_flags.py @@ -0,0 +1,27 @@ +from ctypes import LittleEndianStructure, Union, c_uint8 + +from pyboy import PyBoy + + +class StatusFlags1Bits(LittleEndianStructure): + _fields_ = [ + ("USING_STRENGTH_OUTSIDE_OF_BATTLE", c_uint8, 1), + ("IS_SURFING_ALLOWED", c_uint8, 1), + ("UNUSED_0", c_uint8, 1), + ("RECEIVED_OLD_ROD", c_uint8, 1), + ("RECEIVED_GOOD_ROD", c_uint8, 1), + ("RECEIVED_SUPER_ROD", c_uint8, 1), + ("GAVE_SAFFRON_GUARD_DRINK", c_uint8, 1), + ("UNUSED_2", c_uint8, 1), + ] + + +class StatusFlags1(Union): + _fields_ = [("b", StatusFlags1Bits), ("asbytes", c_uint8)] + + def __init__(self, emu: PyBoy): + super().__init__() + self.asbytes = (c_uint8)(emu.memory[emu.symbol_lookup("wStatusFlags1")[1]]) + + def get_bit(self, bit: str) -> bool: + return bool(getattr(self.b, bit))