Cramming bunch of stuff in 32KB
I finished building level 4. Now I just need to place enemies, script a event, and reprogram the 4th boss.
I thought up a way to reduce my metamapping screen writing routine.
Before:
void WriteScreen() {y=0;c=0;x=0;for(i=0;i!=192;i++){c=Data[i];if(c==0){put_frame(SkyDkBlu,x,y,2,2);}if(c==1){put_frame(SkyTrans,x,y,2,2);}if(c==2){put_frame(SkyLtBlue,x,y,2,2);}if(c==3){put_frame(GrassTopSolid,x,y,2,2);}if(c==4){put_frame(GroundSolid,x,y,2,2);}if(c==5){put_frame(GroundBG,x,y,2,2);}if(c==6){put_frame(CaveWallSolid,x,y,2,2);}if(c==7){put_frame(CaveWallSolidL,x,y,2,2);}if(c=={put_frame(CaveWallBG,x,y,2,2);}if(c==9){put_frame(GrassTopBG,x,y,2,2);}if(c==10){put_frame(WaterTop,x,y,2,2);}if(c==11){put_frame(CaveCeiling,x,y,2,2);}if(c==12){put_frame(CaveSpike,x,y,2,2);}if(c==13){put_frame(RockPile,x,y,2,2);}if(c==14){put_frame(RockPile2,x,y,2,2);}if(c==15){put_frame(LedgeGrass,x,y,2,2);}if(c==16){put_frame(TreeTop,x,y,2,2);}if(c==17){put_frame(TreeTrunk,x,y,2,2);}if(c==18){put_frame(Grassy,x,y,2,2);}if(c==19){put_frame(Flower,x,y,2,2);}if(c==20){put_frame(CloudLeft,x,y,2,2);}if(c==21){put_frame(CloudRight,x,y,2,2);}if(c==22){put_frame(GoRightSign,x,y,2,2);}if(c==23){put_frame(RockLedge,x,y,2,2);}if(c==24){put_frame(Water,x,y,2,2);}if(c==25){put_frame(Curtain,x,y,2,2);}if(c==26){put_frame(Waterfall,x,y,2,2);}if(c==27){put_frame(Cave2Wall,x,y,2,2);}if(c==28){put_frame(Cave2BG,x,y,2,2);}if(c==29){put_frame(Cave2Ledge,x,y,2,2);}if(c==30){put_frame(Cave2Wallhalf,x,y,2,2);}if(c==31){put_frame(CoralPlant,x,y,2,2);}if(c==32){put_frame(Cave2Ledge2,x,y,2,2);}if(c==33){put_frame(Cave2Beam,x,y,2,2);}if(c==34){put_frame(Cave2Beam2,x,y,2,2);}if(c==35){put_frame(SandyTop,x,y,2,2);}if(c==36){put_frame(SandyWall,x,y,2,2);}if(c==37){put_frame(LavaTop,x,y,2,2);}if(c==38){put_frame(Lava,x,y,2,2);}x+=2;if(x>=32){x=0;y+=2;}}}
after
void WriteScreen() {y=0;c=0;x=0;for(i=0;i!=192;i++){c=Data[i];c=c*4;put_frame(SkyDkBlu+c,x,y,2,2);x+=2;if(x>=32){x=0;y+=2;}}}
This gained me 1,100 bytes. This routine is good for 64 16x16 metatiles. Also, the screen is written a lot quicker. NMI is disabled during the map loading sequence. The drawback that the sounds will sustain until nmi is enabled. I could leave nmi enabled, and then add delay(1); whenever the y position is added by 2. It'll slow the drawing routine, won't overrun the CPU, advance the sounds. The screen draw is quick enough that I will leave it as it is.
I just compressed level 4 mapping data. It was 2.43KB. After pletter compressing it, it only took up 433 bytes. Now I have 28.1 KB to play with. Just need to get Level 4 done, and then level 5 will be a very short level leading up to the final boss.
- 1
1 Comment
Recommended Comments