A Few Hello World 'Tests'

A place where you can keep others updated about your NES-related projects through screenshots, videos or information in general.

Moderator: Moderators

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

A Few Hello World 'Tests'

Post by nicklausw »

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 320 times
asm tests 0.3.zip
(10.33 KiB) Downloaded 286 times
asm tests 0.2.zip
(10.05 KiB) Downloaded 257 times
Last edited by nicklausw on Fri Jul 10, 2015 1:51 pm, edited 6 times in total.
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: A Few Hello World 'Tests'

Post by rainwarrior »

In CA65 you can put string literals in a .byte directive. You can also interleave number literals with it.

Code: Select all

.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.
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: A Few Hello World 'Tests'

Post by rainwarrior »

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.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: A Few Hello World 'Tests'

Post by Drew Sebastino »

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.)
User avatar
Prime
Posts: 32
Joined: Sun Sep 21, 2014 10:18 pm

Re: A Few Hello World 'Tests'

Post by Prime »

I use wla-dx for master system programming so it made sense to also use it for nes.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: A Few Hello World 'Tests'

Post by Drew Sebastino »

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.
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: A Few Hello World 'Tests'

Post by nicklausw »

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.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: A Few Hello World 'Tests'

Post by Drew Sebastino »

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.
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: A Few Hello World 'Tests'

Post by nicklausw »

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?
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: A Few Hello World 'Tests'

Post by rainwarrior »

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.)
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: A Few Hello World 'Tests'

Post by nicklausw »

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: Select all

charmap1 .set $41
charmap2 .set $b
.repeat 26
.charmap charmap1,charmap2
charmap1 .set charmap1+1
charmap2 .set charmap2+1
.endrep
.charmap $20,$00 ; space
User avatar
Movax12
Posts: 529
Joined: Sun Jan 02, 2011 11:50 am

Re: A Few Hello World 'Tests'

Post by Movax12 »

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
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: A Few Hello World 'Tests'

Post by nicklausw »

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?
User avatar
rainwarrior
Posts: 8062
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: A Few Hello World 'Tests'

Post by rainwarrior »

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)
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: A Few Hello World 'Tests'

Post by nicklausw »

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...?
Post Reply