Page 1 of 1

FamiToneUpdate problem

Posted: Fri Oct 26, 2018 2:10 pm
by battagline
I created a little test project that played different sounds effects I created with Famitracker. Everything seemed to work well, so I moved the sound effects and famitone into my asteroids game, and suddenly the screen goes nuts.

The problem seems to be the call to

Code: Select all

jsr FamiToneUpdate
inside the game loop. The total number of cycles used in the gameloop is about 5700. At first I thought I may have been using too many cycles or something, but I thought the gameloop had something like 16000 cycles (might be wrong about that).

If I comment out the call to FamiToneUpdate everything goes back to normal.

Any ideas or suggestions?

Thanks

Re: FamiToneUpdate problem

Posted: Fri Oct 26, 2018 2:13 pm
by rainwarrior
Did you make sure that Famitone's allocated memory is not in the same location as memory you're using for your game?

Re: FamiToneUpdate problem

Posted: Fri Oct 26, 2018 2:19 pm
by battagline
rainwarrior wrote:Did you make sure that Famitone's allocated memory is not in the same location as memory you're using for your game?
You're right. It was pointed to the same address as my OAM.

Thanks!

Re: FamiToneUpdate problem

Posted: Fri Oct 26, 2018 2:41 pm
by battagline
rainwarrior wrote:Did you make sure that Famitone's allocated memory is not in the same location as memory you're using for your game?
So I changed the memory it was using so it's not hitting OAM anymore, but I think it's messing up some other variables. How do I find some space to put the Famitone's memory? Should I modify my .cfg file to set aside some space for it?

Any suggestions?

Thanks

Re: FamiToneUpdate problem

Posted: Fri Oct 26, 2018 3:06 pm
by rainwarrior
Did you adjust FT_TEMP or just FT_BASE_ADR?
FT_BASE_ADR points to a page in main RAM, but FT_TEMP also needs to point to 3 free bytes on the ZP.

Yes I would recommend using the CFG to make sure nothing goes into the page used by FT_BASE_ADR. (E.g. if it's at $700, make sure your RAM segments aren't allowed to use that area.)

For the ZP thing you could just reserve 3 bytes and export a label to it:

Code: Select all

; with your other allocations
.segment "ZEROPAGE" : zeropage
ft_temp: .res 3

; in famitone2.s
.importzp ft_temp
FT_TEMP = ft_temp

Re: FamiToneUpdate problem

Posted: Fri Oct 26, 2018 3:57 pm
by battagline
rainwarrior wrote:Did you adjust FT_TEMP or just FT_BASE_ADR?
FT_BASE_ADR points to a page in main RAM, but FT_TEMP also needs to point to 3 free bytes on the ZP.

Yes I would recommend using the CFG to make sure nothing goes into the page used by FT_BASE_ADR. (E.g. if it's at $700, make sure your RAM segments aren't allowed to use that area.)

For the ZP thing you could just reserve 3 bytes and export a label to it:

Code: Select all

; with your other allocations
.segment "ZEROPAGE" : zeropage
ft_temp: .res 3

; in famitone2.s
.importzp ft_temp
FT_TEMP = ft_temp

It's working now. I ended up reserving a page of space in my bss segment with a label instead of changing the .cfg file. I put 7 bytes on the zeropage. In your last post you said I only needed 3 bytes, but the comments inside the famitone code says it uses 7. Is that comment out of date or something?

Thanks for all your help

Re: FamiToneUpdate problem

Posted: Fri Oct 26, 2018 4:04 pm
by rainwarrior
I don't know what version of Famitone you're using. If it says 7 then go with that. If it's inconsistent maybe tell the person who maintains it.

Re: FamiToneUpdate problem

Posted: Fri Oct 26, 2018 9:48 pm
by pubby
Make sure Famitone's memory is set to all zeroes before initializing it. I recall having problems before when I didn't do that.

Re: FamiToneUpdate problem

Posted: Sat Oct 27, 2018 12:14 pm
by battagline
pubby wrote:Make sure Famitone's memory is set to all zeroes before initializing it. I recall having problems before when I didn't do that.
That's funny, it was playing a little tone when the game started up and I think that may have been why.

Thanks