cirla / nesdev Goto Github PK
View Code? Open in Web Editor NEWNES Development Tutorial
License: MIT License
NES Development Tutorial
License: MIT License
Syntax for configuration files or commands might change from version to version.
see #1
To prevent frustration, the used cc65 version should be named in the README file.
Also it should be mentioned in the tutorial. (Which is great by the way ๐ )
The parameter stack in this project is not set up correctly: it is placed on page one, starting at the exact same address as the hardware return stack. If you attempt to use functions that take arguments, or local variables in functions, they will overwrite return addresses on the 6502's hardware return stack.
Your current code doesn't have any problems, because its C code never uses function arguments or local variables. However, if a hapless tutorial reader (like me), tries to write typical C code with function arguments or locals, the program will soon start behaving erratically and eventually crash.
The cc65 compiler uses a separate stack for function arguments and local variables: the "parameter stack". It is typically placed at the end of RAM, and occupies a configurable number of pages. The usage of the return and parameter stacks in cc65 is documented here: https://github.com/cc65/wiki/wiki/Parameter-and-return-stacks
You can see how cc65's default linker configuration files reserve space at the end of RAM for the parameter stack: https://github.com/cc65/cc65/blob/master/cfg/nes.cfg
I believe the correct fix would be to initialize the parameter stack (sp
) to start at the end of NES RAM ($07FF
), and, optionally, to reduce the "RAM" memory region (in the .cfg
file) to reserve some space for the parameter stack.
By the way, thanks for writing this tutorial and providing this sample code. It was very helpful for me getting my NES project started!
(Edited: Fixed the address of end of RAM.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.