Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2019-09-08 11:46:44

Ardis
Member
From: USA
Registered: 2019-06-06
Posts: 20
Website

Seeing how much of your ROM file is used in GBDK

I'm trying to keep the game I'm working on under 32KB so I can use the simplest possible cartridge for it. Right now, the compiler spits out a 32KB .gb ROM file no matter what, telling me that a portion of the ROM file is just blank data.

I don't know what my compiler will do if the game exceeds that. Will it jump to the next standard ROM file size? Or will it give me an error until I tell it to compile a larger ROM?

For now, I just need to know if there is a way to see how much of that 32KB is actually in use so I know how much more I can add to the game.

Offline

 

#2 2019-09-08 14:35:21

Jonas
Member
From: Frankfurt, Germany
Registered: 2016-06-06
Posts: 97
Website

Re: Seeing how much of your ROM file is used in GBDK

Ardis wrote:

I don't know what my compiler will do if the game exceeds that. Will it jump to the next standard ROM file size? Or will it give me an error until I tell it to compile a larger ROM?

You will get an error message until you tell the compiler to compile a larger ROM.

Ardis wrote:

For now, I just need to know if there is a way to see how much of that 32KB is actually in use so I know how much more I can add to the game.

Take a look here: http://gbdev.gg8.se/forums/viewtopic.php?pid=2470#p2470

Offline

 

#3 2019-09-12 22:32:40

PinoBatch
Member
Registered: 2018-03-22
Posts: 50

Re: Seeing how much of your ROM file is used in GBDK

I wrote a Python script that will find long runs of $00 or $FF bytes in a ROM, which are likely to correspond to unused areas.

Source: unused.py
License: zlib

Offline

 

#4 2019-09-13 14:01:53

bbbbbr
Member
Registered: 2019-03-04
Posts: 27

Re: Seeing how much of your ROM file is used in GBDK

Also, if you are using ZGB on Linux then this post has a shell script for generating a report of space used
https://gbdev.gg8.se/forums/viewtopic.p … 3585#p3585

If you are using GBDK directly, then you can look at the .map and .lst files. The .map file gives you listing of where the linker placed everything. The .lst files give you a per-source file listing along with a summary at the bottom- check the "Area Table".

Not a 100% sure this works, but here is a modified version of the script linked above for regular GBDK output (just changing .sym to .lst in the regex). Still requires datamash if you want the tabulated output.

Code:

#!/bin/bash

# find all the data allocation rows in the linker symbol output
# dump them into a csv -> datamash -> table output

rm linker_summary.csv
echo "File,Seg,Size" > linker_summary.csv;
grep -R "flags" * | grep ".lst" | perl -pe 's/(.*)\.lst\:\s*\d+\s_([0-9A-Z_]*)\s*size\s*([0-9A-F]*)\s*flags.*/ /; print $1 . "," . $2 . "," . hex($3) . ","' >> linker_summary.csv
datamash --headers --field-separator=, --no-strict --ignore-case --narm  --sort --group 2 sum 3 < linker_summary.csv

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson