If you do decide to use CA65 as your assembler, setup is very difficult. I will attempt to help with a very basic linker file for you. This linker file assumes you are creating a simple NROM game. NROM are the simplest games, they have essentially no mapper. You get 2 PRG banks to hold your data, which is plenty for most starting projects (sudoku only used 1).
Copy this chunk into a file called nes.ini
MEMORY {
HEADER: start = $00, size = $0010, type = ro, file = "tmp/lightgun.hed";
ZP: start = $00, size = $100, type = rw, file = "";
RAM: start = $200, size = $400, type = rw, file = "";
PRG0: start = $8000, size = $4000, type = ro, file = "tmp/bank0.prg";
PRG1: start = $C000, size = $4000, type = ro, file = "tmp/bank1.prg";
}
SEGMENTS {
INES_HEADER: load = HEADER, type = ro, align = $10;
ZEROPAGE: load = ZP, type = zp;
BSS: load = RAM, type = bss, define = yes;
BANK0: load = PRG0, type = ro, align = $100;
TITLE_REGION: load = PRG0, type = ro, start= $8000;
BANK0_END: load = PRG0, type = ro, start= $C000;
BANK1: load = PRG1, type = ro, start = $C000;
VECTORS: load = PRG1, type = ro, start = $FFFA;
}
Now you need a simple makefile. I use cygwin since I have a Unix background. I suspect that if you are not familiar with makefiles, this will be difficult to read and understand.
Copy these contents into file called "makefile"
# To build the NES ROM just type: make
# To run the NES ROM just type: make run
# Note: as with any make system, if any of the files have been updated they will
# be rebuilt along with any parts that are dependant on them
# Tools required. You should set these defines in your environment rather than update the makefile
# ie: Control Panel -> System -> Advanced -> Environment Variables -> (New) User Variable
# Three environment variables are required
#
ifndef CA65
CA65 = C:\Personal\NES\Dev\Compilers\cc65\bin\ca65.exe
endif
ifndef LD65
LD65 = C:\Personal\NES\Dev\Compilers\cc65\bin\ld65.exe
endif
ifndef EMU
EMU = C:\Personal\NES\Dev\Emulators\fceu-0.98.15-rerecording\fceu.exe
endif
# Change the MAIN from "example" to whatever your project is going to be called.
# This means you need a file called "example.asm" and a tiles file called "example.chr"
MAIN = example
INTER = tmp
# intermediate files
OBJS = $(MAIN).o
HEADER = $(INTER)/header.hed
ALL_PRG = $(INTER)/bank0.prg $(INTER)/bank1.prg
ALL_CHR = resources/$(MAIN).chr
# the part that does the compiling, assembling, linking etc..
all: $(MAIN).nes
clean:
rm -f $(OBJS) $(HEADER_OBJS) $(BANK_OBJS) $(HEADER) $(MAIN).nes $(ALL_PRG)
rm -Rf $(INTER)
run: $(MAIN).nes
$(EMU) $(MAIN).nes
# For making the PRG (including header)
$(OBJS): %.o: %.asm
$(CA65) $(CFLAGS) $< -o $@
$(ALL_PRG): $(OBJS)
mkdir -p $(INTER)
$(LD65) $(OBJS) -C nes.ini
# For making the final iNES ROM
$(MAIN).nes: $(ALL_PRG) $(HEADER)
cat $(HEADER) $(ALL_PRG) $(ALL_CHR) > $(MAIN).nes