Prev: ABA8 Up: Map Next: AC29
AC08: Find a map square's bit in the player's record
Used by the routines at draw_beams and beam_hits_ground_object.
The player's record (score) keeps 24 bits at +3 to +5 (cleared at the end of each level, level_done), one for each of twelve page rows and two halves of the map across (columns below $30 and from $30), marking the squares whose beam generator has been destroyed. This returns the byte and the bit, the bit as eight times its number, ready to add into a BIT, SET or RES opcode. beam_hits_ground_object sets them and draw_beams tests them.
Input
D The page row (1-12)
E The page column
Output
HL The byte
B Eight times the bit number
map_square_bit AC08 LD HL,player_flag_bits The byte: page row less one, divided by four
AC0B LD A,D
AC0C SUB $01
AC0E LD D,A
AC0F AND $0C
AC11 SRL A
AC13 SRL A
AC15 CALL add_a_to_hl
AC18 LD A,D The bit: twice the remainder...
AC19 AND $03
AC1B ADD A,A
AC1C ADD A,A
AC1D ADD A,A
AC1E ADD A,A
AC1F LD B,A
AC20 LD A,E ...plus one for the right half of the map
AC21 CP $30
AC23 RET C
AC24 LD A,B
AC25 ADD A,$08
AC27 LD B,A
AC28 RET
Prev: ABA8 Up: Map Next: AC29