Prev: B115 Up: Map Next: B178
B145: Copy Score To Screen
Used by the routine at ScoreForCreature.
Copies the part of the buffer that holds the score to the screen. It is 06 bytes wide and 08 pixel lines tall, and its bottom left corner is at (B8, 09).
Work out the addresses of the area in the screen and in the buffer.
CopyScoreToScreen B145 LD BC,$09B8 Set B to the y co-ordinate and C to the x co-ordinate of the area.
B148 CALL CalculateScreenAddress Call CalculateScreenAddress to get the screen address in DE.
B14B CALL CalculateBufferAddress Call CalculateBufferAddress to get the buffer address in BC.
B14E LD H,B Copy the buffer address to HL.
B14F LD L,C
B150 LD C,$08 Set a counter in C of 08 lines.
Copy a line of 06 bytes.
CopyScoreToScreen_Loop B152 PUSH BC Stash the line counter on the stack.
B153 PUSH DE Stash the screen address on the stack.
B154 LD BC,$0006 Set a counter in BC of 06 bytes.
B157 LDIR Copy the line to the screen.
B159 POP DE Restore the screen address from the stack.
Move up to the next pixel line of the screen.
B15A DEC D Move up one pixel line.
B15B LD A,D Invert the high byte of the screen address to test its pixel line bits.
B15C CPL
B15D AND %00000111 Keep only the pixel line bits.
B15F JR NZ,CopyScoreToScreen_Next Jump to CopyScoreToScreen_Next if the line is still in the same character row.
B161 LD A,E Move up one character row.
B162 SUB $20
B164 LD E,A
B165 JR C,CopyScoreToScreen_Next Jump to CopyScoreToScreen_Next if that has crossed into the third above.
B167 LD A,D Otherwise cancel the effect of the borrow on the third, by adding 08 to the high byte.
B168 ADD A,$08
B16A LD D,A
Move on to the next line of the buffer.
CopyScoreToScreen_Next B16B POP BC Restore the line counter from the stack.
B16C LD A,L Add 1A to HL, which takes it from the end of the line just copied to the start of the next (a line is 20 bytes long).
B16D ADD A,$1A
B16F LD L,A
B170 LD A,H
B171 ADC A,$00
B173 LD H,A
B174 DEC C Decrease the line counter.
B175 JR NZ,CopyScoreToScreen_Loop Jump to CopyScoreToScreen_Loop until all the lines have been copied.
B177 RET Return.
Prev: B115 Up: Map Next: B178