asm6 + ines = asm6n

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

User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

asm6 + ines = asm6n

Post by nicklausw »

This has probably been done before (as I say with every project I do), but I added INES directives to asm6.

https://github.com/nicklausw/asm6n

The 'n' can be for nicklausw, nintendo, nes, whatever. I dunno.

Anyway, here's an NROM example:

Code: Select all

.inesprg 1 ; 1x 16KB bank of PRG code
.ineschr 1 ; 1x 8KB bank of CHR data
.inesmap 0 ; mapper 0 = NROM, no bank swapping
.inesmir 1 ; background mirroring (ignore for now)
.inesins ; put ines header in the file!
Yes, there has to be an insertion directive, because asm6 doesn't make NES support mandatory, and I'd rather keep it that way for now.

Also ANSI compatibility. Not sure why. Just wanted it.

This should work from what I've tested, tell me otherwise.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: asm6 + ines = asm6n

Post by tepples »

It inspired me to make a set of macros for ca65 to build an NES 2.0 header.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: asm6 + ines = asm6n

Post by dougeff »

Is there any emulator that makes use of the 2.0 standard?

Nevermind, I see it on the wiki...

BizHawk as of r6313
FCEUX as of r3071
Nintendulator 0.975 Beta
MESS (per BBS post 62428)
no$nes v1.1
PowerMappers v23 for PowerPak
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + ines = asm6n

Post by nicklausw »

Glad to see I inspired some macro packs. Actually I forgot to add support for the upper nibble of the mapper number, so that's there now.

How is it suggested that iNES 2.0 be implemented in an assembler? I think Unofficial Magickit might handle this, so I'll take a look.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: asm6 + ines = asm6n

Post by koitsu »

This is super cool -- thanks for it! Is there any reason this didn't get added to official asm6? loopy lingers and is contactable in many ways...
User avatar
Gilbert
Posts: 564
Joined: Sun Dec 12, 2010 10:27 pm
Location: Hong Kong
Contact:

Re: asm6 + ines = asm6n

Post by Gilbert »

I think that's because asm6 wasn't specifically aimed towards the Famicom. I used it more on Apple ][ projects.
That doesn't mean it's not cool to have such extra features though.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: asm6 + ines = asm6n

Post by koitsu »

No, asm6 was invented solely for NES/Famicom work, but obviously it's a generic enough assembler that you can use it for anything 6502-based. Quoting the original README:

Code: Select all

--------------------------------------------------------------
ASM6 (v1.6)
A 6502 assembler by loopy (loopy at mm.st)
--------------------------------------------------------------

Yes, it's another 6502 assembler.  I built it to do NES development, but you
can probably use it for just about anything. ...
Anyway, I'll point out that we now have at *least* 2 forks of asm6, which is why I keep asking the question why these features + patches aren't being sent in to loopy to incorporate into asm6 officially:

https://github.com/nicklausw/asm6n
https://github.com/freem/asm6f
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: asm6 + ines = asm6n

Post by thefox »

Frankly, if I was loopy, I wouldn't accept this patch. There's really no need for such directives when the assembler is flexible enough to generate the header with existing directives like .byte. Wrap it in a macro (like tepples did), and you get the same level of usability as well.

It's not too surprising that NESASM had to add those directives, because of the 8 KB bank size requirement.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + ines = asm6n

Post by nicklausw »

thefox wrote:There's really no need for such directives when the assembler is flexible enough to generate the header with existing directives like .byte. Wrap it in a macro (like tepples did), and you get the same level of usability as well.
While people clinging for dear life onto NESASM isn't a major problem as far as I can tell, asm6n does help with "NESASM doesn't NEED macros for that!"

Later on today I'll see about making a command line arg to have asm6n always put a blank header at the beginning for it to fill out later, meaning you don't need .inesins.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: asm6 + ines = asm6n

Post by thefox »

nicklausw wrote:While people clinging for dear life onto NESASM isn't a major problem as far as I can tell, asm6n does help with "NESASM doesn't NEED macros for that!"
Just to be clear, I wasn't criticizing your work. I just think it's for the better if the mainline asm6 stays platform agnostic.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + ines = asm6n

Post by nicklausw »

Yeah, I think asm6 should be clear of an intended platform.

At the same time, I'm interested in merging my changes with freem's; why choose between header directives and illegal opcodes with .nl support when you can have it all?
User avatar
freem
Posts: 176
Joined: Mon Oct 01, 2012 3:47 pm
Location: freemland (NTSC-U)
Contact:

Re: asm6 + ines = asm6n

Post by freem »

koitsu wrote:Anyway, I'll point out that we now have at *least* 2 forks of asm6, which is why I keep asking the question why these features + patches aren't being sent in to loopy to incorporate into asm6 officially:

https://github.com/nicklausw/asm6n
https://github.com/freem/asm6f
It should be noted that my fork is a "continuation" of sonder's fork (or more accurately, I stole his code for fceux *.nl generation).
nicklausw wrote:At the same time, I'm interested in merging my changes with freem's; why choose between header directives and illegal opcodes with .nl support when you can have it all?
Even though I'm against the idea of the directives (for reasons mentioned in the thread), I don't see any harm in actually merging them, since you're not forced to use them; feel free to send a pull request to the asm6f repo and I'll look things over. (Personally though, I would hope support for NES 2.0 header fields would get added.)
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + ines = asm6n

Post by nicklausw »

The -i command line option now makes use of INESINS not needed! (Still there, though, of course).

So if you want to, you can just do:

Code: Select all

.inesprg 1 ; 1x 16KB bank of PRG code
.ineschr 1 ; 1x 8KB bank of CHR data
.inesmap 0 ; mapper 0 = NROM, no bank swapping
.inesmir 1 ; background mirroring (ignore for now)
And assuming that's bla.asm, assemble with:

Code: Select all

asm6n -i bla.asm bla.nes
And the header goes in. If you don't like the terminal args, then use the insertion directive, it's up to you.

(On a separate note, the code used to implement this is redundant and kind of hideous, but eh).
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: asm6 + ines = asm6n

Post by koitsu »

nicklausw, is there a particular need for this -i flag (or the equivalent .inesins pseudo-op)? It seems to me that inclusion of the 16-byte NES header would be based on any use of .ines{prg,chr,map,mir} directives. Rephrased: use of any of those should enable adding the header to the resulting binary. There should be defaults for each of the respective pseudo-ops as well (the default values should be documented), so that you could literally have a program that just says .inesprg 1 (with no other .inesXXX directives) and gets you a .NES ROM. There is no way to solve every "error condition/usage case", but to me the above is intuitive and how some other assemblers do it.

Just my two cents.
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: asm6 + ines = asm6n

Post by nicklausw »

If the code only needs one pass, then the way asm6 works, either you'd have to do another pass for no reason to add the header bytes at the start of the file, or find a way to add bytes to the beginning of an existing file. Not possible, as far as I know (easily anyway).
Post Reply