#include "config.h"\r
#include "plat.h"\r
#include "input.h"\r
+#include "posix.h"\r
\r
#include <pico/pico_int.h>\r
#include <pico/patch.h>\r
currentConfig_t currentConfig, defaultConfig;\r
int state_slot = 0;\r
int config_slot = 0, config_slot_current = 0;\r
+int pico_pen_x = 320/2, pico_pen_y = 240/2;\r
int pico_inp_mode = 0;\r
int engineState = PGS_Menu;\r
\r
char rom_fname_reload[512] = { 0, };\r
char rom_fname_loaded[512] = { 0, };\r
int rom_loaded = 0;\r
+int reset_timing = 0;\r
\r
unsigned char *movie_data = NULL;\r
static int movie_size = 0;\r
\r
for (i = 0; i < count; i++)\r
{\r
- emu_getMainDir(bios_path, sizeof(bios_path));\r
+ plat_get_root_dir(bios_path, sizeof(bios_path));\r
strcat(bios_path, files[i]);\r
strcat(bios_path, ".bin");\r
f = fopen(bios_path, "rb");\r
for (; p >= rom_fname_loaded && *p != PATH_SEP_C; p--); p++;\r
*dst = 0;\r
if (prefix) {\r
- int len = emu_getMainDir(dst, 512);\r
+ int len = plat_get_root_dir(dst, 512);\r
strcpy(dst + len, prefix);\r
prefix_len = len + strlen(prefix);\r
}\r
static void make_config_cfg(char *cfg)\r
{\r
int len;\r
- len = emu_getMainDir(cfg, 512);\r
+ len = plat_get_root_dir(cfg, 512);\r
strncpy(cfg + len, PicoConfigFile, 512-6-1-len);\r
if (config_slot != 0)\r
{\r
}\r
}\r
\r
-void emu_RunEventsPico(unsigned int events)\r
+static void emu_msg_tray_open(void)\r
{\r
- if (events & (1 << 3)) {\r
+ plat_status_msg("CD tray opened");\r
+}\r
+\r
+void emu_reset_game(void)\r
+{\r
+ PicoReset();\r
+ reset_timing = 1;\r
+}\r
+\r
+void run_events_pico(unsigned int events)\r
+{\r
+ int lim_x;\r
+\r
+ if (events & PEV_PICO_SWINP) {\r
pico_inp_mode++;\r
if (pico_inp_mode > 2)\r
pico_inp_mode = 0;\r
break;\r
}\r
}\r
- if (events & (1 << 4)) {\r
+ if (events & PEV_PICO_PPREV) {\r
PicoPicohw.page--;\r
if (PicoPicohw.page < 0)\r
PicoPicohw.page = 0;\r
plat_status_msg("Page %i", PicoPicohw.page);\r
}\r
- if (events & (1 << 5)) {\r
+ if (events & PEV_PICO_PNEXT) {\r
PicoPicohw.page++;\r
if (PicoPicohw.page > 6)\r
PicoPicohw.page = 6;\r
plat_status_msg("Page %i", PicoPicohw.page);\r
}\r
+\r
+ if (pico_inp_mode == 0)\r
+ return;\r
+\r
+ /* handle other input modes */\r
+ if (PicoPad[0] & 1) pico_pen_y--;\r
+ if (PicoPad[0] & 2) pico_pen_y++;\r
+ if (PicoPad[0] & 4) pico_pen_x--;\r
+ if (PicoPad[0] & 8) pico_pen_x++;\r
+ PicoPad[0] &= ~0x0f; // release UDLR\r
+\r
+ lim_x = (Pico.video.reg[12]&1) ? 319 : 255;\r
+ if (pico_pen_y < 8)\r
+ pico_pen_y = 8;\r
+ if (pico_pen_y > 224 - PICO_PEN_ADJUST_Y)\r
+ pico_pen_y = 224 - PICO_PEN_ADJUST_Y;\r
+ if (pico_pen_x < 0)\r
+ pico_pen_x = 0;\r
+ if (pico_pen_x > lim_x - PICO_PEN_ADJUST_X)\r
+ pico_pen_x = lim_x - PICO_PEN_ADJUST_X;\r
+\r
+ PicoPicohw.pen_pos[0] = pico_pen_x;\r
+ if (!(Pico.video.reg[12] & 1))\r
+ PicoPicohw.pen_pos[0] += pico_pen_x / 4;\r
+ PicoPicohw.pen_pos[0] += 0x3c;\r
+ PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);\r
}\r
\r
static void do_turbo(int *pad, int acts)\r
*pad |= turbo_pad & (acts >> 8);\r
}\r
\r
-static void run_ui_events(unsigned int which)\r
+static void run_events_ui(unsigned int which)\r
{\r
if (which & (PEV_STATE_LOAD|PEV_STATE_SAVE))\r
{\r
if ((events ^ prevEvents) & PEV_FF) {\r
emu_changeFastForward(events & PEV_FF);\r
plat_update_volume(0, 0);\r
-// reset_timing = 1;\r
+ reset_timing = 1;\r
}\r
\r
events &= ~prevEvents;\r
\r
-// TODO if (PicoAHW == PAHW_PICO)\r
-// RunEventsPico(events);\r
+ if (PicoAHW == PAHW_PICO)\r
+ run_events_pico(events);\r
if (events)\r
- run_ui_events(events);\r
+ run_events_ui(events);\r
if (movie_data)\r
update_movie();\r
\r
prevEvents = (allActions[0] | allActions[1]) & PEV_MASK;\r
}\r
\r
+static void mkdir_path(char *path_with_reserve, int pos, const char *name)\r
+{\r
+ strcpy(path_with_reserve + pos, name);\r
+ if (plat_is_dir(path_with_reserve))\r
+ return;\r
+ if (mkdir(path_with_reserve, 0777) < 0)\r
+ lprintf("failed to create: %s\n", path_with_reserve);\r
+}\r
+\r
+void emu_init(void)\r
+{\r
+ char dir[256];\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
+\r
+ PicoInit();\r
+ PicoMessage = plat_status_msg_busy_next;\r
+ PicoMCDopenTray = emu_msg_tray_open;\r
+ PicoMCDcloseTray = menu_loop_tray;\r
+}\r
+\r
+void emu_finish(void)\r
+{\r
+ // save SRAM\r
+ if ((currentConfig.EmuOpt & EOPT_USE_SRAM) && SRam.changed) {\r
+ emu_SaveLoadGame(0, 1);\r
+ SRam.changed = 0;\r
+ }\r
+\r
+ if (!(currentConfig.EmuOpt & EOPT_NO_AUTOSVCFG))\r
+ emu_writelrom();\r
+\r
+ PicoExit();\r
+}\r
+\r
extern int state_slot;
extern int config_slot, config_slot_current;
extern unsigned char *movie_data;
+extern int reset_timing;
+
+#define PICO_PEN_ADJUST_X 4
+#define PICO_PEN_ADJUST_Y 2
+extern int pico_pen_x, pico_pen_y;
extern int pico_inp_mode;
extern char rom_fname_reload[512]; // ROM to try loading on next PGS_ReloadRom
};
+void emu_init(void);
+void emu_finish(void);
+
int emu_ReloadRom(char *rom_fname);
int emu_SaveLoadGame(int load, int sram);
+void emu_reset_game(void);
int emu_ReadConfig(int game, int no_defaults);
int emu_WriteConfig(int game);
#define PEVB_SSLOT_NEXT 24
#define PEVB_MENU 23
#define PEVB_FF 22
+#define PEVB_PICO_PNEXT 21
+#define PEVB_PICO_PPREV 20
+#define PEVB_PICO_SWINP 19
#define PEV_VOL_DOWN (1 << PEVB_VOL_DOWN)
#define PEV_VOL_UP (1 << PEVB_VOL_UP)
#define PEV_SSLOT_NEXT (1 << PEVB_SSLOT_NEXT)
#define PEV_MENU (1 << PEVB_MENU)
#define PEV_FF (1 << PEVB_FF)
+#define PEV_PICO_PNEXT (1 << PEVB_PICO_PNEXT)
+#define PEV_PICO_PPREV (1 << PEVB_PICO_PPREV)
+#define PEV_PICO_SWINP (1 << PEVB_PICO_SWINP)
-#define PEV_MASK 0x7fc00000
+#define PEV_MASK 0x7ff80000
enum {
\r
/* in_init() must go before config, config accesses in_ fwk */\r
in_init();\r
- emu_prepareDefaultConfig();\r
+ pemu_prep_defconfig();\r
emu_ReadConfig(0, 0);\r
config_readlrom(PicoConfigFile);\r
\r
in_probe();\r
in_debug_dump();\r
\r
- emu_Init();\r
+ emu_init();\r
menu_init();\r
\r
engineState = PGS_Menu;\r
engineState = PGS_Running;\r
\r
case PGS_Running:\r
- emu_Loop();\r
+ pemu_loop();\r
break;\r
\r
case PGS_Quit:\r
\r
endloop:\r
\r
- emu_Deinit();\r
+ emu_finish();\r
plat_finish();\r
\r
return 0;\r
}\r
\r
/* do a frame and fetch menu bg */\r
- emu_forcedFrame(POPT_EN_SOFTSCALE);\r
+ pemu_forced_frame(POPT_EN_SOFTSCALE);\r
plat_video_menu_enter(1);\r
\r
memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram));\r
// "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE"\r
me_bind_action emuctrl_actions[] =\r
{\r
- { "Load State ", 1 << PEVB_STATE_LOAD },\r
- { "Save State ", 1 << PEVB_STATE_SAVE },\r
- { "Prev Save Slot ", 1 << PEVB_SSLOT_PREV },\r
- { "Next Save Slot ", 1 << PEVB_SSLOT_NEXT },\r
- { "Switch Renderer ", 1 << PEVB_SWITCH_RND },\r
- { "Volume Down ", 1 << PEVB_VOL_DOWN },\r
- { "Volume Up ", 1 << PEVB_VOL_UP },\r
- { "Fast forward ", 1 << PEVB_FF },\r
- { "Enter Menu ", 1 << PEVB_MENU },\r
- { "Pico Next page ", 1 << 21 }, /* TODO */\r
- { "Pico Prev page ", 1 << 20 },\r
- { "Pico Switch input", 1 << 19 },\r
+ { "Load State ", PEV_STATE_LOAD },\r
+ { "Save State ", PEV_STATE_SAVE },\r
+ { "Prev Save Slot ", PEV_SSLOT_PREV },\r
+ { "Next Save Slot ", PEV_SSLOT_NEXT },\r
+ { "Switch Renderer ", PEV_SWITCH_RND },\r
+ { "Volume Down ", PEV_VOL_DOWN },\r
+ { "Volume Up ", PEV_VOL_UP },\r
+ { "Fast forward ", PEV_FF },\r
+ { "Enter Menu ", PEV_MENU },\r
+ { "Pico Next page ", PEV_PICO_PNEXT },\r
+ { "Pico Prev page ", PEV_PICO_PPREV },\r
+ { "Pico Switch input", PEV_PICO_SWINP },\r
{ NULL, 0 }\r
};\r
\r
\r
static void mplayer_loop(void)\r
{\r
- emu_startSound();\r
+ pemu_sound_start();\r
\r
while (1)\r
{\r
PDebugZ80Frame();\r
if (in_menu_wait_any(0) & PBTN_MA3)\r
break;\r
- emu_waitSound();\r
+ pemu_sound_wait();\r
}\r
\r
- emu_endSound();\r
+ pemu_sound_stop();\r
}\r
\r
static void draw_text_debug(const char *str, int skip, int from)\r
if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6);\r
\r
memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);\r
- emu_forcedFrame(0);\r
+ pemu_forced_frame(0);\r
smalltext_out16(4, 1, "build: " __DATE__ " " __TIME__, 0xffff);\r
smalltext_out16(4, g_screen_height - me_sfont_h, layer_str, 0xffff);\r
}\r
{\r
case 0: plat_video_menu_begin();\r
tmp = PDebugMain();\r
- emu_platformDebugCat(tmp);\r
+ plat_debug_cat(tmp);\r
draw_text_debug(tmp, 0, 0);\r
if (dumped) {\r
smalltext_out16(g_screen_width - 6 * me_sfont_h,\r
break;\r
case 1: draw_frame_debug(); break;\r
case 2: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);\r
- emu_forcedFrame(0);\r
+ pemu_forced_frame(0);\r
menu_darken_bg(g_screen_ptr, g_screen_width * g_screen_height, 0);\r
PDebugShowSpriteStats((unsigned short *)g_screen_ptr + (g_screen_height/2 - 240/2)*g_screen_width +\r
g_screen_width/2 - 320/2, g_screen_width); break;\r
break;\r
case MA_MAIN_RESET_GAME:\r
if (rom_loaded) {\r
- emu_ResetGame();\r
+ emu_reset_game();\r
return 1;\r
}\r
break;\r
/* stuff to be implemented by platform code */
extern char cpu_clk_name[];
-/* TODO rename all these */
-extern const char * const keyNames[]; // TODO rm
-void emu_prepareDefaultConfig(void);
-void emu_platformDebugCat(char *str);
-void emu_forcedFrame(int opts);
-void emu_startSound(void);
-void emu_endSound(void);
-void emu_waitSound(void);
-void emu_ResetGame(void); // TODO mv rm?
-void emu_Init(void);
-void emu_Deinit(void);
-void emu_Loop(void);
-
-int emu_getMainDir(char *dst, int len);
+
+void pemu_prep_defconfig(void);
+void pemu_loop(void);
+void pemu_forced_frame(int opts);
+void pemu_sound_start(void);
+void pemu_sound_stop(void);
+void pemu_sound_wait(void);
+
void menu_romload_prepare(const char *rom_name);
void menu_romload_end(void);
void plat_init(void);
void plat_finish(void);
+/* return the dir/ where configs, saves, bios, etc. are found */
+int plat_get_root_dir(char *dst, int len);
+
/* to be used while emulation is starting or running */
void plat_status_msg(const char *format, ...);
unsigned int plat_get_ticks_ms(void);
const char *plat_get_credits(void);
+void plat_debug_cat(char *str);
#ifdef __cplusplus
} // extern "C"
// main 300K gfx-related buffer. Used by menu and renderers.
unsigned char gfx_buffer[321*240*2*2];
-
unsigned char *PicoDraw2FB = gfx_buffer; // temporary buffer for alt renderer ( (8+320)*(8+240+8) )
-int reset_timing = 0;
static DWORD noticeMsgTime = 0;
static short *snd_cbuff = NULL;
noticeMsgTime = GetTickCount();
}
-int emu_getMainDir(char *dst, int len)
+int plat_get_root_dir(char *dst, int len)
{
if (len > 0) *dst = 0;
Sleep(0); /* yield the CPU, the system may need it */
}
-static void emu_msg_tray_open(void)
-{
- strcpy(noticeMsg, "CD tray opened");
- noticeMsgTime = GetTickCount();
-}
-
-
-void emu_Init(void)
-{
- // make dirs for saves, cfgs, etc.
- mkdir("mds", 0777);
- mkdir("srm", 0777);
- mkdir("brm", 0777);
- mkdir("cfg", 0777);
-
- PicoInit();
- PicoMessage = emu_msg_cb;
- PicoMCDopenTray = emu_msg_tray_open;
- PicoMCDcloseTray = menu_loop_tray;
-}
-
-void emu_Deinit(void)
-{
- // save SRAM
- if ((currentConfig.EmuOpt & 1) && SRam.changed) {
- emu_SaveLoadGame(0, 1);
- SRam.changed = 0;
- }
-
- if (!(currentConfig.EmuOpt & 0x20))
- config_writelrom(PicoConfigFile);
-
- PicoExit();
-}
-
-void emu_prepareDefaultConfig(void)
+void pemu_prep_defconfig(void)
{
memset(&defaultConfig, 0, sizeof(defaultConfig));
defaultConfig.EmuOpt = 0x1d | 0x680; // | confirm_save, cd_leds, 16bit rend
}
/* forced frame to front buffer */
-void emu_forcedFrame(int opts)
+void pemu_forced_frame(int opts)
{
int po_old = PicoOpt;
int eo_old = currentConfig.EmuOpt;
prevEvents = (allActions[0] | allActions[1]) >> 16;
}
-void emu_platformDebugCat(char *str)
+void plat_debug_cat(char *str)
{
- // nothing
}
static void simpleWait(DWORD until)
spend_cycles(1024*2);
}
-void emu_Loop(void)
+void pemu_loop(void)
{
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
char fpsbuff[24]; // fps count c string
}
}
-
-void emu_ResetGame(void)
-{
- PicoReset();
- reset_timing = 1;
-}
-
engineState = PGS_Running;\r
\r
case PGS_Running:\r
- emu_Loop();\r
+ pemu_loop();\r
break;\r
\r
case PGS_Quit:\r
#include "../../pico/sound/ym2612.h"\r
#include "../../pico/sound/mix.h"\r
\r
-extern int reset_timing;\r
static unsigned char *shared_mem = 0;\r
static _940_data_t *shared_data = 0;\r
_940_ctl_t *shared_ctl = 0;\r
#include <stdio.h>\r
#include <stdlib.h>\r
#include <sys/time.h>\r
-#include <sys/stat.h>\r
-#include <sys/types.h>\r
#include <stdarg.h>\r
\r
#include "plat_gp2x.h"\r
static int osd_fps_x;\r
static int gp2x_old_gamma = 100;\r
static char noticeMsg[40];\r
-unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer\r
-int reset_timing = 0;\r
-\r
-#define PICO_PEN_ADJUST_X 4\r
-#define PICO_PEN_ADJUST_Y 2\r
-static int pico_pen_x = 320/2, pico_pen_y = 240/2;\r
-\r
-static void emu_msg_tray_open(void);\r
+static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];\r
+unsigned char *PicoDraw2FB = PicoDraw2FB_;\r
\r
\r
void plat_status_msg(const char *format, ...)\r
gettimeofday(¬iceMsgTime, 0);\r
}\r
\r
-int emu_getMainDir(char *dst, int len)\r
+int plat_get_root_dir(char *dst, int len)\r
{\r
extern char **g_argv;\r
int j;\r
return j + 1;\r
}\r
\r
-void emu_Init(void)\r
-{\r
- // make temp buffer for alt renderer\r
- PicoDraw2FB = malloc((8+320)*(8+240+8));\r
- if (!PicoDraw2FB)\r
- {\r
- printf("PicoDraw2FB == 0\n");\r
- }\r
-\r
- // make dirs for saves, cfgs, etc.\r
- mkdir("mds", 0777);\r
- mkdir("srm", 0777);\r
- mkdir("brm", 0777);\r
- mkdir("cfg", 0777);\r
-\r
- PicoInit();\r
- PicoMessage = plat_status_msg_busy_next;\r
- PicoMCDopenTray = emu_msg_tray_open;\r
- PicoMCDcloseTray = menu_loop_tray;\r
-}\r
-\r
\r
static void scaling_update(void)\r
{\r
}\r
\r
\r
-void emu_Deinit(void)\r
-{\r
- // save SRAM\r
- if((currentConfig.EmuOpt & 1) && SRam.changed) {\r
- emu_SaveLoadGame(0, 1);\r
- SRam.changed = 0;\r
- }\r
-\r
- if (!(currentConfig.EmuOpt & EOPT_NO_AUTOSVCFG))\r
- emu_writelrom();\r
-\r
- free(PicoDraw2FB);\r
-\r
- PicoExit();\r
-\r
- // restore gamma\r
- if (gp2x_old_gamma != 100)\r
- set_lcd_gamma(100, 0);\r
-}\r
-\r
-void emu_prepareDefaultConfig(void)\r
+void pemu_prep_defconfig(void)\r
{\r
gp2x_soc_t soc;\r
\r
}\r
}\r
\r
-static void emu_msg_tray_open(void)\r
-{\r
- plat_status_msg("CD tray opened");\r
-}\r
-\r
+#if 0 // TODO\r
static void RunEventsPico(unsigned int events)\r
{\r
int ret, px, py, lim_x;\r
static int pdown_frames = 0;\r
\r
- emu_RunEventsPico(events);\r
-\r
- if (pico_inp_mode == 0) return;\r
-\r
// for F200\r
ret = gp2x_touchpad_read(&px, &py);\r
if (ret >= 0)\r
//if (ret == 0)\r
// PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;\r
}\r
-\r
- if (PicoPad[0] & 1) pico_pen_y--;\r
- if (PicoPad[0] & 2) pico_pen_y++;\r
- if (PicoPad[0] & 4) pico_pen_x--;\r
- if (PicoPad[0] & 8) pico_pen_x++;\r
- PicoPad[0] &= ~0x0f; // release UDLR\r
-\r
- lim_x = (Pico.video.reg[12]&1) ? 319 : 255;\r
- if (pico_pen_y < 8) pico_pen_y = 8;\r
- if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y;\r
- if (pico_pen_x < 0) pico_pen_x = 0;\r
- if (pico_pen_x > lim_x-PICO_PEN_ADJUST_X) pico_pen_x = lim_x-PICO_PEN_ADJUST_X;\r
-\r
- PicoPicohw.pen_pos[0] = pico_pen_x;\r
- if (!(Pico.video.reg[12]&1)) PicoPicohw.pen_pos[0] += pico_pen_x/4;\r
- PicoPicohw.pen_pos[0] += 0x3c;\r
- PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);\r
}\r
+#endif\r
\r
void plat_update_volume(int has_changed, int is_up)\r
{\r
sndout_oss_write(PsndOut, len<<1);\r
}\r
\r
-void emu_startSound(void)\r
+void pemu_sound_start(void)\r
{\r
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;\r
int target_fps = Pico.m.pal ? 50 : 60;\r
}\r
}\r
\r
-void emu_endSound(void)\r
+void pemu_sound_stop(void)\r
{\r
}\r
\r
-/* wait until we can write more sound */\r
-void emu_waitSound(void)\r
+void pemu_sound_wait(void)\r
{\r
// don't need to do anything, writes will block by themselves\r
}\r
}\r
\r
\r
-void emu_forcedFrame(int opts)\r
+void pemu_forced_frame(int opts)\r
{\r
int po_old = PicoOpt;\r
int eo_old = currentConfig.EmuOpt;\r
\r
- PicoOpt &= ~0x10;\r
- PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites\r
- currentConfig.EmuOpt |= 0x80;\r
+ PicoOpt &= ~POPT_ALT_RENDERER;\r
+ PicoOpt |= opts|POPT_ACC_SPRITES;\r
+ currentConfig.EmuOpt |= EOPT_16BPP;\r
\r
- //vidResetMode();\r
PicoDrawSetColorFormat(1);\r
PicoScanBegin = EmuScanBegin16;\r
Pico.m.dirtyPal = 1;\r
currentConfig.EmuOpt = eo_old;\r
}\r
\r
-void emu_platformDebugCat(char *str)\r
+void plat_debug_cat(char *str)\r
{\r
- // nothing\r
}\r
\r
static void simpleWait(int thissec, int lim_time)\r
#endif\r
\r
\r
-void emu_Loop(void)\r
+void pemu_loop(void)\r
{\r
static int gp2x_old_clock = -1, EmuOpt_old = 0;\r
char fpsbuff[24]; // fps count c string\r
target_frametime = 1000000/target_fps;\r
reset_timing = 1;\r
\r
- emu_startSound();\r
+ pemu_sound_start();\r
\r
// prepare CD buffer\r
if (PicoAHW & PAHW_MCD) PicoCDBufferInit();\r
\r
// if in 8bit mode, generate 16bit image for menu background\r
if ((PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP))\r
- emu_forcedFrame(POPT_EN_SOFTSCALE);\r
-}\r
-\r
-\r
-void emu_ResetGame(void)\r
-{\r
- PicoReset();\r
- reset_timing = 1;\r
+ pemu_forced_frame(POPT_EN_SOFTSCALE);\r
}\r
\r
const char *plat_get_credits(void)\r
-// (c) Copyright 2006-2008 notaz, All rights reserved.\r
+// (c) Copyright 2006-2009 notaz, All rights reserved.\r
// Free for non-commercial use.\r
\r
// For commercial use, separate licencing terms must be obtained.\r
#include <stdio.h>\r
#include <stdlib.h>\r
#include <sys/time.h>\r
-#include <sys/stat.h>\r
-#include <sys/types.h>\r
-#include <linux/limits.h>\r
-#include <ctype.h>\r
-#include <unistd.h>\r
-\r
#include <stdarg.h>\r
\r
#include "../common/arm_utils.h"\r
static struct timeval noticeMsgTime = { 0, 0 }; // when started showing\r
static int osd_fps_x;\r
unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer\r
-int reset_timing = 0;\r
\r
#define PICO_PEN_ADJUST_X 4\r
#define PICO_PEN_ADJUST_Y 2\r
static int pico_pen_x = 0, pico_pen_y = 240/2;\r
\r
-static void emu_msg_cb(const char *msg);\r
-static void emu_msg_tray_open(void);\r
-\r
\r
void plat_status_msg(const char *format, ...)\r
{\r
gettimeofday(¬iceMsgTime, 0);\r
}\r
\r
-int emu_getMainDir(char *dst, int len)\r
+int plat_get_root_dir(char *dst, int len)\r
{\r
extern char **g_argv;\r
int j;\r
return j + 1;\r
}\r
\r
-void emu_Init(void)\r
-{\r
- // make temp buffer for alt renderer\r
- PicoDraw2FB = malloc((8+320)*(8+240+8));\r
- if (!PicoDraw2FB)\r
- {\r
- printf("PicoDraw2FB == 0\n");\r
- }\r
-\r
- // make dirs for saves, cfgs, etc.\r
- mkdir("mds", 0777);\r
- mkdir("srm", 0777);\r
- mkdir("brm", 0777);\r
- mkdir("cfg", 0777);\r
-\r
- PicoInit();\r
- PicoMessage = emu_msg_cb;\r
- PicoMCDopenTray = emu_msg_tray_open;\r
- PicoMCDcloseTray = menu_loop_tray;\r
-}\r
-\r
-\r
-void emu_Deinit(void)\r
-{\r
- // save SRAM\r
- if((currentConfig.EmuOpt & 1) && SRam.changed) {\r
- emu_SaveLoadGame(0, 1);\r
- SRam.changed = 0;\r
- }\r
-\r
- if (!(currentConfig.EmuOpt & 0x20)) {\r
- config_writelrom(PicoConfigFile);\r
-#ifndef NO_SYNC\r
- sync();\r
-#endif\r
- }\r
-\r
- free(PicoDraw2FB);\r
-\r
- PicoExit();\r
-}\r
-\r
-void emu_prepareDefaultConfig(void)\r
+void pemu_prep_defconfig(void)\r
{\r
memset(&defaultConfig, 0, sizeof(defaultConfig));\r
defaultConfig.EmuOpt = 0x8f | 0x00600; // | <- confirm_save, cd_leds\r
}\r
\r
\r
-static void emu_msg_cb(const char *msg)\r
-{\r
-/*\r
- if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
- // 8-bit renderers\r
- gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16), 0xe0, g_screen_width*16);\r
- osd_text(4, g_screen_height-16, msg);\r
- gp2x_memcpy_all_buffers((char *)g_screen_ptr+g_screen_width*(g_screen_height-16),\r
- g_screen_width*(g_screen_height-16), g_screen_width*16);\r
- } else {\r
- // 16bit accurate renderer\r
- gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16)*2, 0, g_screen_width*16*2);\r
- osd_text(4, g_screen_height-16, msg);\r
- gp2x_memcpy_all_buffers((char *)g_screen_ptr+g_screen_width*(g_screen_height-16)*2,\r
- g_screen_width*(g_screen_height-16)*2, g_screen_width*16*2);\r
- }\r
- gettimeofday(¬iceMsgTime, 0);\r
- noticeMsgTime.tv_sec -= 2;\r
-*/\r
- /* assumption: emu_msg_cb gets called only when something slow is about to happen */\r
- reset_timing = 1;\r
-}\r
-\r
-static void emu_state_cb(const char *str)\r
-{\r
- clearArea(0);\r
- blit("", str);\r
-}\r
-\r
-static void emu_msg_tray_open(void)\r
-{\r
- strcpy(noticeMsg, "CD tray opened");\r
- gettimeofday(¬iceMsgTime, 0);\r
-}\r
-\r
-\r
static void update_volume(int has_changed, int is_up)\r
{\r
static int prev_frame = 0, wait_frames = 0;\r
}\r
\r
\r
-void emu_forcedFrame(int opts)\r
+void pemu_forced_frame(int opts)\r
{\r
int po_old = PicoOpt;\r
int eo_old = currentConfig.EmuOpt;\r
currentConfig.EmuOpt = eo_old;\r
}\r
\r
-void emu_platformDebugCat(char *str)\r
+void plat_debug_cat(char *str)\r
{\r
- // nothing\r
}\r
\r
static void simpleWait(int thissec, int lim_time)\r
}\r
}\r
\r
-void emu_startSound(void)\r
+void pemu_sound_start(void)\r
{\r
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;\r
int target_fps = Pico.m.pal ? 50 : 60;\r
}\r
}\r
\r
-void emu_endSound(void)\r
+void pemu_sound_stop(void)\r
{\r
}\r
\r
-/* wait until we can write more sound */\r
-void emu_waitSound(void)\r
+void pemu_sound_wait(void)\r
{\r
// don't need to do anything, writes will block by themselves\r
}\r
\r
-void emu_Loop(void)\r
+void pemu_loop(void)\r
{\r
char fpsbuff[24]; // fps count c string\r
struct timeval tval; // timing\r
target_frametime = 1000000/target_fps;\r
reset_timing = 1;\r
\r
- emu_startSound();\r
+ pemu_sound_start();\r
\r
// prepare CD buffer\r
if (PicoAHW & PAHW_MCD) PicoCDBufferInit();\r
\r
// save SRAM\r
if((currentConfig.EmuOpt & 1) && SRam.changed) {\r
+ /* FIXME: plat_status_msg_busy_first */\r
emu_state_cb("Writing SRAM/BRAM..");\r
emu_SaveLoadGame(0, 1);\r
SRam.changed = 0;\r
\r
// if in 8bit mode, generate 16bit image for menu background\r
if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80))\r
- emu_forcedFrame(POPT_EN_SOFTSCALE);\r
-}\r
-\r
-\r
-void emu_ResetGame(void)\r
-{\r
- PicoReset();\r
- reset_timing = 1;\r
+ pemu_forced_frame(POPT_EN_SOFTSCALE);\r
}\r
\r
int engineStateSuspend;
static unsigned int noticeMsgTime = 0;
-int reset_timing = 0; // do we need this?
#define PICO_PEN_ADJUST_X 4
#define PICO_PEN_ADJUST_Y 2
noticeMsgTime = sceKernelGetSystemTimeLow();
}
-int emu_getMainDir(char *dst, int len)
+int plat_get_root_dir(char *dst, int len)
{
if (len > 0) *dst = 0;
return 0;
reset_timing = 1;
}
-static void emu_msg_tray_open(void)
-{
- plat_status_msg("CD tray opened");
-}
-
-
+/* FIXME: move to plat */
void emu_Init(void)
{
- // make dirs for saves, cfgs, etc.
- mkdir("mds", 0777);
- mkdir("srm", 0777);
- mkdir("brm", 0777);
- mkdir("cfg", 0777);
-
sound_init();
-
- PicoInit();
- PicoMessage = emu_msg_cb;
- PicoMCDopenTray = emu_msg_tray_open;
- PicoMCDcloseTray = menu_loop_tray;
}
void emu_Deinit(void)
{
- // save SRAM
- if ((currentConfig.EmuOpt & 1) && SRam.changed) {
- emu_SaveLoadGame(0, 1);
- SRam.changed = 0;
- }
-
- if (!(currentConfig.EmuOpt & 0x20))
- config_writelrom(PicoConfigFile);
-
- PicoExit();
sound_deinit();
}
-void emu_prepareDefaultConfig(void)
+void pemu_prep_defconfig(void)
{
memset(&defaultConfig, 0, sizeof(defaultConfig));
defaultConfig.EmuOpt = 0x1d | 0x680; // | <- confirm_save, cd_leds, acc rend
sceGuSync(0,0);
}
-void emu_platformDebugCat(char *str)
+void plat_debug_cat(char *str)
{
strcat(str, blit_16bit_mode ? "soft clut\n" : "hard clut\n");
}
lprintf("sceKernelCreateThread failed: %i\n", thid);
}
-void emu_startSound(void)
+void pemu_sound_start(void)
{
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
int ret, stereo;
}
}
-void emu_endSound(void)
+void pemu_sound_stop(void)
{
int i;
if (samples_done == 0)
}
/* wait until we can write more sound */
-void emu_waitSound(void)
+void pemu_sound_wait(void)
{
// TODO: test this
while (!sound_thread_exit && samples_made - samples_done > samples_block * 4)
PicoSkipFrame=0;
}
-void emu_forcedFrame(int opts)
+void pemu_forced_frame(int opts)
{
int po_old = PicoOpt;
int eo_old = currentConfig.EmuOpt;
sceKernelDelayThread(diff);
}
-void emu_Loop(void)
+void pemu_loop(void)
{
static int mp3_init_done = 0;
char fpsbuff[24]; // fps count c string
// prepare sound stuff
PsndOut = NULL;
- if (currentConfig.EmuOpt & 4)
+ if (currentConfig.EmuOpt & EOPT_EN_SOUND)
{
- emu_startSound();
+ pemu_sound_start();
}
sceDisplayWaitVblankStart();
if (PicoAHW & PAHW_MCD) PicoCDBufferFree();
if (PsndOut != NULL) {
- emu_endSound();
+ pemu_sound_stop();
PsndOut = NULL;
}
memset32_uncached((int *)psp_video_get_active_fb() + 512*264*2/4, 0, 512*8*2/4);
}
-
-void emu_ResetGame(void)
-{
- PicoReset();
- reset_timing = 1;
-}
-
void emu_HandleResume(void)
{
if (!(PicoAHW & PAHW_MCD)) return;
emu_HandleResume();
break;
}
- emu_Loop();
+ pemu_loop();
#ifdef GPROF
goto endloop;
#endif
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
};
-int emu_getMainDir(char *dst, int len)
+int plat_get_root_dir(char *dst, int len)
{
strcpy(dst, "D:\\other\\PicoDrive\\");
return strlen(dst);