**************************************************************************** **************************************************************************** ** ** Platinum Edition (Startup/interrupt/timing code) ** ** Copyright 2004 by Patrick Davidson. This software may be freely ** modified and/or copied with no restrictions. There is no warranty. ** ** by Patrick Davidson (pad@calc.org, http://pad.calc.org/) ** ** Last updated September 15, 2004 ** **************************************************************************** **************************************************************************** data_size equ data_end-data_start score_size equ 24*8 var_size equ data_size+score_size+2+4+7 VERSION equ 1 ******************************************** INITIALIZATION initialize_all: clr.w saved_game(a5) bra.s data_ready view_scores_only: bsr Display_High_Scores bra.s vars_ready start_program: lea -offset(a7),a7 ; allocate local variables lea (a7),a5 vars_ready: bsr Activate_Grayscale beq exit_program bsr _get_data_file ; attempt to load data file move.l a0,d0 beq.s initialize_all ; NULL -> nothing found cmp.w #var_size-2,(a0)+ bne.s initialize_all ; data invalid if wrong size cmp.l #VERSION,(a0)+ bne.s initialize_all ; data invalid if wrong version lea data_start(a5),a1 move.w #(data_size/2)-1,d0 ; load variable data \lvd: move.w (a0)+,(a1)+ dbra d0,\lvd lea High_Score_Data(pc),a1 ; load score data move.w #(score_size/2)-1,d0 \lsd: move.w (a0)+,(a1)+ dbra d0,\lsd data_ready: bsr Grayscale_Post_Init clr.w exit_status(a5) bsr main_game bsr Wait_No_Key bsr Deactivate_Grayscale cmp.w #EXIT_NOLEVEL,exit_status(a5) beq.s no_level_error cmp.w #EXIT_QUIT,exit_status(a5) beq.s no_save tst.w exit_status(a5) blt.s view_scores_only beq.s exit_program bsr Game_Finished exit_program: move.w #var_size,d6 ; attempt to create save file bsr _create_save_file move.l a0,d0 ; NULL -> unable to create beq.s no_save move.w #var_size-2,(a0)+ ; put variable size move.l #VERSION,(a0)+ lea data_start(a5),a1 ; save variables move.w #(data_size/2)-1,d0 \svd: move.w (a1)+,(a0)+ dbra d0,\svd lea High_Score_Data(pc),a1 ; save score data move.w #(score_size/2)-1,d0 \ssd: move.w (a1)+,(a0)+ dbra d0,\ssd lea final_data(pc),a1 ; put system junk at end of data moveq #6,d0 \sfd: move.b (a1)+,(a0)+ dbra d0,\sfd no_save: lea offset(a5),a7 rts no_level_error: lea LCD_MEM,a0 move.w #959,d0 \x: clr.l (a0)+ dbra d0,\x moveq #1,d0 bsr Set_Font moveq #5,d1 moveq #5,d0 lea nle1(pc),a0 bsr Display_String moveq #5,d1 moveq #25,d0 lea nle2(pc),a0 bsr Display_String \wel: bsr Read_All_Keys lea offset(a5),a7 GETEDGE 6,0,8,6 ; ESC bne.s \wel rts final_data: dc.b 0,'Mnst',0,$F8 nle1: dc.b 'No level files found!',0 nle2: dc.b 'Press ESC to exit',0 EVEN