![]() |
Routines |
| Prev: B837 | Up: Map | Next: B866 |
|
This checks the mask buffer to see if the hero is hiding behind the scenery.
Used by the routine at plot_sprites.
|
||||||||
| searchlight_mask_test | B83B | PUSH IY | Copy the current visible character pointer into HL | |||||
| B83D | POP HL | |||||||
| B83E | LD A,L | Extract the visible character's offset | ||||||
| B83F | AND A | Is it zero? | ||||||
| B840 | RET NZ | Return if not - skip non-hero characters | ||||||
|
Start testing at approximately the middle of the character.
|
||||||||
| B841 | LD HL,$8131 | Point HL at mask_buffer ($8100) + $31 | ||||||
|
Bug: This does a fused load of BC, but doesn't use C after. It's probably a leftover stride constant.
|
||||||||
| B844 | LD BC,$0804 | Set B for eight iterations | ||||||
|
Start loop
|
||||||||
| B847 | XOR A | Preload A with zero | ||||||
| searchlight_mask_test_0 | B848 | CP (HL) | Is the mask byte zero? | |||||
| B849 | JR NZ,still_in_searchlight | Jump to still_in_searchlight if not | ||||||
| B84B | INC L | Advance HL to the next row (note cheap increment due to alignment) | ||||||
| B84C | INC L | |||||||
| B84D | INC L | |||||||
| B84E | INC L | |||||||
| B84F | DJNZ searchlight_mask_test_0 | ...loop | ||||||
|
Otherwise the hero has escaped the searchlight, so decrement the counter.
|
||||||||
| B851 | LD HL,$81BD | Point HL at searchlight_state | ||||||
| B854 | DEC (HL) | Decrement it | ||||||
| B855 | LD A,$FF | Is it searchlight_STATE_SEARCHING? | ||||||
| B857 | CP (HL) | |||||||
| B858 | RET NZ | Return if not | ||||||
| B859 | CALL choose_game_window_attributes | Choose game window attributes | ||||||
| B85C | CALL set_game_window_attributes | Set game window attributes | ||||||
| B85F | RET | Return | ||||||
| still_in_searchlight | B860 | LD HL,$81BD | Set searchlight_state to searchlight_STATE_CAUGHT | |||||
| B863 | LD (HL),$1F | |||||||
| B865 | RET | Return | ||||||
| Prev: B837 | Up: Map | Next: B866 |