BydoEmpire Posted April 15, 2021 Share Posted April 15, 2021 From the 7800basic manual: Quote The non-BCD variable should be in the range between 0-99, or else it will start to display incorrect values. Is there a cheap way around this? I'd *like* to repurpose a bcd variable to show numbers in a range beyond 100. I could just do a loop like "for i=0 to dec_value ; bcdval=bcdval+$1 ; next i" ... seems kind of wasteful. Better way? Quote Link to comment Share on other sites More sharing options...
RevEng Posted April 15, 2021 Share Posted April 15, 2021 BCD numbers are basically hex numbers. i.e. When you convert the decimal value "13" to BCD, it becomes $13. Since a byte's max value is $FF in hex, those 2 hex digits only allow for representing a BCD value up to "99". Yes, there could be a routine developed to return 2 bytes, but I try not to add a lot of functions that will go unused by a large number of games. How's your number generated in the first place, and what's it's max value? If it's updated with addition and subtraction, you could also use an extra score variable to track it in BCD. Or if we're just talking about a value with a max of 255, you could just do some iterative subtraction to pull out the 100's place. Quote Link to comment Share on other sites More sharing options...
BydoEmpire Posted April 15, 2021 Author Share Posted April 15, 2021 7 hours ago, RevEng said: BCD numbers are basically hex numbers. i.e. When you convert the decimal value "13" to BCD, it becomes $13. Since a byte's max value is $FF in hex, those 2 hex digits only allow for representing a BCD value up to "99". Yes, there could be a routine developed to return 2 bytes, but I try not to add a lot of functions that will go unused by a large number of games. How's your number generated in the first place, and what's it's max value? If it's updated with addition and subtraction, you could also use an extra score variable to track it in BCD. Or if we're just talking about a value with a max of 255, you could just do some iterative subtraction to pull out the 100's place. That makes sense. It's just incremented every time you enter a room, and caps at 256 (in the end of game display, if the value is 0 I display "perfect" instead, since you can never visit 0 rooms and finish teh game I can assume you hit all 256 and it just wrapped). I use the extra score value for health, but along the way I capped out health at 50 so I don't really need it. I was thinking of using score1 for this instead, that might be the way to go. Quote Link to comment Share on other sites More sharing options...
RevEng Posted April 15, 2021 Share Posted April 15, 2021 It sounds like you don't need to, but you can also dim extra score variables, in addition to the two scores provided. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.