;############## CMonster by Patrick Davidson - bonus brick Check_Drop_Bonus: call get_rand and 127 cp 4 ret nc ; exit if outside range (don't drop anything) ld hl,bonus_type ; exit if bonus existing bit 2,(hl) ret nz add a,4 ld (hl),a inc hl ld a,(de) and %11111000 ld (hl),a inc hl inc de ld a,(de) ld (hl),a ret Show_Bonus: ld a,(bonus_type) or a ret z ; exit if type is 0 ld hl,bonus_y inc (hl) ld a,(hl) cp 217 jr c,bonus_still_on_screen dec hl ld a,(hl) ; A = bonus X ld hl,p_x sub (hl) ; A = bonus X - paddle X add a,7 cp 34 jr c,collect_bonus ld a,(bonus_y) cp 232 jr nz,bonus_still_on_screen remove_bonus_brick: ld hl,bonus_type ld a,(hl) or a ret z ld (hl),0 inc hl ld b,(hl) inc hl ld l,(hl) dec l ld de,img_fake_bonus ld a,8 jp Erase_Sprite_Check_Clip_Below bonus_still_on_screen: ld bc,(bonus_type-1) ld hl,bonus_images-(66*4) ld de,66 loop_find_image: add hl,de djnz loop_find_image ex de,hl ld hl,(bonus_x) ld b,l ld l,h ld a,8 call Draw_Sprite_Check_Clip_Below_16 ld a,(bonus_y) dec a and 7 call Draw_Brick_Set_Single_Line ld de,(bonus_x) ld a,e rra rra rra and 31 ld b,a ld a,d dec a rra rra rra and 31 push af push bc sla b sla b sla b sla b ; B = X * 16 add a,b ld d,a ld e,a ld hl,12345 add hl,de ex de,hl pop bc pop af call Draw_Brick jp Draw_Brick_Set_Normal collect_bonus: ld hl,remove_bonus_brick push hl ld a,(bonus_type) sub 5 jr z,collect_multi_ball dec a jr z,collect_bonus_points dec a jr z,collect_extra_life collect_brickthrough: ld a,2 ld (brickthrough),a ret collect_bonus_points: ld de,score_bonus+6 ld hl,score+6 jp Add_6_Digits_BCD collect_extra_life: #ifndef TI84CE call Full_Window #endif ld hl,lives ld a,(hl) cp 99 ret z inc (hl) call Decode_Lives ld a,(livesm) ld bc,15*4*256+232 call Draw_Char ld a,(livesm+1) ld bc,16*4*256+232 jp Draw_Char collect_multi_ball: ld hl,b_type ld a,(hl) or a jr nz,found_source ld hl,b2 ld a,(hl) or a jr nz,found_source ld hl,b3 found_source: ld de,b_type call Duplicate_Ball ld de,b2 call Duplicate_Ball ld de,b3 Duplicate_Ball: ld a,(de) or a ret nz ; don't duplicate over existing ball push hl ld bc,3 ; copy type and coordinates ldir call get_rand ; select from middle bounce directions at random and 6 ld c,a ld b,0 ld hl,ball_directions+2 add hl,bc ld c,2 ldir call get_rand pop hl add a,a ret c ; half the time negate Y velocity dec de ld a,(de) neg ld (de),a ret get_rand: ld hl,rand_inc ; generate random bonus type ld a,(hl) inc hl add a,(hl) ld (hl),a ret