Ejemplo n.º 1
0
    def __init__(self, object_set: int, palette_index: int):
        png = QImage(str(data_dir.joinpath("gfx.png")))

        png.convertTo(QImage.Format_RGB888)

        rows_per_object_set = 256 // 64

        y_offset = 12 * rows_per_object_set * Block.HEIGHT

        self.png_data = png.copy(QRect(0, y_offset, png.width(), png.height() - y_offset))

        self.palette_group = load_palette_group(object_set, palette_index)
Ejemplo n.º 2
0
    def __init__(self, parent):
        super(AboutDialog, self).__init__(parent, title="About SMB3Foundry")

        main_layout = QBoxLayout(QBoxLayout.LeftToRight, self)

        image = QPixmap(str(data_dir.joinpath("foundry.ico"))).scaled(200, 200)

        icon = QLabel(self)
        icon.setPixmap(image)

        main_layout.addWidget(icon)

        text_layout = QBoxLayout(QBoxLayout.TopToBottom)

        text_layout.addWidget(QLabel(f"SMB3 Foundry v{get_current_version_name()}", self))
        text_layout.addWidget(HorizontalLine())
        text_layout.addWidget(LinkLabel(self, f'By <a href="{LINK_SMB3F}">Michael</a>'))
        text_layout.addWidget((QLabel("", self)))
        text_layout.addWidget(QLabel("With thanks to:", self))
        text_layout.addWidget(
            LinkLabel(self, f'<a href="{LINK_HUKKA}">Hukka</a> for <a href="{LINK_SMB3WS}">SMB3 Workshop</a>')
        )
        text_layout.addWidget(
            LinkLabel(
                self,
                f'<a href="{LINK_SOUTHBIRD}">Captain Southbird</a> '
                f'for the <a href="{LINK_DISASM}">SMB3 Disassembly</a>',
            )
        )
        text_layout.addWidget(
            LinkLabel(self, f'<a href="{LINK_PIJOKRA}">PiJoKra</a> for helping to parse the disassembly')
        )
        text_layout.addWidget(
            LinkLabel(
                self,
                f'<a href="{LINK_BLUEFINCH}">BlueFinch</a>, ZacMario and '
                f'<a href="{LINK_SKY}">SKJyannick</a> for testing and sanity checking',
            )
        )
        text_layout.addWidget(
            QLabel(
                "Spinzig for compiling the enemy incompatibilities.",
                self
            )
        )

        main_layout.addLayout(text_layout)
Ejemplo n.º 3
0
def _load_level_offsets() -> Tuple[List[Mario3Level], List[int]]:
    offsets = [Mario3Level(0, 0, 0, 0, 0, "Placeholder")]
    world_indexes = [0]

    with open(data_dir.joinpath("levels.dat"), "r") as level_data:
        for line_no, line in enumerate(level_data.readlines()):
            data = line.rstrip("\n").split(",")

            numbers = [int(_hex, 16) for _hex in data[0:5]]
            level_name = data[5]

            game_world, level_in_world, rom_level_offset, enemy_offset, real_obj_set = numbers

            level = Mario3Level(game_world, level_in_world, rom_level_offset, enemy_offset, real_obj_set, level_name)

            offsets.append(level)

            if level.game_world > 0 and level.level_in_world == 1:
                world_indexes.append(line_no)

    return offsets, world_indexes
Ejemplo n.º 4
0
def load_object_definitions(object_set):
    global object_metadata

    object_definition = object_set_to_definition[object_set]

    if object_definition == ENEMY_OBJECT_DEFINITION:
        return object_metadata[object_definition]

    with open(data_dir.joinpath(f"romobjs{object_definition}.dat"),
              "rb") as obj_def:
        data = obj_def.read()

    assert len(data) > 0

    object_count = data[0]

    if object_definition != 0 and object_count < 0xF7:
        # first byte did not represent the object_count
        object_count = 0xFF
        position = 0
    else:
        position = 1

    for object_index in range(object_count):
        object_design_length = data[position]

        object_metadata[object_definition][
            object_index].object_design_length = object_design_length

        position += 1

        for i in range(object_design_length):
            block_index = data[position]

            if block_index == 0xFF:
                block_index = (data[position + 1] << 16) + (
                    data[position + 2] << 8) + data[position + 3]

                position += 3

            object_metadata[object_definition][object_index].rom_object_design[
                i] = block_index

            position += 1

    # read overlay data
    if position >= len(data):
        return

    for object_index in range(object_count):
        object_design_length = object_metadata[object_definition][
            object_index].object_design_length

        object_metadata[object_definition][object_index].object_design2 = []

        for i in range(object_design_length):
            if i <= object_design_length:
                object_metadata[object_definition][
                    object_index].object_design2.append(data[position])
                position += 1

    return object_metadata[object_definition]
Ejemplo n.º 5
0
        for index, item in enumerate(self.object_design):
            self.object_design[index] = int(item)  # original data
            self.object_design2.append(
                0)  # data after trimming through romobjset*.dat file?
            self.rom_object_design.append(self.object_design[index])
            self.object_design_length = index + 1  # todo necessary when we have len()?

        self.description = self.description.split("|")[0]


object_metadata: List[List[ObjectDefinition]] = [[]]
enemy_handle_x = []
enemy_handle_x2 = []
enemy_handle_y = []

with open(data_dir.joinpath("data.dat"), "r") as f:
    first_index = 0  # todo what are they symbolizing? object tables?
    second_index = 0

    for line in f.readlines():
        if line.startswith(";"):  # is a comment
            continue

        if line.rstrip() == "":
            object_metadata.append([])

            first_index += 1
            second_index = 0
            continue

        object_metadata[first_index].append(ObjectDefinition(line))