Nerdy Nights week 7 example (Pong1) completed

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

Post Reply
arcangeldemerida
Posts: 21
Joined: Wed Jun 22, 2022 7:00 am

Nerdy Nights week 7 example (Pong1) completed

Post by arcangeldemerida »

Has anyone by any chance made a complete version of the example from lesson/week 7 (Pong1) with the code segments that were incomplete now complete?

I need it as an example.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Nerdy Nights week 7 example (Pong1) completed

Post by Pokun »

Well I finished my Pong when I first completed the tutorial, although I probably did some changes to the original program. But I can't seem to find it, it was probably on my old computer.

Do you need it for something special or are you just stuck in your own Pong attempt?
arcangeldemerida
Posts: 21
Joined: Wed Jun 22, 2022 7:00 am

Re: Nerdy Nights week 7 example (Pong1) completed

Post by arcangeldemerida »

Pokun wrote: Thu Jul 07, 2022 5:09 pm Do you need it for something special or are you just stuck in your own Pong attempt?
Yes, I'm stuck in my own attempt at pong.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Nerdy Nights week 7 example (Pong1) completed

Post by Pokun »

We might be able to give some advice if you can describe the problem.

I remember some people have posted their Pong attempts on Github. I found one here.
User avatar
donato-zits-
Posts: 47
Joined: Fri Jun 03, 2022 11:14 am
Contact:

Re: Nerdy Nights week 7 example (Pong1) completed

Post by donato-zits- »

in my first attempt of those pong NN codes every was been going nice until the ball\paddle colissions...I think so thata plan to try again if I got to make a translation to the CC65 terminology, or perhaps even in NESASM
arcangeldemerida
Posts: 21
Joined: Wed Jun 22, 2022 7:00 am

Re: Nerdy Nights week 7 example (Pong1) completed

Post by arcangeldemerida »

I have already been trying to make my own Pong, I already have something advanced but the game keeps working badly (it hangs when adding 1 point to the score).
I've been trying to fix it but no results.

I attach my ASM file so that you can review it and then tell me what corrections I have to make.

I thank you in advance.

NOTE: some comments in the file may be in Spanish, however the labels, variables and constants are in English. Remember to assemble with NESASM.
Attachments
pong_basic.asm
(36.76 KiB) Downloaded 26 times
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Nerdy Nights week 7 example (Pong1) completed

Post by Pokun »

OK I found the crashing bug.

Here is what I did to find it:
I assembled your game in NESASM and ran it in Mesen and it crashes after scoring a point as expected. I opened the debugger and reset the game, then I let one player score a point. As soon as the score happened the debugger automatically paused the emulation because I have it set to break on unofficial opcodes, CPU crashes and other things. The break happened at address $8658 becuase there are unofficial opcode there (it's an $FF area outside your program).
Then I opened the Trace Logger (found under the Debugger menu on the menu bar of the main Mesen window, not in the debugger menu).
Here I could see the instruction that happened before the break was at the address $8648 and it was a BNE to $8658. But it's hard to tell where in your program this BNE is.

I went back to your program and used the .list directive at the beginning of your ROM, this makes so NESASM creates a program listing complete with addresses for every instruction in your program, and then I reassembled your file. This should create a "pong_basic.lst" file where the program listing is listed. In here we can see that the BNE $8658 is actually the BNE .IncDone in your HexByteToUnsignedDecimal subroutine. You just forgot an RTS at the end of it.

The score increment still doesn't work correctly when adding the RTS, but I guess you are not done yet.
arcangeldemerida
Posts: 21
Joined: Wed Jun 22, 2022 7:00 am

Re: Nerdy Nights week 7 example (Pong1) completed

Post by arcangeldemerida »

Pokun wrote: Sun Jul 31, 2022 6:01 am OK I found the crashing bug.

Here is what I did to find it:
I assembled your game in NESASM and ran it in Mesen and it crashes after scoring a point as expected. I opened the debugger and reset the game, then I let one player score a point. As soon as the score happened the debugger automatically paused the emulation because I have it set to break on unofficial opcodes, CPU crashes and other things. The break happened at address $8658 becuase there are unofficial opcode there (it's an $FF area outside your program).
Then I opened the Trace Logger (found under the Debugger menu on the menu bar of the main Mesen window, not in the debugger menu).
Here I could see the instruction that happened before the break was at the address $8648 and it was a BNE to $8658. But it's hard to tell where in your program this BNE is.

I went back to your program and used the .list directive at the beginning of your ROM, this makes so NESASM creates a program listing complete with addresses for every instruction in your program, and then I reassembled your file. This should create a "pong_basic.lst" file where the program listing is listed. In here we can see that the BNE $8658 is actually the BNE .IncDone in your HexByteToUnsignedDecimal subroutine. You just forgot an RTS at the end of it.

The score increment still doesn't work correctly when adding the RTS, but I guess you are not done yet.
Ok, I forgot to write the RTS at the end.
After making more modifications to the code, I finally got the game to work normally.

Thanks for the help. :D
Attachments
pong_basic.asm
(37.04 KiB) Downloaded 30 times
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Nerdy Nights week 7 example (Pong1) completed

Post by Pokun »

Good job, I tried it and it seems to work perfectly. Remember the the tools Debugger and Trace Logger as they can help you find problems in the future.
Post Reply