Ubuntu 16.04
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
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
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'
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
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!