Fix tools/free_space.awk for new rgbds (#1049)

This commit is contained in:
mid-kid 2023-05-17 16:18:18 +02:00 committed by GitHub
parent 8c6242a152
commit 5e8c7c8f78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,17 +38,25 @@ function register_bank(amount) {
printf "Bank %3d: %5d/16384 (%.2f%%)\n", bank_num, amount, amount * 100 / 16384
}
}
function register_bank_str(str) {
if (str ~ /\$[0-9A-F]+/) {
register_bank(strtonum("0x" substr(str, 2)))
} else {
printf "Malformed number? \"%s\" does not start with '$'\n", str
}
}
rom_bank && toupper($0) ~ /^[ \t]*EMPTY$/ {
# Empty bank
register_bank(16384)
}
rom_bank && toupper($0) ~ /^[ \t]*SLACK:[ \t]/ {
if ($2 ~ /\$[0-9A-F]+/) {
register_bank(strtonum("0x" substr($2, 2)))
} else {
printf "Malformed slack line? \"%s\" does not start with '$'\n", $2
}
# Old (rgbds <=0.6.0) end-of-bank free space
register_bank_str($2)
}
rom_bank && toupper($0) ~ /^[ \t]*TOTAL EMPTY:[ \t]/ {
# New (rgbds >=0.6.1) total free space
register_bank_str($3)
}
END {