Page 1 of 1

Adding MYMPlayer to C

Posted: Sun Oct 07, 2018 9:53 pm
by Badger
I'm trying to add the mymplayer to my C game with a few issues.
So I did this

Code: Select all

#include <lib.h>
main(){
sedoric("!DIR"); //just display disk contents
sedoric("!MYMPLAYER.BIN"); //load mymplayer to mem
sedoric("!BUBBLE.BIN"); //load bubble bobble tune                                   
call(25856); //#6500
}

It builds runs and the music plays.....great....but.....

This happens

Code: Select all

                                   
  Drive A V3 (Mst) TAP2DSK SAMPLE DISC  
                                        
  TEST     .COM   4   MYMPLAYER.BIN   4 
  BUBBLE   .BIN  10                     
                                        
  *237 sectors free (S/21/17)  3 Files  
                                        
  ?SYNTAX ERROR IN  8192                
  Ready                                 
  LIST 8192                             
                                        
                                        
  Ready                                 
  CALL #6503                            
                                        
  Ready                                 
  CALL #6500                            
                                        
  Ready                                 
  CALL #6503                            
                                        
  Ready                                 
  
So the music plays on load , get the syntax error after about 1 second but music continues

further calls #6503 to stop the music work and #6500 to start work with no error.

I get stranger results when I insert similar code to the sideways scroller such as display corruption and freeze.

YM2MYM is version 1.007 and the showmap.bat shows the osdk starting at #600 and going to #8d8 so no overlap with #6500-> or #7600

Any hints?

Badger

Re: Adding MYMPlayer to C

Posted: Mon Oct 08, 2018 8:23 pm
by Dbug
The error is reported from the system not being happy after the program finished.

If you add:

Code: Select all

	printf("Press a key to stop");
	get();
	call(0x6503);
you'll see that the error appears only after you exit the program.

Basically the whole "sedoric" invocation is kind of wonky (and by the way, how did you get it to work, I had to add some lines to my library.ndx!

Code: Select all

-sedoric.s
    _sedoric


Regarding corruption with the scroller, that requires a bit more investigation: Could be some rogue pointer, badly used zero page location, C code writing to where the player plays, etc...

If you plan on having the player in your program, it's probably a better idea to have the code assembled as part of your program, this particular BASIC player was created to allow the author of Athanor to have music in a BASIC program, and there was some pretty explicit constraints about where it could be run, it was not really a generic routine, like it kind of hook on the system IRQ and uses specific memory addresses for temporary depacking of data. (like the entire area $6800 to $7600 is used)

Re: Adding MYMPlayer to C

Posted: Tue Oct 09, 2018 6:48 pm
by Badger
Dbug wrote
Basically the whole "sedoric" invocation is kind of wonky (and by the way, how did you get it to work, I had to add some lines to my library.ndx!

-sedoric.s
_sedoric
I dont remember having to change the library files and when I looked the _sedoric was already there (although I could have added it as a flash of inspiratiion and then forgot about it :D )

Yes it does exactly as you say with the keypress and I suspect with the scroller it is C which is wrting over the code.

I'll have a play around and see if its possible to either mod the player code or incorporate it into the c program or something. maybe time to delve into some assembler (luckily I found some books on ebay to help).....this may take some time :D

Re: Adding MYMPlayer to C

Posted: Tue Oct 09, 2018 7:06 pm
by Dbug
What you can do, is to use osdk_showmap to generated the memory map of your program and see if any area overlap with the music player.
If you are doing the program in C or assembler, you can put it wherever you want: The CALL#6000 thing was just because in had to work with BASIC.
If you integrate the player as an additional module to compile with your program, then it will just be added wherever you want, and you can have the depacking buffers as just a normal additional buffer somewhere in memory.

Re: Adding MYMPlayer to C

Posted: Tue Oct 09, 2018 7:11 pm
by Badger
Thanks, I'll give that a try :)

Re: Adding MYMPlayer to C

Posted: Tue Oct 09, 2018 7:26 pm
by Badger
I just figured out what I did to get the sedoric commands working.

I copied the sedoric.s (which had the _sedoric in it) into the scroller working directory and compiled with the c program.

This should have triggered in my brain that I should be able to do the same with the music player.... but it didnt :)

Re: Adding MYMPlayer to C

Posted: Tue Oct 09, 2018 7:39 pm
by Dbug
Could you give a shot at adding

Code: Select all

-sedoric.s
    _sedoric
at the end of your lib/library.ndx instead of copying the sedoric.s :) ?

If that works fine, I'll publish a new OSDK with this fix and the few other things Waskol signaled.

If we have too many persons working with too many differently patched version, it become difficult to find out what goes wrong.

Re: Adding MYMPlayer to C

Posted: Tue Oct 09, 2018 8:01 pm
by Badger
Works perfectly.

Re: Adding MYMPlayer to C

Posted: Sun Nov 10, 2019 5:18 pm
by waskol
Hello, I think we are far to have solved that issue.

At the end of the music, when it is supposed to stop gently, I face up an ugly white noise and then the music restarts from beginning (it is supposed to stop).
I have tried to put the _MusicLooped byte in mymplayer to 0, my library.ndx contains the 2 Sedoric lines (running OSDK 1.15).

My assembly knowledge is still approximative because I do not see why the music loops again.
It does the same in basic and C and I am pretty much sure there is no memory overlap.

One thing I would like to know also, I would like to display a simple vumeter of the 3 channels (based on the channel volumes).

I suppose I can chain the irq interupt from another sub program in order to leave the mymplayer code untouched, but I don't see how I can hook the channel volumes.

Thank you for help.

I attached my project.
The music is Big in Japan from Alphaville was composed with vortex tracker.

It sounds really good !!! until the end of the tune... ouch

Re: Adding MYMPlayer to C

Posted: Sun Nov 10, 2019 6:04 pm
by waskol
Just a thing, like that, croossing my mind.
May be there is some extra junk or something cut at the end of the data.
ay2mym ?
uncompresse process ?

Re: Adding MYMPlayer to C

Posted: Mon Nov 18, 2019 6:45 pm
by waskol
I partially solved my problem. I had to modify mymplayer.s

dec _MusicResetCounter+1 at line 284, it shortens the "white noise at the end) (damned, it's ugly!)
jmp EndMusic line 363 (stops the music and do not start over from the beginning)

what is almost sure is that ym2mym do the right job : if I produce a wav file with it the music plays till the last note without a glitch.