diff options
Diffstat (limited to 'FAQ-cd.txt')
-rw-r--r-- | FAQ-cd.txt | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -131,10 +131,11 @@ A: Firstly, when you have a raw sector, you have to understand its primary form. in packed BCD format. You may know what the BCD format is if you are "old" enough for that. I won't enter into the details so if you want a more description of the BCD format, look into the net. You only have to know that: - -unsigned char from_BCD(unsigned char x) {return ((x & 15) + (x & 240) * 10));} -unsigned char to_BCD(unsigned char x) {return ((x / 10) << 4) | (x % 10));} -int is_valid_BCD(unsigned char x) {return (((x & 15) < 10) && ((x >> 4) < 10));} + +typedef unsigned char uchar; +uchar from_BCD(uchar x) {return ((x & 15) + ((x & 240) >> 4) * 10));} +uchar to_BCD(uchar x) {return ((x / 10) << 4) | (x % 10));} +int is_valid_BCD(uchar x) {return (((x & 15) < 10) && ((x >> 4) < 10));} Last thing: when you look at a BCD packed number, you have to read it in hexadecimal, and then you will see a "decimal" number. So when you count |