Routines

27276: Save area of screen to be overwritten by lines message etc.


Used by routines at 29716, 29896 and 62668. Returns with the carry flag set if the message would be off-screen.

DE Play area coordinates of point above character's head

27276 3AFF7F LD A,(32767) A=column of play area at far left of screen
27279 47 LD B,A
27280 7B LD A,E A=x-coordinate of point above character
27281 E6F8 AND 248 A=x-coordinate of left side of message
27283 90 SUB B
27284 FE20 CP 32
27286 3F CCF
27287 D8 RET C Return if the message would be off-screen to the right
27288 5F LD E,A 0≤E≤31: relative x-coordinate of left side of message
27289 7A LD A,D A=y-coordinate of point above character's head
27290 D603 SUB 3 A=y-coordinate of top line of message
27292 D8 RET C Return if this would be off the top of the screen
27293 1600 LD D,0
27295 E5 PUSH HL
27296 87 ADD A,A
27297 87 ADD A,A
27298 87 ADD A,A
27299 6F LD L,A
27300 2616 LD H,22
27302 29 ADD HL,HL
27303 29 ADD HL,HL
27304 19 ADD HL,DE HL=attribute file address for top left corner of message
27305 E5 PUSH HL
27306 1128E3 LD DE,58152 Point DE at the buffer used to save screen area
27309 3E03 LD A,3 3 rows
27311 010800 LD BC,8 8 character squares per row
27314 EDB0 LDIR Copy 8 attribute bytes into the buffer
27316 0E18 LD C,24
27318 09 ADD HL,BC
27319 3D DEC A
27320 20F5 JR NZ,27311 Jump back until all the attribute bytes have been copied
27322 E1 POP HL
27323 E5 PUSH HL
27324 7C LD A,H
27325 D650 SUB 80
27327 87 ADD A,A
27328 87 ADD A,A
27329 87 ADD A,A
27330 67 LD H,A HL=display file address for top left of message
27331 0E03 LD C,3 3 rows
27333 3E08 LD A,8 8 pixel lines per row
27335 C5 PUSH BC
27336 E5 PUSH HL
27337 0E08 LD C,8 8 character squares per row
27339 EDB0 LDIR Copy one pixel line into the buffer
27341 E1 POP HL
27342 24 INC H
27343 3D DEC A
27344 20F6 JR NZ,27336 Jump back until all 8 pixel lines for this row have been copied
27346 7D LD A,L
27347 C620 ADD A,32
27349 6F LD L,A
27350 3804 JR C,27356
27352 7C LD A,H
27353 D608 SUB 8
27355 67 LD H,A
27356 C1 POP BC
27357 0D DEC C
27358 20E5 JR NZ,27333 Jump back until all 3 rows have been copied
27360 D1 POP DE
27361 E1 POP HL
27362 C9 RET