Guidance for creating a pong game (New here)

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
test_matsu
Posts: 23
Joined: Tue Feb 19, 2019 11:54 pm
Location: Planet Earth, Milky Way

Guidance for creating a pong game (New here)

Post by test_matsu » Wed Feb 20, 2019 6:00 am

:oops: Looking for a general direction I can go as far as creating something simple for the NES so I can understand how this works.

I have 2 programs so far

Notepad ++
Fami Tracker

The first one is for coding and the second one is for music (For anyone who doesn't understand). What can I do to start I've programmed in python so I kinda know what's going on the same with c++ and java.. also HTML.

I know that the NES has it's limitations I think it reads and wrights to ram and memory. It also uses two different chips one for sound and the other for code?

Anyways I wanted to start and learn and I thought what a fun way to start by coding a game of pong for the NES.

Thank you for your time! :)

User avatar
gravelstudios
Posts: 75
Joined: Mon Mar 13, 2017 5:21 pm
Contact:

Re: Guidance for creating a pong game (New here)

Post by gravelstudios » Wed Feb 20, 2019 6:20 am

The best place to start is probably the Nerdy Nights NES programming tutorials:

http://nintendoage.com/forum/messagevie ... eadid=7155

Not all the information is totally accurate or up-to-date, but I think it's still a great place to start. I taught me enough to make my first game. You'll need an emulator for testing. I'd recommend Mesen and FCEUX (Mesen is the better emulator, but FCEUX has some nice features that make debugging easier).

You'll also need to become familiar with the 6502 instruction set:

http://www.6502.org/tutorials/6502opcodes.html

This site's wiki is also a great source once you are familiar with the basics:

http://wiki.nesdev.com/w/index.php/Programming_guide

Good luck, and happy coding!

User avatar
test_matsu
Posts: 23
Joined: Tue Feb 19, 2019 11:54 pm
Location: Planet Earth, Milky Way

Re: Guidance for creating a pong game (New here)

Post by test_matsu » Wed Feb 20, 2019 6:56 am

Thank you so much, I'm currently checking them out as we speak.

User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2032
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Guidance for creating a pong game (New here)

Post by FrankenGraphics » Wed Feb 20, 2019 7:07 am

Yes, the NES largely consists of:
-a simpler variant of the 6502 CPU. Any 6502 programming guide will help, but keep in mind that decimal mode is not present. Also, unlike a c64 or apple computer or whatever, each game is its own self-contained ROM system. You have full access to the internal RAM.
-a music synthesizer (called APU or audio processing unit)
-hardware accelerated graphics (called PPU or picture processing unit - think of it as a specialized, yet limited GPU) with its own RAM not directly usable to the CPU.
-2kB:s of internal RAM.
-in/out ports
-a total 64kB address range (of which most is connected to your ROM memory on cartridge).

In addition, your cartridge might contain additional hardware features.

You program for the CPU. But reading and writing data to certain addresses connected to the controllers, the PPU (for graphics) or APU (for sound/music) will have these units perform hardware accelerated tasks for you. You don't have to render a picture in software - the PPU does that for you!

Music is often a combination of programmed software features and predefined hardware features. For example, your vibrato or glissando effect might be either, depending on what you want.

At this point in time, several people have written drivers for the APU which you can use: famitracker comes with its own driver, which is very flexible for people mainly interested in chip music but may be impractical for more ambitious games. For a pong demo, though, it's more than adequate. Then there's also famitone2, pently, ggsound and penguin. Maybe some more.

Note that the famitracker driver doesn't have a way to handle sound fx.


You'll need an assembler to turn your text document code into machine code. I'd recommend asm6 as a first-time assembler because it is easy to use, but i believe the nerdy nights tutorials were written for nesasm. That means syntax will be a bit different. You need to do a bit of translation if using asm6 and that specific tutorial.

--
edited a typo
Last edited by FrankenGraphics on Wed Feb 20, 2019 1:50 pm, edited 1 time in total.
http://www.frankengraphics.com - personal NES blog

User avatar
darryl.revok
Posts: 520
Joined: Sat Jul 25, 2015 1:22 pm

Re: Guidance for creating a pong game (New here)

Post by darryl.revok » Wed Feb 20, 2019 8:26 am

Personal recommendations:

I like recommending this before nerdy nights. It's really simple, and while it's using the same instructions you'll use on NES, it eliminates the need to deal with NES graphics or other complexities while you're taking your first couple steps:

https://skilldrick.github.io/easy6502/

I'd do that, THEN Nerdy Nights.

For a reference, I pretty much have this page open all of the time when I'm doing 6502:

http://www.obelisk.me.uk/

On the left side, click on 6502 and pull that down. The "Reference" page is probably the most valuable, but they're all helpful.

User avatar
samophlange
Posts: 48
Joined: Sun Apr 08, 2018 11:45 pm
Location: Southern California

Re: Guidance for creating a pong game (New here)

Post by samophlange » Wed Feb 20, 2019 9:34 am

This youtube channel has some good videos that talk about NES development:
https://www.youtube.com/watch?v=JgdcGcJ ... PqwliHEuEk

There are two playlists. The first is "The Zero Pages", which are instructional videos. The second playlist is "NES Programming", where he is coding a game and learning as he goes. Both can be helpful, but I would recommend starting with "The Zero Pages" first.

User avatar
test_matsu
Posts: 23
Joined: Tue Feb 19, 2019 11:54 pm
Location: Planet Earth, Milky Way

Re: Guidance for creating a pong game (New here)

Post by test_matsu » Wed Feb 20, 2019 1:41 pm

darryl.revok wrote:Personal recommendations:

I like recommending this before nerdy nights. It's really simple, and while it's using the same instructions you'll use on NES, it eliminates the need to deal with NES graphics or other complexities while you're taking your first couple steps:

https://skilldrick.github.io/easy6502/

I'd do that, THEN Nerdy Nights.

For a reference, I pretty much have this page open all of the time when I'm doing 6502:

http://www.obelisk.me.uk/

On the left side, click on 6502 and pull that down. The "Reference" page is probably the most valuable, but they're all helpful.
Not going to lie that simulator is pretty neat! Also learned quite a bit from it as well.
Also, thank you, everyone, for the replies, I'm still looking at everything to learn it all will take forever so I'm working step by step to getting a grip on things.

Sour
Posts: 815
Joined: Sun Feb 07, 2016 6:16 pm

Re: Guidance for creating a pong game (New here)

Post by Sour » Wed Feb 20, 2019 2:48 pm

gravelstudios wrote:[...] but FCEUX has some nice features that make debugging easier).
Offtopic but, what in FCEUX makes you say it is easier to debug at this point? I believe I've essentially incorporated all of its debugging features (and added a lot more on top of them), with the exception of a TAS editor, if that counts as one. (I don't mean this as a complaint, by the way, just genuinely curious to know - I can't improve the debugger if people don't tell me what they don't like about it, after all)

FCEUX is definitely faster and better for debugging on low-end devices, though.

User avatar
gravelstudios
Posts: 75
Joined: Mon Mar 13, 2017 5:21 pm
Contact:

Re: Guidance for creating a pong game (New here)

Post by gravelstudios » Wed Feb 20, 2019 4:38 pm

Offtopic but, what in FCEUX makes you say it is easier to debug at this point? I believe I've essentially incorporated all of its debugging features (and added a lot more on top of them), with the exception of a TAS editor, if that counts as one. (I don't mean this as a complaint, by the way, just genuinely curious to know - I can't improve the debugger if people don't tell me what they don't like about it, after all)
You know what, I retract that statement. I only just started using Mesen a few days ago, and didn't really know where everything was located, or how to use it. after I read your post, I looked again and found some of the stuff I was looking for. Sorry about that.

User avatar
test_matsu
Posts: 23
Joined: Tue Feb 19, 2019 11:54 pm
Location: Planet Earth, Milky Way

Re: Guidance for creating a pong game (New here)

Post by test_matsu » Wed Feb 20, 2019 11:51 pm

I Also have a graphics editor called YY-CHR although I don't know if it's good to have it or not

User avatar
test_matsu
Posts: 23
Joined: Tue Feb 19, 2019 11:54 pm
Location: Planet Earth, Milky Way

Re: Guidance for creating a pong game (New here)

Post by test_matsu » Wed Feb 20, 2019 11:59 pm

FrankenGraphics wrote:Yes, the NES largely consists of:
-a simpler variant of the 6502 CPU. Any 6502 programming guide will help, but keep in mind that decimal mode is not present. Also, unlike a c64 or apple computer or whatever, each game is its own self-contained ROM system. You have full access to the internal RAM.
-a music synthesizer (called APU or audio processing unit)
-hardware accelerated graphics (called PPU or picture processing unit - think of it as a specialized, yet limited GPU) with its own RAM not directly usable to the CPU.
-2kB:s of internal RAM.
-in/out ports
-a total 64kB address range (of which most is connected to your ROM memory on cartridge).

In addition, your cartridge might contain additional hardware features.

You program for the CPU. But reading and writing data to certain addresses connected to the controllers, the PPU (for graphics) or APU (for sound/music) will have these units perform hardware accelerated tasks for you. You don't have to render a picture in software - the PPU does that for you!

Music is often a combination of programmed software features and predefined hardware features. For example, your vibrato or glissando effect might be either, depending on what you want.

At this point in time, several people have written drivers for the APU which you can use: famitracker comes with its own driver, which is very flexible for people mainly interested in chip music but may be impractical for more ambitious games. For a pong demo, though, it's more than adequate. Then there's also famitone2, pently, ggsound and penguin. Maybe some more.

Note that the famitracker driver doesn't have a way to handle sound fx.


You'll need an assembler to turn your text document code into machine code. I'd recommend asm6 as a first-time assembler because it is easy to use, but i believe the nerdy nights tutorials were written for nesasm. That means syntax will be a bit different. You need to do a bit of translation if using asm6 and that specific tutorial.

--
edited a typo
It seems like ASM6 closes out immediately when I run the program :?

User avatar
Gilbert
Posts: 400
Joined: Sun Dec 12, 2010 10:27 pm
Location: Hong Kong
Contact:

Re: Guidance for creating a pong game (New here)

Post by Gilbert » Thu Feb 21, 2019 1:42 am

This is the correct behaviour as it's a console app.
Read this apparently recent thread.

User avatar
test_matsu
Posts: 23
Joined: Tue Feb 19, 2019 11:54 pm
Location: Planet Earth, Milky Way

Re: Guidance for creating a pong game (New here)

Post by test_matsu » Thu Feb 21, 2019 1:52 am

Gilbert wrote:This is the correct behaviour as it's a console app.
Read this apparently recent thread.
I'm still confused as what to do with this.. unfortunately.

User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2032
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Guidance for creating a pong game (New here)

Post by FrankenGraphics » Thu Feb 21, 2019 3:12 am

The easiest way is to simply drag and drop your text file onto asm6.exe. If your code contains syntax errors, you'll hardly notice anything and it won't produce a file. If your code is error-free, then it will produce a file (theNameOfYourTextfile.bin) in the same folder. So this method is good when you want to do something quick. But it's probably not the best method if you don't know your way around the syntax just yet.

But the proper way (most of the time) is to either:

A)
-open command prompt in your project folder
-type: asm6 yourMainCodeTextFile.asm myGame.nes listing.txt

or

B)
-make a new text file
-type this:

Code: Select all

asm6 yourMainCodeTextFile.asm myGame.nes listing.txt
pause
-and save as "assemble.bat" or something like that.
-double click assemble.bat

the pause is important to be able to have a chance to get a look at the program readout.

obviously, replace my mockup file names with something that makes sense to your project.


as a suggestion, keep a copy of asm6 in each project folder. It simplifies things like not needing to specify full paths in the command line or batch (.bat) file.


For reference, here's what the readme file says:

Code: Select all

Usage:

        asm6 [-options] sourcefile [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
	-q         Quiet mode (suppress all output unless there's an error)
        Default output is <sourcefile>.bin
        Default listing is <sourcefile>.lst
It says other things too that are important to read.
Last edited by FrankenGraphics on Thu Feb 21, 2019 3:18 am, edited 1 time in total.
http://www.frankengraphics.com - personal NES blog

Pokun
Posts: 1512
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Guidance for creating a pong game (New here)

Post by Pokun » Thu Feb 21, 2019 3:17 am

Look at the command prompt tutorial in that link or google for another tutorial. Using commandline programs is a basic computer skill you need to learn.

I think Nerdy Nights teaches you that though. Here are the Nerdy Nights lesson files in asm6 so you don't have to learn how to convert from nesasm.

Post Reply