Adding MYMPlayer to C

Since we do not have native C compilers on the Oric, this forum will be mostly be used by people using CC65 or the OSDK. But any general C related post will be welcome !
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Adding MYMPlayer to C

Post 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
flag_uk Amateurs built the Ark, Professionals built the Titanic.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Adding MYMPlayer to C

Post 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)
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: Adding MYMPlayer to C

Post 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
flag_uk Amateurs built the Ark, Professionals built the Titanic.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Adding MYMPlayer to C

Post 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.
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: Adding MYMPlayer to C

Post by Badger »

Thanks, I'll give that a try :)
flag_uk Amateurs built the Ark, Professionals built the Titanic.
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: Adding MYMPlayer to C

Post 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 :)
flag_uk Amateurs built the Ark, Professionals built the Titanic.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Adding MYMPlayer to C

Post 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.
User avatar
Badger
Pilot Officer
Posts: 84
Joined: Sat Sep 22, 2018 10:04 am
Location: Wigan, England

Re: Adding MYMPlayer to C

Post by Badger »

Works perfectly.
flag_uk Amateurs built the Ark, Professionals built the Titanic.
User avatar
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Re: Adding MYMPlayer to C

Post 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
Attachments
bij.zip
(10.1 KiB) Downloaded 350 times
User avatar
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Re: Adding MYMPlayer to C

Post 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 ?
User avatar
waskol
Flight Lieutenant
Posts: 414
Joined: Wed Jun 13, 2007 8:20 pm
Location: FRANCE, Paris

Re: Adding MYMPlayer to C

Post 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.
Attachments
mymplayer.zip
(3.66 KiB) Downloaded 364 times
Post Reply