Prev: 45333 Up: Map Next: 45432
45381: 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 6 bytes wide and 8 pixel lines tall, and its bottom left corner is at (184, 9).
Work out the addresses of the area in the screen and in the buffer.
CopyScoreToScreen 45381 LD BC,2488 Set B to the y co-ordinate and C to the x co-ordinate of the area.
45384 CALL CalculateScreenAddress Call CalculateScreenAddress to get the screen address in DE.
45387 CALL CalculateBufferAddress Call CalculateBufferAddress to get the buffer address in BC.
45390 LD H,B Copy the buffer address to HL.
45391 LD L,C
45392 LD C,8 Set a counter in C of 8 lines.
Copy a line of 6 bytes.
CopyScoreToScreen_Loop 45394 PUSH BC Stash the line counter on the stack.
45395 PUSH DE Stash the screen address on the stack.
45396 LD BC,6 Set a counter in BC of 6 bytes.
45399 LDIR Copy the line to the screen.
45401 POP DE Restore the screen address from the stack.
Move up to the next pixel line of the screen.
45402 DEC D Move up one pixel line.
45403 LD A,D Invert the high byte of the screen address to test its pixel line bits.
45404 CPL
45405 AND %00000111 Keep only the pixel line bits.
45407 JR NZ,CopyScoreToScreen_Next Jump to CopyScoreToScreen_Next if the line is still in the same character row.
45409 LD A,E Move up one character row.
45410 SUB 32
45412 LD E,A
45413 JR C,CopyScoreToScreen_Next Jump to CopyScoreToScreen_Next if that has crossed into the third above.
45415 LD A,D Otherwise cancel the effect of the borrow on the third, by adding 8 to the high byte.
45416 ADD A,8
45418 LD D,A
Move on to the next line of the buffer.
CopyScoreToScreen_Next 45419 POP BC Restore the line counter from the stack.
45420 LD A,L Add 26 to HL, which takes it from the end of the line just copied to the start of the next (a line is 32 bytes long).
45421 ADD A,26
45423 LD L,A
45424 LD A,H
45425 ADC A,0
45427 LD H,A
45428 DEC C Decrease the line counter.
45429 JR NZ,CopyScoreToScreen_Loop Jump to CopyScoreToScreen_Loop until all the lines have been copied.
45431 RET Return.
Prev: 45333 Up: Map Next: 45432