mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 14:57:46 -04:00
pandora: tripplebuffer fbdev out, refactoring
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@845 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
fbe111032e
commit
b188c2b6d0
17 changed files with 404 additions and 171 deletions
|
@ -1535,6 +1535,9 @@ void emu_loop(void)
|
||||||
|
|
||||||
emu_update_input();
|
emu_update_input();
|
||||||
PicoFrame();
|
PicoFrame();
|
||||||
|
pemu_finalize_frame(fpsbuff, notice_msg);
|
||||||
|
|
||||||
|
//plat_video_flip();
|
||||||
|
|
||||||
/* frame limiter */
|
/* frame limiter */
|
||||||
if (!reset_timing && !(currentConfig.EmuOpt & (EOPT_NO_FRMLIMIT|EOPT_EXT_FRMLIMIT)))
|
if (!reset_timing && !(currentConfig.EmuOpt & (EOPT_NO_FRMLIMIT|EOPT_EXT_FRMLIMIT)))
|
||||||
|
@ -1552,7 +1555,9 @@ void emu_loop(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pemu_update_display(fpsbuff, notice_msg);
|
// XXX: for some plats it might be better to flip before vsync
|
||||||
|
// (due to shadow registers in display hw)
|
||||||
|
plat_video_flip();
|
||||||
|
|
||||||
pframes_done++; frames_done++; frames_shown++;
|
pframes_done++; frames_done++; frames_shown++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -590,7 +590,16 @@ static void me_loop(menu_entry *menu, int *menu_sel, void (*draw_more)(void))
|
||||||
/* ***************************************** */
|
/* ***************************************** */
|
||||||
|
|
||||||
/* platform specific options and handlers */
|
/* platform specific options and handlers */
|
||||||
|
#if defined(__GP2X__)
|
||||||
#include "../gp2x/menu.c"
|
#include "../gp2x/menu.c"
|
||||||
|
#elif defined(PANDORA)
|
||||||
|
#include "../pandora/menu.c"
|
||||||
|
#else
|
||||||
|
#define MENU_OPTIONS_GFX
|
||||||
|
#define MENU_OPTIONS_ADV
|
||||||
|
#define mgn_opt_renderer NULL /* TODO */
|
||||||
|
#define menu_main_plat_draw NULL
|
||||||
|
#endif
|
||||||
|
|
||||||
static void draw_menu_credits(void)
|
static void draw_menu_credits(void)
|
||||||
{
|
{
|
||||||
|
@ -668,20 +677,18 @@ static void cdload_progress_cb(const char *fname, int percent)
|
||||||
void menu_romload_prepare(const char *rom_name)
|
void menu_romload_prepare(const char *rom_name)
|
||||||
{
|
{
|
||||||
const char *p = rom_name + strlen(rom_name);
|
const char *p = rom_name + strlen(rom_name);
|
||||||
|
int i;
|
||||||
|
|
||||||
while (p > rom_name && *p != '/')
|
while (p > rom_name && *p != '/')
|
||||||
p--;
|
p--;
|
||||||
|
|
||||||
/* fill both buffers, callbacks won't update in full */
|
/* fill all buffers, callbacks won't update in full */
|
||||||
plat_video_menu_begin();
|
for (i = 0; i < 3; i++) {
|
||||||
smalltext_out16(1, 1, "Loading", 0xffff);
|
|
||||||
smalltext_out16(1, me_sfont_h, p, 0xffff);
|
|
||||||
plat_video_menu_end();
|
|
||||||
|
|
||||||
plat_video_menu_begin();
|
plat_video_menu_begin();
|
||||||
smalltext_out16(1, 1, "Loading", 0xffff);
|
smalltext_out16(1, 1, "Loading", 0xffff);
|
||||||
smalltext_out16(1, me_sfont_h, p, 0xffff);
|
smalltext_out16(1, me_sfont_h, p, 0xffff);
|
||||||
plat_video_menu_end();
|
plat_video_menu_end();
|
||||||
|
}
|
||||||
|
|
||||||
PicoCartLoadProgressCB = load_progress_cb;
|
PicoCartLoadProgressCB = load_progress_cb;
|
||||||
PicoCDLoadProgressCB = cdload_progress_cb;
|
PicoCDLoadProgressCB = cdload_progress_cb;
|
||||||
|
@ -1508,7 +1515,7 @@ static menu_entry e_menu_adv_options[] =
|
||||||
mee_onoff ("Don't save last used ROM", MA_OPT2_NO_LAST_ROM, currentConfig.EmuOpt, EOPT_NO_AUTOSVCFG),
|
mee_onoff ("Don't save last used ROM", MA_OPT2_NO_LAST_ROM, currentConfig.EmuOpt, EOPT_NO_AUTOSVCFG),
|
||||||
mee_onoff ("Disable idle loop patching",MA_OPT2_NO_IDLE_LOOPS,PicoOpt, POPT_DIS_IDLE_DET),
|
mee_onoff ("Disable idle loop patching",MA_OPT2_NO_IDLE_LOOPS,PicoOpt, POPT_DIS_IDLE_DET),
|
||||||
mee_onoff ("Disable frame limiter", MA_OPT2_NO_FRAME_LIMIT,currentConfig.EmuOpt, EOPT_NO_FRMLIMIT),
|
mee_onoff ("Disable frame limiter", MA_OPT2_NO_FRAME_LIMIT,currentConfig.EmuOpt, EOPT_NO_FRMLIMIT),
|
||||||
MENU_GP2X_OPTIONS_ADV
|
MENU_OPTIONS_ADV
|
||||||
mee_end,
|
mee_end,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1530,7 +1537,7 @@ static int mh_opt_render(menu_id id, int keys)
|
||||||
static menu_entry e_menu_gfx_options[] =
|
static menu_entry e_menu_gfx_options[] =
|
||||||
{
|
{
|
||||||
mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer),
|
mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer),
|
||||||
MENU_GP2X_OPTIONS_GFX
|
MENU_OPTIONS_GFX
|
||||||
mee_end,
|
mee_end,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ void pemu_validate_config(void);
|
||||||
void pemu_loop_prep(void);
|
void pemu_loop_prep(void);
|
||||||
void pemu_loop_end(void);
|
void pemu_loop_end(void);
|
||||||
void pemu_forced_frame(int opts);
|
void pemu_forced_frame(int opts);
|
||||||
void pemu_update_display(const char *fps, const char *notice_msg);
|
void pemu_finalize_frame(const char *fps, const char *notice_msg);
|
||||||
|
|
||||||
void pemu_sound_start(void);
|
void pemu_sound_start(void);
|
||||||
void pemu_sound_stop(void);
|
void pemu_sound_stop(void);
|
||||||
|
@ -33,8 +33,10 @@ void plat_video_menu_enter(int is_rom_loaded);
|
||||||
void plat_video_menu_begin(void);
|
void plat_video_menu_begin(void);
|
||||||
void plat_video_menu_end(void);
|
void plat_video_menu_end(void);
|
||||||
|
|
||||||
|
void plat_video_flip(void);
|
||||||
void plat_video_wait_vsync(void);
|
void plat_video_wait_vsync(void);
|
||||||
void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu);
|
void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu);
|
||||||
|
|
||||||
void plat_update_volume(int has_changed, int is_up);
|
void plat_update_volume(int has_changed, int is_up);
|
||||||
|
|
||||||
int plat_is_dir(const char *path);
|
int plat_is_dir(const char *path);
|
||||||
|
|
|
@ -302,7 +302,7 @@ static int make_local_pal_sms(int fast_mode)
|
||||||
return 0x40;
|
return 0x40;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pemu_update_display(const char *fps, const char *notice)
|
void pemu_finalize_frame(const char *fps, const char *notice)
|
||||||
{
|
{
|
||||||
int emu_opt = currentConfig.EmuOpt;
|
int emu_opt = currentConfig.EmuOpt;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -344,7 +344,10 @@ void pemu_update_display(const char *fps, const char *notice)
|
||||||
draw_cd_leds();
|
draw_cd_leds();
|
||||||
if (PicoAHW & PAHW_PICO)
|
if (PicoAHW & PAHW_PICO)
|
||||||
draw_pico_ptr();
|
draw_pico_ptr();
|
||||||
|
}
|
||||||
|
|
||||||
|
void plat_video_flip(void)
|
||||||
|
{
|
||||||
gp2x_video_flip();
|
gp2x_video_flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,7 +414,8 @@ void plat_status_msg_clear(void)
|
||||||
void plat_status_msg_busy_next(const char *msg)
|
void plat_status_msg_busy_next(const char *msg)
|
||||||
{
|
{
|
||||||
plat_status_msg_clear();
|
plat_status_msg_clear();
|
||||||
pemu_update_display("", msg);
|
pemu_finalize_frame("", msg);
|
||||||
|
plat_video_flip();
|
||||||
emu_status_msg("");
|
emu_status_msg("");
|
||||||
|
|
||||||
/* assumption: msg_busy_next gets called only when
|
/* assumption: msg_busy_next gets called only when
|
||||||
|
|
16
gp2x/menu.c
16
gp2x/menu.c
|
@ -1,5 +1,3 @@
|
||||||
#ifdef __GP2X__
|
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "soc.h"
|
#include "soc.h"
|
||||||
|
|
||||||
|
@ -84,25 +82,17 @@ static const char *mgn_aopt_gamma(menu_id id, int *offs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define MENU_GP2X_OPTIONS_GFX \
|
#define MENU_OPTIONS_GFX \
|
||||||
mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling), \
|
mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling), \
|
||||||
mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX), \
|
mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX), \
|
||||||
mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma), \
|
mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma), \
|
||||||
mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA), \
|
mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA), \
|
||||||
mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC),
|
mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC),
|
||||||
|
|
||||||
#define MENU_GP2X_OPTIONS_ADV \
|
#define MENU_OPTIONS_ADV \
|
||||||
mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), \
|
mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), \
|
||||||
mee_onoff ("RAM overclock", MA_OPT2_RAMTIMINGS, currentConfig.EmuOpt, EOPT_RAM_TIMINGS), \
|
mee_onoff ("RAM overclock", MA_OPT2_RAMTIMINGS, currentConfig.EmuOpt, EOPT_RAM_TIMINGS), \
|
||||||
mee_onoff ("MMU hack", MA_OPT2_SQUIDGEHACK, currentConfig.EmuOpt, EOPT_MMUHACK), \
|
mee_onoff ("MMU hack", MA_OPT2_SQUIDGEHACK, currentConfig.EmuOpt, EOPT_MMUHACK), \
|
||||||
mee_onoff ("SVP dynarec", MA_OPT2_SVP_DYNAREC, PicoOpt, POPT_EN_SVP_DRC), \
|
mee_onoff ("SVP dynarec", MA_OPT2_SVP_DYNAREC, PicoOpt, POPT_EN_SVP_DRC), \
|
||||||
mee_onoff ("Status line in main menu", MA_OPT2_STATUS_LINE, currentConfig.EmuOpt, EOPT_SHOW_RTC ),
|
mee_onoff ("Status line in main menu", MA_OPT2_STATUS_LINE, currentConfig.EmuOpt, EOPT_SHOW_RTC),
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define MENU_GP2X_OPTIONS_GFX
|
|
||||||
#define MENU_GP2X_OPTIONS_ADV
|
|
||||||
#define mgn_opt_renderer NULL /* TODO */
|
|
||||||
#define menu_main_plat_draw NULL
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
# settings
|
# settings
|
||||||
|
#use_fbdev = 1
|
||||||
|
#fake_in_gp2x = 1
|
||||||
|
|
||||||
use_musashi = 1
|
use_musashi = 1
|
||||||
#use_fame = 1
|
#use_fame = 1
|
||||||
use_cz80 = 1
|
use_cz80 = 1
|
||||||
|
@ -8,7 +11,6 @@ use_sh2drc = 1
|
||||||
#drc_debug = 3
|
#drc_debug = 3
|
||||||
#drc_debug_interp = 1
|
#drc_debug_interp = 1
|
||||||
#profile = 1
|
#profile = 1
|
||||||
#fake_in_gp2x = 1
|
|
||||||
|
|
||||||
-include Makefile.local
|
-include Makefile.local
|
||||||
|
|
||||||
|
@ -24,8 +26,6 @@ ifeq "$(ARCH)" "arm"
|
||||||
CFLAGS += -mcpu=arm920t
|
CFLAGS += -mcpu=arm920t
|
||||||
DEFINES += ARM
|
DEFINES += ARM
|
||||||
endif
|
endif
|
||||||
LDFLAGS += -lpthread
|
|
||||||
LDFLAGS += -lX11
|
|
||||||
|
|
||||||
CC = $(CROSS)gcc
|
CC = $(CROSS)gcc
|
||||||
|
|
||||||
|
@ -37,6 +37,14 @@ OBJS += platform/common/main.o platform/common/emu.o platform/common/menu.o \
|
||||||
platform/common/config.o platform/common/fonts.o platform/common/readpng.o \
|
platform/common/config.o platform/common/fonts.o platform/common/readpng.o \
|
||||||
platform/common/input.o
|
platform/common/input.o
|
||||||
|
|
||||||
|
ifeq "$(use_fbdev)" "1"
|
||||||
|
DEFINES += FBDEV
|
||||||
|
OBJS += fbdev.o
|
||||||
|
else
|
||||||
|
LDFLAGS += -lpthread
|
||||||
|
LDFLAGS += -lX11
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq "$(fake_in_gp2x)" "1"
|
ifeq "$(fake_in_gp2x)" "1"
|
||||||
DEFINES += IN_GP2X FAKE_IN_GP2X
|
DEFINES += IN_GP2X FAKE_IN_GP2X
|
||||||
OBJS += platform/gp2x/in_gp2x.o
|
OBJS += platform/gp2x/in_gp2x.o
|
||||||
|
|
45
linux/emu.c
45
linux/emu.c
|
@ -17,18 +17,11 @@
|
||||||
|
|
||||||
|
|
||||||
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
|
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
|
||||||
unsigned char temp_frame[320 * 240 * 2];
|
|
||||||
unsigned char *PicoDraw2FB = temp_frame;
|
|
||||||
static int osd_fps_x;
|
|
||||||
char cpu_clk_name[] = "unused";
|
char cpu_clk_name[] = "unused";
|
||||||
|
|
||||||
extern void update_screen(void);
|
|
||||||
|
|
||||||
|
|
||||||
void pemu_prep_defconfig(void)
|
void pemu_prep_defconfig(void)
|
||||||
{
|
{
|
||||||
// XXX: move elsewhere
|
|
||||||
g_menubg_ptr = temp_frame;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void pemu_validate_config(void)
|
void pemu_validate_config(void)
|
||||||
|
@ -41,6 +34,7 @@ void pemu_validate_config(void)
|
||||||
// FIXME: dupes from GP2X, need cleanup
|
// FIXME: dupes from GP2X, need cleanup
|
||||||
static void (*osd_text)(int x, int y, const char *text);
|
static void (*osd_text)(int x, int y, const char *text);
|
||||||
|
|
||||||
|
/*
|
||||||
static void osd_text8(int x, int y, const char *text)
|
static void osd_text8(int x, int y, const char *text)
|
||||||
{
|
{
|
||||||
int len = strlen(text)*8;
|
int len = strlen(text)*8;
|
||||||
|
@ -55,6 +49,7 @@ static void osd_text8(int x, int y, const char *text)
|
||||||
}
|
}
|
||||||
emu_text_out8(x, y, text);
|
emu_text_out8(x, y, text);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
static void osd_text16(int x, int y, const char *text)
|
static void osd_text16(int x, int y, const char *text)
|
||||||
{
|
{
|
||||||
|
@ -108,18 +103,16 @@ static int EmuScanBegin16(unsigned int num)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pemu_update_display(const char *fps, const char *notice)
|
void pemu_finalize_frame(const char *fps, const char *notice)
|
||||||
{
|
{
|
||||||
if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {
|
if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {
|
||||||
if (notice)
|
if (notice)
|
||||||
osd_text(4, g_screen_height - 8, notice);
|
osd_text(4, g_screen_height - 8, notice);
|
||||||
if (currentConfig.EmuOpt & EOPT_SHOW_FPS)
|
if (currentConfig.EmuOpt & EOPT_SHOW_FPS)
|
||||||
osd_text(osd_fps_x, g_screen_height - 8, fps);
|
osd_text(g_screen_width - 60, g_screen_height - 8, fps);
|
||||||
}
|
}
|
||||||
if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))
|
if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))
|
||||||
draw_cd_leds();
|
draw_cd_leds();
|
||||||
|
|
||||||
update_screen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu)
|
void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu)
|
||||||
|
@ -139,7 +132,7 @@ void plat_video_menu_begin(void)
|
||||||
|
|
||||||
void plat_video_menu_end(void)
|
void plat_video_menu_end(void)
|
||||||
{
|
{
|
||||||
update_screen();
|
plat_video_flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void plat_status_msg_clear(void)
|
void plat_status_msg_clear(void)
|
||||||
|
@ -152,7 +145,8 @@ void plat_status_msg_clear(void)
|
||||||
void plat_status_msg_busy_next(const char *msg)
|
void plat_status_msg_busy_next(const char *msg)
|
||||||
{
|
{
|
||||||
plat_status_msg_clear();
|
plat_status_msg_clear();
|
||||||
pemu_update_display("", msg);
|
pemu_finalize_frame("", msg);
|
||||||
|
plat_video_flip();
|
||||||
emu_status_msg("");
|
emu_status_msg("");
|
||||||
reset_timing = 1;
|
reset_timing = 1;
|
||||||
}
|
}
|
||||||
|
@ -202,29 +196,30 @@ static void updateSound(int len)
|
||||||
|
|
||||||
void pemu_sound_start(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;
|
int target_fps = Pico.m.pal ? 50 : 60;
|
||||||
|
|
||||||
PsndOut = NULL;
|
PsndOut = NULL;
|
||||||
|
|
||||||
if (currentConfig.EmuOpt & EOPT_EN_SOUND)
|
if (currentConfig.EmuOpt & EOPT_EN_SOUND)
|
||||||
{
|
{
|
||||||
int snd_excess_add;
|
int snd_excess_add, frame_samples;
|
||||||
if (PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old)
|
int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;
|
||||||
|
|
||||||
PsndRerate(Pico.m.frame_count ? 1 : 0);
|
PsndRerate(Pico.m.frame_count ? 1 : 0);
|
||||||
|
|
||||||
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
|
frame_samples = PsndLen;
|
||||||
|
snd_excess_add = ((PsndRate - PsndLen * target_fps)<<16) / target_fps;
|
||||||
|
if (snd_excess_add != 0)
|
||||||
|
frame_samples++;
|
||||||
|
|
||||||
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
|
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
|
||||||
PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);
|
PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal);
|
||||||
sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);
|
sndout_oss_start(PsndRate, frame_samples, is_stereo);
|
||||||
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
|
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
|
||||||
PicoWriteSound = updateSound;
|
PicoWriteSound = updateSound;
|
||||||
plat_update_volume(0, 0);
|
plat_update_volume(0, 0);
|
||||||
memset(sndBuffer, 0, sizeof(sndBuffer));
|
memset(sndBuffer, 0, sizeof(sndBuffer));
|
||||||
PsndOut = sndBuffer;
|
PsndOut = sndBuffer;
|
||||||
PsndRate_old = PsndRate;
|
|
||||||
PicoOpt_old = PicoOpt;
|
|
||||||
pal_old = Pico.m.pal;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,8 +238,6 @@ void plat_debug_cat(char *str)
|
||||||
|
|
||||||
void emu_video_mode_change(int start_line, int line_count, int is_32cols)
|
void emu_video_mode_change(int start_line, int line_count, int is_32cols)
|
||||||
{
|
{
|
||||||
osd_fps_x = 260;
|
|
||||||
|
|
||||||
// clear whole screen in all buffers
|
// clear whole screen in all buffers
|
||||||
memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);
|
memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);
|
||||||
}
|
}
|
||||||
|
@ -292,10 +285,6 @@ void plat_wait_till_us(unsigned int us_to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void plat_video_wait_vsync(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *plat_get_credits(void)
|
const char *plat_get_credits(void)
|
||||||
{
|
{
|
||||||
return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n"
|
return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n"
|
||||||
|
|
162
linux/fbdev.c
Normal file
162
linux/fbdev.c
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <linux/fb.h>
|
||||||
|
#include <linux/matroxfb.h>
|
||||||
|
|
||||||
|
#include "../common/emu.h"
|
||||||
|
#include "fbdev.h"
|
||||||
|
|
||||||
|
#define FBDEV_MAX_BUFFERS 3
|
||||||
|
|
||||||
|
static int fbdev = -1;
|
||||||
|
static void *fbdev_mem = MAP_FAILED;
|
||||||
|
static int fbdev_mem_size;
|
||||||
|
static struct fb_var_screeninfo fbvar_old;
|
||||||
|
static struct fb_var_screeninfo fbvar_new;
|
||||||
|
static int fbdev_buffer_write;
|
||||||
|
|
||||||
|
void *fbdev_buffers[FBDEV_MAX_BUFFERS];
|
||||||
|
int fbdev_buffer_count;
|
||||||
|
|
||||||
|
void plat_video_flip(void)
|
||||||
|
{
|
||||||
|
int draw_buf;
|
||||||
|
|
||||||
|
if (fbdev_buffer_count < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
draw_buf = fbdev_buffer_write;
|
||||||
|
fbdev_buffer_write++;
|
||||||
|
if (fbdev_buffer_write >= fbdev_buffer_count)
|
||||||
|
fbdev_buffer_write = 0;
|
||||||
|
|
||||||
|
fbvar_new.yoffset = fbvar_old.yres * draw_buf;
|
||||||
|
g_screen_ptr = fbdev_buffers[fbdev_buffer_write];
|
||||||
|
}
|
||||||
|
|
||||||
|
void plat_video_wait_vsync(void)
|
||||||
|
{
|
||||||
|
int arg = 0;
|
||||||
|
ioctl(fbdev, FBIO_WAITFORVSYNC, &arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int vout_fbdev_init(int *w, int *h)
|
||||||
|
{
|
||||||
|
static const char *fbdev_name = "/dev/fb0";
|
||||||
|
int i, ret;
|
||||||
|
|
||||||
|
fbdev = open(fbdev_name, O_RDWR);
|
||||||
|
if (fbdev == -1) {
|
||||||
|
fprintf(stderr, "%s: ", fbdev_name);
|
||||||
|
perror("open");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ioctl(fbdev, FBIOGET_VSCREENINFO, &fbvar_old);
|
||||||
|
if (ret == -1) {
|
||||||
|
perror("FBIOGET_VSCREENINFO ioctl");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
fbvar_new = fbvar_old;
|
||||||
|
printf("%s: %ix%i@%d\n", fbdev_name, fbvar_old.xres, fbvar_old.yres, fbvar_old.bits_per_pixel);
|
||||||
|
*w = fbvar_old.xres;
|
||||||
|
*h = fbvar_old.yres;
|
||||||
|
fbdev_buffer_count = FBDEV_MAX_BUFFERS; // be optimistic
|
||||||
|
|
||||||
|
if (fbvar_new.bits_per_pixel != 16) {
|
||||||
|
printf(" switching to 16bpp\n");
|
||||||
|
fbvar_new.bits_per_pixel = 16;
|
||||||
|
ret = ioctl(fbdev, FBIOPUT_VSCREENINFO, &fbvar_new);
|
||||||
|
if (ret == -1) {
|
||||||
|
perror("FBIOPUT_VSCREENINFO ioctl");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fbvar_new.yres_virtual < fbvar_old.yres * fbdev_buffer_count) {
|
||||||
|
fbvar_new.yres_virtual = fbvar_old.yres * fbdev_buffer_count;
|
||||||
|
ret = ioctl(fbdev, FBIOPUT_VSCREENINFO, &fbvar_new);
|
||||||
|
if (ret == -1) {
|
||||||
|
fbdev_buffer_count = 1;
|
||||||
|
fprintf(stderr, "Warning: failed to increase virtual resolution, "
|
||||||
|
"doublebuffering disabled\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fbdev_mem_size = *w * *h * 2 * fbdev_buffer_count;
|
||||||
|
fbdev_mem = mmap(0, fbdev_mem_size, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);
|
||||||
|
if (fbdev_mem == MAP_FAILED && fbdev_buffer_count > 1) {
|
||||||
|
fbdev_mem_size = *w * *h * 2;
|
||||||
|
fbdev_buffer_count = 1;
|
||||||
|
fprintf(stderr, "Warning: can't map %d bytes, doublebuffering disabled\n", fbdev_mem_size);
|
||||||
|
fbdev_mem = mmap(0, fbdev_mem_size, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);
|
||||||
|
}
|
||||||
|
if (fbdev_mem == MAP_FAILED) {
|
||||||
|
perror("mmap framebuffer");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
memset(fbdev_mem, 0, fbdev_mem_size);
|
||||||
|
for (i = 0; i < fbdev_buffer_count; i++)
|
||||||
|
fbdev_buffers[i] = (char *)fbdev_mem + i * *w * *h * 2;
|
||||||
|
g_screen_ptr = fbdev_buffers[0];
|
||||||
|
|
||||||
|
// some checks
|
||||||
|
ret = 0;
|
||||||
|
ret = ioctl(fbdev, FBIO_WAITFORVSYNC, &ret);
|
||||||
|
if (ret != 0)
|
||||||
|
fprintf(stderr, "Warning: vsync doesn't seem to be supported\n");
|
||||||
|
|
||||||
|
if (fbdev_buffer_count > 1) {
|
||||||
|
fbdev_buffer_write = 0;
|
||||||
|
fbvar_new.yoffset = fbvar_old.yres * (fbdev_buffer_count - 1);
|
||||||
|
ret = ioctl(fbdev, FBIOPAN_DISPLAY, &fbvar_new);
|
||||||
|
if (ret != 0) {
|
||||||
|
fbdev_buffer_count = 1;
|
||||||
|
fprintf(stderr, "Warning: can't pan display, doublebuffering disabled\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("fbdev initialized.\n");
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
close(fbdev);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vout_fbdev_finish(void)
|
||||||
|
{
|
||||||
|
ioctl(fbdev, FBIOPUT_VSCREENINFO, &fbvar_old);
|
||||||
|
if (fbdev_mem != MAP_FAILED)
|
||||||
|
munmap(fbdev_mem, fbdev_mem_size);
|
||||||
|
if (fbdev >= 0)
|
||||||
|
close(fbdev);
|
||||||
|
fbdev_mem = NULL;
|
||||||
|
fbdev = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void *g_screen_ptr;
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int w, h;
|
||||||
|
vout_fbdev_init(&w, &h);
|
||||||
|
//while (1)
|
||||||
|
{
|
||||||
|
memset(g_screen_ptr, 0xff, fbdev_mem_size / 2);
|
||||||
|
plat_video_wait_vsync();
|
||||||
|
plat_video_flip();
|
||||||
|
memset(g_screen_ptr, 0x00, fbdev_mem_size / 2);
|
||||||
|
usleep(8000);
|
||||||
|
// plat_video_wait_vsync();
|
||||||
|
plat_video_flip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
5
linux/fbdev.h
Normal file
5
linux/fbdev.h
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
int vout_fbdev_init(int *w, int *h);
|
||||||
|
void vout_fbdev_finish(void);
|
||||||
|
|
||||||
|
extern void *fbdev_buffers[];
|
||||||
|
extern int fbdev_buffer_count;
|
62
linux/io.c
62
linux/io.c
|
@ -2,13 +2,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <semaphore.h>
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#include "../common/emu.h"
|
#include "../common/emu.h"
|
||||||
#include "../common/menu.h"
|
#include "../common/menu.h"
|
||||||
|
@ -17,15 +10,23 @@
|
||||||
|
|
||||||
#include "log_io.h"
|
#include "log_io.h"
|
||||||
|
|
||||||
unsigned long current_keys = 0;
|
int current_keys;
|
||||||
|
unsigned char *PicoDraw2FB;
|
||||||
|
|
||||||
|
#ifdef FBDEV
|
||||||
|
|
||||||
|
#include "fbdev.h"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <semaphore.h>
|
||||||
|
|
||||||
static int current_bpp = 16;
|
static int current_bpp = 16;
|
||||||
static int current_pal[256];
|
static int current_pal[256];
|
||||||
static const char *verstring = "PicoDrive " VERSION;
|
static const char *verstring = "PicoDrive " VERSION;
|
||||||
static int scr_changed = 0, scr_w = SCREEN_WIDTH, scr_h = SCREEN_HEIGHT;
|
static int scr_changed = 0, scr_w = SCREEN_WIDTH, scr_h = SCREEN_HEIGHT;
|
||||||
|
|
||||||
/* ifndef is for qemu build without video out */
|
|
||||||
#ifndef ARM
|
|
||||||
|
|
||||||
/* faking GP2X pad */
|
/* faking GP2X pad */
|
||||||
enum { GP2X_UP=0x1, GP2X_LEFT=0x4, GP2X_DOWN=0x10, GP2X_RIGHT=0x40,
|
enum { GP2X_UP=0x1, GP2X_LEFT=0x4, GP2X_DOWN=0x10, GP2X_RIGHT=0x40,
|
||||||
GP2X_START=1<<8, GP2X_SELECT=1<<9, GP2X_L=1<<10, GP2X_R=1<<11,
|
GP2X_START=1<<8, GP2X_SELECT=1<<9, GP2X_L=1<<10, GP2X_R=1<<11,
|
||||||
|
@ -245,23 +246,24 @@ static void xlib_init(void)
|
||||||
sem_wait(&xlib_sem);
|
sem_wait(&xlib_sem);
|
||||||
sem_destroy(&xlib_sem);
|
sem_destroy(&xlib_sem);
|
||||||
}
|
}
|
||||||
#endif // !ARM
|
|
||||||
|
|
||||||
/* --- */
|
/* --- */
|
||||||
|
|
||||||
static void realloc_screen(void)
|
static void realloc_screen(void)
|
||||||
{
|
{
|
||||||
void *old = g_screen_ptr;
|
int size = scr_w * scr_h * 2;
|
||||||
g_screen_width = scr_w;
|
g_screen_width = scr_w;
|
||||||
g_screen_height = scr_h;
|
g_screen_height = scr_h;
|
||||||
g_screen_ptr = calloc(g_screen_width * g_screen_height * 2, 1);
|
g_screen_ptr = realloc(g_screen_ptr, size);
|
||||||
free(old);
|
g_menubg_ptr = realloc(g_menubg_ptr, size);
|
||||||
|
memset(g_screen_ptr, 0, size);
|
||||||
|
memset(g_menubg_ptr, 0, size);
|
||||||
|
PicoDraw2FB = g_menubg_ptr;
|
||||||
scr_changed = 0;
|
scr_changed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_screen(void)
|
void plat_video_flip(void)
|
||||||
{
|
{
|
||||||
#ifndef ARM
|
|
||||||
unsigned int *image;
|
unsigned int *image;
|
||||||
int pixel_count, i;
|
int pixel_count, i;
|
||||||
|
|
||||||
|
@ -301,29 +303,45 @@ void update_screen(void)
|
||||||
realloc_screen();
|
realloc_screen();
|
||||||
ximage_realloc(xlib_display, DefaultVisual(xlib_display, 0));
|
ximage_realloc(xlib_display, DefaultVisual(xlib_display, 0));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void plat_video_wait_vsync(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !FBDEV
|
||||||
|
|
||||||
void plat_early_init(void)
|
void plat_early_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void plat_init(void)
|
void plat_init(void)
|
||||||
{
|
{
|
||||||
|
#ifdef FBDEV
|
||||||
|
int ret, w, h;
|
||||||
|
ret = vout_fbdev_init(&w, &h);
|
||||||
|
if (ret != 0)
|
||||||
|
exit(1);
|
||||||
|
g_screen_width = w;
|
||||||
|
g_menubg_ptr = realloc(g_menubg_ptr, w * g_screen_height * 2);
|
||||||
|
PicoDraw2FB = g_menubg_ptr;
|
||||||
|
#else
|
||||||
realloc_screen();
|
realloc_screen();
|
||||||
memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);
|
memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);
|
||||||
|
xlib_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
// snd
|
// snd
|
||||||
sndout_oss_init();
|
sndout_oss_init();
|
||||||
|
|
||||||
#ifndef ARM
|
|
||||||
xlib_init();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void plat_finish(void)
|
void plat_finish(void)
|
||||||
{
|
{
|
||||||
|
#ifdef FBDEV
|
||||||
|
vout_fbdev_finish();
|
||||||
|
#else
|
||||||
free(g_screen_ptr);
|
free(g_screen_ptr);
|
||||||
|
#endif
|
||||||
sndout_oss_exit();
|
sndout_oss_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,21 +25,27 @@ int sndout_oss_init(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sndout_oss_stop(void)
|
||||||
|
{
|
||||||
|
if (sounddev < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ioctl(sounddev, SOUND_PCM_SYNC, 0);
|
||||||
|
close(sounddev);
|
||||||
|
sounddev = -1;
|
||||||
|
}
|
||||||
|
|
||||||
int sndout_oss_start(int rate, int frame_samples, int stereo)
|
int sndout_oss_start(int rate, int frame_samples, int stereo)
|
||||||
{
|
{
|
||||||
static int s_oldrate = 0, s_old_fsamples = 0, s_oldstereo = 0;
|
static int s_oldrate = 0, s_old_fsamples = 0, s_oldstereo = 0;
|
||||||
int frag, bsize, bits, ret;
|
int frag, bsize, bits, ret;
|
||||||
|
|
||||||
// if no settings change, we don't need to do anything,
|
// GP2X: if no settings change, we don't need to do anything,
|
||||||
// since audio is never stopped
|
// since audio is never stopped there
|
||||||
if (rate == s_oldrate && s_old_fsamples == frame_samples && s_oldstereo == stereo)
|
if (sounddev >= 0 && rate == s_oldrate && s_old_fsamples == frame_samples && s_oldstereo == stereo)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (sounddev >= 0) {
|
sndout_oss_stop();
|
||||||
ioctl(sounddev, SOUND_PCM_SYNC, 0);
|
|
||||||
close(sounddev);
|
|
||||||
}
|
|
||||||
|
|
||||||
sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC);
|
sounddev = open("/dev/dsp", O_WRONLY|O_ASYNC);
|
||||||
if (sounddev == -1)
|
if (sounddev == -1)
|
||||||
{
|
{
|
||||||
|
@ -72,8 +78,10 @@ int sndout_oss_start(int rate, int frame_samples, int stereo)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
perror("failed to set audio format");
|
perror("failed to set audio format");
|
||||||
|
|
||||||
|
#ifdef __GP2X__
|
||||||
// not sure if this is still needed (avoiding driver bugs?)
|
// not sure if this is still needed (avoiding driver bugs?)
|
||||||
usleep(192*1024);
|
usleep(192*1024);
|
||||||
|
#endif
|
||||||
|
|
||||||
printf("sndout_oss_start: %d/%dbit/%s, %d buffers of %i bytes\n",
|
printf("sndout_oss_start: %d/%dbit/%s, %d buffers of %i bytes\n",
|
||||||
rate, bits, stereo ? "stereo" : "mono", frag >> 16, 1 << (frag & 0xffff));
|
rate, bits, stereo ? "stereo" : "mono", frag >> 16, 1 << (frag & 0xffff));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
int sndout_oss_init(void);
|
int sndout_oss_init(void);
|
||||||
int sndout_oss_start(int rate, int frame_samples, int stereo);
|
int sndout_oss_start(int rate, int frame_samples, int stereo);
|
||||||
|
void sndout_oss_stop(void);
|
||||||
int sndout_oss_write(const void *buff, int len);
|
int sndout_oss_write(const void *buff, int len);
|
||||||
int sndout_oss_can_write(int bytes);
|
int sndout_oss_can_write(int bytes);
|
||||||
void sndout_oss_sync(void);
|
void sndout_oss_sync(void);
|
||||||
|
|
|
@ -48,7 +48,8 @@ OBJS += pandora.o emu.o asm_utils.o
|
||||||
OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \
|
OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \
|
||||||
platform/common/arm_utils.o platform/common/mp3_helix.o platform/common/arm_linux.o \
|
platform/common/arm_utils.o platform/common/mp3_helix.o platform/common/arm_linux.o \
|
||||||
platform/common/readpng.o platform/common/input.o platform/common/main.o \
|
platform/common/readpng.o platform/common/input.o platform/common/main.o \
|
||||||
platform/linux/in_evdev.o platform/linux/sndout_oss.o platform/linux/plat.o
|
platform/linux/fbdev.o platform/linux/in_evdev.o platform/linux/sndout_oss.o \
|
||||||
|
platform/linux/plat.o
|
||||||
|
|
||||||
# ARM stuff
|
# ARM stuff
|
||||||
OBJS += pico/carthw/svp/compiler.o pico/carthw/svp/stub_arm.o
|
OBJS += pico/carthw/svp/compiler.o pico/carthw/svp/stub_arm.o
|
||||||
|
|
133
pandora/emu.c
133
pandora/emu.c
|
@ -4,24 +4,25 @@
|
||||||
// For commercial use, separate licencing terms must be obtained.
|
// For commercial use, separate licencing terms must be obtained.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "../common/emu.h"
|
#include "../common/emu.h"
|
||||||
#include "../common/menu.h"
|
#include "../common/menu.h"
|
||||||
#include "../common/plat.h"
|
#include "../common/plat.h"
|
||||||
#include "../common/arm_utils.h"
|
#include "../common/arm_utils.h"
|
||||||
#include "../linux/sndout_oss.h"
|
#include "../linux/sndout_oss.h"
|
||||||
|
#include "../linux/fbdev.h"
|
||||||
#include "asm_utils.h"
|
#include "asm_utils.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#include <pico/pico_int.h>
|
#include <pico/pico_int.h>
|
||||||
|
|
||||||
#define USE_320_SCREEN 1
|
//#define USE_320_SCREEN 1
|
||||||
|
|
||||||
|
|
||||||
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
|
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
|
||||||
static unsigned char temp_frame[g_screen_width * g_screen_height * 2];
|
static unsigned char temp_frame[g_screen_width * g_screen_height * 2];
|
||||||
unsigned char *PicoDraw2FB = temp_frame;
|
unsigned char *PicoDraw2FB = temp_frame;
|
||||||
static int osd_fps_x;
|
|
||||||
char cpu_clk_name[] = "unused";
|
char cpu_clk_name[] = "unused";
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +30,8 @@ void pemu_prep_defconfig(void)
|
||||||
{
|
{
|
||||||
// XXX: move elsewhere
|
// XXX: move elsewhere
|
||||||
g_menubg_ptr = temp_frame;
|
g_menubg_ptr = temp_frame;
|
||||||
|
|
||||||
|
defaultConfig.EmuOpt |= EOPT_VSYNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pemu_validate_config(void)
|
void pemu_validate_config(void)
|
||||||
|
@ -141,15 +144,40 @@ static int EmuScanEnd16(unsigned int num)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int EmuScanEnd16_32x(unsigned int num)
|
||||||
|
{
|
||||||
|
unsigned int *ps;
|
||||||
|
unsigned int *pd;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
ps = (unsigned int *)temp_frame;
|
||||||
|
pd = (unsigned int *)g_screen_ptr + (num*800*2 + 800/2 - 320*2/2) / 2;
|
||||||
|
|
||||||
|
for (len = 320/2; len > 0; len--, ps++) {
|
||||||
|
unsigned int p, p1;
|
||||||
|
p1 = *ps;
|
||||||
|
p = p1 << 16;
|
||||||
|
p |= p >> 16;
|
||||||
|
*pd = pd[800/2] = p;
|
||||||
|
pd++;
|
||||||
|
|
||||||
|
p = p1 >> 16;
|
||||||
|
p |= p << 16;
|
||||||
|
*pd = pd[800/2] = p;
|
||||||
|
pd++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif // USE_320_SCREEN
|
#endif // USE_320_SCREEN
|
||||||
|
|
||||||
void pemu_update_display(const char *fps, const char *notice)
|
void pemu_finalize_frame(const char *fps, const char *notice)
|
||||||
{
|
{
|
||||||
if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {
|
if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {
|
||||||
if (notice)
|
if (notice)
|
||||||
osd_text(4, 460, notice);
|
osd_text(4, 464, notice);
|
||||||
if (currentConfig.EmuOpt & EOPT_SHOW_FPS)
|
if (currentConfig.EmuOpt & EOPT_SHOW_FPS)
|
||||||
osd_text(osd_fps_x, 460, fps);
|
osd_text(640, 464, fps);
|
||||||
}
|
}
|
||||||
if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))
|
if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))
|
||||||
draw_cd_leds();
|
draw_cd_leds();
|
||||||
|
@ -172,19 +200,24 @@ void plat_video_menu_begin(void)
|
||||||
|
|
||||||
void plat_video_menu_end(void)
|
void plat_video_menu_end(void)
|
||||||
{
|
{
|
||||||
|
plat_video_flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void plat_status_msg_clear(void)
|
void plat_status_msg_clear(void)
|
||||||
{
|
{
|
||||||
unsigned short *d = (unsigned short *)g_screen_ptr + g_screen_width * g_screen_height;
|
int s = g_screen_width * g_screen_height * 2;
|
||||||
int l = g_screen_width * 8;
|
int l = g_screen_width * 16 * 2;
|
||||||
memset32((int *)(d - l), 0, l * 2 / 4);
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < fbdev_buffer_count; i++)
|
||||||
|
memset32((int *)((char *)fbdev_buffers[i] + s - l), 0, l / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plat_status_msg_busy_next(const char *msg)
|
void plat_status_msg_busy_next(const char *msg)
|
||||||
{
|
{
|
||||||
plat_status_msg_clear();
|
plat_status_msg_clear();
|
||||||
pemu_update_display("", msg);
|
pemu_finalize_frame("", msg);
|
||||||
|
plat_video_flip();
|
||||||
emu_status_msg("");
|
emu_status_msg("");
|
||||||
reset_timing = 1;
|
reset_timing = 1;
|
||||||
}
|
}
|
||||||
|
@ -224,13 +257,6 @@ void pemu_forced_frame(int opts)
|
||||||
PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites
|
PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites
|
||||||
currentConfig.EmuOpt |= 0x80;
|
currentConfig.EmuOpt |= 0x80;
|
||||||
|
|
||||||
#ifdef USE_320_SCREEN
|
|
||||||
PicoDrawSetColorFormat(1);
|
|
||||||
PicoScanBegin = EmuScanBegin16;
|
|
||||||
#else
|
|
||||||
PicoDrawSetColorFormat(-1);
|
|
||||||
PicoScanEnd = EmuScanEnd16;
|
|
||||||
#endif
|
|
||||||
Pico.m.dirtyPal = 1;
|
Pico.m.dirtyPal = 1;
|
||||||
PicoFrameDrawOnly();
|
PicoFrameDrawOnly();
|
||||||
|
|
||||||
|
@ -240,48 +266,59 @@ void pemu_forced_frame(int opts)
|
||||||
|
|
||||||
static void updateSound(int len)
|
static void updateSound(int len)
|
||||||
{
|
{
|
||||||
|
unsigned int t;
|
||||||
|
|
||||||
len <<= 1;
|
len <<= 1;
|
||||||
if (PicoOpt & POPT_EN_STEREO)
|
if (PicoOpt & POPT_EN_STEREO)
|
||||||
len <<= 1;
|
len <<= 1;
|
||||||
|
|
||||||
|
// sndout_oss_can_write() not reliable..
|
||||||
if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))
|
if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* avoid writing audio when lagging behind to prevent audio lag */
|
/* avoid writing audio when lagging behind to prevent audio lag */
|
||||||
if (PicoSkipFrame != 2)
|
if (PicoSkipFrame == 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
t = plat_get_ticks_ms();
|
||||||
sndout_oss_write(PsndOut, len);
|
sndout_oss_write(PsndOut, len);
|
||||||
|
t = plat_get_ticks_ms() - t;
|
||||||
|
if (t > 1)
|
||||||
|
printf("audio lag %u\n", t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pemu_sound_start(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;
|
int target_fps = Pico.m.pal ? 50 : 60;
|
||||||
|
|
||||||
PsndOut = NULL;
|
PsndOut = NULL;
|
||||||
|
|
||||||
if (currentConfig.EmuOpt & 4)
|
if (currentConfig.EmuOpt & EOPT_EN_SOUND)
|
||||||
{
|
{
|
||||||
int snd_excess_add;
|
int snd_excess_add, frame_samples;
|
||||||
if (PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old)
|
int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;
|
||||||
|
|
||||||
PsndRerate(Pico.m.frame_count ? 1 : 0);
|
PsndRerate(Pico.m.frame_count ? 1 : 0);
|
||||||
|
|
||||||
snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;
|
frame_samples = PsndLen;
|
||||||
|
snd_excess_add = ((PsndRate - PsndLen * target_fps)<<16) / target_fps;
|
||||||
|
if (snd_excess_add != 0)
|
||||||
|
frame_samples++;
|
||||||
|
|
||||||
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
|
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",
|
||||||
PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);
|
PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal);
|
||||||
sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);
|
sndout_oss_start(PsndRate, frame_samples * 2, is_stereo);
|
||||||
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
|
//sndout_oss_setvol(currentConfig.volume, currentConfig.volume);
|
||||||
PicoWriteSound = updateSound;
|
PicoWriteSound = updateSound;
|
||||||
plat_update_volume(0, 0);
|
plat_update_volume(0, 0);
|
||||||
memset(sndBuffer, 0, sizeof(sndBuffer));
|
memset(sndBuffer, 0, sizeof(sndBuffer));
|
||||||
PsndOut = sndBuffer;
|
PsndOut = sndBuffer;
|
||||||
PsndRate_old = PsndRate;
|
|
||||||
PicoOpt_old = PicoOpt;
|
|
||||||
pal_old = Pico.m.pal;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pemu_sound_stop(void)
|
void pemu_sound_stop(void)
|
||||||
{
|
{
|
||||||
|
sndout_oss_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void pemu_sound_wait(void)
|
void pemu_sound_wait(void)
|
||||||
|
@ -295,22 +332,32 @@ void plat_debug_cat(char *str)
|
||||||
|
|
||||||
void emu_video_mode_change(int start_line, int line_count, int is_32cols)
|
void emu_video_mode_change(int start_line, int line_count, int is_32cols)
|
||||||
{
|
{
|
||||||
osd_fps_x = 260;
|
int i;
|
||||||
|
|
||||||
// clear whole screen in all buffers
|
// clear whole screen in all buffers
|
||||||
memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);
|
for (i = 0; i < fbdev_buffer_count; i++)
|
||||||
}
|
memset32(fbdev_buffers[i], 0, g_screen_width * g_screen_height * 2 / 4);
|
||||||
|
|
||||||
void pemu_loop_prep(void)
|
|
||||||
{
|
|
||||||
#ifdef USE_320_SCREEN
|
#ifdef USE_320_SCREEN
|
||||||
PicoDrawSetColorFormat(1);
|
PicoDrawSetColorFormat(1);
|
||||||
PicoScanBegin = EmuScanBegin16;
|
PicoScanBegin = EmuScanBegin16;
|
||||||
#else
|
#else
|
||||||
|
if (PicoAHW & PAHW_32X) {
|
||||||
|
DrawLineDest = (unsigned short *)temp_frame;
|
||||||
|
PicoDrawSetColorFormat(1);
|
||||||
|
PicoScanBegin = NULL;
|
||||||
|
PicoScanEnd = EmuScanEnd16_32x;
|
||||||
|
} else {
|
||||||
PicoDrawSetColorFormat(-1);
|
PicoDrawSetColorFormat(-1);
|
||||||
|
PicoScanBegin = NULL;
|
||||||
PicoScanEnd = EmuScanEnd16;
|
PicoScanEnd = EmuScanEnd16;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void pemu_loop_prep(void)
|
||||||
|
{
|
||||||
|
emu_video_mode_change(0, 0, 0);
|
||||||
pemu_sound_start();
|
pemu_sound_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,23 +382,27 @@ void pemu_loop_end(void)
|
||||||
currentConfig.EmuOpt = eo_old;
|
currentConfig.EmuOpt = eo_old;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: avoid busy wait somehow? */
|
|
||||||
void plat_wait_till_us(unsigned int us_to)
|
void plat_wait_till_us(unsigned int us_to)
|
||||||
{
|
{
|
||||||
unsigned int now;
|
unsigned int now;
|
||||||
|
signed int diff;
|
||||||
|
|
||||||
spend_cycles(1024);
|
|
||||||
now = plat_get_ticks_us();
|
now = plat_get_ticks_us();
|
||||||
|
|
||||||
while ((signed int)(us_to - now) > 512)
|
// XXX: need to check NOHZ and djw kernel
|
||||||
{
|
diff = (signed int)(us_to - now);
|
||||||
|
if (diff > 10000) {
|
||||||
|
//printf("sleep %d\n", us_to - now);
|
||||||
|
usleep(diff * 15 / 16);
|
||||||
|
now = plat_get_ticks_us();
|
||||||
|
//printf(" wake %d\n", (signed)(us_to - now));
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
while ((signed int)(us_to - now) > 512) {
|
||||||
spend_cycles(1024);
|
spend_cycles(1024);
|
||||||
now = plat_get_ticks_us();
|
now = plat_get_ticks_us();
|
||||||
}
|
}
|
||||||
}
|
*/
|
||||||
|
|
||||||
void plat_video_wait_vsync(void)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *plat_get_credits(void)
|
const char *plat_get_credits(void)
|
||||||
|
|
|
@ -1,62 +1,39 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <linux/fb.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include "../linux/sndout_oss.h"
|
#include "../linux/sndout_oss.h"
|
||||||
#include "../common/arm_linux.h"
|
#include "../linux/fbdev.h"
|
||||||
#include "../common/emu.h"
|
#include "../common/emu.h"
|
||||||
|
|
||||||
static int fbdev = -1;
|
|
||||||
|
|
||||||
#define SCREEN_MAP_SIZE (800*480*2)
|
|
||||||
static void *screen = MAP_FAILED;
|
|
||||||
|
|
||||||
void plat_early_init(void)
|
void plat_early_init(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void plat_init(void)
|
void plat_init(void)
|
||||||
{
|
{
|
||||||
printf("entering init()\n"); fflush(stdout);
|
int ret, w, h;
|
||||||
|
|
||||||
fbdev = open("/dev/fb0", O_RDWR);
|
ret = vout_fbdev_init(&w, &h);
|
||||||
if (fbdev == -1)
|
if (ret != 0) {
|
||||||
{
|
fprintf(stderr, "couldn't init framebuffer\n");
|
||||||
perror("open(\"/dev/fb0\")");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
screen = mmap(0, SCREEN_MAP_SIZE, PROT_WRITE|PROT_READ, MAP_SHARED, fbdev, 0);
|
if (w != g_screen_width || h != g_screen_height) {
|
||||||
if (screen == MAP_FAILED)
|
fprintf(stderr, "%dx%d not supported\n", w, h);
|
||||||
{
|
vout_fbdev_finish();
|
||||||
perror("mmap(fbptr)");
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("fbptr %p\n", screen);
|
|
||||||
g_screen_ptr = screen;
|
|
||||||
|
|
||||||
// snd
|
// snd
|
||||||
sndout_oss_init();
|
sndout_oss_init();
|
||||||
|
|
||||||
printf("exitting init()\n"); fflush(stdout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void plat_finish(void)
|
void plat_finish(void)
|
||||||
{
|
{
|
||||||
if (screen != MAP_FAILED)
|
|
||||||
munmap(screen, SCREEN_MAP_SIZE);
|
|
||||||
if (fbdev >= 0)
|
|
||||||
close(fbdev);
|
|
||||||
|
|
||||||
sndout_oss_exit();
|
sndout_oss_exit();
|
||||||
|
vout_fbdev_finish();
|
||||||
|
|
||||||
printf("all done");
|
printf("all done");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#define CASE_SENSITIVE_FS 1 // CS filesystem
|
#define CASE_SENSITIVE_FS 1 // CS filesystem
|
||||||
#define DONT_OPEN_MANY_FILES 0
|
#define DONT_OPEN_MANY_FILES 0
|
||||||
#define REDUCE_IO_CALLS 0
|
#define REDUCE_IO_CALLS 0
|
||||||
#define SIMPLE_WRITE_SOUND 0
|
|
||||||
|
|
||||||
#define SCREEN_SIZE_FIXED 1
|
#define SCREEN_SIZE_FIXED 1
|
||||||
#define SCREEN_WIDTH 800
|
#define SCREEN_WIDTH 800
|
||||||
|
@ -22,6 +21,8 @@
|
||||||
// pico.c
|
// pico.c
|
||||||
#define CAN_HANDLE_240_LINES 1
|
#define CAN_HANDLE_240_LINES 1
|
||||||
|
|
||||||
|
#define SIMPLE_WRITE_SOUND 0
|
||||||
|
|
||||||
// logging emu events
|
// logging emu events
|
||||||
#define EL_LOGMASK (EL_STATUS|EL_IDLE) // (EL_STATUS|EL_ANOMALY|EL_UIO|EL_SRAMIO|EL_INTS|EL_CDPOLL) // xffff
|
#define EL_LOGMASK (EL_STATUS|EL_IDLE) // (EL_STATUS|EL_ANOMALY|EL_UIO|EL_SRAMIO|EL_INTS|EL_CDPOLL) // xffff
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,11 @@ void pemu_forced_frame(int opts)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void pemu_update_display(const char *fps, const char *notice_msg)
|
void pemu_finalize_frame(const char *fps, const char *notice_msg)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void plat_video_flip(void)
|
||||||
{
|
{
|
||||||
DirectScreen(g_screen_ptr);
|
DirectScreen(g_screen_ptr);
|
||||||
DirectPresent();
|
DirectPresent();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue