;############## Calcuzap by Patrick Davidson - level setup next_level: ld a,(level) inc a wrap: ld (level),a call Decode_Level ld a,(levelm) ld bc,24*4*256+232 call Draw_Char ld a,(levelm+1) ld bc,25*4*256+232 call Draw_Char #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 few_xs jp many_xs jp many_xs_and_boss jp square_spinner_tough jp indented_spinner_tough jp boss_spinner_tough pop hl ld hl,win_message jp check_highscore few_xs: ld a,128 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 de,img_x_enemy ld a,30 jr to_place_enemy_row_early many_xs_and_boss: 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,img_x_enemy 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: 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 jr 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 jr 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 jr common_levels square_small: ld de,img_small_enemy jr square_common square_large: ld de,img_large_enemy jr square_common 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: ld a,1 ld (flag_spin),a ld de,img_spin_start jr square_common square_green: xor a ld (flag_spin),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 ;############## 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 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 jr 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: #ifdef TI84CE jp place_enemy_row_standard #else jr place_enemy_row_standard #endif boss_entry: ld bc,(1*256)+48 ld h,17 ld de,img_boss ld a,(level) cp 3 jr nz,normal_boss_entry ld de,img_mild_boss normal_boss_entry 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 ;############## Fill in string from level number Decode_Level: ld l,a ld h,0 bcall(_DivHLBy10) add a,'0' ld (levelm+1),a ld a,l add a,'0' ld (levelm),a ret