@@ -110,6 +110,46 @@ def safe_to_send(self):
110110 countdown_value = self .n64_client .read_u8 (memory_location + DK64MemoryMap .safety_text_timer )
111111 return countdown_value == 0
112112
113+ def _getShopStatus (self , p_type : int , p_value : int , p_kong : int ) -> bool :
114+ if p_type == 0xFFFF :
115+ return False
116+ if p_value == 0 :
117+ return False
118+ if p_kong > 4 :
119+ p_kong = 0
120+ kong_base = 0x807FC950 + (p_kong * 0x5E )
121+ if p_type < 5 :
122+ val = self .n64_client .read_u8 (kong_base + p_type )
123+ if p_type in (1 , 3 ):
124+ # Slam, Ammo Belt
125+ return val >= p_type
126+ else :
127+ return (val & (1 << (p_value - 1 ))) != 0
128+ else :
129+ return self .readFlag (p_value ) != 0
130+
131+ def getCheckStatus (self , check_type , flag_index = None , shop_index = None , level_index = None , kong_index = None ) -> bool :
132+ # shop_index: 0 = cranky, 1 = funky, 2 = candy, 3=bfi
133+ # flag_index: as expected
134+ if check_type == "shop" :
135+ if shop_index == 3 :
136+ header = 0x807FF6E8
137+ else :
138+ header = 0x807FF400 + (shop_index * 0xF0 ) + (kong_index * 0x30 ) + (level_index * 6 )
139+ purchase_type = self .n64_client .read_u16 (header + 0 )
140+ purchase_value = self .n64_client .read_u16 (header + 2 )
141+ purchase_kong = self .n64_client .read_u8 (header + 4 )
142+ return self ._getShopStatus (purchase_type , purchase_value , purchase_kong )
143+ else :
144+ for flut_index in range (0x400 ):
145+ raw_flag = self .n64_client .read_u16 (0x807E2EE0 + (4 * flut_index ))
146+ if raw_flag == flag_index :
147+ target_flag = self .n64_client .read_u16 (0x807E2EE0 + (4 * flut_index ) + 2 )
148+ return self .readFlag (target_flag ) != 0
149+ elif raw_flag == 0xFFFF :
150+ return self .readFlag (flag_index ) != 0
151+
152+ # TODO: We need to modify this function to use getCheckStatus instead of the gameboy logic
113153 async def readChecks (self , cb ):
114154 new_checks = []
115155 for check in self .remaining_checks :
0 commit comments