| Chase H.Q. | Routines |
| Prev: 9542 | Up: Map | Next: 9618 |
|
The even-width half of plot_sprite_flipped, reached by falling through it; nothing else calls it. Each row is read as byte pairs through SP, bit reversed through the flip table and stored right to left, then HL steps back a row and DE advances the bitmap pointer by the stride. 9553 has already picked the entry point into the unrolled table at psf_even_jumptable, skipping (4 - A) of its five 9-byte plot operations so that exactly the sprite's width is written. The caller's SP is restored from the operand self modified at 954B.
|
||||||||||||||||||
| plot_sprite_flipped_even | 9565 | JR plot_sprite_flipped_even_start | Jump into body of loop | |||||||||||||||
| psf_even_continue | 9567 | EXX | UNBANK | |||||||||||||||
| 9568 | DJNZ psf_even_next | Next scanline | ||||||||||||||||
| 956A | LD SP,$0000 | Restore original SP (self modified) | ||||||||||||||||
| 956D | RET | Return | ||||||||||||||||
| psf_even_next | 956E | ADD HL,DE | Calculate address of next bitmap scanline | |||||||||||||||
| plot_sprite_flipped_even_start | 956F | LD SP,HL | Put it in SP (so we can use PUSH for speed) | |||||||||||||||
| 9570 | EXX | BANK | ||||||||||||||||
| 9571 | LD A,L | [check elsewhere too] | ||||||||||||||||
| 9572 | EX AF,AF' | BANK | ||||||||||||||||
| 9573 | JP (IX) | Jump into table | ||||||||||||||||
| psf_even_jumptable | 9575 | POP BC | Transfer two bitmap bytes (16 pixels) from the "stack" to screen buffer with flipping | |||||||||||||||
| 9576 | LD E,C | Set flip table address | ||||||||||||||||
| 9577 | LD A,(DE) | Flip byte and write to screen | ||||||||||||||||
| 9578 | LD (HL),A | |||||||||||||||||
| 9579 | DEC L | Advance backwards | ||||||||||||||||
| 957A | LD E,B | Set flip table address | ||||||||||||||||
| 957B | LD A,(DE) | Flip byte and write to screen | ||||||||||||||||
| 957C | LD (HL),A | |||||||||||||||||
| 957D | DEC L | Advance backwards | ||||||||||||||||
| 957E | POP BC | Transfer another 16 pixels | ||||||||||||||||
| 957F | LD E,C | |||||||||||||||||
| 9580 | LD A,(DE) | |||||||||||||||||
| 9581 | LD (HL),A | |||||||||||||||||
| 9582 | DEC L | |||||||||||||||||
| 9583 | LD E,B | |||||||||||||||||
| 9584 | LD A,(DE) | |||||||||||||||||
| 9585 | LD (HL),A | |||||||||||||||||
| 9586 | DEC L | |||||||||||||||||
| 9587 | POP BC | Transfer another 16 pixels | ||||||||||||||||
| 9588 | LD E,C | |||||||||||||||||
| 9589 | LD A,(DE) | |||||||||||||||||
| 958A | LD (HL),A | |||||||||||||||||
| 958B | DEC L | |||||||||||||||||
| 958C | LD E,B | |||||||||||||||||
| 958D | LD A,(DE) | |||||||||||||||||
| 958E | LD (HL),A | |||||||||||||||||
| 958F | DEC L | |||||||||||||||||
| 9590 | POP BC | Transfer another 16 pixels | ||||||||||||||||
| 9591 | LD E,C | |||||||||||||||||
| 9592 | LD A,(DE) | |||||||||||||||||
| 9593 | LD (HL),A | |||||||||||||||||
| 9594 | DEC L | |||||||||||||||||
| 9595 | LD E,B | |||||||||||||||||
| 9596 | LD A,(DE) | |||||||||||||||||
| 9597 | LD (HL),A | |||||||||||||||||
| 9598 | EX AF,AF' | UNBANK | ||||||||||||||||
| 9599 | LD L,A | Restore HL | ||||||||||||||||
|
Move to next scanline (longer form).
|
||||||||||||||||||
| 959A | LD A,H | Save for checking in a moment | ||||||||||||||||
| 959B | DEC H | Move to next scanline (visually upwards) | ||||||||||||||||
| 959C | AND $0F | Would it have rolled over into the top nibble? | ||||||||||||||||
| 959E | JP NZ,psf_even_continue | No - continue | ||||||||||||||||
|
It rolled over.
|
||||||||||||||||||
| 95A1 | LD A,H | Put back the bit stolen by rollover | ||||||||||||||||
| 95A2 | ADD A,$10 | |||||||||||||||||
| 95A4 | LD H,A | |||||||||||||||||
| 95A5 | LD A,L | Move to next chunk of 16 scanlines | ||||||||||||||||
| 95A6 | SUB $20 | |||||||||||||||||
| 95A8 | LD L,A | |||||||||||||||||
| 95A9 | JP NC,psf_even_continue | Continue if it didn't roll over | ||||||||||||||||
| 95AC | LD A,H | Otherwise move to the next chunk of 128 scanlines (would put us outside the back buffer) | ||||||||||||||||
| 95AD | SUB $10 | |||||||||||||||||
| 95AF | LD H,A | |||||||||||||||||
| 95B0 | JP psf_even_continue | Loop back to psf_even_continue | ||||||||||||||||
|
This entry point is used by the routine at plot_sprite_flipped.
|
||||||||||||||||||
| plot_sprite_flipped_odd | 95B3 | INC A | Increment A for upcoming calculation | |||||||||||||||
| 95B4 | LD ($95D4),SP | Save SP to restore on exit (self modify) [in a different position to others] | ||||||||||||||||
| 95B8 | LD IX,$95DE | Point IX at start of plot instructions | ||||||||||||||||
| 95BC | CPL | (~A + 5) is (4 - A) is the number of plot operations to skip | ||||||||||||||||
| 95BD | ADD A,$05 | |||||||||||||||||
| 95BF | LD C,A | Multiply A by 9: the length of an individual plot operation | ||||||||||||||||
| 95C0 | RLCA | |||||||||||||||||
| 95C1 | RLCA | |||||||||||||||||
| 95C2 | RLCA | |||||||||||||||||
| 95C3 | ADD A,C | |||||||||||||||||
| 95C4 | LD C,A | Move result to BC | ||||||||||||||||
| 95C5 | LD B,$00 | |||||||||||||||||
| 95C7 | ADD IX,BC | Add it to IX to complete the jump target | ||||||||||||||||
| 95C9 | LD D,$EF | Point DE at table of flipped bytes at $EF00 | ||||||||||||||||
| 95CB | EXX | Bank | ||||||||||||||||
| 95CC | LD D,$00 | |||||||||||||||||
| 95CE | JR psf_odd_body | Jump into body of loop | ||||||||||||||||
| psf_odd_continue | 95D0 | EXX | Bank | |||||||||||||||
| 95D1 | DJNZ psf_odd_next | Next scanline | ||||||||||||||||
| 95D3 | LD SP,$0000 | Restore original SP (self modified) | ||||||||||||||||
| 95D6 | RET | Return | ||||||||||||||||
| psf_odd_next | 95D7 | ADD HL,DE | Calculate address of next bitmap scanline | |||||||||||||||
| psf_odd_body | 95D8 | LD SP,HL | Put it in SP (so we can use PUSH for speed) | |||||||||||||||
| 95D9 | EXX | Unbank | ||||||||||||||||
| 95DA | LD A,L | |||||||||||||||||
| 95DB | EX AF,AF' | |||||||||||||||||
| 95DC | JP (IX) | Jump into table | ||||||||||||||||
| psf_odd_jumptable | 95DE | POP BC | Transfer two bitmap bytes (16 pixels) from the "stack" to screen buffer with flipping | |||||||||||||||
| 95DF | LD E,C | Set flip table address | ||||||||||||||||
| 95E0 | LD A,(DE) | Flip byte and write to screen | ||||||||||||||||
| 95E1 | LD (HL),A | |||||||||||||||||
| 95E2 | DEC L | Advance backwards | ||||||||||||||||
| 95E3 | LD E,B | Set flip table address | ||||||||||||||||
| 95E4 | LD A,(DE) | Flip byte and write to screen | ||||||||||||||||
| 95E5 | LD (HL),A | |||||||||||||||||
| 95E6 | DEC L | Advance backwards | ||||||||||||||||
| 95E7 | POP BC | Transfer another 16 pixels | ||||||||||||||||
| 95E8 | LD E,C | |||||||||||||||||
| 95E9 | LD A,(DE) | |||||||||||||||||
| 95EA | LD (HL),A | |||||||||||||||||
| 95EB | DEC L | |||||||||||||||||
| 95EC | LD E,B | |||||||||||||||||
| 95ED | LD A,(DE) | |||||||||||||||||
| 95EE | LD (HL),A | |||||||||||||||||
| 95EF | DEC L | |||||||||||||||||
| 95F0 | POP BC | Transfer another 16 pixels | ||||||||||||||||
| 95F1 | LD E,C | |||||||||||||||||
| 95F2 | LD A,(DE) | |||||||||||||||||
| 95F3 | LD (HL),A | |||||||||||||||||
| 95F4 | DEC L | |||||||||||||||||
| 95F5 | LD E,B | |||||||||||||||||
| 95F6 | LD A,(DE) | |||||||||||||||||
| 95F7 | LD (HL),A | |||||||||||||||||
| 95F8 | DEC L | |||||||||||||||||
| 95F9 | POP BC | Transfer another 8 pixels | ||||||||||||||||
| 95FA | LD E,C | |||||||||||||||||
| 95FB | LD A,(DE) | |||||||||||||||||
| 95FC | LD (HL),A | |||||||||||||||||
| 95FD | EX AF,AF' | |||||||||||||||||
| 95FE | LD L,A | Restore HL | ||||||||||||||||
|
Move to next scanline (longer form).
|
||||||||||||||||||
| 95FF | LD A,H | Save for checking in a moment | ||||||||||||||||
| 9600 | DEC H | Move to next scanline (visually upwards) | ||||||||||||||||
| 9601 | AND $0F | Would it have rolled over into the top nibble? | ||||||||||||||||
| 9603 | JP NZ,psf_odd_continue | No - continue | ||||||||||||||||
|
It rolled over.
|
||||||||||||||||||
| 9606 | LD A,H | Put back the bit stolen by rollover | ||||||||||||||||
| 9607 | ADD A,$10 | |||||||||||||||||
| 9609 | LD H,A | |||||||||||||||||
| 960A | LD A,L | Move to next chunk of 16 scanlines | ||||||||||||||||
| 960B | SUB $20 | |||||||||||||||||
| 960D | LD L,A | |||||||||||||||||
| 960E | JP NC,psf_odd_continue | Continue if it didn't roll over | ||||||||||||||||
| 9611 | LD A,H | Otherwise move to the next chunk of 128 scanlines (would put us outside the back buffer) | ||||||||||||||||
| 9612 | SUB $10 | |||||||||||||||||
| 9614 | LD H,A | |||||||||||||||||
| 9615 | JP psf_odd_continue | Loop back to psf_odd_continue | ||||||||||||||||
| Prev: 9542 | Up: Map | Next: 9618 |