;############## Calcuzap by Patrick Davidson - level setup ;############## Patterns ; ; each segment of the pattern has 2 bytes - direction then count ; negative direction - jump back that many bytes segments ; direction: 0=up, 2=up/right, 4=right, 6=down/right, 8=down, 10=down/left, 12=left, 14=up/left pattern_flat_small: .db 8,40 .db 8,8,6,12,4,28,2,12,0,8,14,12,12,28,10,12,-8 pattern_flat_large: .db 8,18 .db 8,8,10,12,12,33,14,12,0,8,2,12,4,33,6,12,-8 pattern_flat_huge: .db 8,45 .db 8,8,6,12,4,88,2,12,0,8,14,12,12,88,10,12,-8 pattern_data_circle: .db 8,20 .db 8,18,6,12,4,18,2,12,0,18,14,12,12,18,10,12,-8 ; KKK EEEE ; L J D F ; L J D F ;| A JD G | ;| A DJ G | ;v A D J G v ; B D J H ; BCCC IIIH pattern_figure_eight: .db 8,26 .db 8,18 ;A .db 6,12 ;B .db 4,21 ;C .db 2,42 ;D .db 4,21 ;E .db 6,12 ;F .db 8,18 ;G .db 10,12 ;H .db 12,21 ;I .db 14,42 ;J .db 12,21 ;K .db 10,12,-12 next_level: ld a,(level) inc a wrap: ld (level),a call Show_Level #ifdef TI84CE ld a,(level) ld de,0 ld e,a ld hl,level_table-4 add hl,de #else ld de,(level) ld d,0 ld hl,level_table-3 #endif add hl,de add hl,de add hl,de jp (hl) level_table: jp square_green jp indented_green jp green_with_boss jp square_blue jp indented_blue jp blue_with_boss jp triangle_level jp square_small jp indented_small jp small_with_boss jp triangle_level jp square_large jp indented_large jp large_with_boss jp triangle_level jp square_spinner jp indented_spinner jp boss_spinner jp square_xo jp indented_xo jp xo_with_boss jp few_xs jp many_xs jp double_circle_pattern jp many_xs_and_boss jp square_spinner_tough jp indented_spinner_tough jp figure_eight_pattern jp boss_spinner_tough jp square_spinner_very_tough jp indented_spinner_very_tough jp double_flat_pattern jp boss_spinner_very_tough jp swoop_level jp megaboss_level jp few_os jp many_xs jp many_os_and_boss jp lightning_level jp lightning_level_double jp megaboss_later jp zigzag_few jp zigzag_many jp zigzag_boss jp few_vs jp many_xs jp many_vs_and_boss pop hl ld hl,win_message jp check_highscore megaboss_later: ld a,12 ld hl,img_roller_lightning jr megaboss_common megaboss_level: ld a,5 ld hl,img_roller_enemy megaboss_common: ld (spin_image),hl ld (smc_pattern_strength+1),a ld hl,megaboss_source ld de,enemies ld bc,e_dmg+1 ldir ld a,2 ld (flag_spin),a ld bc,(20*256)+48 xor a ld de,pattern_flat_huge ld hl,enemies+e_size jp install_pattern_enemies megaboss_source: .db 51,186,0 #ifdef TI84CE .dl img_megaboss_1 #else .dw img_megaboss_1 #endif .db -1,20 swoop_level: xor a ld (escape_flag),a ld hl,img_sliding_enemy ld (spin_image),hl ld a,2 ld (flag_spin),a ld hl,enemies ld b,11 dec a ld de,e_misc loop_store_swoop: ld (hl),39 ; e_type - swoop waiting add hl,de ; dl -> e_misc ld (hl),a ; entry delay add a,14 inc hl ld (hl),6 ; damage inc hl ld (hl),50 ; initial X inc hl ld (hl),89 ; max Y inc hl #ifdef TI84CE inc hl #endif djnz loop_store_swoop ret figure_eight_pattern: ld hl,img_roller_enemy ld (spin_image),hl ld a,2 ld (flag_spin),a ld hl,enemies ld bc,(21*256)+70 xor a ld de,pattern_figure_eight jr install_pattern_enemies double_flat_pattern: xor a ld (escape_flag),a ld hl,img_roller_enemy ld (spin_image),hl ld a,2 ld (flag_spin),a ld hl,enemies ld bc,(10*256)+48 xor a ld de,pattern_flat_small call install_pattern_enemies ld bc,(11*256)+200 xor a ld de,pattern_flat_large jr install_pattern_enemies double_circle_pattern: ld a,5 ld (smc_pattern_strength+1),a ld hl,img_roller_enemy ld (spin_image),hl ld a,2 ld (flag_spin),a ld hl,enemies ld bc,(10*256)+64 ; B = count, C = X xor a ; A = initial delay ld de,pattern_data_circle call install_pattern_enemies ld bc,(10*256)+144 ; B = count, C = X ld a,5 ; A = initial delay ld de,pattern_data_circle install_pattern_enemies: ld (hl),33 ; pattern enemy waiting inc hl ld (hl),c ; X coordinate inc hl ld (hl),0 ; Y coordinate inc hl ld (hl),img_roller_enemy&255 inc hl ld (hl),(img_roller_enemy>>8)&255 inc hl #ifdef TI84CE ld (hl),(img_roller_enemy>>16)&255 inc hl #endif add a,12 ld (hl),a ; e_misc inc hl smc_pattern_strength: ld (hl),5 ; e_dmg inc hl #ifdef TI84CE ld (hl),de inc hl inc hl inc hl #else ld (hl),e inc hl ld (hl),d inc hl #endif djnz install_pattern_enemies ret few_vs: ld de,img_vicious_spinner ld (spin_image),de ld a,130 jr xo_image_spin_set few_os: ld de,img_o_enemy jr xo_image_set few_xs: ld de,img_x_enemy xo_image_set: ld a,128 xo_image_spin_set: ld (flag_spin),a ld bc,(10*256)+48 ; B is count, C initial X coordinate ld hl,(37*256)+15 ; 0 data (down/right), 15 X increment ld (enemy_image),de ld a,30 jr to_place_enemy_row_early many_vs_and_boss: ld de,img_vicious_spinner ld a,129 jr xo_boss_image_spin_set many_xs_and_boss: ld de,img_x_enemy jr xo_boss_image_set many_os_and_boss: ld de,img_o_enemy xo_boss_image_set: ld a,128 xo_boss_image_spin_set: ld (enemy_image),de ld (flag_spin),a ld a,20 ld (enemy_delay),a ld hl,boss_entry ld (enemy_entry),hl many_xs: ld bc,(15*256)+48 ; B is count, C initial X coordinate ld hl,(37*256)+10 ; 0 data (down/right), 15 X increment ld de,(enemy_image) ld a,30 to_place_enemy_row_early: jp place_enemy_row boss_spinner_tough: ld de,img_spin_tough_start jr common_with_boss boss_spinner_very_tough: ld a,1 ld (escape_flag),a ld de,img_spin_very_tough_start jr common_with_boss boss_spinner: ld de,img_spin_start jr common_with_boss large_with_boss: ld de,img_large_enemy jr common_with_boss small_with_boss: ld de,img_small_enemy jr common_with_boss blue_with_boss: ld de,img_blue_enemy jr common_with_boss green_with_boss: ld de,img_plain_enemy common_with_boss: ld hl,second_boss_row ld (enemy_entry),hl ld a,20 ld (enemy_delay),a ld bc,(10*256)+48 ld hl,(90*256)+12 jp create_and_set_image indented_small: ld de,img_small_enemy jr indented_common indented_large: ld de,img_large_enemy jr indented_common indented_blue: ld de,img_blue_enemy indented_common ld hl,second_row_indented #ifdef TI84CE jp common_levels #else jr common_levels #endif indented_spinner_very_tough: ld de,img_spin_very_tough_start ld hl,second_row_indented jr to_common_levels indented_spinner_tough: ld de,img_spin_tough_start ld hl,second_row_indented jr common_levels indented_spinner: ld de,img_spin_start ld hl,second_row_indented jr common_levels indented_green: ld de,img_plain_enemy ld hl,second_row_indented to_common_levels: jr common_levels square_small: ld de,img_small_enemy jr square_common square_large: ld de,img_large_enemy jr square_common square_xo: ld a,128 ld (flag_spin),a ld de,img_xo_enemy jr square_common indented_xo: ld de,img_xo_enemy jr indented_common xo_with_boss: ld de,img_xo_enemy jr common_with_boss square_blue: ld de,img_blue_enemy jr square_common square_spinner_tough: ld a,2 ld (flag_spin),a ld de,img_spin_tough_start jr square_common square_spinner_very_tough: ld a,2 ld (flag_spin),a ld (escape_flag),a ld de,img_spin_very_tough_start jr square_common square_spinner: ld a,1 ld (flag_spin),a ld de,img_spin_start jr square_common square_green: xor a ld (flag_spin),a ld a,3 ld (default_weapon),a ld de,img_plain_enemy square_common: ld hl,second_row_not_indented common_levels: ld a,20 ld (enemy_delay),a ld (enemy_entry),hl ld bc,(7*256)+48 ; B is count, C initial X coordinate ld hl,(77*256)+20 ; 75 is data, 20 is X coordinate increment create_and_set_image: ld (enemy_image),de ld (spin_image),de ;############## Create a row of enemies place_enemy_row_standard: ld a,3 ld de,(enemy_image) place_enemy_row: ld (new_enemy_type+1),a ; A = enemy type ld a,l ; L = X coordinate increment ld (enemy_x_increment+1),a ld a,h ; H = misc data (entry countdown) ld (enemy_misc_data+1),a ld (smc_enemy_image+1),de ; enemy image new_enemy_loop: push bc ld hl,enemies ld b,e_count ld de,e_size loop_search_enemies: ld a,(hl) or a jr z,found_enemy add hl,de djnz loop_search_enemies pop bc ret found_enemy: pop bc new_enemy_type: ld (hl),3 ; enemy type inc hl ld a,c ld (hl),a ; enemy X coordinate enemy_x_increment: add a,30 ld c,a inc hl ld (hl),0 ; enemy Y coordinate inc hl smc_enemy_image: ld de,0 #ifdef TI84CE ld (hl),de inc hl inc hl inc hl #else ld (hl),e ; enemy image pointer inc hl ld (hl),d inc hl #endif enemy_misc_data: ld (hl),75 inc hl dec de ld a,(de) ld (hl),a djnz new_enemy_loop ret zigzag_boss: call zigzag_many ex de,hl ld hl,megaboss_source ld bc,e_dmg+1 ldir ret zigzag_many: ld bc,(17*256)+11 ; B = count, C = increment jr zigzag_common zigzag_few: ld bc,(11*256)+17 ; B = count, C = increment zigzag_common: ld hl,enemies ld de,img_heavy_enemy loop_store_zigzag: ld (hl),54 ; e_type - zigzag waiting inc hl inc hl inc hl ; HL -> e_image #ifdef TI84CE ld (hl),de inc hl inc hl #else ld (hl),e inc hl ld (hl),d #endif inc hl ; hl -> e_misc ld (hl),a ; entry delay add a,c inc hl ld (hl),12 ; damage inc hl inc hl inc hl #ifdef TI84CE inc hl #endif djnz loop_store_zigzag ret lightning_level_double: ld hl,enemies ld bc,(10*256)+100 xor a ld de,pattern_flat_small call install_pattern_enemies ld a,20 ld (enemy_delay),a ld hl,lightning_again ld (enemy_entry),hl ld bc,(5*256)+65 ; B is count, C initial X coordinate ld hl,(115*256)+25 ; 115 is data, 25 is X coordinate increment jp place_enemy_row_standard lightning_level: ld a,12 ld (smc_pattern_strength+1),a ld hl,img_roller_lightning ld (spin_image),hl ld hl,enemies ld bc,(11*256)+200 xor a ld (flag_spin),a ld de,pattern_flat_large call install_pattern_enemies ld a,30 ld (default_weapon),a ld hl,img_lightning_enemy ld (enemy_image),hl ld bc,(7*256)+48 ; B is count, C initial X coordinate ld hl,(115*256)+20 ; 115 is data, 25 is X coordinate increment jp place_enemy_row_standard triangle_level: ld de,img_triangle_enemy ld a,(level) srl a add a,4 ld b,a ld a,24 ld c,48 ld hl,(1*256)+15 jp place_enemy_row ;############## Routines for placing delayed-entry enemies second_row_not_indented: ld bc,(7*256)+48 ; B is count, C initial X coordinate jr second_row_common second_row_indented: ld bc,(7*256)+56 ; B is count, C initial X coordinate second_row_common: ld hl,(57*256)+20 ; 55 is data, 20 is X coordinate increment ld de,third_row_not_indented ld (enemy_entry),de ld a,20 ld (enemy_delay),a to_place_enemy_row_standard: jp place_enemy_row_standard boss_entry: ld bc,(1*256)+48 ld h,17 ld a,(level) ld de,img_boss cp 12 jr nc,boss_image_selected ld de,img_ufo_boss cp 4 jr nc,boss_image_selected ld de,img_mild_boss boss_image_selected: ld a,18 jp place_enemy_row third_row_not_indented: ld bc,(7*256)+48 ; B is count, C initial X coordinate ld hl,(37*256)+20 ; 37 is data, 20 is X coordinate increment jr to_place_enemy_row_standard second_boss_row: ld hl,boss_entry ld (enemy_entry),hl ld bc,(10*256)+48 ld hl,(70*256)+12 ld a,20 ld (enemy_delay),a jr to_place_enemy_row_standard lightning_again: ld bc,(5*256)+55 ; B is count, C initial X coordinate ld hl,(85*256)+25 ; 90 is data, 20 is X coordinate increment jp place_enemy_row_standard ;############## Fill in string from level number Show_Level: ld l,a ld h,0 bcall(_DivHLBy10) add a,'0' push hl ld bc,25*4*256+232 call Draw_Char pop hl ld a,l add a,'0' ld bc,24*4*256+232 jp Draw_Char