(Fetched from https://pineight.com/)
IF THIS FILE HAS NO LINE BREAKS: View it in a web browser. Windows Notepad is a very popular text editor that comes with the Windows operating system, but it doesn't recognize line breaks in text files made on Linux or any other UNIX-like operating system. Text files with UNIX line breaks display correctly in WordPad, Notepad++, Programmer's Notepad, Gedit, or a web browser, just not in Windows Notepad.
This is a minimal working program for the Nintendo Entertainment System using the SGROM or SNROM board.
Concepts illustrated:
- init code
- setting up a static background
- structure of a game loop
- DPCM-safe controller reading
- 8.8 fixed-point arithmetic
- acceleration-based character movement physics
- sprite drawing and animation, with horizontal flipping
- makefile-controlled conversion of sprite sheets
- initializing the MMC1
- loading tile data into CHR RAM
- calls from one PRG bank to another
Building this demo requires that the following software be installed on your computer first:
- ca65 and ld65, the assembly language tools that ship with the cc65 C compiler
- Python, a programming language interpreter
- Python Imaging Library, a Python extension to read and write bitmap images
- GNU Make, a program to calculate which files need to be rebuilt when other files change
- GNU Coreutils, a set of simple command-line utilities for file management and text processing
It also requires general familiarity with the command prompt. You are encouraged to read and understand the articles on general computer science topics listed at Before the basics.
The MSYS project ports Make, Coreutils, and other key parts of the GNU operating environment to Windows. An easy way to install MSYS is through the automated installer provided by devkitPro.
- Visit MSYS2 Project home page.
- Follow the instructions there to download and run the MSYS2 Installer.
To install Python under Windows:
- Visit Python home page.
- Under Downloads, under Download for Windows, click Python 3.5.1. (This step may change if the maintainers of the Python web site reorganize the Python web site.)
- In your web browser's downloads folder, run
python-3.5.1.msi
- Follow the prompts through the installer wizard.
To install Python Imaging Library under Windows:
- Visit Pillow project page.
- Under Package, click the latest version.
- Click Downloads.
- Click
Pillow-3.2.0.win32-py3.5.exe
. Thepy-3.5
part MUST match the major and minor version of Python installed on your PC. (In Python 3.5.1, the major version is 3, the minor version is 5, and the bug fix version is 1.) - In your web browser's downloads folder, run
Pillow-3.2.0.win32-py3.5.exe
- Follow the prompts through the installer wizard
To install cc65 under Windows:
- Visit cc65 introduction.
- Scroll to the bottom.
- Click "Windows Snapshot" to download a zip file.
- Open the zip file.
- Inside the zip file, open the bin folder.
- Drag
ca65.exe
andld65.exe
into a new folder. - Add this folder to your "Path" environment variable.
Finally, to make ca65, ld65, and Python available to Make, you'll
need to add the folders containing ca65.exe
, ld65.exe
, and
python.exe
to the Path
environment variable. Because the steps
for setting environment variables differ between versions of Windows,
you'll want to search the web for windows x.x path variable
,
replacing x.x
with 7
, 8.1
, etc.
Finally, open the makefile in a text editor and change EMU to whatever NES emulator you have installed.
nes.inc
: Register definitions and useful macrosglobal.inc
: Global variable and function declarations
mmc1.s
: iNES header and driver for MMC1unrom.s
: iNES header and driver for UNROM/UOROMinit.s
: PPU and CPU I/O initialization codemain.s
: Main programbankcalltable.s
: List of entry points called through a far call (one that goes from one bank to another)chrram.s
: CHR RAM data setupbg.s
: Background graphics setupplayer.s
: Player sprite graphics setup and movementpads.s
: Read the controllers in a DPCM-safe mannerppuclear.s
: Useful subroutines for interacting with the S-PPU
Each source code file is made up of subroutines that start with
.proc
and end with .endproc
. See the ca65 Users Guide for
what these mean.
The tools
folder contains a couple essential command-line programs
written in Python to convert graphics into a form usable by the NES.
The makefile contains instructions to run the program again whenever
the original asset data changes.
pilbmp2nes.py
is a program to convert bitmap images in PNG or BMP format into tile data usable by several classic video game consoles. It has several options to control the data format; usepilbmp2nes.py --help
from the command prompt to see them all.
The demo is distributed under the following license, based on the GNU All-Permissive License:
Copyright 2011-2015 Damian Yerrick
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved in all source code copies. This file is offered as-is, without any warranty.