#include "../../pico_int.h"
#include "compiler.h"
-#ifdef __linux__
+#if defined(__linux__) && defined(ARM)
#include <sys/mman.h>
#endif
void PicoSVPInit(void)
{
-#ifdef __linux__
+#if defined(__linux__) && defined(ARM)
int ret;
ret = munmap(tcache, SSP_DRC_SIZE);
printf("munmap tcache: %i\n", ret);
static void PicoSVPShutdown(void)
{
-#ifdef __linux__
+#if defined(__linux__) && defined(ARM)
// also unmap tcache
PicoSVPInit();
#endif
svp = (void *) ((char *)tmp + 0x200000);
memset(svp, 0, sizeof(*svp));
-#ifdef __linux__
+#if defined(__linux__) && defined(ARM)
tmp = mmap(tcache, SSP_DRC_SIZE, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_SHARED|MAP_ANONYMOUS, -1, 0);
printf("mmap tcache: %p, asked %p\n", tmp, tcache);
#endif
\r
for (i = 0; i < count; i++)\r
{\r
- plat_get_root_dir(bios_path, sizeof(bios_path));\r
- strcat(bios_path, files[i]);\r
+ emu_make_path(bios_path, files[i], sizeof(bios_path) - 4);\r
strcat(bios_path, ".bin");\r
f = fopen(bios_path, "rb");\r
if (f) break;\r
if (ext) strcat(dst, ext);\r
}\r
\r
-static void make_config_cfg(char *cfg)\r
+void emu_make_path(char *buff, const char *end, int size)\r
{\r
- int len;\r
- len = plat_get_root_dir(cfg, 512);\r
- strncpy(cfg + len, PicoConfigFile, 512-6-1-len);\r
+ int pos, end_len;\r
+\r
+ end_len = strlen(end);\r
+ pos = plat_get_root_dir(buff, size);\r
+ strncpy(buff + pos, end, size - pos);\r
+ buff[size - 1] = 0;\r
+ if (pos + end_len > size - 1)\r
+ lprintf("Warning: path truncated: %s\n", buff);\r
+}\r
+\r
+static void make_config_cfg(char *cfg_buff_512)\r
+{\r
+ emu_make_path(cfg_buff_512, PicoConfigFile, 512-6);\r
if (config_slot != 0)\r
{\r
- char *p = strrchr(cfg, '.');\r
- if (p == NULL) p = cfg + strlen(cfg);\r
+ char *p = strrchr(cfg_buff_512, '.');\r
+ if (p == NULL)\r
+ p = cfg_buff_512 + strlen(cfg_buff_512);\r
sprintf(p, ".%i.cfg", config_slot);\r
}\r
- cfg[511] = 0;\r
+ cfg_buff_512[511] = 0;\r
}\r
\r
static void emu_setDefaultConfig(void)\r
}\r
\r
\r
-void emu_writelrom(void)\r
-{\r
- char cfg[512];\r
- make_config_cfg(cfg);\r
- config_writelrom(cfg);\r
-#ifndef NO_SYNC\r
- sync();\r
-#endif\r
-}\r
-\r
/* always using built-in font */\r
\r
#define mk_text_out(name, type, val) \\r
\r
void emu_init(void)\r
{\r
- char dir[256];\r
+ char path[512];\r
int pos;\r
\r
/* make dirs for saves */\r
- pos = plat_get_root_dir(dir, sizeof(dir) - 4);\r
- mkdir_path(dir, pos, "mds");\r
- mkdir_path(dir, pos, "srm");\r
- mkdir_path(dir, pos, "brm");\r
+ pos = plat_get_root_dir(path, sizeof(path) - 4);\r
+ mkdir_path(path, pos, "mds");\r
+ mkdir_path(path, pos, "srm");\r
+ mkdir_path(path, pos, "brm");\r
+\r
+ make_config_cfg(path);\r
+ config_readlrom(path);\r
\r
PicoInit();\r
PicoMessage = plat_status_msg_busy_next;\r
SRam.changed = 0;\r
}\r
\r
- if (!(currentConfig.EmuOpt & EOPT_NO_AUTOSVCFG))\r
- emu_writelrom();\r
+ if (!(currentConfig.EmuOpt & EOPT_NO_AUTOSVCFG)) {\r
+ char cfg[512];\r
+ make_config_cfg(cfg);\r
+ config_writelrom(cfg);\r
+#ifndef NO_SYNC\r
+ sync();\r
+#endif\r
+ }\r
\r
PicoExit();\r
}\r
int emu_read_config(int game, int no_defaults);
int emu_write_config(int game);
-void emu_writelrom(void);
char *emu_get_save_fname(int load, int is_sram, int slot);
int emu_check_save_file(int slot);
void emu_setSaveStateCbs(int gz);
+void emu_make_path(char *buff, const char *end, int size);
void emu_update_input(void);
void emu_textOut8 (int x, int y, const char *text);
void emu_textOut16(int x, int y, const char *text);
}\r
\r
// load custom font and selector (stored as 1st symbol in font table)\r
- readpng(menu_font_data, "skin/font.png", READPNG_FONT);\r
+ emu_make_path(buff, "skin/font.png", sizeof(buff));\r
+ readpng(menu_font_data, buff, READPNG_FONT);\r
// default selector symbol is '>'\r
memcpy(menu_font_data, menu_font_data + ((int)'>') * me_mfont_w * me_mfont_h / 2,\r
me_mfont_w * me_mfont_h / 2);\r
- readpng(menu_font_data, "skin/selector.png", READPNG_SELECTOR);\r
+ emu_make_path(buff, "skin/selector.png", sizeof(buff));\r
+ readpng(menu_font_data, buff, READPNG_SELECTOR);\r
\r
// load custom colors\r
- f = fopen("skin/skin.txt", "r");\r
+ emu_make_path(buff, "skin/skin.txt", sizeof(buff));\r
+ f = fopen(buff, "r");\r
if (f != NULL)\r
{\r
lprintf("found skin.txt\n");\r
{\r
unsigned char ucData[1024];\r
int nRead, i, nLen = 0;\r
- char binpath[1024];\r
+ char binpath[512];\r
FILE *fp;\r
\r
- strncpy(binpath, g_argv[0], 1023);\r
- binpath[1023] = 0;\r
- for (i = strlen(binpath); i > 0; i--)\r
- if (binpath[i] == '/') { binpath[i] = 0; break; }\r
- strcat(binpath, "/" CODE940_FILE);\r
-\r
+ emu_make_path(binpath, CODE940_FILE, sizeof(binpath));\r
fp = fopen(binpath, "rb");\r
if(!fp)\r
{\r
}
else
{
+ char buff[256];
+
// should really only happen once, on startup..
- readpng(g_screen_ptr, "skin/background.png", READPNG_BG);
+ emu_make_path(buff, "skin/background.png", sizeof(buff));
+ if (readpng(g_screen_ptr, buff, READPNG_BG) < 0)
+ memset(g_screen_ptr, 0, 320*240*2);
}
// copy to buffer2
}
else
{
+ char buff[256];
+
// should really only happen once, on startup..
- readpng(g_screen_ptr, "skin/background.png", READPNG_BG);
+ emu_make_path(buff, "skin/background.png", sizeof(buff));
+ if (readpng(g_screen_ptr, buff, READPNG_BG) < 0)
+ memset(g_screen_ptr, 0, 320*240*2);
}
memcpy(menu_bg_buffer, g_screen_ptr, 320*240*2);