| Chase H.Q. | Routines |
| Prev: B6D6 | Up: Map | Next: B76C |
|
This plots the game's graphics using AND-OR masking.
This uses the "stack trick": internally the stack is pointed at pairs of bitmap and mask bytes and HL points into the screen buffer. It proceeds left-right.
This routine doesn't flip sprites; instead use plot_masked_sprite_flipped (below) for that.
|
||||||||||||||||||||||
| plot_masked_sprite | B716 | LD ($B720),SP | Save SP to be restored on exit | |||||||||||||||||||
| B71A | JR pms_entry | Start | ||||||||||||||||||||
| pms_end_row | B71C | EXX | Unbank | |||||||||||||||||||
| B71D | DJNZ pms_start_row | Decrement rows, jump if +ve | ||||||||||||||||||||
| B71F | LD SP,$0000 | Restore original SP (self modified) | ||||||||||||||||||||
| B722 | RET | Return | ||||||||||||||||||||
| pms_start_row | B723 | ADD HL,DE | Advance to start of next row | |||||||||||||||||||
|
This entry point is used by the routine at plot_masked_sprite_inverted.
|
||||||||||||||||||||||
| pms_entry | B724 | LD SP,HL | Point SP at the source data | |||||||||||||||||||
| B725 | EXX | Bank | ||||||||||||||||||||
| B726 | LD C,L | Preserve start address | ||||||||||||||||||||
| B727 | JP (IX) | Jump into table | ||||||||||||||||||||
| pms_jumptable | B729 | POP DE | Load a bitmap and mask pair (D,E) | |||||||||||||||||||
| B72A | LD A,(HL) | Load the screen pixels and AND with mask | ||||||||||||||||||||
| B72B | AND E | |||||||||||||||||||||
| B72C | OR D | OR in new pixels and store back to screen | ||||||||||||||||||||
| B72D | LD (HL),A | |||||||||||||||||||||
| B72E | INC L | Move to next screen pixel | ||||||||||||||||||||
| B72F | POP DE | 7 | ||||||||||||||||||||
| B730 | LD A,(HL) | |||||||||||||||||||||
| B731 | AND E | |||||||||||||||||||||
| B732 | OR D | |||||||||||||||||||||
| B733 | LD (HL),A | |||||||||||||||||||||
| B734 | INC L | |||||||||||||||||||||
| B735 | POP DE | 6 | ||||||||||||||||||||
| B736 | LD A,(HL) | |||||||||||||||||||||
| B737 | AND E | |||||||||||||||||||||
| B738 | OR D | |||||||||||||||||||||
| B739 | LD (HL),A | |||||||||||||||||||||
| B73A | INC L | |||||||||||||||||||||
| B73B | POP DE | 5 | ||||||||||||||||||||
| B73C | LD A,(HL) | |||||||||||||||||||||
| B73D | AND E | |||||||||||||||||||||
| B73E | OR D | |||||||||||||||||||||
| B73F | LD (HL),A | |||||||||||||||||||||
| B740 | INC L | |||||||||||||||||||||
| B741 | POP DE | 4 | ||||||||||||||||||||
| B742 | LD A,(HL) | |||||||||||||||||||||
| B743 | AND E | |||||||||||||||||||||
| B744 | OR D | |||||||||||||||||||||
| B745 | LD (HL),A | |||||||||||||||||||||
| B746 | INC L | |||||||||||||||||||||
| B747 | POP DE | 3 | ||||||||||||||||||||
| B748 | LD A,(HL) | |||||||||||||||||||||
| B749 | AND E | |||||||||||||||||||||
| B74A | OR D | |||||||||||||||||||||
| B74B | LD (HL),A | |||||||||||||||||||||
| B74C | INC L | |||||||||||||||||||||
| B74D | POP DE | 2 | ||||||||||||||||||||
| B74E | LD A,(HL) | |||||||||||||||||||||
| B74F | AND E | |||||||||||||||||||||
| B750 | OR D | |||||||||||||||||||||
| B751 | LD (HL),A | |||||||||||||||||||||
| B752 | INC L | |||||||||||||||||||||
| B753 | POP DE | 1 | ||||||||||||||||||||
| B754 | LD A,(HL) | |||||||||||||||||||||
| B755 | AND E | |||||||||||||||||||||
| B756 | OR D | |||||||||||||||||||||
| B757 | LD (HL),A | |||||||||||||||||||||
| B758 | LD L,C | Restore row start address | ||||||||||||||||||||
|
Move to next scanline (shorter form).
Move to next back buffer row (addresses have the form 0b1111BAAACCCXXXXX where 0bCCCBAAA is the row index).
|
||||||||||||||||||||||
| B759 | LD A,H | Save for checking in a moment | ||||||||||||||||||||
| B75A | DEC H | Move to next scanline (visually upwards) | ||||||||||||||||||||
| B75B | AND B | Would it have rolled over into the top nibble? (B is a mask, 15, here) | ||||||||||||||||||||
| B75C | JP NZ,pms_end_row | No - continue | ||||||||||||||||||||
|
It rolled over.
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.
|
||||||||||||||||||||||
| B75F | LD A,L | Move to next chunk of 16 scanlines | ||||||||||||||||||||
| B760 | SUB $20 | |||||||||||||||||||||
| B762 | LD L,A | |||||||||||||||||||||
| B763 | JR C,pms_end_row | Carry set if CCC field was zero - don't compensate 1111 field and continue | ||||||||||||||||||||
|
Otherwise have to compensate 1111 field.
|
||||||||||||||||||||||
| B765 | LD A,H | Put back the bit stolen since BAAA field was zero | ||||||||||||||||||||
| B766 | ADD A,$10 | |||||||||||||||||||||
| B768 | LD H,A | |||||||||||||||||||||
| B769 | JP pms_end_row | Loop | ||||||||||||||||||||
| Prev: B6D6 | Up: Map | Next: B76C |