+batari Posted July 2, 2009 Share Posted July 2, 2009 (edited) Here is a driver written in bB that can play music generated from SID2TIA in your bB programs. Make sure you include all of the relevant parts of the attached .bas file (that is, all of it except for the stuff in vblank, which is just intended to display something on the screen while trying out your music files.) One issue is that SID2TIA produces an output file (tsmsong.h) with a hard-coded ORG, so I hex-edited SID2TIA.EXE to comment out this line because it doesn't work with bB (and a hard-coded ORG is too limiting, anyway.) The original SID2TIA can be found here. You must also use the attached music.h as the original format didn't work with bB (another hard-coded ORG.) The version I am attaching will work with bB and is also reverse-compatible with assembly programs requiring the old music.h. tsm2.zip Edited July 2, 2009 by batari Quote Link to comment Share on other sites More sharing options...
Animan Posted July 2, 2009 Share Posted July 2, 2009 Looks cool. I'll try it out later. Quote Link to comment Share on other sites More sharing options...
yuppicide Posted July 2, 2009 Share Posted July 2, 2009 Wow. Freakin awesome. Thanks! What do I use to compile or whatever now? I've been using "dasm tsm2.s -f3 -ofilename.bin", but unsure what to do here.. Quote Link to comment Share on other sites More sharing options...
+batari Posted July 2, 2009 Author Share Posted July 2, 2009 Wow. Freakin awesome. Thanks! What do I use to compile or whatever now? I've been using "dasm tsm2.s -f3 -ofilename.bin", but unsure what to do here.. Just create the tsmsong.h file using SID2TIA and build the tsm2.bas with bB. Or, take the contents of tsm2.bas and integrate it into your bB game you need everything but the vblank stuff. Quote Link to comment Share on other sites More sharing options...
yuppicide Posted July 2, 2009 Share Posted July 2, 2009 Oh.. *smacks forehead* duh. I'll try it out shortly. So, if knows where to correctly put the music if I create it with bB? If I stick it in myself, can I stick it anywhere? For example, my current game was 8K, but I ran into some space issues so I had to bump it to 16k, which leaves bank 3 completely empty. Bank 1 has 183 bytes, bank 2 has 1849 but the game isn't finished so I need more stuff to go here, and the last bank bB stores stuff in so it only has 1433 bytes left. Quote Link to comment Share on other sites More sharing options...
+batari Posted July 2, 2009 Author Share Posted July 2, 2009 Oh.. *smacks forehead* duh. I'll try it out shortly. So, if knows where to correctly put the music if I create it with bB? If I stick it in myself, can I stick it anywhere? For example, my current game was 8K, but I ran into some space issues so I had to bump it to 16k, which leaves bank 3 completely empty. Bank 1 has 183 bytes, bank 2 has 1849 but the game isn't finished so I need more stuff to go here, and the last bank bB stores stuff in so it only has 1433 bytes left. Yes, you can put it anywhere, provided some conditions are met. The following should go at or near the beginning of your code (at a minimum): include music.h set smartbranching on dim tempoCount=a const songendlo=<.songend const songendhi=>.songend dim soundPointerlo=soundPointer dim soundPointerhi=soundPointer+1 In the above example, one variable is dimmed as "a" but it could be any free variable you have. The rest of the code below all needs to go in the same bank, but it can go in any bank. This code initializes the music to the beginning. Do not call it every frame but only at the beginning of your program or at the end of your music so it will repeat. Keep the lines exactly as they appear below, except you may change the variable used for sdata (the example below uses "b" but note that sdata will also use the next variable "c.") rem THE FOLLOWING LINES MUST NOT BE BROKEN UP sdata soundPointer=b end goto songend inline tsmsong.h songend rem END OF UNBROKEN LINES rem this is to get past the goto songend and trick the sdata statement rem to point to the music file temp1=sread(soundPointer) temp1=sread(soundPointer) temp1=sread(soundPointer) This code must be called in every frame you want music: tempoCount=tempoCount+1 temp1=tempoCount^#TEMPODELAY if temp1<>0 then musicdone tempoCount=temp1 temp1=getsound(0) temp1=getsound(1) rem return value is of no consequence musicdone This is a check to see if the music is done. In tsm2.bas, it jumps to the sdata statement above so it can repeat your music. It could also be used to stop the music.) if soundPointerlo=songendlo && soundPointerhi=songendhi then restartmusic The functions and data statements below must be placed in the same bank (change audvol if you wish the volume to be less than 15.) In a bankswitched game, I'd recommend using "return thisbank" below. function getsound temp2=sread(soundPointer) if temp2=0 then AUDV0[temp1]=0:goto silence AUDF0[temp1]=temp2 temp2=temp2/32 AUDC0[temp1]=soundTypeArray[temp2] AUDV0[temp1]=audvol[temp1] silence return data soundTypeArray 4,6,7,8,15,12,1,3 end data audvol 15,15 end Quote Link to comment Share on other sites More sharing options...
yuppicide Posted July 2, 2009 Share Posted July 2, 2009 (edited) I'm trying it now for the first time and can't get anything to compile. Well, actually compilation completes.. just doesn't do anything. I am using vBB. I copied the new music.h to the includes directory. Not sure where to put my tsmsong.h file, so I put it in the includes directory and also the directory where I store the games I made. I copied tsm2.bas into the directory where I store the games I made. I set the romsize to 4k and get this: DASM V2.20.07, Macro Assembler (C)1988-2003 bytes of ROM space left -205 bytes of ROM space left 2600basic_variable_redefs.h (14): error: EQU: Value mismatch. old value: $000f new value: $0012 -205 bytes of ROM space left -205 bytes of ROM space left segment: ff9c vs current org: 10069 tsm2.bas.asm (2251): error: Origin Reverse-indexed. Aborting assembly Errors were encountered during assembly. 2600 Basic compilation completed. Compilation completed at 7/2/2009 12:24:22 PM view output file:///C:/atari2600/bB/bin If I set the romsize to 8k I get this: DASM V2.20.07, Macro Assembler (C)1988-2003 bytes of ROM space left in bank 1 bytes of ROM space left in bank 2 976 bytes of ROM space left in bank 1 2714 bytes of ROM space left in bank 2 976 bytes of ROM space left in bank 1 2714 bytes of ROM space left in bank 2 976 bytes of ROM space left in bank 1 2714 bytes of ROM space left in bank 2 --- Unresolved Symbol List SAW_F3 0000 ???? (R ) SAW_F4 0000 ???? (R ) SAW_F5 0000 ???? (R ) SQUARE_D5_2 0000 ???? (R ) LEAD_E3_2 0000 ???? (R ) LEAD_A4 0000 ???? (R ) LEAD_E4 0000 ???? (R ) LEAD_D4 0000 ???? (R ) SQUARE_Cw5_1 0000 ???? (R ) SAW_Aw3 0000 ???? (R ) SAW_Gw4 0000 ???? (R ) LEAD_Fw3_1 0000 ???? (R ) LEAD_Aw4 0000 ???? (R ) LEAD_Fw4 0000 ???? (R ) LEAD_Dw4 0000 ???? (R ) COMPILE_VERSION 0000 ???? SILENT 0000 ???? (R ) SQUARE_Fw5 0000 ???? (R ) SQUARE_Dw5 0000 ???? (R ) SQUARE_C5 0000 ???? (R ) NTSC 0000 ???? (R ) Fatal assembly error: Source is not resolvable. Errors were encountered during assembly. 2600 Basic compilation completed. Compilation completed at 7/2/2009 12:26:46 PM view output file:///C:/atari2600/bB/bin The song in question works fine when I compile with normal SID2TIA and I played it. Edited July 2, 2009 by yuppicide Quote Link to comment Share on other sites More sharing options...
+batari Posted July 2, 2009 Author Share Posted July 2, 2009 I'm trying it now for the first time and can't get anything to compile. Well, actually compilation completes.. just doesn't do anything. I am using vBB. I copied the new music.h to the includes directory. Not sure where to put my tsmsong.h file, so I put it in the includes directory and also the directory where I store the games I made. I copied tsm2.bas into the directory where I store the games I made. I set the romsize to 4k and get this: DASM V2.20.07, Macro Assembler (C)1988-2003 bytes of ROM space left -205 bytes of ROM space left 2600basic_variable_redefs.h (14): error: EQU: Value mismatch. old value: $000f new value: $0012 -205 bytes of ROM space left -205 bytes of ROM space left segment: ff9c vs current org: 10069 tsm2.bas.asm (2251): error: Origin Reverse-indexed. Aborting assembly Errors were encountered during assembly. 2600 Basic compilation completed. Compilation completed at 7/2/2009 12:24:22 PM view output file:///C:/atari2600/bB/bin This means that your tsmsong.h is too large to fit into 4k with the kernel and driver. SID2TIA thinks it has around 3.5k and it does when using the tsm2.s assembly file, but it does not have that much space in a 4k bB game. To reduce the song size, you might try increasing the value in the "Resolution" box to something like 4 or 8. Apparently with 4, you get up to 2 minutes of playback and 8 should give you 4 minutes. You may lose some accuracy in the song but often you don't. Regardless, I expect that it should work in the first bank of an 8k game. I believe your problem with 8k is that your "include music.h" is not in the first line of code and is being ignored. Quote Link to comment Share on other sites More sharing options...
Cybergoth Posted July 2, 2009 Share Posted July 2, 2009 One issue is that SID2TIA produces an output file (tsmsong.h) with a hard-coded ORG, so I hex-edited SID2TIA.EXE to comment out this line because it doesn't work with bB (and a hard-coded ORG is too limiting, anyway.) You're absolutely right. Here's an updated SID2TIA 1.6.3 package where I moved the ORG from the tool into the driver sid2tia.zip Quote Link to comment Share on other sites More sharing options...
yuppicide Posted July 2, 2009 Share Posted July 2, 2009 The song I have is not that long. Moving the set romsize 8k made the program compile just fine, but I get no sound totally though now though. Just a black screen. Where am I supposed to put tsmsong.h file? I've included my two files here.. songandbas.zip Quote Link to comment Share on other sites More sharing options...
Cybergoth Posted July 2, 2009 Share Posted July 2, 2009 SID2TIA thinks it has around 3.5k and it does when using the tsm2.s assembly file, but it does not have that much space in a 4k bB game. Here's an updated SID2TIA 1.6.4 package where I removed the write protection from the "Frames" edit control when generating TSM2 output. It still defaults and resets to 3.5K though sid2tia.zip Quote Link to comment Share on other sites More sharing options...
+batari Posted July 2, 2009 Author Share Posted July 2, 2009 The song I have is not that long. Moving the set romsize 8k made the program compile just fine, but I get no sound totally though now though. Just a black screen. Where am I supposed to put tsmsong.h file? I've included my two files here.. The vblank statement needs to go in the last bank. Quote Link to comment Share on other sites More sharing options...
yuppicide Posted July 3, 2009 Share Posted July 3, 2009 (edited) It is. I removed all the stuff in it so it's just vblank return thisbank I just wanna go your demo program working before I go messing with my real program. The song I have is not that long. Moving the set romsize 8k made the program compile just fine, but I get no sound totally though now though. Just a black screen. Where am I supposed to put tsmsong.h file? I've included my two files here.. The vblank statement needs to go in the last bank. Edited July 3, 2009 by yuppicide Quote Link to comment Share on other sites More sharing options...
+batari Posted July 3, 2009 Author Share Posted July 3, 2009 It is. I removed all the stuff in it so it's just vblank return thisbank I just wanna go your demo program working before I go messing with my real program. The song I have is not that long. Moving the set romsize 8k made the program compile just fine, but I get no sound totally though now though. Just a black screen. Where am I supposed to put tsmsong.h file? I've included my two files here.. The vblank statement needs to go in the last bank. Actually, it isn't unless you place "bank 2" before it. Either do that or remove vblank altogether. Quote Link to comment Share on other sites More sharing options...
yuppicide Posted July 3, 2009 Share Posted July 3, 2009 I do have bank 2 in my code. You said that one part of the codes needs to come in the beginning and the rest can all go in another bank if I wanted.. so I moved it all to bank 2. Quote Link to comment Share on other sites More sharing options...
+batari Posted July 3, 2009 Author Share Posted July 3, 2009 I do have bank 2 in my code. You said that one part of the codes needs to come in the beginning and the rest can all go in another bank if I wanted.. so I moved it all to bank 2. Oh, I see it now. The code doesn't necessarily have to be contiguous, but everything before vblank does need to be in the same bank. Quote Link to comment Share on other sites More sharing options...
yuppicide Posted July 4, 2009 Share Posted July 4, 2009 I put this in bank 1: include music.h set smartbranching on dim tempoCount=a const songendlo=<.songend const songendhi=>.songend dim soundPointerlo=soundPointer dim soundPointerhi=soundPointer+1 Everything else in bank2. That's how it would be in my real game also, except everything else in bank 3. I do have bank 2 in my code. You said that one part of the codes needs to come in the beginning and the rest can all go in another bank if I wanted.. so I moved it all to bank 2. Oh, I see it now. The code doesn't necessarily have to be contiguous, but everything before vblank does need to be in the same bank. Quote Link to comment Share on other sites More sharing options...
+batari Posted July 4, 2009 Author Share Posted July 4, 2009 I put this in bank 1: include music.h set smartbranching on dim tempoCount=a const songendlo=<.songend const songendhi=>.songend dim soundPointerlo=soundPointer dim soundPointerhi=soundPointer+1 Everything else in bank2. That's how it would be in my real game also, except everything else in bank 3. I do have bank 2 in my code. You said that one part of the codes needs to come in the beginning and the rest can all go in another bank if I wanted.. so I moved it all to bank 2. Oh, I see it now. The code doesn't necessarily have to be contiguous, but everything before vblank does need to be in the same bank. Unfortunately that won't work. You need to put the code to read the music in the same bank as the music itself. If the code to read it is in another bank than your game code, you will need to access music with an inter-bank goto or gosub once per frame. Quote Link to comment Share on other sites More sharing options...
yuppicide Posted July 4, 2009 Share Posted July 4, 2009 But that code below in bank 1 doesn't read anything.. it just includes music.h and dims things. I can't stick that stuff in bank 3 can I? I don't think so.. I put this in bank 1: include music.h set smartbranching on dim tempoCount=a const songendlo=<.songend const songendhi=>.songend dim soundPointerlo=soundPointer dim soundPointerhi=soundPointer+1 Everything else in bank2. That's how it would be in my real game also, except everything else in bank 3. I do have bank 2 in my code. You said that one part of the codes needs to come in the beginning and the rest can all go in another bank if I wanted.. so I moved it all to bank 2. Oh, I see it now. The code doesn't necessarily have to be contiguous, but everything before vblank does need to be in the same bank. Unfortunately that won't work. You need to put the code to read the music in the same bank as the music itself. If the code to read it is in another bank than your game code, you will need to access music with an inter-bank goto or gosub once per frame. Quote Link to comment Share on other sites More sharing options...
+batari Posted July 4, 2009 Author Share Posted July 4, 2009 (edited) But that code below in bank 1 doesn't read anything.. it just includes music.h and dims things. I see tsmsong.h in there as well as the dims. tsmsong.h is the music data which needs to be in the same bank as the code that reads it. Here is something that should compile: tsm2.bas Edited July 4, 2009 by batari Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.