pyNES: writing NES games in Python

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

slobu
Posts: 275
Joined: Tue Jul 12, 2011 10:58 am

Re: pyNES: writing NES games in Python

Post by slobu »

Nice idea. Needs instructions. The requirements are two words: pil mock

No idea what that means.

I'd assume install some version of python then some version of pil then this mock thing..
User avatar
thefox
Posts: 3139
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: pyNES: writing NES games in Python

Post by thefox »

It's a nice experiment, but seems very limited, "specialized" and kind of gimmicky. But it should be a nice way for newbies to get started.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
Movax12
Posts: 529
Joined: Sun Jan 02, 2011 11:50 am

Re: pyNES: writing NES games in Python

Post by Movax12 »

Reminds me a lot of batari basic. It would be pretty limited without a lot of work, but yes maybe good for newbs to get interested.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: pyNES: writing NES games in Python

Post by tokumaru »

How come tepples isn't all over this thing? He's one of the biggest Python fans I know, I thought he would be interested in finding out what this compiler is capable of.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: pyNES: writing NES games in Python

Post by tepples »

tokumaru wrote:How come tepples isn't all over this thing?
Honestly? The blank docs page.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: pyNES: writing NES games in Python

Post by tokumaru »

tepples wrote:Honestly? The blank docs page.
Same here. Even though I'm not crazy about Python (and I doubt this tool is powerful enough to make something meaningful), I was mildly interested in this project, until I saw the blank docs page.
strat
Posts: 396
Joined: Mon Apr 07, 2008 6:08 pm
Location: Missouri

Re: pyNES: writing NES games in Python

Post by strat »

Got it to work. He clearly expected everyone to read the Python code to figure out how his creation works (He said it himself, "the documentation is in another castle!").

This is what I had to do just to not get Python to bark an error:

-Install Python 2.7
-Install something called setuptools
http://pypi.python.org/pypi/setuptools
-Run setup.py install in the Pynes folder

And there was no command line problem at all. Here is what you have to do. Open one of the example programs. See that call to 'pynes.press_start()'? Place a 'True' in the call. Now it will output asm. Hardy har har.
slobu
Posts: 275
Joined: Tue Jul 12, 2011 10:58 am

Re: pyNES: writing NES games in Python

Post by slobu »

Thanks for the first steps strat! However, when I run setup.py it gives me this:

Code: Select all

Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 

Traceback (most recent call last):
  File "C:\pyNES-master\setup.py", line 22, in <module>
    url = 'http://github.com/gutomaia/pyNES/',
  File "C:\Python27\lib\distutils\core.py", line 140, in setup
    raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied
>>> 
Is setup.py actually the compiler for the examples?
dullahan
Posts: 96
Joined: Mon Dec 07, 2009 11:08 am
Location: USA

Re: pyNES: writing NES games in Python

Post by dullahan »

I started something similar in ruby a few years ago. This appears to be a templating library that outputs asm or you could think of it as a meta-programming library that outputs a NES program instead of a python program. Tools like these are useful because among other things they reduce copy and paste of code fragments and can make code more succinct and readable.

When I was @ Intel working on their internal automated build system, they had ugly and huge (epic) build scripts written in XML. Every version of a driver had pages and pages of XML describing the build--it made your eyeballs bleed. The worse part was that each build script was about 98% similar to the rest so there was tons of duplication. And they were editing this stuff by hand! So I wrote a ruby library that could slurp up xml and produce ruby code and a DSL that emitted valid XML build scripts (the templating part like pyNES). This reduced code verbage by probably 75%. Some coworkers loved it and used it, others smiled and stuck with raw xml in notepad.

Moral of the story..........I forgot.
slobu
Posts: 275
Joined: Tue Jul 12, 2011 10:58 am

Re: pyNES: writing NES games in Python

Post by slobu »

dullahan wrote:I started something similar in ruby a few years ago. This appears to be a templating library that outputs asm or you could think of it as a meta-programming library that outputs a NES program instead of a python program. Tools like these are useful because among other things they reduce copy and paste of code fragments and can make code more succinct and readable.

When I was @ Intel working on their internal automated build system, they had ugly and huge (epic) build scripts written in XML. Every version of a driver had pages and pages of XML describing the build--it made your eyeballs bleed. The worse part was that each build script was about 98% similar to the rest so there was tons of duplication. And they were editing this stuff by hand! So I wrote a ruby library that could slurp up xml and produce ruby code and a DSL that emitted valid XML build scripts (the templating part like pyNES). This reduced code verbage by probably 75%. Some coworkers loved it and used it, others smiled and stuck with raw xml in notepad.

Moral of the story..........I forgot.
Moral is that you're right. This is how every successful high level language tackles low resource hardware. batari BASIC, BasiEgaXorz, ZX Basic for SMS etc..
strat
Posts: 396
Joined: Mon Apr 07, 2008 6:08 pm
Location: Missouri

Re: pyNES: writing NES games in Python

Post by strat »

You forgot to supply the install command.

python setup.py install

This is standard for installing Python packages; it just sends the Pynes stuff to the installed Python directory so an 'import' statement will find the code.

P.S. Now that I think about it, he may have had a brainfart coding the "press_start" routine and put False as the default args when he meant to put True. So you can find that in the __init__ file and change that as well.
slobu
Posts: 275
Joined: Tue Jul 12, 2011 10:58 am

Re: pyNES: writing NES games in Python

Post by slobu »

Thanks for the followup strat. Your advice worked to a tee!

Umn, I got mario.py to spit out a mario.py.asm but how does one compile THAT? I feel that after figuring out how to compile the .asm output file the only mystery is manually exploring his functions.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: pyNES: writing NES games in Python

Post by tokumaru »

The ASM syntax appears to be NESASM. Try putting NESASM in the same folder and making a .bat file with "nesasm whatever.asm" in it, and then double click it.
slobu
Posts: 275
Joined: Tue Jul 12, 2011 10:58 am

Re: pyNES: writing NES games in Python

Post by slobu »

NESASM3 seems to emit mario.fns files when I make a batch file with "NESASM3.EXE MARIO.ASM"

I put both the NESASM3.EXE and the mario.chr files in the same directory. Same result. Compiled a PONG1.ASM example from nespowerpak.com without issue.

Y'all know I have zero assembly skills but evidence points to not just no documentation but straight up broke. No offence to Guto Maia as I truly hope this project matures!
3gengames
Formerly 65024U
Posts: 2281
Joined: Sat Mar 27, 2010 12:57 pm

Re: pyNES: writing NES games in Python

Post by 3gengames »

FNS is just labels and such, while it should also make a .NES ROM file too. Add PAUSE to the line after those 2 commands and it'll tell you how any errors the file has.
Post Reply