Prev: E300 Up: Map Next: E376
E34A: Centre And Draw Message Row
Used by the routine at Paint_MessageBuffer.
Count characters in the current message row (until $ + or ]), centre that run within 20 columns, then draw it via Draw_MessageCharacter.
Input
HL Attribute-file address for the row
IX Pointer into the decoded message buffer
Count characters until a row or message end, then centre and draw the run.
Centre_AndDrawMessageRow E34A PUSH HL Stash HL and IX on the stack.
E34B PUSH IX
E34D LD C,$FF Start the character count at FF (pre-increment).
Count characters until $ + or ] to measure the current message row.
Centre_AndDrawMessageRow_Count E34F INC C Advance the character count.
E350 LD A,(IX+$00) Fetch the next buffer byte through IX.
E353 CP $24 Is it $ + or ] (row/message end)?, then if $ stop counting at Centre_AndDrawMessageRow_Centre.
E355 JR Z,Centre_AndDrawMessageRow_Centre
E357 CP $2B Is it a new-row marker (+)? If so, stop counting at Centre_AndDrawMessageRow_Centre.
E359 JR Z,Centre_AndDrawMessageRow_Centre
E35B CP $5D Is it the message terminator (])? If so, stop counting at Centre_AndDrawMessageRow_Centre.
E35D JR Z,Centre_AndDrawMessageRow_Centre
E35F INC IX Advance IX to the next buffer byte.
E361 JR Centre_AndDrawMessageRow_Count Jump to Centre_AndDrawMessageRow_Count to keep counting.
Centre the counted run within 20 columns and draw it via Draw_MessageCharacter.
Centre_AndDrawMessageRow_Centre E363 POP IX Restore IX from the stack.
E365 LD ($DDA1),A Remember the terminator byte in DDA1.
E368 LD A,$20 Compute (20−length)/02 as a left-indent.
E36A SUB C Subtract the row width from 20 to get the left pad.
E36B SRL A Halve that pad so the row is centred.
E36D LD B,$00 Clear B.
E36F LD C,A Keep the indent in BC.
E370 ADD HL,BC Add it to the row's attribute address.
E371 CALL Draw_MessageCharacter Call Draw_MessageCharacter to draw the centred row.
E374 POP HL Restore HL from the stack.
E375 RET Return.
Prev: E300 Up: Map Next: E376