mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 06:24:30 +00:00
Whitespace (#1112)
* remove trailing whitespaces * minor docs tweaks * some more trailing whitespaces * few more tweaks
This commit is contained in:
parent
f344fe648b
commit
f4a72303cb
150 changed files with 493 additions and 494 deletions
|
@ -103,7 +103,7 @@ def diff_syms(qb, tb):
|
|||
else:
|
||||
larger = tb
|
||||
smaller = qb
|
||||
|
||||
|
||||
len_ratio = len(smaller) / len(larger)
|
||||
|
||||
n_bytes = len(smaller)
|
||||
|
|
|
@ -100,7 +100,7 @@ def bootstrap(ovl_path, ovl_text):
|
|||
if init_data is None or len(init_data.regs) == 0:
|
||||
return ""
|
||||
init_data = data_text[init_data.regs[0][0]:init_data.regs[0][1]]
|
||||
|
||||
|
||||
lines = init_data.split("\n")
|
||||
|
||||
init_var_label = lines[0][7:]
|
||||
|
@ -167,14 +167,14 @@ def bootstrap(ovl_path, ovl_text):
|
|||
init_vars += indent + "(ActorFunc)Actor_Noop,\n"
|
||||
else:
|
||||
init_vars += indent + "(ActorFunc)" + init_func_name + ",\n"
|
||||
|
||||
|
||||
if destroy_func == "0x00000000":
|
||||
init_vars += indent + "NULL,\n"
|
||||
elif destroy_func == "Actor_Noop":
|
||||
init_vars += indent + "(ActorFunc)Actor_Noop,\n"
|
||||
else:
|
||||
init_vars += indent + "(ActorFunc)" + destroy_func_name + ",\n"
|
||||
|
||||
|
||||
if update_func == "0x00000000":
|
||||
init_vars += indent + "NULL,\n"
|
||||
elif update_func == "Actor_Noop":
|
||||
|
@ -188,7 +188,7 @@ def bootstrap(ovl_path, ovl_text):
|
|||
init_vars += indent + "(ActorFunc)Actor_Noop,\n"
|
||||
else:
|
||||
init_vars += indent + "(ActorFunc)" + draw_func_name + ",\n"
|
||||
|
||||
|
||||
init_vars += "};\n"
|
||||
|
||||
return struct_text + "\n" + defines + "\n" + decs + "\n/*\n" + init_vars + "*/"
|
||||
|
@ -208,7 +208,7 @@ def main():
|
|||
newline_spot = file_text.find("\n\n") + 1
|
||||
newfile_text = file_text[:newline_spot] + "\n" + bootstrap_text + file_text[newline_spot:]
|
||||
newfile_text = newfile_text.replace("\n\n\n\n\n", "\n")
|
||||
|
||||
|
||||
with open(file_path, "w", newline="\n") as f:
|
||||
f.write(newfile_text)
|
||||
else:
|
||||
|
|
|
@ -132,10 +132,10 @@ def get_header(header_path):
|
|||
ovl_name = path_split[-2]
|
||||
short_name = ovl_name[14:]
|
||||
init_vars_name = "".join(ovl_name[4:].split("_")) + "InitParams"
|
||||
|
||||
|
||||
ifndef = "#ifndef _Z_EFF_SS_" + short_name.upper() + "_H_\n" + \
|
||||
"#define _Z_EFF_SS_" + short_name.upper() + "_H_\n\n"
|
||||
|
||||
|
||||
includes = "#include <ultra64.h>\n#include <global.h>\n\n"
|
||||
|
||||
struct = "typedef struct {\n" + \
|
||||
|
|
|
@ -10,22 +10,22 @@ root_dir = script_dir + "/../"
|
|||
|
||||
def handle_match(match):
|
||||
original_text = match.group()
|
||||
|
||||
|
||||
match_text = original_text.replace("\\x", "")
|
||||
|
||||
if match_text.lower() == "1b":
|
||||
return original_text
|
||||
|
||||
|
||||
end = ""
|
||||
if original_text.lower().endswith("\\x1b"):
|
||||
end = original_text[-4:]
|
||||
match_text = match_text[:-2]
|
||||
|
||||
|
||||
try:
|
||||
text = bytes.fromhex(match_text).decode("EUC-JP")
|
||||
except UnicodeDecodeError:
|
||||
return original_text
|
||||
|
||||
|
||||
if text[2:].lower() == match_text.lower():
|
||||
return original_text
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ includes = "#include <ultra64.h>\n#include <global.h>\n\n"
|
|||
def remove_struct(root, filename):
|
||||
with open(os.path.join(root, filename)) as f:
|
||||
c_text = f.read()
|
||||
|
||||
|
||||
struct_start = c_text.find("typedef")
|
||||
struct_end = c_text.find("#define")
|
||||
|
||||
struct = c_text[struct_start:struct_end]
|
||||
|
||||
|
||||
newfile_text = "#include \"" + filename[:-2] + ".h\"" + "\n\n" + c_text[struct_end:]
|
||||
with open(os.path.join(root, filename), "w", newline="\n") as f:
|
||||
f.write(newfile_text)
|
||||
|
@ -51,7 +51,7 @@ def handle_file(root, filename):
|
|||
header_text += "extern const ActorInit " + init_vars_name + ";\n\n"
|
||||
|
||||
header_text += "#endif\n"
|
||||
|
||||
|
||||
with open(os.path.join(root, filename[:-2] + ".h"), "w", newline="\n") as f:
|
||||
f.write(header_text)
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ def disas_elfmsgs(start):
|
|||
assert False , "Encountered unknown type"
|
||||
|
||||
ARG_2 = f"{bool(b0 & 1)}".lower()
|
||||
|
||||
|
||||
# Get condition
|
||||
condition_type = b0 & 0x1E
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ static char *sprintf_alloc(const char *fmt, ...)
|
|||
va_end(args);
|
||||
|
||||
buffer = malloc(size);
|
||||
|
||||
|
||||
va_start(args, fmt);
|
||||
vsprintf(buffer, fmt, args);
|
||||
va_end(args);
|
||||
|
@ -155,7 +155,7 @@ static void parse_input_file(const char *filename)
|
|||
segment->romStart = find_rom_address(syms, numRomSymbols, segment->name, "Start");
|
||||
segment->romEnd = find_rom_address(syms, numRomSymbols, segment->name, "End");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
g_romSize = find_symbol_value(syms, numRomSymbols, "_RomSize");
|
||||
|
|
|
@ -46,7 +46,7 @@ static const void *get_section_contents(struct Elf32 *e, int secnum)
|
|||
{
|
||||
size_t secoffset = e->shoff + secnum * 0x28;
|
||||
size_t dataoffset;
|
||||
|
||||
|
||||
if (secnum >= e->shnum || secoffset >= e->dataSize)
|
||||
return NULL;
|
||||
dataoffset = e->read32(e->data + secoffset + 0x10);
|
||||
|
@ -102,14 +102,14 @@ bool elf32_init(struct Elf32 *e, const void *data, size_t size)
|
|||
e->shentsize = e->read16(e->data + 0x2E);
|
||||
e->shnum = e->read16(e->data + 0x30);
|
||||
e->shstrndx = e->read16(e->data + 0x32);
|
||||
|
||||
|
||||
// find symbol table section
|
||||
e->symtabndx = -1;
|
||||
for (i = 0; i < e->shnum; i++)
|
||||
{
|
||||
const uint8_t *sechdr = get_section_header(e, i);
|
||||
uint32_t type = e->read32(sechdr + 0x04);
|
||||
|
||||
|
||||
if (type == SHT_SYMTAB)
|
||||
{
|
||||
e->symtabndx = i;
|
||||
|
@ -123,12 +123,12 @@ bool elf32_init(struct Elf32 *e, const void *data, size_t size)
|
|||
{
|
||||
const uint8_t *sechdr = get_section_header(e, i);
|
||||
uint32_t type = e->read32(sechdr + 0x04);
|
||||
|
||||
|
||||
if (type == SHT_STRTAB)
|
||||
{
|
||||
const char *strings = get_section_contents(e, e->shstrndx);
|
||||
const char *secname = strings + e->read32(sechdr + 0);
|
||||
|
||||
|
||||
if (strcmp(secname, ".strtab") == 0)
|
||||
{
|
||||
e->strtabndx = i;
|
||||
|
@ -136,19 +136,19 @@ bool elf32_init(struct Elf32 *e, const void *data, size_t size)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
e->numsymbols = 0;
|
||||
if (e->symtabndx != -1)
|
||||
{
|
||||
const uint8_t *sechdr = get_section_header(e, e->symtabndx);
|
||||
//const uint8_t *symtab = get_section_contents(e, e->symtabndx);
|
||||
|
||||
|
||||
e->numsymbols = e->read32(sechdr + 0x14) / e->read32(sechdr + 0x24);
|
||||
}
|
||||
|
||||
if (e->shoff + e->shstrndx * 0x28 >= e->dataSize)
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,18 +23,18 @@ rm old_list.txt cur_list.txt old_data_list.txt data_list.txt list.txt
|
|||
|
||||
if [ "$1" = "-d" ]
|
||||
then
|
||||
if [ -s diff.txt ]
|
||||
then
|
||||
rm $(cat diff.txt)
|
||||
fi
|
||||
rm diff.txt
|
||||
if [ -s diff.txt ]
|
||||
then
|
||||
rm $(cat diff.txt)
|
||||
fi
|
||||
rm diff.txt
|
||||
else
|
||||
if [ -s diff.txt ]
|
||||
then
|
||||
cat diff.txt
|
||||
rm diff.txt
|
||||
exit 55
|
||||
else
|
||||
rm diff.txt
|
||||
fi
|
||||
if [ -s diff.txt ]
|
||||
then
|
||||
cat diff.txt
|
||||
rm diff.txt
|
||||
exit 55
|
||||
else
|
||||
rm diff.txt
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -45,9 +45,9 @@ def main():
|
|||
spec_text = spec_file.read()
|
||||
|
||||
spec_text_replaced = re.sub(".*ovl_.*\.o.*\n", handle_actor_line, spec_text)
|
||||
|
||||
|
||||
with open(root_dir + "spec", "w", newline="\n") as spec_file:
|
||||
spec_file.write(spec_text_replaced)
|
||||
|
||||
|
||||
main()
|
||||
main()
|
||||
|
|
|
@ -49,7 +49,7 @@ def remove_balign_after_float(file_text):
|
|||
def format_file(file_path):
|
||||
with open(file_path) as f:
|
||||
orig_file_text = f.read()
|
||||
|
||||
|
||||
file_text = orig_file_text
|
||||
|
||||
# Condense 2+ empty lines to 1
|
||||
|
|
|
@ -45,11 +45,11 @@ def count_non_matching():
|
|||
actor_funcs[f_name] = file_size
|
||||
|
||||
overlays[actor_dir] = {
|
||||
"summary": (num_files, max_size, total_size,
|
||||
"summary": (num_files, max_size, total_size,
|
||||
total_size / num_files),
|
||||
"funcs": actor_funcs
|
||||
}
|
||||
|
||||
|
||||
return overlays
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ def count_builded_funcs_and_instructions(f_path):
|
|||
f_lines = ""
|
||||
with open(f_path) as f:
|
||||
f_lines = f.readlines()
|
||||
|
||||
|
||||
current = ""
|
||||
funcs = {}
|
||||
for line in f_lines:
|
||||
|
@ -101,7 +101,7 @@ def count_build():
|
|||
|
||||
file_path = os.path.join(ovl_path, f_name)
|
||||
funcs = count_builded_funcs_and_instructions(file_path)
|
||||
|
||||
|
||||
if len(funcs) > 0:
|
||||
num_files += len(funcs)
|
||||
# round up the file size to a multiple of four.
|
||||
|
@ -111,7 +111,7 @@ def count_build():
|
|||
actor_funcs = {**actor_funcs, **funcs}
|
||||
|
||||
overlays[actor_dir] = {
|
||||
"summary": (num_files, max_size, total_size,
|
||||
"summary": (num_files, max_size, total_size,
|
||||
total_size / num_files),
|
||||
"funcs": actor_funcs
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ def get_actor_var_names():
|
|||
if "}" in line:
|
||||
# Reached the end of the actor struct so break out
|
||||
break
|
||||
|
||||
|
||||
# Parse out the memory address (from the comment) and the variable name
|
||||
regex = r'.*\/\* (.*) \*\/\s+(struct)?\s*.+\s+(.+);.*'
|
||||
actor_var_info = re.match(regex, line)
|
||||
|
@ -66,7 +66,7 @@ def main():
|
|||
parser.add_argument('offset', help='ROM offset or symbol of an InitChain')
|
||||
parser.add_argument('--names', action="store_true", help='Retrieve variable names from the actor struct')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
# Get the ROM address, if the offset is already a ROM address it will just be returned.
|
||||
args.offset = get_rom_address(args.offset)
|
||||
|
||||
|
@ -101,7 +101,7 @@ def main():
|
|||
var_name = actor_variable_names[var_name]
|
||||
else:
|
||||
var_name = "unk_" + var_name
|
||||
|
||||
|
||||
print(' {0}({1}, {2}, {3}),'.format(ICHAIN_MACROS[t], var_name, value, ('ICHAIN_CONTINUE' if cont == 1 else 'ICHAIN_STOP')))
|
||||
if cont == 0:
|
||||
break
|
||||
|
|
|
@ -103,7 +103,7 @@ def is_rodata(r):
|
|||
"""
|
||||
For given asm and rodata files, build a rodata section for the asm file
|
||||
"""
|
||||
def build_rodata(asm, rodata):
|
||||
def build_rodata(asm, rodata):
|
||||
contained_syms = [s for s in asm_syms(asm) if s in rodata_syms(rodata)]
|
||||
contained_blocks = [b for b in rodata_blocks(rodata) if rodata_sym(b) in contained_syms]
|
||||
# TODO include arrays in rodata_list
|
||||
|
@ -188,7 +188,7 @@ Processes each individual file
|
|||
data\code\
|
||||
"""
|
||||
def process_file(filename, identifier, delete_rodata):
|
||||
folder_path = "asm" + sep + "non_matchings" + sep + ("code" + sep if identifier=="code" else "overlays" + sep + identifier.lower() + sep + "ovl_") + filename + sep
|
||||
folder_path = "asm" + sep + "non_matchings" + sep + ("code" + sep if identifier=="code" else "overlays" + sep + identifier.lower() + sep + "ovl_") + filename + sep
|
||||
rodata_path = "data" + sep + (sep if identifier=="code" else "overlays" + sep + identifier.lower() + sep + "z_") + filename.lower() + ".rodata.s"
|
||||
if filename == "player":
|
||||
folder_path = "asm" + sep + "non_matchings" + sep + "overlays" + sep + "actors" + sep + "ovl_player_actor" + sep
|
||||
|
@ -227,7 +227,7 @@ def process_files(filenames, identifier, spechandle, delete_rodata):
|
|||
files = filenames.split(",")
|
||||
for f in files:
|
||||
process_file(f, identifier, delete_rodata)
|
||||
else:
|
||||
else:
|
||||
process_file(filenames, identifier, delete_rodata)
|
||||
if spechandle.lower() == "delete":
|
||||
modify_spec(filenames, identifier, True)
|
||||
|
@ -294,4 +294,3 @@ run(False)
|
|||
# command = "echo >> src/overlays/effects/ovl_" + effects[i] + "/z_" + effects[i].lower() + ".c"
|
||||
# os.system(command) # purpose of this is to "modify" each C file in order to prevent undefined symbol errors.
|
||||
# # the new line will be removed by format.sh
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc, char **argv)
|
|||
FILE *dmaout;
|
||||
void *spec;
|
||||
size_t size;
|
||||
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
usage(argv[0]);
|
||||
|
|
|
@ -88,7 +88,7 @@ static void write_ld_script(FILE *fout)
|
|||
fprintf(fout, " _%sSegmentDataEnd = .;\n", seg->name);
|
||||
|
||||
fprintf(fout, " _%sSegmentDataSize = ABSOLUTE( _%sSegmentDataEnd - _%sSegmentDataStart );\n", seg->name, seg->name, seg->name);
|
||||
|
||||
|
||||
fprintf(fout, " _%sSegmentRoDataStart = .;\n", seg->name);
|
||||
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
|
@ -135,7 +135,7 @@ static void write_ld_script(FILE *fout)
|
|||
|
||||
if (seg->fields & (1 << STMT_increment))
|
||||
fprintf(fout, " . += 0x%08X;\n", seg->increment);
|
||||
|
||||
|
||||
|
||||
fputs(" }\n", fout);
|
||||
//fprintf(fout, " _RomSize += ( _%sSegmentDataEnd - _%sSegmentTextStart );\n", seg->name, seg->name);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
#
|
||||
# message_data_static disassembler/decompiler
|
||||
#
|
||||
#
|
||||
|
||||
import re, struct
|
||||
from os import path
|
||||
|
@ -129,11 +129,11 @@ colors = {
|
|||
|
||||
highscores = {
|
||||
0x00 : "HS_HORSE_ARCHERY",
|
||||
0x01 : "HS_POE_POINTS",
|
||||
0x02 : "HS_LARGEST_FISH",
|
||||
0x03 : "HS_HORSE_RACE",
|
||||
0x04 : "HS_MARATHON",
|
||||
0x06 : "HS_DAMPE_RACE",
|
||||
0x01 : "HS_POE_POINTS",
|
||||
0x02 : "HS_LARGEST_FISH",
|
||||
0x03 : "HS_HORSE_RACE",
|
||||
0x04 : "HS_MARATHON",
|
||||
0x06 : "HS_DAMPE_RACE",
|
||||
}
|
||||
|
||||
def format_char(byte):
|
||||
|
@ -195,7 +195,7 @@ def decode(read_bytes, box_type):
|
|||
if byte == ord(ctrl):
|
||||
name = control_codes[ctrl]
|
||||
# single bytes
|
||||
if (name == "COLOR" or name == "SHIFT" or name == "BOX_BREAK_DELAYED" or
|
||||
if (name == "COLOR" or name == "SHIFT" or name == "BOX_BREAK_DELAYED" or
|
||||
name == "FADE" or name == "ITEM_ICON" or name == "TEXT_SPEED" or
|
||||
name == "HIGHSCORE"):
|
||||
buf.append("\" " + name + "(")
|
||||
|
@ -340,7 +340,7 @@ def dump_all_text():
|
|||
with open("baserom/ger_message_data_static","rb") as infile:
|
||||
infile.seek(ger_offset)
|
||||
ger_text = fixup_message(decode(infile.read(ger_length), entry[1]).replace("\x00","",-1))
|
||||
|
||||
|
||||
fra_offset = segmented_to_physical(entry[5])
|
||||
fra_length = next_entry[5] - entry[5]
|
||||
with open("baserom/fra_message_data_static","rb") as infile:
|
||||
|
|
|
@ -36,7 +36,7 @@ def CreateAddrLookup(dict, recs, tracer):
|
|||
print(length)
|
||||
recs.append((recs[length-1][1], None, None))
|
||||
recs = sorted(recs, key=lambda x: x[0], reverse=True)
|
||||
|
||||
|
||||
for i in range(length):
|
||||
if recs[i][0] != recs[i+1][1]:
|
||||
if tracer != "ra" or recs[i][0] != recs[i+1][1] + 0xFFF & -0x1000:
|
||||
|
@ -51,7 +51,7 @@ def CreateTable():
|
|||
vrecs = []
|
||||
rrecs = []
|
||||
vrecs.append((PVA(0x80157D90), PVA(0x80800000), None))
|
||||
|
||||
|
||||
dict = {
|
||||
"va" : {},
|
||||
"ra" : {},
|
||||
|
@ -67,14 +67,14 @@ def CreateTable():
|
|||
vrecs.append(vrec)
|
||||
dict["ft"][li[7]] = (rrec[0], rrec[1])
|
||||
file = None
|
||||
|
||||
|
||||
with open("filetable2.txt", "r") as file:
|
||||
for line in file:
|
||||
li = line.rstrip().split('\t')
|
||||
rrec = (int(li[2],16), int(li[3],16), li[5])
|
||||
rrecs.append(rrec)
|
||||
dict["ft"][li[5]] = (rrec[0], rrec[1])
|
||||
|
||||
|
||||
CreateAddrLookup(dict["va"], vrecs, "va")
|
||||
CreateAddrLookup(dict["ra"], rrecs, "ra")
|
||||
|
||||
|
@ -85,7 +85,7 @@ def AddressLookup(lookupTable, addr):
|
|||
start = 0;
|
||||
end = 0;
|
||||
key = None;
|
||||
|
||||
|
||||
for k, v in lookupTable.items():
|
||||
if addr >= k:
|
||||
start = k
|
||||
|
@ -93,13 +93,13 @@ def AddressLookup(lookupTable, addr):
|
|||
break
|
||||
end = k
|
||||
return (key, start, end)
|
||||
|
||||
|
||||
def GetFromVRam(addr):
|
||||
key, vramStart, vramEnd = AddressLookup(table["va"], PVA(addr))
|
||||
|
||||
|
||||
if key is None:
|
||||
return None
|
||||
|
||||
|
||||
ftl = table["ft"][key]
|
||||
vrom = AddrRange(ftl[0], ftl[1])
|
||||
vram = AddrRange(UVA(vramStart), UVA(vramEnd))
|
||||
|
@ -107,13 +107,13 @@ def GetFromVRam(addr):
|
|||
offset = addr - vram.start
|
||||
|
||||
return FileResult(key, vrom, vram, offset)
|
||||
|
||||
|
||||
def GetFromRom(addr):
|
||||
key, romStart, romEnd = AddressLookup(table["ra"], addr)
|
||||
|
||||
|
||||
if key is None:
|
||||
return None
|
||||
|
||||
|
||||
vrom = AddrRange(romStart, romEnd)
|
||||
offset = addr - vrom.start
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ def IND(n):
|
|||
|
||||
|
||||
scriptDir = os.path.dirname(os.path.realpath(__file__))
|
||||
repo = scriptDir + os.sep + ".." + os.sep + ".."
|
||||
repo = scriptDir + os.sep + ".." + os.sep + ".."
|
||||
|
||||
|
||||
kaleido_scope_data = []
|
||||
|
|
|
@ -110,7 +110,7 @@ for i in range(NUM_SCENES):
|
|||
cstr = HEADER
|
||||
|
||||
for scenemap in scenemaps:
|
||||
cstr += f"MapMarkData {GetDungeonSymbol(scenemap[0])}[] = {{\n"
|
||||
cstr += f"MapMarkData {GetDungeonSymbol(scenemap[0])}[] = {{\n"
|
||||
for mapId, map in enumerate(scenemap[1]):
|
||||
cstr += IND(1) + f"// {GetDungeonName(scenemap[0])} minimap {mapId}\n"
|
||||
cstr += IND(1) + "{\n"
|
||||
|
@ -130,7 +130,7 @@ for scenemap in scenemaps:
|
|||
|
||||
cstr += "MapMarkData* gMapMarkDataTable[] = {\n"
|
||||
for scenemap in scenemaps:
|
||||
cstr += f" {GetDungeonSymbol(scenemap[0])},\n"
|
||||
cstr += f" {GetDungeonSymbol(scenemap[0])},\n"
|
||||
cstr += "};\n"
|
||||
|
||||
with open(sys.argv[1], "w") as file:
|
||||
|
|
|
@ -42,7 +42,7 @@ def read_file(filename):
|
|||
|
||||
file_contents = file_contents[end:]
|
||||
match = pattern.search(file_contents)
|
||||
|
||||
|
||||
parsed_contents += file_contents
|
||||
return parsed_contents
|
||||
|
||||
|
@ -81,7 +81,7 @@ def main():
|
|||
else:
|
||||
write_file(filename, contents)
|
||||
else:
|
||||
index = parse_number(args.index, args.hex)
|
||||
index = parse_number(args.index, args.hex)
|
||||
if args.offset:
|
||||
offset = index
|
||||
if not check_valid_offset(offset):
|
||||
|
|
|
@ -172,7 +172,7 @@ void parse_rom_spec(char *spec, struct Segment **segments, int *segment_count)
|
|||
if (currSeg != NULL)
|
||||
{
|
||||
// ensure no duplicates (except for 'include' or 'pad_text')
|
||||
if (stmt != STMT_include && stmt != STMT_include_data_with_rodata && stmt != STMT_pad_text &&
|
||||
if (stmt != STMT_include && stmt != STMT_include_data_with_rodata && stmt != STMT_pad_text &&
|
||||
(currSeg->fields & (1 << stmt)))
|
||||
util_fatal_error("line %i: duplicate '%s' statement", lineNum, stmtName);
|
||||
|
||||
|
|
|
@ -52,4 +52,4 @@ for i in range(0, len(specLines)):
|
|||
|
||||
specOut = open("build/spec_preproc", "w");
|
||||
specOut.writelines(specLines);
|
||||
specOut.close();
|
||||
specOut.close();
|
||||
|
|
|
@ -23,7 +23,7 @@ def handle_file(asm_root, asm_file, c_file_path):
|
|||
file_path = os.path.join(asm_root, asm_file)
|
||||
with open(file_path) as f:
|
||||
file_lines = f.readlines()
|
||||
|
||||
|
||||
new_files = []
|
||||
num_rodata = 0
|
||||
for i, line in enumerate(file_lines):
|
||||
|
@ -53,10 +53,10 @@ def handle_file(asm_root, asm_file, c_file_path):
|
|||
new_file_lines = file_lines[new_file[0]:new_files[i+1][0]]
|
||||
else:
|
||||
new_file_lines = file_lines[new_file[0]:]
|
||||
|
||||
|
||||
with open(os.path.join(asm_root, new_file[1]), mode="w", newline="\n") as out_file:
|
||||
out_file.writelines(new_file_lines)
|
||||
|
||||
|
||||
os.remove(c_file_path)
|
||||
|
||||
pragma_begin = "#pragma GLOBAL_ASM(\"" + asm_root.split("../")[1] + "/"
|
||||
|
|
|
@ -59,13 +59,13 @@ void *util_read_whole_file(const char *filename, size_t *pSize)
|
|||
void util_write_whole_file(const char *filename, const void *data, size_t size)
|
||||
{
|
||||
FILE *file = fopen(filename, "wb");
|
||||
|
||||
|
||||
if (file == NULL)
|
||||
util_fatal_error("failed to open file '%s' for writing: %s", filename, strerror(errno));
|
||||
|
||||
if (fwrite(data, size, 1, file) != 1)
|
||||
util_fatal_error("error writing to file '%s': %s", filename, strerror(errno));
|
||||
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ def vt_fmt(text):
|
|||
|
||||
i += 1
|
||||
|
||||
|
||||
|
||||
if curLiteral:
|
||||
chars += '\"'
|
||||
|
||||
|
@ -70,7 +70,7 @@ def main():
|
|||
parser = argparse.ArgumentParser(description='Properly formats VT macros')
|
||||
parser.add_argument('string', help='String to format')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
print(vt_fmt(args.string))
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ static const struct option cmdline_opts[] = {
|
|||
static uint32_t parse_int(const char *num){
|
||||
uint32_t ret;
|
||||
char outnum[21];
|
||||
|
||||
|
||||
if(strlen(num) > 2 && num[0] == '0' && (num[1] == 'x' || num[1] == 'X')) {
|
||||
strncpy(outnum, &num[2], 20);
|
||||
sscanf(outnum, "%"SCNx32, &ret);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue