Prev: A6FC Up: Map Next: A7B8
A770: Reset Bullet Price
Used by the routine at SetUpPlayer.
Gives bullets their starting price of $5 if the price is zero.
ResetBulletPrice A770 LD HL,$A25E Point HL at the bullet price.
A773 LD A,(HL) Fetch the low byte of the price.
A774 INC HL Move on to the high byte.
A775 OR (HL) Return if the bullet price is not zero.
A776 RET NZ
A777 LD DE,$A83D Point DE at TelegramLines_BulletDigits.
A77A LD BC,$0005 Set the starting bullet price of $5 in BC.
This entry point is used by the routines at UpdatePrices, ResetHorsePrice and ResetFine.
This entry point stores the price in BC and converts it to digits. It is used when the telegram changes a price.
ResetBulletPrice_SetPrice A77D LD (HL),B Store the high byte of the price.
A77E DEC HL Move back to the low byte.
A77F LD (HL),C Store the low byte of the price.
A780 EX DE,HL Point HL at the digits.
This entry point is used by the routine at PrintTelegram.
This entry point converts the two packed decimal bytes at DE, in the order low byte first, into digits at HL. Leading zeros are not printed and are replaced by spaces after the digits instead.
ConvertPriceToDigits A781 LD BC,$0200 Set the number of bytes to two and clear the count of leading zeros.
A784 INC DE Point DE at the high byte.
ResetBulletPrice_ConvertPriceSkipZeros A785 LD A,(DE) Fetch a byte.
A786 AND %11110000 Keep the first digit.
A788 JR NZ,ResetBulletPrice_ConvertPriceDigits Jump to ResetBulletPrice_ConvertPriceDigits if it is not zero.
A78A INC C Count a leading zero.
A78B LD A,(DE) Fetch the byte again.
A78C AND %00001111 Keep the second digit.
A78E JR NZ,ResetBulletPrice_Done Jump to ResetBulletPrice_Done if it is not zero.
A790 INC C Count another leading zero.
A791 DEC DE Move down to the next byte.
A792 DJNZ ResetBulletPrice_ConvertPriceSkipZeros Loop back until both bytes have been checked.
A794 RET Return.
ResetBulletPrice_ConvertPriceDigits A795 LD A,(DE) Fetch the byte.
A796 RRCA Move the first digit into the bottom half of the byte.
A797 RRCA
A798 RRCA
A799 RRCA
A79A AND %00001111 Keep the digit.
A79C ADD A,$30 Convert it to a character.
A79E LD (HL),A Write it to the text.
A79F INC HL Move on to the next character.
ResetBulletPrice_Done A7A0 LD A,(DE) Fetch the byte.
A7A1 AND %00001111 Keep the second digit.
A7A3 ADD A,$30 Convert it to a character.
A7A5 LD (HL),A Write it to the text.
A7A6 INC HL Move on to the next character.
A7A7 DEC DE Move down to the next byte.
A7A8 DJNZ ResetBulletPrice_ConvertPriceDigits Loop back until both bytes have been converted.
ResetBulletPrice_ConvertPricePad A7AA LD A,C Fetch the count of leading zeros.
A7AB AND A Return once every leading zero has been replaced.
A7AC RET Z
A7AD LD (HL),$20 Write a space.
A7AF INC HL Move on to the next character.
A7B0 DEC C Count the space.
A7B1 JR ResetBulletPrice_ConvertPricePad Loop back to ResetBulletPrice_ConvertPricePad.
A7B3 DEFB $C9,$AF,$32,$42,$A8 Unused.
Prev: A6FC Up: Map Next: A7B8