Jump to content

Kiwi's Blog

  • entries
    92
  • comments
    70
  • views
    87,995

Gaining more memory back to put more stuff in Rock Cutter


Kiwi

648 views

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...

if(objecttype==1){objectID[ID]=2;objecty[ID]=y;objectx[ID]=x;objectc1[ID]=1;objectc2[ID]=12;objectp1[ID]=128;objectp2[ID]=132;objectb[ID]=b;goto added;}//rocky..to..if(objecttype==17){objectID[ID]=17;objecty[ID]=y;objectx[ID]=x;objectc1[ID]=14;objectc2[ID]=4;objectp1[ID]=248;objectp2[ID]=180;objectb[ID]=b;goto added;}//heart


Now it is just...

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.

  • Like 1

1 Comment


Recommended Comments

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...