forked from lukaszdk/ps2doom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Now loads the .wad from current directory. No need to put it at a root of a USB device anymore. As consequence, loads perfectly from memory card. - The Quit option menu now boots back to the OSD PS2 Browser
- Loading branch information
Pedro Duarte
committed
Mar 20, 2021
1 parent
a1188f1
commit c9bd49c
Showing
10 changed files
with
757 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#include "cosmitoFileIO.h" | ||
|
||
// Note: This calls fseek, so watch out... | ||
int GetFilesize(FILE * fd) | ||
{ | ||
int size; | ||
fseek(fd, 0, SEEK_END); | ||
size = (int)ftell(fd); | ||
fseek(fd, 0, SEEK_SET); | ||
return (size); | ||
} | ||
|
||
/// | ||
int GetWAVsize(char *filename) | ||
{ | ||
int size; | ||
FILE *wav; | ||
wav = fopen(filename, "rb"); | ||
|
||
if (wav != NULL) | ||
{ | ||
fseek(wav, 0, SEEK_END); | ||
size = (int)ftell(wav); | ||
size -= 0x30; | ||
fclose(wav); | ||
return size; | ||
} | ||
else | ||
return 0; | ||
} | ||
|
||
/// TBD | ||
//// Dynamically mallocs a signed char buffer and loads from file into it. res < 0 means error. | ||
//FILE AllocLoad_scharbuffer(char *filename, int optionalBufSize, int *res) | ||
//{ | ||
// FILE *fd; | ||
// int size; | ||
// | ||
// | ||
// if (optionalBufSize == 0) | ||
// | ||
//} | ||
|
||
/// | ||
void GetElfFilename(const char *argv0_probe, char* deviceName, char* fullPath, char* elfFilename) | ||
{ | ||
int i; | ||
|
||
int lenght = strlen(argv0_probe); | ||
int doispontosIndex = 0; | ||
int slashIndex = 0; | ||
int isFileOnRoot = 0; | ||
|
||
|
||
// locate '/' from the end of path | ||
for(i=lenght-1; i>=0; i--) | ||
{ | ||
if (argv0_probe[i] == '/') | ||
{ | ||
slashIndex = i; | ||
break; | ||
} | ||
} | ||
if (slashIndex == 0) | ||
isFileOnRoot = 1; // elf is located on root of device | ||
|
||
// locate ':' from the start of path | ||
for(i=0; i<lenght; i++) | ||
{ | ||
if (argv0_probe[i] == ':') | ||
{ | ||
doispontosIndex = i; | ||
break; | ||
} | ||
} | ||
|
||
// set deviceName to device name (ex: 'mass:', 'host:', 'mc0', etc) | ||
strncpy(deviceName, argv0_probe, doispontosIndex+1); | ||
deviceName[doispontosIndex+1] = 0; | ||
|
||
// set fullPath to full path (ex: 'mass:directory/', 'mass:directory1/directory2', etc (no limit over depth)) | ||
if (isFileOnRoot) | ||
strcpy(fullPath, deviceName); // fullPath = deviceName actually | ||
else | ||
{ | ||
strncpy(fullPath, argv0_probe, slashIndex+1); | ||
fullPath[slashIndex+1] = 0; | ||
} | ||
|
||
// set elfFilename | ||
if (isFileOnRoot) | ||
memcpy(elfFilename, argv0_probe + doispontosIndex + 1, lenght - doispontosIndex); | ||
else | ||
memcpy(elfFilename, argv0_probe + slashIndex + 1, lenght - slashIndex); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef _COSMITOFILEIO | ||
#define _COSMITOFILEIO | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
// Note: This calls fseek, so watch out... | ||
int GetFilesize(FILE * fd); | ||
|
||
int GetWAVsize(char *filename); | ||
|
||
void GetElfFilename(const char *argv0_probe, char* deviceName, char* fullPath, char* elfFilename); | ||
|
||
#endif // _COSMITOFILEIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Oops, something went wrong.