Prev: A2DB Up: Map Next: A34D
A2E6: Draws a windows in the display file
Reads the text definition data format and draws the border and content of the windows. Used by the routines at 9470, 99E3, 9D68 and DF59.
Input
IX Address of the text definition data
B Number of lines of the windows
A2E6 PUSH IX Save IX and BC
A2E8 PUSH BC
A2E9 LD A,$01 Initialise the width of the popup at A22E
A2EB LD ($A22E),A
First compute the width of the windows based on the max length of all the lines of text plus 2 Special case: the first line of text computes a width of length of text plus 1
A2EE LD A,$01 Initialise the temporal computed width of the windows at A22C
A2F0 LD ($A22C),A
A2F3 LD DE,$0003 In the first iteration, point IX to the first character of the line. Subsequent iterations points to the vertical position
A2F6 ADD IX,DE
A2F8 LD A,(IX+$00) Pick up the character at IX
A2FB OR A Is the character an end of marker ($00)?
A2FC JP Z,$A308 Jump if so
A2FF LD HL,$A22C Increment the temporal computed width at A22C
A302 INC (HL)
A303 INC IX Increment the address pointer to read the next character
A305 JP $A2F8 Jump back and repeat the process
A308 LD A,($A22C) Compare the width computed in the last iteration with the max width previously saved
A30B LD HL,$A22E
A30E CP (HL)
A30F JP C,$A315 Jump if the max width is greater or equal than the current computed width
A312 LD ($A22E),A Update the max width of the windows at A095 with the new computed value
A315 DJNZ $A2EE Jump back while there are lines to process
The next section of code obtain the position and color attributes of the windows
A317 POP BC Restore BC and IX
A318 POP IX
A31A PUSH IX Save BC and IX
A31C PUSH BC
A31D LD A,B Is there only one line of text?
A31E CP $01
A320 JP NZ,$A327 Jump if not
A323 LD HL,$A22E Increment the width of the windows by one at A22E. This account for the special case described above
A326 INC (HL)
A327 LD A,(IX+$01) Pick up the horizontal position of the first line of text
A32A SUB $03 Substract 3 to obtain the horizontal position of the windows: one for the border and two for the left margin.
A32C LD H,A Save the horizontal position of the windows at H
A32D LD A,(IX+$02) Pick up the vertical position of the first line of text
A330 SRL A The position is defined in bits 7-3 so move this value to bits 4-0
A332 SRL A
A334 SRL A
A336 DEC A Decrement by one to account for the top border
A337 LD L,A Save the vertical position of the windows at L
A338 LD E,B Save the number of lines of the windows in register E
A339 LD A,($A22E) Pick up the width of the windows saved at A22E
A33C SUB $02 Substract 2 for the borders
A33E LD D,A Save the width of the windows (minus borders) at D
A33F LD A,$47 Save at A the color attributes for the windows border
A341 LD C,$07 Save at C the color attributes for the windows body
A343 CALL $BADC Draws the windows borders in the display file
A346 POP BC Save BC and IX
A347 POP IX
A349 CALL $A487 Print the text content of the windows in the display file
A34C RET
Prev: A2DB Up: Map Next: A34D