A visual check of ROM usage

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

Here's a bitmap representation of the binary.

What I was looking for here was obvious gaps -- which would indicate spare room in the ROM that I was not aware of.  Fortunately (unfortunately?) it looks like I've packed the ROM pretty efficiently!  That  black band at the bottom is my free space, available for caves and any final coding.


Andrew Davie

CategoryColourHow it's found
C codegreenARM .text/.bootcode, minus everything below
sound codesea greenDWARF debug-line info (objdump --dwarf=decodedline) attributing code ranges to main/sound.c — the only way to split code by source file, since LTO merges everything into one .text
C datayellowgeneric ARM OBJECT symbols
sprite framesblueshape_FRAME_* symbols
characterset datacyansymbols with "charset" in the name
sound effectsdeep pinksample*-prefixed symbols (sound_data.c)
cave/level datapurplenames read live from main/cave_data/*.cave.c (no shared naming convention, so the tool scans the actual source files) + planetHuffman's phrase tables + caveData's dispatch table
planet texturesbrownsymbols matching *_palette/*_char_NNN (spinningGlobe/*.c)
6502 codeorangeDASM listing
6502 dataredDASM listing

Andrew Davie

This was quite useful in identifying the large cost of the planet textures (brown).  I've been working on various ways of reducing this;  reducing complexity in the textures, building a shared character set (rather than individuals), reducing character counts. Still working on it, but I've seen about a 16K reduction in ROM space already, at the cost of slightly worse textures. But since they're random-ish anyway, that may not matter.

Andrew Davie

#3
As noted, the "brown" (under the yellow band, mid-image) was quite costly. The planet textures.

Prior version had a separate characterset for each planet, and I set an arbitrary limit on the number of characters (per planet). Hand-tuned, basically.  So I ended up with some planets "needing" 80 characters, some 40, some 128.  The total ROM size with this method was about 120K - leaving precious little left.

I tried a number of methods, finally settling on a shared 256 character set. This reduced the ROM size to 106K; a huge saving. But unfortunately the detail in nearly all the planets became blocky. Just awful, actually. I briefly experimented with allowing > 256 characters in the set, but this meant moving  to > 8 bits per character in the maps, and I lost a lot doing that.  Next I hit on the idea of "entropy" -- that is, do a prior reduction of the detail in each texture, so we had a shared amount of "complexity" in each texture, then produce a combined characterset and reduce it to 256 by matching pairs of "kinda equal" characters. That worked. Better.

Finally, I used an algorithm called Lloyd refinement to reduce the characterset from (say) 400 to 256.  Huge improvement. I did some more testing and realised that that first step - entropy - was completely invalidated by the Lloyd algorithm, and in fact we could keep ALL the detail in the textures and let the Lloyd refinement algorithm do a full reduction to 256 characters, essentially unguided.

Since we're still generating 256 characters the final ROM size is the same - 106K.  But now we have much improved visuals because the textures are (for the most part) not obnoxiously incorrect/blocky.

Here's the new "visual memory map" and note how much reduced the brown (planet textures) area is, and compare the free space (white) at the end. This is after I've added a few actual levels, too. Nice!