PAlib: PA_GBFS.h Source File

Main Page | Modules | File List | Globals | Search for

# PA_GBFS.h

Go to the documentation of this file.

    00001 #ifndef _PA_GBFS
    00002 #define _PA_GBFS
    00003
    00004 #ifdef __cplusplus
    00005 extern "C" {
    00006 #endif
    00007
    00015 #include "PA_Text.h"
    00016 #include "gbfs.h"
    00017
    00018 extern inline u8 PA_CompareText(char *text1, char *text2){
    00019        u8 ok = 1; // Devrait etre bon
    00020        u8 i = 0;
    00021        while(ok && text2[i]){
    00022               if (text1[i] != text2[i]) ok = 0;
    00023               i++;
    00024        }
    00025        return ok;
    00026 }
    00027
    00028
    00029 typedef struct{
    00030        void *File; // Position du fichier...
    00031        char Name[30]; // Nom du fichier, sans extension
    00032        char Ext[6]; // Extension du fichier !
    00033        u32 Length; // Longueur
    00034 } PA_GBFS_infos;
    00035 extern PA_GBFS_infos PA_GBFSfile[200];
    00036 extern s16 PA_GBFS_nfiles;
    00037 extern GBFS_FILE const* PA_GBFS_FILE;
    00038
    00049 extern inline u32 PA_InitGBFS(void){
    00050 s16 dot = 0;
    00051 s16 i = 0;
    00052
    00053        WAIT_CR &= ~0x80;
    00054
    00055        PA_GBFS_FILE = find_first_gbfs_file((void*)0x08000000);
    00056        PA_GBFS_nfiles = 0;
    00057        PA_GBFSfile[PA_GBFS_nfiles].File = (void*)gbfs_get_nth_obj(PA_GBFS_FILE, PA_GBFS_nfiles, (char*)PA_GBFSfile[PA_GBFS_nfiles].Name, &PA_GBFSfile[PA_GBFS_nfiles].Length);
    00058
    00059 while(PA_GBFSfile[PA_GBFS_nfiles].File != NULL){
    00060
    00061        // On cherche la fin du nom
    00062        while(PA_GBFSfile[PA_GBFS_nfiles].Name[i]) i++;
    00063        // On en déduit le dernier point, pour avoir l'extension
    00064        while(PA_GBFSfile[PA_GBFS_nfiles].Name[i] != '.') i--; // On cherche l'extension
    00065        dot = i+1;
    00066
    00067        for (i = 0; PA_GBFSfile[PA_GBFS_nfiles].Name[i+dot] ; i++){
    00068               PA_GBFSfile[PA_GBFS_nfiles].Ext[i] = PA_GBFSfile[PA_GBFS_nfiles].Name[i+dot];
    00069               if (('A' <= PA_GBFSfile[PA_GBFS_nfiles].Ext[i])&&(PA_GBFSfile[PA_GBFS_nfiles].Ext[i] <= 'Z')) PA_GBFSfile[PA_GBFS_nfiles].Ext[i] += 'a' - 'A'; // On passe en minuscule
    00070               PA_GBFSfile[PA_GBFS_nfiles].Ext[i+1] = 0;
    00071               PA_GBFSfile[PA_GBFS_nfiles].Name[i+dot-1] = 0;
    00072               if (PA_GBFSfile[PA_GBFS_nfiles].Name[i+dot-2] == '.') PA_GBFSfile[PA_GBFS_nfiles].Name[i+dot-2] = 0;
    00073        }
    00074        PA_GBFSfile[PA_GBFS_nfiles].Name[dot] = 0;
    00075        PA_GBFSfile[PA_GBFS_nfiles].Ext[dot] = 0;
    00076
    00077        ++PA_GBFS_nfiles; // On ajoute un objet...
    00078        PA_GBFSfile[PA_GBFS_nfiles].File = (void*)gbfs_get_nth_obj(PA_GBFS_FILE, PA_GBFS_nfiles, (char*)PA_GBFSfile[PA_GBFS_nfiles].Name, &PA_GBFSfile[PA_GBFS_nfiles].Length);
    00079 }
    00080
    00081 return PA_GBFS_nfiles;
    00082 }
    00083
    00084
    00085
    00100 extern inline s32 PA_GetGBFSFile(s16 start, char *name, char *extension){
    00101 s16 i;
    00102
    00103 for (i = start; i < PA_GBFS_nfiles; i++){
    00104        if (PA_CompareText(PA_GBFSfile[i].Name, name)&& PA_CompareText(PA_GBFSfile[i].Ext, extension))
    00105               return i;
    00106 }
    00107
    00108 return -1;
    00109 }
    00110
    00111
    00123 s16 PA_GBFSSearchExt(s16 *array, char *extension);
    00124
    00125  // end of GBFS
    00127
    00128
    00129 #ifdef __cplusplus
    00130 }
    00131 #endif
    00132
    00133 #endif
    00134
    00135