It is currently Mon Mar 27, 2017 11:13 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Mar 16, 2017 6:52 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1421
Location: DIGDUG
This is the disassembler I've been working on...

http://dl.dropboxusercontent.com/s/3xkx ... /6502d.zip

It's stable now. And worked on 6 of 7 files that I tested. (Haven't had time to look into why the 1 didn't work. It seems to do great on smaller files). Definitely not 'finished'. Feel free, any of you, to make changes to this file, as you see fit. It works with Python 3, on Windows. May work on other platforms, IDK. Reassembles with asm6.


Known issues. For some reason, I made it absolutely require that the filesize match what the iNES header claims. In my tests, I have been having to edit the file in a hex editor, to remove signatures appended to the end of the ROM.

EDIT - another issue, is filenames with spaces in them, asm6 was confused when I typed the name in...like each word of the name was a separate argument. Just remove spaces from the original name before disassembling.


Other uses of this file.
1.It tells you (in the command line dialog) lots about the file. How many banks. What mapper. Mirroring. Etc. Some emulators do this too. No big deal.

2.It splits the PRG-ROM and CHR-ROM and saves them (minus the header) as 2 binary files. This might be useful to people planning to burn actual hardware ROMs.


Again, feel free, to fix or improve this file. I know nothing about Python. Also, read the usage for lots of ominous warnings about how it can delete / erase files if you are not careful.


EDIT - you will have to edit line 34 of the python script (path to file) to make this work. See usage for more info.

EDIT2 - This is a no brainer disassembler...you (maybe) will have to literally do nothing to the output file to get it to reassemble correctly with asm6.

EDIT3 - Only for whole .NES files. Won't work for anything else. Maybe I'll edit it later to be more general.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Last edited by dougeff on Fri Mar 17, 2017 5:14 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Mar 16, 2017 9:20 pm 
Offline
User avatar

Joined: Thu Jan 19, 2006 5:08 pm
Posts: 729
Location: Shelton, Washington.
When I try to disassemble "Super Mario Bros 2. (U) (PRG0) [!].NES" as a test, It fails to disassemble due to the following:

"ERROR: couldn't find iNES header"

This is false, it has a "VALID" iNES 1.0 header, This may be a big problem with your code!

_________________
AKA SmilyMZX/AtariHacker.


Top
 Profile  
 
PostPosted: Fri Mar 17, 2017 4:40 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1421
Location: DIGDUG
Then remove (or comment out) the lines "exit()". See what happens. Maybe something good. Maybe something bad. Nobody knows.

By the way. The only thing that part of the code is doing, is comparing the first 4 bytes of the ROM to $4E $45 $53 $1A. As "usage" says. I don't know Python. I don't know why it doesn't work. It works for me.


EDIT - actually, I left the debugging test there, just uncomment (remove the # from) line 886 that says...

print (workArray[i], " ", testarray[i])

I get... (printed in the command line box)...
78 78
69 69
83 83
26 26

What do you get?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Fri Mar 17, 2017 9:19 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2778
Location: Tampere, Finland
I'm guessing Hamtaro used Python 2. In Python 2, file.read() returns a string. If you index into it, you will get another string (the character), not an int.

You could put something like assert sys.version_info[0] >= 3, "python 3 required" at the top of your source code (after import sys, of course).

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Fri Mar 17, 2017 9:33 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 17993
Location: NE Indiana, USA (NTSC)
If you want to go the 2/3 polyglot route:
In Python 2.6 or 2.7, bytearray(file.read()) returns an object that behaves more like a Python 3 bytes.

If you want to mark a Python program as 3-only, test for the specific behaviors you're expecting:
Code:
#!/usr/bin/env python3
assert str is not bytes


Top
 Profile  
 
PostPosted: Fri Mar 17, 2017 9:48 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1421
Location: DIGDUG
On my Linux computer, which has both python 2 and 3, I had to type...

"python3 6502d.py"

...in the terminal.

Workes fine (I also had to edit the path, as usual, within the file).

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Fri Mar 17, 2017 9:56 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 4912
Location: Canada
tepples wrote:
If you want to mark a Python program as 3-only, test for the specific behaviors you're expecting

Why would you need to test for behaviours that Python 3 guarantees in a program that's only supposed to run on Python 3?

Also, to know what to test requires an encyclopedic knowledge of the differences between Python 2 and 3.

The hashbang line is very useful, though, because it can be used to automatically select Python 3 on systems with both 2 and 3 installed. I'd recommend that, combined with thefox's assert, which will give a helpful error in the case that Python 2 is used by mistake.
Code:
#!/usr/bin/env python3
import sys
assert sys.version_info[0] >= 3, "python 3 required"

wiLL tHE gREat pYtHON scHisM EvER ENd?


This post was corrupted and has been reconstructed from memory.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group