It is currently Fri Jul 20, 2018 7:23 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: A problem with NESASM
PostPosted: Wed Apr 04, 2018 9:41 pm 
Offline

Joined: Wed Apr 04, 2018 9:26 pm
Posts: 4
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.


Top
 Profile  
 
PostPosted: Wed Apr 04, 2018 10:01 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3435
Location: Mountain View, CA
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:
         -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).


Top
 Profile  
 
PostPosted: Wed Apr 04, 2018 10:51 pm 
Offline

Joined: Wed Apr 04, 2018 9:26 pm
Posts: 4
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


Top
 Profile  
 
PostPosted: Wed Apr 04, 2018 11:04 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10614
Location: Rio de Janeiro - Brazil
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;


Top
 Profile  
 
PostPosted: Wed Apr 04, 2018 11:19 pm 
Offline

Joined: Wed Apr 04, 2018 9:26 pm
Posts: 4
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!


Top
 Profile  
 
PostPosted: Wed Apr 04, 2018 11:23 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10614
Location: Rio de Janeiro - Brazil
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.


Top
 Profile  
 
PostPosted: Thu Apr 05, 2018 7:23 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20280
Location: NE Indiana, USA (NTSC)
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


Top
 Profile  
 
PostPosted: Thu Apr 05, 2018 8:38 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7318
Location: Seattle
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


Top
 Profile  
 
PostPosted: Thu Apr 05, 2018 9:26 am 
Offline

Joined: Wed Apr 04, 2018 9:26 pm
Posts: 4
Thank you guys! I really appreciate your attention. This motivates me a lot! (I like the Deepl translator:)


Top
 Profile  
 
PostPosted: Thu Apr 05, 2018 11:53 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3435
Location: Mountain View, CA
English:
Code:
         -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:
         -raw   El programa genera archivos con header por default;
                si usas este parametro, creara un archivo sin header.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group