Prev: 8EB7 Up: Map Next: 8F5F
8EE7: Draw the smash bar
Used by the routine at main_loop.
draw_smash_bar 8EE7 LD A,($A22E) Return if the perp has not yet been sighted
8EEA AND A
8EEB RET Z
8EEC LD A,($A230) Return if perp_caught_stage is >= 3 (car has stopped)
8EEF CP $03
8EF1 RET NC
8EF2 LD HL,$F7A2 Back buffer address of bottom of bar
8EF5 LD DE,$0F10 D = 15 = mask, E = 16 = row stride
Draws bottom two rows
8EF8 LD B,$02 2 rows
8EFA CALL draw_smash_bar_solid_bit Call draw_smash_bar_solid_bit
8EFD LD A,($A233) Get smash_counter
8F00 AND A Jump straight to drawing solid if it's zero (whole bar solid)
8F01 JR Z,draw_smash_bar_solid_top
8F03 LD C,A Set iterations in C for call
8F04 EX AF,AF' Preserve smash_counter
8F05 CALL draw_smash_bar_segment Call draw_smash_bar_segment
8F08 EX AF,AF' Restore smash_counter
draw_smash_bar_solid_top 8F09 LD C,A Iterations = smash_counter
8F0A ADD A,A B = ~(A * 3) + 63 = amount of solid rows to draw
8F0B ADD A,C
8F0C CPL
8F0D ADD A,$3F
8F0F LD B,A
8F10 JP draw_smash_bar_solid_bit Call draw_smash_bar_solid_bit
draw_smash_bar_segment 8F13 LD (HL),$81 Set 8 pixels to "X......X"
8F15 LD A,H Save for checking in a moment
8F16 DEC H Move to next scanline
8F17 AND D Would it have rolled over into the top nibble?
8F18 JP NZ,draw_smash_bar_segment2 No - continue
It rolled over
8F1B LD A,H Put back the bit stolen by rollover
8F1C ADD A,E
8F1D LD H,A
8F1E LD A,L Move to next chunk of 16 scanlines
8F1F SUB $20
8F21 LD L,A
8F22 JP NC,draw_smash_bar_segment2 Continue if it didn't roll over
8F25 LD A,H Otherwise move to the next chunk of 128 scanlines (would put us outside the back buffer)
8F26 SUB E
8F27 LD H,A
draw_smash_bar_segment2 8F28 LD (HL),$81 Set 8 pixels to "X......X"
8F2A LD A,H Save for checking in a moment
8F2B DEC H Move to next scanline
8F2C AND D Would it have rolled over into the top nibble?
It rolled over
8F2D JP NZ,draw_smash_bar_segment_cont No - continue
8F30 LD A,H Put back the bit stolen by rollover
8F31 ADD A,E
8F32 LD H,A
8F33 LD A,L Move to next chunk of 16 scanlines
8F34 SUB $20
8F36 LD L,A
8F37 JP NC,draw_smash_bar_segment_cont Continue if it didn't roll over
8F3A LD A,H Otherwise move to the next chunk of 128 scanlines (would put us outside the back buffer)
8F3B SUB E
8F3C LD H,A
draw_smash_bar_segment_cont 8F3D LD B,$01 1 row
8F3F CALL draw_smash_bar_solid_bit Call draw_smash_bar_solid_bit
8F42 DEC C Loop while iterations remain
8F43 JP NZ,draw_smash_bar_segment
8F46 RET Return
draw_smash_bar_solid_bit 8F47 LD (HL),$FF Set 8 pixels to solid black
Move to next scanline
8F49 LD A,H Save for checking in a moment
8F4A DEC H Move to next scanline (visually upwards)
8F4B AND D Would it have rolled over into the top nibble?
8F4C JP NZ,draw_smash_bar_cont No - continue
It rolled over
8F4F LD A,H Put back the bit stolen by rollover
8F50 ADD A,E
8F51 LD H,A
8F52 LD A,L Move to next chunk of 16 scanlines
8F53 SUB $20
8F55 LD L,A
8F56 JP NC,draw_smash_bar_cont Continue if it didn't roll over
8F59 LD A,H Otherwise move to the next chunk of 128 scanlines (would put us outside the back buffer)
8F5A SUB E
8F5B LD H,A
draw_smash_bar_cont 8F5C DJNZ draw_smash_bar_solid_bit Loop while iterations remain
8F5E RET Return
Prev: 8EB7 Up: Map Next: 8F5F