Jump to content

Kiwi's Blog - Gaining more memory back to put more stuff in Rock Cutter


Recommended Posts

I was reading Groovybee's comment about structure. I thought back to my CreateObject function and it can be a lot smaller if I used a pointer to a table of information about the object in question and less if branches.


Before, it was...

const byte ObjCol1[] = {0,1,1,14,1,11,1,1,1,1,12,7,1,10,0,1,8,14};const byte ObjCol2[] = {0,14,12,1,14,1,14,14,6,12,1,4,6,8,0,8,9,4};const byte ObjPat1[] = {0,128,128,160,176,184,196,204,176,208,224,232,236,232,0,252,252,248};const byte ObjPat2[] = {0,132,132,164,180,188,192,200,180,212,228,180,240,236,0,180,180,180};//if(level==4){objectc1[ID]=10;objectc2[ID]=6;}void CreateObject(byte objecttype,byte x,byte y,byte b){for(ID=0;ID!=6;ID++){if(objectID[ID]==0){objectID[ID]=objecttype;objecty[ID]=y;objectx[ID]=x;objectc1[ID]=ObjCol1[objecttype];objectc2[ID]=ObjCol2[objecttype];if(level==4 && objecttype==9){objectc1[ID]=10;objectc2[ID]=6;}objectp1[ID]=ObjPat1[objecttype];objectp2[ID]=ObjPat2[objecttype];objectb[ID]=b;goto added;}}added:}
The ROM size was 28.1. Now it is 25.8. 2.3 KB gain. Now have 6.2 KB left before hitting 32KB. I might have enough memory to do a full small or medium size level for level 5. I just need to place the enemies in level 4. Boss 4 code have to be rewritten and his graphics have to be written back into the game and load into VRAM upon entering the boss room. Then I'll work on the Final boss first, before building his level.


There's boss code the use the same code, so there's space to be gain there.

I'm not sure what the structure pointer for sprites. Newcoleco mentioned something like that when I posted my helloworld programming example. That was my first attempt to flicker 8 8x8 ghost sprites in a row. Now that I have that in my mind, I can set the updatesprites(0,64); to updatesprites(0,28); to gain cycles back. Yep, 28 sprites for the entire program. Flappe Byrd was restricted to 12 sprites for both Flappy Bird and Sparrow Flaps, which I multiplex'd a lot of the sprites. Updatesprites(); seems buggy for some reason. Updatesprites(0,64); ensure that the sprites won't do that revolving flickering.


I now need to work on sleeping. Good night.

Link to comment
Share on other sites

This topic is now closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...