Ejemplo n.º 1
0
    def _parse_structure_data_block(self, rom: Rom):
        structure_block_offset = rom.little_endian(STRUCTURE_DATA_OFFSETS +
                                                   OFFSET_SIZE *
                                                   self.world_index)

        self.structure_block_start = WORLD_MAP_BASE_OFFSET + structure_block_offset

        # the indexes into the y_pos list, where the levels for the n-th screen start
        y_pos_start_by_screen = rom.read(self.structure_block_start, 4)

        level_y_pos_list_start = WORLD_MAP_BASE_OFFSET + rom.little_endian(
            LEVEL_Y_POS_LISTS + OFFSET_SIZE * self.world_index)

        level_x_pos_list_start = WORLD_MAP_BASE_OFFSET + rom.little_endian(
            LEVEL_X_POS_LISTS + OFFSET_SIZE * self.world_index)

        level_y_pos_list_end = level_x_pos_list_start - level_y_pos_list_start

        self.level_count_s1 = y_pos_start_by_screen[1] - y_pos_start_by_screen[
            0]
        self.level_count_s2 = y_pos_start_by_screen[2] - y_pos_start_by_screen[
            1]
        self.level_count_s3 = y_pos_start_by_screen[3] - y_pos_start_by_screen[
            2]
        self.level_count_s4 = level_y_pos_list_end - y_pos_start_by_screen[3]
Ejemplo n.º 2
0
def test_little_endian():
    rom_bytes = bytearray(b"\x00\x01\x02\x03\x04\x05\x06\x00")

    rom = Rom(rom_bytes)

    assert rom.little_endian(0) == (0x01 << 8) + 0x00
    assert rom.little_endian(6) == (0x00 << 8) + 0x06