void piggy_read_sounds() { ubyte * ptr; int i, sbytes; ptr = SoundBits; sbytes = 0; for (i=0; i<Num_sound_files; i++ ) { digi_sound *snd = &GameSounds[i]; if ( SoundOffset[i] > 0 ) { if ( piggy_is_needed(i) ) { cfseek( Piggy_fp, SoundOffset[i], SEEK_SET ); // Read in the sound data!!! snd->data = ptr; ptr += snd->length; sbytes += snd->length; cfread( snd->data, snd->length, 1, Piggy_fp ); } } } mprintf(( 0, "\nActual Sound usage: %d KB\n", sbytes/1024 )); }
void piggy_read_sounds(int pc_shareware) { ubyte * ptr; int i, sbytes; int lastsize = 0; ubyte * lastbuf = NULL; if (MacPig) { // Read Mac sounds converted to RAW format (too messy to read them directly from the resource fork code-wise) char soundfile[32] = "Sounds/sounds.array"; extern int ds_load(int skip, char * filename ); PHYSFS_file *array = PHYSFSX_openReadBuffered(soundfile); // hack for Mac Demo if (!array && (PHYSFSX_fsize(DEFAULT_PIGFILE_REGISTERED) == D1_MAC_SHARE_PIGSIZE)) { con_printf(CON_URGENT,"Warning: Missing Sounds/sounds.array for Mac data files"); return; } else if (array) { if (PHYSFS_read(array, Sounds, MAX_SOUNDS, 1) != 1) // make the 'Sounds' index array match with the sounds we're about to read in { con_printf(CON_URGENT,"Warning: Can't read Sounds/sounds.array: %s", PHYSFS_getLastError()); PHYSFS_close(array); return; } PHYSFS_close(array); } for (i = 0; i < MAX_SOUND_FILES; i++) { sprintf(soundfile, "SND%04d.raw", i); if (ds_load(0, soundfile) == 255) break; } return; } ptr = SoundBits; sbytes = 0; for (i=0; i<Num_sound_files; i++ ) { digi_sound *snd = &GameSounds[i]; if ( SoundOffset[i] > 0 ) { if ( piggy_is_needed(i) ) { PHYSFSX_fseek( Piggy_fp, SoundOffset[i], SEEK_SET ); // Read in the sound data!!! snd->data = ptr; #ifdef ALLEGRO ptr += snd->len; sbytes += snd->len; #else ptr += snd->length; sbytes += snd->length; #endif //Arne's decompress for shareware on all soundcards - [email protected] if (pc_shareware) { if (lastsize < SoundCompressed[i]) { if (lastbuf) d_free(lastbuf); lastbuf = d_malloc(SoundCompressed[i]); } PHYSFS_read( Piggy_fp, lastbuf, SoundCompressed[i], 1 ); sound_decompress( lastbuf, SoundCompressed[i], snd->data ); } else #ifdef ALLEGRO PHYSFS_read( Piggy_fp, snd->data, snd->len, 1 ); #else PHYSFS_read( Piggy_fp, snd->data, snd->length, 1 ); #endif } } } if (lastbuf) d_free(lastbuf); }