Page 1 of 1

Reading Hex Files

Posted: Fri Jan 16, 2009 9:57 pm
by Laserbeak43
Hi,
I've been out of it for a long time, doing all my other stuff, and I can't seem to figure out how to read hex files anymore.
I'm looking at Kevtris' .nsf document, and this line says
0070: 05 05 05 05 05 05 05 05 - 00 00 00 00 00 00 00 00
0080: ... music data goes here...

Since 0070h-0077h are something other than 00h, then we know that this
tune uses bankswitching. The load address for the data is specified as
08000h.
thing is, I cant figure how you get 8000h from 05 05 05 05 05 05 05 05. :oops: can someone help? thanks

Posted: Fri Jan 16, 2009 10:01 pm
by Disch
You don't. You get the $8000 from elsewhere in the header. The load address, specifically -- offset 0x0008, which is most likely '00 80'.

Posted: Sat Jan 17, 2009 4:50 am
by Laserbeak43

Code: Select all

4E 45 53 4D 1A 01 0C 01   00 80 00 A0 B4 B3 4D 65
Ahh
0008 2 WORD (lo/hi) load address of data (8000-FFFF)
so each set of two digits(00) is 1 byte long? and does 0 start on the left or the right?

Posted: Sat Jan 17, 2009 9:04 am
by Disch
Yes, 2 digits in hex represents 8 bit, which is one byte (00 - FF).

Numbers larger than a byte are stored little endian (at least here and in most places), which means the low byte is listed first, followed by the high byte. So the 16-bit value $1234 would be seen in the file as "34 12"

From that bit you pasted, you can see that it has the following addresses:

Load = $8000
Init = $A000
Play = $B3B4

Posted: Sat Jan 17, 2009 10:00 am
by Laserbeak43
Wicked!!
Thanks Disch!! :D