Prev: 92E1 Up: Map Next: 9542
949C: Sprite plotter for back buffer, up to 64px wide, 15px high, no mask, no flip
Used by the routines at reveal_perp_car, draw_object_right and draw_car.
Input
A Plot (A + 1) * 8 pixels
DE' Stride of bitmap data in bytes
HL Address in back buffer to plot at
HL' Address of bitmap data
plot_sprite 949C SRL A Use ps_odd if the bottom bit is set (odd widths)
949E JP C,ps_odd
94A1 LD IX,$94C8 IX = Base of jump table
94A5 CPL (~A + 5) is (4 - A) is the number of plot operations to skip
94A6 ADD A,$05
94A8 LD C,A Multiply A by 5: the length of an individual plot operation
94A9 RLCA
94AA RLCA
94AB ADD A,C
94AC LD C,A Move result to BC
94AD LD B,$00
94AF ADD IX,BC Add it to IX to complete the jump target
This entry point is used by the routine at draw_object_right.
plot_sprite_entry 94B1 LD ($94BF),SP Save SP to restore on exit (self modify)
94B5 LD BC,$0F10 B = 15 rows to draw, C = 16, an increment value used later
94B8 EXX Bank
94B9 JR ps_even_body Jump into body of loop
ps_even_loop 94BB EXX Bank
ps_even_continue 94BC DJNZ ps_even_next Next scanline
94BE LD SP,$0000 Restore original SP (self modified)
94C1 RET Return
ps_even_next 94C2 ADD HL,DE Calculate address of next bitmap scanline
ps_even_body 94C3 LD SP,HL Put it in SP (so we can use POP for speed)
94C4 EXX Unbank
94C5 LD A,L
94C6 JP (IX) Jump into table
ps_even_jumptable 94C8 POP DE Transfer two bitmap bytes (16 pixels) from the "stack" to screen buffer
94C9 LD (HL),E
94CA INC L
94CB LD (HL),D
94CC INC L
94CD POP DE Transfer another 16 pixels
94CE LD (HL),E
94CF INC L
94D0 LD (HL),D
94D1 INC L
94D2 POP DE Transfer another 16 pixels
94D3 LD (HL),E
94D4 INC L
94D5 LD (HL),D
94D6 INC L
94D7 POP DE Transfer another 16 pixels
94D8 LD (HL),E
94D9 INC L
94DA LD (HL),D
94DB LD L,A Restore row start address
Move to next back buffer row (addresses have the form 0b1111BAAACCCXXXXX where 0bCCCBAAA is the row index)
94DC LD A,H Preserve A for checking in a moment
94DD DEC H Move to next row (visually upwards)
94DE AND B Would it have rolled over into the top nibble? (B is a mask, 15, here)
94DF JP NZ,ps_even_loop No - continue
The row field BAAA was zero but the decrement changed it to 1111 and borrowed from the 1111 field at the top of the address.
94E2 LD A,H Fix 1111 field (C is 16 here)
94E3 ADD A,C
94E4 LD H,A
94E5 LD A,L Move to next chunk of 16 rows
94E6 SUB $20
94E8 LD L,A
94E9 JP NC,ps_even_loop No carry, so continue
Otherwise have to compensate 1111 field.
94EC LD A,H Undo carry
94ED SUB C
94EE LD H,A
94EF JP ps_even_loop Continue
ps_odd 94F2 INC A Increment A for upcoming calculation
94F3 LD IX,$951A Point IX at start of plot instructions
94F7 CPL (~A + 5) is (4 - A) is the number of plot operations to skip
94F8 ADD A,$05
94FA LD C,A Multiply A by 5: the length of an individual plot operation
94FB RLCA
94FC RLCA
94FD ADD A,C
94FE LD C,A Move result to BC
94FF LD B,$00
9501 ADD IX,BC Add it to IX to complete the jump target
9503 LD ($9511),SP Save SP to restore on exit (self modify)
9507 LD BC,$0F10 B = 15 rows to draw, C = 16, an increment value used later
950A EXX Bank
950B JR ps_odd_body Jump into body of loop
ps_odd_loop 950D EXX Bank
ps_odd_continue 950E DJNZ ps_odd_next Next scanline
9510 LD SP,$0000 Restore original SP (self modified)
9513 RET Return
ps_odd_next 9514 ADD HL,DE Calculate address of next bitmap scanline
ps_odd_body 9515 LD SP,HL Put it in SP (so we can use POP for speed)
9516 EXX Unbank
9517 LD A,L
9518 JP (IX) Jump into table
ps_odd_jumptable 951A POP DE Transfer two bitmap bytes (16 pixels) from the "stack" to screen buffer
951B LD (HL),E
951C INC L
951D LD (HL),D
951E INC L
951F POP DE Transfer another 16 pixels
9520 LD (HL),E
9521 INC L
9522 LD (HL),D
9523 INC L
9524 POP DE Transfer another 16 pixels
9525 LD (HL),E
9526 INC L
9527 LD (HL),D
9528 INC L
9529 POP DE Transfer another 8 pixels
952A LD (HL),E
Handle end of row.
952B LD L,A Restore row start address
Move to next back buffer row (addresses have the form 0b1111BAAACCCXXXXX where 0bCCCBAAA is the row index)
952C LD A,H Preserve A for checking in a moment
952D DEC H Move to next row (visually upwards)
952E AND B Would it have rolled over into the top nibble? (B is a mask, 15, here)
952F JP NZ,ps_odd_loop No - continue
The row field BAAA was zero but the decrement changed it to 1111 and borrowed from the 1111 field at the top of the address.
9532 LD A,H Fix 1111 field (C is 16 here)
9533 ADD A,C
9534 LD H,A
9535 LD A,L Move to next chunk of 16 rows
9536 SUB $20
9538 LD L,A
9539 JP NC,ps_odd_loop No carry, so continue
Otherwise have to compensate 1111 field.
953C LD A,H Undo carry
953D SUB C
953E LD H,A
953F JP ps_odd_loop Continue
Prev: 92E1 Up: Map Next: 9542