Programming guide
From NESdev Wiki
(Redirected from Programming)
Jump to navigationJump to search
This programming guide is the complement to the NES reference guide. You will find more in-depth documentation about specific topics, tutorials on the most common problems encountered, a list of existing tools that will assist you during you development phase and more. If you're new to NES development, you should give a look to the "getting started" section first.
Getting started
- Before the basics
- Commissioning - suggestions for a non-programmer seeking help
- Programming Basics
- Installing CC65
General reference
- Registers
- Waiting for the PPU to power on
- CHR-ROM vs CHR-RAM and how to switch an NROM project from the former to the latter
- Emulation Libraries
- Catch-up technique used by emulators
- Flash Cartridges (PowerPak / Everdrive N8 / Everdrive N8 Pro / KrzysioCart)
- Music: Expansion audio
- Tools — includes assemblers, disassemblers, graphics, music/audio, and emulator-related utilities
Tutorials
- CPU basics
- PPU reference
- APU basics
- Compression
- Programming mappers
- Programming Techniques
- Limitations
- Emulation Tutorials
- Sample RAM map
- PPU scrolling
- How to scroll an infinite map
- How to scroll with less artifact
- How to split the screen for a status bar
- How to do parallax scrolling with the scroll register
- Sprite size
- How to make raster effects by Bregalad
- The frame and NMIs by Disch
- NMI thread: Make your status bar rock-solid
- Nerdy Nights sound
- Palette change mid frame
- Don't hardcode OAM addresses
- Interrupt forwarding
- Sprite cel streaming
- Drawing terrain
- Releasing on modern platforms
Libraries and samples
System
Input
Graphics
Math
- Multiplication by a constant integer
- Fast signed multiply - Fast table driven multiplication
- 8-bit Multiply - Multiplies two 8-bit integers to a 16-bit result
- 8-bit Divide - Divide two 8-bit integers to a 16-bit result
- Division by a constant integer
- Divide by 3
- 16-bit BCD - An efficient 16-bit binary to decimal converter
- Base 100 - An alternate method of storing numbers, to simplify BCD conversion
- Random number generator
Audio
Misc
Examples
- Projects - includes many useful open-source examples.
- Nerdy Nights Out (aka: Learning 6502) by BunnyBoy
- Programming NES Games in C by Shiru
- How to Program an NES game in C by dougeff
- Simple game and editing guide (in C)
- Project template by tepples
- Minimal NES example using ca65 by rainwarrior
Reverse engineered techniques
- Bad Apple video compression
- Codemasters tile compression
- Big Bird's Hide and Speak sample compression
- Battletoads text compression (Huffman coding)
- Rad Racer rendering
Useful reference materials
Books
- Cady, Fredrick M. (1997). Microcontrollers and Microcomputers: Principles of Software and Hardware Engineering. New York: Oxford University Press. ISBN 0-19-511008-0.
- Eyes, David; Lichty, Ron (1986). Programming the 65816 including the 6502, 65C02, and 65802. New York: Brady Books/Prentice Hall Press (Simon & Schuster, Inc). ISBN 0-89303-789-3. Rights later purchased by Western Design Center.
- Fernandez, Judi N. (1983). 6502 Assembly Language Programming (Self-teaching Guides). John Wiley & Sons Inc. ISBN 978-0471861201.
- Leventhal, Lance A. (1986). 6502 Assembly Language Programming 2nd Edition. Osborne/McGraw-Hill. ISBN 0-07-881216-X.
- Zaks, Rodnay (1983). Programming the 6502 (Fourth Edition). Sybex, Inc. ISBN 0-89588-135-7.
- Zaks, Rodnay (1982). Advanced 6502 Programming. Sybex, Inc. ISBN 0-89588-089-X.
- Zaks, Rodnay (1980). Programming the 6502 (Third Edition). Sybex, Inc. ISBN 0-89588-046-6.
Online
- Programming the 65816 (including the 6502, 65C02, and 65802) by Western Design Center
- Programmingthe65816_ProgManual.pdf — 54MBytes, created 2015/03/27.
- This is a full scan of the original Eyes/Lichty book using full images for each page, with the added bonus of OCR being applied so that text is searchable and copy-paste-able. Accurate/reliable given the nature of the scan.
- backup copy via Koitsu (primary)
- backup copy via Koitsu (secondary)
- This is a full scan of the original Eyes/Lichty book using full images for each page, with the added bonus of OCR being applied so that text is searchable and copy-paste-able. Accurate/reliable given the nature of the scan.
- Programmanual.pdf (a.k.a. WDC65C816_Program_Manual.pdf) — 1.7MBytes, created 2007/04/16.
- This is a "pure text" version of the Eyes/Lichty book, however it is rife with very dangerous typos (wrong opcodes, etc.) in many areas, and contains a large number of formatting/layout mistakes not present in the original book. Bill Mensch (6502/65C02/65816 architect/designer) confirmed these mistakes, stating WDC is in the process of fixing them. If at all possible, use the newer PDF mentioned above.
- It is suspected that WDC has pulled this PDF entirely from their website, instead advocating purchasing a "redone" version of the Lichty/Eyes book via Amazon. Kindle and paperback versions are available, but I (Koitsu) have not reviewed it.
- Programmingthe65816_ProgManual.pdf — 54MBytes, created 2015/03/27.
Links
- The infamous 6502.txt: allegedly complete info on the 6502 instructions
- Machine Language for Beginners: a 1983 introduction to 6502 assembly language