Пример #1
0
def town_map(filename_in, filename_out):
    t_map = open(filename_in).read(1024)
    pixels = []
    for row in range(32):
        for shape_row in range(16):
            for col in range(32):
                for shape_col in range(16):
                    town_offset = 32 * row + col
                    pixels.append(SHAPES[ord(t_map[town_offset])][16 * shape_row + shape_col])
    write_png(filename_out, 512, 512, pixels)
Пример #2
0
def town_map(filename_in, filename_out):
    t_map = open(filename_in, 'rb').read(1024)
    pixels = []
    for row in range(32):
        for shape_row in range(16):
            for col in range(32):
                for shape_col in range(16):
                    town_offset = 32 * row + col
                    pixels.append(SHAPES[t_map[town_offset]][16 * shape_row + shape_col])
    write_png(filename_out, 512, 512, pixels)
Пример #3
0
def rle(filename_in, filename_out, w, h):
    pixels = []
    bytes = open(filename_in).read()

    state = 0
    for d in map(ord, bytes):
        if state == 0:
            if d == 0x02:
                state = 1
            else:
                a, b = divmod(d, 16)
                pixels.append(EGA2RGB[a])
                pixels.append(EGA2RGB[b])
        elif state == 1:
            run = d
            state = 2
        elif state == 2:
            for i in range(run):
                a, b = divmod(d, 16)
                pixels.append(EGA2RGB[a])
                pixels.append(EGA2RGB[b])
            state = 0

    write_png(filename_out, w, h, pixels)
Пример #4
0
def main(args):
    romfile = args[0]
    outdir = args[1]
    mkdir(outdir)
    mkdir(os.path.join(outdir, "shiny"))
    mkdir(os.path.join(outdir, "back"))
    mkdir(os.path.join(outdir, "back", "shiny"))

    with gzopen(romfile) as f:
        info = get_rom_info(f)

        sprite_count = info['MonsterPicCount']

        front_pointers = read_pointers(f, info['MonsterPics'], sprite_count)
        back_pointers = read_pointers(f, info['MonsterBackPics'], sprite_count)
        palette_pointers = read_pointers(f, info['MonsterPals'], sprite_count)
        shiny_pointers = read_pointers(f, info['MonsterShinyPals'], sprite_count)

        for i in range(0, sprite_count):
            outname = "%s.png" % i

            pixels = read_sprite(f, front_pointers[i])
            if back_pointers[i] < palette_pointers[i]:
                back_pixels = read_sprite(f, back_pointers[i])
                palette = read_palette(f, palette_pointers[i])
            else:
                palette = read_palette(f, palette_pointers[i])
                back_pixels = read_sprite(f, back_pointers[i])
            shiny_palette = read_palette(f, shiny_pointers[i])

            # XXX Castform and Deoxys have multiple forms. The sprites (and
            # palettes, in Castform's case) are all lumped together. They
            # should be split into separate images.
            write_png(pixels, palette, os.path.join(outdir, outname))
            write_png(pixels, shiny_palette, os.path.join(outdir, "shiny", outname))

            write_png(back_pixels, palette, os.path.join(outdir, "back", outname))
            write_png(back_pixels, shiny_palette, os.path.join(outdir, "back", "shiny", outname))

    return 0
Пример #5
0
with open("ULT/MAP", "rb") as f:
    britannia = []
    for yy in range(8):
        britannia_row = []
        for xx in range(8):
            block = []
            for y in range(16):
                row = []
                for x in range(8):
                    a, b, c = f.read(3)
                    d, e = divmod(c * 256 * 256 + b * 256 + a, 4096)
                    row.append(e)
                    row.append(d)
                block.append(row)
            britannia_row.append(block)
        britannia.append(britannia_row)

pixels = []
for yy in range(8):
    for y in range(16):
        for cy in range(8):
            for xx in range(8):
                for x in range(16):
                    for cx in range(8):
                        tile = chunks[britannia[yy][xx][y][x]][cy][cx]
                        r, gb = divmod(tile, 64)
                        g, b = divmod(gb, 4)
                        pixels.append((r << 6, g << 4, b << 6))
png.write_png("map.png", 1024, 1024, pixels)
Пример #6
0
#!/usr/bin/env python

from png import write_png

from shapes import load_shapes


SHAPES = load_shapes()


world = open("ULT/WORLD.MAP").read()
pixels = []
for chunk_row in range(8):
    for row in range(32):
        for shape_row in range(16):
            for chunk_col in range(8):
                for col in range(32):
                    for shape_col in range(16):
                        world_offset = (8 * chunk_row + chunk_col) * 1024 + (32 * row + col)
                        pixels.append(SHAPES[ord(world[world_offset])][16 * shape_row + shape_col])

write_png("world.png", 4096, 4096, pixels)