Minimal NES example using ca65

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
rainwarrior
Posts: 7838
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Minimal NES example using ca65

Post by rainwarrior » Sun Apr 06, 2014 9:06 pm

I thought this might be helpful for people trying to learn NES programming. This is a very minimal program written for the ca65 assembler.

The hope was to provide a starting example for learning to use the NES, something that accepts and responds to input, and demonstrates a straightforward PPU technique. It does not attempt do demonstrate the sound APU at all. Additionally, it is an example of how to set up and build a simple ca65 program.

This is now maintained at GitHub: https://github.com/bbbradsmith/NES-ca65-example


The original version is still attached to this post below.

There is also an FDS version available at the GitHub repository above, but it was originally available on the forum: post in thread requesting FDS example
Attachments
example1.zip
Minimal NES example using ca65
(9.43 KiB) Downloaded 845 times
Last edited by rainwarrior on Thu Feb 07, 2019 7:15 pm, edited 17 times in total.

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Minimal NES example using ca65

Post by thefox » Mon Apr 07, 2014 3:56 am

I'm not the one to toot my own horn, but with a tiny change in the linker switches you could add source level debugging support for NintendulatorDX and NESICIDE:

Code: Select all

cc65\bin\ld65 -o example.nes -C example.cfg example.o -m example.map.txt -Ln example.labels.txt --dbgfile example.nes.dbg
I also moved the "-o" switch before "-C" in there, because the latest version of ld65 explicitly requires the switches in that order (unfortunately).
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: Minimal NES example using ca65

Post by cpow » Mon Apr 07, 2014 4:23 am

thefox wrote:I'm not the one to toot my own horn...NESICIDE:
Thanks for tooting mine. :lol:
When did ld65's parameter ordering requirements change?

User avatar
rainwarrior
Posts: 7838
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Minimal NES example using ca65

Post by rainwarrior » Mon Apr 07, 2014 5:58 am

Okay, I made the suggested change.

As far as parameter order for ld65, I think the strict requirement has been removed, as I had tested this against the latest cc65 snapshot with no problems.

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Minimal NES example using ca65

Post by thefox » Mon Apr 07, 2014 6:17 am

rainwarrior wrote:As far as parameter order for ld65, I think the strict requirement has been removed, as I had tested this against the latest cc65 snapshot with no problems.
Did you get the warning? Or when was this change made? I have a fairly recent version from some weeks back (ld65 V2.14 - Git eaf4c8c), and it gave the warning and output the ROM in a.out, ignored the -o that came after -C.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

User avatar
rainwarrior
Posts: 7838
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Minimal NES example using ca65

Post by rainwarrior » Mon Apr 07, 2014 6:26 am

No warning. The files in the snapshot are stamped 4/04/2014. (It shouldn't be a warning or an error anyway, there was no good reason to have added such an arbitrary rule to the command line in the first place.)

User avatar
thefox
Posts: 3141
Joined: Mon Jan 03, 2005 10:36 am
Location: Tampere, Finland
Contact:

Re: Minimal NES example using ca65

Post by thefox » Mon Apr 07, 2014 6:41 am

rainwarrior wrote:No warning. The files in the snapshot are stamped 4/04/2014. (It shouldn't be a warning or an error anyway, there was no good reason to have added such an arbitrary rule to the command line in the first place.)
Yeah I completely agree about the arbitrariness (that's why the "unfortunately" in my original post). It seems like this got fixed about a week ago. Works with the latest snapshot.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi

User avatar
Jarhmander
Formerly ~J-@D!~
Posts: 508
Joined: Sun Mar 12, 2006 12:36 am
Location: Rive nord de Montréal

Re: Minimal NES example using ca65

Post by Jarhmander » Mon Apr 07, 2014 7:30 am

Great example. I do believe however that the best would be to supply a NESICIDE project (either along or instead of compile_example) with your example because for a starter, using this IDE is much easier than using a shell "script", in the sense that NESICIDE will do a much better compile-time error reporting and simpler/faster testing of the resulting program, with the free added benefit that the example will be portable and much more scalable (NESICIDE can add files to a project with a few clicks, no script to modify). The downside is that it's possible that the package needs updating as NESICIDE evolves, but I don't think there will be much problems because a .nesproject is a xml file, so except if NESICIDE maintainer(s) change(s) the name of basic properties I don't see why it wouldn't work in the future.

Very minor fix btw: typo on line 9 (example.txt), "A Python 3 program to build debugging symbols for FCUEX is included."
((λ (x) (x x)) (λ (x) (x x)))

User avatar
rainwarrior
Posts: 7838
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Minimal NES example using ca65

Post by rainwarrior » Mon Apr 07, 2014 7:38 am

If you want to create an NESICIDE version of this please go right ahead. I don't use it, so I'm not interested or qualified to do so.

If it's minimal enough I'll add it to the attached zip.

User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: Minimal NES example using ca65

Post by cpow » Fri May 02, 2014 7:05 am

rainwarrior wrote:If it's minimal enough I'll add it to the attached zip.
Compiles, runs. Had to RAR it though since .nesproject file extension is not allowed...
Attachments
example.rar
(1.29 KiB) Downloaded 846 times

tepples
Posts: 22052
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Minimal NES example using ca65

Post by tepples » Fri May 02, 2014 7:05 am

Why use WinRAR ($$$) instead of 7-Zip?

User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: Minimal NES example using ca65

Post by cpow » Fri May 02, 2014 7:26 am

tepples wrote:Why use WinRAR ($$$) instead of 7-Zip?
I dunno. Just what I have. Yeah it keeps asking me to buy it. But I don't. Actually I also have 7-zip but it's not in my context menu so I never use it.

User avatar
rainwarrior
Posts: 7838
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Minimal NES example using ca65

Post by rainwarrior » Fri May 02, 2014 8:18 am

WinRAR is still my preferred windows archiver after all these years. I still like its interface better than 7-Zip.

If 7-Zip is your preference, it will unpack RARs just fine, but I'm sure you know that already.

User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Re: Minimal NES example using ca65

Post by cpow » Fri May 02, 2014 8:44 am

rainwarrior wrote:If 7-Zip is your preference, it will unpack RARs just fine, but I'm sure you know that already.
I lack the energy for a preference here. If you can use the file I attached, great. If not...maybe we could adjust the forum rules to allow .nesproject extensions? Not that I want to blast the forum with a bunch of NESICIDE project files...and maybe it would be best for me to set up my own forum [which tepples has offered to help with several times]. But I'm just too busy for such things.

User avatar
rainwarrior
Posts: 7838
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Minimal NES example using ca65

Post by rainwarrior » Fri May 02, 2014 11:37 am

So, we can attach .nesproject files now, but then I realized I should probably just add it to the zip. :P

Post Reply