TK2048/src/dlog_main.c

64 lines
1.6 KiB
C

#include <stubs.h>
#include <string.h>
#include <calypsi/intrinsics6502.h>
#include "game_graphics.h"
#include "monitor_subroutines.h"
#include "utility.h"
#include "mem_map.h"
#include "shared_page.h"
#include "state_page.h"
#include "dlog_data.h"
#include "game_data.h"
#include "input.h"
#include "sound.h"
// External initialization requirements
#pragma require __preserve_zp
#pragma require __data_initialization_needed
static state_page_data* state_page = (state_page_data*)STATE_PAGE;
static shared_page_data *shared_page = (shared_page_data*)SHARED_PAGE;
void main(void) {
dlog_data *dld = (dlog_data *)(shared_page->module_data);
game_data *gad = (game_data *)(shared_page->module_data);
// Make sure the buffers are pointing to the correct memory
initialize_display_buffers();
switch(dld->mode) {
case DLOG_MODE_WIN:
snd_festive();
ddraw_endgame_box(1, dld->score, state_page->hi_score);
break;
case DLOG_MODE_LOSE:
snd_sad_scale();
ddraw_endgame_box(-1, dld->score, state_page->hi_score);
break;
default:
case DLOG_MODE_START:
ddraw_endgame_box(0, dld->score, state_page->hi_score);
snd_start();
break;
};
if(dld->score > state_page->hi_score) { // New high-score. We need to save it.
state_page->hi_score = dld->score;
shared_page->master_command = MASTER_COMMAND_SAVE;
} else {
shared_page->master_command = MASTER_COMMAND_NONE;
}
shared_page->next_module_idx = 4; // Go to the GAME module
gad->mode = GAME_MODE_NORMAL; // Set the proper start mode for the game
while(!read_any_key()) {
lfsr_update();
}
snd_mod_button();
return;
}