Broke my GGSound program

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Broke my GGSound program
by on (#169395)
I just don't know what's going on with the program that I've made. It just won't work. And would someone please kindly explain to me how to break the program in FCEUX like in Visual Studio one clicks the pause button?

I tried to write a basic program after a while and I somehow broke it. I don't know where and how. It's supposed to use GGSound and play a song. I'm just lost. https://www.dropbox.com/s/rk7z20w12p9e1 ... 3.zip?dl=0
Re: Broke my GGSound program
by on (#169401)
8bitMicroGuy wrote:
would someone please kindly explain to me how to break the program in FCEUX like in Visual Studio one clicks the pause button?

You can pause execution of an NES program in FCEUX for Windows in either of two ways:
  1. Press the Frame Advance key (defaults to backslash)
  2. Debug > Debugger > Step Into

Unless you've set a breakpoint in the debugger, FCEUX usually pauses on the post-render line (240). To skip forward to the beginning of the NMI handler (241), click Run Line in the debugger window.
Re: Broke my GGSound program
by on (#169406)
I always used the "Pause Break" key on my keyboard, which also pauses FCEUX.
Re: Broke my GGSound program
by on (#169583)
Maybe start backing up your code so you can go back to when it was working, helps you learn what broke. Simplest way to do that would be to copy your code to a new folder and date/timestamp it, each time you're happy with progress you've made. Eventually you might even want to pick up git or svn to automate this. I use git all the time even for small experiments like this one.
Re: Broke my GGSound program
by on (#169772)
I seriously don't understand why the program counter jumps to $5000 something. That's not supposed to happen. Can someone please help me by debugging my program for me and finding the problem?
Re: Broke my GGSound program
by on (#169893)
Hey 8bitmicroguy, I was able to figure out what was going wrong with your program. First, you were using the wrong banks for your code:

Code:

  .bank 3
  .org $C000
  include "battle3_dpcm.asm"
 
  .bank 4
  .org $E000


Replace these with:

Code:


  .bank 2
  .org $C000
  include "battle3_dpcm.asm"
 
  .bank 3
  .org $E000



Then your rom will execute---you've still got some problems though as the music sounds messed up. You're doing a couple of things wrong. You shouldn't be setting nmi within nmi, for one. I would recommend against reading the controller within nmi, as well, you should do this in your main thread, and have some mechanism for synchronizing your main thread/loop with nmi. Hopefully that'll get you started.
Re: Broke my GGSound program
by on (#169897)
There's also something wrong with your controller testing code, its alternating pausing and unpausing the song every frame.
Re: Broke my GGSound program
by on (#169903)
You need to use your button flags using immediate addressing:

Code:

if_pressed .macro   ; Return non-zero if joypad=1 and joypadhold=0
            lda \1+1 ; Load joypad hold byte
         eor #$FF  ; Invert
         and \1   ; And joypad byte
         and #\2   ; And button flags     <<<ADD IMMEDIATE ADDRESSING FOR THIS BUTTON FLAG, (or you could pass it in to the macro with a #)
         .endm    ; Use BNE for JUST PRESSED or BEQ for NOT JUST PRESSED
         



You also used the wrong condition to test, you used bne, but your own documentation says use BEQ for not just pressed.

I made those described changes and commented out your ppu code in nmi and was able to play and pause/unpause the song without issue.
Re: Broke my GGSound program
by on (#169912)
I know, I should have used #s for immediate operand.

I fixed the GGSound bug that's in the other topic. But I still get the stuttering. I just don't know how to debug this. I have another demo where these button latches work perfectly fine. I looked up the hex-editor and see that the controller latches perfectly fine.

Two bytes are reserved for each controller. The first byte has the current presses and the second one has the presses of the previous frame. They are bitwise compared for "edge detection" as in "pressed this frame" and "released this frame".

I'll be tweaking until I find out what's going on.
Re: Broke my GGSound program
by on (#169916)
Update: Commented out the controller code which means that the controller code is bad.
Re: Broke my GGSound program
by on (#169933)
Sorry. I didn't see your post, GradualGames.

https://www.dropbox.com/s/rk7z20w12p9e1 ... 3.zip?dl=0

Here's the updated version. I fixed it and it works, but the problem is that the sound effect doesn't stop playing. Could you fix that please?

EDIT:
Also, the duty cycle changing loop doesn't loop in GGSound. Listen to the FamiTracker module and to the NES file.
Re: Broke my GGSound program
by on (#169992)
8bitMicroGuy wrote:
Sorry. I didn't see your post, GradualGames.

https://www.dropbox.com/s/rk7z20w12p9e1 ... 3.zip?dl=0

Here's the updated version. I fixed it and it works, but the problem is that the sound effect doesn't stop playing. Could you fix that please?


If I recall correctly you were also using bne instead of beq in your controller/sfx play test. I was able to hear your sound effect just fine with your own code, yesterday.

Quote:
EDIT:
Also, the duty cycle changing loop doesn't loop in GGSound. Listen to the FamiTracker module and to the NES file.


You know what? I never implemented loop points for duty cycles (they either loop in full, or don't loop at all). I will add this next GGSound update! (prob Wednesday, sit tight!)