clueless wrote:I'm just curious... what was the problem? What did you change to make it work?
I wasn't aware that I had to place the fixed bank
after the other PRG ROM banks in the NES file. I had previously been writing the fixed bank immediately following the iNES header.
Of course, tokumaru told me exactly what to do from the beginning:
tokumaru wrote:But be sure to place your vectors and reset code in the last 16KB bank, because that's the one UNROM keeps mapped at $C000-$FFFF at all times.
I guess I was just being dense.
Anyhow, below are the header, linker config, and batch file I use to build my (now working!) UNROM project:
Header:
Code: Select all
.segment "HEADER"
; Header for UNROM board
.byte "NES", $1A ; "NES" followed by MS-DOS end-of-file
.byte $08 ; Size of PRG ROM in 16 KB units (128 KB for UNROM)
.byte $00 ; Size of CHR ROM in 8 KB units (Value 0 means the board uses CHR RAM)
.byte $20, $00 ; Mapper 2 = UNROM/UOROM
.byte $00 ; Size of PRG RAM in 8 KB units (Value 0 infers 8 KB for compatibility)
Linker config:
Code: Select all
MEMORY {
M_ZEROPAGE: start = $00, size = $100, type = rw;
M_RAM: start = $200, size = $600, type = rw;
M_HEADER: start = $0, size = $10, type = ro, fill = yes, file = "build\ld65\header.bin";
M_WORKRAM: start = $6000, size = $2000, type = rw;
# PRG ROM banks (16 KB each, bank 7 is fixed)
M_PRGBANK0: start = $8000, size = $4000, type = ro, fill = yes, file = "build\ld65\bank0.prg";
M_PRGBANK1: start = $8000, size = $4000, type = ro, fill = yes, file = "build\ld65\bank1.prg";
M_PRGBANK2: start = $8000, size = $4000, type = ro, fill = yes, file = "build\ld65\bank2.prg";
M_PRGBANK3: start = $8000, size = $4000, type = ro, fill = yes, file = "build\ld65\bank3.prg";
M_PRGBANK4: start = $8000, size = $4000, type = ro, fill = yes, file = "build\ld65\bank4.prg";
M_PRGBANK5: start = $8000, size = $4000, type = ro, fill = yes, file = "build\ld65\bank5.prg";
M_PRGBANK6: start = $8000, size = $4000, type = ro, fill = yes, file = "build\ld65\bank6.prg";
M_PRGFIXED: start = $C000, size = $4000, type = ro, fill = yes, file = "build\ld65\fixed.prg";
}
SEGMENTS {
HEADER: load = M_HEADER, type = ro;
CODE: load = M_PRGFIXED, type = ro, start = $C000;
RODATA: load = M_PRGFIXED, type = ro;
VECTORS: load = M_PRGFIXED, type = ro, start = $FFF0;
ZEROPAGE: load = M_ZEROPAGE, type = zp;
BSS: load = M_RAM, type = bss, align = $100;
PRGBANK0: load = M_PRGBANK0, type = ro, start = $8000;
PRGBANK1: load = M_PRGBANK1, type = ro, start = $8000;
PRGBANK2: load = M_PRGBANK2, type = ro, start = $8000;
PRGBANK3: load = M_PRGBANK3, type = ro, start = $8000;
PRGBANK4: load = M_PRGBANK4, type = ro, start = $8000;
PRGBANK5: load = M_PRGBANK5, type = ro, start = $8000;
PRGBANK6: load = M_PRGBANK6, type = ro, start = $8000;
}
Batch file:
Code: Select all
@ECHO OFF
SET NESFILE="Bionic Commander (U).nes"
SET BUILD1=build\ca65
SET BUILD2=build\ld65
REM Assemble
call ca65 -I source source\main.s -o %BUILD1%\main.o
call ca65 -I source source\input.s -o %BUILD1%\input.o
call ca65 -I source source\level1.s -o %BUILD1%\level1.o
call ca65 -I source source\util.s -o %BUILD1%\util.o
REM Link
call ld65 --obj-path %BUILD1% -C unrom.cfg main.o input.o level1.o util.o -o ""
REM Create NES file
call copy /b /y %BUILD2%\header.bin %NESFILE%
call copy /b /y %NESFILE% + %BUILD2%\bank0.prg %NESFILE%
call copy /b /y %NESFILE% + %BUILD2%\bank1.prg %NESFILE%
call copy /b /y %NESFILE% + %BUILD2%\bank2.prg %NESFILE%
call copy /b /y %NESFILE% + %BUILD2%\bank3.prg %NESFILE%
call copy /b /y %NESFILE% + %BUILD2%\bank4.prg %NESFILE%
call copy /b /y %NESFILE% + %BUILD2%\bank5.prg %NESFILE%
call copy /b /y %NESFILE% + %BUILD2%\bank6.prg %NESFILE%
call copy /b /y %NESFILE% + %BUILD2%\fixed.prg %NESFILE%
pause