Kiiro_Yakumo

Pseudo Fat Music

Jul 9th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. #include <PA9.h>
  2.  
  3. //#include "all_gfx.h"
  4.  
  5. #include <maxmod9.h>
  6. //#include "soundbank.h"
  7. //#include "soundbank_bin.h"
  8.  
  9. #include <fat.h>
  10.  
  11. int main()
  12. {
  13.     PA_Init();
  14.     PA_InitVBL();
  15.     PA_SetAutoCheckLid(0);
  16.     PA_InitText(0, 1);
  17.     PA_InitText(1, 1);
  18.    
  19.     fatInitDefault();
  20.    
  21.     FILE * pFile;
  22.     long lSize;
  23.     char * buffer;
  24.     size_t result;
  25.     //char * results;
  26.    
  27.     pFile = fopen ("fat:/music/music1.it", "rb");
  28.     if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
  29.    
  30.     // obtain file size:
  31.     fseek (pFile , 0 , SEEK_END);
  32.     lSize = ftell (pFile);
  33.     rewind (pFile);
  34.  
  35.     // allocate memory to contain the whole file:
  36.     buffer = (char*) malloc (sizeof(char)*lSize);
  37.     if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}
  38.  
  39.     // copy the file into the buffer:
  40.     result = fread (buffer,1,lSize,pFile);
  41.     if (result != lSize) {fputs ("Reading error",stderr); exit (3);}
  42.  
  43.     /* the whole file is now loaded in the memory buffer. */
  44.  
  45.     // terminate
  46.     /*fclose (pFile);
  47.     free (buffer);
  48.     return 0;*/
  49.    
  50.     //results = fread(buffer, 1, lSize, pFile);
  51.     mmInitDefaultMem((mm_addr)buffer);
  52.     mmLoad((mm_word)buffer);
  53.     mmStart( (mm_word)result, MM_PLAY_LOOP );
  54.    
  55.     while(1)
  56.     {
  57.        
  58.    
  59.     PA_WaitForVBL();
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment