;############## Calcuzap by Patrick Davidson - enemies moving according to patterns boss_main: call boss_shoot_maybe ld de,e_misc add hl,de ld a,(hl) dec hl dec hl #ifdef TI84CE dec hl #endif dec hl dec hl ; HL -> X add a,a ; double speed and test if negative push hl jr c,boss_going_left call move_right pop hl ld a,(hl) ; A = X coordinate of boss cp 48+160-12 ; compare with right edge ret nz inc hl inc hl inc hl #ifdef TI84CE inc hl #endif inc hl ; HL -> e_misc ld (hl),-1 ; set X velocity to -1 (go left) ret boss_going_left: call move_left pop hl ld a,(hl) ; A = X coordinate of boss cp 48 ; compare with left edge ret nz inc hl #ifdef TI84CE inc hl #endif inc hl inc hl inc hl ; HL -> e_misc ld (hl),1 ;set X velocity to 1 (go right) ret boss_entering: ld a,1 inc hl ; HL -> e_x push hl call move_down pop hl inc hl inc hl inc hl #ifdef TI84CE inc hl #endif inc hl dec (hl) ret nz ; still in descent countdown ld (hl),1 ld bc,-e_misc add hl,bc ; HL -> e_type ld (hl),21 ret zigzag_waiting: push hl ld de,e_misc add hl,de dec (hl) pop hl ret nz ld (hl),57 zigzag_init: inc hl zigzag_init_x: ld (hl),60 ; X inc hl ld (hl),0 ; Y dec hl dec hl zigzag: call heavy_shoot_maybe inc hl ; HL -> e_x push hl ld de,e_misc-e_x add hl,de ; HL -> e_misc inc (hl) ld a,(hl) ; A = e_misc value cp 187 jr z,zigzag_restart pop hl ; HL -> e_x sub 30 jp c,pattern_down cp 128 jp nc,pattern_up bit 4,a jp z,pattern_downright jp pattern_upright zigzag_restart: ld (hl),0 pop hl push hl ld b,(hl) inc hl ld c,(hl) ld de,(7*256)+14 call Erase_Rectangle pop hl jr zigzag_init_x megaboss: call megaboss_shoot_maybe inc hl ld b,(hl) inc hl ld a,(hl) cp 20 dec hl jr z,megaboss_entry_complete ld a,1 jp move_down megaboss_entry_complete: push hl ld a,(hl) ; A = X ld de,e_misc-e_x add hl,de ; HL -> X-velocity cp 60 jr nz,megaboss_not_left_edge ld (hl),1 megaboss_not_left_edge: cp 180 jr nz,megaboss_not_right_edge ld (hl),-1 megaboss_not_right_edge: ld a,(hl) ; A = X-velocity pop hl ; HL -> X coordinate bit 7,a jp nz,move_left jp move_right swoop_wait: ld de,e_misc push hl add hl,de ld a,(frame_count) rra jr c,no_swoop_dec dec (hl) push hl ld de,img_sliding_enemy #ifdef TI84CE dec hl dec hl dec hl ld (hl),de #else dec hl ld (hl),d dec hl ld (hl),e #endif pop hl inc hl inc hl ; HL -> e_pattern ld a,(hl) ; A = initial X pop hl ret nz ld (hl),42 inc hl ld (hl),a ; initial X inc hl ld (hl),0 ; initial Y ret no_swoop_dec: pop hl ret swoop_active: call enemy_shoot_maybe inc hl call maybe_spin ld a,1 push hl call move_down pop hl push hl inc hl ld a,(hl) ; A = new Y coordinate ld de,e_pattern+1-e_y add hl,de cp (hl) pop hl ret nz dec hl ld (hl),45 ret swoop_right: call enemy_shoot_maybe inc hl call maybe_spin ld a,1 push hl call move_right pop hl push hl ld a,(hl) ; A = new X coordinate ld de,e_pattern-e_x add hl,de add a,(hl) cp 246 pop hl ret nz dec hl ld (hl),48 ret swoop_up: call enemy_shoot_maybe inc hl call maybe_spin ld a,-1 push hl call move_up pop hl inc hl ld a,(hl) ; A = Y coordinate after moving up or a ret nz ld de,e_pattern-e_y add hl,de ld a,(hl) ; A = (re)start X coordinate ld de,e_x-e_pattern add hl,de ld b,(hl) ; B = old X coordinate ld (hl),a dec hl ld (hl),42 ld c,12 ld e,2 ld d,14 jp Erase_Rectangle pattern_active: call diagonal_shoot_maybe inc hl call always_spin push hl ld de,e_misc-e_x add hl,de ; HL -> counter dec (hl) inc hl inc hl ; HL -> pattern pointer #ifdef TI84CE ld de,(hl) #else ld e,(hl) inc hl ld d,(hl) #endif jr nz,pattern_segment_not_over inc de inc de ; DE -> new pattern segment ld a,(de) add a,a jr nc,pattern_not_over push hl ex de,hl #ifdef TI84CE ld de,-1 #else ld d,-1 #endif ld e,a add hl,de ex de,hl pop hl pattern_not_over: inc de ld a,(de) ; A = new counter dec de #ifdef TI84CE ld (hl),de #else ld (hl),d dec hl ld (hl),e #endif dec hl dec hl ; HL -> e_misc ld (hl),a ; save new countdown pattern_segment_not_over: ld a,(de) ; A = direction pop hl ; HL -> X ld (to_pattern_segment+1),a to_pattern_segment: jr to_pattern_segment jr pattern_up jr pattern_upright jr pattern_right jr pattern_downright jr pattern_down jr pattern_downleft jr pattern_left pattern_upleft: ld bc,$FFFE jp move_up_left ;############## Calcuzap by Patrick Davidson - enemies moving in patterns pattern_downleft: ld bc,$FF02 jp move_down_left pattern_down: ld a,2 jp move_down pattern_up: ld a,-2 jp move_up pattern_left: ld a,-1 jp move_left pattern_right: ld a,1 jp move_right pattern_downright: ld bc,$0102 jp move_down_right pattern_upright: ld bc,$01FE jp move_up_right pattern_wait: ld de,e_misc add hl,de dec (hl) ret nz inc hl inc hl ; HL -> pattern pointer #ifdef TI84CE ld de,(hl) #else ld e,(hl) inc hl ld d,(hl) dec hl #endif inc de ; DE -> second byte of pattern (counter) ld a,(de) dec hl dec hl ; HL -> e_misc again ld (hl),a ; save remaining time on pattern segment ld de,-e_misc add hl,de ld (hl),36 ; save new enemy type (active pattern-based) ret enemy_down: push de call enemy_shoot_maybe pop de inc hl push hl call maybe_spin ld a,1 call move_down jr enemy_change_direction enemy_up: push de call enemy_shoot_maybe pop de inc hl push hl call maybe_spin ld a,-1 call move_up jr enemy_change_direction enemy_right: push de call enemy_shoot_maybe pop de inc hl push hl call maybe_spin ld a,1 call move_right jr enemy_change_direction enemy_left: push de call enemy_shoot_maybe pop de inc hl push hl call maybe_spin ld a,-1 call move_left enemy_change_direction: pop hl ; HL -> e_x inc hl inc hl #ifdef TI84CE inc hl #endif inc hl inc hl ; HL -> e_misc dec (hl) ; remaining duration this direction ret nz ld (hl),25 ld bc,-e_misc add hl,bc ld a,(hl) add a,3 ld (hl),a and %111111 cp 15 ret nz ld (hl),3 ret