multiple songs with savage engine

utzutz
edited May 2011 in Development
sorry friends, another thread with my stupid questions. maybe wos should introduce a noob section for people like me? :oops:

anyway, how does using multiple songs with the same player work?
i've tried the magic formula from the beepola help files but can't get it to work.

assuming i have the player and data of the first song compiled to 32768, and the next song data is at 37417.

the manual reads:

POKE playeraddr+59,songaddr-256 * int(songaddr/256)
POKE playeraddr+60,int(songaddr/256)

which, if i'm not mistaken, should sum up to

POKE 32827,41
POKE 32828,145

now when i RANDOMIZE USR 32768 it doesn't exactly produce the desired result. what am i doing wrong?

also how do i get it back to normal, aka how long is the player and where does the first song data start?
Post edited by utz on

Comments

  • edited May 2011
    The low byte should be 146 not 145.
  • utzutz
    edited May 2011
    ooops... true that. still doesn't work though.
  • edited May 2011
    utz wrote: »
    assuming i have the player and data of the first song compiled to 32768, and the next song data is at 37417.

    You should have the player at 32768. The first song data normally starts at 33774.
    also how do i get it back to normal, aka how long is the player and where does the first song data start?

    Same as above.

    Start by compiling a blank song from Beepola. So that you have the engine setup to play the first song automatically.

    Compile to address: 33774, your first written song using the song data only*.asm option.
    Open this asm file of your new song with Spin's assembler and assemble it, best to stay in 48k machine type as well. Note down the length in bytes that were assembled for your song. Now in Spin insert a tape for saving, name it songs.tap making sure to write the .tap extension. Type SAVE "song1" CODE 33774, lengthofsong1.

    Each time you want to add a song do this again but adding the length of the last song to the compile address, for the next song's compile address. This way you'll have the address of each song at the top of each of your .asm songs where it says ORG address.

    You can also save all the songs in one block with SAVE "songs" CODE 33774, lengthofsong1+lengthofsong2+length..etc

    At least I think this is correct.
  • utzutz
    edited May 2011
    will assembling the song data in spin produce a different result than compiling it directly to .tap (song data only) in beepola?

    anyway to cut short the guessing game i'll post the entire project here:

    http://home.arcor.de/ipcore/md2z.tzx.txt

    there are 4 songs on this musicdisk, only "lake vostok" (automatically selected, at 33774) and "can't stop" (at 37417) are savage. also i didn't add the poke to jump back to the first savage song yet.

    interestingly it does seem to work if i play "can't stop" immediately after loading the tape, but after a while it will crash and reset.
  • edited May 2011
    utz wrote: »
    will assembling the song data in spin produce a different result than compiling it directly to .tap (song data only) in beepola?

    anyway to cut short the guessing game i'll post the entire project here:

    http://home.arcor.de/ipcore/md2z.tzx.txt

    there are 4 songs on this musicdisk, only "lake vostok" (automatically selected, at 33774) and "can't stop" (at 37417) are savage. also i didn't add the poke to jump back to the first savage song yet.

    interestingly it does seem to work if i play "can't stop" immediately after loading the tape, but after a while it will crash and reset.

    Assembling to .tap is fine.

    Make sure you have the line, savebin "test.bin",begin,end-begin, in tritone's test.asm. The tritone engine is only 458 bytes long.

    When you compile your first tritone song, rename music.asm to music1.asm. Next compile rename music.asm to music2.asm. Then after you've compiled all your songs, make these changes to test.asm in tritone folder.

    I just put the whole text file, its very small.
        device zxspectrum48
    
    	org 49152
    
    begin
    	ld hl,(playlist)
    	jp tritone.play
    	jp begin
    
    playlist
    	defw musicData
    	defw musicDatb
    	defw musicDatc
    
    	include "tritone.asm"
    
    musicData
    	include "music1.asm"
    musicDatb
    	include "music2.asm"
    musicDatc
    	include "music3.asm"
    
    end
    	display /d,end-begin
    
    	savebin "test.bin",begin,end-begin
    

    Now before compiling this, open all your music*.asm and make sure this is at the very top of all of them. It should already be there, just add a TAB.
    	module
    
    And at the end of the file add this.
    	endmodule
    
    Then when you compile this you should have one engine with multiple songs. You can see how to add more than 3 songs. And you don't need to know their start addresses.

    To change the song from basic, just POKE startaddress+1,a. Where a=9 for first song on list, add 2 for the next song.
    Something like,

    5 LET tritone=49152
    10 IF INKEY$="" THEN GOTO 10
    20 IF INKEY$="1" THEN LET a=9
    30 IF INKEY$="2" THEN LET a=11
    etc.
    100 POKE tritone+1,a
    110 RANDOMIZE USR tritone

    #Edit
    If you've compiled tritone to an address that is not on a 256 byte boundary (e.g. $8000, $8100 etc), then do,
    PEEK tritone+1 ,to get the value of the first song. If its a high number 254, your next song will be 0 and tritone+2 will need to add 1 to it.
    Edit#

    The same method can be used for all of Shiru's engines.
    Hope this helps.

    Really nice music by the way, i like it. :)
    And nice screen as well.
  • utzutz
    edited May 2011
    that's a nice method, will keep it in mind for the next demo :)

    however my problem is with the savage engine, not the tritone engine ;)
  • edited May 2011
    Why two CLEARs? This operator moves so called RAMTOP variable, which tells Basic interpreter to not touch memory above certain address (through putting variables data, erasing program with NEW, etc). So, make just one CLEAR before load anything, and it should be one byte lower than lowest address used to load data. With beeper music and Basic demos it is 32767.

    Also, don't forget, SFX and Savage engines use IM2 interrupts, this means they use a bit of memory to store interrupt vector. By default it is 65024 - so don't put anything between 65024 and 65535, otherwise it will be corrupted by player.
  • utzutz
    edited May 2011
    Shiru wrote: »
    Why two CLEARs?

    ehehehe... maybe because i don't know **** about programming 8)

    anyway everything works now. will release the fixed version in a few days. thanx alot everyone!!!
Sign In or Register to comment.