Prev: 27037 Up: Map Next: 27145
27068: Draw HUD Panel
Used by the routine at CreateWindow.
Draws the sidebar (the leftmost 8 columns of the screen) from the tile layout at SidebarLayoutData and the attributes at SidebarAttributes. Each tile is printed with PrintScreen while the character set pointer refers to the tiles at UDG_Tiles.
Before After
draw-sidebar-before draw-sidebar-after
DrawHUDPanel 27068 LD HL,(23606) Stash CHARS on the stack.
27071 PUSH HL
27072 LD HL,29873 Write UDG_Tiles to CHARS.
27075 LD (23606),HL
27078 LD HL,30353 Point HL at the tile layout of the sidebar (SidebarLayoutData).
27081 LD DE,30545 Point DE at the attributes of the sidebar (SidebarAttributes).
27084 EXX Switch to the shadow registers.
27085 LD HL,16384 Point HL' at the screen buffer (16384).
27088 LD DE,22528 Point DE' at the attribute buffer (22528).
27091 LD C,24 Set the row counter to 24 the height of the sidebar.
27093 LD A,8 Write 8 (width of the sidebar) to WidthCounter.
27095 LD (24108),A
DrawHUDPanel_Loop 27098 LD A,(24108) Set the tile counter to the width of the sidebar (WidthCounter).
27101 LD B,A
27102 PUSH HL Stash the buffer addresses of the start of this row on the stack.
27103 PUSH DE
DrawHUDPanel_LineLoop 27104 EXX Switch back to the normal registers.
27105 LD A,(HL) Fetch the tile from the sidebar layout.
27106 INC HL Move on to the next tile.
27107 EXX Switch to the shadow registers.
Now using the screen data held by the shadow registers.
27108 CALL PrintScreen Print the tile using PrintScreen.
27111 EXX Switch back to the normal registers.
27112 LD A,(DE) Fetch the attribute of the tile from the sidebar attributes.
27113 INC DE Move on to the next attribute.
27114 EXX Switch to the shadow registers.
27115 LD (DE),A Write the sidebar attribute data to the attribute buffer.
27116 INC DE Increment the attribute buffer pointer by one.
27117 DJNZ DrawHUDPanel_LineLoop Decrease the tile counter by one and loop back to DrawHUDPanel_LineLoop until the whole row has been drawn.
Restore the attribute buffer address for the start of this line.
27119 POP HL Restore HL' from the stack.
27120 CALL MoveDownOneRow Call MoveDownOneRow to move down a row.
27123 EX DE,HL Exchange DE' and HL' so that DE' holds the attribute address for the next row (HL' is overwritten below).
Restore the screen buffer address for the start of this line.
27124 POP HL Restore HL' from the stack.
27125 CALL MoveDownOneRow Call MoveDownOneRow to move down a row.
Account for the Spectrum screen layout in memory.
27128 LD A,L Fetch the low byte of the screen buffer address.
27129 AND %11100000 Keep only bits 5-7.
27131 JR NZ,DrawHUDPanel_Skip Jump to DrawHUDPanel_Skip if we're not crossing a screen section.
27133 LD A,H Else H'=H'+7.
27134 ADD A,7
27136 LD H,A
DrawHUDPanel_Skip 27137 DEC C Decrease the row counter by one.
27138 JR NZ,DrawHUDPanel_Loop Jump back to DrawHUDPanel_Loop until all of the rows have been drawn.
All done! Finish by reverting the change to CHARS and returning.
27140 POP HL Restore CHARSET from the stack and write it back to CHARS.
27141 LD (23606),HL
27144 RET Return.
View the equivalent code in;
Prev: 27037 Up: Map Next: 27145