NESASM - How to keep header in ROM

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
kuja killer
Posts: 130
Joined: Mon May 25, 2009 2:20 pm

NESASM - How to keep header in ROM

Post by kuja killer »

Hello, im having a pretty annoying problem with how to include the NES header on my Megaman 3 romhack "megaman odyssey" without adding it at all from the NESASM assembler using that "-raw" command.

For now i just have the NESASM add a header for me like normal since things are fine but, it does not support editing the 8th byte of the header, the SaveRAM size. which must be an 04 in my game, cause i use 32 KB SRAM, with MMC5 mapper. but the assembler always sets it to 0.

The problem is, if i do the -raw command, then the rom is always missing the header. i've tried everything i could think of to manually add it in myself like ".bank 0 .org $0000 [header stuff here] [rom stuff here]" but it never gets added. :( and the rom size will repeatedly get 16 bytes cut off or shorter every single time i assemble rom unless i take off that dumb -raw command.

This is all solely "just" because i need byte 8 with 04...because the NESASM doesnt allow editing that byte. Im not sure what other information i need to provide, but i'll try if asked
User avatar
never-obsolete
Posts: 411
Joined: Wed Sep 07, 2005 9:55 am
Location: Phoenix, AZ
Contact:

Re: NESASM - How to keep header in ROM

Post by never-obsolete »

Could you have your header in file1, output the headerless rom to file2, and then merge them into file3? All of this in a batch file with your actual file names, something like this:

Code: Select all

copy /b file1 + file2 file3
. That's just like, your opinion, man .
kuja killer
Posts: 130
Joined: Mon May 25, 2009 2:20 pm

Re: NESASM - How to keep header in ROM

Post by kuja killer »

oh wow, so just a 16 byte file with the header alone ? wow i never even thought of that. i'll show what my compile thing looks like just in case ? i use a little program called "dd" which acts a failsafe so the NESASM can never delete the rom whenever there's any "compile errors" of any kind. Since assemblers to like to delete the roms ..i stopped that from happening heh

this is how my things look currently at the momment

Code: Select all

dd if="MMC5 EXAtt MegaMan3.nes" of="testrom.nes" bs=16 skip=1
nesasm_x86 ody_kai.asm -autozp
rename "ody_kai.nes" "MMC5 EXAtt MegaMan3.nes"
move "MMC5 EXAtt MegaMan3.nes" "C:\My Documents\Backup clean rom\"
del "C:\My Documents\Backup clean rom\testrom.nes"
and this is the actual main NESASM file... whatever stuff

Code: Select all

;ody_kai.asm
;nesasm3 script
	.db "NES", $1A ;nes header
	.inesprg $20   ;code
	.ineschr $40   ;graphics
	.inesmir 2     ;mirroring
	.inesmap 5     ;MMC5 mapper
;WARNING! byte 8 in header MUST be 4, it's not working!!
	.db $4         ;max SRAM size

	.bank 0
	.org $0000

	.incbin "C:\My Documents\Backup clean rom\testrom.nes"
	.include "src\main.asm"
Pokun
Posts: 2675
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: NESASM - How to keep header in ROM

Post by Pokun »

There are forks of NESASM that supports NES 2.0 header directives I think. This one seems to do that, haven't tried it though.
kuja killer
Posts: 130
Joined: Mon May 25, 2009 2:20 pm

Re: NESASM - How to keep header in ROM

Post by kuja killer »

i umm, dont use anything about nes 2.0 though. the 32 KB saveRAM is the "only" thing i used, that i mentioned, because the MMC5 mapper supports it natrually.

and i kinda need to use this specific nesasm 2.51 autozp from a japanese site i got it off of, cause i have hundreds of labels names or addresses or whatever that "dont" use the little > thing next to them, cause of the autozp feature i wanted.

and no other "fork" i ever seen through countless hours and days of google searches ever had the autozp :(

http://www.2a03.jp/~minachun/nesasm/nesasm_x86.html
that's the one i use. So i cant really switch to anything else personally.

anyway back to the original point... i just have like a 16 byte .nes file with the header... and umm ... i guess put it "before" the "nesasm_x86 ody_kai.asm -raw -autozp"
line ?? or after ?
Pokun
Posts: 2675
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: NESASM - How to keep header in ROM

Post by Pokun »

I see, byte 8 of the iNES header isn't supported by NESASM, nor does emulators honor it in general (because ROMs tend to not set it correctly according to the wiki). This is why I don't like NESASM and its required bank directives (if it weren't for the banks you could probably implement the header manually without using those useless header directives).
If I were you I'd switch to an assembler that wasn't so limiting on things like this (like ASM6) and implement a NES 2.0 header ("Byte 10 of the NES 2.0 header should be reliable"). But I guess you are too far into the project to just switch assembler like that.
anyway back to the original point... i just have like a 16 byte .nes file with the header... and umm ... i guess put it "before" the "nesasm_x86 ody_kai.asm -raw -autozp"
line ?? or after ?
It should be after that line. You would need to merge the header file with the NES file, and you can't do that until the NES file has been assembled/exists.
kuja killer
Posts: 130
Joined: Mon May 25, 2009 2:20 pm

Re: NESASM - How to keep header in ROM

Post by kuja killer »

awesome i did it. :) thank you.
I'll show a pastebin of what the batch file looks like now.

https://pastebin.com/GWXby7AS

I know it probably looks way too long and overly complex, but this just ensures that the NESASM will never delete the rom on compile errors since assemblers like doing that. -- the mmc5 exatt megaman3.nes (for reloading in FCEUX emu)

And whenever an error does happen like this for example, then it wont ever modify the rom or delete it. (the NES header is now always showing 04 on byte 8, perfect :)

-------------------------------
NES Assembler (v2.51+autozp beta3)

#[4] src/Level Events/Rapid Events.asm
7 20:9993 ldz cur_screen
Unknown instruction!
# 1 error(s)
The system cannot find the file specified.
The system cannot find the file specified.
Could Not Find ody_kai.nes
-------------------
alright, so thank you :)
Post Reply