A problem with NESASM

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
Ignis
Posts: 4
Joined: Wed Apr 04, 2018 9:26 pm

A problem with NESASM

Post by Ignis »

Hello! I have a little problem with nesasm. When I try to run a .nes rom compiled without -raw nesasm option, it works perfectly, but when I don´t use that option I get an error. Is -raw option really necessary during compilation? I understand its purpose but anything works when is used.
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: A problem with NESASM

Post by koitsu »

This sentence is hard to understand: "When I try to run a .nes rom compiled without -raw nesasm option, it works perfectly, but when I don´t use that option I get an error." So... it works perfectly without -raw, but when you don't use -raw, it fails. How would it work perfectly then? :/

So let's just stick with the documentation. Assuming this is NESASM 3.0 or 3.1 (and not 2.x) -- because you didn't specify: the documentation is clear about what the -raw flag does:

Code: Select all

         -raw   Control the header generation. By default the assembler
                always adds an header to the ROM file; unless '-raw' is
                specified, in this case no ROM header is generated.
"Header" in this case refers to the necessary 16-byte NES header (i.e. .nes file extension). This is necessary when used with emulators, for loading via the PowerPak, and so on.

If your code is generating the 16-byte header itself, then you need to use -raw (otherwise you will end up with two 16-byte headers and your code/game will probably crash upon load).

If your code is not generating the 16-byte header itself, then you should not use -raw (otherwise you will end up with a raw binary file that lacks the header; this would be used if you were to, say, be flashing your assembled code onto an EPROM/EEPROM).
Ignis
Posts: 4
Joined: Wed Apr 04, 2018 9:26 pm

Re: A problem with NESASM

Post by Ignis »

Sorry for my horrible English, haha, I only speak Spanish. I'll better use Google translator. I understand what you say about -raw because I read the documentation. The problem I have is that a .nes file generated from a source code as simple as the following one, for example, gives me an error when I try to execute it in any emulator if during the compilation phase I use the -raw option:

.inesprg 1
.ineschr 0
.inesmir 1
.inesmap 0

.org $8000
.bank 0

Start:
jmp Start

.bank 1
.org $FFFA
.dw 0 ;(NMI_Routine)
.dw Start ;(Reset_Routine)
.dw 0 ;(IRQ_Routine)

However, if I do not use the -raw option everything works perfectly, which I find strange
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: A problem with NESASM

Post by tokumaru »

What you describe is the expected behavior. The -raw option omits the iNES header, so emulators don't recognize the resulting file as an NES ROM. You absolutely need the header for playing the game on emulators. Why do you think you need to use the -raw option in the first place?

Here are a few examples of cases when omitting the header would make sense:

- You're making a game for a system other than the NES (e.g. the Atari 2600);
- You're supplying your own header some other way instead of using NESASM's directives (.inesprg, .ineschr, etc.);
- You're generating a binary file to burn to an EPROM that you'll put in an actual cartridge;
Ignis
Posts: 4
Joined: Wed Apr 04, 2018 9:26 pm

Re: A problem with NESASM

Post by Ignis »

Ahhh, I understood! How silly I am! I thought that the -raw option automatically inserts a header into the source code before compiling. Maybe I should rest a bit, haha. Thanks for answering!
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: A problem with NESASM

Post by tokumaru »

Ignis wrote:I thought that the -raw option automatically inserts a header into the source code before compiling.
The assembler never modifies the source code files, but it does include the header in the output file by default. In the rare cases when you DON'T want the header, then you use the -raw option.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: A problem with NESASM

Post by tepples »

Some other cases where you might want to -raw:
  1. You're separately assembling one self-contained module with its own predefined entry point, such as a music bank or a game on a multicart, and then including that binary into your program
  2. You're building an NSF file instead of an NES ROM; those have a different 128-byte header, and you can get reasonable behavior by specifying $8080 as the load address
lidnariq
Posts: 10677
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: A problem with NESASM

Post by lidnariq »

Ignis wrote:Sorry for my horrible English, haha, I only speak Spanish. I'll better use Google translator.
P.S., and off-topic, but I've heard fantastic things about https://www.deepl.com/Translator
Ignis
Posts: 4
Joined: Wed Apr 04, 2018 9:26 pm

Re: A problem with NESASM

Post by Ignis »

Thank you guys! I really appreciate your attention. This motivates me a lot! (I like the Deepl translator:)
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: A problem with NESASM

Post by koitsu »

English:

Code: Select all

         -raw   Control the header generation. By default the assembler
                always adds an header to the ROM file; unless '-raw' is
                specified, in this case no ROM header is generated.
Spanish (not from Google Translate):

Code: Select all

         -raw   El programa genera archivos con header por default;
                si usas este parametro, creara un archivo sin header.
Post Reply