It is currently Sat Nov 18, 2017 10:57 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 37 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Wed May 27, 2015 11:26 pm 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 368
Location: ...
So recently I got bored with the good ol' Sega 8 bit systems, and decided to try out the NES.

When first walking in, there was an unfortunately debatable topic: which assembler to use.

So I not only created a hello world for one assembler, I made one for them all. By 'all' I mean asm6, ca65, nesasm and wla-dx.

The download link is below. It gives you a little taste of each one (except for possibly ca65, because for all I know that thing could have every function in the world I could have used).

Got feedback on the code itself? I'd love it.

I'm not sure if this is even a good section for the subject, but here's my thoughts.

asm6
Easy to use. Simple and compatible. I've only ever seen two complaints with it, one of which was somewhat outlandish and the other one I'm not concerned with. Overall my favourite.

ca65
Nice and all, but a bit heavy for my tastes. What with the separate cfg file being required for all your projects (unless portability isn't a concern). And I couldn't figure out how to have ascii text, but eh, that's not really the main subject. Certainly a second fave.

wla-dx
My god, it's so underrated. The documentation may not be so great, but once you figure it out it can do plenty. Its main downside is its inability to decide on whether to put in addresses as 8 or 16 bit (you have to specify with .b or .w). I could have some bias since this is the assembler of choice in the z80 community, so.

nesasm
Eh. Not into it. Directives need to be indented, making me wonder why do they even start with a period (which I would think lets the assembler detect if it's a directive). No anonymous labels. Somewhat picky syntax. I'd say the pre-generated headers aren't worth having to live with the rest of the BS.

Anyway, what are your thoughts on these? Tell meh.


Attachments:
asm tests 0.4.zip [10.89 KiB]
Downloaded 185 times
asm tests 0.3.zip [10.33 KiB]
Downloaded 156 times
asm tests 0.2.zip [10.05 KiB]
Downloaded 130 times


Last edited by nicklausw on Fri Jul 10, 2015 1:51 pm, edited 6 times in total.
Top
 Profile  
 
PostPosted: Thu May 28, 2015 7:17 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
In CA65 you can put string literals in a .byte directive. You can also interleave number literals with it.
Code:
.byte "MY NAME IS",0
.byte "A",13,"B",$42


If you want to get more advanced, it has directives to remap characters too, so that the encoding for string literals can map to something other than ASCII.


Top
 Profile  
 
PostPosted: Thu May 28, 2015 7:21 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
Also, you should wait for two vblanks to pass before writing to the PPU registers. Move that second jsr vblank_cycle before your stx $2000. (Won't cause a problem on emulators, or with powerpak, but if you built a cartidge for it you might see problems if you're using the PPU before it's warmed up.)

Secondly, you enable sprite rendering but you've never initialized the OAM data for displaying sprites. You're likely to see weird random sprites on the screen if you try it on real hardware. Emulators will probably just show a pile of sprite tile $00 in the top left corner.


Top
 Profile  
 
PostPosted: Thu May 28, 2015 9:14 am 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3108
Location: Nacogdoches, Texas
I don't know about asm6, but I wholeheartedly recommend ca65 over wla-dx (I think you all know my opinion on that one...) and nesasm. I remember when I first wanted to do SNES programming, I found that I had a hard time finding anything, and I kept hearing about something called "nerdy nights" which was basically a tutorial for NES programming. I figured that maybe some of the knowledge that I'd acquire there would help me on the SNES, (luckily, it did a bit) and I remember them using nesasm as the assembler. I remember hating every second of it. It was only until I found bazz's tutorials on superfamicom.org and this website that I had any clue as to what I was doing. (I really don't think nerdy nights was the best tutorial either.)


Top
 Profile  
 
PostPosted: Thu May 28, 2015 9:25 am 
Offline
User avatar

Joined: Sun Sep 21, 2014 10:18 pm
Posts: 32
I use wla-dx for master system programming so it made sense to also use it for nes.


Top
 Profile  
 
PostPosted: Thu May 28, 2015 9:34 am 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3108
Location: Nacogdoches, Texas
I just had a big fiasco where it decided to use 8 bit addressing instead of 16 bit and it screwed me over, so I vowed never to use it again. I thought I was going crazy because I kept looking over the code I made and the SNES kept crashing, but it wasn't actually my fault.


Top
 Profile  
 
PostPosted: Thu May 28, 2015 9:52 am 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 368
Location: ...
Espozo wrote:
I just had a big fiasco where it decided to use 8 bit addressing instead of 16 bit and it screwed me over, so I vowed never to use it again. I thought I was going crazy because I kept looking over the code I made and the SNES kept crashing, but it wasn't actually my fault.

Like I said, that can be fixed by adding a ".w" but it looks ugly and shouldn't be necessary.

Prime wrote:
I use wla-dx for master system programming so it made sense to also use it for nes.

Yup, that's my exact situation. It just doesn't seem as good for the 6502.

rainwarrior, thanks for the suggestions. Fix'd it up. What are the directives to remap characters though?

EDIT: Added new version to this post on accident.


Top
 Profile  
 
PostPosted: Thu May 28, 2015 9:57 am 
Offline
User avatar

Joined: Mon Sep 15, 2014 4:35 pm
Posts: 3108
Location: Nacogdoches, Texas
nicklausw wrote:
Like I said, that can be fixed by adding a ".w" but it looks ugly and shouldn't be necessary.

Nobody told me that... Anyway, the only reason you have to do that is that it's too stupid to realize if you want 8 bit or 16 bit addressing. It's not like any of the other assemblers have that problem.


Top
 Profile  
 
PostPosted: Thu May 28, 2015 9:59 am 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 368
Location: ...
Espozo wrote:
nicklausw wrote:
Like I said, that can be fixed by adding a ".w" but it looks ugly and shouldn't be necessary.

Nobody told me that...

Wait, seriously? People around here don't seem to have ANY idea how to use WLA. Perhaps it needs some better examples?


Top
 Profile  
 
PostPosted: Thu May 28, 2015 10:21 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
nicklausw wrote:
What are the directives to remap characters though?


The relevant control command is .charmap

You can find all this stuff in the documentation: http://www.cc65.org/doc/ca65.html

(You might look at the entry for .byte to see an example for using strings, too.)


Top
 Profile  
 
PostPosted: Thu May 28, 2015 10:33 am 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 368
Location: ...
rainwarrior wrote:
nicklausw wrote:
What are the directives to remap characters though?


The relevant control command is .charmap

You can find all this stuff in the documentation: http://www.cc65.org/doc/ca65.html

(You might look at the entry for .byte to see an example for using strings, too.)

I tried to set A-Z to their specific characters, and found that the only good way to do so is through a loop. Is this really the best way?

Code:
charmap1 .set $41
charmap2 .set $b
.repeat 26
.charmap charmap1,charmap2
charmap1 .set charmap1+1
charmap2 .set charmap2+1
.endrep
.charmap $20,$00 ; space


Top
 Profile  
 
PostPosted: Thu May 28, 2015 10:37 am 
Offline
User avatar

Joined: Sun Jan 02, 2011 11:50 am
Posts: 522
More up-to-date documentation is here: http://cc65.github.io/doc/ca65.html
Most recent win32 binary (If you don't want to build your own): http://sourceforge.net/projects/cc65/

For charsets, maybe take a look at this post by thefox: viewtopic.php?p=129836#p129836


Top
 Profile  
 
PostPosted: Thu May 28, 2015 10:51 am 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 368
Location: ...
Thanks Movax, I was able to set that up accordingly. The multi-line thing didn't work though...

Anyway 0.3 is up (updates so fast I'm like Ville Helin XD). Fixed the NESASM example (forgot to remove the part enabling sprites,) added the charmap to the ca65 example and changed how the print screen function works. At first I had the idea that this lets you print to infinity, but that's not the case.

So far nesasm is the only assembler that I couldn't set up strings with. Any ideas?


Top
 Profile  
 
PostPosted: Thu May 28, 2015 12:35 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
Just one more thing about the startup code. I think what you've got probably works, but for good practice you should add one extra read of $2002 before your 2 vblank loops, or alternatively just do 3 vblank loops.

The reasons are outlined here: http://forums.nesdev.com/viewtopic.php?f=2&t=3958

I'd forgotten about this because it's been a long time since I wrote new startup code, but basically a lot of commercial NES games don't do this, and the popular Nerdy Nights tutorial doesn't either, but if you start writing to the PPU too soon after that second vblank loop, it can fail.

Because you initialize RAM and stuff afterwards, the cycles spent doing that should actually cover the problematic window of time, but I'm just letting you know it's a probably a good idea to clear $2002 anyway. (Example: http://wiki.nesdev.com/w/index.php/Init_code)


Top
 Profile  
 
PostPosted: Thu May 28, 2015 12:50 pm 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 368
Location: ...
rainwarrior wrote:
Just one more thing about the startup code. I think what you've got probably works, but for good practice you should add one extra read of $2002 before your 2 vblank loops, or alternatively just do 3 vblank loops.

The reasons are outlined here: http://forums.nesdev.com/viewtopic.php?f=2&t=3958

I'd forgotten about this because it's been a long time since I wrote new startup code, but basically a lot of commercial NES games don't do this, and the popular Nerdy Nights tutorial doesn't either, but if you start writing to the PPU too soon after that second vblank loop, it can fail.

Because you initialize RAM and stuff afterwards, the cycles spent doing that should actually cover the problematic window of time, but I'm just letting you know it's a probably a good idea to clear $2002 anyway. (Example: http://wiki.nesdev.com/w/index.php/Init_code)

Alright, made that one last change. Didn't increment the version because it's...not really all that necessary.

Espozo: I opened an issue on GitHub about how you have to use .w for all 16-bit addresses, and apparently Ville is looking into it. How long has this problem been around, anyway...?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 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