Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lucasw
Last active October 30, 2021 15:07
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasw/53ece8eed3b99beb6215b42cc686d1a7 to your computer and use it in GitHub Desktop.
Save lucasw/53ece8eed3b99beb6215b42cc686d1a7 to your computer and use it in GitHub Desktop.
Linux Nintendo NES development

Ubuntu 16.04

install cc65

mkdir ~/other
cd ~/other
git clone https://github.com/cc65/cc65
cd cc65
make
PATH=$PATH:`pwd`/bin

If need to update:

make clean
git pull
make

Install Emulator

sudo apt-get install fceux

or

sudo apt install subversion  # I didn't have this installed, since git is so prevalent...
sudo apt install scons
svn checkout https://svn.code.sf.net/p/fceultra/code/fceu/trunk fceultra-code
cd fceultra-code
scons
...
xport PATH=$PATH:`pwd`/bin

build nes examples (doesn't work)

Then get nes samples:

Don't bother with these

cd ~/other
mkdir nes
cd nes
wget https://shiru.untergrund.net/files/src/cc65_nes_examples.zip
unzip cc64_nes_examples.zip
cc65 crt0.s
crt0.s(1): Warning: Implicit `int' is an obsolete feature
crt0.s(1): Error: `;' expected
...
crt0.s(1): Fatal: Too many errors

Oops, try ca65 instead, that works

ca65 crt0.s   # create crt0.o
cc65 -Oi example1.c --add-source  # create example1.s
ca65 example1.s  # creates example1.o
ld65 -C nrom_128_horz.cfg -o example1.nes crt0.o example1.o runtime.lib 
ld65: Error: nrom_128_horz.cfg(53): Attribute expected, got '__STACKSIZE__'

replace line 53 with (looking at cc65/cfg/nes.cfg):

  __STACKSIZE__: type = weak, value = $0500; # 5 pages stack

But then get

ld65: Error: nrom_128_horz.cfg(55): Attribute expected, got 'NES_MAPPER'

Other nes cc65 examples? (doesn't work)

Try these instead? https://github.com/jmk/cc65-nes-examples.git

~/other/cc65-nes-examples$ make
ca65 crt0.s
cc65 -Oi example1.c --add-source
ca65 example1.s
rm example1.s
ld65 -C nes.cfg -o example1.nes crt0.o example1.o runtime.lib
ld65: Error: nes.cfg(82): Attribute expected, got '__STACKSIZE__'
Makefile:22: recipe for target 'example1.nes' failed
make: *** [example1.nes] Error 1
rm example1.o

These are 4 years old without an update.

https://github.com/RichardJohnn/cc65-nes-examples has a more recent fork

algofoogle examples (works!)

How about https://github.com/algofoogle/nes-gamedev-examples ?

nes-gamedev-examples/part01/ex01-c-example$ cl65 -t nes hello-nes.c -o hello.nes

That actually built a hello.nes

fceux hello.nes

Works!

@denisenepraunig
Copy link

denisenepraunig commented Oct 30, 2021

Thanks for your gist, I was struggling with shiru's cc65 examples but thanks to your links I found something that works :-) (macOS 11.6)

@lucasw
Copy link
Author

lucasw commented Oct 30, 2021

I should have left a link here to https://github.com/lucasw/nes_cc65_demo earlier - if you didn't already see that it may be more useful, better organized than this gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment