Reading Hex Files

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
User avatar
Laserbeak43
Posts: 188
Joined: Fri Sep 21, 2007 4:31 pm
Contact:

Reading Hex Files

Post by Laserbeak43 » Fri Jan 16, 2009 9:57 pm

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
Noob sticky!!
Please document this part of the NESdevWiki!! XD
YOU NEED A RETROMACHINESHOP!!

User avatar
Disch
Posts: 1849
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch » Fri Jan 16, 2009 10:01 pm

You don't. You get the $8000 from elsewhere in the header. The load address, specifically -- offset 0x0008, which is most likely '00 80'.

User avatar
Laserbeak43
Posts: 188
Joined: Fri Sep 21, 2007 4:31 pm
Contact:

Post by Laserbeak43 » Sat Jan 17, 2009 4:50 am

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?
Noob sticky!!
Please document this part of the NESdevWiki!! XD
YOU NEED A RETROMACHINESHOP!!

User avatar
Disch
Posts: 1849
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch » Sat Jan 17, 2009 9:04 am

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

User avatar
Laserbeak43
Posts: 188
Joined: Fri Sep 21, 2007 4:31 pm
Contact:

Post by Laserbeak43 » Sat Jan 17, 2009 10:00 am

Wicked!!
Thanks Disch!! :D
Noob sticky!!
Please document this part of the NESdevWiki!! XD
YOU NEED A RETROMACHINESHOP!!

Post Reply