There seems to be a lot of contempt towards NESASM...so which assembler would the people on this board recommend?
I've grown to love ACME. Sure it's non-standard pseudo opcode format (!byte, !text, etc...) means a slight learning curve, but it does have alot of useful crap!
It appears that most people are using the "CA65" toolchain, a nickname for
CC65 minus the C compiler. Compared to some other assemblers such as x816, CA65 needs a couple extra files (such as a "link script" for a given mapper) because it follows the more flexible model of separate assembly and linking just like native compilers, but I can get you started with those.
CA65 (part of the CC65 package) is a 6502 assembler -- not a C compiler.
A close alternative to NESASM I have found, is ASM6 by loopy. Almost the same syntax as NESASM and so far no problems with my limited testing.
Atomik wrote:
A close alternative to NESASM I have found, is ASM6 by loopy. Almost the same syntax as NESASM and so far no problems with
my limited testing.
ASM6 is the way to go, It is a faster replacement for both NESASM and
x816. In fact, It has the same syntax as x816, Instead of the DB and DW
there is BYTE and WORD. Also, sometimes ASM6 source code works on CA65!
-Hamtaro126
Hmm cc65 looks nice, but it might be good to use ASM6 too since so many tutorials seem to use the NESASM syntax. Thanks guys!
ehhh....could anyone point me to where I can download ASM6?
mcfiredrill wrote:
ehhh....could anyone point me to where I can download ASM6?
Try this
http://home.comcast.net/~olimar/NES/asm6.zip
Where's the source code to asm6?
Atomik wrote:
This looks nice. I'll give it a try.
That's it, I'm switching to asm6. It's simple, compact, easy to use, and has everything you need to assemble a full .nes ROM (with a header, multiple program banks, and all that) in a single step.
Actually, the only thing I miss are local labels, but I guess the temporary labels will make up for them.
Well, I just happened to test the main features, and it has some nice directives that make it easy to output a complete ROM file (ready to be used in emulators) by assembling a single .asm file.
For example, it has the .enum/.ende directive, that works somewhat like .org, but whatever is inside the .enum block is not assembled. That means you can use it to define the labels of variables in RAM, reserving bytes or words with .dsb and .dsw. This turns out to be a very clean way to define variables.
Another very useful directive is .base, that allows you to define the base address for the code that follows. For example, if you are making an UNROM game, you'll want to define multiple banks of code that get mapped to $8000-$BFFF. In order to do that, you can just put ".base $8000" before the code for each of the banks, and put ".pad $C000" at the end of each one, and you get multiple 16KB banks. It's very simple.
To make the INES header, you can just ".org $7FF0" before the first $8000-$BFFF bank, and define all the bytes with .db. This means that by assembling a single file you get a complete .nes ROM. I'm not sure what other assemblers can do that, but the way I did before involved compiling each program bank individually and joining them all, plus the header, in the end. Of course it's not practical to have all your source in a single file, but it sure is useful to have one file with the whole structure of the ROM, and have this file include other files, which contain the code for the different banks, variable definitions, data, etc. But you can still assemble that one file and get the complete ROM.
Take a look at the readme that's included with the assembler. That's what convinced me. Of course I tested the features to see if they did exactly what I thought they did. I'm now in the process of converting my sources to compile with this assembler.
I really think Wla-Dx is a great thing to use. It takes a while to get used to (Or at least it did for me), but once you really know how to use it, it's SO much better than NESASM. I at first didn't understand why everyone hated NESASM so much, but as soon as I actually started making something that wasn't just displaying a sprite on screen, I noticed TONS of things that really sucked. I recall not being able to do nameless lables and things like that, but I also couldn't figure out its banking system. I couldn't really make a game that wasn't NROM. I found the little features that Wla-Dx offered to be quite handy.
Does anyone know how to output a .nes on the ASM6. It says that can only output a .bin file. very simlar to the x816.
Code:
Usage:
asm6 [-options] sourcefile[.asm|.s] [outputfile] [listfile]
Options:
-? Show some help
-l Create listing
-L Create verbose listing (expand REPT, MACRO)
-d<name>: Define a symbol and make it equal to 1
Default output is <sourcefile>.bin
Default listing is <sourcefile>.lst
A .bin file is all you need. Just slap on a header and the chr and give it an .nes extension. You can do that in a batch file. Put this in a text file and rename it to whatever.bat:
Code:
asm6 yoursourcefile.asm output.bin
copy /B header.bin+output.bin+yourchr.chr yourrom.nes
pause
(you can remove that pause if you want -- but i usually leave it so I can see any assembler errors).
Of course you'll need to make header.bin and yourchr.chr by hand (chr can be made with a tile editor like YY-CHR or something -- header.bin is just the $10 byte header which you can throw together with a hex editor pretty easily)
do i define the .chr file in the .asm file like in NESASM
ie:
Code:
.bank 2 ; switch to bank 2
.org $0000 ; start at $0000
.incbin "demo.chr" ; empty background first
or do i just include it? thanks for the fast reply
no
the CHR will be appended to the end of the ROM by the batch file -- it should not run through the assembler.
do not include/incbin the CHR anywhere in your code.
its complies with no flaws it just dosent open in FCEUXD. i figure its my header. im putting all 00 in a 16 bit notepad edited in a hex editor. either that or its my .asm file.
Code:
it starts with:
.org $8000
::
::
::
::
ends with:
.pad $FFFA
.dw nmi,reset,reset
.end
yeah those docs do explain alot.
so if i use:
.db "NES",$1a
.db 2 ;prgsize
.db 1 ;chrsize
.db 0 ;mapper#, etc
.db 0,0,0,0,0,0,0,0,0 ;filler
then i dont have to combine the header with the output.bin? or do i just put this in a seperate file and then combine them.
In ASM6, I start like this:
Code:
.org $7ff0
.db "NES", $1a ;ID
.db $10 ;16 PRG-ROM pages
.db $00 ;No CHR-ROM present
.db $21 ;Mapper 2 with vertical mirroring
.dsb $09, $00 ;Clear the rest
Then follow all the ROM banks that get mapped to $8000. Each of them looks like this:
Code:
.base $8000
;WHATEVER GOES IN THE BANK
.org $c000
Then comes the last bank, the one that gets mapped to $c000:
Code:
.org $c000
;WHATEVER GOES IN THE BANK
.org $fffa
.dw NMI
.dw Reset
.dw IRQ
This is a CHR-RAM project, so I do not have any CHR banks, but i'm sure there would be no problems in including the binary data at the end.
I also have all my variables defined before the header, like this:
Code:
.enum $0000
Character ;Index of the character being used
.dsb 1
LevelIndex ;Index of the level being played
.dsb 1
(...)
.ende
When you assemble the code, you can even specify the name of the output file, which can have a .nes extension, resulting in a ROM ready to be used in emulators.
i can seem to output my demo normally. at first i couldnt even open it in FCEUXD when i tried to merge a header, output.bin and .chr file. so then i just pasted the header into the .asm file and it all compiled without any errors but i just get a grey screen. if figured it was the .incbin(ed) .pal file. but still nothing i used db statements. i wondering if maybe it has to do with the fact that used this demo on NESASM. what kind of things do i look out for when switching compilers?
heres the code that complied without errors but just show up grey:
Code:
.db "NES",$1a
.db 1 ;prgsize
.db 1 ;chrsize
.db 0 ;mapper#, etc
.db 0,0,0,0,0,0,0,0,0 ;filler
.org $8000
vbtrip = $01
SP_yp = $0300
SP_tn = $0301
SP_at = $0302
SP_xp = $0303
Start:
sei
cld
vb1: lda $2002
bne vb1
vb2: lda $2002
bne vb2
lda #$00
sta $2000
sta $2001
jsr ldpal
jsr ldnmt
lda #%10000000
sta $2000
lda #%00011110
sta $2001
loop
jmp loop
ldpal
ldx #$00
lda #$3F
sta $2006
lda #$00
sta $2006
loadpal:
lda tilepal, x
sta $2007
inx
cpx #32
bne loadpal
rts
ldnmt
lda #$20
sta $2006
lda #$20
sta $2006
ldx #$00
loadNames1:
lda ourMap, X
sta $2007
inx
bne loadNames1
loadNames2:
lda ourMap+$100, X
sta $2007
inx
bne loadNames2
loadNames3:
lda ourMap+$200, X
sta $2007
inx
bne loadNames3
loadNames4:
lda ourMap+$300, X
sta $2007
inx
cpx #$80
bne loadNames4
lda #$2c
sta $2006
lda #$20
sta $2006
ldx #$00
loadNames5:
lda ourMap2, X
sta $2007
inx
bne loadNames5
loadNames6:
lda ourMap2+$100, X
sta $2007
inx
bne loadNames6
loadNames7:
lda ourMap2+$200, X
sta $2007
inx
bne loadNames7
loadNames8:
lda ourMap2+$300, X
sta $2007
inx
cpx #$80
bne loadNames8
rts
lda #$80
sta vbtrip
nmi
pha
txa
pha
tya
pha
dec vbtrip
lda #$03
sta $0301
lda #$20
sta $0300
LDA $0303
ADC #$01
sta $0303
lda #$03
sta $4014
lda #$00
Sta $2005
Sta $2005
pla
tay
pla
tax
pla
RTI
irq:
rti
tilepal:
.incbin "basictst.nam"
ourMap:
.incbin "basictst.nam"
ourMap2:
.incbin "basictst2.nam"
.org $FFFA
.dw nmi
.dw Start
.dw irq
I had the grey screen for a while once...turns out I was just starting at the wrong address, lol! (PRG set to 1 on N-ROM at $7000 by mistake)
ok it worked. but its all messed up. does anyone know how to upload a file so can show you the difference.
If I can make a suggestion, I would actually stay away from that method of loading information onto the Name Table. It looks kind of like how the GBA Guy showed in his tutorials. And it doesn't look like you reset your scroll after your routine either. If you want a whole screen filled with different tile data, I'd suggest Tepple's name table editor. That way, you can have one file that's 1k, and you can load it directly on from $2000-$23FF (It comes with the attributes attached). But yeah, stick this on the end of the routine:
lda #$20
sta $2006
lda #$00
sta $2006
sta $2005
sta $2005
That's at least a step closer to solving the problem.
EDIT: Oh, and if you want to upload files, you should open a freewebs account. Just go to
www.freewebs.com and make an account. Select HTML mode, not the easy freewebs builder. You don't have to make anything of your website, but you can upload files onto your site, and allow us to download them. So if your user name was "Chicken", and your uploaded file was "Sample.NES", you'd tell us to go to
www.freewebs.com/chicken/sample.nes.
Still the same. Funny thing now FCE is acting funny. it keeps gliching. meaning a sprite would move- stop- move again.
well heres the demo.
http://www.freewebs.com/ninetendo/NESASM.rar
http://www.freewebs.com/ninetendo/asm6.rar
I haven't looked at the whole thing yet and found the problem but just for future reference, this is the common way to load a .nam file:
Code:
loadnam:
lda #<NameFile
sta $0
lda #>NameFile
sta $1
lda #$20
sta $2006
lda #$00
sta $2006
ldx #4
ldy #0
-
lda ($0),y
sta $2007
iny
bne -
inc $1
dex
bne -
If I find your problem, I will edit this post, but it will show up as a new post.
also whats with the "not enough memory" error in x816. looking at the ines format documents, could i use the same header i use with asm6 with x816. it looks to be a universal thing
nineTENdo wrote:
could i use the same header i use with asm6 with x816.
Of course. The assembler does not care about the header, the emulator does. And the emulator does not care about which assembler produced the ROM.
May I ask what the demo's supposed to look like?
EDIT: You shouldn't go up to #$80 in the last part. You should let to routine go until it reaches $2400, that way it'll also store the attributes. So just delete the CPX #$80 out of there.
Code:
loadNames4:
lda ourMap+$300, X
sta $2007
inx
bne loadNames4
The above code is proper. And I see you do this:
Code:
lda #$03
sta $0301
lda #$20
sta $0300
LDA $0303
ADC #$01
sta $0303
in the NMI routine. You only need to store those variables into $300/$301 one time, so just stick that outside of the NMI routine before the NMI init. Also, if you do an Add with Carry, you want to put a CLC before it. Unless you're doing 16-bit addition. But if you're only increasing it by one, I'd reccomend the INC instruction.
clearing out that last cpx #$80 did fill in the last row on NESASM. i tried it on asm6 but still nothing. what im thinking is maybe i need to clear all my registers on restart. i did it on NESASM. it worked but i actually had to slip in a
lda #$00
sta $0303
to get the the sprite moving right to reset on reset. for some reason it wont clear it out the sprite DMA with my code. i even used the ol Duck Hunt Rip with nothing. im probrably going to try another emulator on the asm6 rom
You can clear all registers in RAM very easily at the beggining of the reset routine:
Code:
ldx #0
txa
-
sta $0,x
sta $100,x
sta $200,x
sta $300,x
sta $400,x
sta $500,x
sta $600,x
sta $700,x
inx
bne -
I do that on reset. That's a very easy way to clear RAM. So your demo is working when compiled with NESASM?
Well, it looks like the code works, it's just your CHR file that's not successfully becoming a part of the ROM. Something's wrong with the way you're including the CHR file, I think. I don't know anything about asm6, so I can't be of much help solving the problem. But I'm pretty sure that's the problem.
i tried the .incbin loopy mentioned
and
the merging them together without .incbin.
asm6 tst.asm tst.bin
copy /B tst.bin +tst.chr tst.nes
pause
but yeah i figured it was something with .chr