// check for both gmv and rom\r
int dummy;\r
FILE *movie_file = fopen(rom_fname, "rb");\r
- if(!movie_file) {\r
+ if (!movie_file) {\r
me_update_msg("Failed to open movie.");\r
return 0;\r
}\r
fseek(movie_file, 0, SEEK_END);\r
movie_size = ftell(movie_file);\r
fseek(movie_file, 0, SEEK_SET);\r
- if(movie_size < 64+3) {\r
+ if (movie_size < 64+3) {\r
me_update_msg("Invalid GMV file.");\r
fclose(movie_file);\r
return 0;\r
}\r
movie_data = malloc(movie_size);\r
- if(movie_data == NULL) {\r
+ if (movie_data == NULL) {\r
me_update_msg("low memory.");\r
fclose(movie_file);\r
return 0;\r
}\r
- fread(movie_data, 1, movie_size, movie_file);\r
+ dummy = fread(movie_data, 1, movie_size, movie_file);\r
fclose(movie_file);\r
if (strncmp((char *)movie_data, "Gens Movie TEST", 15) != 0) {\r
me_update_msg("Invalid GMV file.");\r
sram_size = SRam.size;\r
sram_data = SRam.data;\r
}\r
- if (!sram_data) return 0; // SRam forcefully disabled for this game\r
+ if (sram_data == NULL)\r
+ return 0; // SRam forcefully disabled for this game\r
\r
if (load)\r
{\r
sramFile = fopen(saveFname, "rb");\r
- if(!sramFile) return -1;\r
- fread(sram_data, 1, sram_size, sramFile);\r
+ if (!sramFile)\r
+ return -1;\r
+ ret = fread(sram_data, 1, sram_size, sramFile);\r
+ ret = ret > 0 ? 0 : -1;\r
fclose(sramFile);\r
if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART))\r
memcpy32((int *)Pico_mcd->bram, (int *)sram_data, 0x2000/4);\r
lprintf("found skin.txt\n");\r
while (!feof(f))\r
{\r
- fgets(buff, sizeof(buff), f);\r
+ if (fgets(buff, sizeof(buff), f) == NULL)\r
+ break;\r
if (buff[0] == '#' || buff[0] == '/') continue; // comment\r
if (buff[0] == '\r' || buff[0] == '\n') continue; // empty line\r
if (strncmp(buff, "text_color=", 11) == 0)\r
\r
static int scandir_cmp(const void *p1, const void *p2)\r
{\r
- struct dirent **d1 = (struct dirent **)p1, **d2 = (struct dirent **)p2;\r
- if ((*d1)->d_type == (*d2)->d_type) return alphasort(d1, d2);\r
- if ((*d1)->d_type == DT_DIR) return -1; // put before\r
- if ((*d2)->d_type == DT_DIR) return 1;\r
+ const struct dirent **d1 = (const struct dirent **)p1;\r
+ const struct dirent **d2 = (const struct dirent **)p2;\r
+ if ((*d1)->d_type == (*d2)->d_type)\r
+ return alphasort(d1, d2);\r
+ if ((*d1)->d_type == DT_DIR)\r
+ return -1; // put before\r
+ if ((*d2)->d_type == DT_DIR)\r
+ return 1;\r
+\r
return alphasort(d1, d2);\r
}\r
\r
fname = p+1;\r
}\r
\r
- n = scandir(curr_path, &namelist, scandir_filter, scandir_cmp);\r
+ n = scandir(curr_path, &namelist, scandir_filter, (void *)scandir_cmp);\r
if (n < 0) {\r
lprintf("menu_loop_romsel failed, dir: %s\n", curr_path);\r
\r
// try root\r
- getcwd(curr_path, len);\r
- n = scandir(curr_path, &namelist, scandir_filter, scandir_cmp);\r
+ plat_get_root_dir(curr_path, len);\r
+ n = scandir(curr_path, &namelist, scandir_filter, (void *)scandir_cmp);\r
if (n < 0) {\r
// oops, we failed\r
lprintf("menu_loop_romsel failed, dir: %s\n", curr_path);\r
static int in_gp2x_get_wiz_bits(void)
{
- int value = 0;
- read(gpiodev, &value, 4);
+ int r, value = 0;
+ r = read(gpiodev, &value, 4);
if (value & 0x02)
value |= 0x05;
if (value & 0x08)
if (sounddev == -1)
{
perror("open(\"/dev/dsp\")");
- return -1;
+ sounddev = open("/dev/dsp1", O_WRONLY|O_ASYNC);
+ if (sounddev == -1) {
+ perror("open(\"/dev/dsp1\")");
+ return -1;
+ }
}
// calculate buffer size. We one to fit 1 frame worth of sound data.