I Made a NES Pong Thing

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
I Made a NES Pong Thing
by on (#161481)
Yes, I know, this is my third time making pong for a console, but this is just my way with getting familiar with a console. :wink:

Anyway yeah, I ported pong to the NES. Note that this version gets no inspiration from Nerdy Nights, which can be either good or bad, I can't remember.

I had actually attempted to do this a few months ago, but on a relative's computer, as mine was getting repairs. The relative's computer freaked out and deleted the source, and my PC's hard drive was damaged past restoration, so...yeah.


The source can be found here. Written for ca65. Its throne resides in my pong repo, because three different repos for the same game is. Well. Weird.

My to do list:
* make the source code readable (more comments)
* make the AI beatable (random value magic)
* make the source build into two roms: pong_ai.nes, which is you versus the computer, and pong_vs.nes, you versus player two.

Please give as much feedback as possible. As I said, that's the main reason I keep making pong games in the first place.
Re: I Made a NES Pong Thing
by on (#161508)
Rather than make a better Pong, wouldn't you like to branch out into a more complex game?

Or, do what you want...
It would be nice if moving the paddle up or down during ball collision would change it's direction/speed.

ca65 has random number generator code, btw...it's under stdlib.h.
Re: I Made a NES Pong Thing
by on (#161511)
dougeff wrote:
Rather than make a better Pong, wouldn't you like to branch out into a more complex game?

My dilemma is what console, what tools, and what time.

Quote:
It would be nice if moving the paddle up or down during ball collision would change it's direction/speed.

Direction, I can do. Speed, I can't.

Quote:
ca65 has random number generator code, btw...it's under stdlib.h.

You're talking about cc65; I'm using assembly. Will check out the C stuff, though, because it wouldn't be my first time taking something from there. ("My" NES defines)
Re: I Made a NES Pong Thing
by on (#161512)
Nope... The code is asm. Take a look. Cut/Paste it out of stdlib.h

...or maybe it was rand.s...
https://github.com/cc65/cc65/blob/maste ... mon/rand.s
Re: I Made a NES Pong Thing
by on (#161513)
nicklausw wrote:
You're talking about cc65; I'm using assembly. Will check out the C stuff, though, because it wouldn't be my first time taking something from there.
You can still call functions from the cc65 runtime even in a pure-asm project.
Re: I Made a NES Pong Thing
by on (#161515)
...what lidnariq said...

I think you have to type something like...

.import _rand, _srand

And CA65 automatically knows what you're talking about... I'm away from my computer at the moment, so I can't test it. Maybe you also need to have an include. (?)

And then later...jsr _rand will put a pseudorandom number in A [and X].
Re: I Made a NES Pong Thing
by on (#161516)
I'd rather just do copy-paste (and maybe "sorry") than go through the trouble of having to rely on the C suite.
Re: I Made a NES Pong Thing
by on (#161524)
This worked for me...(no need to include anything)

Code:
   .import      _rand
   .import      _srand

.segment   "CODE"
   ;you should first put a seed value in...
   jsr _srand

   jsr _rand ;then this generates a new random number
Re: I Made a NES Pong Thing
by on (#161526)
The linker would need to know where to find _rand. It's in the common lib, but you can just look at the code yourself if you like:
https://github.com/cc65/cc65/blob/master/libsrc/common/rand.s

Alternatively, I put a simple PRNG implementation on the wiki a while back because it kept coming up: http://wiki.nesdev.com/w/index.php/Random_number_generator