equal
deleted
inserted
replaced
72 _fio.usage_count[slot]++; |
72 _fio.usage_count[slot]++; |
73 } |
73 } |
74 #endif /* LIMITED_FDS */ |
74 #endif /* LIMITED_FDS */ |
75 |
75 |
76 /* Seek to a file and a position */ |
76 /* Seek to a file and a position */ |
77 void FioSeekToFile(uint32 pos) |
77 void FioSeekToFile(uint8 slot, uint32 pos) |
78 { |
78 { |
79 FILE *f; |
79 FILE *f; |
80 #if defined(LIMITED_FDS) |
80 #if defined(LIMITED_FDS) |
81 /* Make sure we have this file open */ |
81 /* Make sure we have this file open */ |
82 FioRestoreFile(pos >> 24); |
82 FioRestoreFile(slot); |
83 #endif /* LIMITED_FDS */ |
83 #endif /* LIMITED_FDS */ |
84 f = _fio.handles[pos >> 24]; |
84 f = _fio.handles[slot]; |
85 assert(f != NULL); |
85 assert(f != NULL); |
86 _fio.cur_fh = f; |
86 _fio.cur_fh = f; |
87 _fio.filename = _fio.filenames[pos >> 24]; |
87 _fio.filename = _fio.filenames[slot]; |
88 FioSeekTo(GB(pos, 0, 24), SEEK_SET); |
88 FioSeekTo(pos, SEEK_SET); |
89 } |
89 } |
90 |
90 |
91 byte FioReadByte() |
91 byte FioReadByte() |
92 { |
92 { |
93 if (_fio.buffer == _fio.buffer_end) { |
93 if (_fio.buffer == _fio.buffer_end) { |
178 #if defined(LIMITED_FDS) |
178 #if defined(LIMITED_FDS) |
179 FioFreeHandle(); |
179 FioFreeHandle(); |
180 #endif /* LIMITED_FDS */ |
180 #endif /* LIMITED_FDS */ |
181 f = FioFOpenFile(filename); |
181 f = FioFOpenFile(filename); |
182 if (f == NULL) error("Cannot open file '%s'", filename); |
182 if (f == NULL) error("Cannot open file '%s'", filename); |
|
183 uint32 pos = ftell(f); |
183 |
184 |
184 FioCloseFile(slot); // if file was opened before, close it |
185 FioCloseFile(slot); // if file was opened before, close it |
185 _fio.handles[slot] = f; |
186 _fio.handles[slot] = f; |
186 _fio.filenames[slot] = filename; |
187 _fio.filenames[slot] = filename; |
187 #if defined(LIMITED_FDS) |
188 #if defined(LIMITED_FDS) |
188 _fio.usage_count[slot] = 0; |
189 _fio.usage_count[slot] = 0; |
189 _fio.open_handles++; |
190 _fio.open_handles++; |
190 #endif /* LIMITED_FDS */ |
191 #endif /* LIMITED_FDS */ |
191 FioSeekToFile(slot << 24); |
192 FioSeekToFile(slot, pos); |
192 } |
193 } |
193 |
194 |
194 const char *_subdirs[NUM_SUBDIRS] = { |
195 const char *_subdirs[NUM_SUBDIRS] = { |
195 "", |
196 "", |
196 "save" PATHSEP, |
197 "save" PATHSEP, |