- return true; // Made it!
-}
-
-
-//
-// Get length of sample from WAV format
-//
-uint32_t GetWAVLength(fstream & file)
-{
- char ch;
- uint32_t len;
-
- file.ignore(16); // Skip header BS
-
- for(int i=0; i<2; i++)
- {
- file.get(ch); len = (int)(uint8_t)ch;
- file.get(ch); len |= (int)(uint8_t)ch << 8;
- file.get(ch); len |= (int)(uint8_t)ch << 16;
- file.get(ch); len |= (int)(uint8_t)ch << 24;
-
- // Skip intermediate data
- file.ignore(len + 4);
- }
-
- // & finally get length of data
- file.get(ch); len = (int)(uint8_t)ch;
- file.get(ch); len |= (int)(uint8_t)ch << 8;
- file.get(ch); len |= (int)(uint8_t)ch << 16;
- file.get(ch); len |= (int)(uint8_t)ch << 24;
-
- return len;
-}
-
-
-#if 0
-//
-// Load PSG samples from disk
-//
-void LoadPSGs(void)
-{
- char file[40];
- char ch;
- uint32_t len;
-
- for(int i=0; i<16; i++)
- {
- fstream fp;
-
- psg_adrs[i] = NULL; // Zero out pointer
- sprintf(file, "./sounds/psg%i.wav", i); // Create filename
-
- fp.open(file, ios::binary | ios::in); // Attempt to open it...
-
- if (fp)
- {
- len = GetWAVLength(fp); // Get WAV data length...
- psg_adrs[i] = new uint8_t[len]; // Attempt to allocate space...
-
- if (psg_adrs[i] != NULL)
- {
- for(int j=0; j<(signed)len; j++)
- {
- fp.get(ch);
- psg_adrs[i][j] = ch; // & load it in...
- }
-
- psg_lens[i] = len;
- printf("Found sample file: %s\t[Length: %u]\n", file, len);
- }
-
- fp.close();
- }
- }