Hi guys, sorry for the delay. I'm the author of the project.
First, I really would like to thanks for sharing.
Second, No it's not fake. pyNES is meant to be a python compiler for NES. However it is being built in a different way.
Usually compilers are formal. Take the "C" compiler for example, it evolves along with the processor in their time. The number of instructions and the optimizations where really tight couple with the processor instructions of their launch. As the language, "C" programmers also evolved. Changing the static linking for dynamic link as more memory became available. That leads to GRASP patterns and then OOP and C++. 'Course, even C and C++ have stopped as a language it self, however the compiler didn't stop. Nowadays processors have multicore specific instructions and of course compilers must deal with those optimizations using some kind of pattern matching. That leads as to Virtual machines like JVM, .NET, pypy. Witch can deal of optimizations in layers using hotspot.
Therefore, why not use pattern matching for transitions from a highlevel language to a limited processor?
NES developers knows how developing for a such limited machine differs from actual highlevel programming. Most of the logic is decoded into the most simplest instructions. Complex structure types are hacked into address and ways of reading it.
At first pyNES was just an ASM compiler compatible with nesasm. However after nodeNES (a javascript IDE, not finish also). I need to go further with pyNES. Then, Klaus Silveira, a friend cames if a challenge to write nes games in python. Okay, at the start he was just kidding, but after some rounds in street fighter (witch Zangief beats him pile dive after pile diver), we imagine that it was possible.
Okay
That was the intention was the aim of pyNES. Write NES games in Python. However, I need to add some constrains. And there goes:
1) The approach:
- It's not a formal compiler. Structures are not pre-defined. Same goes for types
- TDD drives the format, at the end, the software will emerge.
- I must keep the hack felling! It must feels like a hack.
2) The Values:
- I must respect python, although it's not a full python compiler and it will only use a subset of python. That subset must be respected.
- I must respect NES developers. When I started my NES ASM research, I saw how clever and fantastic was developing for NES. The referenced python code must generate an ASM code that a NES developer would write. A code that could be found here.
3) The Goals:
The main goal is to build 3 NES games entire in python:
- A Sidescroller Plataform
- A TopDown Shooter
- A RPG
Okay, so much for the compiler introduction and for the project goals. Let me explain in the bits:
How to map the types?
For example, how to map an Int?
- if it is used but not assined the value could be directed assigned in the asm, like in a local scope
- If it is used and assigned but not changed, it could be a const.
- If it is assigned and changed it must be used as an .RS
And for a more complex type, like a List? I have to put some extra constrains here
- List cannot be changed after used by a bitpak.
- Lists can have constants or int, cannot have objects or strings
- Lists are a dataset of sequencial address in the bank 1
And a String? more constraints here, cause String works like a list.
- String cannot be changed after used by a bitpak.
- String are mapped by a String that defines the charset and also end String char. So it can use the assets on the CHR
What the hell are those bitpak?
- Highlevel languages dosent provide much of label instructions. Therefore there is no GOTO. Instructions like a WAITVBLANK, would be very strange.The correct would be a While loop, but that is not what happen at hardware level. So I created a way to gather a bunch of asm instructions in a single function.
How FOR would be made? In python, for usually uses dynamic loops with a list. Like "for a in [1,2,3,4]:"
- I told, i must respect python, so loops must keep that way, but nes dosent have ways to store that dynamic part. And that must be hacked.
- if the for is in a sequential series of arguments, it must be just use a comparison with the last value.
- if the for is in a list that is stored in the cart, like a String or List
- If the list is not stored and the cart has space, so why not store it
.
Well, I'm still refactoring most of the hacks right now and starting the docs. Klaus Silveira help me out with the site. Gabriel Ozeas help me with some erros on travis CI. Docs are coming, more examples also.
Right now: THE DOCUMENTATION IS IN ANOTHER CASTLE!
There are more features related with image and direct conversion to the chr and nametables.
Anyone can contribute with the project. If you dont know how, just ask me. If you have a ASM example that does compile with NESASM, just send me. I will add it as a project fixture.
PS: if some guys could really help me with some ASM questions and specific nes stuff.