rendered paste body// Includes
#include <PA9.h> // Include for PA_Lib
int GetFileList(char *dir,int filenum){
int palnr;
char filename[255]; int fcount=2;
PA_SetBgPalCol(0, 1, PA_RGB(31, 31, 31));
PA_SetBgPalCol(0, 2, PA_RGB(31, 0, 0));
PA_SetBgPalCol(0, 3, PA_RGB(0, 0, 31));
PA_SetBgPalCol(0, 4, PA_RGB(0, 31, 0));
PA_SetBgPalCol(1, 1, PA_RGB(31, 31, 31));
PA_SetBgPalCol(1, 2, PA_RGB(31, 0, 0));
PA_SetBgPalCol(1, 3, PA_RGB(0, 0, 31));
PA_SetBgPalCol(1, 4, PA_RGB(0, 31, 0));
PA_Init8bitBg(0, 3);
PA_Init8bitBg(1, 3);
FAT_InitFiles();
FAT_chdir(dir);
FAT_FindFirstFile(filename);
PA_SmartText(1, 0, 1, 255, 7, "File Browser", 2, 0, 0, 100);
if(filenum==1){
palnr=4;
} else {
palnr=1;
}
FAT_GetLongFilename(filename);
PA_SmartText(1, 0, 7, 255, 14, filename, palnr, 0, 0, 100);
while(FAT_FindNextFile(filename)!=0){
if(filenum==fcount){
palnr=4;
} else {
palnr=1;
}
fcount++;
FAT_GetLongFilename(filename);
PA_SmartText(1, 0, 7*(fcount-1), 255, 7*fcount, filename, palnr, 0, 0, 100);
}
PA_InitText(0, 0);
PA_OutputText(0, 1, 11, " %d, %d ", fcount, filenum);
return fcount;
}
// Function: main()
int main(int argc, char ** argv)
{
int filenum;
int cnt;
PA_Init(); // Initializes PA_Lib
PA_InitVBL(); // Initializes a standard VBL
filenum=1;
cnt = GetFileList("/",filenum);
// Infinite loop to keep the program running
while (1)
{
PA_WaitForVBL();
// PA_UpdatePad();
if(Pad.Newpress.Up){
filenum--;
cnt = GetFileList("/",filenum);
}
if(Pad.Newpress.Down){
filenum++;
cnt = GetFileList("/",filenum);
}
}
return 0;
} // End of main()