#143712 - Cid2Mizard - Thu Oct 25, 2007 3:22 pm
I have a problem for create a FAT Player .mod, when i opened my first .mod it's good but with the 2nd i have no sound and a bug.
When you touch the name of .mod, it's played... enjoy
Where is my probl?me ?
_________________
www.nintendomax.com 100% Hack 0% Warez
When you touch the name of .mod, it's played... enjoy
Code: |
#include <PA9.h> #include <fat.h> #include <sys/dir.h> #include <stdio.h> #define MAX_FILENAME_LEN 256; void ManipFichier(int number); char * buffer; typedef struct{ char filename[100]; char name[100]; char ext[10]; u32 size; } PAfiletype; PAfiletype files[50]; extern inline char PA_GetSmall(char letter){ if((letter >= 'A')&&(letter <= 'Z')) return (letter-'A'+'a'); return letter; } s16 PA_FATSearchExt(DIR_ITER* dir, PAfiletype *filelist, char *ext){ s16 number = 0; u8 i, j; struct stat st; while (dirnext(dir, filelist[number].filename, &st) == 0) { if(!(st.st_mode & S_IFDIR)){ i = 0; while( filelist[number].filename[i]) i++; while( filelist[number].filename[i-1] != '.') i--; u8 same = 1; for(j = 0; ext[j]; j++) if(PA_GetSmall(ext[j]) != PA_GetSmall(filelist[number].filename[i+j])) same = 0; // not right extension if(same){ for(j = 0; j < i-1; j++) filelist[number].name[j] = filelist[number].filename[j]; filelist[number].name[j] = 0; for(i = 0; ext[i]; i++) filelist[number].ext[i] = ext[i]; filelist[number].ext[i] = 0; filelist[number].size = st.st_size; number++; } } } return number; } void ManipFichier(int number) { char * debut; char * fin; u32 modSize; FILE * modFile; strcpy(debut, "//mods//"); fin = files[number].filename; strcat(debut, fin); PA_OutputText(1, 1, 4, "Nom : %s ", files[number].filename); modFile = fopen(debut, "rb"); fseek (modFile, 0 , SEEK_END); modSize = ftell (modFile); rewind (modFile); PA_OutputText(1, 1, 6, "Taille: %d ", modSize); PA_OutputText(1, 1, 12, "strcat: %s ", debut); buffer = (char*) malloc (sizeof(char)*modSize); PA_OutputSimpleText(1, 1, 8, "Copie mod au buffer"); fread (buffer,1,modSize,modFile); fclose (modFile); PA_OutputSimpleText(1, 1, 10, "Complet Fichier Ferm?"); } int main (void) { PA_Init(); PA_InitVBL(); PA_InitSound(); PA_InitText(0, 0); PA_InitText(1, 0); PA_WaitForVBL(); fatInitDefault(); s32 i; DIR_ITER* dir; dir = diropen ("/Mods/"); u32 FileNumber = PA_FATSearchExt(dir, files, "mod"); for (i = 0; i < FileNumber; i++) PA_OutputSimpleText(0, 0, 0 + i, files[i].filename); s16 nfile = 0; s32 k; char filename[256] = "Mods/"; for(k = 0; k < 200; k++) filename[k+5] = files[nfile].filename[k]; u8 LectureEnCours=0; while(1) { if (Stylus.Newpress) { nfile = ((Stylus.Y)/8); if(LectureEnCours==1) { PA_StopMod(); free(buffer); LectureEnCours = 0; } if (nfile < 0) nfile = 0; if (nfile >= FileNumber-1) nfile = FileNumber-1; PA_OutputText(1, 1, 2, "Numero :%d ", nfile); ManipFichier(nfile); PA_OutputSimpleText(1, 1, 14, "Lecture du .mod"); PA_PlayMod(buffer); LectureEnCours = 1; } PA_WaitForVBL(); } return 0; } |
Where is my probl?me ?
_________________
www.nintendomax.com 100% Hack 0% Warez