1 /* 2 * OpenBOR - http://www.chronocrash.com 3 * ----------------------------------------------------------------------- 4 * All rights reserved, see LICENSE in OpenBOR root for details. 5 * 6 * Copyright (c) 2004 - 2014 OpenBOR Team 7 */ 8 9 #ifndef SPK_SUPPORTED 10 11 #ifndef PACKFILE_H 12 #define PACKFILE_H 13 14 #include <stdio.h> 15 #include <dirent.h> 16 17 #ifndef WIN 18 #include <unistd.h> 19 #define O_BINARY 0 20 #endif 21 22 #ifdef SDL 23 #include <SDL.h> 24 #endif 25 26 #ifdef PSP 27 #include "image.h" 28 #endif 29 30 // 31 // Structure used for handling packfiles 32 // 33 typedef struct pnamestruct 34 { 35 unsigned int pns_len; // Length of the struct in bytes 36 unsigned int filestart; // Start position of referenced file 37 unsigned int filesize; // Size of referenced file 38 char namebuf[80]; // Buffer to hold the file's name 39 } pnamestruct; 40 41 typedef struct fileliststruct 42 { 43 char filename[128]; 44 int nTracks; 45 char bgmFileName[256][80]; 46 int bgmTrack; 47 unsigned int bgmTracks[256]; 48 #ifdef SDL 49 SDL_Surface *preview; 50 #elif PSP 51 Image *preview; 52 #endif 53 } fileliststruct; 54 55 #define NUMPACKHANDLES 8 56 #define PACKVERSION 0x00000000 57 #define testpackfile(filename, packfilename) closepackfile(openpackfile(filename, packfilename)) 58 59 extern int printFileUsageStatistics; 60 61 // All of these return -1 on error 62 int openpackfile(const char *filename, const char *packfilename); 63 int readpackfile(int handle, void *buf, int len); 64 int closepackfile(int handle); 65 int seekpackfile(int handle, int offset, int whence); 66 int pak_init(); 67 void pak_term(); 68 void packfile_mode(int mode); 69 int pakopen(const char *filename, int mode); 70 int pakread(int fd, void *buf, int len); 71 void pakclose(int fd); 72 int paklseek(int fd, int n, int whence); 73 int openreadaheadpackfile(const char *filename, const char *packfilename, int readaheadsize, int prebuffersize); 74 int readpackfile_noblock(int fd, void *buf, int len); 75 int packfileeof(int fd); 76 int packfile_supported(struct dirent *ds); 77 void packfile_music_read(struct fileliststruct *filelist, int dListTotal); 78 int packfile_music_play(struct fileliststruct *filelist, FILE *bgmFile, int bgmLoop, int curPos, int scrPos); 79 void freefilenamecache(void); 80 81 #endif 82 83 #endif 84