Name the last two files in src (#429)

* label animation and a few object flags

* models

* name funny spline

* Update menu.c

* better name

* rename unknown_005740.c

* ah its happened again

* fix warnings

* Fix that dumb idiot warning finally

* teag

* rename the last audio file

* Update math_util.c

* update math util to the latest

* small funny format

* quick change

* fix warnings

* Update README.md

* Fix a maths func

* fix nonequiv building

* bro come on
This commit is contained in:
Fazana
2023-10-31 16:39:28 +00:00
committed by GitHub
parent 8019d578c0
commit d8e58622e0
65 changed files with 6344 additions and 6231 deletions
+85 -85
View File
@@ -1,85 +1,85 @@
import re
import os
import sys
from file_util import FileUtil
VERSION = sys.argv[1]
BUILD_DIR = 'build/' + VERSION
MAP_FILEPATH = BUILD_DIR + '/dkr.map'
ROM_FILEPATH = BUILD_DIR + '/dkr.z64'
FUNCTIONS_TO_CALC = [
# function checksum variable func size variable
('func_80019808', 'gFunc80019808Checksum', 'gFunc80019808Length'),
('render_scene', 'gTractionTableChecksum', 'gFunc80024D54Length'),
('obj_loop_goldenballoon', 'gObjLoopGoldenBalloonChecksum', 'gObjLoopGoldenBalloonLength'),
('func_80068158', 'gFunc80068158Checksum', 'gFunc80068158Length')
]
def getMatches(string, regex):
out = []
matches = re.finditer(regex, string, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
start = match.start()
end = match.end()
out.append((string[start:end], match.groups(), (start, end)))
return out
rom = FileUtil.get_bytes_from_file(ROM_FILEPATH)
mapFile = {}
RAM_TO_ROM = None
def write_word_to_rom(romOffset, value):
global rom
rom[romOffset + 0] = (value >> 24) & 0xFF
rom[romOffset + 1] = (value >> 16) & 0xFF
rom[romOffset + 2] = (value >> 8) & 0xFF
rom[romOffset + 3] = value & 0xFF
def calculate_checksum_for_function(funcLabel, varLabel, funcSizeLabel):
if funcLabel not in mapFile:
raise Exception('Label "' + funcLabel + '" does not exist in the map file!')
if varLabel not in mapFile:
raise Exception('Label "' + varLabel + '" does not exist in the map file!')
if funcSizeLabel not in mapFile:
raise Exception('Label "' + funcSizeLabel + '" does not exist in the map file!')
funcEntry = mapFile[funcLabel]
funcAddress = funcEntry['value']
funcLength = funcEntry['length']
funcRomOffset = funcAddress - RAM_TO_ROM
count = 0
for i in range(0, funcLength):
count += rom[funcRomOffset + i]
# Save function checksum.
varEntry = mapFile[varLabel]
varAddress = varEntry['value']
varRomOffset = varAddress - RAM_TO_ROM
write_word_to_rom(varRomOffset, count)
# Save function size.
sizeEntry = mapFile[funcSizeLabel]
sizeAddress = sizeEntry['value']
sizeRomOffset = sizeAddress - RAM_TO_ROM
write_word_to_rom(sizeRomOffset, funcLength)
def calculate_matches():
global mapFile, RAM_TO_ROM
REGEX_MAP_GET_LABEL = r"[ ]*?(?:0x[0-9A-Fa-f]{8})?([0-9A-Fa-f]{8})[ ]*?([_A-Za-z0-9]+)"
mapText = FileUtil.get_text_from_file(MAP_FILEPATH)
mapMatches = getMatches(mapText, REGEX_MAP_GET_LABEL)
for i in range(0, len(mapMatches) - 1):
match = mapMatches[i]
labelValue = match[1]
value = int(labelValue[0], 16)
length = int(mapMatches[i + 1][1][0], 16) - value
mapFile[labelValue[1]] = { "value": value, "length": length }
RAM_TO_ROM = mapFile['__RAM_TO_ROM']['value']
def main():
calculate_matches()
for entry in FUNCTIONS_TO_CALC:
calculate_checksum_for_function(entry[0], entry[1], entry[2])
FileUtil.write_bytes_to_file(ROM_FILEPATH, rom)
main()
import re
import os
import sys
from file_util import FileUtil
VERSION = sys.argv[1]
BUILD_DIR = 'build/' + VERSION
MAP_FILEPATH = BUILD_DIR + '/dkr.map'
ROM_FILEPATH = BUILD_DIR + '/dkr.z64'
FUNCTIONS_TO_CALC = [
# function checksum variable func size variable
('func_80019808', 'gFunc80019808Checksum', 'gFunc80019808Length'),
('render_scene', 'gTractionTableChecksum', 'gTrackRenderFuncLength'),
('obj_loop_goldenballoon', 'gObjLoopGoldenBalloonChecksum', 'gObjLoopGoldenBalloonLength'),
('func_80068158', 'gFunc80068158Checksum', 'gFunc80068158Length')
]
def getMatches(string, regex):
out = []
matches = re.finditer(regex, string, re.MULTILINE)
for matchNum, match in enumerate(matches, start=1):
start = match.start()
end = match.end()
out.append((string[start:end], match.groups(), (start, end)))
return out
rom = FileUtil.get_bytes_from_file(ROM_FILEPATH)
mapFile = {}
RAM_TO_ROM = None
def write_word_to_rom(romOffset, value):
global rom
rom[romOffset + 0] = (value >> 24) & 0xFF
rom[romOffset + 1] = (value >> 16) & 0xFF
rom[romOffset + 2] = (value >> 8) & 0xFF
rom[romOffset + 3] = value & 0xFF
def calculate_checksum_for_function(funcLabel, varLabel, funcSizeLabel):
if funcLabel not in mapFile:
raise Exception('Label "' + funcLabel + '" does not exist in the map file!')
if varLabel not in mapFile:
raise Exception('Label "' + varLabel + '" does not exist in the map file!')
if funcSizeLabel not in mapFile:
raise Exception('Label "' + funcSizeLabel + '" does not exist in the map file!')
funcEntry = mapFile[funcLabel]
funcAddress = funcEntry['value']
funcLength = funcEntry['length']
funcRomOffset = funcAddress - RAM_TO_ROM
count = 0
for i in range(0, funcLength):
count += rom[funcRomOffset + i]
# Save function checksum.
varEntry = mapFile[varLabel]
varAddress = varEntry['value']
varRomOffset = varAddress - RAM_TO_ROM
write_word_to_rom(varRomOffset, count)
# Save function size.
sizeEntry = mapFile[funcSizeLabel]
sizeAddress = sizeEntry['value']
sizeRomOffset = sizeAddress - RAM_TO_ROM
write_word_to_rom(sizeRomOffset, funcLength)
def calculate_matches():
global mapFile, RAM_TO_ROM
REGEX_MAP_GET_LABEL = r"[ ]*?(?:0x[0-9A-Fa-f]{8})?([0-9A-Fa-f]{8})[ ]*?([_A-Za-z0-9]+)"
mapText = FileUtil.get_text_from_file(MAP_FILEPATH)
mapMatches = getMatches(mapText, REGEX_MAP_GET_LABEL)
for i in range(0, len(mapMatches) - 1):
match = mapMatches[i]
labelValue = match[1]
value = int(labelValue[0], 16)
length = int(mapMatches[i + 1][1][0], 16) - value
mapFile[labelValue[1]] = { "value": value, "length": length }
RAM_TO_ROM = mapFile['__RAM_TO_ROM']['value']
def main():
calculate_matches()
for entry in FUNCTIONS_TO_CALC:
calculate_checksum_for_function(entry[0], entry[1], entry[2])
FileUtil.write_bytes_to_file(ROM_FILEPATH, rom)
main()
+1 -1
View File
@@ -57,7 +57,7 @@ def _find_glabels(asm):
def main():
FileUtil.set_working_dir_to_project_base()
contents = FileUtil.get_text_from_file('asm/non_matchings/unknown_005740/func_80005254.s')
contents = FileUtil.get_text_from_file('asm/non_matchings/audio_vehicle/func_80005254.s')
glabels = _find_glabels(contents)
print('%d undeclared labels found:' % len(glabels))
for glabel in glabels: