Prev: 81B5 Up: Map Next: 820B
81DE: Drawing: Screen Address From The Row
Used by the routines at Drawing_MaskOneScreenByte and Drawing_AddressThePixel.
Builds a Spectrum screen address from the pen in D and E.
Drawing_ScreenAddressFromTheRow 81DE LD A,$7F The top screen row is 7F.
81E0 SUB E The pixel row is 7F minus the low coordinate.
81E1 LD L,A Keep 7F.
81E2 AND %00000111 Keep the low three bits of the row and select the screen base.
81E4 OR $40 Merge in 40.
81E6 LD H,A Store the screen address high byte so far.
81E7 LD A,L Take the pixel row back into A.
81E8 AND %11000000 Take the top two bits of the row.
81EA RRCA Move the screen-third bits down one place.
81EB RRCA Move the screen-third bits down another place.
81EC RRCA Move the screen-third bits down to bits 3-4.
81ED OR H Fold them into the screen address.
81EE LD H,A Store the screen address high byte.
81EF LD A,L Take the pixel row back into A.
81F0 AND %00111000 Take the middle three bits of the row.
81F2 RLCA Move the middle row bits up one place.
81F3 RLCA Move them up to bits 5-7.
81F4 LD L,A Those bits start the screen address low byte.
81F5 LD A,D Take the high coordinate.
81F6 RRCA
81F7 RRCA
81F8 RRCA
81F9 AND $1F
81FB OR L Fold the character column into the screen address.
81FC LD L,A Store the screen address low byte.
81FD LD A,D Take the high coordinate again.
81FE AND %00000111 The low three bits choose the pixel inside the byte.
8200 PUSH BC Save BC and keep A in B.
8201 LD B,A
8202 INC B Make the rotate count one more than the bit number.
8203 LD A,$01 Start the pixel mask at 01.
Drawing_ScreenAddressFromTheRow_ShiftPixelMask 8205 RRC A Rotate the pixel mask one place right.
8207 DJNZ Drawing_ScreenAddressFromTheRow_ShiftPixelMask Decrease counter by one and loop back to Drawing_ScreenAddressFromTheRow_ShiftPixelMask until counter is zero.
8209 POP BC Restore BC from the stack.
820A RET Return.
Prev: 81B5 Up: Map Next: 820B