Skip to content

Commit 508a46b

Browse files
vulcandthmid-kid
andauthored
Fix tools/free_space.awk for new rgbds (pret/pokecrystal#1049) (pret#416)
Co-authored-by: mid-kid <esteve.varela@gmail.com>
1 parent 8003cca commit 508a46b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

‎tools/free_space.awk‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,25 @@ function register_bank(amount) {
3838
printf "Bank %3d: %5d/16384 (%.2f%%)\n", bank_num, amount, amount * 100 / 16384
3939
}
4040
}
41+
function register_bank_str(str) {
42+
if (str ~ /\$[0-9A-F]+/) {
43+
register_bank(strtonum("0x" substr(str, 2)))
44+
} else {
45+
printf "Malformed number? \"%s\" does not start with '$'\n", str
46+
}
47+
}
4148

4249
rom_bank && toupper($0) ~ /^[ \t]*EMPTY$/ {
4350
# Empty bank
4451
register_bank(16384)
4552
}
4653
rom_bank && toupper($0) ~ /^[ \t]*SLACK:[ \t]/ {
47-
if ($2 ~ /\$[0-9A-F]+/) {
48-
register_bank(strtonum("0x" substr($2, 2)))
49-
} else {
50-
printf "Malformed slack line? \"%s\" does not start with '$'\n", $2
51-
}
54+
# Old (rgbds <=0.6.0) end-of-bank free space
55+
register_bank_str($2)
56+
}
57+
rom_bank && toupper($0) ~ /^[ \t]*TOTAL EMPTY:[ \t]/ {
58+
# New (rgbds >=0.6.1) total free space
59+
register_bank_str($3)
5260
}
5361

5462
END {

0 commit comments

Comments
 (0)