Jump to content
  • entries
    650
  • comments
    2,609
  • views
    872,097

freed up some ROM

Sign in to follow this  
SpiceWare

907 views

I rewrote PrepScoreDatastream(), BreakAsteroids() and made some other changes (thanks cd-w!). The ARM free has increased to $41C (1042) while Display Data decreased to $14 (20). Much better than the $30 (48)and $30 of a few days ago, and there's still more optimizing to be done.

 

If anybody else spots anything that can be optimized, don't hesitate to post it :) Also I'd appreciate any play testing of the latest build in case any of the optimizations broke something.

 

ROMs

spacerocks20120827_NTSC.bin

spacerocks20120827_PAL.bin

 

Source

spacerocks20120827.zip

 

 

 

 

Blinky lives.

Sign in to follow this  


9 Comments


Recommended Comments

I couldn't find any large wins this time, but I think you may be able to save some bytes by doing:

 

1) Moving the shift operation inside the random function, so you would call it like Random32(15):

unsigned int Random32( unsigned int mask)
{
static unsigned int random = 0x02468ace;
random = (random >> 1) ^ (unsigned int)(-(random & 1u) & 0xd0000001u);
return (random & mask);
}

2) Packing the arrays to save bytes, e.g. the values in PF_1_DIGIT_MASK only require 2 bits each to store, so you could pack 16 of them into a single 32-bit integer:

 

2<<30 | 0 <<28 | 3<<26 .... 1<<4 | 2<<2 | 1<<0

 

You can then extract the value using a small function, e.g:

 

unsigned char extract_pf1_data(int[] packed, int position)
{
return (packed[position/16] >> ((position%16) * 2)) & 0x3;
}

 

Hopefully the bytes needed to call this function will be less than the number originally used!

 

3) The vector_three_on array could be calculated (2^(x+3))-(2^x) I think.

 

4) In the InitSpriteShotDatastreams function - if the queues are contiguous then a single memset could be used to zero all of them?

 

5) When calling InitShip, the x & y values are always shifted by FRACTION_BITS. You could move this shift inside the function:

 

gSpriteX[player] = x << FRACTION_BITS;
gSpriteY[player] = (y- << FRACTION_BITS;

 

6) In the PrepSpeedRange function, the SPEED_RANGE and SPEED_BASE calculations could be moved inside the loop:

 

for (i=0;i<3;++i)
{
SPEED_RANGE[i] = (level >> (2-i)) + 4;
SPEED_BASE[i] = (level >> (6-i) + base_adjust;
...
}

Share this comment


Link to comment

Thanks! I've been optimizing the 6507 banks since posting this build. Display data went from $14 (20) to $84 (132) and bank 5 went from $117 (279) free to $188 (392).

 

I've got a buddy coming over tonight so I'll look at these tomorrow. He's in his mid 20s and I introduced him to Red Dwarf a few months ago. He comes over a few times a month and we watch a season in one sitting, though we're starting season 7 tonight which is when they increased the # of episodes so we decided to split it and season 8 over 2 viewing sessions for each season. I think I'll introduce him to Blackadder next.

Share this comment


Link to comment

I was looking for asteroids hacks to find ideas and I discovered Asteroids DC+ from Thomas. He added driving controllers.

Maybe you could add driving controllers with the 180°, shield, hyper options...

 

Of course, you already have many options in your game and I think it will be difficult to navigate the menu with driving controllers.

Share this comment


Link to comment

The new small asteroids were added on the 5th.

 

Driving controllers, hmm. Menu wouldn't be a problem, rotate controller to select an option then hit fire to change the value. I'll have to take a look at Thomas' hack to see how that works.

Share this comment


Link to comment

explosion graphics were changed on the 5th as well.

 

Besides the new graphics, I made it so that the fragments continue their trajectory along the asteroid's original path. I love the "close call" feeling you get when shooting an asteroid that's about to hit you and seeing the fragments fly harmlessly over your ship.

  • Like 1

Share this comment


Link to comment

I couldn't find any large wins this time, but I think you may be able to save some bytes by doing:

Thanks, saved 112 bytes!

 

#1 - didn't pan out, increased code by 28 bytes

#2 - only tried for PF1 and it increased code by 48 bytes. I thought for sure this one would have helped.

#3 - use 7 << x. I'd tried it before and it increased code size by 12 bytes. Tried it again and the code size stayed the same, so I left it in place so it'll be consistent with the vector_on_one logic.

#4 - saved 80 bytes!

#5 - most of those were constants, but the Respawn function did a lot of shifting that I was able to eliminate to save 20 bytes

#6 - saved 12 bytes

Share this comment


Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...