;############## Calcuzap by Patrick Davidson - enemy bullets ;############## Move/draw enemy bullets ; Calls the code specified by the bullet 'type'. The 'type', which must ; be a multiple of 3, is an index into the table of jumps for bullet code. ; Bullet routines should move the bullet and draw its image. They are ; called with HL pointing to the bullet entry, and can change all registers. process_enemy_bullets: ld hl,p_x call set_collision_check_object ld hl,enemy_bullets ld b,eb_count loop_enemy_bullets: ld a,(hl) push hl push bc call do_enemy_bullet pop bc pop hl ld de,eb_size add hl,de djnz loop_enemy_bullets ret do_enemy_bullet: #ifdef TI84CE push hl ld bc,0 ld c,a ld hl,enemy_bullet_table add hl,bc ld hl,(hl) ex (sp),hl ret #else ld (smc_do_enemy_bullet+1),a smc_do_enemy_bullet: jr point_to_enemy_bullet_code point_to_enemy_bullet_code: #endif ;############## Bullet routine table starts here enemy_bullet_table: #ifdef TI84CE .dl null_ebullet ; 0 = no bullet here .dl new_ebullet .dl normal_ebullet ; 6 .dl removed_object ; 9 .dl boss_ebullet ; 12 .dl bonus_block ; 15 .dl aimed_left ; 18 .dl aimed_right ; 21 .dl aimed_full_left ; 24 .dl aimed_full_right .dl new_lightning ; 30 .dl eb_lightning ; 33 #else jp null_ebullet ; 0 = no bullet here jp new_ebullet jp normal_ebullet ; 6 jp removed_object ; 9 jp boss_ebullet ; 12 jp bonus_block ; 15 jp aimed_left ; 18 jp aimed_right ; 21 jp aimed_full_left ; 24 jp aimed_full_right jp new_lightning ; 30 ; 33 #endif eb_lightning: ld a,5 jr common_ebullet aimed_full_right: ld bc,$102 jr aimed_right_BC aimed_full_left: ld bc,$ff02 jr aimed_left_BC aimed_right: ld bc,$103 aimed_right_BC: inc hl ld a,(hl) cp 208-3 jp z,removed_object_x push hl call move_down_right jr ebullet_after_move aimed_left: ld bc,$ff03 aimed_left_BC: inc hl ld a,(hl) cp 48 jp z,removed_object_x push hl call move_down_left jr ebullet_after_move bonus_block: ld a,2 jr common_ebullet boss_ebullet: ld a,4 jr common_ebullet normal_ebullet: #ifdef SLOW_BULLETS ld a,1 #else ld a,3 #endif common_ebullet: inc hl ; HL -> X push hl call move_down ebullet_after_move: pop hl inc hl ld a,(hl) cp 244 ; remove bullet if Y is 244 or below jp nc,remove_bullet ld de,(player_cd) ; no hits when player in ghost/explosion mode ld a,d or e ret nz dec hl push hl call collision_check pop hl ret nc hit_you: push hl dec hl call removed_object pop hl inc hl inc hl #ifdef TI84CE ld de,(hl) #else ld e,(hl) inc hl ld d,(hl) ; DE = image pointer #endif dec de ld a,(de) ld hl,lives dec a jr z,collect_bonus_points dec a jr z,collect_bonus_life dec a jr z,collect_bonus_weapon dec a jr z,collect_bonus_weapon_3 dec a jr Z,collect_bonus_weapon_4 ld a,(hl) or a ret z dec (hl) inc hl ld (hl),1 ; set player_cd (countdown) ld hl,p_x call erase_object_x ld de,img_enemy_explode ld (p_image),de Show_Lives: ld hl,(lives) ld h,0 bcall(_DivHLBy10) add a,'0' push hl ld bc,16*4*256+232 call Draw_Char pop hl ld a,l add a,'0' ld bc,15*4*256+232 jp Draw_Char collect_bonus_life: ld a,(hl) cp 99 ret z inc (hl) jr Show_Lives collect_bonus_weapon: inc a set_p_weapon: ld (p_weapon),a null_ebullet: ret collect_bonus_weapon_3: ld a,2 jr set_p_weapon collect_bonus_weapon_4: ld a,3 jr set_p_weapon collect_bonus_points: ld hl,score+5 ; and increment the score ld de,score_increment+4 ld a,(score_inc) ld (score_changed),a ld (de),a inc de ld b,5 jp loop_add_nocarry new_ebullet: ld a,6 ; set type to standard bullet ld (hl),a draw_object: inc hl ld b,(hl) ; X coordinate inc hl ld a,(hl) ; Y coordinate inc hl #ifdef TI84CE ld de,(hl) #else ld e,(hl) inc hl ld d,(hl) ; DE = image pointer #endif ld l,a jp Draw_Sprite_Packed new_lightning: ld a,33 ld (hl),a inc hl inc hl inc hl ld de,img_lightning_bullet #ifdef TI84CE ld (hl),de #else inc hl ld (hl),d dec hl ld (hl),e #endif dec hl dec hl dec hl jr draw_object