Graphics Extension ROM based Game - experimenting

bbc/electron apps, languages, utils, educational progs, demos + more
cmorley
Posts: 1258
Joined: Sat Jul 30, 2016 8:11 pm
Location: Oxford
Contact:

Re: Graphics Extension ROM based Game - experimenting

Post by cmorley » Fri Nov 22, 2019 6:48 am

flibble wrote:
Fri Nov 22, 2019 12:56 am
I've also bounced off the memory limit (appears to be a binary size of approx 23KB (and 5KB sprites)) and discovered some interested things about the C implementation with regards to memory. Creating large local variables on the stack is generally a lot worse than just having a static variable in global scope, it's nicely making me write worse C :D
Static allocations on a memory constrained system is not "bad C". It is standard practice. Indeed so far as dynamic allocation is often frowned upon and malloc (etc) might be banned by coding guidelines :D

There are things you can do to drop the code size. Are you using the heap? Bin it if not. Run your init from an init segment then reuse this memory for data after init - easy to do in C. Pointer maths on 6502 are bloaty when the compiler can't elide it (might be why stack variables suck so bad - that & the register spill code is huge). Aggresively drop to (un)signed char from ints where you definitely only need 8 bits.

Post Reply

Return to “8-bit acorn software: other”