mischief managed
Last entry I complained that I'd run out of space. Well, I've now managed to free up a whack-o-space, which has (at least for the moment) cured my space issues. I'm now trying to work out what the heck my enemy AI code is doing (along with some code tweaking). I'm hoping I can get a new release out in the next couple of days.
For those curious, I found the space in my kernal (of all places). Since I knew I needed a goodly amount of space (i.e. not just a few bytes), I first looked at the listing and divided the code (and data) into chunks (i.e. enemy AI) along with how big each was. The theory it's easier to find savings in a big chunk of code (or data) than a small routine. For Skeleton+ I removed a color lookup table used as part of the Skeleton dead sequence and replaced it with a random number generator (since the colors looked mostly random anyway). Unfortunately there aren't any similar tables in Leprechaun.
The biggest routine in the first bank (which is where I needed space) was the kernel, so I started looking there. One of the things which I saw was there were three repositioning routines which took up a bunch of space: first row, odd rows, and even rows. Hmmm... Might it be possible to get rid of the first row routine? Unfortunately, there wasn't quite enough cycles at the end of the odd row repositioning routine to squeeze in a test to jump directly to the even row repositioning routine.
Then I had a flash of insight. Part of the reason the repositioning routine is so large is it is partially unrolled to give it enough cycles to squeeze in some of the other logic into a single line. But the first row doesn't have to fit in a single line - there's some unused cycles after the score routine. Thus a 94 byte routine dropped to 34 bytes (and moved to a different bank, not that I have a lot of space left there either). Woo-hoo!
9 Comments
Recommended Comments