Minimal NES Code

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
sburrow
Posts: 833
Joined: 09 Oct 2021
Location: Texas

Minimal NES Code

Post by sburrow »

Howdy everyone!

I was watching a few Youtube videos this morning because I was *super* bored for like an hour or so. Then I got inspired again! See attached. [ Everything is .txt format so that this site will allow them to be attached at all! It is actually: Program.asm, Character.hex, and GAME.NES ]

I'm trying to make some minimal NES game code, a "Hello World" in a way, but something a bit more useful than just displaying some text. This tiny demo shows background tiles and a moving sprite with the controller input. And that's it. And that's the point!

I'm thinking of creative ways to include all of this into a single file somehow. I'm thinking when I ".ORG $0000" in my code, that my Parser program would say "oh that's Character ROM instead", and when I ".ORG $7FF0" in my code, that my Parser program would say "oh that's Header instead".

What is the eventual goal? Well, I'd like to see about making an NES game :) I just programmed Tetris in 6502 assembly for my Neon6502 project. See here: viewtopic.php?f=4&t=8489 And though that was fun, it's not portable at all. This would be much more portable, and will run on my PIC32 projects. Plus, programming costs exactly zero dollars! Plus plus, I get to hang out in 6502-land a little bit longer :)

I'm using my PICnes emulator for testing purposes. See here: https://github.com/stevenchadburrow/PICnes So far so good!

Tomorrow morning I hope to make everything compact, easy to modify, and actually commented for once! Will keep you posted. Thank you everyone :)

Chad
Attachments
NesGameDev-Screenshot.png
NesGameDev-Screenshot.png (7.18 KiB) Viewed 801 times
GAME.txt
(40.02 KiB) Downloaded 36 times
NesGameDev-ProgramROM.txt
(3.33 KiB) Downloaded 32 times
NesGameDev-CharacterROM.txt
(24.53 KiB) Downloaded 31 times
sburrow
Posts: 833
Joined: 09 Oct 2021
Location: Texas

Re: Minimal NES Code

Post by sburrow »

Alright, I changed things a bit.

1) I added more comments to the code. I think it's fine enough at this point.

2) I cleaned up the code a bit, again focusing on what the minimal code would be to have a working prototype with necessary features: Background, Sprites, Controller Input.

3) I decided to use .BMP images to represent the Character ROM. This allows me to easily edit that data without the need to program my own CHR-ROM editor, or use someone elses. I'm good with GIMP, so let's just use that! See attached for my smiley face prototype (in .PNG form)

4) I set up a script to run through all the mess of tools each time to get my working GAME.NES file.

5) I put it all on GitHub! https://github.com/stevenchadburrow/PIC ... NesGameDev I am hosting it under my PICnes repository but in a separate folder. Again, this is just a 'Hello World' in a way.

While doing the readme in GitHub, I noticed that AS65 aka DEV65 by Andrew Jacobs is what I have been using. http://6502.org/users/obelisk/dev65/index.html It works great for me, however I fear that with the lack of support for it at this point that I aught to switch to something else. I am *highly* inclined to write my own assembler, as I did a long time ago, but it would be non-conformist to say the least, and would waste a bit of my time, and if I show y'all code you wouldn't like it. So I am open to suggestions! It is such a classic question here, but: What 6502 assembler would you recommend (for Linux)? I wonder what the NesDev folks use...

EDIT: Yep, those NesDev guys got the good stuff :) https://www.nesdev.org/wiki/Tools I picked 'asm6', it compiled in Linux immediately, and I don't have to use my old Parser program anymore!!! Wow, like SOOO much easier to use. All my code ported over immediately as well, literally not a single change. Updated GitHub accordingly.

Well, here we have it. A minimal NES code!

Thank you all!

Chad
Attachments
NesGameDev-PatternTable0.png
NesGameDev-PatternTable0.png (620 Bytes) Viewed 770 times
6502inside
Posts: 101
Joined: 03 Jan 2007
Location: Sunny So Cal
Contact:

Re: Minimal NES Code

Post by 6502inside »

Basically an NES hello world then. :)
Post Reply