It is currently Tue Nov 21, 2017 3:21 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: I Made a NES Pong Thing
PostPosted: Tue Dec 29, 2015 12:33 pm 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 368
Location: ...
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.


Attachments:
pong.nes [16.02 KiB]
Downloaded 142 times
Top
 Profile  
 
PostPosted: Tue Dec 29, 2015 6:09 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1824
Location: DIGDUG
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.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Dec 29, 2015 6:56 pm 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 368
Location: ...
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)


Top
 Profile  
 
PostPosted: Tue Dec 29, 2015 7:08 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1824
Location: DIGDUG
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

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Dec 29, 2015 7:17 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6447
Location: UK (temporarily)
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.


Top
 Profile  
 
PostPosted: Tue Dec 29, 2015 7:30 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1824
Location: DIGDUG
...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].

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Dec 29, 2015 7:36 pm 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 368
Location: ...
I'd rather just do copy-paste (and maybe "sorry") than go through the trouble of having to rely on the C suite.


Top
 Profile  
 
PostPosted: Tue Dec 29, 2015 10:06 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1824
Location: DIGDUG
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

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Dec 29, 2015 10:51 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5824
Location: Canada
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group