Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_type(self):
self.assertEqual(self.rom.type, ROMType.LoROM)
def test_type(self):
self.assertEqual(self.rom.type, ROMType.HiROM)
def _discover_subtype(self) -> ROMType:
markup = self.read_byte(Header.MARKUP)
if (self.type == ROMType.LoROM) and (markup & 0b10):
return ROMType.ExLoROM
elif (self.type == ROMType.HiROM) and (markup & 0b100):
return ROMType.ExHiROM
return self.type
def _translate(self, address: int) -> int:
# Translate address from SNES to PC format.
if self.type == ROMType.LoROM:
pc = ((address & 0x7F0000) >> 1) | (address & 0x7FFF)
elif self.type == ROMType.ExLoROM:
if address & 0x800000:
pc = ((address & 0x7F0000) >> 1) | (address & 0x7FFF)
else:
pc = (((address & 0x7F0000) >> 1) | (address & 0x7FFF)) + 0x400000
elif self.type == ROMType.HiROM:
pc = address & 0x3FFFFF
elif self.type == ROMType.ExHiROM:
if (address & 0xC00000) != 0xC00000:
pc = (address & 0x3FFFFF) | 0x400000
else:
pc = address & 0x3FFFFF
def _discover_subtype(self) -> ROMType:
markup = self.read_byte(Header.MARKUP)
if (self.type == ROMType.LoROM) and (markup & 0b10):
return ROMType.ExLoROM
elif (self.type == ROMType.HiROM) and (markup & 0b100):
return ROMType.ExHiROM
return self.type
def _discover_type(self) -> ROMType:
if len(self.data) <= 0x8000:
return ROMType.LoROM
lorom_score = self._type_score(ROMType.LoROM)
hirom_score = self._type_score(ROMType.HiROM)
if hirom_score > lorom_score:
return ROMType.HiROM
else:
return ROMType.LoROM