Jump to content
IGNORED

Example Code for CC65 TGI Sound Functions


BitJag

Recommended Posts

Hi, just started working with the lynx and I am going through the tutorials at https://atarilynxdeveloper.wordpress.com/(LX.NET I believe) . Awesome set of tutorials, I already have a spaceship with some stars zooming past on the screen. :) Plus plenty of head scratching on how I can get my program to work on my flash card, another thread for another day maybe.

 

I am trying to work out various pieces of a small "game" and I am currently stuck at sound.

 

I noticed in the lynx.h header file that there are functions available for sound support, but I haven't been able to find much about them other than they exist.

 

I was wondering if anyone would be willing to point me to an example (did a quick search on the forum and didn't spot anything myself...), or maybe build an example for me.

 

Here is my process so far.

 

I used Chipper 2.0 to make a quick tune and exported it with the /For BLL Driver>Export CC65 "remake"> option

(I realize this may be my problem because it is under the "for BLL Driver category" and that the resulting .asm file is not formatted to work with cc65 library out of the box. Would like to verify this.)

 

I then modify the labels int he .asm file for the name of the file, adding underscores to make them accessible to me in my C code. (Another clue that I am doing this completely wrong. You can tell I am new at this right? :P ).

 

I then assemble the .asm file with ca665 and link it with the rest of my object files.

 

In my C code I initialize the sound with

lynx_snd_init();

I attempt to play the sound with

lynx_snd_play ( Channel0 , &music);

I included some defines at the top of my C file for the channels (Again, this doesn't feel like the appropriate way of doing this). I got these defines from another thread

 

#define Channel0 (char *)0xfd20
#define Channel1 (char *)0xfd28
#define Channel2 (char *)0xfd30
#define Channel3 (char *)0xfd38

I included my source files. I am currently working in Linux environment.

 

Thanks again for any help you can give a fledgling Lynx developer.

 

2-14-16_AA_sound_help.zip

Link to comment
Share on other sites

Did a bit more digging and found some gems.

 

It seems that modifying the .asm produced from Clipper is appropriate at this point

 

http://atariage.com/forums/topic/207105-pong-with-segments/page-3?do=findComment&comment=2740272

 

Also, found and example of the C code at work in the same thread. Thanks Karri!

 

Time for some more trial and error to see if I can get this to work.

 

http://atariage.com/forums/topic/207105-pong-with-segments/page-3?do=findComment&comment=3207763

 

Edit:

 

The C code I uploaded is a mess by the way... sorry.

Edited by lachoneus
Link to comment
Share on other sites

Okay... Pulled those useless defines from the top of my C file, and mimicked the initialization code from the link in the above post.

 

Game starts fine, and then garbage fills the screen, and I can move the sprite around for a moment and then it stops for moment, and then I can move fore a moment etc...

 

Reading into the above thread more leads me to believe that I need to adjust my lynx.cfg file and my directory lists. So this might be a memory issue with my compiled code not knowing where to put the music in memory? I admit, the content in the tutorials about the directory is still sinking in. I have read through it a few times, time to go through it again.

Link to comment
Share on other sites

Yes! Got the first channel of the song working. I wasn't pointing to the music data correctly in the C file.

 

The first channel is working fine, anyone have any ideas on the second channel? I am sure I missing something incredibly simple. Right now I am assuming that I just tell it to play the second channel by changing the first function parameter to 1.

 

No matter what I change the channel parameter to (0,1,2,3), it seems that it is just playing the first channel.

Edited by lachoneus
Link to comment
Share on other sites

And it was incredibly simple... Took a look at the "Shaken Not Stirred" source code as suggested the aforementioned posts and I had it figured in a matter of minutes. Thanks again Karri for putting these examples together, I am definately going to do some more digging.

 

For those who maybe running into a similar problem here is the path to the exact file that shows a struct for all four channels. "Shaken / resident / aaresident.c" lines 38-60 will get you on the right path.

 

Just duplicate and you will have some awesome tunes running with your awesome games in no time. ;)

Link to comment
Share on other sites

  • 3 years later...

Hey Lachoneus!

 

I am stuck with a similar problem to yours, and unfortunately the repo containing "Shaken / resident / aaresident.c" lines 38-60 is not online anymore.

 

Basically, I tried to use your music.asm and  soundbs.mac files, which I can compile and link. 

I then declared:

 

	extern unsigned char *music;
	void PlayMusic() { 
		lynx_snd_pause();
		lynx_snd_play(0, music);
		lynx_snd_continue();
	}
	void StopMusic() { 
		lynx_snd_stop();
	}

But the game just freezes when lynx_snd_play is called. I tried declaring music as other types, but I cannot get this to work...

Would it be possible at all to upload an update of your demo in a working state?
Thanks in advance,

Tony

Edited by 8bit-Dude
Link to comment
Share on other sites

@8bit-Dude  It has been a few years since I have touched this stuff, but I did assemble a project to help me get back into it when the time was right.  I can't walk you through the project at this point, since it has been a while since I have done anything with it.  But I am going to trust my past self to have set this project up in such a way that the code works out of the box once you have a proper build environment set up.  I do remember composing the song that plays in this program in Chipper, and that I put this together not too long after my posts in this thread.  I hope this helps.

blank_project.zip

Link to comment
Share on other sites

I already sent my comments in another thread where you asked the same question. Using HandyMusic is currently not included in the template. You can have a look at how I did it on another competition game "Find a way to my heart". It use HandyMusic for everything. PCM, SFX and bg music. https://bitbucket.org/karri/findaway

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...