Prev: 42748 Up: Map Next: 42936
42864: Reset Bullet Price
Used by the routine at SetUpPlayer.
Gives bullets their starting price of $5 if the price is zero.
ResetBulletPrice 42864 LD HL,41566 Point HL at the bullet price.
42867 LD A,(HL) Fetch the low byte of the price.
42868 INC HL Move on to the high byte.
42869 OR (HL) Return if the bullet price is not zero.
42870 RET NZ
42871 LD DE,43069 Point DE at TelegramLines_BulletDigits.
42874 LD BC,5 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 42877 LD (HL),B Store the high byte of the price.
42878 DEC HL Move back to the low byte.
42879 LD (HL),C Store the low byte of the price.
42880 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 42881 LD BC,512 Set the number of bytes to two and clear the count of leading zeros.
42884 INC DE Point DE at the high byte.
ResetBulletPrice_ConvertPriceSkipZeros 42885 LD A,(DE) Fetch a byte.
42886 AND %11110000 Keep the first digit.
42888 JR NZ,ResetBulletPrice_ConvertPriceDigits Jump to ResetBulletPrice_ConvertPriceDigits if it is not zero.
42890 INC C Count a leading zero.
42891 LD A,(DE) Fetch the byte again.
42892 AND %00001111 Keep the second digit.
42894 JR NZ,ResetBulletPrice_Done Jump to ResetBulletPrice_Done if it is not zero.
42896 INC C Count another leading zero.
42897 DEC DE Move down to the next byte.
42898 DJNZ ResetBulletPrice_ConvertPriceSkipZeros Loop back until both bytes have been checked.
42900 RET Return.
ResetBulletPrice_ConvertPriceDigits 42901 LD A,(DE) Fetch the byte.
42902 RRCA Move the first digit into the bottom half of the byte.
42903 RRCA
42904 RRCA
42905 RRCA
42906 AND %00001111 Keep the digit.
42908 ADD A,48 Convert it to a character.
42910 LD (HL),A Write it to the text.
42911 INC HL Move on to the next character.
ResetBulletPrice_Done 42912 LD A,(DE) Fetch the byte.
42913 AND %00001111 Keep the second digit.
42915 ADD A,48 Convert it to a character.
42917 LD (HL),A Write it to the text.
42918 INC HL Move on to the next character.
42919 DEC DE Move down to the next byte.
42920 DJNZ ResetBulletPrice_ConvertPriceDigits Loop back until both bytes have been converted.
ResetBulletPrice_ConvertPricePad 42922 LD A,C Fetch the count of leading zeros.
42923 AND A Return once every leading zero has been replaced.
42924 RET Z
42925 LD (HL),32 Write a space.
42927 INC HL Move on to the next character.
42928 DEC C Count the space.
42929 JR ResetBulletPrice_ConvertPricePad Loop back to ResetBulletPrice_ConvertPricePad.
42931 DEFB 201,175,50,66,168 Unused.
Prev: 42748 Up: Map Next: 42936