@Seihen: You might be confusing text files with binary files.
If you write an integer that contains "ten" to a binary file... it will write the binary representation of the number "ten" -- it will not write "one zero".
but without doing any sort of DEC->HEX conversion in your program
There is no such thing as dec->hex conversion unless you are dealing with text.
Numbers are numbers. They don't come in different forms*. The only difference is how they are displayed in text
for humans to read.
Decimal (10), Hexadecimal (0A), and English (ten) are all 3 different textual
representations of the same number: ten.
Since text is not involved here... we just have a digital value. So there's nothing to convert.* they actually do come in different digital forms, but it's unrelated to what we're discussing here. Trying to keep it simple
Although King Mike brings up the notion that the lives counter may in fact be BCD, in which case $10 would be "ten" and values $0A-$0F would be invalid. In which case, yes, conversion will be necessary:
// convert 'val' to BCD using a single temp var:
temp = val / 10;
val %= 10;
val += temp*16;
// covert 'val' FROM BCD:
temp = val / 16;
val %= 16;
val += temp*10;