/* Example code for loading and installing VAB data from the boot CD Copyright 1998 Dominic Collins Feel free to use this code in your games; it's much less annoying than downloading lots of pointless data through the serial link. :( To use, set the variables and #defines as appropriate. Then call InitSound() before using any music, and call Shutdown() before quitting. To play a SEQ using the loaded VAB, use SsSeqPlay(SEQNum[music], SSPLAY_PLAY, SSPLAY_INFINITY); or similar, where music=number of SEQ file to play. */ // Definitions used by the code: #define DATA_START (0x80090000) // Start of VAB data #define VH_Start_Addr (DATA_START) // Start of VH data #define VB_Start_Addr (VH_Start_Addr+0xED00) //Start of VB data #define Number_of_Musics 3 // Number of SEQ files in game (max 32) // Start addresses of SEQ data; // Change to whatever, or use the Batch File Assistant program. #define Seq1_Start_Addr 0x80100d00 #define Seq2_Start_Addr (Seq1_Start_Addr+Seq1_Length) #define Seq3_Start_Addr (Seq1_Start_Addr+Seq1_Length+Seq2_Length) // Variables char musicflag=1; CdlFILE fp; // File pointer for loading files u_char cdreadresult=0; // Result of file load (error or zero) short vabid; // VAB identifier short SEQNum[Number_of_Musics]; // SEQ identifier(s) // Pointers to SEQ files in memory ulong* SeqStart[Number_of_Musics]={ (ulong*) Seq1_Start_Addr, (ulong*) Seq2_Start_Addr, (ulong*) Seq3_Start_Addr }; InitSound() { // In case another game has changed the volume: printf("Setting main volume to maximum\n"); SsSetMVol(127, 127); printf("Loading VH data from CD..."); if (CdSearchFile(&fp, "\\DATA\\SOUND\\STD0.VH;1")!=0) { CdReadFile("\\data\\sound\\std0.vh;1", (u_long*)VH_Start_Addr, 0); printf("Reading data..."); CdReadSync(0, &cdreadresult); printf("Done!\n"); } else { printf("Load failed!\nSorry, no music...\n"); } printf("Loading VB data from CD..."); if (CdSearchFile(&fp, "\\DATA\\SOUND\\STD0.VB;1")!=0) { CdReadFile("\\data\\sound\\std0.vb;1", (u_long*)VB_Start_Addr, 0); printf("Reading data..."); CdReadSync(0, &cdreadresult); printf("Done!\n"); } else { printf("Load failed!\nSorry, no music...\n"); } printf("Installing instruments..."); vabid=SsVabTransfer((u_char*)VH_Start_Addr, (u_char*)VB_Start_Addr, -1, 1); if (vabid<0) { printf("Failed!\nSorry, no music.\n"); musicflag=0; /* Note that I deliberately did NOT set 'musicflag=0' when the load failed in case the VH and VB files have been downloaded normally (through the serial link). This could happen if you have a game which uses SEQ files or can play audio CDs instead. */ } else { printf("OK\nHouston, we have music!\n"); } if (musicflag) { for (i=0; i