Improve the BFile API in libfxcg
This commit is contained in:
parent
3bc23b89d0
commit
3df65755bc
3
README
3
README
|
@ -25,13 +25,10 @@ Technical support TODO:
|
|||
-> Supply more VRAM memory to internal allocator
|
||||
=> Merge internal heap into Z_Zone? (< 50 kB)
|
||||
=> Remove multiply-avoiding lookup tables?
|
||||
-> Rate-limit the game when overclocking
|
||||
-> Load/Save game would be very cool
|
||||
-> Reenable LTO if possible
|
||||
-> Built-in overclocking?
|
||||
-> SDL2 debug version support?
|
||||
-> Darken background in menu (some code does that somewhere?)
|
||||
-> Rate-limit
|
||||
|
||||
CGDoom used to be compiled with the mini-SDK. However, it's become quite
|
||||
difficult to get a copy of that. Instead, this port is built with a modified
|
||||
|
|
|
@ -212,15 +212,6 @@ typedef struct {
|
|||
int miTotalLength;
|
||||
} FileMapping;
|
||||
|
||||
/* Bfile's file info structure returned by filesystem search functions. */
|
||||
typedef struct
|
||||
{
|
||||
unsigned short id, type;
|
||||
unsigned long fsize, dsize;
|
||||
unsigned int property;
|
||||
unsigned long address;
|
||||
} Bfile_FileInfo;
|
||||
|
||||
/* Find WAD files in the filesystem. */
|
||||
int FindWADs(WADFileInfo *files, int max)
|
||||
{
|
||||
|
@ -531,14 +522,15 @@ static void DelayedWriteFile(int i)
|
|||
|
||||
Bfile_DeleteEntry(fc_path);
|
||||
|
||||
rc = Bfile_CreateEntry_OS(fc_path, CREATEMODE_FILE, (size_t *)&dfw->size);
|
||||
rc = Bfile_CreateEntry_OS(fc_path, BFILE_CREATEMODE_FILE,
|
||||
(size_t *)&dfw->size);
|
||||
if (rc < 0) {
|
||||
I_Error("Bfile_CreateEntry_OS(%s, %d bytes): %d", dfw->filename,
|
||||
dfw->size, rc);
|
||||
return;
|
||||
}
|
||||
|
||||
fd = Bfile_OpenFile_OS(fc_path, WRITE, 0);
|
||||
fd = Bfile_OpenFile_OS(fc_path, BFILE_WRITE, 0);
|
||||
if (fd < 0) {
|
||||
I_Error("Bfile_OpenFile_OS(%s): %d", dfw->filename, fd);
|
||||
return;
|
||||
|
|
|
@ -481,7 +481,7 @@ void M_ReadSaveStrings(void)
|
|||
fc_path[j+7] = name[j];
|
||||
fc_path[j+7] = 0x0000;
|
||||
|
||||
fd = Bfile_OpenFile_OS(fc_path, READ, 0);
|
||||
fd = Bfile_OpenFile_OS(fc_path, BFILE_READ, 0);
|
||||
|
||||
if(fd < 0) {
|
||||
strcpy(savegamestrings[i], EMPTYSTRING);
|
||||
|
|
|
@ -87,40 +87,6 @@ int M_DrawText ( int x, int y, boolean direct, char* string )
|
|||
*/
|
||||
|
||||
|
||||
//
|
||||
// M_WriteFile
|
||||
//
|
||||
boolean M_WriteFile(char const *name, const void *source, int length)
|
||||
{
|
||||
uint16_t fc_path[100] = u"\\\\fls0\\";
|
||||
size_t size = length;
|
||||
int j = 7;
|
||||
int rc, fd;
|
||||
|
||||
for (int i = 0; name[i]; i++)
|
||||
fc_path[j++] = name[i];
|
||||
fc_path[j++] = 0x0000;
|
||||
|
||||
Bfile_DeleteEntry(fc_path);
|
||||
|
||||
rc = Bfile_CreateEntry_OS(fc_path, CREATEMODE_FILE, &size);
|
||||
if (rc < 0) {
|
||||
/* Displaying the error message destroys the save data, so quit */
|
||||
I_Error("Bfile_CreateEntry_OS(%s, %d bytes): %d", name, length, rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
fd = Bfile_OpenFile_OS(fc_path, WRITE, 0);
|
||||
if (fd < 0) {
|
||||
I_Error("Bfile_OpenFile_OS(%s): %d", name, fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
Bfile_WriteFile_OS(fd, source, length);
|
||||
Bfile_CloseFile_OS(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// M_ReadFile
|
||||
//
|
||||
|
@ -134,7 +100,7 @@ int M_ReadFile(const char *name, byte **buffer)
|
|||
fc_path[j++] = name[i];
|
||||
fc_path[j++] = 0x0000;
|
||||
|
||||
fd = Bfile_OpenFile_OS(fc_path, READ, 0);
|
||||
fd = Bfile_OpenFile_OS(fc_path, BFILE_READ, 0);
|
||||
if (fd < 0) {
|
||||
I_Error("Bfile_OpenFile_OS(%s): %d", name, fd);
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue