mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 14:57:46 -04:00
further unification and refactoring
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@710 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
71769e27e9
commit
93c18cb44b
11 changed files with 187 additions and 306 deletions
106
common/emu.c
106
common/emu.c
|
@ -16,6 +16,7 @@
|
|||
#include "config.h"
|
||||
#include "plat.h"
|
||||
#include "input.h"
|
||||
#include "posix.h"
|
||||
|
||||
#include <pico/pico_int.h>
|
||||
#include <pico/patch.h>
|
||||
|
@ -34,6 +35,7 @@ char *PicoConfigFile = "config.cfg";
|
|||
currentConfig_t currentConfig, defaultConfig;
|
||||
int state_slot = 0;
|
||||
int config_slot = 0, config_slot_current = 0;
|
||||
int pico_pen_x = 320/2, pico_pen_y = 240/2;
|
||||
int pico_inp_mode = 0;
|
||||
int engineState = PGS_Menu;
|
||||
|
||||
|
@ -41,6 +43,7 @@ int engineState = PGS_Menu;
|
|||
char rom_fname_reload[512] = { 0, };
|
||||
char rom_fname_loaded[512] = { 0, };
|
||||
int rom_loaded = 0;
|
||||
int reset_timing = 0;
|
||||
|
||||
unsigned char *movie_data = NULL;
|
||||
static int movie_size = 0;
|
||||
|
@ -109,7 +112,7 @@ int emu_findBios(int region, char **bios_file)
|
|||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
emu_getMainDir(bios_path, sizeof(bios_path));
|
||||
plat_get_root_dir(bios_path, sizeof(bios_path));
|
||||
strcat(bios_path, files[i]);
|
||||
strcat(bios_path, ".bin");
|
||||
f = fopen(bios_path, "rb");
|
||||
|
@ -519,7 +522,7 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext)
|
|||
for (; p >= rom_fname_loaded && *p != PATH_SEP_C; p--); p++;
|
||||
*dst = 0;
|
||||
if (prefix) {
|
||||
int len = emu_getMainDir(dst, 512);
|
||||
int len = plat_get_root_dir(dst, 512);
|
||||
strcpy(dst + len, prefix);
|
||||
prefix_len = len + strlen(prefix);
|
||||
}
|
||||
|
@ -536,7 +539,7 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext)
|
|||
static void make_config_cfg(char *cfg)
|
||||
{
|
||||
int len;
|
||||
len = emu_getMainDir(cfg, 512);
|
||||
len = plat_get_root_dir(cfg, 512);
|
||||
strncpy(cfg + len, PicoConfigFile, 512-6-1-len);
|
||||
if (config_slot != 0)
|
||||
{
|
||||
|
@ -957,9 +960,22 @@ void emu_changeFastForward(int set_on)
|
|||
}
|
||||
}
|
||||
|
||||
void emu_RunEventsPico(unsigned int events)
|
||||
static void emu_msg_tray_open(void)
|
||||
{
|
||||
if (events & (1 << 3)) {
|
||||
plat_status_msg("CD tray opened");
|
||||
}
|
||||
|
||||
void emu_reset_game(void)
|
||||
{
|
||||
PicoReset();
|
||||
reset_timing = 1;
|
||||
}
|
||||
|
||||
void run_events_pico(unsigned int events)
|
||||
{
|
||||
int lim_x;
|
||||
|
||||
if (events & PEV_PICO_SWINP) {
|
||||
pico_inp_mode++;
|
||||
if (pico_inp_mode > 2)
|
||||
pico_inp_mode = 0;
|
||||
|
@ -971,18 +987,44 @@ void emu_RunEventsPico(unsigned int events)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (events & (1 << 4)) {
|
||||
if (events & PEV_PICO_PPREV) {
|
||||
PicoPicohw.page--;
|
||||
if (PicoPicohw.page < 0)
|
||||
PicoPicohw.page = 0;
|
||||
plat_status_msg("Page %i", PicoPicohw.page);
|
||||
}
|
||||
if (events & (1 << 5)) {
|
||||
if (events & PEV_PICO_PNEXT) {
|
||||
PicoPicohw.page++;
|
||||
if (PicoPicohw.page > 6)
|
||||
PicoPicohw.page = 6;
|
||||
plat_status_msg("Page %i", PicoPicohw.page);
|
||||
}
|
||||
|
||||
if (pico_inp_mode == 0)
|
||||
return;
|
||||
|
||||
/* handle other input modes */
|
||||
if (PicoPad[0] & 1) pico_pen_y--;
|
||||
if (PicoPad[0] & 2) pico_pen_y++;
|
||||
if (PicoPad[0] & 4) pico_pen_x--;
|
||||
if (PicoPad[0] & 8) pico_pen_x++;
|
||||
PicoPad[0] &= ~0x0f; // release UDLR
|
||||
|
||||
lim_x = (Pico.video.reg[12]&1) ? 319 : 255;
|
||||
if (pico_pen_y < 8)
|
||||
pico_pen_y = 8;
|
||||
if (pico_pen_y > 224 - PICO_PEN_ADJUST_Y)
|
||||
pico_pen_y = 224 - PICO_PEN_ADJUST_Y;
|
||||
if (pico_pen_x < 0)
|
||||
pico_pen_x = 0;
|
||||
if (pico_pen_x > lim_x - PICO_PEN_ADJUST_X)
|
||||
pico_pen_x = lim_x - PICO_PEN_ADJUST_X;
|
||||
|
||||
PicoPicohw.pen_pos[0] = pico_pen_x;
|
||||
if (!(Pico.video.reg[12] & 1))
|
||||
PicoPicohw.pen_pos[0] += pico_pen_x / 4;
|
||||
PicoPicohw.pen_pos[0] += 0x3c;
|
||||
PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
|
||||
}
|
||||
|
||||
static void do_turbo(int *pad, int acts)
|
||||
|
@ -1009,7 +1051,7 @@ static void do_turbo(int *pad, int acts)
|
|||
*pad |= turbo_pad & (acts >> 8);
|
||||
}
|
||||
|
||||
static void run_ui_events(unsigned int which)
|
||||
static void run_events_ui(unsigned int which)
|
||||
{
|
||||
if (which & (PEV_STATE_LOAD|PEV_STATE_SAVE))
|
||||
{
|
||||
|
@ -1096,18 +1138,58 @@ void emu_update_input(void)
|
|||
if ((events ^ prevEvents) & PEV_FF) {
|
||||
emu_changeFastForward(events & PEV_FF);
|
||||
plat_update_volume(0, 0);
|
||||
// reset_timing = 1;
|
||||
reset_timing = 1;
|
||||
}
|
||||
|
||||
events &= ~prevEvents;
|
||||
|
||||
// TODO if (PicoAHW == PAHW_PICO)
|
||||
// RunEventsPico(events);
|
||||
if (PicoAHW == PAHW_PICO)
|
||||
run_events_pico(events);
|
||||
if (events)
|
||||
run_ui_events(events);
|
||||
run_events_ui(events);
|
||||
if (movie_data)
|
||||
update_movie();
|
||||
|
||||
prevEvents = (allActions[0] | allActions[1]) & PEV_MASK;
|
||||
}
|
||||
|
||||
static void mkdir_path(char *path_with_reserve, int pos, const char *name)
|
||||
{
|
||||
strcpy(path_with_reserve + pos, name);
|
||||
if (plat_is_dir(path_with_reserve))
|
||||
return;
|
||||
if (mkdir(path_with_reserve, 0777) < 0)
|
||||
lprintf("failed to create: %s\n", path_with_reserve);
|
||||
}
|
||||
|
||||
void emu_init(void)
|
||||
{
|
||||
char dir[256];
|
||||
int pos;
|
||||
|
||||
/* make dirs for saves */
|
||||
pos = plat_get_root_dir(dir, sizeof(dir) - 4);
|
||||
mkdir_path(dir, pos, "mds");
|
||||
mkdir_path(dir, pos, "srm");
|
||||
mkdir_path(dir, pos, "brm");
|
||||
|
||||
PicoInit();
|
||||
PicoMessage = plat_status_msg_busy_next;
|
||||
PicoMCDopenTray = emu_msg_tray_open;
|
||||
PicoMCDcloseTray = menu_loop_tray;
|
||||
}
|
||||
|
||||
void emu_finish(void)
|
||||
{
|
||||
// save SRAM
|
||||
if ((currentConfig.EmuOpt & EOPT_USE_SRAM) && SRam.changed) {
|
||||
emu_SaveLoadGame(0, 1);
|
||||
SRam.changed = 0;
|
||||
}
|
||||
|
||||
if (!(currentConfig.EmuOpt & EOPT_NO_AUTOSVCFG))
|
||||
emu_writelrom();
|
||||
|
||||
PicoExit();
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,11 @@ extern int rom_loaded;
|
|||
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
|
||||
|
@ -91,8 +96,12 @@ enum TPicoGameState {
|
|||
};
|
||||
|
||||
|
||||
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);
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#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)
|
||||
|
@ -36,8 +39,11 @@
|
|||
#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 {
|
||||
|
|
|
@ -69,7 +69,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* in_init() must go before config, config accesses in_ fwk */
|
||||
in_init();
|
||||
emu_prepareDefaultConfig();
|
||||
pemu_prep_defconfig();
|
||||
emu_ReadConfig(0, 0);
|
||||
config_readlrom(PicoConfigFile);
|
||||
|
||||
|
@ -77,7 +77,7 @@ int main(int argc, char *argv[])
|
|||
in_probe();
|
||||
in_debug_dump();
|
||||
|
||||
emu_Init();
|
||||
emu_init();
|
||||
menu_init();
|
||||
|
||||
engineState = PGS_Menu;
|
||||
|
@ -117,7 +117,7 @@ int main(int argc, char *argv[])
|
|||
engineState = PGS_Running;
|
||||
|
||||
case PGS_Running:
|
||||
emu_Loop();
|
||||
pemu_loop();
|
||||
break;
|
||||
|
||||
case PGS_Quit:
|
||||
|
@ -131,7 +131,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
endloop:
|
||||
|
||||
emu_Deinit();
|
||||
emu_finish();
|
||||
plat_finish();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -997,7 +997,7 @@ static void draw_savestate_bg(int slot)
|
|||
}
|
||||
|
||||
/* do a frame and fetch menu bg */
|
||||
emu_forcedFrame(POPT_EN_SOFTSCALE);
|
||||
pemu_forced_frame(POPT_EN_SOFTSCALE);
|
||||
plat_video_menu_enter(1);
|
||||
|
||||
memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram));
|
||||
|
@ -1286,18 +1286,18 @@ me_bind_action me_ctrl_actions[15] =
|
|||
// "LOAD STATE", "VOLUME UP", "VOLUME DOWN", "DONE"
|
||||
me_bind_action emuctrl_actions[] =
|
||||
{
|
||||
{ "Load State ", 1 << PEVB_STATE_LOAD },
|
||||
{ "Save State ", 1 << PEVB_STATE_SAVE },
|
||||
{ "Prev Save Slot ", 1 << PEVB_SSLOT_PREV },
|
||||
{ "Next Save Slot ", 1 << PEVB_SSLOT_NEXT },
|
||||
{ "Switch Renderer ", 1 << PEVB_SWITCH_RND },
|
||||
{ "Volume Down ", 1 << PEVB_VOL_DOWN },
|
||||
{ "Volume Up ", 1 << PEVB_VOL_UP },
|
||||
{ "Fast forward ", 1 << PEVB_FF },
|
||||
{ "Enter Menu ", 1 << PEVB_MENU },
|
||||
{ "Pico Next page ", 1 << 21 }, /* TODO */
|
||||
{ "Pico Prev page ", 1 << 20 },
|
||||
{ "Pico Switch input", 1 << 19 },
|
||||
{ "Load State ", PEV_STATE_LOAD },
|
||||
{ "Save State ", PEV_STATE_SAVE },
|
||||
{ "Prev Save Slot ", PEV_SSLOT_PREV },
|
||||
{ "Next Save Slot ", PEV_SSLOT_NEXT },
|
||||
{ "Switch Renderer ", PEV_SWITCH_RND },
|
||||
{ "Volume Down ", PEV_VOL_DOWN },
|
||||
{ "Volume Up ", PEV_VOL_UP },
|
||||
{ "Fast forward ", PEV_FF },
|
||||
{ "Enter Menu ", PEV_MENU },
|
||||
{ "Pico Next page ", PEV_PICO_PNEXT },
|
||||
{ "Pico Prev page ", PEV_PICO_PPREV },
|
||||
{ "Pico Switch input", PEV_PICO_SWINP },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
|
@ -1727,17 +1727,17 @@ extern void SekStepM68k(void);
|
|||
|
||||
static void mplayer_loop(void)
|
||||
{
|
||||
emu_startSound();
|
||||
pemu_sound_start();
|
||||
|
||||
while (1)
|
||||
{
|
||||
PDebugZ80Frame();
|
||||
if (in_menu_wait_any(0) & PBTN_MA3)
|
||||
break;
|
||||
emu_waitSound();
|
||||
pemu_sound_wait();
|
||||
}
|
||||
|
||||
emu_endSound();
|
||||
pemu_sound_stop();
|
||||
}
|
||||
|
||||
static void draw_text_debug(const char *str, int skip, int from)
|
||||
|
@ -1776,7 +1776,7 @@ static void draw_frame_debug(void)
|
|||
if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6);
|
||||
|
||||
memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);
|
||||
emu_forcedFrame(0);
|
||||
pemu_forced_frame(0);
|
||||
smalltext_out16(4, 1, "build: " __DATE__ " " __TIME__, 0xffff);
|
||||
smalltext_out16(4, g_screen_height - me_sfont_h, layer_str, 0xffff);
|
||||
}
|
||||
|
@ -1793,7 +1793,7 @@ static void debug_menu_loop(void)
|
|||
{
|
||||
case 0: plat_video_menu_begin();
|
||||
tmp = PDebugMain();
|
||||
emu_platformDebugCat(tmp);
|
||||
plat_debug_cat(tmp);
|
||||
draw_text_debug(tmp, 0, 0);
|
||||
if (dumped) {
|
||||
smalltext_out16(g_screen_width - 6 * me_sfont_h,
|
||||
|
@ -1803,7 +1803,7 @@ static void debug_menu_loop(void)
|
|||
break;
|
||||
case 1: draw_frame_debug(); break;
|
||||
case 2: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);
|
||||
emu_forcedFrame(0);
|
||||
pemu_forced_frame(0);
|
||||
menu_darken_bg(g_screen_ptr, g_screen_width * g_screen_height, 0);
|
||||
PDebugShowSpriteStats((unsigned short *)g_screen_ptr + (g_screen_height/2 - 240/2)*g_screen_width +
|
||||
g_screen_width/2 - 320/2, g_screen_width); break;
|
||||
|
@ -1896,7 +1896,7 @@ static int main_menu_handler(menu_id id, int keys)
|
|||
break;
|
||||
case MA_MAIN_RESET_GAME:
|
||||
if (rom_loaded) {
|
||||
emu_ResetGame();
|
||||
emu_reset_game();
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -4,20 +4,14 @@ extern "C" {
|
|||
|
||||
/* 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);
|
||||
|
||||
|
@ -25,6 +19,9 @@ void plat_early_init(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, ...);
|
||||
|
||||
|
@ -49,6 +46,7 @@ void plat_sleep_ms(int ms);
|
|||
unsigned int plat_get_ticks_ms(void);
|
||||
|
||||
const char *plat_get_credits(void);
|
||||
void plat_debug_cat(char *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "../../pico/sound/ym2612.h"
|
||||
#include "../../pico/sound/mix.h"
|
||||
|
||||
extern int reset_timing;
|
||||
static unsigned char *shared_mem = 0;
|
||||
static _940_data_t *shared_data = 0;
|
||||
_940_ctl_t *shared_ctl = 0;
|
||||
|
|
117
gp2x/emu.c
117
gp2x/emu.c
|
@ -6,8 +6,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "plat_gp2x.h"
|
||||
|
@ -42,14 +40,8 @@ static struct timeval noticeMsgTime = { 0, 0 }; // when started showing
|
|||
static int osd_fps_x;
|
||||
static int gp2x_old_gamma = 100;
|
||||
static char noticeMsg[40];
|
||||
unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer
|
||||
int reset_timing = 0;
|
||||
|
||||
#define PICO_PEN_ADJUST_X 4
|
||||
#define PICO_PEN_ADJUST_Y 2
|
||||
static int pico_pen_x = 320/2, pico_pen_y = 240/2;
|
||||
|
||||
static void emu_msg_tray_open(void);
|
||||
static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];
|
||||
unsigned char *PicoDraw2FB = PicoDraw2FB_;
|
||||
|
||||
|
||||
void plat_status_msg(const char *format, ...)
|
||||
|
@ -63,7 +55,7 @@ void plat_status_msg(const char *format, ...)
|
|||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
|
||||
int emu_getMainDir(char *dst, int len)
|
||||
int plat_get_root_dir(char *dst, int len)
|
||||
{
|
||||
extern char **g_argv;
|
||||
int j;
|
||||
|
@ -78,27 +70,6 @@ int emu_getMainDir(char *dst, int len)
|
|||
return j + 1;
|
||||
}
|
||||
|
||||
void emu_Init(void)
|
||||
{
|
||||
// make temp buffer for alt renderer
|
||||
PicoDraw2FB = malloc((8+320)*(8+240+8));
|
||||
if (!PicoDraw2FB)
|
||||
{
|
||||
printf("PicoDraw2FB == 0\n");
|
||||
}
|
||||
|
||||
// make dirs for saves, cfgs, etc.
|
||||
mkdir("mds", 0777);
|
||||
mkdir("srm", 0777);
|
||||
mkdir("brm", 0777);
|
||||
mkdir("cfg", 0777);
|
||||
|
||||
PicoInit();
|
||||
PicoMessage = plat_status_msg_busy_next;
|
||||
PicoMCDopenTray = emu_msg_tray_open;
|
||||
PicoMCDcloseTray = menu_loop_tray;
|
||||
}
|
||||
|
||||
|
||||
static void scaling_update(void)
|
||||
{
|
||||
|
@ -116,27 +87,7 @@ static void scaling_update(void)
|
|||
}
|
||||
|
||||
|
||||
void emu_Deinit(void)
|
||||
{
|
||||
// save SRAM
|
||||
if((currentConfig.EmuOpt & 1) && SRam.changed) {
|
||||
emu_SaveLoadGame(0, 1);
|
||||
SRam.changed = 0;
|
||||
}
|
||||
|
||||
if (!(currentConfig.EmuOpt & EOPT_NO_AUTOSVCFG))
|
||||
emu_writelrom();
|
||||
|
||||
free(PicoDraw2FB);
|
||||
|
||||
PicoExit();
|
||||
|
||||
// restore gamma
|
||||
if (gp2x_old_gamma != 100)
|
||||
set_lcd_gamma(100, 0);
|
||||
}
|
||||
|
||||
void emu_prepareDefaultConfig(void)
|
||||
void pemu_prep_defconfig(void)
|
||||
{
|
||||
gp2x_soc_t soc;
|
||||
|
||||
|
@ -411,20 +362,12 @@ void plat_video_toggle_renderer(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void emu_msg_tray_open(void)
|
||||
{
|
||||
plat_status_msg("CD tray opened");
|
||||
}
|
||||
|
||||
#if 0 // TODO
|
||||
static void RunEventsPico(unsigned int events)
|
||||
{
|
||||
int ret, px, py, lim_x;
|
||||
static int pdown_frames = 0;
|
||||
|
||||
emu_RunEventsPico(events);
|
||||
|
||||
if (pico_inp_mode == 0) return;
|
||||
|
||||
// for F200
|
||||
ret = gp2x_touchpad_read(&px, &py);
|
||||
if (ret >= 0)
|
||||
|
@ -449,24 +392,8 @@ static void RunEventsPico(unsigned int events)
|
|||
//if (ret == 0)
|
||||
// PicoPicohw.pen_pos[0] = PicoPicohw.pen_pos[1] = 0x8000;
|
||||
}
|
||||
|
||||
if (PicoPad[0] & 1) pico_pen_y--;
|
||||
if (PicoPad[0] & 2) pico_pen_y++;
|
||||
if (PicoPad[0] & 4) pico_pen_x--;
|
||||
if (PicoPad[0] & 8) pico_pen_x++;
|
||||
PicoPad[0] &= ~0x0f; // release UDLR
|
||||
|
||||
lim_x = (Pico.video.reg[12]&1) ? 319 : 255;
|
||||
if (pico_pen_y < 8) pico_pen_y = 8;
|
||||
if (pico_pen_y > 224-PICO_PEN_ADJUST_Y) pico_pen_y = 224-PICO_PEN_ADJUST_Y;
|
||||
if (pico_pen_x < 0) pico_pen_x = 0;
|
||||
if (pico_pen_x > lim_x-PICO_PEN_ADJUST_X) pico_pen_x = lim_x-PICO_PEN_ADJUST_X;
|
||||
|
||||
PicoPicohw.pen_pos[0] = pico_pen_x;
|
||||
if (!(Pico.video.reg[12]&1)) PicoPicohw.pen_pos[0] += pico_pen_x/4;
|
||||
PicoPicohw.pen_pos[0] += 0x3c;
|
||||
PicoPicohw.pen_pos[1] = pico_inp_mode == 1 ? (0x2f8 + pico_pen_y) : (0x1fc + pico_pen_y);
|
||||
}
|
||||
#endif
|
||||
|
||||
void plat_update_volume(int has_changed, int is_up)
|
||||
{
|
||||
|
@ -519,7 +446,7 @@ static void updateSound(int len)
|
|||
sndout_oss_write(PsndOut, len<<1);
|
||||
}
|
||||
|
||||
void emu_startSound(void)
|
||||
void pemu_sound_start(void)
|
||||
{
|
||||
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
|
||||
int target_fps = Pico.m.pal ? 50 : 60;
|
||||
|
@ -549,12 +476,11 @@ void emu_startSound(void)
|
|||
}
|
||||
}
|
||||
|
||||
void emu_endSound(void)
|
||||
void pemu_sound_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* wait until we can write more sound */
|
||||
void emu_waitSound(void)
|
||||
void pemu_sound_wait(void)
|
||||
{
|
||||
// don't need to do anything, writes will block by themselves
|
||||
}
|
||||
|
@ -568,16 +494,15 @@ static void SkipFrame(int do_audio)
|
|||
}
|
||||
|
||||
|
||||
void emu_forcedFrame(int opts)
|
||||
void pemu_forced_frame(int opts)
|
||||
{
|
||||
int po_old = PicoOpt;
|
||||
int eo_old = currentConfig.EmuOpt;
|
||||
|
||||
PicoOpt &= ~0x10;
|
||||
PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites
|
||||
currentConfig.EmuOpt |= 0x80;
|
||||
PicoOpt &= ~POPT_ALT_RENDERER;
|
||||
PicoOpt |= opts|POPT_ACC_SPRITES;
|
||||
currentConfig.EmuOpt |= EOPT_16BPP;
|
||||
|
||||
//vidResetMode();
|
||||
PicoDrawSetColorFormat(1);
|
||||
PicoScanBegin = EmuScanBegin16;
|
||||
Pico.m.dirtyPal = 1;
|
||||
|
@ -597,9 +522,8 @@ void emu_forcedFrame(int opts)
|
|||
currentConfig.EmuOpt = eo_old;
|
||||
}
|
||||
|
||||
void emu_platformDebugCat(char *str)
|
||||
void plat_debug_cat(char *str)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
static void simpleWait(int thissec, int lim_time)
|
||||
|
@ -668,7 +592,7 @@ static void tga_dump(void)
|
|||
#endif
|
||||
|
||||
|
||||
void emu_Loop(void)
|
||||
void pemu_loop(void)
|
||||
{
|
||||
static int gp2x_old_clock = -1, EmuOpt_old = 0;
|
||||
char fpsbuff[24]; // fps count c string
|
||||
|
@ -726,7 +650,7 @@ void emu_Loop(void)
|
|||
target_frametime = 1000000/target_fps;
|
||||
reset_timing = 1;
|
||||
|
||||
emu_startSound();
|
||||
pemu_sound_start();
|
||||
|
||||
// prepare CD buffer
|
||||
if (PicoAHW & PAHW_MCD) PicoCDBufferInit();
|
||||
|
@ -920,14 +844,7 @@ void emu_Loop(void)
|
|||
|
||||
// if in 8bit mode, generate 16bit image for menu background
|
||||
if ((PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP))
|
||||
emu_forcedFrame(POPT_EN_SOFTSCALE);
|
||||
}
|
||||
|
||||
|
||||
void emu_ResetGame(void)
|
||||
{
|
||||
PicoReset();
|
||||
reset_timing = 1;
|
||||
pemu_forced_frame(POPT_EN_SOFTSCALE);
|
||||
}
|
||||
|
||||
const char *plat_get_credits(void)
|
||||
|
|
120
pandora/emu.c
120
pandora/emu.c
|
@ -1,4 +1,4 @@
|
|||
// (c) Copyright 2006-2008 notaz, All rights reserved.
|
||||
// (c) Copyright 2006-2009 notaz, All rights reserved.
|
||||
// Free for non-commercial use.
|
||||
|
||||
// For commercial use, separate licencing terms must be obtained.
|
||||
|
@ -6,12 +6,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <linux/limits.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "../common/arm_utils.h"
|
||||
|
@ -43,15 +37,11 @@ static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
|
|||
static struct timeval noticeMsgTime = { 0, 0 }; // when started showing
|
||||
static int osd_fps_x;
|
||||
unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer
|
||||
int reset_timing = 0;
|
||||
|
||||
#define PICO_PEN_ADJUST_X 4
|
||||
#define PICO_PEN_ADJUST_Y 2
|
||||
static int pico_pen_x = 0, pico_pen_y = 240/2;
|
||||
|
||||
static void emu_msg_cb(const char *msg);
|
||||
static void emu_msg_tray_open(void);
|
||||
|
||||
|
||||
void plat_status_msg(const char *format, ...)
|
||||
{
|
||||
|
@ -64,7 +54,7 @@ void plat_status_msg(const char *format, ...)
|
|||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
|
||||
int emu_getMainDir(char *dst, int len)
|
||||
int plat_get_root_dir(char *dst, int len)
|
||||
{
|
||||
extern char **g_argv;
|
||||
int j;
|
||||
|
@ -79,49 +69,7 @@ int emu_getMainDir(char *dst, int len)
|
|||
return j + 1;
|
||||
}
|
||||
|
||||
void emu_Init(void)
|
||||
{
|
||||
// make temp buffer for alt renderer
|
||||
PicoDraw2FB = malloc((8+320)*(8+240+8));
|
||||
if (!PicoDraw2FB)
|
||||
{
|
||||
printf("PicoDraw2FB == 0\n");
|
||||
}
|
||||
|
||||
// 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);
|
||||
#ifndef NO_SYNC
|
||||
sync();
|
||||
#endif
|
||||
}
|
||||
|
||||
free(PicoDraw2FB);
|
||||
|
||||
PicoExit();
|
||||
}
|
||||
|
||||
void emu_prepareDefaultConfig(void)
|
||||
void pemu_prep_defconfig(void)
|
||||
{
|
||||
memset(&defaultConfig, 0, sizeof(defaultConfig));
|
||||
defaultConfig.EmuOpt = 0x8f | 0x00600; // | <- confirm_save, cd_leds
|
||||
|
@ -431,42 +379,6 @@ static void vidResetMode(void)
|
|||
}
|
||||
|
||||
|
||||
static void emu_msg_cb(const char *msg)
|
||||
{
|
||||
/*
|
||||
if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {
|
||||
// 8-bit renderers
|
||||
gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16), 0xe0, g_screen_width*16);
|
||||
osd_text(4, g_screen_height-16, msg);
|
||||
gp2x_memcpy_all_buffers((char *)g_screen_ptr+g_screen_width*(g_screen_height-16),
|
||||
g_screen_width*(g_screen_height-16), g_screen_width*16);
|
||||
} else {
|
||||
// 16bit accurate renderer
|
||||
gp2x_memset_all_buffers(g_screen_width*(g_screen_height-16)*2, 0, g_screen_width*16*2);
|
||||
osd_text(4, g_screen_height-16, msg);
|
||||
gp2x_memcpy_all_buffers((char *)g_screen_ptr+g_screen_width*(g_screen_height-16)*2,
|
||||
g_screen_width*(g_screen_height-16)*2, g_screen_width*16*2);
|
||||
}
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
noticeMsgTime.tv_sec -= 2;
|
||||
*/
|
||||
/* assumption: emu_msg_cb gets called only when something slow is about to happen */
|
||||
reset_timing = 1;
|
||||
}
|
||||
|
||||
static void emu_state_cb(const char *str)
|
||||
{
|
||||
clearArea(0);
|
||||
blit("", str);
|
||||
}
|
||||
|
||||
static void emu_msg_tray_open(void)
|
||||
{
|
||||
strcpy(noticeMsg, "CD tray opened");
|
||||
gettimeofday(¬iceMsgTime, 0);
|
||||
}
|
||||
|
||||
|
||||
static void update_volume(int has_changed, int is_up)
|
||||
{
|
||||
static int prev_frame = 0, wait_frames = 0;
|
||||
|
@ -520,7 +432,7 @@ static void SkipFrame(int do_audio)
|
|||
}
|
||||
|
||||
|
||||
void emu_forcedFrame(int opts)
|
||||
void pemu_forced_frame(int opts)
|
||||
{
|
||||
int po_old = PicoOpt;
|
||||
int eo_old = currentConfig.EmuOpt;
|
||||
|
@ -554,9 +466,8 @@ void emu_forcedFrame(int opts)
|
|||
currentConfig.EmuOpt = eo_old;
|
||||
}
|
||||
|
||||
void emu_platformDebugCat(char *str)
|
||||
void plat_debug_cat(char *str)
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
static void simpleWait(int thissec, int lim_time)
|
||||
|
@ -575,7 +486,7 @@ static void simpleWait(int thissec, int lim_time)
|
|||
}
|
||||
}
|
||||
|
||||
void emu_startSound(void)
|
||||
void pemu_sound_start(void)
|
||||
{
|
||||
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;
|
||||
int target_fps = Pico.m.pal ? 50 : 60;
|
||||
|
@ -603,17 +514,16 @@ void emu_startSound(void)
|
|||
}
|
||||
}
|
||||
|
||||
void emu_endSound(void)
|
||||
void pemu_sound_stop(void)
|
||||
{
|
||||
}
|
||||
|
||||
/* wait until we can write more sound */
|
||||
void emu_waitSound(void)
|
||||
void pemu_sound_wait(void)
|
||||
{
|
||||
// don't need to do anything, writes will block by themselves
|
||||
}
|
||||
|
||||
void emu_Loop(void)
|
||||
void pemu_loop(void)
|
||||
{
|
||||
char fpsbuff[24]; // fps count c string
|
||||
struct timeval tval; // timing
|
||||
|
@ -636,7 +546,7 @@ void emu_Loop(void)
|
|||
target_frametime = 1000000/target_fps;
|
||||
reset_timing = 1;
|
||||
|
||||
emu_startSound();
|
||||
pemu_sound_start();
|
||||
|
||||
// prepare CD buffer
|
||||
if (PicoAHW & PAHW_MCD) PicoCDBufferInit();
|
||||
|
@ -823,6 +733,7 @@ void emu_Loop(void)
|
|||
|
||||
// save SRAM
|
||||
if((currentConfig.EmuOpt & 1) && SRam.changed) {
|
||||
/* FIXME: plat_status_msg_busy_first */
|
||||
emu_state_cb("Writing SRAM/BRAM..");
|
||||
emu_SaveLoadGame(0, 1);
|
||||
SRam.changed = 0;
|
||||
|
@ -830,13 +741,6 @@ void emu_Loop(void)
|
|||
|
||||
// if in 8bit mode, generate 16bit image for menu background
|
||||
if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80))
|
||||
emu_forcedFrame(POPT_EN_SOFTSCALE);
|
||||
}
|
||||
|
||||
|
||||
void emu_ResetGame(void)
|
||||
{
|
||||
PicoReset();
|
||||
reset_timing = 1;
|
||||
pemu_forced_frame(POPT_EN_SOFTSCALE);
|
||||
}
|
||||
|
||||
|
|
58
psp/emu.c
58
psp/emu.c
|
@ -37,7 +37,6 @@ unsigned char *PicoDraw2FB = (unsigned char *)VRAM_CACHED_STUFF + 8; // +8 to be
|
|||
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
|
||||
|
@ -59,7 +58,7 @@ void plat_status_msg(const char *format, ...)
|
|||
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;
|
||||
|
@ -90,44 +89,18 @@ void emu_msg_cb(const char *msg)
|
|||
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
|
||||
|
@ -530,7 +503,7 @@ static void vidResetMode(void)
|
|||
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");
|
||||
}
|
||||
|
@ -613,7 +586,7 @@ static void sound_init(void)
|
|||
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;
|
||||
|
@ -651,7 +624,7 @@ void emu_startSound(void)
|
|||
}
|
||||
}
|
||||
|
||||
void emu_endSound(void)
|
||||
void pemu_sound_stop(void)
|
||||
{
|
||||
int i;
|
||||
if (samples_done == 0)
|
||||
|
@ -671,7 +644,7 @@ void emu_endSound(void)
|
|||
}
|
||||
|
||||
/* 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)
|
||||
|
@ -719,7 +692,7 @@ static void SkipFrame(void)
|
|||
PicoSkipFrame=0;
|
||||
}
|
||||
|
||||
void emu_forcedFrame(int opts)
|
||||
void pemu_forced_frame(int opts)
|
||||
{
|
||||
int po_old = PicoOpt;
|
||||
int eo_old = currentConfig.EmuOpt;
|
||||
|
@ -878,7 +851,7 @@ static void simpleWait(unsigned int until)
|
|||
sceKernelDelayThread(diff);
|
||||
}
|
||||
|
||||
void emu_Loop(void)
|
||||
void pemu_loop(void)
|
||||
{
|
||||
static int mp3_init_done = 0;
|
||||
char fpsbuff[24]; // fps count c string
|
||||
|
@ -923,9 +896,9 @@ void emu_Loop(void)
|
|||
|
||||
// prepare sound stuff
|
||||
PsndOut = NULL;
|
||||
if (currentConfig.EmuOpt & 4)
|
||||
if (currentConfig.EmuOpt & EOPT_EN_SOUND)
|
||||
{
|
||||
emu_startSound();
|
||||
pemu_sound_start();
|
||||
}
|
||||
|
||||
sceDisplayWaitVblankStart();
|
||||
|
@ -1071,7 +1044,7 @@ void emu_Loop(void)
|
|||
if (PicoAHW & PAHW_MCD) PicoCDBufferFree();
|
||||
|
||||
if (PsndOut != NULL) {
|
||||
emu_endSound();
|
||||
pemu_sound_stop();
|
||||
PsndOut = NULL;
|
||||
}
|
||||
|
||||
|
@ -1086,13 +1059,6 @@ void emu_Loop(void)
|
|||
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;
|
||||
|
|
|
@ -90,7 +90,7 @@ int pico_main(void)
|
|||
emu_HandleResume();
|
||||
break;
|
||||
}
|
||||
emu_Loop();
|
||||
pemu_loop();
|
||||
#ifdef GPROF
|
||||
goto endloop;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue