;############## Calcuzap by Patrick Davidson - player bullets ;############## Fire a player bullet fire_bullet: ld a,(ghost_timer) ; no shooting in ghost phase or a ret nz ld a,(p_weapon) or a jr z,fire_bullet_normal dec a jr z,fire_bullet_double dec a jr z,fire_bullet_triple ld a,7 ld c,26 call fire_bullet_normal_image ld a,-1 ld c,20 jr fire_bullet_normal_image fire_bullet_triple: ld c,8 call fire_bullet_normal_except_type xor a ld c,12 call fire_bullet_normal_image ld a,6 ld c,18 jr fire_bullet_normal_image fire_bullet_double: xor a ld de,img_player_bullet_fast ld c,8 call fire_bullet_ADE ld a,7 ld de,img_player_bullet_fast ld c,8 jr fire_bullet_ADE fire_bullet_normal: ld c,2 fire_bullet_normal_except_type: ld a,3 fire_bullet_normal_image: ld de,img_player_bullet fire_bullet_ADE: push de push af fire_bullet_main: ld hl,bullets ; Locate unused bullet in HL ld b,b_count ld de,b_size loop_search_bullet: ld a,(hl) or a jr z,found_bullet add hl,de djnz loop_search_bullet pop af pop de ret found_bullet: ld (hl),c inc hl ld a,(p_x) pop bc ; B = X offset add a,b ld (hl),a inc hl ld a,(p_y) sub 2 ld (hl),a inc hl pop de ; DE = bullet image #ifdef TI84CE ld (hl),de #else ld (hl),e inc hl ld (hl),d #endif ret ;############## Move/draw player bullets ; ; Calls the code specified by the bullet 'type'. The 'type', which must ; be a multiple of 2, 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. player_bullets: ld hl,bullets ld b,b_count loop_player_bullets: ld a,(hl) ld (do_player_bullet+1),a push hl push bc call do_player_bullet pop bc pop hl ld de,b_size add hl,de djnz loop_player_bullets ret new_xright: ld (hl),22 jr xright_after_erase xright: push hl call erase_object pop hl xright_after_erase: inc hl inc (hl) ld b,(hl) ld a,b cp 208-2 jp nc,remove_bullet_x ld c,9 jr bullet_x_in_b new_right: ld (hl),16 jr standard_right_after_erase standard_right: push hl call erase_object pop hl standard_right_after_erase: inc hl inc (hl) ld b,(hl) ld a,b cp 208-2 jr nc,remove_bullet_x ld c,8 jr bullet_x_in_b do_player_bullet: jr point_to_pbullet_code point_to_pbullet_code: ;############## Bullet routine table starts here no_pbullet: jr null_bullet ; 0 = no bullet here jr new_bullet ; 2 = new bullet (no erase) jr standard_bullet ; 4 = standard bullet jr removed_object ; 6 = bullet about to be removed (erase only) jr new_fast ; 8 jr standard_fast ; 10 jr new_left ; 12 jr standard_left ; 14 jr standard_right ; 16 jr new_right ; 18 jr new_xright ; 20 jr xright ; 22 jr xleft ; 24 ; 26 new_xleft: ld (hl),24 jr xleft_after_erase xleft: push hl call erase_object pop hl xleft_after_erase: inc hl dec (hl) ld b,(hl) ld a,b cp 48 jp c,remove_bullet_x ld c,9 jr bullet_x_in_b standard_fast: push hl call erase_object pop hl new_fast: ld a,10 ld c,8 jr common_bullet standard_bullet: push hl call erase_object pop hl new_bullet: ld a,4 ; set type to standard bullet #ifdef SLOW_BULLETS ld c,1 #else ld c,a #endif common_bullet: ld (hl),a inc hl ld b,(hl) ; X coordinate bullet_x_in_b: inc hl ld a,(hl) ; Y coordinate sub c jr c,remove_bullet ld (hl),a 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_left: ld (hl),14 jr standard_left_after_erase standard_left: push hl call erase_object pop hl standard_left_after_erase: inc hl dec (hl) ld b,(hl) ld a,b cp 48 jr c,remove_bullet_x ld c,8 jr bullet_x_in_b remove_bullet: dec hl remove_bullet_x: dec hl ld (hl),0 null_bullet: ret removed_object_x: dec hl removed_object: ld (hl),0 erase_object: inc hl erase_object_x: ld b,(hl) ; X coordinate inc hl ld c,(hl) ; Y coordinate inc hl #ifdef TI84CE ld hl,(hl) ld de,(hl) #else ld e,(hl) inc hl ld d,(hl) ; DE = image pointer ex de,hl ld e,(hl) ; height inc hl ld d,(hl) ; width #endif jp Erase_Rectangle