**************************************************************************** **************************************************************************** ** ** Platinum Edition (Startup/interrupt/timing code) ** ** This software is in the public domain. There is no warranty. ** ** by Patrick Davidson (pad@calc.org, http://pad.calc.org/) ** ** Last updated August 3, 2001 ** **************************************************************************** **************************************************************************** ******************************************** INITIALIZATION data_size equ data_end-data_start score_size equ 24*8 var_size equ data_size+score_size+2+4+7 initialize_all: sf game_started(a5) ; initialize configuration data clr.w ludicrous(a5) clr.w classic(a5) move.w #1,difficulty(a5) clr.w back_type(a5) bra.s data_ready start_program: move.w #0,oskey ; OS keyboard routines off move.l ($64).w,oldint1 ; install replacement interrupt 1 lea trigger(pc),a0 move.l a0,($64).w lea -offset(a7),a7 ; allocate local variables lea (a7),a5 jsr _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 Hardware_Check bsr Initialize_Info pea plane0(a5) jsr _grayscale_on move.l #(239<<16)+127,-(sp) move.l plane1(a5),-(sp) JSR_ROM PortSet IFD ti92plus move.l plane0(a5),a0 move.l plane1(a5),a1 move.w #959,d2 moveq #0,d1 moveq #-1,d0 \loop: move.l d0,(a0)+ move.l d1,(a1)+ dbra d2,\loop ENDIF bsr main_game exit_program: jsr _grayscale_off move.w #var_size,-(sp) ; attempt to create save file jsr _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 final_data: dc.b 0,'PlEd',0,$F8 EVEN ******************************************** HARDWARE VERSION CHECK * * This routine checks the calculator's hardware version and sets the timer * delay appropriately. The hardware checking comes from code written by * Zeljko Juric posted on the assembly-89 mailing list. * ******** Hardware_Check: lea Timer_Delay+6(pc),a2 move.l $C8,d1 and.l #$600000,d1 move.l d1,a1 move.l 260(a1),a0 move.l a0,d2 sub.l d1,d2 cmp.l #$FFFF,d2 bhi.s hw1 cmpi.w #$16,(a0) bls.s hw1 move.l $16(a0),d1 subq.w #1,d1 beq.s hw1 hw2: move.w #8,(a2) rts hw1: move.w #12,(a2) rts ******************************************** SLOW DOWN TO 32 FRAMES/SEC * * This routine regulates the speed of gameplay to ensure that it runs * always at 32 frames per second. * ******** Timer_Delay: move.w ticks(pc),d0 cmp.w #12,d0 blt.s Timer_Delay move.w #0,ticks rts trigger: addq.b #1,ticks+1 tst.w oskey bne.s call_old_int1 rte call_old_int1: movem.l d0/a0,-(sp) lea (LCD_MEM+99*30+20).w,a0 moveq #5,d0 \loop: move.l -(a0),-(sp) move.l -(a0),-(sp) move.l -(a0),-(sp) move.l -(a0),-(sp) move.l -(a0),-(sp) lea -10(a0),a0 dbra d0,\loop pea return(pc) move.w sr,-(sp) move.l oldint1(pc),a0 jmp (a0) return: lea (LCD_MEM+94*30).w,a0 moveq #5,d0 \loop: move.l (sp)+,(a0)+ move.l (sp)+,(a0)+ move.l (sp)+,(a0)+ move.l (sp)+,(a0)+ move.l (sp)+,(a0)+ lea 10(a0),a0 dbra d0,\loop movem.l (sp)+,d0/a0 rte oldint1: dc.l 0 ticks: dc.w 0 oskey: dc.w 0