It is currently Mon Oct 16, 2017 3:13 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Broke my GGSound program
PostPosted: Mon Apr 25, 2016 1:48 pm 
Offline

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


Top
 Profile  
 
PostPosted: Mon Apr 25, 2016 2:49 pm 
Offline

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


Top
 Profile  
 
PostPosted: Mon Apr 25, 2016 3:46 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5703
Location: Canada
I always used the "Pause Break" key on my keyboard, which also pauses FCEUX.


Top
 Profile  
 
PostPosted: Thu Apr 28, 2016 10:39 am 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 983
Location: Pennsylvania, USA
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.


Top
 Profile  
 
PostPosted: Sat Apr 30, 2016 7:44 am 
Offline

Joined: Sun Mar 08, 2015 12:23 pm
Posts: 251
Location: Croatia
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?


Top
 Profile  
 
PostPosted: Sun May 01, 2016 12:33 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 983
Location: Pennsylvania, USA
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.


Top
 Profile  
 
PostPosted: Sun May 01, 2016 12:44 pm 
Offline
User avatar

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


Top
 Profile  
 
PostPosted: Sun May 01, 2016 1:12 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 983
Location: Pennsylvania, USA
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.


Top
 Profile  
 
PostPosted: Sun May 01, 2016 1:59 pm 
Offline

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


Top
 Profile  
 
PostPosted: Sun May 01, 2016 2:19 pm 
Offline

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


Top
 Profile  
 
PostPosted: Sun May 01, 2016 4:03 pm 
Offline

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


Top
 Profile  
 
PostPosted: Mon May 02, 2016 5:24 am 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 983
Location: Pennsylvania, USA
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!)


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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