Esempio n. 1
0
from coilsnake.exceptions.common.exceptions import TableSchemaError, \
    TableEntryError
from coilsnake.model.common.table import LittleEndianIntegerTableEntry, \
    RowTableEntry, TableEntry
from coilsnake.model.eb.table import EbEventFlagTableEntry

EnemyGroupTableEntry = RowTableEntry.from_schema(
    name="Enemy Group Entry",
    schema=[
        LittleEndianIntegerTableEntry.create("Amount", 1),
        LittleEndianIntegerTableEntry.create("Enemy", 2)
    ])

MapEnemyGroupHeaderTableEntry = RowTableEntry.from_schema(
    name="Map Enemy Group Header Table Entry",
    schema=[
        EbEventFlagTableEntry,
        type("Rate1", (LittleEndianIntegerTableEntry, ), {
            "name": "Sub-Group 1 Rate",
            "size": 1
        }),
        type("Rate2", (LittleEndianIntegerTableEntry, ), {
            "name": "Sub-Group 2 Rate",
            "size": 1
        })
    ])

MapEnemySubGroupTableEntry = RowTableEntry.from_schema(
    name="Map Enemy Sub-Group Table Entry",
    schema=[
        type("Probability", (LittleEndianIntegerTableEntry, ), {
Esempio n. 2
0
    def flipped_hash(self):
        self.flip_horizontally()
        h = self.hash()
        self.flip_horizontally()
        return h


SPRITE_SIZES = [
    "16x16", "16x16 2", "24x16", "32x16", "48x16", "16x24", "24x24", "16x32",
    "32x32", "48x32", "24x40", "16x48", "32x48", "48x48", "64x48", "64x64",
    "64x80"
]
SpriteGroupSizeTableEntry = EnumeratedLittleEndianIntegerTableEntry.create(
    "Size", 1, SPRITE_SIZES)
SpriteGroupCollisionNSWidthEntry = LittleEndianIntegerTableEntry.create(
    "North/South Collision Width", 1)
SpriteGroupCollisionNSHeightEntry = LittleEndianIntegerTableEntry.create(
    "North/South Collision Height", 1)
SpriteGroupCollisionEWWidthEntry = LittleEndianIntegerTableEntry.create(
    "East/West Collision Width", 1)
SpriteGroupCollisionEWHeightEntry = LittleEndianIntegerTableEntry.create(
    "East/West Collision Height", 1)

SpriteGroupHeaderTableEntry = RowTableEntry.from_schema(
    name="Sprite Group Header Table Entry",
    schema=[
        LittleEndianIntegerTableEntry.create("Height", 1),
        LittleEndianIntegerTableEntry.create("Width",
                                             1), SpriteGroupSizeTableEntry,
        LittleEndianIntegerTableEntry.create("Palette", 1),
        SpriteGroupCollisionNSWidthEntry, SpriteGroupCollisionNSHeightEntry,
Esempio n. 3
0
from coilsnake.exceptions.common.exceptions import TableSchemaError, \
    TableEntryError
from coilsnake.model.common.table import LittleEndianIntegerTableEntry, \
    RowTableEntry, TableEntry
from coilsnake.model.eb.table import EbEventFlagTableEntry


EnemyGroupTableEntry = RowTableEntry.from_schema(
    name="Enemy Group Entry",
    schema=[LittleEndianIntegerTableEntry.create("Amount", 1),
            LittleEndianIntegerTableEntry.create("Enemy", 2)]
)

MapEnemyGroupHeaderTableEntry = RowTableEntry.from_schema(
    name="Map Enemy Group Header Table Entry",
    schema=[EbEventFlagTableEntry,
            type("Rate1", (LittleEndianIntegerTableEntry,), {"name": "Sub-Group 1 Rate", "size": 1}),
            type("Rate2", (LittleEndianIntegerTableEntry,), {"name": "Sub-Group 2 Rate", "size": 1})]
)

MapEnemySubGroupTableEntry = RowTableEntry.from_schema(
    name="Map Enemy Sub-Group Table Entry",
    schema=[type("Probability", (LittleEndianIntegerTableEntry,), {"name": "Probability", "size": 1}),
            type("EnemyGroup", (LittleEndianIntegerTableEntry,), {"name": "Enemy Group", "size": 2})]
)


class MapEnemyGroupTableEntry(TableEntry):
    name = "Map Enemy Group Table Entry"

    @classmethod
Esempio n. 4
0
from functools import partial

from coilsnake.model.common.table import LittleEndianIntegerTableEntry
from coilsnake.model.eb.blocks import EbCompressibleBlock
from coilsnake.model.eb.graphics import EbGraphicTileset
from coilsnake.model.eb.palettes import EbPalette
from coilsnake.model.eb.table import EbEventFlagTableEntry
from coilsnake.util.eb.helper import is_in_bank


CHARACTERS = "0123456789abcdefghijklmnopqrstuv"

SpritePaletteIdTableEntry = LittleEndianIntegerTableEntry.create(name="Sprite Palette", size=1)
FlashEffectTableEntry = LittleEndianIntegerTableEntry.create(name="Flash Effect", size=1)


class EbMapPalette(EbPalette):
    def __init__(self):
        super(EbMapPalette, self).__init__(num_subpalettes=6, subpalette_length=16)
        self.flag = 0
        self.flag_palette = None
        self.flag_palette_pointer = None
        self.sprite_palette_id = 0
        self.flash_effect = 0

    def from_block(self, block, offset=0):
        self.flag = block.read_multi(offset, 2)
        if self.flag != 0:
            alternate_address = block.read_multi(offset + 0x20, 2) | 0x1a0000
            self.flag_palette = EbMapPalette()
            self.flag_palette.from_block(block, offset=alternate_address)
Esempio n. 5
0
from functools import partial

from coilsnake.model.common.table import LittleEndianIntegerTableEntry
from coilsnake.model.eb.blocks import EbCompressibleBlock
from coilsnake.model.eb.graphics import EbGraphicTileset
from coilsnake.model.eb.palettes import EbPalette
from coilsnake.model.eb.table import EbEventFlagTableEntry
from coilsnake.util.eb.helper import is_in_bank

CHARACTERS = "0123456789abcdefghijklmnopqrstuv"

SpritePaletteIdTableEntry = LittleEndianIntegerTableEntry.create(
    name="Sprite Palette", size=1)
FlashEffectTableEntry = LittleEndianIntegerTableEntry.create(
    name="Flash Effect", size=1)


class EbMapPalette(EbPalette):
    def __init__(self):
        super(EbMapPalette, self).__init__(num_subpalettes=6,
                                           subpalette_length=16)
        self.flag = 0
        self.flag_palette = None
        self.flag_palette_pointer = None
        self.sprite_palette_id = 0
        self.flash_effect = 0

    def from_block(self, block, offset=0):
        self.flag = block.read_multi(offset, 2)
        if self.flag != 0:
            alternate_address = block.read_multi(offset + 0x20, 2) | 0x1a0000
Esempio n. 6
0
    ["None", "Onett", "Twoson", "Threed", "Fourside", "Scaraba", "Summers", "None 2"]
)
SETTING_ENTRY = EnumeratedLittleEndianIntegerTableEntry.create(
    "Setting", 1,
    ["None", "Indoors", "Exit Mouse usable", "Lost Underworld sprites", "Magicant sprites", "Robot sprites",
     "Butterflies", "Indoors and Butterflies"]
)
TOWNMAP_IMAGE_ENTRY = EnumeratedLittleEndianIntegerTableEntry.create(
    "Town Map Image", 1,
    ["None", "Onett", "Twoson", "Threed", "Fourside", "Scaraba", "Summers"]
)
TOWNMAP_ARROW_ENTRY = EnumeratedLittleEndianIntegerTableEntry.create(
    "Town Map Arrow", 1,
    ["None", "Up", "Down", "Right", "Left"]
)
TOWNMAP_X = LittleEndianIntegerTableEntry.create("Town Map X", 1)
TOWNMAP_Y = LittleEndianIntegerTableEntry.create("Town Map Y", 1)

SectorYmlTable = RowTableEntry.from_schema(
    name="Aggregate Sector Properties Table Entry",
    schema=[LittleEndianIntegerTableEntry.create("Tileset", 1),
            LittleEndianIntegerTableEntry.create("Palette", 1),
            LittleEndianIntegerTableEntry.create("Music", 1),
            TELEPORT_ENTRY,
            TOWNMAP_ENTRY,
            SETTING_ENTRY,
            LittleEndianIntegerTableEntry.create("Item", 1),
            TOWNMAP_ARROW_ENTRY,
            TOWNMAP_IMAGE_ENTRY,
            TOWNMAP_X,
            TOWNMAP_Y]
Esempio n. 7
0
        return (self.width / 8) * (self.height / 8) * 32

    def hash(self):
        return hash_tile(self.data)

    def flipped_hash(self):
        self.flip_horizontally()
        h = self.hash()
        self.flip_horizontally()
        return h


SPRITE_SIZES = ["16x16", "16x16 2", "24x16", "32x16", "48x16", "16x24", "24x24", "16x32", "32x32", "48x32", "24x40",
                "16x48", "32x48", "48x48", "64x48", "64x64", "64x80"]
SpriteGroupSizeTableEntry = EnumeratedLittleEndianIntegerTableEntry.create("Size", 1, SPRITE_SIZES)
SpriteGroupCollisionNSWidthEntry = LittleEndianIntegerTableEntry.create("North/South Collision Width", 1)
SpriteGroupCollisionNSHeightEntry = LittleEndianIntegerTableEntry.create("North/South Collision Height", 1)
SpriteGroupCollisionEWWidthEntry = LittleEndianIntegerTableEntry.create("East/West Collision Width", 1)
SpriteGroupCollisionEWHeightEntry = LittleEndianIntegerTableEntry.create("East/West Collision Height", 1)

SpriteGroupHeaderTableEntry = RowTableEntry.from_schema(
    name="Sprite Group Header Table Entry",
    schema=[LittleEndianIntegerTableEntry.create("Height", 1),
            LittleEndianIntegerTableEntry.create("Width", 1),
            SpriteGroupSizeTableEntry,
            LittleEndianIntegerTableEntry.create("Palette", 1),
            SpriteGroupCollisionNSWidthEntry,
            SpriteGroupCollisionNSHeightEntry,
            SpriteGroupCollisionEWWidthEntry,
            SpriteGroupCollisionEWHeightEntry,
            LittleEndianIntegerTableEntry.create("Bank", 1)])