Skip to content

Commit

Permalink
Add support for uma0
Browse files Browse the repository at this point in the history
  • Loading branch information
meetpatty committed Nov 16, 2017
1 parent c791b54 commit ff6373a
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 64 deletions.
5 changes: 3 additions & 2 deletions src/PSP2/gui_psp.cpp
Expand Up @@ -21,7 +21,8 @@
extern char *RequestFile (char *initialPath);

extern bool emerg_quit; // Flag: emergency quit requested


extern char psp_home[256];

/*
* OSK support code
Expand Down Expand Up @@ -194,7 +195,7 @@ void do_gui(struct gui_menu *menu, void *menufn, char *exit_msg)
sceCtrlPeekBufferPositive(0, &pad, 1);
if (*(int *)menu[csel].field1)
free(*(char **)menu[csel].field1);
strcpy(temp, HOME_DIR);
strcpy(temp, psp_home);
strcat(temp, (char *)menu[csel].field2);
strcat(temp, "/");
req = RequestFile(temp);
Expand Down
92 changes: 45 additions & 47 deletions src/PSP2/main_psp.cpp
Expand Up @@ -97,7 +97,13 @@ uint8 *ScratchMem = NULL; // Scratch memory for Mac ROM writes

bool emerg_quit = false; // Flag: emergency quit requested

char* psp_home = HOME_DIR;
char psp_home[256];
char temp[256];
char *partitions[] = { "ux0:", "uma0:" };
char *data_dir = "data/BasiliskII/";
char *data_sub_dirs[] = { "cdroms", "disks", "files", "hardfiles", "imaps", "roms" };
int num_partitions = 2;
int num_data_sub_dirs = 6;

int psp_net_error = 0;
int psp_net_available = 0;
Expand Down Expand Up @@ -154,42 +160,43 @@ int main(int argc, char **argv)

sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG);
sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START);

int d = sceIoDopen(HOME_DIR "cdroms");
if (d >= 0)
sceIoDclose(d);
else
sceIoMkdir(HOME_DIR "cdroms", 0777);

d = sceIoDopen(HOME_DIR "disks");
if (d >= 0)
sceIoDclose(d);
else
sceIoMkdir(HOME_DIR "disks", 0777);

d = sceIoDopen(HOME_DIR "files");
if (d >= 0)
sceIoDclose(d);
else
sceIoMkdir(HOME_DIR "files", 0777);

d = sceIoDopen(HOME_DIR "hardfiles");
if (d >= 0)
sceIoDclose(d);
else
sceIoMkdir(HOME_DIR "hardfiles", 0777);

d = sceIoDopen(HOME_DIR "imaps");
if (d >= 0)
sceIoDclose(d);
else
sceIoMkdir(HOME_DIR "imaps", 0777);

d = sceIoDopen(HOME_DIR "roms");
if (d >= 0)
sceIoDclose(d);
else
sceIoMkdir(HOME_DIR "roms", 0777);

// Print some info
psvDebugScreenClear(0xFF000000);
psvDebugScreenPrintf("\n\n ");
psvDebugScreenPrintf(Get_String(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR);
psvDebugScreenPrintf("\n %s\n", Get_String(STR_ABOUT_TEXT2));
sceKernelDelayThread(2*1000*1000);

int i, d, found = 0;
for (i = 0; i < num_partitions; i++) {
strcpy(psp_home, partitions[i]);
strcat(psp_home, data_dir);

d = sceIoDopen(psp_home);
if (d >= 0) {
sceIoDclose(d);
found = 1;
break;
}
}

if (!found) {
psvDebugScreenPrintf("\n\n ");
psvDebugScreenPrintf("Data directory not found! Exiting...");
sceKernelDelayThread(2*1000*1000);
return 0;
}

for (i = 0; i < num_data_sub_dirs; i++) {
strcpy(temp, psp_home);
strcat(temp, data_sub_dirs[i]);
d = sceIoDopen(temp);
if (d >= 0)
sceIoDclose(d);
else
sceIoMkdir(temp, 0777);
}

psp_time_init();

Expand All @@ -201,16 +208,7 @@ int main(int argc, char **argv)

// Initialize variables
RAMBaseHost = NULL;
ROMBaseHost = NULL;

// Print some info
psvDebugScreenSetBgColor(0xFF000000);
psvDebugScreenSetFgColor(0xFFFFFFFF);
psvDebugScreenClear(0xFF000000);
psvDebugScreenPrintf("\n\n ");
psvDebugScreenPrintf(Get_String(STR_ABOUT_TEXT1), VERSION_MAJOR, VERSION_MINOR);
psvDebugScreenPrintf("\n %s\n", Get_String(STR_ABOUT_TEXT2));
sceKernelDelayThread(2*1000*1000);
ROMBaseHost = NULL;

// Read preferences
PrefsInit(argc, argv);
Expand Down
15 changes: 10 additions & 5 deletions src/PSP2/prefs_editor_psp.cpp
Expand Up @@ -81,7 +81,8 @@ int psp_lcd_border = 1; // default to inverting the data
int psp_60hz_timing = 1; // default to relaxed timing

extern char *psp_floppy_inserted; // String: filename of floppy inserted
extern char *psp_cdrom_inserted; // String: filename of cdrom inserted
extern char *psp_cdrom_inserted; // String: filename of cdrom inserted
extern char psp_home[256];

// Memory support code

Expand Down Expand Up @@ -147,7 +148,7 @@ void psp_create_hardfile(void *arg)
if (!psp_hardfile)
return; // abort creation

strcpy(filename, HOME_DIR);
strcpy(filename, psp_home);
strcat(filename, "hardfiles/");
strcat(filename, psp_hardfile);
sprintf(textbuf, "Making %d MB hardfile:\n\n%s", filesize, filename);
Expand Down Expand Up @@ -189,7 +190,7 @@ void psp_create_floppy(void *arg)
if (!psp_hardfile)
return; // abort creation

strcpy(filename, HOME_DIR);
strcpy(filename, psp_home);
strcat(filename, "disks/");
strcat(filename, psp_hardfile);
sprintf(message, "Making 1.4 MB floppy:\n\n%s", filename);
Expand Down Expand Up @@ -645,8 +646,12 @@ bool PrefsEditor(void)
psp_floppy_inserted = psp_floppyfile;

PrefsRemoveItem("extfs");
if (psp_extfs_enable)
PrefsReplaceString("extfs", "files/");
if (psp_extfs_enable) {
char temp_path[256];
strcpy(temp_path, psp_home);
strcat(temp_path, "files");
PrefsReplaceString("extfs", temp_path);
}

PrefsReplaceInt32("pspspeed", psp_cpu_speed);

Expand Down
10 changes: 7 additions & 3 deletions src/PSP2/prefs_psp.cpp
Expand Up @@ -40,18 +40,22 @@ prefs_desc platform_prefs_items[] = {
{"relaxed60hz", TYPE_BOOLEAN, false, "Use relaxed timing for 60 Hz IRQ"},
{NULL, TYPE_END, false, NULL} // End of list
};


extern char psp_home[256];

// Preferences file name and path
const char PREFS_FILE_NAME[] = HOME_DIR "BasiliskII_prefs";
char PREFS_FILE_NAME[256];


/*
* Load preferences from settings file
*/

void LoadPrefs(void)
{
{
strcpy(PREFS_FILE_NAME, psp_home);
strcat(PREFS_FILE_NAME, "BasiliskII_prefs");

// Read preferences from settings file
FILE *f = fopen(PREFS_FILE_NAME, "r");
if (f != NULL) {
Expand Down
4 changes: 1 addition & 3 deletions src/PSP2/sysdeps.h
Expand Up @@ -36,9 +36,7 @@
#include <sys/time.h>
#include <time.h>

#define lerp(value, from_max, to_max) ((((value*10) * (to_max*10))/(from_max*10))/10)

#define HOME_DIR "ux0:data/BasiliskII/"
#define lerp(value, from_max, to_max) ((((value*10) * (to_max*10))/(from_max*10))/10)

/* Mac and host address space are distinct */
#define REAL_ADDRESSING 0
Expand Down
9 changes: 5 additions & 4 deletions src/PSP2/video_psp.cpp
Expand Up @@ -102,7 +102,8 @@ static int psp_lcd_aspect = 0; // 4:3

extern bool emerg_quit; // Flag: emergency quit requested
extern int FONT_SIZE;
extern vita2d_font *font;
extern vita2d_font *font;
extern char psp_home[256];

extern char *psp_floppy_inserted; // String: filename of floppy inserted
extern char *psp_cdrom_inserted; // String: filename of cdrom inserted
Expand Down Expand Up @@ -949,19 +950,19 @@ void handle_menu(SceCtrlData pad)

if (numcdroms == -1)
{
strcpy(temp, HOME_DIR);
strcpy(temp, psp_home);
strcat(temp, "cdroms");
numcdroms = parse_dir(temp, cdroms, MAXCDROMS);
}
if (numfloppies == -1)
{
strcpy(temp, HOME_DIR);
strcpy(temp, psp_home);
strcat(temp, "disks");
numfloppies = parse_dir(temp, floppies, MAXFLOPPIES);
}
if (numimaps == -1)
{
strcpy(temp, HOME_DIR);
strcpy(temp, psp_home);
strcat(temp, "imaps");
numimaps = parse_dir(temp, imaps, MAXIMAPS);
}
Expand Down

0 comments on commit ff6373a

Please sign in to comment.