Coder Social home page Coder Social logo

nesdev's Introduction

Hi there ๐Ÿ‘‹

nesdev's People

Contributors

cirla 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

nesdev's Issues

The parameter stack is not configured correctly.

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.)

Define used cc65 version

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 ๐Ÿ‘ )

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.