This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

NES with WLA header info?

NES with WLA header info?
by on (#51441)
Ok, so im sure that this has been a topic of discussion so far but internet searches have yielded no results and i couldn't find a forum that exactly helped me either. I am trying to assemble an nes program with wla-6502 and even though it outputs a .nes file it seems to be invalid as my emulator says there is a load error. this is the code i am trying to assemble. it was taken directly from a topic on this site about using wla-6502 w/ nes:


SLOTSIZE   $2000
SLOT 0      $8000
SLOT 1      $A000
SLOT 2      $C000
SLOT 3      $E000
SLOT 4      $2000

BANKSIZE   $2000
BANKS      4

PPU_SET1:      DB
PPU_SET2:      DB

.BANK   0   SLOT   0
.ORGA   $8000

.BANK   1   SLOT   1
.ORGA   $A000

.BANK   2   SLOT   2
.ORGA   $C000

.BANK   3   SLOT   3
.ORGA   $E000

   lda PPU_READ.w
   jmp main

.DW   main, main, main

i assembled it by typing:

wla-6502 test.asm test.obj
wlalink test.nes

i have made the .link file and everything assembles correctly, but my emulator which is fceux will not load this program. Please help! I dont wanna use nesasm but it seems to be the only thing i can get to work!!! Is there something missing or something that needs done to the code to make this work?

by on (#51446)
I'm not familiar with this assembler and linker, but my first/initial guess is that it's not tacking on the necessary 16-byte NES header. Have you verified that the first 16 bytes of the .NES file consist of the header, and contain appropriate values for your ROM?

by on (#51448)
well actually thats my problem. Im not sure how to make my assembler put the header on the ROM file or even what the format of the header is or any of that. I really just started this yesterday. Not that im new to programming, i write assembly code for x86 machines but the syntax is way less complex to me than this and im not really sure what im doing yet. Can you tell me what exactly the header is, how it works, stuff like that. or is there a place where that information resides that you could point me to? thanx!!!

by on (#51449)
It sounds like WLA isn't truly familiar with generating NES files (that is to say, including the header). And that's okay, because that's pretty easy to deal with.

You can make a 16-byte file of your own and prepend it to your ROM image after the linking phase by doing something like:

wla-6502 test.asm test.obj
wlalink test.bin
copy /b header.bin+test.bin test.nes

header.bin would be a 16-byte file adhering to the following format:

by on (#51451)
Are you using a link file ? Linkfiles can add header to the output ROM very easily.

And here you are the mapping I use for a NROM game with WLA-DX if it helps you (modify it for whathever mapping sturcutre you use).
;Defines NES's RAM for any games witout SRAM
;Stack isn't defined, it's use is reserved
;Also $200-$2ff is reserved for SpriteRam and isn't defined here

defaultslot 0
slotsize $100
slot 0 $0   ;0 page RAM
slotsize $500
slot 1 $300   ;BSS RAM
slotsize $4000      ;PRG ROM slot (32kb)
slot 2 $c000
slotsize $2000      ;CHR ROM slot (8kb)
slot 3 $0

;Define a NROM structure with 16kb PRG and 8kb CHR

bankstotal 2
banksize $4000      ;1x 16kb PRG
banks 1
banksize $2000      ;1x 8kb CHR
banks 1

The only REAL annoyance I've had with WLA is to make commodre 64 programms : It just assmes the output is ROM and not just a file on a disk, so you have to make it a fixed size and it wasn't practical.