| Routines

38430: Check and set the attribute byte for a cell occupied by Willy's sprite

Used by the routine at 38344. Sets the attribute byte in the buffer at 23552 for one of the six cells (in three rows of two) occupied by or under Willy's sprite, or kills Willy if the cell contains a nasty. On entry, C holds either 15 if the cell is in the top two rows, or Willy's y-coordinate if the cell is in the bottom row.
Input
C | 15 or Willy's y-coordinate
HL | Address of the attribute byte in the buffer at 23552
38430 | LD A,(32928) | Pick up the attribute byte of the background tile in the current room from 32928
38433 | CP (HL) | Does this cell contain a background tile?
38434 | JR NZ,38447 | Jump if not
38436 | LD A,C | Set the zero flag if we are going to retain the INK colour in this cell; this happens only if the cell is in the bottom row and Willy's sprite is confined to the top two rows
38437 | AND 15
38439 | JR Z,38447 | Jump if we are going to retain the current INK colour in this cell
38441 | LD A,(32928) | Pick up the attribute byte of the background tile in the current room from 32928
38444 | OR 7 | Set bits 0-2, making the INK white
38446 | LD (HL),A | Set the attribute byte for this cell in the buffer at 23552
38447 | LD A,(32955) | Pick up the attribute byte of the nasty tile in the current room from 32955
38450 | CP (HL) | Has Willy hit a nasty?
38451 | JP Z,37046 | Kill Willy if so
38454 | RET |