98 lines
No EOL
2 KiB
C
98 lines
No EOL
2 KiB
C
#include <genesis.h>
|
|
#include <resources.h>
|
|
|
|
#include "global.h"
|
|
#include "background.h"
|
|
#include "bullets.h"
|
|
#include "enemies.h"
|
|
#include "humans.h"
|
|
#include "player.h"
|
|
#include "stage.h"
|
|
#include "chrome.h"
|
|
#include "start.h"
|
|
#include "sfx.h"
|
|
|
|
static void loadInternals(){
|
|
JOY_init();
|
|
JOY_setEventHandler(&updateControls);
|
|
SPR_init();
|
|
VDP_setPlaneSize(128, 32, TRUE);
|
|
VDP_loadFont(font.tileset, DMA);
|
|
PAL_setPalette(PAL0, font.palette->data, DMA);
|
|
PAL_setPalette(PAL1, shadow.palette->data, CPU);
|
|
VDP_setTextPriority(1);
|
|
}
|
|
|
|
void clearLevel(){
|
|
for(s16 i = 0; i < BULLET_COUNT; i++)
|
|
if(bullets[i].active) killBullet(i, FALSE);
|
|
for(s16 i = 0; i < ENEMY_COUNT; i++)
|
|
if(enemies[i].active){ enemies[i].hp = 0; killEnemy(i); }
|
|
for(s16 i = 0; i < HUMAN_COUNT; i++)
|
|
if(humans[i].active) killHuman(i);
|
|
humanBeingCarried = FALSE;
|
|
collectedCount = 0;
|
|
// black out everything
|
|
SPR_setVisibility(player.image, HIDDEN);
|
|
VDP_clearTileMapRect(BG_A, 0, 0, 128, 32);
|
|
VDP_clearTileMapRect(BG_B, 0, 0, 128, 32);
|
|
}
|
|
|
|
void loadGame(){
|
|
loadBackground();
|
|
loadPlayer();
|
|
loadChrome();
|
|
loadLevel(0);
|
|
started = TRUE;
|
|
}
|
|
|
|
static void updateGame(){
|
|
updateChrome();
|
|
updateSfx();
|
|
if(levelClearing){
|
|
levelClearClock++;
|
|
if(levelClearClock == 1){
|
|
clearLevel();
|
|
}
|
|
if(levelClearClock >= 120){
|
|
levelClearing = FALSE;
|
|
loadBackground();
|
|
loadChrome();
|
|
loadLevel(level + 1);
|
|
SPR_setVisibility(player.image, VISIBLE);
|
|
}
|
|
return;
|
|
}
|
|
if(!paused){
|
|
updatePlayer();
|
|
if(clock % 2 == 0){
|
|
updateEnemies();
|
|
if(!gameOver && enemyCount == 0){
|
|
if(level >= LEVEL_COUNT - 1){
|
|
gameOver = TRUE;
|
|
} else {
|
|
levelClearing = TRUE;
|
|
levelClearClock = 0;
|
|
}
|
|
}
|
|
updateHumans();
|
|
} else {
|
|
updateBackground();
|
|
updateBullets();
|
|
}
|
|
}
|
|
}
|
|
|
|
int main(bool hardReset){
|
|
loadInternals();
|
|
loadStart();
|
|
while(1){
|
|
if(started) updateGame();
|
|
else updateStart();
|
|
clock++;
|
|
if(clock >= CLOCK_LIMIT) clock = 600;
|
|
SPR_update();
|
|
SYS_doVBlankProcess();
|
|
}
|
|
return(0);
|
|
} |