f;############# Calcuzap by Patrick Davidson - title screen Show_Title_Screen: ld a,86 ld (delay_amount),a ld a,'1' ld (score_inc),a call Clear_Screen ld hl,title_screen call Draw_Strings ld hl,$B000 ld (wait_count),hl ld hl,0 ld (title_count),hl #ifndef TI84CE ld a,2 ld (smc_mask+1),a #endif loop_title: ld hl,(wait_count) inc hl ld (wait_count),hl ld a,h or l ld c,1 ret z ld hl,(title_count) inc hl inc hl ld a,h and 31 ; position limited to 32*256 pixels = 1024 chars ld h,a ld (title_count),hl #ifndef TI84CE ld a,(smc_mask+1) rrca rrca ld (smc_mask+1),a #endif ld hl,0 ; HL = X coordinate of segment of scroll being drawn loop_scroll_message: push hl push hl ld a,(title_count) sub l ld hl,scroll_table #ifdef TI84CE ld de,0 #else ld d,0 #endif ld e,a add hl,de ld a,l add a,h or %1100001 ld (smc_color_selection+1),a ld b,(hl) ; B = Y coordinate for character pop hl ; HL = X coordinate for character push hl ld hl,(title_count) pop de ; DE = X coordinate for character add hl,de ex de,hl ; HL = X coordinate, DE = X coordinate + adjust amount #ifdef TI84CE ld a,e and 7 ld c,a ; C = X coordinate within character #endif srl d rr e srl d rr e srl d rr e push hl ld hl,scroll_message add hl,de ld a,(hl) pop hl call Draw_Vertical_Subchar pop hl inc hl ld a,h dec a jr nz,loop_scroll_message ld a,l cp 64 jr nz,loop_scroll_message call GET_KEY ld c,1 cp skClear ret z cp skDel ret z dec c cp sk2nd ret z cp skAdd jr z,easy_selected cp skSub jr z,hard_selected cp skAlpha jr z,title_show_highscore ld b,9 ld hl,speed_table loop_search_speed: cp (hl) inc hl jr z,speed_match inc hl djnz loop_search_speed jp loop_title easy_selected: xor a ld hl,easy jr difficulty_selected hard_selected: ld a,-1 ld hl,hard difficulty_selected: ld (hard_flag),a ld bc,(52*256)+85 call Draw_String jp loop_title speed_match: ld a,'0'+10 sub b ld (score_inc),a ld a,(hl) ld (delay_amount),a ld a,(score_inc) ld bc,(40*256)+95 call Draw_Char jp loop_title title_show_highscore: call show_highscores jp Show_Title_Screen ; ############# Draw a vertical slice of a character ; HL = X coordinate ; A = character ; B = Y coordinate ; C = slice (0 - 7) Draw_Vertical_Subchar: #ifdef TI84CE push hl sub 32 ld hl,0 add a,a ld l,a ld de,tileData add hl,hl add hl,hl add hl,de ; HL -> start of char ex de,hl pop hl ; HL = X coordinate push de ; save character pointer on stack push hl ; save X coordinate on stack ld a,c add a,a add a,a add a,a xor %01111111 ld (smc_bit_selection+1),a ld hl,0 ld de,0 ld e,b ld l,b add hl,hl add hl,hl add hl,de ; HL = 5 * Y add hl,hl add hl,hl ; HL = 20 * Y add hl,hl add hl,hl ; HL = 80 * Y add hl,hl add hl,hl ; HL = 320 * Y pop de add hl,de ; HL = 320 * Y + X add hl,hl ; HL = 640 * Y + 2 * X ld de,$D40000 add hl,de call blank_3_rows pop de ld b,8 loop_char_main_slice: ld a,(de) inc de smc_bit_selection: bit 7,a smc_color_selection: ld a,$ff jr z,char_slice_set xor a char_slice_set: push bc ld bc,320*2-1 ld (hl),a inc hl ld (hl),a add hl,bc ld (hl),a inc hl ld (hl),a add hl,bc pop bc djnz loop_char_main_slice blank_3_rows: ld bc,320*2-1 ld a,3 loop_verticalsub: ld (hl),0 inc hl ld (hl),0 add hl,bc dec a jr nz,loop_verticalsub ret #else push af push bc ld a,$52 ; minimum X call Write_Display_Control ld a,$21 ; current X call Write_Display_Control ld a,$53 ; maximum X call Write_Display_Control pop bc ld h,0 ld l,b ld a,$50 ; minimum Y call Write_Display_Control ld a,$20 ; current Y call Write_Display_Control ld a,$22 out ($10),a out ($10),a call blank_3_rows smc_color_selection: ld c,$ff pop af sub 32 add a,a ld l,a ld h,0 ld de,tileData add hl,hl add hl,hl add hl,de smc_mask: ld a,1 rrca ld (smc_mask+1),a ld e,a ld b,8 loop_char_main_slice: ld a,(hl) inc hl and e ld a,c jr z,char_slice_set xor a char_slice_set: out ($11),a out ($11),a out ($11),a out ($11),a djnz loop_char_main_slice blank_3_rows: xor a out ($11),a out ($11),a out ($11),a out ($11),a out ($11),a out ($11),a ret #endif GET_KEY: #ifdef TI84CE push hl push de push bc di ld hl,$F50004 ld (hl),8 inc hl ld (hl),8 ld l,0 ld (hl),2 xor a wait_for_keys: cp (hl) jr nz,wait_for_keys ld e,0 ; E = GET_KEY result ld d,e ; D = current key counter ld hl,getkeylastdata ld bc,$F5001E ; pointer to key input data scan_next_row: ld a,(bc) ; A = one row of key data push bc ld c,(hl) ; C = previous scan results ld (hl),a ; save the new results inc hl cpl ; bits set to 0 for pressed keys or c ; now 0 for newly pressed only ld b,8 scan_next_column: inc d ; D = next char value rrca jr c,key_not_pressed ld e,d key_not_pressed: djnz scan_next_column pop bc dec bc dec bc ld a,c cp $10 ; check if at port $F50010 jr nz,scan_next_row ; if so, done ei ld a,e pop bc pop de pop hl ret #else push hl push de push bc ld e,0 ; E = GET_KEY result ld hl,getkeylastdata ; HL = ptr to last read's table ld a,$fe ; A = key port mask ld c,e ; C = key number counter gkol: out (1),a ; select row to read rlca ; next row to read ld b,20 key_wait: djnz key_wait ld b,8 push af ld d,(hl) ; D = old mask in a,(1) ; A = new mask ld (hl),a gkl: inc c ; increment current key number rrca jr c,nokey ; not pressed now bit 0,d jr z,nokey ; already pressed ld e,c ; newly pressed nokey: rr d djnz gkl pop af inc hl cp $7F ; final row not present jr nz,gkol ld a,e pop bc pop de pop hl ret #endif getkeylastdata: .db $ff,$ff,$ff,$ff,$ff,$ff,$ff title_screen: .db 24,10 .db "Calcuzap by Patrick Davidson",0 .db 40,20 .db "eeulplek@hotmail.com",0 .db 14,30 .db "http://www.ocf.berkeley.edu/~pad/",0 .db 6,40 .db "IRC: PatrickD on EfNet #ti, #cemetech",0 .db 18,50 .db "eeulplek on Twitter and YouTube",0 .db 4,85 .db "Difficulty: " easy: .db "Easy (Select with + and -)",0 .db 12,95 .db "Speed: 1 (Select with 1 through 9)",0 .db 26,140 .db "Press 2ND to start the game",0 .db 12,150 .db "Arrows move, DEL exits, 2ND shoots",0 .db 30,160 .db "MODE saves game and exits",0 .db -1 hard: .db "Hard",0 #ifdef TI84CE scroll_message: .fill 40,' ' #import "scroll.txt" .fill (scroll_message+1024+40-$),' ' #endif speed_table: .db sk1,86 .db sk2,82 .db sk3,78 .db sk4,75 .db sk5,70 .db sk6,65 .db sk7,61 .db sk8,56 .db sk9,51