Broke my GGSound program

Discuss NSF files, FamiTracker, MML tools, or anything else related to NES music.

Moderator: Moderators

Post Reply
8bitMicroGuy
Posts: 314
Joined: Sun Mar 08, 2015 12:23 pm
Location: Croatia

Broke my GGSound program

Post by 8bitMicroGuy »

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
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Broke my GGSound program

Post by tepples »

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.
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Broke my GGSound program

Post by rainwarrior »

I always used the "Pause Break" key on my keyboard, which also pauses FCEUX.
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: Broke my GGSound program

Post by GradualGames »

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.
8bitMicroGuy
Posts: 314
Joined: Sun Mar 08, 2015 12:23 pm
Location: Croatia

Re: Broke my GGSound program

Post by 8bitMicroGuy »

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?
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: Broke my GGSound program

Post by GradualGames »

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: Select all


  .bank 3
  .org $C000
  include "battle3_dpcm.asm"
  
  .bank 4
  .org $E000
Replace these with:

Code: Select all



  .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.
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: Broke my GGSound program

Post by GradualGames »

There's also something wrong with your controller testing code, its alternating pausing and unpausing the song every frame.
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: Broke my GGSound program

Post by GradualGames »

You need to use your button flags using immediate addressing:

Code: Select all


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.
8bitMicroGuy
Posts: 314
Joined: Sun Mar 08, 2015 12:23 pm
Location: Croatia

Re: Broke my GGSound program

Post by 8bitMicroGuy »

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.
8bitMicroGuy
Posts: 314
Joined: Sun Mar 08, 2015 12:23 pm
Location: Croatia

Re: Broke my GGSound program

Post by 8bitMicroGuy »

Update: Commented out the controller code which means that the controller code is bad.
8bitMicroGuy
Posts: 314
Joined: Sun Mar 08, 2015 12:23 pm
Location: Croatia

Re: Broke my GGSound program

Post by 8bitMicroGuy »

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.
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: Broke my GGSound program

Post by GradualGames »

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.
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!)
Post Reply