Ejemplo n.º 1
0
#!/bin/python

import os, sys
from ast import literal_eval
sys.path.append(os.path.join(os.path.dirname(__file__), 'common'))
from common import utils, tilesets

output_file = sys.argv[1]
input_file = sys.argv[2]
version_suffix = sys.argv[3]

prefix = "." + os.path.splitext(os.path.basename(input_file))[0]

char_table = utils.reverse_dict(
    utils.merge_dicts([
        tilesets.get_tileset("MainSpecial"),
        tilesets.get_tileset("MainDialog"),
        tilesets.get_tileset("dakuten", override_offset=0x0)
    ]))

try:
    with open(input_file, 'r', encoding="utf-8") as i, open(output_file,
                                                            'w') as o:
        term, prefixlen = literal_eval(i.readline().strip())
        ptrs = []

        version_check = "[{}]".format(version_suffix)
        for n, line in enumerate(i):
            if not line.startswith("[") or line.startswith(version_check):
                line = line.replace(
                    version_check,
Ejemplo n.º 2
0
import csv
import re
import sys

sys.path.append(os.path.join(os.path.dirname(__file__), 'common'))
from common import utils, tilesets

output_file = sys.argv[1]
input_file = sys.argv[2]
column_name = sys.argv[3]
version_suffix = sys.argv[4]

base_name = os.path.splitext(os.path.basename(input_file))[0]
char_table = utils.reverse_dict(
    utils.merge_dicts([
        tilesets.get_tileset("MainDialog1", override_offset=0x0),
        tilesets.get_tileset("MainDialog2", override_offset=0x80),
        tilesets.get_tileset("Special", override_offset=0xE0)
    ]))
kanji = utils.reverse_dict(tilesets.get_tileset("Kanji", override_offset=0x0))
assert ((set(kanji.keys()) - set(char_table.keys())) == set(kanji.keys()))
ptr_names = utils.read_table(os.path.join(os.path.dirname(__file__), 'res',
                                          'ptrs.tbl'),
                             keystring=True)

with open(input_file, 'r', encoding='utf-8-sig') as fp:
    reader = csv.reader(fp, delimiter=',', quotechar='"')
    header = next(reader, None)
    idx_index = header.index("Index[#version]")
    idx_pointer = header.index("Pointer[#version|]")
    idx_text = header.index(column_name)
Ejemplo n.º 3
0
    'Medarotters': ((0x20, 0x4328), 2, [None, 0xCB], [(3, 0x00), (None, None)],
                    [True, False], None, None),
    'Unknown10': ((0x20, 0x4EA4), 1, [None], [(35, 0x00)], [True], None, None),
    'Terrain': ((0x23, 0x7A23), 1, [0xCB], [(None, None)], [False], None,
                None),
    'Attacks': ((0x23, 0x7A80), 1, [0xCB], [(None, None)], [False], None,
                None),
    'CharacterNames': ((0x21, 0x4000), 1, [0xCB], [(None, None)], [False],
                       None, None),
    'Unknown14': ((0x21, 0x461B), 1, [None], [(11, 0x00)], [True], None, None),
    'Medarots': ((0x23, 0x4000), 1, [0xCB], [(None, None)], [False], None,
                 None),
})

tileset = utils.merge_dicts([
    tilesets.get_tileset("MainDialog1", override_offset=0x0),
    tilesets.get_tileset("MainDialog2", override_offset=0x80),
    tilesets.get_tileset("Special", override_offset=0xE0)
])

kanji = tilesets.get_tileset("Kanji", override_offset=0x0)

with open("./game/src/version/ptrlist_data.asm", "w") as datafile:
    datafile.write(
        f'INCLUDE "build/ptrlists/ptrlist_data_constants_{{GAMEVERSION}}.asm"\n\n'
    )
    for l in list_map:
        addr, spp, term, fix_len, print_hex, null_indicator, data_prefix = list_map[
            l]
        if isinstance(addr, tuple):
            bank = addr[0]
Ejemplo n.º 4
0
    ptrfile = None
    ptrtable = {}

    tileset_file = None
    tileset_table = {}
    tiletables = {}

    if os.path.exists("scripts/res/meta_tilemap_files.tbl"):
        ptrtable = utils.read_table("scripts/res/meta_tilemap_files.tbl")
    else:
        ptrfile = open("scripts/res/meta_tilemap_files.tbl", "w")

    # Load previously generated/manually written tilemap <-> tileset mapping
    tileset_default = utils.merge_dicts([
        tilesets.get_tileset("MainDialog"),
        tilesets.get_tileset("MainSpecial"),
    ])
    tileset_default[
        0xFE] = '\n'  # 0xFE is a special control code for a new line, not really a tile

    if os.path.exists("scripts/res/meta_tilemap_tilesets.tbl"):
        tileset_table = utils.read_table(
            "scripts/res/meta_tilemap_tilesets.tbl", keystring=True)
        for fname in tileset_table:
            if tileset_table[fname] not in tiletables:
                tiletables[tileset_table[fname]] = utils.merge_dicts([
                    utils.merge_dicts([
                        tilesets.get_tileset(tbl) for tbl in filter(
                            None, tileset_table[fname].split(","))
                    ])