Prev: B34B Up: Map Next: B3AB
B34C: Print Earnings
Used by the routines at PrintWages and GameOver.
Input
C Initial colour attribute value
DE Screen co-ordinates
HL Pointer to money earned memory location
PrintEarnings B34C PUSH HL Stash HL, BC and DE on the stack.
B34D PUSH BC
B34E PUSH DE
Print (or don't print) the equals sign:
udg57796_69x4
When called by GameOver the attribute for this is 00 (INK: BLACK, PAPER: BLACK and so, is invisible).
B34F LD A,$3D A=3D.
B351 CALL PrintStringColour Call PrintStringColour.
Move one character block to the right.
B354 INC E Increment E by one.
Print the GBP pounds sign.
udg57612_66x4
B355 LD C,$42 C=42 (INK: RED, PAPER: BLACK (BRIGHT) ).
B357 LD A,$26 A=26.
B359 CALL PrintStringColour Call PrintStringColour.
Move one character block to the right.
B35C INC E Increment E by one.
Initialise the leading zero suppression flag. See Flag_MoneyHelper for details.
B35D XOR A Write 00 to Flag_MoneyHelper.
B35E LD ($B34B),A
Set the attribute for all the money digits.
B361 LD C,$45 C=45 (INK: CYAN, PAPER: BLACK (BRIGHT) ).
Money is stored as two digits.
B363 LD B,$02 B=02 (counter).
Fetch the money digit.
PrintEarnings_Loop B365 LD A,(HL) A=*HL.
B366 SRL A Shift and rotate the upper bits to be the lower bits.
B368 SRL A
B36A SRL A
B36C SRL A
Convert the number into ASCII ready for printing to the screen.
Add ASCII "0" - so for example 01 ends up being 01 + 30 = 31 (e.g. "1" in ASCII).
B36E ADD A,$30 A+=30.
If the resulting number is not zero, then it needs to be printed to the screen.
B370 CP $30 If A is not 30 jump to PrintEarnings_Print_Upper.
B372 JR NZ,PrintEarnings_Print_Upper
And, if it is zero - print it, unless the leading zero suppression flag says otherwise.
B374 LD A,($B34B) If Flag_MoneyHelper is zero jump to PrintEarnings_Skip.
B377 OR A
B378 JR Z,PrintEarnings_Skip
Set the following printed character to be zero:
udg57692_69x4
B37A LD A,$30 A=30.
PrintEarnings_Print_Upper B37C CALL PrintStringColour Call PrintStringColour.
Indicate that we have written a digit.
B37F LD A,$01 Write 01 to Flag_MoneyHelper.
B381 LD ($B34B),A
Move one character block to the right.
PrintEarnings_Skip B384 INC E Increment E by one.
Refresh the money byte. We've processed the upper bits already and now we want to process the lower bits.
B385 LD A,(HL) A=*HL.
B386 AND %00001111 Keep only bits 0-3.
As above; add ASCII "0".
B388 ADD A,$30 A+=30.
If the resulting number is not zero, then it needs to be printed to the screen.
B38A CP $30 If A is not 30 jump to PrintEarnings_Print_Lower.
B38C JR NZ,PrintEarnings_Print_Lower
Force some output if everything is zero.
B38E LD A,B If B (the counter) is 01 jump to PrintEarnings_Print_Zero.
B38F CP $01
B391 JR Z,PrintEarnings_Print_Zero
If nothing has been printed yet just skip to the next money byte.
B393 LD A,($B34B) If Flag_MoneyHelper is zero jump to PrintEarnings_NextByte.
B396 OR A
B397 JR Z,PrintEarnings_NextByte
udg57692_69x4
PrintEarnings_Print_Zero B399 LD A,$30 A=30.
PrintEarnings_Print_Lower B39B CALL PrintStringColour Call PrintStringColour.
B39E LD A,$01 Write 01 to Flag_MoneyHelper.
B3A0 LD ($B34B),A
Move one character block to the right.
PrintEarnings_NextByte B3A3 INC E Increment E by one.
Move onto the next money byte.
B3A4 INC HL Increment HL by one.
B3A5 DJNZ PrintEarnings_Loop Decrease counter by one and loop back to PrintEarnings_Loop until counter is zero.
Restore all the previous registers and return.
B3A7 POP DE Restore DE, BC and HL from the stack.
B3A8 POP BC
B3A9 POP HL
B3AA RET Return.
Prev: B34B Up: Map Next: B3AB