Giter VIP home page Giter VIP logo

pynes's Introduction

pyNES

Join the chat at https://gitter.im/gutomaia/pyNES

The Legend

There was a time when game cartridges were forged in the fire of mount doom itself. That great power was then trapped into a regular plastic shelf. Most of the secrets were sealed by fellowship of hardcore game programmers. Their names were concealed in end-game credits from games that were never supposed to be finished. Countless game lives were wasted in the first level, in fruitless attempts of unveiling their evil[1] spell.

That was what my curious and inventive mind believed for years, and still do so. As a kid, I used to play those games and always asked myself how they were done. I really wanted to experience some of the game design problems the pioneers once faced. Back then, they had to wage their own tools, hack the specs for game effects and layout the memory mapper circuits. I figured out, to reach mount doom as equal, first, I had to forge my own hammer. I've decided trail their footmarks therefore I built PyNES: A Python ASM compiler for Nintendo 8 bits.

However as I strum steps progresses, the anvil didn't sound the same. Knowledge weight has changed. Internet made it all available and communities are helpful. Also, computer power had grown and programming languages evolved. I must go a further in each step of their challenges. PyNES is turning into a high-level compiler which will allow Nintendo games to be written mostly in Python. This lecture will explain the several hacks and drawbacks of such approach. And I must say, trying to compile a such evolved language to a such limited processor as the c6502 it's MADNESS. It's pyNES!

The Untold Story

pyNES <http://gutomaia.net/pyNES> started as a regular 6502 assembler. However, writing games in ASM wasn't fun enough. Thus, using some AST hacks I tried to figure out a way of translating Python code into ASM.

Release notes

  • pyNES versions 0.1.x is released as a Proof of concept.

Installation

Clone this repo into your computer, then:

cd pyNES
sudo python setup.py install

Examples

Inside pynes/examples you'll find a set of examples. Compile them with:

pynes py pynes/examples/helloworld.py -o helloworld.nes

Now you can open helloworld.nes

[1] Read "That's not all" at the end

That's not all folks

** pyNES 0.1.x **

Despite all my efforts, the pyNES version 0.1.x had several limitations as it should as a proof of concept.

Tricky limitations:
  • Sprite collision
  • Scrolling Screen
  • Sprite animation
  • Better joystick support
  • Hard to extend

Being Hard to extend

** pyNES 0.2.x **

Therefore, pyNES version 0.2.x must overcome those limitations. And so far it is going great.

Project has been split into 4 projects:
  • lexical - just the lexical analyzer
  • nesasm_py - a 6502 ASM compiler based on NESASM
  • pyNES - This project, wich must restrict it's responsibility just to
  • pyNES_StdLib - Standard Library.
Mantras:
  • No more templating.
  • Less gaps between what you are writing and what the compiler is doing.
  • Easier to extend

Hi Level Functions are not templated anymore. However, th

Example of waitvblank function:

@asm_function
def waitvblank():
    BIT('$2002')
    BPL(waitvblank)
    RTS()

That must be translated to:

waitvblank:
BIT $2002
BPL waitvblank
RTS

pynes's People

Contributors

danilobellini avatar dependabot[bot] avatar ellisonleao avatar gabriel-ozeas avatar gitter-badger avatar gutomaia avatar kirkins avatar popmilo avatar rahulunair avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pynes's Issues

Does this even work on Windows 11?

Here's what i got:
C:\Users\smart>pynes
'pynes' is not recognized as an internal or external command, operable program or batch file.

Associate .asm file to pynes.exe on NSIS

Improve the NSIS instaler with:

Associate the .asm file to pynes.exe command on the local folder. The expected behavior should be. When the user has a folder with the whole asm project, when double clicks on the main.asm file, a new main.nes file should appear.

command line and readme broken

Can't get the readme example to work AND the output from the pynes executable isn't very helpful either.

here's the hello.py file I used:

import pynes
from pynes.bitbag import *

palette = [
    0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
    0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
    0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
]

chr_asset = import_chr('player.chr')

sprite = define_sprite(128, 128, 0, 3)

def reset():
    global palette, sprite
    wait_vblank()
    clearmem()
    wait_vblank()
    load_palette(palette)
    load_sprite(sprite, 0)

I grabbed a copy of player.chr from github then used this command line:

pynes -p hello.py -o hello.nes

unfortunately this doesn't work. It produces no error message other than an unhelpful help message. The tool runs though because it creates an empty hello.nes file.

so I'm stuck - I can't even get the basics working

any ideas?

I'm on mac os x 10.11.3. installed pynes using pip.

Fix Readme issue

The sentence before the waitvblank function example is incomplete:

"Hi Level Functions are not templated anymore. However, th"

looks like it was cut off.

use Pillow instead of PIL

PIL as a graphic library is outdated and doomed. I should use Pillow from the beguining.

Context:

Sprite library uses PIL to import/export sprites from JPEG. However, PIL is outdated, we need to move on to Pillow. Basically, the change on library should only affect sprite tests.

  • remove PIL from the requirements.txt and also setup.py and put latest Pillow ilb
  • fix all the tests and make the pass

Fix PNG support on Travis

Travis is breaking tests 'cause of the lack of PIL PNG on PIP.

Witch could be called the 3P problem (3Ps with 3 letters each, that is just Pain Phuck Parody).

Anyway. Just someone that could fix this:

91 --------------------------------------------------------------------
92 PIL 1.1.7 SETUP SUMMARY
93 --------------------------------------------------------------------
94 version 1.1.7
95 platform linux2 2.7.3 (default, Aug 1 2012, 05:16:07)
96 [GCC 4.6.3]
97 --------------------------------------------------------------------
98 *** TKINTER support not available
99 --- JPEG support available
100 *** ZLIB (PNG/ZIP) support not available
101 *** FREETYPE2 support not available
102 *** LITTLECMS support not available
103 --------------------------------------------------------------------
104

Support Python 3

Support for Python 3 is a must have, especially if you intent to use pyNES in a Raspberry PI. It came with Python 3 as a standard!

  • Create a task on Makefile using Tox to in order to test with multiple python environments
  • Assert that all tests works with Python 3 and make the appropriate changes
  • Added Python 3 to run on TravisCI, just add it on .travis.yml

Documentation

Is there any documentation? The docs link currently directs here

Updated:

TODO to fullfill this issue!

  • Docs on kill the baby branch
  • Simple tutorial

Change analyser.py to use iterators

Actually pyNES deal with the process of compiling (lexical, syntax, semantic) in a serial form. I mean, I think, we will increase the performance and also the readable intention of the code if we use iterators.

That is an outstanding task, you will deal with the main spine of pyNES, however, there is nothing to be worried about that, the test coverage will guide you before any detour. Use them, "use the force Luke". Any doubt just ask.

If you are not sure how iterators work on python take a look on @ramalho presentation about it

https://speakerdeck.com/ramalho/iterators-and-generators-the-python-way
http://pyvideo.org/video/1709/iteration-generators-the-python-way

Goal:

  • change analyser.py to use iterators. For doing that, you will definitely perform a huge refactoring on the that file, and some slight changes on the syntax method.

ATTENTION:

  • I know that I should use iterator on syntax and semantic also. But let's do one step at the time. Focus only on changing the lexical analyzer.

runtime error with pyNES

can you help me i got this error :

 Traceback (most recent call last):

File "C:/Users/User/PycharmProjects/marioNES/source.py", line 6, in
pynes.press_start()
File "C:\Python34\lib\site-packages\pynes__init__.py", line 18, in press_start
game = compose(code)
File "C:\Python34\lib\site-packages\pynes\composer.py", line 348, in compose
turist.visit(python_land)
File "C:\Python34\lib\ast.py", line 245, in visit
return visitor(node)
File "C:\Python34\lib\site-packages\pynes\composer.py", line 101, in generic_visit
self.visit(item)
File "C:\Python34\lib\ast.py", line 245, in visit
return visitor(node)
File "C:\Python34\lib\site-packages\pynes\composer.py", line 178, in visit_Assign
self.generic_visit(node)
File "C:\Python34\lib\site-packages\pynes\composer.py", line 103, in generic_visit
self.visit(value)
File "C:\Python34\lib\ast.py", line 245, in visit
return visitor(node)
File "C:\Python34\lib\site-packages\pynes\composer.py", line 245, in visit_Call
self.generic_visit(node.args)
File "C:\Python34\lib\site-packages\pynes\composer.py", line 90, in generic_visit
self.visit(n)
File "C:\Python34\lib\ast.py", line 245, in visit
return visitor(node)
File "C:\Python34\lib\site-packages\pynes\composer.py", line 293, in visit_Str
self.stack(NesString(node.s))
File "C:\Python34\lib\site-packages\pynes\nes_types.py", line 112, in init
str.init(self, string)
TypeError: object.init() takes no parameters

more and better examples needed

i think that the examples are far not enough for figuring out the potential of pyNES, like developing more complex code, like what we can do on Boriel’s ZXBasic Compiler - where from can we find these examples? and would be great if this github account could host such examples as well - and thanks in advance! :)

[OFF-TOPIC] Sobre o PyNES

Olá Guto, tudo bem?
Gostei muito do PyNES, é uma idéia sensacional e ficou muito bom o SDK kit.
Recentemente, eu estava pensando em uma idéia semelhante só que para Mega Drive, visto que existem outras SDKS para a plataforma mas em linguagens muito travadas como C ou BASIC. Atualmente prefiro fazer em puro assembly m68k do que usar elas.

Sem mais rodeios, gostaria de saber se tenho sua permissão para desenvolver baseado no PyNES, uma sdk para o Mega Drive.

Aguardo sua autorização, obrigado!

Error on compile pynes/examples/helloworld.py

I write commands:

$ git clone https://github.com/gutomaia/pyNES
$ cd pyNES/
$ python3 setup.py install
$ pynes py pynes/examples/helloworld.py -o helloworld.nes

Output:

Traceback (most recent call last):
  File "/usr/local/bin/pynes", line 4, in <module>
    __import__('pkg_resources').run_script('pyNES==0.0.2', 'pynes')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 667, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1463, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.8/dist-packages/pyNES-0.0.2-py3.8.egg/EGG-INFO/scripts/pynes", line 7, in <module>
    main(sys.argv)
  File "/usr/local/lib/python3.8/dist-packages/pyNES-0.0.2-py3.8.egg/pynes/__init__.py", line 82, in main
    args.func(args)
  File "/usr/local/lib/python3.8/dist-packages/pyNES-0.0.2-py3.8.egg/pynes/__init__.py", line 86, in exec_py
    pynes.composer.compose_file(args.input, output=args.output,
  File "/usr/local/lib/python3.8/dist-packages/pyNES-0.0.2-py3.8.egg/pynes/composer.py", line 327, in compose_file
    game = compose(code)
  File "/usr/local/lib/python3.8/dist-packages/pyNES-0.0.2-py3.8.egg/pynes/composer.py", line 345, in compose
    builder.visit(python_land)
  File "/usr/lib/python3.8/ast.py", line 363, in visit
    return visitor(node)
  File "/usr/lib/python3.8/ast.py", line 439, in generic_visit
    value = self.visit(value)
  File "/usr/lib/python3.8/ast.py", line 363, in visit
    return visitor(node)
  File "/usr/lib/python3.8/ast.py", line 448, in generic_visit
    new_node = self.visit(old_value)
  File "/usr/lib/python3.8/ast.py", line 363, in visit
    return visitor(node)
  File "/usr/local/lib/python3.8/dist-packages/pyNES-0.0.2-py3.8.egg/pynes/composer.py", line 57, in visit_List
    expr = self.generic_visit(node)
  File "/usr/lib/python3.8/ast.py", line 439, in generic_visit
    value = self.visit(value)
  File "/usr/lib/python3.8/ast.py", line 363, in visit
    return visitor(node)
  File "/usr/lib/python3.8/ast.py", line 393, in visit_Constant
    return visitor(node)
  File "/usr/local/lib/python3.8/dist-packages/pyNES-0.0.2-py3.8.egg/pynes/composer.py", line 54, in visit_Num
    return Num(NesInt(node.n))
NameError: name 'Num' is not defined

Can anyone help me?

Python version: 3.8.5

Added README.rst to the setup.py

When the project is listed on Python Index (pypi), usually it does have a small description. That usually come when refering the README.rst in setup.py and adding the file to wheel package.

Docs!

We need docs, really!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.