From cc821af39d994ccac83b4a6dbcb609c0a2bf24f6 Mon Sep 17 00:00:00 2001 From: infvaL <38145742+infval@users.noreply.github.com> Date: Sun, 15 Apr 2018 05:09:55 +0300 Subject: [PATCH] Fix black line on real PS2 * Fix black line (main.c) * Code formatting (browser.c) --- README.md | 1 + src/drivers/ps2/browser.c | 461 +++++++++++++++++++------------------- src/drivers/ps2/main.c | 7 +- 3 files changed, 236 insertions(+), 233 deletions(-) diff --git a/README.md b/README.md index 90c251f..e38b7c1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ FCEUmm-PS2 =========== +[![forthebadge](https://forthebadge.com/images/badges/contains-technical-debt.svg)](https://forthebadge.com) [Download](https://github.com/infval/Fceumm-PS2/releases) binary release (ELF file). diff --git a/src/drivers/ps2/browser.c b/src/drivers/ps2/browser.c index 3ffdbdf..1b96144 100644 --- a/src/drivers/ps2/browser.c +++ b/src/drivers/ps2/browser.c @@ -35,40 +35,42 @@ extern GSFONTM *gsFontM; extern u32 old_pad[2]; static struct padButtonStatus buttons[2]; -extern int defaultx,defaulty; +extern int defaultx, defaulty; int oldselect = -1; s8 selected = 0; u8 selected_dir = 0; extern int FONT_HEIGHT; char path[4096] = "path"; -int needed_path[2] = {-1,-1}; +int needed_path[2] = { -1, -1 }; char mpartitions[4][256]; -u16 history[20]; //20 levels should be enough +u16 history[20]; // 20 levels should be enough u8 h = 0; extern int Browser_Menu(); -static inline char* strzncpy(char *d, char *s, int l) { d[0] = 0; return strncat(d, s, l); } +static inline char* strzncpy(char *d, const char *s, size_t l) { d[0] = 0; return strncat(d, s, l); } char* browseup(char *path) { char *temp; - if((temp = strrchr(path,'/')) != NULL) {//temp = address of first / path equals mc0:/folder/folder/ + if ((temp = strrchr(path, '/')) != NULL) { // temp = address of first / path equals mc0:/folder/folder/ printf("There is a /\n"); - *temp = 0;//stores (\0) at address of first / and path equals mc0:/folder/folder - if((temp = strrchr(path,'/')) != NULL) {//temp = address of second / + *temp = 0; // Stores (\0) at address of first / and path equals mc0:/folder/folder + if ((temp = strrchr(path, '/')) != NULL) { // temp = address of second / printf("There is a /\n"); - temp++; //adjusts address to after second / - *temp = 0;//stores 0 at address after second / and path now equals mc0:/folder/ or mc0: + temp++; // Adjusts address to after second / + *temp = 0; // Stores 0 at address after second / and path now equals mc0:/folder/ or mc0: } else { - path[0] = 0;//sets the first char in path to \0 + path[0] = 0; // Sets the first char in path to \0 printf("There is no /\n"); - strcpy(path,"path"); + strcpy(path, "path"); } - } else { - path[0] = 0; strcpy(path,"path"); + } + else { + path[0] = 0; + strcpy(path, "path"); } return path; @@ -76,41 +78,41 @@ char* browseup(char *path) int RomBrowserInput(int files_too, int inside_menu) { - //was easier just to c&p and replace port with 0 + // Was easier just to c&p and replace port with 0 int ret[2]; u32 paddata[2]; u32 new_pad[2]; u16 slot = 0; - ret[1]=0; + ret[1] = 0; - //check to see if pads are disconnected - ret[0]=padGetState(0, slot); - if((ret[0] != PAD_STATE_STABLE) && (ret[0] != PAD_STATE_FINDCTP1)) { - if(ret[0]==PAD_STATE_DISCONN) { + // Check to see if pads are disconnected + ret[0] = padGetState(0, slot); + if ((ret[0] != PAD_STATE_STABLE) && (ret[0] != PAD_STATE_FINDCTP1)) { + if (ret[0] == PAD_STATE_DISCONN) { printf("Pad(%d, %d) is disconnected\n", 0, slot); } - ret[0]=padGetState(0, slot); + ret[0] = padGetState(0, slot); } ret[0] = padRead(0, slot, &buttons[0]); // port, slot, buttons if (ret[0] != 0) { paddata[0]= 0xffff ^ buttons[0].btns; - new_pad[0] = paddata[0] & ~old_pad[0]; // buttons pressed AND NOT buttons previously pressed + new_pad[0] = paddata[0] & ~old_pad[0]; // Buttons pressed AND NOT buttons previously pressed old_pad[0] = paddata[0]; - if(new_pad[0] & PAD_LEFT) { + if (new_pad[0] & PAD_LEFT) { } - if(new_pad[0] & PAD_DOWN) { + if (new_pad[0] & PAD_DOWN) { ret[1] = 1; } - if(new_pad[0] & PAD_RIGHT) { + if (new_pad[0] & PAD_RIGHT) { } - if(new_pad[0] & PAD_UP) { + if (new_pad[0] & PAD_UP) { ret[1] = -1; } - if((new_pad[0] & PAD_SELECT) && !inside_menu) { + if ((new_pad[0] & PAD_SELECT) && !inside_menu) { ret[0] = Browser_Menu(); if (ret[0] == 1) { oldselect = -3; @@ -122,13 +124,13 @@ int RomBrowserInput(int files_too, int inside_menu) oldselect = -1; } } - if(new_pad[0] & PAD_TRIANGLE) { + if (new_pad[0] & PAD_TRIANGLE) { oldselect = -4; } - if(new_pad[0] & PAD_CIRCLE) { + if (new_pad[0] & PAD_CIRCLE) { selected = 1; } - if((new_pad[0] & PAD_START) && inside_menu && !files_too) { + if ((new_pad[0] & PAD_START) && inside_menu && !files_too) { selected_dir = 1; } } @@ -152,11 +154,11 @@ int listcdvd(const char *path, entries *FileEntry) { FileEntry[0].dircheck = 1; t = 1; - for (i=0; i 0) { - if ( n > 2046) { break; } - if((FIO_SO_ISDIR(buf.stat.mode)) && (!strcmp(buf.name,".") || !strcmp(buf.name,".."))) - continue; //makes sure no .. or .'s are listed since it's already there - if(FIO_SO_ISDIR(buf.stat.mode)) { + n = 1; + while (fioDread(dd, &buf) > 0) { + if (n > 2046) { break; } + if ((FIO_SO_ISDIR(buf.stat.mode)) && (!strcmp(buf.name, ".") || !strcmp(buf.name, ".."))) + continue; // Makes sure no .. or .'s are listed since it's already there + if (FIO_SO_ISDIR(buf.stat.mode)) { FileEntry[n].dircheck = 1; - strcpy(FileEntry[n].filename,buf.name); - strzncpy(FileEntry[n].displayname,FileEntry[n].filename,63); + strcpy(FileEntry[n].filename, buf.name); + strzncpy(FileEntry[n].displayname, FileEntry[n].filename, 63); n++; if (n >= 2046) break; } } - if(dd >= 0) { + if (dd >= 0) { fioDclose(dd); printf("Directory closed!\n"); } - if(files_too) { + if (files_too) { dd = 0; dd = fioDopen(path); - while(fioDread(dd, &buf) > 0) { - if ( n > 2046) { break; } - if(FIO_SO_ISREG(buf.stat.mode)) { + while (fioDread(dd, &buf) > 0) { + if (n > 2046) { break; } + if (FIO_SO_ISREG(buf.stat.mode)) { FileEntry[n].dircheck = 0; - strcpy(FileEntry[n].filename,buf.name); - strzncpy(FileEntry[n].displayname,FileEntry[n].filename,63); + strcpy(FileEntry[n].filename, buf.name); + strzncpy(FileEntry[n].displayname, FileEntry[n].filename, 63); n++; } } - if(dd >= 0) { + if (dd >= 0) { fioDclose(dd); printf("Directory closed!\n"); } } } - printf("listdir path = %s\n",path); + printf("listdir path = %s\n", path); } - printf("listdir path = %s\n",path); + printf("listdir path = %s\n", path); return n; } @@ -282,17 +283,17 @@ int listpfs(char *path, entries *FileEntry, int files_too) int dd, n = 0; iox_dirent_t buf; - if(!(strchr(path,'/'))) { //if path is not valid then load default device menu - strcpy(FileEntry[0].displayname,"mc0:"); - strcpy(FileEntry[1].displayname,"mc1:"); - strcpy(FileEntry[2].displayname,"mass:"); - strcpy(FileEntry[3].displayname,"hdd0:"); - strcpy(FileEntry[4].displayname,"cdfs:"); - strcpy(FileEntry[0].filename,"mc0:/"); - strcpy(FileEntry[1].filename,"mc1:/"); - strcpy(FileEntry[2].filename,"mass:/"); - strcpy(FileEntry[3].filename,"hdd0:/"); - strcpy(FileEntry[4].filename,"cdfs:"); + if (!(strchr(path, '/'))) { //if path is not valid then load default device menu + strcpy(FileEntry[0].displayname, "mc0:"); + strcpy(FileEntry[1].displayname, "mc1:"); + strcpy(FileEntry[2].displayname, "mass:"); + strcpy(FileEntry[3].displayname, "hdd0:"); + strcpy(FileEntry[4].displayname, "cdfs:"); + strcpy(FileEntry[0].filename, "mc0:/"); + strcpy(FileEntry[1].filename, "mc1:/"); + strcpy(FileEntry[2].filename, "mass:/"); + strcpy(FileEntry[3].filename, "hdd0:/"); + strcpy(FileEntry[4].filename, "cdfs:"); FileEntry[0].dircheck = 1; FileEntry[1].dircheck = 1; FileEntry[2].dircheck = 1; @@ -300,51 +301,51 @@ int listpfs(char *path, entries *FileEntry, int files_too) n = 4; } #ifdef CDSUPPORT - else if(!strncmp(path, "cdfs", 4)) { + else if (!strncmp(path, "cdfs", 4)) { n = listcdvd(path, FileEntry); } #endif else { - if((dd=fileXioDopen(path)) < 0) { + if ((dd = fileXioDopen(path)) < 0) { printf("Didn't open!\n"); return 0; } else { printf("Directory opened!\n"); - //adds pseudo folder .. to every folder opened as mass: reported none but mc0: did - strcpy(FileEntry[0].filename,".."); - strcpy(FileEntry[0].displayname,".."); + // Adds pseudo folder .. to every folder opened as mass: reported none but mc0: did + strcpy(FileEntry[0].filename, ".."); + strcpy(FileEntry[0].displayname, ".."); FileEntry[0].dircheck = 1; - n=1; - while(fileXioDread(dd, &buf) > 0) { - if(buf.stat.mode & FIO_S_IFDIR && (!strcmp(buf.name,".") || !strcmp(buf.name,".."))) + n = 1; + while (fileXioDread(dd, &buf) > 0) { + if (buf.stat.mode & FIO_S_IFDIR && (!strcmp(buf.name, ".") || !strcmp(buf.name, ".."))) continue; - if(buf.stat.mode & FIO_S_IFDIR) { + if (buf.stat.mode & FIO_S_IFDIR) { FileEntry[n].dircheck = 1; - strcpy(FileEntry[n].filename,buf.name); - strzncpy(FileEntry[n].displayname,FileEntry[n].filename,63); + strcpy(FileEntry[n].filename, buf.name); + strzncpy(FileEntry[n].displayname, FileEntry[n].filename, 63); n++; } - if(n > 2046) { break; } + if (n > 2046) { break; } } - if( dd > 0) { + if (dd > 0) { fileXioDclose(dd); printf("Directory closed!\n"); } - if(files_too) { + if (files_too) { dd = 0; dd = fileXioDopen(path); - while(fileXioDread(dd, &buf) > 0) { - if(buf.stat.mode & FIO_S_IFREG) { + while (fileXioDread(dd, &buf) > 0) { + if (buf.stat.mode & FIO_S_IFREG) { FileEntry[n].dircheck = 0; - strcpy(FileEntry[n].filename,buf.name); - strzncpy(FileEntry[n].displayname,FileEntry[n].filename,63); + strcpy(FileEntry[n].filename, buf.name); + strzncpy(FileEntry[n].displayname, FileEntry[n].filename, 63); n++; } - if(n > 2046) { break; } + if (n > 2046) { break; } } - if(dd >= 0) { + if (dd >= 0) { fileXioDclose(dd); printf("Directory closed!\n"); } @@ -354,7 +355,7 @@ int listpfs(char *path, entries *FileEntry, int files_too) return n; } -int listpartitions( entries *FileEntry) +int listpartitions(entries *FileEntry) { printf("List Partitions\n"); @@ -363,31 +364,31 @@ int listpartitions( entries *FileEntry) int n = 0; strcpy(FileEntry[n].filename, ".."); - strcpy(FileEntry[n].displayname,".."); + strcpy(FileEntry[n].displayname, ".."); FileEntry[n].dircheck = 1; - n=1; + n = 1; - if((hddFd=fileXioDopen("hdd0:")) < 0) + if ((hddFd = fileXioDopen("hdd0:")) < 0) return 0; - while(fileXioDread(hddFd, &hddEnt) > 0) { - if(n >= 500) + while (fileXioDread(hddFd, &hddEnt) > 0) { + if (n >= 500) break; - if((hddEnt.stat.attr != ATTR_MAIN_PARTITION) || (hddEnt.stat.mode != FS_TYPE_PFS)) + if ((hddEnt.stat.attr != ATTR_MAIN_PARTITION) || (hddEnt.stat.mode != FS_TYPE_PFS)) continue; - //Patch this to see if new CB versions use valid PFS format - //NB: All CodeBreaker versions up to v9.3 use invalid formats - if(!strncmp(hddEnt.name, "PP.",3)) { + // Patch this to see if new CB versions use valid PFS format + // NB: All CodeBreaker versions up to v9.3 use invalid formats + if (!strncmp(hddEnt.name, "PP.", 3)) { int len = strlen(hddEnt.name); - if(!strcmp(hddEnt.name+len-4, ".PCB")) + if (!strcmp(hddEnt.name + len - 4, ".PCB")) continue; } - if(!strncmp(hddEnt.name, "__", 2) && - strcmp(hddEnt.name, "__boot") && - strcmp(hddEnt.name, "__net") && - strcmp(hddEnt.name, "__system") && + if (!strncmp(hddEnt.name, "__", 2) && + strcmp(hddEnt.name, "__boot") && + strcmp(hddEnt.name, "__net") && + strcmp(hddEnt.name, "__system") && strcmp(hddEnt.name, "__sysconf") && strcmp(hddEnt.name, "__common")) continue; @@ -404,18 +405,18 @@ int listpartitions( entries *FileEntry) char *partname(char *d, const char *hdd_path) { - char *temp1; //first '/' - char *temp2; //second '/' + char *temp1; // First '/' + char *temp2; // Second '/' - temp1 = strchr(hdd_path,'/'); + temp1 = strchr(hdd_path, '/'); temp1++; temp2 = temp1; - while(*temp2 != '/') { temp2++; } + while (*temp2 != '/') { temp2++; } - memcpy(d, temp1, temp2-temp1); + memcpy(d, temp1, temp2 - temp1); - d[temp2-temp1] = 0; + d[temp2 - temp1] = 0; return d; } @@ -424,7 +425,7 @@ void unmountPartition(int pfs_number) { char pfs_str[6]; - sprintf(pfs_str,"pfs%d:",pfs_number); + sprintf(pfs_str, "pfs%d:", pfs_number); fileXioUmount(pfs_str); @@ -436,23 +437,23 @@ int mountPartition(char *name) char pfs_str[6]; char partition[256]; - partname(partition,name); + partname(partition, name); - for(i=0; i < 3; i++) { - printf("Mounted Partition %d: %s\n",i,mpartitions[i]); - if(!strcmp(mpartitions[i],partition)) { + for (i = 0; i < 3; i++) { + printf("Mounted Partition %d: %s\n", i, mpartitions[i]); + if (!strcmp(mpartitions[i], partition)) { printf("%s already mounted at pfs%d:!\n", partition, i); return i; } } - for(i=0; i < 3; i++) { //check for empty entry and mount there - if(mpartitions[i][0] == 0) { - strcpy(mpartitions[i],partition); //fill entry - sprintf(pfs_str,"pfs%d:", i); - sprintf(name,"hdd0:%s",partition); - printf("mount %s to %s\n",name, pfs_str); - if(fileXioMount(pfs_str, name, FIO_MT_RDWR) >= 0) { + for (i = 0; i < 3; i++) { // Check for empty entry and mount there + if (mpartitions[i][0] == 0) { + strcpy(mpartitions[i], partition); // Fill entry + sprintf(pfs_str, "pfs%d:", i); + sprintf(name, "hdd0:%s", partition); + printf("mount %s to %s\n", name, pfs_str); + if (fileXioMount(pfs_str, name, FIO_MT_RDWR) >= 0) { printf("mount success\n"); return i; } @@ -463,12 +464,12 @@ int mountPartition(char *name) } } } - //control reached past for-loop so manually mount at pfs3: + // Control reached past for-loop so manually mount at pfs3: unmountPartition(3); - strcpy(mpartitions[3],partition); //fill entry - sprintf(pfs_str,"pfs%d:", 3); - sprintf(name,"hdd0:%s",partition); - if(fileXioMount(pfs_str, name, FIO_MT_RDWR) >= 0) { + strcpy(mpartitions[3], partition); // Fill entry + sprintf(pfs_str, "pfs%d:", 3); + sprintf(name, "hdd0:%s", partition); + if (fileXioMount(pfs_str, name, FIO_MT_RDWR) >= 0) { printf("mount success\n"); return 3; } @@ -489,63 +490,63 @@ char* Browser(int files_too, int menu_id) int part_num = -1; int max_item = 21; - if(menu_id == 1) { - if(!strncmp(Settings.savepath,"pfs", 3)) + if (menu_id == 1) { + if (!strncmp(Settings.savepath, "pfs", 3)) part_num = needed_path[1]; } else if (menu_id == 2) { - if(!strncmp(Settings.elfpath,"pfs", 3)) + if (!strncmp(Settings.elfpath, "pfs", 3)) part_num = needed_path[0]; } - int menu_x1 = gsGlobal->Width*0.05; - int menu_y1 = gsGlobal->Height*0.05; - int menu_x2 = gsGlobal->Width*0.95; - int menu_y2 = gsGlobal->Height*0.95; + int menu_x1 = gsGlobal->Width * 0.05; + int menu_y1 = gsGlobal->Height * 0.05; + int menu_x2 = gsGlobal->Width * 0.95; + int menu_y2 = gsGlobal->Height * 0.95; int text_line = menu_y1 + 40; oldselect = -1; - //entries FileEntry[2048];// = malloc(sizeof(entries)*2048); + //entries FileEntry[2048]; // = malloc(sizeof(entries)*2048); entries *FileEntry = calloc(sizeof(entries), 2048); int list_offset = text_line; - //switch to one shot drawing queue + // Switch to one shot drawing queue gsKit_mode_switch(gsGlobal, GS_ONESHOT); gsKit_queue_reset(gsGlobal->Os_Queue); - gsGlobal->DrawOrder = GS_PER_OS; //draw one shot objects last + gsGlobal->DrawOrder = GS_PER_OS; // Draw one shot objects last char oldpath[2048]; - strcpy(oldpath,"oldpath"); + strcpy(oldpath, "oldpath"); - while(1) { //list loop - selection += RomBrowserInput(files_too,menu_id); + while (1) { // List loop + selection += RomBrowserInput(files_too, menu_id); - if(drawn_screen == 1) { //workaround for screenbuffer limitation in PAL mode + if (drawn_screen == 1) { // Workaround for screenbuffer limitation in PAL mode init_custom_screen(); oldselect = -3; } - if(old_pad[0] & PAD_DOWN) { + if (old_pad[0] & PAD_DOWN) { button_held++; - if(button_held >= 32767) { + if (button_held >= 32767) { button_held = 32767; selection++; } } - if(old_pad[0] & PAD_UP) { + if (old_pad[0] & PAD_UP) { button_held++; - if(button_held >= 32767) { + if (button_held >= 32767) { button_held = 32767; selection--; } } - if(!(old_pad[0] & PAD_UP) && !(old_pad[0] & PAD_DOWN)) { + if (!(old_pad[0] & PAD_UP) && !(old_pad[0] & PAD_DOWN)) { button_held = 0; } - if(Settings.display) { + if (Settings.display) { max_item = 25; } else { @@ -555,172 +556,172 @@ char* Browser(int files_too, int menu_id) max_item = 9; -//scan for direct commands from input function - if(oldselect == -4) { //just pushed triangle so go up a dir - //if path is in partition root AND current partition number is not needed - if (!strcmp(path,"pfs0:/") || !strcmp(path,"pfs1:/") || !strcmp(path,"pfs2:/") || !strcmp(path,"pfs3:/")) { + // Scan for direct commands from input function + if (oldselect == -4) { // Just pushed triangle so go up a dir + // If path is in partition root AND current partition number is not needed + if (!strcmp(path, "pfs0:/") || !strcmp(path, "pfs1:/") || !strcmp(path, "pfs2:/") || !strcmp(path, "pfs3:/")) { if (part_num != needed_path[0] || needed_path[1]) { unmountPartition(part_num); mpartitions[part_num][0] = 0; - strcpy(path,"hdd0:/"); + strcpy(path, "hdd0:/"); } else { - strcpy(path,"hdd0:/"); + strcpy(path, "hdd0:/"); } } else { - strcpy(path,browseup(path)); + strcpy(path, browseup(path)); } - if( h != 0 ) + if (h != 0 ) h = h - 1; selection = history[h]; oldselect = selection + 1; } - if(oldselect == -3) { //reset browser dimensions - menu_x1 = gsGlobal->Width*0.05; - menu_y1 = gsGlobal->Height*0.05; - menu_x2 = gsGlobal->Width*0.95; - menu_y2 = gsGlobal->Height*0.95; + if (oldselect == -3) { // Reset browser dimensions + menu_x1 = gsGlobal->Width * 0.05; + menu_y1 = gsGlobal->Height * 0.05; + menu_x2 = gsGlobal->Width * 0.95; + menu_y2 = gsGlobal->Height * 0.95; text_line = menu_y1 + 40; } -//list files below - if(strcmp(path,oldpath) != 0) { - if(!strncmp(path,"hdd0:/", 6)) { - if(!strcmp(path,"hdd0:/")) { //hdd0: selected so list partitions + // List files below + if (strcmp(path, oldpath) != 0) { + if (!strncmp(path, "hdd0:/", 6)) { + if (!strcmp(path, "hdd0:/")) { // hdd0: selected so list partitions n = listpartitions(FileEntry); } - else if(strcmp(path,"hdd0:/") > 0) { //hdd0:/partition, get partition name and mount - if((part_num = mountPartition(path)) != -1) { - sprintf(path,"pfs%d:/",part_num); //path becomes pfs0:/ - n = listpfs(path,FileEntry,files_too); - //n = listdir(path,FileEntry,files_too); + else if (strcmp(path, "hdd0:/") > 0) { // hdd0:/partition, get partition name and mount + if ((part_num = mountPartition(path)) != -1) { + sprintf(path, "pfs%d:/", part_num); // Path becomes pfs0:/ + n = listpfs(path, FileEntry, files_too); + //n = listdir(path, FileEntry, files_too); } else n = 0; } } - //else if(!strncmp(path,"pfs",3)) { - //n = listpfs(path,FileEntry,files_too); + //else if (!strncmp(path, "pfs", 3)) { + //n = listpfs(path, FileEntry, files_too); //} else { - n = listpfs(path,FileEntry,files_too); - //n = listdir(path,FileEntry,files_too); //n == max number of items + empty entry + n = listpfs(path, FileEntry, files_too); + //n = listdir(path, FileEntry, files_too); // n == max number of items + empty entry } - if(n == 0) { + if (n == 0) { path[0] = 0; - strcpy(path,"path"); - n = listpfs(path,FileEntry,files_too); - //n = listdir(path,FileEntry,files_too); + strcpy(path, "path"); + n = listpfs(path, FileEntry, files_too); + //n = listdir(path, FileEntry, files_too); } - strcpy(oldpath,path);//needed so listdir isn't called every loop - oldselect = -1; //so the screen draws on load - printf("n = %d\n",n); + strcpy(oldpath, path); // Needed so listdir isn't called every loop + oldselect = -1; // So the screen draws on load + printf("n = %d\n", n); } -//display list - if(selection > (n-1)) { selection = 0; }//selection-(n-1); } - if(selection < 0) { selection = (n-1); } - if(selection != oldselect) { + // Display list + if (selection > (n-1)) { selection = 0; } //selection-(n-1); } + if (selection < 0) { selection = (n-1); } + if (selection != oldselect) { - gsKit_clear(gsGlobal,GS_SETREG_RGBAQ(0x00,0x00,0x00,0x80,0x00)); - browser_primitive("FCEUltra PS2 B0.93 [x.2.1]","Browser", &BG_TEX, menu_x1, menu_y1, menu_x2, menu_y2); + gsKit_clear(gsGlobal, GS_SETREG_RGBAQ(0x00, 0x00, 0x00, 0x80, 0x00)); + browser_primitive("FCEUltra PS2 B0.93 [x.2.2]", "Browser", &BG_TEX, menu_x1, menu_y1, menu_x2, menu_y2); - if(selection > max_item) { + if (selection > max_item) { list_offset = text_line - (selection - max_item) * FONT_HEIGHT; } - if(selection <= max_item) { + if (selection <= max_item) { list_offset = text_line; } - for(i=0;i= menu_y2 - FONT_HEIGHT) { + for (i = 0; i < n; i++) { // Display list + if (i*16+list_offset >= menu_y2 - FONT_HEIGHT) { continue; } - if(i*16+list_offset < text_line) { + if (i*16+list_offset < text_line) { continue; } - if(i == selection) { - printXY(FileEntry[i].displayname,menu_x1+10,i*16+list_offset, 2, FCEUSkin.highlight, 1, 0); + if (i == selection) { + printXY(FileEntry[i].displayname, menu_x1+10, i*16+list_offset, 2, FCEUSkin.highlight, 1, 0); } else { - printXY(FileEntry[i].displayname,menu_x1+10,i*16+list_offset, 2, FCEUSkin.textcolor, 1, 0); + printXY(FileEntry[i].displayname, menu_x1+10, i*16+list_offset, 2, FCEUSkin.textcolor, 1, 0); } } DrawScreen(gsGlobal); } -//post list directory options + // Post list directory options drawn_screen++; - if(drawn_screen > 2) { + if (drawn_screen > 2) { drawn_screen = 2; } - if(oldselect == -2) { //Clean up my memory usage and exit to elf + if (oldselect == -2) { // Clean up my memory usage and exit to elf free(FileEntry); - RunLoaderElf(Settings.elfpath,"");//modify function to support hdd0:/partition/etc. paths + RunLoaderElf(Settings.elfpath, ""); // Modify function to support hdd0:/partition/etc. paths } oldselect = selection; - if(selected) { - if(!strcmp(FileEntry[selection].filename,"..")) { - //if path is in partition root AND current partition number is not needed - if (!strcmp(path,"pfs0:/") || !strcmp(path,"pfs1:/") || !strcmp(path,"pfs2:/")) { + if (selected) { + if (!strcmp(FileEntry[selection].filename, "..")) { + // If path is in partition root AND current partition number is not needed + if (!strcmp(path, "pfs0:/") || !strcmp(path, "pfs1:/") || !strcmp(path, "pfs2:/")) { if (part_num != needed_path[0] || needed_path[1]) { unmountPartition(part_num); mpartitions[part_num][0] = 0; - strcpy(path,"hdd0:/"); + strcpy(path, "hdd0:/"); } else { - strcpy(path,"hdd0:/"); + strcpy(path, "hdd0:/"); } } else { - strcpy(path,browseup(path)); + strcpy(path, browseup(path)); } - if( h != 0 ) + if (h != 0 ) h = h - 1; selection = history[h]; oldselect = selection + 1; selected = 0; } - else if(FileEntry[selection].dircheck) { //if directory - if(strchr(path,'/') == NULL) { //"path" is the value - strcpy(path,FileEntry[selection].filename); //copy device:/ to path + else if (FileEntry[selection].dircheck) { // If directory + if (strchr(path, '/') == NULL) { // "path" is the value + strcpy(path, FileEntry[selection].filename); // Copy device:/ to path history[h] = selection; h = h + 1; selection = 0; selected = 0; } else { - sprintf(path,"%s%s/",path,FileEntry[selection].filename); + sprintf(path, "%s%s/", path, FileEntry[selection].filename); history[h] = selection; h = h + 1; selection = 0; - printf("path is %s\n",path); + printf("path is %s\n", path); selected = 0; } } - else if(!FileEntry[selection].dircheck) { //if file - sprintf(path,"%s%s",path,FileEntry[selection].filename); + else if (!FileEntry[selection].dircheck) { // If file + sprintf(path, "%s%s", path, FileEntry[selection].filename); printf("rompath = %s\n", path); history[h] = selection; selected = 0; //free(FileEntry); - if(!strncmp(path,"pfs",3) && menu_id) - needed_path[0] = part_num; //part_num is -1 if not having browsed hdd + if (!strncmp(path, "pfs", 3) && menu_id) + needed_path[0] = part_num; // part_num is -1 if not having browsed hdd return (char *)path; } - } //end if file selected - if(selected_dir) { - if(!strncmp(path,"pfs",3) && menu_id) + } // End if file selected + if (selected_dir) { + if (!strncmp(path, "pfs", 3) && menu_id) needed_path[1] = part_num; - if(strcmp(path,"hdd0:/")) { + if (strcmp(path, "hdd0:/")) { //free(FileEntry); return (char *)path; } } - } //end list loop + } // End list loop } diff --git a/src/drivers/ps2/main.c b/src/drivers/ps2/main.c index 436ed29..d140393 100644 --- a/src/drivers/ps2/main.c +++ b/src/drivers/ps2/main.c @@ -901,11 +901,12 @@ void RenderFrame(const uint8 *frame) gsKit_texture_upload(gsGlobal, &NES_TEX); - /* execute render queue */ - gsKit_queue_exec(gsGlobal); - + // Don't swap these lines /* vsync and flip buffer */ gsKit_sync_flip(gsGlobal); + + /* execute render queue */ + gsKit_queue_exec(gsGlobal); } #ifdef SOUND_ON