diff --git a/Makefile b/Makefile index 8f1b4df..d3a14c0 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ p_doors.o p_enemy.o p_floor.o p_inter.o p_lights.o p_map.o p_maputl.o \ p_mobj.o p_plats.o p_pspr.o p_saveg.o p_setup.o p_sight.o p_spec.o \ p_switch.o p_telept.o p_tick.o p_user.o r_bsp.o r_data.o r_draw.o \ r_main.o r_plane.o r_segs.o r_sky.o r_things.o s_sound.o sounds.o \ -st_lib.o st_stuff.o tables.o v_video.o w_wad.o wi_stuff.o z_zone.o ps2doom.o mixer_thread.o mixer.o sjpcm_rpc.o usbd.s usbhdfsd.s SJPCM.s +st_lib.o st_stuff.o tables.o v_video.o w_wad.o wi_stuff.o z_zone.o ps2doom.o mixer_thread.o mixer.o cosmitoFileIO.o sjpcm_rpc.o usbd.s usbhdfsd.s SJPCM.s EE_BIN = ps2doom.elf diff --git a/Whatsthis.txt b/Whatsthis.txt index dda3313..6e8c84c 100644 --- a/Whatsthis.txt +++ b/Whatsthis.txt @@ -1,6 +1,6 @@ -Is is version 1.0.2.2 of PS2Doom, a port of Doom for the PS2, started by Lukasz Bruun (http://lukasz.dk) and currently maintained by me, cosmito (http://ps2homebrewing.wordpress.com). It also features audio support functions by Jason Yu (http://www.jasonyu.net). +Is is version 1.0.3.0 of PS2Doom, a port of Doom for the PS2, started by Lukasz Bruun (http://lukasz.dk) and currently maintained by me, cosmito (http://ps2homebrewing.wordpress.com). It also features audio support functions by Jason Yu (http://www.jasonyu.net). -Run PS2Doom.elf using uLaunchELF and make sure you have a doom1.wad, doom.wad, or doom2.wad copied at the root of a USB pen attached to tou PS2 (put only one .wad at the USB pen since currently no selector is made). +Run PS2Doom.elf using uLaunchELF and make sure you have a doom1.wad, doom.wad, or doom2.wad copied at the same directory as the ps2doom.elf. Memory cards and USB storage devices can be used and also. Currently HD support is not implemented. Put only one .wad at a time since currently no selector is made yet. Dualshock Joystick mappings: @@ -23,7 +23,7 @@ Analog Right click: Brightness (gamma) Please note: Enter key action (required to menu operations like starting new game) is a bit clumsy for now. For bringing up the menu, use the Cross button but to select items, use the Start button. This will be fixed. -You can use any USB compatible with the PlayStation2 also. +You can use any USB compatible keyboard with the PlayStation2 also. Source is included. Also a Visual Studio 2005 project just for code browsing (it doesn't compile). @@ -45,6 +45,10 @@ cosmito History: ======== +01/05/2009 - v1.0.3.0 + - 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 + 20/04/2009 - v1.0.2.2 - Enabled game save/load to memory card (mc0:). Use R1 e R2 buttons to write funny savenames - Nicer 'debug' font (thanks NoEffex and Allen http://forums.ps2dev.org/viewtopic.php?t=11663) diff --git a/cosmitoFileIO.c b/cosmitoFileIO.c new file mode 100644 index 0000000..06254fb --- /dev/null +++ b/cosmitoFileIO.c @@ -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 +#include + +// 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 diff --git a/d_main.c b/d_main.c index d8f6dcc..0688853 100644 --- a/d_main.c +++ b/d_main.c @@ -86,6 +86,7 @@ static int access(char *file, int mode) #include "p_setup.h" #include "r_local.h" +#include "cosmitoFileIO.h" #include "d_main.h" @@ -588,11 +589,20 @@ void IdentifyVersion (void) char *home; char *doomwaddir; + +#ifdef _EE + char elfFilename[100]; + char deviceName[10]; + char fullPath[100]; +#endif + doomwaddir = getenv("DOOMWADDIR"); #ifdef _EE //doomwaddir = ""; - doomwaddir = "mass:"; + //doomwaddir = "mass:"; + GetElfFilename(myargv[0], deviceName, fullPath, elfFilename); + doomwaddir = fullPath; #else if (!doomwaddir) doomwaddir = "./"; diff --git a/i_main.c b/i_main.c index 00e0e0f..512596d 100644 --- a/i_main.c +++ b/i_main.c @@ -57,6 +57,9 @@ static char s_pUDNL [] __attribute__( ( section( ".data" ), aligned( 1 ) ) #include //for GetThreadId #include +#include "cosmitoFileIO.h" + + extern int SAMPLECOUNT; int getDisplayModeFromELFName(char **argv); @@ -74,8 +77,9 @@ int main( int argc, char** argv ) SifInitRpc(0); init_scr(); - scr_printf(" --==== PS2DOOM v1.0.2.2 ====--\n\n"); - scr_printf(" A Doom PS2 port started by Lukasz Bruun and improved by cosmito\n\n\n"); + //scr_printf(" --==== PS2DOOM v1.0.2.2 ====--\n\n"); + //scr_printf(" A Doom PS2 port started by Lukasz Bruun and improved by cosmito\n\n\n"); + scr_printf(" --==== PS2DOOM v1.0.3.0 ====--\n\n\n"); int ret; printf("sample: kicking IRXs\n"); diff --git a/i_system.c b/i_system.c index b611372..281ab97 100644 Binary files a/i_system.c and b/i_system.c differ diff --git a/ps2sdldoom_VS2005/ps2sdldoom_VS2005.suo b/ps2sdldoom_VS2005/ps2sdldoom_VS2005.suo index 157c47f..692617f 100644 Binary files a/ps2sdldoom_VS2005/ps2sdldoom_VS2005.suo and b/ps2sdldoom_VS2005/ps2sdldoom_VS2005.suo differ diff --git a/ps2sdldoom_VS2005/ps2sdldoom_VS2005.vcproj b/ps2sdldoom_VS2005/ps2sdldoom_VS2005.vcproj index 140dc37..ccd425a 100644 --- a/ps2sdldoom_VS2005/ps2sdldoom_VS2005.vcproj +++ b/ps2sdldoom_VS2005/ps2sdldoom_VS2005.vcproj @@ -1,614 +1,622 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/w_wad.c b/w_wad.c index 09ee98b..bd10f44 100644 --- a/w_wad.c +++ b/w_wad.c @@ -312,7 +312,7 @@ void W_InitMultipleFiles (char** filenames) { scr_clear(); scr_printf ("\n\nERROR at W_InitFiles: no files found\n\n"); - scr_printf ("Put a .WAD file into the root of a USB pen or USB hard disk before running Doom.\n\n"); + scr_printf ("Put a .WAD file along with PS2Doom.elf before running it.\n\n"); SleepThread(); }