It is currently Sat Nov 25, 2017 2:46 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Mon Nov 06, 2017 10:04 pm 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 247
Location: Central Illinois, USA
This is probably already posted out there somewhere, but I couldn't find it: How do y'all easily track how much space you have left in each bank and/or segment?

I can think of a few ways to do it, but was curious what you all do -- I imagine somebody has already solved this in a more elegant way than I'll come up with on my own.

_________________
My games: http://www.bitethechili.com


Top
 Profile  
 
PostPosted: Mon Nov 06, 2017 10:13 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5843
Location: Canada
1. Link with -m map.txt will spit out a "map" file with the addresses and sizes of all segments and memory blocks, as well as some other useful info.

2. You can use shiru's space checker tool for a visual inspection.
https://shiru.untergrund.net/software.shtml

In my own project, since I already have a python script processing the label output into FCEUX debug files, at the same time I have it parse the map file and compute empty space for me.


Top
 Profile  
 
PostPosted: Mon Nov 06, 2017 10:19 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1835
Location: DIGDUG
Ok, so in the cfg file, there are 2 areas. The "memory" map and the "segments".

Generally, a segment can go anywhere in the ROM of the memory map, except rarely (vectors, dmc samples).

So, I believe, it doesn't matter,... the segments can expand and contract, as needed. Just check how much free space you have in each BANK. And, it (the linker) will give you an error if you overflow a bank (memory area).

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Mon Nov 06, 2017 10:25 pm 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 247
Location: Central Illinois, USA
rainwarrior wrote:
In my own project, since I already have a python script processing the label output into FCEUX debug files, at the same time I have it parse the map file and compute empty space for me.


That was my plan as well :-)

(Particularly since I'm already using an old version of your python script to generate the FCEUX debug files)

_________________
My games: http://www.bitethechili.com


Last edited by gauauu on Mon Nov 06, 2017 10:35 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Mon Nov 06, 2017 10:31 pm 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 247
Location: Central Illinois, USA
dougeff wrote:
. And, it (the linker) will give you an error if you overflow a bank (memory area).


Yeah, I don't really care about segments as much as the entire bank.

But I do want it to report numbers (preferably dumped out on the console as my makefile runs) so I can see how quickly I'm using up space, and not just the default behavior of saying nothing until "oops, you've gone over!"

_________________
My games: http://www.bitethechili.com


Top
 Profile  
 
PostPosted: Tue Nov 07, 2017 12:06 am 
Offline
Formerly WheelInventor

Joined: Thu Apr 14, 2016 2:55 am
Posts: 1024
Location: Gothenburg, Sweden
Shiru's space checker (already mentioned) provides visual feedback in a way that's quick to overview.

_________________
http://www.frankengraphics.com - personal NES blog


Top
 Profile  
 
PostPosted: Tue Nov 07, 2017 1:25 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 585
od65 -S *.o | grep mybank | summer 2

where summer is a custom script:
Code:
#!/bin/sh

count=$1
[ -z "$count" ] && echo "Usage: $0 column" && exit

awk --non-dec "{s+=\$$count} END {print s}"


Top
 Profile  
 
PostPosted: Tue Nov 07, 2017 12:28 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19259
Location: NE Indiana, USA (NTSC)
gauauu wrote:
This is probably already posted out there somewhere, but I couldn't find it: How do y'all easily track how much space you have left in each bank and/or segment?

ld65 can be set to output a map file, one of whose sections is the size of each segment.

It can also export symbols representing the size of each segment (see descriptions of define = yes in ld65 Users Guide), and code and string constants can use these symbols to calculate and display ROM fullness. I use define = yes in RHDE's linker configuration to have it define labels for the starting address and size of two segments:
Code:
SEGMENTS {
  ZEROPAGE: load=ZP, type=zp;
  BSS:      load=RAM, type=bss, define=yes, align=$100;
  INESHDR:  load=HEADER, type=ro, align=$10;
  DMC:      load=ROM7, type=ro, align=64, optional=yes;
  CODE:     load=ROM7, type=ro, align=$100, define=yes;
  RODATA:   load=ROM7, type=ro, align=$100, define=yes;
  VECTORS:  load=ROM7, type=ro, start=$FFFA;
}


Then title.s picks up these symbols:
Code:
.import __RODATA_LOAD__, __RODATA_SIZE__, __CODE_LOAD__, __CODE_SIZE__
ROMSIZE = __CODE_SIZE__ + __RODATA_SIZE__ + 6
ROMPCT = (1000 * ROMSIZE + 16384) / 32768
; started this project on Sun 2013-08-11
BUILDDAY = (.TIME / 86400) - 15928

uctions5_txt:
  .byte .sprintf("Day %d: ROM ", BUILDDAY)
  .byte '0'|<(ROMPCT / 100 .MOD 10)
  .byte '0'|<(ROMPCT / 10 .MOD 10)
  .byte '.','0'|<(ROMPCT .MOD 10),"% full"

The .MOD stuff is needed because it's the only way to convert a integer that isn't constant at assembly time to decimal digits. BUILDDAY is known at assembly time, but the sizes aren't known until link time.


Top
 Profile  
 
PostPosted: Tue Nov 07, 2017 1:28 pm 
Offline
User avatar

Joined: Thu Mar 31, 2016 11:15 am
Posts: 211
Add dummy segments at the very end of the cfg file:

Code:
    BANK0_END:    load = PRG0, type = ro;
    BANK1_END:    load = PRG1, type = ro;
    BANK2_END:    load = PRG2, type = ro;

Then the 'Start' value in the map file shows where each bank ends.
Code:
Name                   Start     End    Size  Align
----------------------------------------------------
BANK0_END             00BA80  00BA80  000001  00001
BANK1_END             008AB6  008AB6  000001  00001
BANK2_END             00BF00  00BF00  000001  00001

Subtract from 0xC000 to get the size.

You might need to fill these dummy segments with a single byte.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group