Prev: $2E13 Up: Map Next: $2F20
$2EE6: Get the screen bitmap and colour information addresses for a play area tile
Used by the routine at $3326.
Input
($27) Play area x-coordinate
($28) Play area y-coordinate
Output
($5A,$5B) Screen bitmap address
($5C,$5D) Colour information address
$2EE6 LDA $27 Pick up the x-coordinate.
$2EE8 SEC Subtract the x-coordinate of the leftmost column of the skool on screen.
$2EE9 SBC $58
$2EEB STA $5A Store this relative x-coordinate at $5A.
$2EED LDA #$00 Initialise $5D to 0.
$2EEF STA $5D
$2EF1 LDA $28 Pick up the y-coordinate.
$2EF3 ASL A Multiply it by 40, storing bits 8 and 9 of the result at $5D.
$2EF4 ASL A
$2EF5 ADC $28
$2EF7 ASL A
$2EF8 ASL A
$2EF9 ROL $5D
$2EFB ASL A
$2EFC ROL $5D
$2EFE ADC $5A Add the relative x-coordinate.
$2F00 STA $5A Store the relative x-coordinate at $5A.
$2F02 STA $5C Add the relative x-coordinate to the value at $5C.
$2F04 BCC $2F08
$2F06 INC $5D
Now the two-byte value at $5C is equal to 40y+x, where (x,y) are the screen coordinates corresponding to the input play area coordinates. This is the index of the tile, counting row by row from the top left of the screen.
$2F08 LDA $5D Multiply the tile index by 8, add $E000 (the base address of the screen bitmap), and store the result at $5A.
$2F0A ASL $5A
$2F0C ROL A
$2F0D ASL $5A
$2F0F ROL A
$2F10 ASL $5A
$2F12 ROL A
$2F13 ADC #$E0
$2F15 STA $5B
$2F17 LDA $5D Add $CC00 (the base address of the colour information) to the tile index at $5C.
$2F19 ADC #$CC
$2F1B STA $5D
$2F1D ADC #$28 Add 40 to A for no good reason.
$2F1F RTS
Prev: $2E13 Up: Map Next: $2F20