shit
This commit is contained in:
parent
417cae168f
commit
a8bc01bedd
59 changed files with 2053 additions and 1054 deletions
81
src/main.c
81
src/main.c
|
|
@ -10,19 +10,32 @@
|
|||
#include "stage.h"
|
||||
#include "chrome.h"
|
||||
#include "start.h"
|
||||
#include "starfield.h"
|
||||
#include "sfx.h"
|
||||
|
||||
static void loadInternals(){
|
||||
JOY_init();
|
||||
JOY_setEventHandler(&updateControls);
|
||||
SPR_init();
|
||||
VDP_setPlaneSize(128, 32, TRUE);
|
||||
SPR_init();
|
||||
VDP_loadFont(font.tileset, DMA);
|
||||
PAL_setPalette(PAL0, font.palette->data, DMA);
|
||||
PAL_setPalette(PAL1, shadow.palette->data, CPU);
|
||||
PAL_setPalette(PAL2, shadow.palette->data, CPU);
|
||||
VDP_setTextPriority(1);
|
||||
}
|
||||
|
||||
static bool attractEnding;
|
||||
|
||||
static void startLevelFadeIn(){
|
||||
u16 ft[48];
|
||||
memcpy(ft, font.palette->data, 16 * sizeof(u16));
|
||||
memcpy(ft + 16, shadow.palette->data, 16 * sizeof(u16));
|
||||
memcpy(ft + 32, bgPal, 16 * sizeof(u16));
|
||||
PAL_setColors(0, palette_black, 48, CPU);
|
||||
PAL_fadeIn(0, 47, ft, 20, TRUE);
|
||||
}
|
||||
|
||||
void clearLevel(){
|
||||
for(s16 i = 0; i < BULLET_COUNT; i++)
|
||||
if(bullets[i].active) killBullet(i, FALSE);
|
||||
|
|
@ -34,6 +47,7 @@ void clearLevel(){
|
|||
collectedCount = 0;
|
||||
allTreasureCollected = FALSE;
|
||||
treasureCollectedClock = 0;
|
||||
levelEnemiesKilled = 0;
|
||||
// black out everything
|
||||
SPR_setVisibility(player.image, HIDDEN);
|
||||
VDP_clearTileMapRect(BG_A, 0, 0, 128, 32);
|
||||
|
|
@ -41,43 +55,90 @@ void clearLevel(){
|
|||
}
|
||||
|
||||
void loadGame(){
|
||||
VDP_setVerticalScroll(BG_A, 0);
|
||||
score = 0;
|
||||
nextExtendScore = EXTEND_SCORE;
|
||||
loadBackground();
|
||||
loadPlayer();
|
||||
loadChrome();
|
||||
loadLevel(0);
|
||||
XGM2_play(stageMusic);
|
||||
XGM2_setFMVolume(MUSIC_VOLUME);
|
||||
XGM2_setPSGVolume(MUSIC_VOLUME);
|
||||
loadLevel(isAttract ? ATTRACT_LEVEL : START_LEVEL);
|
||||
#if MUSIC_VOLUME > 0
|
||||
if(!isAttract) XGM2_play(isBossLevel(level) ? bossMusic : stageMusic);
|
||||
#endif
|
||||
player.recoveringClock = 240;
|
||||
player.recoverFlash = FALSE;
|
||||
killBullets = TRUE;
|
||||
attractEnding = FALSE;
|
||||
started = TRUE;
|
||||
startLevelFadeIn();
|
||||
}
|
||||
|
||||
static void updateGame(){
|
||||
if(isAttract){
|
||||
if(!attractEnding){
|
||||
if(ctrlHW.start || ctrlHW.a || ctrlHW.b || ctrlHW.c){
|
||||
attractEnding = TRUE;
|
||||
PAL_fadeOut(0, 47, 20, TRUE);
|
||||
}
|
||||
if(attractClock > 0){
|
||||
attractClock--;
|
||||
if(attractClock == 20)
|
||||
PAL_fadeOut(0, 47, 20, TRUE);
|
||||
} else {
|
||||
SYS_hardReset();
|
||||
}
|
||||
} else if(!PAL_isDoingFade()){
|
||||
SYS_hardReset();
|
||||
}
|
||||
}
|
||||
updateChrome();
|
||||
updateSfx();
|
||||
if(levelClearing){
|
||||
levelClearClock++;
|
||||
if(levelClearClock == 73)
|
||||
XGM2_stop();
|
||||
if(levelClearClock == 1){
|
||||
clearLevel();
|
||||
loadStarfield(level % 3);
|
||||
u16 transPal[32];
|
||||
memcpy(transPal, font.palette->data, 16 * sizeof(u16));
|
||||
memcpy(transPal + 16, shadow.palette->data, 16 * sizeof(u16));
|
||||
PAL_fadeIn(0, 31, transPal, 20, TRUE);
|
||||
}
|
||||
if(levelClearClock >= 120){
|
||||
if(levelClearClock == 220)
|
||||
PAL_fadeOut(0, 31, 20, TRUE);
|
||||
if(levelClearClock >= 240){
|
||||
levelClearing = FALSE;
|
||||
player.pos.y = FIX32(112);
|
||||
player.camera = player.pos.x - FIX32(160);
|
||||
playerVelX = 0;
|
||||
clearStarfield();
|
||||
loadBackground();
|
||||
loadChrome();
|
||||
loadLevel(level + 1);
|
||||
SPR_setVisibility(player.image, VISIBLE);
|
||||
startLevelFadeIn();
|
||||
player.pendingShow = TRUE;
|
||||
player.recoveringClock = 240;
|
||||
player.recoverFlash = FALSE;
|
||||
killBullets = TRUE;
|
||||
XGM2_stop();
|
||||
#if MUSIC_VOLUME > 0
|
||||
if(!isAttract) XGM2_play(isBossLevel(level) ? bossMusic : stageMusic);
|
||||
#endif
|
||||
}
|
||||
if(levelClearing) updateStarfield();
|
||||
return;
|
||||
}
|
||||
if(levelWaitClock > 0){
|
||||
levelWaitClock--;
|
||||
#if MUSIC_VOLUME > 0
|
||||
if(levelWaitClock == 209 && !isAttract)
|
||||
XGM2_play(treasureMusic);
|
||||
#endif
|
||||
if(levelWaitClock == 20)
|
||||
PAL_fadeOut(0, 47, 20, TRUE);
|
||||
if(levelWaitClock == 0){
|
||||
statEnemiesKilled = levelEnemiesKilled;
|
||||
statTreasures = collectedCount;
|
||||
levelClearing = TRUE;
|
||||
levelClearClock = 0;
|
||||
return;
|
||||
|
|
@ -93,8 +154,10 @@ static void updateGame(){
|
|||
gameOver = TRUE;
|
||||
XGM2_stop();
|
||||
} else {
|
||||
levelWaitClock = 240;
|
||||
levelWaitClock = 210;
|
||||
killBullets = TRUE;
|
||||
if(paused){ paused = FALSE; clearPause(); }
|
||||
XGM2_stop();
|
||||
}
|
||||
}
|
||||
updateTreasures();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue