OBJS += platform/libpicofe/pandora/plat.o
USE_FRONTEND = 1
endif
+ifeq "$(PLATFORM)" "gp2x"
+OBJS += platform/common/arm_utils.o
+OBJS += platform/libpicofe/gp2x/in_gp2x.o
+OBJS += platform/libpicofe/gp2x/soc.o
+OBJS += platform/libpicofe/gp2x/soc_mmsp2.o
+OBJS += platform/libpicofe/gp2x/soc_pollux.o
+OBJS += platform/libpicofe/gp2x/plat.o
+OBJS += platform/libpicofe/gp2x/pollux_set.o
+OBJS += platform/gp2x/940ctl.o
+OBJS += platform/gp2x/plat.o
+OBJS += platform/gp2x/emu.o
+OBJS += platform/gp2x/vid_mmsp2.o
+OBJS += platform/gp2x/vid_pollux.o
+OBJS += platform/gp2x/warm.o
+USE_FRONTEND = 1
+PLATFORM_MP3 = 1
+endif
ifeq "$(PLATFORM)" "libretro"
OBJS += platform/libretro.o
endif
endif # USE_FRONTEND
OBJS += platform/common/mp3.o
-ifeq "$(HAVE_LIBAVCODEC)" "1"
+ifeq "$(PLATFORM_MP3)" "1"
+else ifeq "$(HAVE_LIBAVCODEC)" "1"
OBJS += platform/common/mp3_libavcodec.o
else
OBJS += platform/common/mp3_dummy.o
CFLAGS += -DIOS
ARCH := arm
- HAVE_NEON = 0
- USE_DYNAREC = 0
use_cyclone = 0
use_fame = 1
ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
ARCH = arm
- HAVE_NEON = 1
ARM_ASM = 1
- USE_DYNAREC = 1
else ifneq (,$(findstring armv,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so
SHARED := -shared -Wl,--no-undefined
ifneq (,$(findstring neon,$(platform)))
CFLAGS += -mfpu=neon
ASFLAGS += -mfpu=neon
- HAVE_NEON = 1
endif
ifneq (,$(findstring softfloat,$(platform)))
CFLAGS += -mfloat-abi=softfp
ARM_ASM = 1
endif
ARCH = arm
- USE_DYNAREC = 1
else
TARGET := $(TARGET_NAME)_retro.dll
CC = gcc
# some elements originated from qemu configure
set -e
-TMPC="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.c"
-TMPO="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.o"
-TMPB="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}"
+TMPC="/tmp/picodrive-conf-${RANDOM}-$$-${RANDOM}.c"
+TMPO="/tmp/picodrive-conf-${RANDOM}-$$-${RANDOM}.o"
+TMPB="/tmp/picodrive-conf-${RANDOM}-$$-${RANDOM}"
trap "rm -f $TMPC $TMPO $TMPB" EXIT INT QUIT TERM
rm -f config.log
compile_binary()
{
- c="$CC $CFLAGS $TMPC -o $TMPB $LDFLAGS $MAIN_LDLIBS $@"
+ c="$CC $CFLAGS $TMPC -o $TMPB $LDFLAGS $@"
echo $c >> config.log
$c >> config.log 2>&1
}
# setting options to "yes" or "no" will make that choice default,
# "" means "autodetect".
-platform_list="generic pandora"
+platform_list="generic pandora gp2x"
platform="generic"
sound_driver_list="oss alsa sdl"
sound_drivers=""
have_armv7=""
have_arm_neon=""
have_libavcodec=""
-enable_dynarec="yes"
need_sdl="no"
need_xlib="no"
# these are for known platforms
optimize_cortexa8="no"
optimize_arm926ej="no"
+optimize_arm920="no"
# hardcoded stuff
CC="${CC-${CROSS_COMPILE}gcc}"
optimize_cortexa8="yes"
have_arm_neon="yes"
;;
+ gp2x)
+ sound_drivers="oss"
+ optimize_arm920="yes"
+ CFLAGS="$CFLAGS -D__GP2X__"
+ if [ "$CROSS_COMPILE" = "arm-linux-" ]; then
+ # still using static, dynamic linking slows Wiz 1-10%
+ # also libm on F100 is not compatible
+ MAIN_LDLIBS="$MAIN_LDLIBS -static"
+ fi
+ ;;
*)
fail "unsupported platform: $platform"
;;
;;
--sound-drivers=*) sound_drivers="$optarg"
;;
- --enable-neon) have_arm_neon="yes"
- ;;
- --disable-neon) have_arm_neon="no"
- ;;
- --disable-dynarec) enable_dynarec="no"
- ;;
*) echo "ERROR: unknown option $opt"; show_help="yes"
;;
esac
echo " available: $platform_list"
echo " --sound-drivers=LIST sound output drivers [guessed]"
echo " available: $sound_driver_list"
- echo " --enable-neon"
- echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
- echo " --disable-dynarec disable dynamic recompiler"
- echo " (dynarec is only available and enabled on ARM)"
echo "influential environment variables:"
echo " CROSS_COMPILE CC CXX AS CFLAGS ASFLAGS LDFLAGS LDLIBS"
exit 1
CFLAGS="$CFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
ASFLAGS="$ASFLAGS -mcpu=arm926ej-s -mfloat-abi=softfp"
fi
+ if [ "$optimize_arm920" = "yes" ]; then
+ CFLAGS="$CFLAGS -mcpu=arm920t -mtune=arm920t"
+ ASFLAGS="$ASFLAGS -mcpu=arm920t -mfloat-abi=soft"
+ fi
if [ "x$have_arm_neon" = "x" ]; then
# detect NEON from user-supplied cflags to enable asm code
fi
# warn about common mistakes
- if [ "$have_armv5" != "yes" ]; then
+ if [ "$platform" != "gp2x" -a "$have_armv5" != "yes" ]; then
if ! echo "$CFLAGS" | grep -q -- '-mcpu=\|-march='; then
echo "Warning: compiling for ARMv4, is that really what you want?"
echo "You probably should specify -mcpu= or -march= like this:"
fi
;;
*)
- # dynarec only available on ARM
- enable_dynarec="no"
;;
esac
#include <png.h>
void main() { png_init_io(0, 0); }
EOF
- compile_binary
+# compile_binary
+ compile_object
}
check_oss()
fi
if echo $sound_drivers | grep -q "\<alsa\>"; then
MAIN_LDLIBS="-lasound $MAIN_LDLIBS"
- check_alsa || fail "please install libasound2-dev"
+ check_alsa -lasound || fail "please install libasound2-dev"
fi
fi
fail "sdl-config is missing; please install libsdl (libsdl1.2-dev)"
CFLAGS="$CFLAGS `sdl-config --cflags`"
MAIN_LDLIBS="`sdl-config --libs` $MAIN_LDLIBS"
- check_sdl || fail "please install libsdl (libsdl1.2-dev)"
+ check_sdl `sdl-config --libs` || fail "please install libsdl (libsdl1.2-dev)"
fi
cat > $TMPC <<EOF
# set things that failed to autodetect to "no"
test "x$have_armv6" != "x" || have_armv6="no"
test "x$have_armv7" != "x" || have_armv7="no"
-test "x$have_arm_neon" != "x" || have_arm_neon="no"
test "x$have_libavcodec" != "x" || have_libavcodec="no"
echo "architecture $ARCH"
echo "libraries $MAIN_LDLIBS"
echo "linker flags $LDFLAGS"
echo "libavcodec (mp3) $have_libavcodec"
-echo "enable dynarec $enable_dynarec"
# echo "ARMv7 optimizations $have_armv7"
-# echo "enable ARM NEON $have_arm_neon"
echo "# Automatically generated by configure" > $config_mak
printf "# Configured with:" >> $config_mak
if [ "$have_libavcodec" = "yes" ]; then
echo "HAVE_LIBAVCODEC = 1" >> $config_mak
fi
-if [ "$have_arm_neon" = "yes" ]; then
- echo "HAVE_NEON = 1" >> $config_mak
-fi
-if [ "$enable_dynarec" = "yes" ]; then
- echo "USE_DYNAREC = 1" >> $config_mak
+
+# GP2X toolchains are too old for UAL asm,
+# so add this here to not litter main Makefile
+if [ "$platform" = "g1p2x" ]; then
+ echo >> $config_mak
+ echo "%.o: %.S" >> $config_mak
+ echo " $(CC) $(CFLAGS) -E -c $^ -o /tmp/$(notdir $@).s" >> $config_mak
+ echo " $(AS) $(ASFLAGS) /tmp/$(notdir $@).s -o $@" >> $config_mak
fi
# use pandora's skin (for now)
void emu_prep_defconfig(void)\r
{\r
memset(&defaultConfig, 0, sizeof(defaultConfig));\r
- defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_EN_CD_LEDS;\r
+ defaultConfig.EmuOpt = 0x9d | EOPT_EN_CD_LEDS;\r
defaultConfig.s_PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 |\r
POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX |\r
POPT_EN_SVP_DRC|POPT_ACC_SPRITES |\r
#define EOPT_SHOW_FPS (1<<1)
#define EOPT_EN_SOUND (1<<2)
#define EOPT_GZIP_SAVES (1<<3)
-#define EOPT_MMUHACK (1<<4)
#define EOPT_NO_AUTOSVCFG (1<<5)
#define EOPT_16BPP (1<<7) // depreceted for .renderer
-#define EOPT_RAM_TIMINGS (1<<8)
#define EOPT_EN_CD_LEDS (1<<10)
#define EOPT_A_SN_GAMMA (1<<12)
#define EOPT_VSYNC (1<<13)
*/
#include <stdio.h>
#include <string.h>
+#include <time.h>
#include "emu.h"
#include "menu_pico.h"
#else
#define MENU_OPTIONS_GFX
#define MENU_OPTIONS_ADV
-#define menu_main_plat_draw NULL
#endif
static void make_bg(int no_scale)
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 frame limiter", MA_OPT2_NO_FRAME_LIMIT,currentConfig.EmuOpt, EOPT_NO_FRMLIMIT),
+ mee_onoff ("Enable dynarecs", 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),
MENU_OPTIONS_ADV
mee_end,
};
// ------------ gfx options menu ------------
-static const char h_gamma[] = "Gamma/brightness adjustment (default 100)";
+static const char h_gamma[] = "Gamma/brightness adjustment (default 1.00)";
+
+static const char *mgn_aopt_gamma(int id, int *offs)
+{
+ sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma % 100);
+ return static_buff;
+}
static menu_entry e_menu_gfx_options[] =
{
mee_enum ("Video output mode", MA_OPT_VOUT_MODE, plat_target.vout_method, men_dummy),
mee_enum ("Renderer", MA_OPT_RENDERER, currentConfig.renderer, renderer_names),
mee_enum ("Filter", MA_OPT3_FILTERING, currentConfig.filter, men_dummy),
- mee_range_h("Gamma adjustment", MA_OPT3_GAMMA, currentConfig.gamma, 1, 200, h_gamma),
+ mee_range_cust_h("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma, h_gamma),
MENU_OPTIONS_GFX
mee_end,
};
static int menu_loop_options(int id, int keys)
{
static int sel = 0;
- int i;
- i = me_id2offset(e_menu_options, MA_OPT_CPU_CLOCKS);
- e_menu_options[i].enabled = e_menu_options[i].name[0] ? 1 : 0;
me_enable(e_menu_options, MA_OPT_SAVECFG_GAME, PicoGameLoaded);
me_enable(e_menu_options, MA_OPT_LOADCFG, config_slot != config_slot_current);
" Lordus, Exophase, Rokas,\n"
" Nemesis, Tasco Deluxe";
+static void menu_main_draw_status(void)
+{
+ static time_t last_bat_read = 0;
+ static int last_bat_val = -1;
+ unsigned short *bp = g_screen_ptr;
+ int bat_h = me_mfont_h * 2 / 3;
+ int i, u, w, wfill, batt_val;
+ struct tm *tmp;
+ time_t ltime;
+ char time_s[16];
+
+ if (!(currentConfig.EmuOpt & EOPT_SHOW_RTC))
+ return;
+
+ ltime = time(NULL);
+ tmp = gmtime(<ime);
+ strftime(time_s, sizeof(time_s), "%H:%M", tmp);
+
+ text_out16(g_screen_width - me_mfont_w * 6, me_mfont_h + 2, time_s);
+
+ if (ltime - last_bat_read > 10) {
+ last_bat_read = ltime;
+ last_bat_val = batt_val = plat_target_bat_capacity_get();
+ }
+ else
+ batt_val = last_bat_val;
+
+ if (batt_val < 0 || batt_val > 100)
+ return;
+
+ /* battery info */
+ bp += (me_mfont_h * 2 + 2) * g_screen_width + g_screen_width - me_mfont_w * 3 - 3;
+ for (i = 0; i < me_mfont_w * 2; i++)
+ bp[i] = menu_text_color;
+ for (i = 0; i < me_mfont_w * 2; i++)
+ bp[i + g_screen_width * bat_h] = menu_text_color;
+ for (i = 0; i <= bat_h; i++)
+ bp[i * g_screen_width] =
+ bp[i * g_screen_width + me_mfont_w * 2] = menu_text_color;
+ for (i = 2; i < bat_h - 1; i++)
+ bp[i * g_screen_width - 1] =
+ bp[i * g_screen_width - 2] = menu_text_color;
+
+ w = me_mfont_w * 2 - 1;
+ wfill = batt_val * w / 100;
+ for (u = 1; u < bat_h; u++)
+ for (i = 0; i < wfill; i++)
+ bp[(w - i) + g_screen_width * u] = menu_text_color;
+}
+
static int main_menu_handler(int id, int keys)
{
const char *ret_name;
menu_enter(PicoGameLoaded);
in_set_config_int(0, IN_CFG_BLOCKING, 1);
- me_loop_d(e_menu_main, &sel, NULL, menu_main_plat_draw);
+ me_loop_d(e_menu_main, &sel, NULL, menu_main_draw_status);
if (PicoGameLoaded) {
if (engineState == PGS_Menu)
menu_init_base();
+ i = 0;
+#if defined(_SVP_DRC) || defined(DRC_SH2)
+ i = 1;
+#endif
+ me_enable(e_menu_adv_options, MA_OPT2_SVP_DYNAREC, i);
+
i = me_id2offset(e_menu_gfx_options, MA_OPT_VOUT_MODE);
e_menu_gfx_options[i].data = plat_target.vout_methods;
me_enable(e_menu_gfx_options, MA_OPT_VOUT_MODE,
me_enable(e_menu_gfx_options, MA_OPT3_FILTERING,
plat_target.hwfilters != NULL);
- me_enable(e_menu_gfx_options, MA_OPT3_GAMMA,
+ me_enable(e_menu_gfx_options, MA_OPT2_GAMMA,
plat_target.gamma_set != NULL);
+
+ i = me_id2offset(e_menu_options, MA_OPT_CPU_CLOCKS);
+ e_menu_options[i].enabled = 0;
+ if (plat_target.cpu_clock_set != NULL) {
+ e_menu_options[i].name = "CPU clock";
+ e_menu_options[i].enabled = 1;
+ }
}
MA_OPT2_GZIP_STATES,
MA_OPT2_NO_LAST_ROM,
MA_OPT2_RAMTIMINGS, /* gp2x */
- MA_OPT2_SQUIDGEHACK, /* gp2x */
MA_OPT2_STATUS_LINE, /* psp */
MA_OPT2_NO_FRAME_LIMIT, /* psp */
MA_OPT2_SVP_DYNAREC,
MA_OPT3_PRES_FULLSCR,
MA_OPT3_FILTERING,
MA_OPT3_VSYNC,
- MA_OPT3_GAMMA,
MA_OPT3_BLACKLVL,
MA_OPT3_LAYER_X,
MA_OPT3_LAYER_Y,
return retval;
}
-void mp3_start_play(void *f_, int pos)
+void mp3_start_play(void *f_, int pos1024)
{
unsigned char buf[2048];
FILE *f = f_;
if (!(PicoOpt & POPT_EN_MCD_CDDA) || f == NULL) // cdda disabled or no file?
return;
- ret = mp3dec_start();
- if (ret != 0)
- return;
-
- decoder_active = 1;
-
- mp3_current_file = f;
fseek(f, 0, SEEK_END);
mp3_file_len = ftell(f);
}
// seek..
- if (pos) {
+ if (pos1024 != 0) {
unsigned long long pos64 = mp3_file_len - mp3_file_pos;
- pos64 *= pos;
+ pos64 *= pos1024;
mp3_file_pos += pos64 >> 10;
}
+ ret = mp3dec_start(f, mp3_file_pos);
+ if (ret != 0) {
+ return;
+ }
+
+ mp3_current_file = f;
+ decoder_active = 1;
+
mp3dec_decode(mp3_current_file, &mp3_file_pos, mp3_file_len);
}
} else {
int ret, left = 1152 - cdda_out_pos;
- mix_samples(buffer, cdda_out_buffer + cdda_out_pos * 2,
- (left >> shr) * 2);
+ if (left > 0)
+ mix_samples(buffer, cdda_out_buffer + cdda_out_pos * 2,
+ (left >> shr) * 2);
ret = mp3dec_decode(mp3_current_file, &mp3_file_pos,
mp3_file_len);
int mp3_find_sync_word(const unsigned char *buf, int size);
/* decoder */
-int mp3dec_start(void);
+int mp3dec_start(FILE *f, int fpos_start);
int mp3dec_decode(FILE *f, int *file_pos, int file_len);
extern unsigned short mpeg1_l3_bitrates[16];
#include <stdio.h>
#include "mp3.h"
-int mp3dec_start(void)
+int mp3dec_start(FILE *f, int fpos_start)
{
return -1;
}
return 0;
}
-int mp3dec_start(void)
+int mp3dec_start(FILE *f, int fpos_start)
{
// must re-init decoder for new track
if (mp3dec)
return 0;
}
-int mp3dec_start(void)
+int mp3dec_start(FILE *f, int fpos_start)
{
void (*avcodec_register_all)(void);
AVCodec *(*avcodec_find_decoder)(enum CodecID id);
#include <fcntl.h>\r
#include <errno.h>\r
\r
-#include "code940/940shared.h"\r
-#include "soc_mmsp2.h"\r
-#include "soc.h"\r
+#include "../libpicofe/input.h"\r
+#include "../libpicofe/gp2x/soc_mmsp2.h"\r
+#include "../libpicofe/gp2x/soc.h"\r
#include "../common/mp3.h"\r
#include "../common/arm_utils.h"\r
-#include "../common/menu.h"\r
+#include "../common/menu_pico.h"\r
#include "../common/emu.h"\r
-#include "../common/input.h"\r
#include "../../pico/pico_int.h"\r
#include "../../pico/sound/ym2612.h"\r
#include "../../pico/sound/mix.h"\r
+#include "code940/940shared.h"\r
+#include "plat.h"\r
+#include "940ctl.h"\r
\r
static unsigned char *shared_mem = 0;\r
static _940_data_t *shared_data = 0;\r
\r
\r
#define CHECK_BUSY(job) \\r
- (gp2x_memregs[0x3b46>>1] & (1<<(job-1)))\r
+ (memregs[0x3b46>>1] & (1<<(job-1)))\r
\r
static void wait_busy_940(int job)\r
{\r
int i;\r
\r
job--;\r
- for (i = 0; (gp2x_memregs[0x3b46>>1] & (1<<job)) && i < 0x10000; i++)\r
+ for (i = 0; (memregs[0x3b46>>1] & (1<<job)) && i < 0x10000; i++)\r
spend_cycles(8*1024); // tested to be best for mp3 dec\r
if (i < 0x10000) return;\r
\r
for (i = 0; i < 8; i++)\r
printf("%i ", shared_ctl->vstarts[i]);\r
printf(")\n");\r
- printf("irq pending flags: DUALCPU %04x, SRCPND %08lx (see 26), INTPND %08lx\n",\r
- gp2x_memregs[0x3b46>>1], gp2x_memregl[0x4500>>2], gp2x_memregl[0x4510>>2]);\r
+ printf("irq pending flags: DUALCPU %04x, SRCPND %08x (see 26), INTPND %08x\n",\r
+ memregs[0x3b46>>1], memregl[0x4500>>2], memregl[0x4510>>2]);\r
printf("last lr: %08x, lastjob: %i\n", shared_ctl->last_lr, shared_ctl->lastjob);\r
printf("trying to interrupt..\n");\r
- gp2x_memregs[0x3B3E>>1] = 0xffff;\r
- for (i = 0; gp2x_memregs[0x3b46>>1] && i < 0x10000; i++)\r
+ memregs[0x3B3E>>1] = 0xffff;\r
+ for (i = 0; memregs[0x3b46>>1] && i < 0x10000; i++)\r
spend_cycles(8*1024);\r
printf("i = 0x%x\n", i);\r
- printf("irq pending flags: DUALCPU %04x, SRCPND %08lx (see 26), INTPND %08lx\n",\r
- gp2x_memregs[0x3b46>>1], gp2x_memregl[0x4500>>2], gp2x_memregl[0x4510>>2]);\r
+ printf("irq pending flags: DUALCPU %04x, SRCPND %08x (see 26), INTPND %08x\n",\r
+ memregs[0x3b46>>1], memregl[0x4500>>2], memregl[0x4510>>2]);\r
printf("last lr: %08x, lastjob: %i\n", shared_ctl->last_lr, shared_ctl->lastjob);\r
\r
- me_update_msg("940 crashed, too much overclock?");\r
+ menu_update_msg("940 crashed, too much overclock?");\r
engineState = PGS_Menu;\r
crashed_940 = 1;\r
}\r
\r
// generate interrupt for this job\r
job--;\r
- gp2x_memregs[(0x3B20+job*2)>>1] = 1;\r
+ memregs[(0x3B20+job*2)>>1] = 1;\r
\r
-// printf("added %i, pending %04x\n", job+1, gp2x_memregs[0x3b46>>1]);\r
+// printf("added %i, pending %04x\n", job+1, memregs[0x3b46>>1]);\r
}\r
\r
\r
reset940(1, 2);\r
pause940(1);\r
\r
- gp2x_memregs[0x3B40>>1] = 0; // disable DUALCPU interrupts for 920\r
- gp2x_memregs[0x3B42>>1] = 1; // enable DUALCPU interrupts for 940\r
+ memregs[0x3B40>>1] = 0; // disable DUALCPU interrupts for 920\r
+ memregs[0x3B42>>1] = 1; // enable DUALCPU interrupts for 940\r
\r
- gp2x_memregl[0x4504>>2] = 0; // make sure no FIQs will be generated\r
- gp2x_memregl[0x4508>>2] = ~(1<<26); // unmask DUALCPU ints in the undocumented 940's interrupt controller\r
+ memregl[0x4504>>2] = 0; // make sure no FIQs will be generated\r
+ memregl[0x4508>>2] = ~(1<<26); // unmask DUALCPU ints in the undocumented 940's interrupt controller\r
\r
\r
if (crashed_940)\r
text_out16(10, 100, "failed to open required file:");\r
text_out16(10, 110, CODE940_FILE);\r
gp2x_video_flip2();\r
- in_menu_wait(PBTN_MOK|PBTN_MBACK, 100);\r
+ in_menu_wait(PBTN_MOK|PBTN_MBACK, NULL, 100);\r
printf("failed to open %s\n", binpath);\r
exit(1);\r
}\r
\r
internal_reset();\r
\r
- loaded_mp3 = 0;\r
+ loaded_mp3 = NULL;\r
\r
- gp2x_memregs[0x3B46>>1] = 0xffff; // clear pending DUALCPU interrupts for 940\r
- gp2x_memregl[0x4500>>2] = 0xffffffff; // clear pending IRQs in SRCPND\r
- gp2x_memregl[0x4510>>2] = 0xffffffff; // clear pending IRQs in INTPND\r
+ memregs[0x3B46>>1] = 0xffff; // clear pending DUALCPU interrupts for 940\r
+ memregl[0x4500>>2] = 0xffffffff; // clear pending IRQs in SRCPND\r
+ memregl[0x4510>>2] = 0xffffffff; // clear pending IRQs in INTPND\r
\r
/* start the 940 */\r
reset940(0, 2);\r
\r
/***********************************************************/\r
\r
-static int mp3_samples_ready = 0, mp3_buffer_offs = 0;\r
-static int mp3_play_bufsel = 0, mp3_job_started = 0;\r
+// FIXME: double buffering no longer used..\r
\r
-void mp3_update(int *buffer, int length, int stereo)\r
+int mp3dec_decode(FILE *f, int *file_pos, int file_len)\r
{\r
- int length_mp3;\r
-\r
if (!(PicoOpt & POPT_EXT_FM)) {\r
- mp3_update_local(buffer, length, stereo);\r
- return;\r
+ //mp3_update_local(buffer, length, stereo);\r
+ return 0;\r
}\r
\r
// check if playback was started, track not ended\r
- if (loaded_mp3 == NULL || shared_ctl->mp3_offs >= shared_ctl->mp3_len)\r
- return;\r
-\r
- length_mp3 = length;\r
- if (PsndRate == 22050) length_mp3 <<= 1; // mp3s are locked to 44100Hz stereo\r
- else if (PsndRate == 11025) length_mp3 <<= 2; // so make length 44100ish\r
-\r
- /* do we have to wait? */\r
- if (mp3_job_started && mp3_samples_ready < length_mp3) {\r
- if (CHECK_BUSY(JOB940_MP3DECODE)) wait_busy_940(JOB940_MP3DECODE);\r
- mp3_job_started = 0;\r
- mp3_samples_ready += 1152;\r
+ if (loaded_mp3 == NULL || shared_ctl->mp3_offs >= shared_ctl->mp3_len) {\r
+ *file_pos = file_len;\r
+ return 1;\r
}\r
\r
- /* mix mp3 data, only stereo */\r
- if (mp3_samples_ready >= length_mp3)\r
- {\r
- int shr = 0;\r
- void (*mix_samples)(int *dest_buf, short *mp3_buf, int count) = mix_16h_to_32;\r
- if (PsndRate == 22050) { mix_samples = mix_16h_to_32_s1; shr = 1; }\r
- else if (PsndRate == 11025) { mix_samples = mix_16h_to_32_s2; shr = 2; }\r
+ /* do we have to wait? */\r
+ if (CHECK_BUSY(JOB940_MP3DECODE))\r
+ wait_busy_940(JOB940_MP3DECODE);\r
\r
- if (1152 - mp3_buffer_offs >= length_mp3) {\r
- mix_samples(buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length<<1);\r
+ memcpy(cdda_out_buffer,\r
+ shared_data->mp3_buffer[shared_ctl->mp3_buffsel],\r
+ sizeof(cdda_out_buffer));\r
\r
- mp3_buffer_offs += length_mp3;\r
- } else {\r
- // collect samples from both buffers..\r
- int left = 1152 - mp3_buffer_offs;\r
- if (mp3_play_bufsel == 0)\r
- {\r
- mix_samples(buffer, shared_data->mp3_buffer[0] + mp3_buffer_offs*2, length<<1);\r
- mp3_buffer_offs = length_mp3 - left;\r
- mp3_play_bufsel = 1;\r
- } else {\r
- mix_samples(buffer, shared_data->mp3_buffer[1] + mp3_buffer_offs*2, (left>>shr)<<1);\r
- mp3_buffer_offs = length_mp3 - left;\r
- mix_samples(buffer + ((left>>shr)<<1),\r
- shared_data->mp3_buffer[0], (mp3_buffer_offs>>shr)<<1);\r
- mp3_play_bufsel = 0;\r
- }\r
- }\r
- mp3_samples_ready -= length_mp3;\r
- }\r
+ *file_pos = shared_ctl->mp3_offs;\r
\r
- // ask to decode more if we already can\r
- if (!mp3_job_started)\r
- {\r
- mp3_job_started = 1;\r
- shared_ctl->mp3_buffsel ^= 1;\r
+ if (shared_ctl->mp3_offs < shared_ctl->mp3_len) {\r
+ // ask to decode more\r
+ //shared_ctl->mp3_buffsel ^= 1;\r
add_job_940(JOB940_MP3DECODE);\r
}\r
-}\r
\r
+ return 0;\r
+}\r
\r
-void mp3_start_play(void *f_, int pos) // pos is 0-1023\r
+int mp3dec_start(FILE *f, int fpos_start)\r
{\r
- int byte_offs = 0;\r
- FILE *f = f_;\r
-\r
- if (!(PicoOpt & POPT_EN_MCD_CDDA) || f == NULL)\r
- return;\r
-\r
if (!(PicoOpt & POPT_EXT_FM)) {\r
- mp3_start_play_local(f, pos);\r
- return;\r
+ //mp3_start_play_local(f, pos);\r
+ return -1;\r
}\r
\r
if (loaded_mp3 != f)\r
}\r
fseek(f, 0, SEEK_SET);\r
fread(mp3_mem, 1, MP3_SIZE_MAX, f);\r
- if (!feof(f)) printf("Warning: mp3 was too large, not all data loaded.\n");\r
+ if (!feof(f))\r
+ printf("Warning: mp3 was too large, not all data loaded.\n");\r
shared_ctl->mp3_len = ftell(f);\r
loaded_mp3 = f;\r
\r
- if (PicoOpt & POPT_EXT_FM) {\r
- // as we are going to change 940's cacheable area, we must invalidate it's cache..\r
- if (CHECK_BUSY(JOB940_MP3DECODE)) wait_busy_940(JOB940_MP3DECODE);\r
- add_job_940(JOB940_INVALIDATE_DCACHE);\r
- }\r
+ // as we are going to change 940's cacheable area,\r
+ // we must invalidate it's cache..\r
+ if (CHECK_BUSY(JOB940_MP3DECODE))\r
+ wait_busy_940(JOB940_MP3DECODE);\r
+ add_job_940(JOB940_INVALIDATE_DCACHE);\r
reset_timing = 1;\r
}\r
\r
- // seek..\r
- if (pos) {\r
- byte_offs = (shared_ctl->mp3_len << 6) >> 10;\r
- byte_offs *= pos;\r
- byte_offs >>= 6;\r
- }\r
- printf(" mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len);\r
+ shared_ctl->mp3_offs = fpos_start;\r
+ shared_ctl->mp3_buffsel = 0;\r
\r
- shared_ctl->mp3_offs = byte_offs;\r
+ add_job_940(JOB940_MP3RESET);\r
+ if (CHECK_BUSY(JOB940_MP3RESET))\r
+ wait_busy_940(JOB940_MP3RESET);\r
\r
- // reset buffer pointers and stuff..\r
- mp3_samples_ready = mp3_buffer_offs = mp3_play_bufsel = 0;\r
- mp3_job_started = 0;\r
- shared_ctl->mp3_buffsel = 1; // will change to 0 on first decode\r
+ // because we decode ahea, need to start now\r
+ if (shared_ctl->mp3_offs < shared_ctl->mp3_len) {\r
+ add_job_940(JOB940_MP3DECODE);\r
+ }\r
\r
- add_job_940(JOB940_MP3RESET);\r
- if (CHECK_BUSY(JOB940_MP3RESET)) wait_busy_940(JOB940_MP3RESET);\r
+ return 0;\r
}\r
\r
-CROSS ?= arm-linux-\r
-\r
-# settings\r
-use_cyclone = 1\r
-#use_musashi = 1\r
-use_drz80 = 1\r
-use_sh2drc = 1\r
-#use_sh2mame = 1\r
-\r
-asm_memory = 1\r
-asm_render = 1\r
-asm_ym2612 = 1\r
-asm_misc = 1\r
-asm_cdpico = 1\r
-asm_cdmemory = 1\r
-asm_32xdraw = 1\r
-#profile = 1\r
-#drc_debug = 3\r
-\r
--include Makefile.local\r
-\r
-ifeq "$(debug_cyclone)" "1"\r
-use_cyclone = 1\r
-use_musashi = 1\r
-endif\r
-ifeq "$(use_musashi)" "1"\r
-# due to CPU stop flag acces\r
-asm_cdpico = 0\r
-asm_cdmemory = 0\r
-endif\r
-\r
-ARCH = arm\r
-DEFINES += ARM __GP2X__ IN_GP2X IN_EVDEV # BENCHMARK\r
-CFLAGS += -Wall -Winline -I../.. -I.\r
-ifeq ($(DEBUG),)\r
-CFLAGS += -O3 -fomit-frame-pointer -fstrict-aliasing -ffast-math\r
-endif\r
-CFLAGS += -mcpu=arm920t -mtune=arm920t\r
-ASFLAGS = -mcpu=arm920t -mfloat-abi=soft\r
-LDFLAGS += -lm -lpng\r
-\r
-CC = $(CROSS)gcc\r
-STRIP = $(CROSS)strip\r
-AS = $(CROSS)as\r
-LD = $(CROSS)ld\r
-OBJCOPY = $(CROSS)objcopy\r
-\r
-# frontend\r
-OBJS += plat.o warm.o pollux_set.o soc.o soc_mmsp2.o soc_pollux.o soc_dummy.o emu.o in_gp2x.o\r
-# 940 core control\r
-OBJS += 940ctl.o\r
-\r
-# ARM stuff\r
-OBJS += pico/carthw/svp/compiler.o pico/carthw/svp/stub_arm.o\r
-OBJS += pico/sound/mix_arm.o\r
-\r
-# common\r
-OBJS += platform/common/emu.o platform/common/menu_pico.o platform/common/fonts.o platform/common/config.o \\r
- platform/common/arm_utils.o platform/common/arm_linux.o platform/common/readpng.o \\r
- platform/common/mp3_helix.o platform/common/input.o platform/common/main.o platform/common/mp3.o \\r
- platform/linux/sndout_oss.o platform/linux/plat.o platform/linux/in_evdev.o\r
-\r
-# unzip\r
-OBJS += unzip/unzip.o unzip/unzip_stream.o\r
-# zlib\r
-OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \\r
- zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o\r
-\r
-vpath %.c = ../..\r
-vpath %.s = ../..\r
-vpath %.S = ../..\r
-\r
-DIRS += platform/gp2x platform/linux zlib unzip \r
-\r
-\r
-all: mkdirs PicoDrive\r
-\r
-include ../common/common.mak\r
-include ../common/common_arm.mak\r
-include ../common/revision.mak\r
-\r
-CFLAGS += $(addprefix -D,$(DEFINES))\r
-\r
-# partial linking helps profiled builds due to section merging\r
-PicoDrive.o : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a\r
- $(LD) -r -o $@ $^\r
-\r
-# still using static, dynamic linking slows Wiz 1-10%\r
-# also libm on F100 is not compatible\r
-PicoDrive : PicoDrive.o\r
- @echo ">>>" $@\r
- $(CC) -static -o $@ $(CFLAGS) $^ $(LDFLAGS) -Wl,-Map=$@.map\r
-ifeq ($(DEBUG),)\r
- $(STRIP) $@\r
-endif\r
-\r
-up: PicoDrive\r
- @cp -v PicoDrive /mnt/gp2x/mnt/sd/emus/PicoDrive/\r
-\r
-clean: tidy\r
- $(RM) PicoDrive\r
-tidy:\r
- $(RM) $(OBJS)\r
-\r
readme.txt: ../../tools/textfilter ../base_readme.txt\r
../../tools/textfilter ../base_readme.txt $@ GP2X\r
\r
-# ----------- release -----------\r
VER ?= $(shell head -n 1 version.h | sed 's/.*"\(.*\)\.\(.*\)".*/\1\2/g')\r
CODE940 = code940/pico940_v3.bin\r
\r
\r
$(CODE940):\r
make -C code940/\r
-\r
#include "../../../pico/sound/ym2612.h"\r
-#include "../../common/helix/pub/mp3dec.h"\r
\r
// max 16 jobs, lower num means higher prio\r
enum _940_job_t {\r
typedef struct\r
{\r
YM2612 ym2612; /* current state of the emulated YM2612 */\r
- HMP3Decoder mp3dec; /* mp3 decoder's handle */\r
+ void *mp3dec; /* mp3 decoder's handle */\r
int ym_buffer[44100/50*2]; /* this is where the YM2612 samples will be mixed to */\r
short mp3_buffer[2][1152*2]; /* buffers for mp3 decoder's output */\r
} _940_data_t;\r
#include <stdlib.h>\r
#include <unistd.h>\r
\r
-#include "plat_gp2x.h"\r
-#include "soc.h"\r
-#include "soc_pollux.h"\r
-#include "../common/plat.h"\r
-#include "../common/menu.h"\r
+#include "../libpicofe/gp2x/plat_gp2x.h"\r
+#include "../libpicofe/gp2x/soc.h"\r
+#include "../libpicofe/input.h"\r
+#include "../libpicofe/plat.h"\r
+#include "../libpicofe/gp2x/soc_pollux.h"\r
+#include "../common/menu_pico.h"\r
#include "../common/arm_utils.h"\r
-#include "../common/fonts.h"\r
#include "../common/emu.h"\r
-#include "../common/config.h"\r
-#include "../common/input.h"\r
-#include "../linux/sndout_oss.h"\r
-#include "version.h"\r
+#include "../common/config_file.h"\r
+#include "../common/version.h"\r
+#include "plat.h"\r
\r
#include <pico/pico_int.h>\r
#include <pico/patch.h>\r
#endif\r
\r
\r
-extern int crashed_940;\r
+//extern int crashed_940;\r
\r
-static short __attribute__((aligned(4))) sndBuffer[2*(44100+100)/50];\r
static int osd_fps_x, osd_y, doing_bg_frame;\r
const char *renderer_names[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };\r
const char *renderer_names32x[] = { "accurate", "faster", "fastest", NULL };\r
static int (*emu_scan_begin)(unsigned int num) = NULL;\r
static int (*emu_scan_end)(unsigned int num) = NULL;\r
\r
-extern void *gp2x_screens[4];\r
-\r
\r
void pemu_prep_defconfig(void)\r
{\r
void plat_update_volume(int has_changed, int is_up)\r
{\r
static int prev_frame = 0, wait_frames = 0;\r
- int vol = currentConfig.volume;\r
int need_low_volume = 0;\r
+ int vol = currentConfig.volume;\r
gp2x_soc_t soc;\r
\r
soc = soc_detect();\r
if (need_low_volume && vol < 5 && prev_frame == Pico.m.frame_count - 1 && wait_frames < 12)\r
wait_frames++;\r
else {\r
- if (is_up) {\r
- if (vol < 99) vol++;\r
- } else {\r
- if (vol > 0) vol--;\r
- }\r
wait_frames = 0;\r
- sndout_oss_setvol(vol, vol);\r
- currentConfig.volume = vol;\r
+ plat_target_step_volume(¤tConfig.volume, is_up ? 1 : -1);\r
+ vol = currentConfig.volume;\r
}\r
emu_status_msg("VOL: %02i", vol);\r
prev_frame = Pico.m.frame_count;\r
}\r
}\r
\r
-static void oss_write_nonblocking(int len)\r
+void pemu_sound_start(void)\r
{\r
- // sndout_oss_can_write() is not reliable, only use with no_frmlimit\r
- if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))\r
- return;\r
+ emu_sound_start();\r
\r
- sndout_oss_write_nb(PsndOut, len);\r
-}\r
+ plat_target_step_volume(¤tConfig.volume, 0);\r
\r
-void pemu_sound_start(void)\r
-{\r
+#if 0\r
static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;\r
\r
PsndOut = NULL;\r
PicoOpt_old = PicoOpt;\r
pal_old = Pico.m.pal;\r
}\r
+#endif\r
}\r
\r
static const int sound_rates[] = { 44100, 32000, 22050, 16000, 11025, 8000 };\r
}\r
}\r
\r
-void pemu_sound_wait(void)\r
-{\r
- // don't need to do anything, writes will block by themselves\r
-}\r
-\r
void pemu_forced_frame(int no_scale, int do_emu)\r
{\r
doing_bg_frame = 1;\r
{\r
}\r
\r
-#if 0\r
-static void tga_dump(void)\r
+void plat_video_loop_prepare(void) \r
{\r
-#define BYTE unsigned char\r
-#define WORD unsigned short\r
- struct\r
- {\r
- BYTE IDLength; /* 00h Size of Image ID field */\r
- BYTE ColorMapType; /* 01h Color map type */\r
- BYTE ImageType; /* 02h Image type code */\r
- WORD CMapStart; /* 03h Color map origin */\r
- WORD CMapLength; /* 05h Color map length */\r
- BYTE CMapDepth; /* 07h Depth of color map entries */\r
- WORD XOffset; /* 08h X origin of image */\r
- WORD YOffset; /* 0Ah Y origin of image */\r
- WORD Width; /* 0Ch Width of image */\r
- WORD Height; /* 0Eh Height of image */\r
- BYTE PixelDepth; /* 10h Image pixel size */\r
- BYTE ImageDescriptor; /* 11h Image descriptor byte */\r
- } __attribute__((packed)) TGAHEAD;\r
- static unsigned short oldscr[320*240];\r
- FILE *f; char name[128]; int i;\r
-\r
- memset(&TGAHEAD, 0, sizeof(TGAHEAD));\r
- TGAHEAD.ImageType = 2;\r
- TGAHEAD.Width = 320;\r
- TGAHEAD.Height = 240;\r
- TGAHEAD.PixelDepth = 16;\r
- TGAHEAD.ImageDescriptor = 2<<4; // image starts at top-left\r
-\r
-#define CONV(X) (((X>>1)&0x7fe0)|(X&0x1f)) // 555?\r
-\r
- for (i = 0; i < 320*240; i++)\r
- if(oldscr[i] != CONV(((unsigned short *)g_screen_ptr)[i])) break;\r
- if (i < 320*240)\r
- {\r
- for (i = 0; i < 320*240; i++)\r
- oldscr[i] = CONV(((unsigned short *)g_screen_ptr)[i]);\r
- sprintf(name, "%05i.tga", Pico.m.frame_count);\r
- f = fopen(name, "wb");\r
- if (!f) { printf("!f\n"); exit(1); }\r
- fwrite(&TGAHEAD, 1, sizeof(TGAHEAD), f);\r
- fwrite(oldscr, 1, 320*240*2, f);\r
- fclose(f);\r
- }\r
+ // make sure we are in correct mode\r
+ change_renderer(0);\r
+ vid_reset_mode();\r
}\r
-#endif\r
\r
void pemu_loop_prep(void)\r
{\r
- static int gp2x_old_clock = -1, EmuOpt_old = 0, pal_old = 0;\r
- static int gp2x_old_gamma = 100;\r
- gp2x_soc_t soc;\r
-\r
- soc = soc_detect();\r
-\r
- if ((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_RAM_TIMINGS) {\r
- if (currentConfig.EmuOpt & EOPT_RAM_TIMINGS)\r
- set_ram_timings();\r
- else\r
- unset_ram_timings();\r
- }\r
-\r
- if (gp2x_old_clock < 0)\r
- gp2x_old_clock = default_cpu_clock;\r
- if (gp2x_old_clock != currentConfig.CPUclock && gp2x_set_cpuclk != NULL) {\r
- printf("changing clock to %i...", currentConfig.CPUclock); fflush(stdout);\r
- gp2x_set_cpuclk(currentConfig.CPUclock);\r
- gp2x_old_clock = currentConfig.CPUclock;\r
- printf(" done\n");\r
- }\r
-\r
- if (gp2x_old_gamma != currentConfig.gamma || ((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_A_SN_GAMMA)) {\r
- set_lcd_gamma(currentConfig.gamma, !!(currentConfig.EmuOpt & EOPT_A_SN_GAMMA));\r
- gp2x_old_gamma = currentConfig.gamma;\r
- printf("updated gamma to %i, A_SN's curve: %i\n", currentConfig.gamma, !!(currentConfig.EmuOpt&0x1000));\r
- }\r
-\r
- if (((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_VSYNC) || Pico.m.pal != pal_old) {\r
- if ((currentConfig.EmuOpt & EOPT_VSYNC) || soc == SOCID_POLLUX)\r
- set_lcd_custom_rate(Pico.m.pal);\r
- else if (EmuOpt_old & EOPT_VSYNC)\r
- unset_lcd_custom_rate();\r
- }\r
-\r
if (gp2x_dev_id == GP2X_DEV_CAANOO)\r
- in_set_config_int(in_name_to_id("evdev:pollux-analog"), IN_CFG_ABS_DEAD_ZONE,\r
- currentConfig.analog_deadzone);\r
-\r
- if ((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_MMUHACK)\r
- gp2x_make_fb_bufferable(currentConfig.EmuOpt & EOPT_MMUHACK);\r
-\r
- EmuOpt_old = currentConfig.EmuOpt;\r
- pal_old = Pico.m.pal;\r
-\r
- // make sure we are in correct mode\r
- change_renderer(0);\r
- vid_reset_mode();\r
+ in_set_config_int(in_name_to_id("evdev:pollux-analog"),\r
+ IN_CFG_ABS_DEAD_ZONE,\r
+ currentConfig.analog_deadzone);\r
\r
// dirty buffers better go now than during gameplay\r
sync();\r
sleep(0);\r
-\r
- pemu_sound_start();\r
}\r
\r
void pemu_loop_end(void)\r
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "../common/input.h"
-#include "in_gp2x.h"
-
-#define IN_GP2X_PREFIX "gp2x:"
-#define IN_GP2X_NBUTTONS 32
-
-/* note: in_gp2x hadles combos (if 2 btns have the same bind,
- * both must be pressed for action to happen) */
-static int in_gp2x_combo_keys = 0;
-static int in_gp2x_combo_acts = 0;
-static int gpiodev = -1; /* Wiz only */
-
-static int (*in_gp2x_get_bits)(void);
-
-static const char *in_gp2x_keys[IN_GP2X_NBUTTONS] = {
- [0 ... IN_GP2X_NBUTTONS-1] = NULL,
- [GP2X_BTN_UP] = "Up", [GP2X_BTN_LEFT] = "Left",
- [GP2X_BTN_DOWN] = "Down", [GP2X_BTN_RIGHT] = "Right",
- [GP2X_BTN_START] = "Start", [GP2X_BTN_SELECT] = "Select",
- [GP2X_BTN_L] = "L", [GP2X_BTN_R] = "R",
- [GP2X_BTN_A] = "A", [GP2X_BTN_B] = "B",
- [GP2X_BTN_X] = "X", [GP2X_BTN_Y] = "Y",
- [GP2X_BTN_VOL_DOWN] = "VOL DOWN",
- [GP2X_BTN_VOL_UP] = "VOL UP",
- [GP2X_BTN_PUSH] = "PUSH"
-};
-
-
-static int in_gp2x_get_mmsp2_bits(void)
-{
- extern volatile unsigned short *gp2x_memregs;
- int value;
- value = gp2x_memregs[0x1198>>1] & 0xff; // GPIO M
- if (value == 0xFD) value = 0xFA;
- if (value == 0xF7) value = 0xEB;
- if (value == 0xDF) value = 0xAF;
- if (value == 0x7F) value = 0xBE;
- value |= gp2x_memregs[0x1184>>1] & 0xFF00; // GPIO C
- value |= gp2x_memregs[0x1186>>1] << 16; // GPIO D
- value = ~value & 0x08c0ff55;
-
- return value;
-}
-
-static int in_gp2x_get_wiz_bits(void)
-{
- int r, value = 0;
- r = read(gpiodev, &value, 4);
- if (value & 0x02)
- value |= 0x05;
- if (value & 0x08)
- value |= 0x14;
- if (value & 0x20)
- value |= 0x50;
- if (value & 0x80)
- value |= 0x41;
-
- /* convert to GP2X style */
- value &= 0x7ff55;
- if (value & (1 << 16))
- value |= 1 << GP2X_BTN_VOL_UP;
- if (value & (1 << 17))
- value |= 1 << GP2X_BTN_VOL_DOWN;
- if (value & (1 << 18))
- value |= 1 << GP2X_BTN_PUSH;
- value &= ~0x70000;
-
- return value;
-}
-
-#ifdef FAKE_IN_GP2X
-volatile unsigned short *gp2x_memregs;
-int gp2x_dev_id = -1;
-
-static int in_gp2x_get_fake_bits(void)
-{
- extern int current_keys;
- return current_keys;
-}
-#endif
-
-static void in_gp2x_probe(void)
-{
- switch (gp2x_dev_id)
- {
- case GP2X_DEV_GP2X:
- in_gp2x_get_bits = in_gp2x_get_mmsp2_bits;
- break;
- case GP2X_DEV_WIZ:
- gpiodev = open("/dev/GPIO", O_RDONLY);
- if (gpiodev < 0) {
- perror("in_gp2x: couldn't open /dev/GPIO");
- return;
- }
- in_gp2x_get_bits = in_gp2x_get_wiz_bits;
- break;
- // we'll use evdev for Caanoo
- default:
-#ifdef FAKE_IN_GP2X
- in_gp2x_get_bits = in_gp2x_get_fake_bits;
- break;
-#endif
- return;
- }
-
- in_register(IN_GP2X_PREFIX "GP2X pad", -1, NULL,
- IN_GP2X_NBUTTONS, in_gp2x_keys, 1);
-}
-
-static void in_gp2x_free(void *drv_data)
-{
- if (gpiodev >= 0) {
- close(gpiodev);
- gpiodev = -1;
- }
-}
-
-static const char * const *
-in_gp2x_get_key_names(int *count)
-{
- *count = IN_GP2X_NBUTTONS;
- return in_gp2x_keys;
-}
-
-/* ORs result with pressed buttons */
-static int in_gp2x_update(void *drv_data, const int *binds, int *result)
-{
- int type_start = 0;
- int i, t, keys;
-
- keys = in_gp2x_get_bits();
-
- if (keys & in_gp2x_combo_keys) {
- result[IN_BINDTYPE_EMU] = in_combos_do(keys, binds, GP2X_BTN_PUSH,
- in_gp2x_combo_keys, in_gp2x_combo_acts);
- type_start = IN_BINDTYPE_PLAYER12;
- }
-
- for (i = 0; keys; i++, keys >>= 1) {
- if (!(keys & 1))
- continue;
-
- for (t = type_start; t < IN_BINDTYPE_COUNT; t++)
- result[t] |= binds[IN_BIND_OFFS(i, t)];
- }
-
- return 0;
-}
-
-int in_gp2x_update_keycode(void *data, int *is_down)
-{
- static int old_val = 0;
- int val, diff, i;
-
- val = in_gp2x_get_bits();
- diff = val ^ old_val;
- if (diff == 0)
- return -1;
-
- /* take one bit only */
- for (i = 0; i < sizeof(diff)*8; i++)
- if (diff & (1<<i))
- break;
-
- old_val ^= 1 << i;
-
- if (is_down)
- *is_down = !!(val & (1<<i));
- return i;
-}
-
-static const struct {
- short key;
- short pbtn;
-} key_pbtn_map[] =
-{
- { GP2X_BTN_UP, PBTN_UP },
- { GP2X_BTN_DOWN, PBTN_DOWN },
- { GP2X_BTN_LEFT, PBTN_LEFT },
- { GP2X_BTN_RIGHT, PBTN_RIGHT },
- { GP2X_BTN_B, PBTN_MOK },
- { GP2X_BTN_X, PBTN_MBACK },
- { GP2X_BTN_A, PBTN_MA2 },
- { GP2X_BTN_Y, PBTN_MA3 },
- { GP2X_BTN_L, PBTN_L },
- { GP2X_BTN_R, PBTN_R },
- { GP2X_BTN_SELECT, PBTN_MENU },
-};
-
-#define KEY_PBTN_MAP_SIZE (sizeof(key_pbtn_map) / sizeof(key_pbtn_map[0]))
-
-static int in_gp2x_menu_translate(void *drv_data, int keycode)
-{
- int i;
- if (keycode < 0)
- {
- /* menu -> kc */
- keycode = -keycode;
- for (i = 0; i < KEY_PBTN_MAP_SIZE; i++)
- if (key_pbtn_map[i].pbtn == keycode)
- return key_pbtn_map[i].key;
- }
- else
- {
- for (i = 0; i < KEY_PBTN_MAP_SIZE; i++)
- if (key_pbtn_map[i].key == keycode)
- return key_pbtn_map[i].pbtn;
- }
-
- return 0;
-}
-
-#if 0 // TODO: move to pico
-static const struct {
- short code;
- char btype;
- char bit;
-} in_gp2x_defbinds[] =
-{
- /* MXYZ SACB RLDU */
- { BTN_UP, IN_BINDTYPE_PLAYER12, 0 },
- { BTN_DOWN, IN_BINDTYPE_PLAYER12, 1 },
- { BTN_LEFT, IN_BINDTYPE_PLAYER12, 2 },
- { BTN_RIGHT, IN_BINDTYPE_PLAYER12, 3 },
- { BTN_X, IN_BINDTYPE_PLAYER12, 4 }, /* B */
- { BTN_B, IN_BINDTYPE_PLAYER12, 5 }, /* C */
- { BTN_A, IN_BINDTYPE_PLAYER12, 6 }, /* A */
- { BTN_START, IN_BINDTYPE_PLAYER12, 7 },
- { BTN_SELECT, IN_BINDTYPE_EMU, PEVB_MENU },
-// { BTN_Y, IN_BINDTYPE_EMU, PEVB_SWITCH_RND },
- { BTN_L, IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
- { BTN_R, IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
- { BTN_VOL_UP, IN_BINDTYPE_EMU, PEVB_VOL_UP },
- { BTN_VOL_DOWN, IN_BINDTYPE_EMU, PEVB_VOL_DOWN },
- { 0, 0, 0 },
-};
-#endif
-
-/* remove binds of missing keys, count remaining ones */
-static int in_gp2x_clean_binds(void *drv_data, int *binds, int *def_binds)
-{
- int i, count = 0;
-// int eb, have_vol = 0, have_menu = 0;
-
- for (i = 0; i < IN_GP2X_NBUTTONS; i++) {
- int t, offs;
- for (t = 0; t < IN_BINDTYPE_COUNT; t++) {
- offs = IN_BIND_OFFS(i, t);
- if (in_gp2x_keys[i] == NULL)
- binds[offs] = def_binds[offs] = 0;
- if (binds[offs])
- count++;
- }
-#if 0
- eb = binds[IN_BIND_OFFS(i, IN_BINDTYPE_EMU)];
- if (eb & (PEV_VOL_DOWN|PEV_VOL_UP))
- have_vol = 1;
- if (eb & PEV_MENU)
- have_menu = 1;
-#endif
- }
-
- // TODO: move to pico
-#if 0
- /* autobind some important keys, if they are unbound */
- if (!have_vol && binds[GP2X_BTN_VOL_UP] == 0 && binds[GP2X_BTN_VOL_DOWN] == 0) {
- binds[IN_BIND_OFFS(GP2X_BTN_VOL_UP, IN_BINDTYPE_EMU)] = PEV_VOL_UP;
- binds[IN_BIND_OFFS(GP2X_BTN_VOL_DOWN, IN_BINDTYPE_EMU)] = PEV_VOL_DOWN;
- count += 2;
- }
-
- if (!have_menu) {
- binds[IN_BIND_OFFS(GP2X_BTN_SELECT, IN_BINDTYPE_EMU)] = PEV_MENU;
- count++;
- }
-#endif
-
- in_combos_find(binds, GP2X_BTN_PUSH, &in_gp2x_combo_keys, &in_gp2x_combo_acts);
-
- return count;
-}
-
-static const in_drv_t in_gp2x_drv = {
- .prefix = IN_GP2X_PREFIX,
- .probe = in_gp2x_probe,
- .free = in_gp2x_free,
- .get_key_names = in_gp2x_get_key_names,
- .clean_binds = in_gp2x_clean_binds,
- .update = in_gp2x_update,
- .update_keycode = in_gp2x_update_keycode,
- .menu_translate = in_gp2x_menu_translate,
-};
-
-void in_gp2x_init(const struct in_default_bind *defbinds)
-{
- if (gp2x_dev_id == GP2X_DEV_WIZ)
- in_gp2x_keys[GP2X_BTN_START] = "MENU";
-
- in_gp2x_combo_keys = in_gp2x_combo_acts = 0;
-
- in_register_driver(&in_gp2x_drv, defbinds);
-}
-
+++ /dev/null
-
-struct in_default_bind;
-
-void in_gp2x_init(const struct in_default_bind *defbinds);
-
-enum { GP2X_BTN_UP = 0, GP2X_BTN_LEFT = 2, GP2X_BTN_DOWN = 4, GP2X_BTN_RIGHT = 6,
- GP2X_BTN_START = 8, GP2X_BTN_SELECT = 9, GP2X_BTN_L = 10, GP2X_BTN_R = 11,
- GP2X_BTN_A = 12, GP2X_BTN_B = 13, GP2X_BTN_X = 14, GP2X_BTN_Y = 15,
- GP2X_BTN_VOL_UP = 23, GP2X_BTN_VOL_DOWN = 22, GP2X_BTN_PUSH = 27 };
-
-/* FIXME */
-#ifndef GP2X_DEV_GP2X
-extern int gp2x_dev_id;
-#define GP2X_DEV_GP2X 1
-#define GP2X_DEV_WIZ 2
-#define GP2X_DEV_CAANOO 3
-#endif
-#include <time.h>
-#include "soc.h"
-#include "plat_gp2x.h"
-
-static void menu_main_plat_draw(void)
-{
- static time_t last_bat_read = 0;
- static int last_bat_val = -1;
- unsigned short *bp = g_screen_ptr;
- int bat_h = me_mfont_h * 2 / 3;
- int i, u, w, wfill, batt_val;
- struct tm *tmp;
- time_t ltime;
- char time_s[16];
-
- if (!(currentConfig.EmuOpt & EOPT_SHOW_RTC))
- return;
-
- ltime = time(NULL);
- tmp = gmtime(<ime);
- strftime(time_s, sizeof(time_s), "%H:%M", tmp);
-
- text_out16(g_screen_width - me_mfont_w * 6, me_mfont_h + 2, time_s);
-
- if (ltime - last_bat_read > 10) {
- last_bat_read = ltime;
- last_bat_val = batt_val = gp2x_read_battery();
- }
- else
- batt_val = last_bat_val;
-
- if (batt_val < 0 || batt_val > 100)
- return;
-
- /* battery info */
- bp += (me_mfont_h * 2 + 2) * g_screen_width + g_screen_width - me_mfont_w * 3 - 3;
- for (i = 0; i < me_mfont_w * 2; i++)
- bp[i] = menu_text_color;
- for (i = 0; i < me_mfont_w * 2; i++)
- bp[i + g_screen_width * bat_h] = menu_text_color;
- for (i = 0; i <= bat_h; i++)
- bp[i * g_screen_width] =
- bp[i * g_screen_width + me_mfont_w * 2] = menu_text_color;
- for (i = 2; i < bat_h - 1; i++)
- bp[i * g_screen_width - 1] =
- bp[i * g_screen_width - 2] = menu_text_color;
-
- w = me_mfont_w * 2 - 1;
- wfill = batt_val * w / 100;
- for (u = 1; u < bat_h; u++)
- for (i = 0; i < wfill; i++)
- bp[(w - i) + g_screen_width * u] = menu_text_color;
-}
+#include "../libpicofe/gp2x/plat_gp2x.h"
// ------------ gfx options menu ------------
-static const char *mgn_aopt_gamma(int id, int *offs)
-{
- sprintf(static_buff, "%i.%02i", currentConfig.gamma / 100, currentConfig.gamma % 100);
- return static_buff;
-}
-
const char *men_scaling_opts[] = { "OFF", "software", "hardware", NULL };
mee_enum ("Horizontal scaling", MA_OPT_SCALING, currentConfig.scaling, men_scaling_opts), \
mee_enum ("Vertical scaling", MA_OPT_VSCALING, currentConfig.vscaling, men_scaling_opts), \
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_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),
#define MENU_OPTIONS_ADV \
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 ("MMU hack", MA_OPT2_SQUIDGEHACK, currentConfig.EmuOpt, EOPT_MMUHACK), \
- 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),
static menu_entry e_menu_adv_options[];
void gp2x_menu_init(void)
{
- static menu_entry *cpu_clk_ent;
- int i;
-
- i = me_id2offset(e_menu_options, MA_OPT_CPU_CLOCKS);
- cpu_clk_ent = &e_menu_options[i];
-
/* disable by default.. */
me_enable(e_menu_adv_options, MA_OPT_ARM940_SOUND, 0);
me_enable(e_menu_gfx_options, MA_OPT_TEARING_FIX, 0);
me_enable(e_menu_adv_options, MA_OPT_ARM940_SOUND, 1);
me_enable(e_menu_gfx_options, MA_OPT2_GAMMA, 1);
me_enable(e_menu_gfx_options, MA_OPT2_A_SN_GAMMA, 1);
- cpu_clk_ent->name = "GP2X CPU clocks";
break;
case GP2X_DEV_WIZ:
me_enable(e_menu_gfx_options, MA_OPT_TEARING_FIX, 1);
- cpu_clk_ent->name = "Wiz/Caanoo CPU clock";
break;
case GP2X_DEV_CAANOO:
- cpu_clk_ent->name = "Wiz/Caanoo CPU clock";
break;
default:
break;
}
- if (gp2x_set_cpuclk == NULL)
- cpu_clk_ent->name = "";
-
if (gp2x_dev_id != GP2X_DEV_GP2X)
men_scaling_opts[2] = NULL; /* leave only off and sw */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <linux/input.h>
-#include "plat_gp2x.h"
-#include "soc.h"
-#include "warm.h"
-#include "../common/plat.h"
-#include "../common/readpng.h"
-#include "../common/menu.h"
#include "../common/emu.h"
-#include "../common/input.h"
-#include "../linux/sndout_oss.h"
+#include "../common/menu_pico.h"
+#include "../common/input_pico.h"
+#include "../libpicofe/input.h"
+#include "../libpicofe/plat.h"
+#include "../libpicofe/linux/in_evdev.h"
+#include "../libpicofe/gp2x/soc.h"
+#include "../libpicofe/gp2x/plat_gp2x.h"
+#include "../libpicofe/gp2x/in_gp2x.h"
+#include "940ctl.h"
+#include "warm.h"
+#include "plat.h"
#include <pico/pico.h>
/* GP2X local */
-int default_cpu_clock;
-int gp2x_dev_id;
int gp2x_current_bpp;
void *gp2x_screens[4];
-#include <linux/input.h>
+void (*gp2x_video_flip)(void);
+void (*gp2x_video_flip2)(void);
+void (*gp2x_video_changemode_ll)(int bpp);
+void (*gp2x_video_setpalette)(int *pal, int len);
+void (*gp2x_video_RGB_setscaling)(int ln_offs, int W, int H);
+void (*gp2x_video_wait_vsync)(void);
-static const char * const caanoo_keys[KEY_MAX + 1] = {
- [0 ... KEY_MAX] = NULL,
- [KEY_UP] = "Up",
- [KEY_LEFT] = "Left",
- [KEY_RIGHT] = "Right",
- [KEY_DOWN] = "Down",
- [BTN_TRIGGER] = "A",
- [BTN_THUMB] = "X",
- [BTN_THUMB2] = "B",
- [BTN_TOP] = "Y",
- [BTN_TOP2] = "L",
- [BTN_PINKIE] = "R",
- [BTN_BASE] = "Home",
- [BTN_BASE2] = "Lock",
- [BTN_BASE3] = "I",
- [BTN_BASE4] = "II",
- [BTN_BASE5] = "Push",
-};
-
-struct in_default_bind in_evdev_defbinds[] =
+static struct in_default_bind in_evdev_defbinds[] =
{
/* MXYZ SACB RLDU */
- { KEY_UP, IN_BINDTYPE_PLAYER12, 0 },
- { KEY_DOWN, IN_BINDTYPE_PLAYER12, 1 },
- { KEY_LEFT, IN_BINDTYPE_PLAYER12, 2 },
- { KEY_RIGHT, IN_BINDTYPE_PLAYER12, 3 },
- { KEY_S, IN_BINDTYPE_PLAYER12, 4 }, /* B */
- { KEY_D, IN_BINDTYPE_PLAYER12, 5 }, /* C */
- { KEY_A, IN_BINDTYPE_PLAYER12, 6 }, /* A */
- { KEY_ENTER, IN_BINDTYPE_PLAYER12, 7 },
+ { KEY_UP, IN_BINDTYPE_PLAYER12, GBTN_UP },
+ { KEY_DOWN, IN_BINDTYPE_PLAYER12, GBTN_DOWN },
+ { KEY_LEFT, IN_BINDTYPE_PLAYER12, GBTN_LEFT },
+ { KEY_RIGHT, IN_BINDTYPE_PLAYER12, GBTN_RIGHT },
+ { KEY_A, IN_BINDTYPE_PLAYER12, GBTN_A },
+ { KEY_S, IN_BINDTYPE_PLAYER12, GBTN_B },
+ { KEY_D, IN_BINDTYPE_PLAYER12, GBTN_C },
+ { KEY_ENTER, IN_BINDTYPE_PLAYER12, GBTN_START },
{ KEY_BACKSLASH, IN_BINDTYPE_EMU, PEVB_MENU },
/* Caanoo */
- { BTN_THUMB, IN_BINDTYPE_PLAYER12, 4 }, /* B */
- { BTN_THUMB2, IN_BINDTYPE_PLAYER12, 5 }, /* C */
- { BTN_TRIGGER, IN_BINDTYPE_PLAYER12, 6 }, /* A */
- { BTN_BASE3, IN_BINDTYPE_PLAYER12, 7 },
+ { BTN_TRIGGER, IN_BINDTYPE_PLAYER12, GBTN_A },
+ { BTN_THUMB, IN_BINDTYPE_PLAYER12, GBTN_B },
+ { BTN_THUMB2, IN_BINDTYPE_PLAYER12, GBTN_C },
+ { BTN_BASE3, IN_BINDTYPE_PLAYER12, GBTN_START },
{ BTN_TOP2, IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
{ BTN_PINKIE, IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
{ BTN_BASE, IN_BINDTYPE_EMU, PEVB_MENU },
{ 0, 0, 0 }
};
+static struct in_default_bind in_gp2x_defbinds[] =
+{
+ { GP2X_BTN_UP, IN_BINDTYPE_PLAYER12, GBTN_UP },
+ { GP2X_BTN_DOWN, IN_BINDTYPE_PLAYER12, GBTN_DOWN },
+ { GP2X_BTN_LEFT, IN_BINDTYPE_PLAYER12, GBTN_LEFT },
+ { GP2X_BTN_RIGHT, IN_BINDTYPE_PLAYER12, GBTN_RIGHT },
+ { GP2X_BTN_A, IN_BINDTYPE_PLAYER12, GBTN_A },
+ { GP2X_BTN_X, IN_BINDTYPE_PLAYER12, GBTN_B },
+ { GP2X_BTN_B, IN_BINDTYPE_PLAYER12, GBTN_C },
+ { GP2X_BTN_START, IN_BINDTYPE_PLAYER12, GBTN_START },
+ { GP2X_BTN_Y, IN_BINDTYPE_EMU, PEVB_SWITCH_RND },
+ { GP2X_BTN_L, IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
+ { GP2X_BTN_R, IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
+ { GP2X_BTN_VOL_DOWN, IN_BINDTYPE_EMU, PEVB_VOL_DOWN },
+ { GP2X_BTN_VOL_UP, IN_BINDTYPE_EMU, PEVB_VOL_UP },
+ { GP2X_BTN_SELECT, IN_BINDTYPE_EMU, PEVB_MENU },
+ { 0, 0, 0 }
+};
+
void gp2x_video_changemode(int bpp)
{
gp2x_video_changemode_ll(bpp);
// switch to 16bpp
gp2x_video_changemode_ll(16);
gp2x_video_RGB_setscaling(0, 320, 240);
+printf("menu_enter\n");
}
void plat_video_menu_begin(void)
gp2x_video_flip2();
}
-void plat_early_init(void)
+void plat_video_menu_leave(void)
{
- gp2x_soc_t soc;
- FILE *f;
-
- soc = soc_detect();
- switch (soc)
- {
- case SOCID_MMSP2:
- default_cpu_clock = 200;
- gp2x_dev_id = GP2X_DEV_GP2X;
- break;
- case SOCID_POLLUX:
- default_cpu_clock = 533;
- f = fopen("/dev/accel", "rb");
- if (f) {
- printf("detected Caanoo\n");
- gp2x_dev_id = GP2X_DEV_CAANOO;
- fclose(f);
- }
- else {
- printf("detected Wiz\n");
- gp2x_dev_id = GP2X_DEV_WIZ;
- }
- break;
- default:
- printf("could not recognize SoC, running in dummy mode.\n");
- break;
- }
+}
+void plat_early_init(void)
+{
// just use gettimeofday until plat_init()
gp2x_get_ticks_ms = plat_get_ticks_ms_good;
gp2x_get_ticks_us = plat_get_ticks_us_good;
void plat_init(void)
{
- gp2x_soc_t soc;
+ warm_init();
- soc = soc_detect();
- switch (soc)
- {
- case SOCID_MMSP2:
- mmsp2_init();
- break;
- case SOCID_POLLUX:
- pollux_init();
+ switch (gp2x_dev_id) {
+ case GP2X_DEV_GP2X:
+ sharedmem940_init();
+ vid_mmsp2_init();
break;
- default:
- dummy_init();
+ case GP2X_DEV_WIZ:
+ case GP2X_DEV_CAANOO:
+ vid_pollux_init();
break;
}
- warm_init();
-
+ g_menuscreen_w = 320;
+ g_menuscreen_h = 240;
gp2x_memset_all_buffers(0, 0, 320*240*2);
+ gp2x_make_fb_bufferable(1);
+
// use buffer2 for menubg to save mem (using only buffers 0, 1 in menu)
g_menubg_ptr = gp2x_screens[2];
- if (gp2x_dev_id == GP2X_DEV_CAANOO)
- in_set_config(in_name_to_id("evdev:pollux-analog"), IN_CFG_KEY_NAMES,
- caanoo_keys, sizeof(caanoo_keys));
-
flip_after_sync = 1;
gp2x_menu_init();
+
+ in_evdev_init(in_evdev_defbinds);
+ in_gp2x_init(in_gp2x_defbinds);
+ in_probe();
+ plat_target_setup_input();
}
void plat_finish(void)
{
- gp2x_soc_t soc;
-
warm_finish();
- soc = soc_detect();
- switch (soc)
- {
- case SOCID_MMSP2:
- mmsp2_finish();
- break;
- case SOCID_POLLUX:
- pollux_finish();
+ switch (gp2x_dev_id) {
+ case GP2X_DEV_GP2X:
+ sharedmem940_finish();
+ vid_mmsp2_finish();
break;
- default:
- dummy_finish();
+ case GP2X_DEV_WIZ:
+ case GP2X_DEV_CAANOO:
+ vid_pollux_finish();
break;
}
}
-
--- /dev/null
+extern void *gp2x_screens[4];
+extern int gp2x_current_bpp;
+
+/* SoC specific functions */
+extern void (*gp2x_video_flip)(void);
+extern void (*gp2x_video_flip2)(void);
+/* negative bpp means rotated mode (for Wiz) */
+extern void (*gp2x_video_changemode_ll)(int bpp);
+extern void (*gp2x_video_setpalette)(int *pal, int len);
+extern void (*gp2x_video_RGB_setscaling)(int ln_offs, int W, int H);
+extern void (*gp2x_video_wait_vsync)(void);
+
+/* ??? */
+void gp2x_video_changemode(int bpp);
+void gp2x_memcpy_all_buffers(void *data, int offset, int len);
+void gp2x_memset_all_buffers(int offset, int byte, int len);
+
+/* vid_*.c */
+void vid_mmsp2_init(void);
+void vid_mmsp2_finish(void);
+
+void vid_pollux_init();
+void vid_pollux_finish();
+
+void gp2x_menu_init(void);
+++ /dev/null
-#ifndef __GP2X_H__
-#define __GP2X_H__
-
-extern int default_cpu_clock;
-
-/* video */
-void gp2x_video_changemode(int bpp);
-void gp2x_memcpy_all_buffers(void *data, int offset, int len);
-void gp2x_memset_all_buffers(int offset, int byte, int len);
-void gp2x_make_fb_bufferable(int yes);
-
-/* input */
-int gp2x_touchpad_read(int *x, int *y);
-
-/* misc */
-enum {
- GP2X_DEV_GP2X = 1,
- GP2X_DEV_WIZ,
- GP2X_DEV_CAANOO,
-};
-extern int gp2x_dev_id;
-extern int gp2x_current_bpp;
-
-unsigned int plat_get_ticks_ms_good(void);
-unsigned int plat_get_ticks_us_good(void);
-
-void gp2x_menu_init(void);
-
-#endif
+++ /dev/null
-/*
- * quick tool to set various timings for Wiz
- *
- * Copyright (c) Gražvydas "notaz" Ignotas, 2009
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the organization nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * HTOTAL: X VTOTAL: 341
- * HSWIDTH: 1 VSWIDTH: 0
- * HASTART: 37 VASTART: 17
- * HAEND: 277 VAEND: 337
- *
- * 120Hz
- * pcd 8, 447: + 594us
- * pcd 9, 397: + 36us
- * pcd 10, 357: - 523us
- * pcd 11, 325: +1153us
- *
- * 'lcd_timings=397,1,37,277,341,0,17,337;dpc_clkdiv0=9'
- * 'ram_timings=2,9,4,1,1,1,1'
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "pollux_set.h"
-
-/* parse stuff */
-static int parse_lcd_timings(const char *str, void *data)
-{
- int *lcd_timings = data;
- const char *p = str;
- int ret, c;
- ret = sscanf(str, "%d,%d,%d,%d,%d,%d,%d,%d",
- &lcd_timings[0], &lcd_timings[1], &lcd_timings[2], &lcd_timings[3],
- &lcd_timings[4], &lcd_timings[5], &lcd_timings[6], &lcd_timings[7]);
- if (ret != 8)
- return -1;
- /* skip seven commas */
- for (c = 0; c < 7 && *p != 0; p++)
- if (*p == ',')
- c++;
- if (c != 7)
- return -1;
- /* skip last number */
- while ('0' <= *p && *p <= '9')
- p++;
-
- return p - str;
-}
-
-static int parse_ram_timings(const char *str, void *data)
-{
- int *ram_timings = data;
- const char *p = str;
- int ret, c;
- float cas;
-
- ret = sscanf(p, "%f,%d,%d,%d,%d,%d,%d",
- &cas, &ram_timings[1], &ram_timings[2], &ram_timings[3],
- &ram_timings[4], &ram_timings[5], &ram_timings[6]);
- if (ret != 7)
- return -1;
- if (cas == 2)
- ram_timings[0] = 1;
- else if (cas == 2.5)
- ram_timings[0] = 2;
- else if (cas == 3)
- ram_timings[0] = 3;
- else
- return -1;
- for (c = 0; c < 6 && *p != 0; p++)
- if (*p == ',')
- c++;
- if (c != 6)
- return -1;
- while ('0' <= *p && *p <= '9')
- p++;
-
- return p - str;
-}
-
-static int parse_decimal(const char *str, void *data)
-{
- char *ep;
-
- *(int *)data = strtoul(str, &ep, 10);
- if (ep == str)
- return -1;
-
- return ep - str;
-}
-
-/* validate and apply stuff */
-static int apply_lcd_timings(volatile unsigned short *memregs, void *data)
-{
- int *lcd_timings = data;
- int i;
-
- for (i = 0; i < 8; i++) {
- if (lcd_timings[i] & ~0xffff) {
- fprintf(stderr, "pollux_set: invalid lcd timing %d: %d\n", i, lcd_timings[i]);
- return -1;
- }
- }
-
- for (i = 0; i < 8; i++)
- memregs[(0x307c>>1) + i] = lcd_timings[i];
-
- return 0;
-}
-
-static const struct {
- signed char adj; /* how to adjust value passed by user */
- signed short min; /* range of */
- signed short max; /* allowed values (inclusive) */
-}
-ram_ranges[] = {
- { 0, 1, 3 }, /* cas (cl) */
- { -2, 0, 15 }, /* trc */
- { -2, 0, 15 }, /* tras */
- { 0, 0, 15 }, /* twr */
- { 0, 0, 15 }, /* tmrd */
- { 0, 0, 15 }, /* trp */
- { 0, 0, 15 }, /* trcd */
-};
-
-static int apply_ram_timings(volatile unsigned short *memregs, void *data)
-{
- int *ram_timings = data;
- int i, val;
-
- for (i = 0; i < 7; i++)
- {
- ram_timings[i] += ram_ranges[i].adj;
- if (ram_timings[i] < ram_ranges[i].min || ram_timings[i] > ram_ranges[i].max) {
- fprintf(stderr, "pollux_set: invalid RAM timing %d\n", i);
- return -1;
- }
- }
-
- val = memregs[0x14802>>1] & 0x0f00;
- val |= (ram_timings[4] << 12) | (ram_timings[5] << 4) | ram_timings[6];
- memregs[0x14802>>1] = val;
-
- val = memregs[0x14804>>1] & 0x4000;
- val |= (ram_timings[0] << 12) | (ram_timings[1] << 8) |
- (ram_timings[2] << 4) | ram_timings[3];
- val |= 0x8000;
- memregs[0x14804>>1] = val;
-
- for (i = 0; i < 0x100000 && (memregs[0x14804>>1] & 0x8000); i++)
- ;
-
- return 0;
-}
-
-static int apply_dpc_clkdiv0(volatile unsigned short *memregs, void *data)
-{
- int pcd = *(int *)data;
- int tmp;
-
- if ((pcd - 1) & ~0x3f) {
- fprintf(stderr, "pollux_set: invalid lcd clkdiv0: %d\n", pcd);
- return -1;
- }
-
- pcd = (pcd - 1) & 0x3f;
- tmp = memregs[0x31c4>>1];
- memregs[0x31c4>>1] = (tmp & ~0x3f0) | (pcd << 4);
-
- return 0;
-}
-
-static int apply_cpuclk(volatile unsigned short *memregs, void *data)
-{
- volatile unsigned int *memregl = (volatile void *)memregs;
- int mhz = *(int *)data;
- int adiv, mdiv, pdiv, sdiv = 0;
- int i, vf000, vf004;
-
- // m = MDIV, p = PDIV, s = SDIV
- #define SYS_CLK_FREQ 27
- pdiv = 9;
- mdiv = (mhz * pdiv) / SYS_CLK_FREQ;
- if (mdiv & ~0x3ff)
- return -1;
- vf004 = (pdiv<<18) | (mdiv<<8) | sdiv;
-
- // attempt to keep AHB the divider close to 250, but not higher
- for (adiv = 1; mhz / adiv > 250; adiv++)
- ;
-
- vf000 = memregl[0xf000>>2];
- vf000 = (vf000 & ~0x3c0) | ((adiv - 1) << 6);
- memregl[0xf000>>2] = vf000;
- memregl[0xf004>>2] = vf004;
- memregl[0xf07c>>2] |= 0x8000;
- for (i = 0; (memregl[0xf07c>>2] & 0x8000) && i < 0x100000; i++)
- ;
-
- printf("clock set to %dMHz, AHB set to %dMHz\n", mhz, mhz / adiv);
- return 0;
-}
-
-static int lcd_timings[8];
-static int ram_timings[7];
-static int dpc_clkdiv0;
-static int cpuclk;
-
-static const char lcd_t_help[] = "htotal,hswidth,hastart,haend,vtotal,vswidth,vastart,vaend";
-static const char ram_t_help[] = "CAS,tRC,tRAS,tWR,tMRD,tRP,tRCD";
-
-static const struct {
- const char *name;
- const char *help;
- int (*parse)(const char *str, void *data);
- int (*apply)(volatile unsigned short *memregs, void *data);
- void *data;
-}
-all_params[] = {
- { "lcd_timings", lcd_t_help, parse_lcd_timings, apply_lcd_timings, lcd_timings },
- { "ram_timings", ram_t_help, parse_ram_timings, apply_ram_timings, ram_timings },
- { "dpc_clkdiv0", "divider", parse_decimal, apply_dpc_clkdiv0, &dpc_clkdiv0 },
- { "clkdiv0", "divider", parse_decimal, apply_dpc_clkdiv0, &dpc_clkdiv0 }, /* alias */
- { "cpuclk", "MHZ", parse_decimal, apply_cpuclk, &cpuclk },
-};
-#define ALL_PARAM_COUNT (sizeof(all_params) / sizeof(all_params[0]))
-
-/*
- * set timings based on preformated string
- * returns 0 on success.
- */
-int pollux_set(volatile unsigned short *memregs, const char *str)
-{
- int parsed_params[ALL_PARAM_COUNT];
- int applied_params[ALL_PARAM_COUNT];
- int applied_something = 0;
- const char *p, *po;
- int i, ret;
-
- if (str == NULL)
- return -1;
-
- memset(parsed_params, 0, sizeof(parsed_params));
- memset(applied_params, 0, sizeof(applied_params));
-
- p = str;
- while (1)
- {
-again:
- while (*p == ';' || *p == ' ')
- p++;
- if (*p == 0)
- break;
-
- for (i = 0; i < ALL_PARAM_COUNT; i++)
- {
- int param_len = strlen(all_params[i].name);
- if (strncmp(p, all_params[i].name, param_len) == 0 && p[param_len] == '=')
- {
- p += param_len + 1;
- ret = all_params[i].parse(p, all_params[i].data);
- if (ret < 0) {
- fprintf(stderr, "pollux_set parser: error at %-10s\n", p);
- fprintf(stderr, " valid format is: <%s>\n", all_params[i].help);
- return -1;
- }
- parsed_params[i] = 1;
- p += ret;
- goto again;
- }
- }
-
- /* Unknown param. Attempt to be forward compatible and ignore it. */
- for (po = p; *p != 0 && *p != ';'; p++)
- ;
-
- fprintf(stderr, "unhandled param: ");
- fwrite(po, 1, p - po, stderr);
- fprintf(stderr, "\n");
- }
-
- /* validate and apply */
- for (i = 0; i < ALL_PARAM_COUNT; i++)
- {
- if (!parsed_params[i])
- continue;
-
- ret = all_params[i].apply(memregs, all_params[i].data);
- if (ret < 0) {
- fprintf(stderr, "pollux_set: failed to apply %s (bad value?)\n",
- all_params[i].name);
- continue;
- }
-
- applied_something = 1;
- applied_params[i] = 1;
- }
-
- if (applied_something)
- {
- int c;
- printf("applied: ");
- for (i = c = 0; i < ALL_PARAM_COUNT; i++)
- {
- if (!applied_params[i])
- continue;
- if (c != 0)
- printf(", ");
- printf("%s", all_params[i].name);
- c++;
- }
- printf("\n");
- }
-
- return 0;
-}
-
-#ifdef BINARY
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-static void usage(const char *binary)
-{
- int i;
- printf("usage:\n%s <set_str[;set_str[;...]]>\n"
- "set_str:\n", binary);
- for (i = 0; i < ALL_PARAM_COUNT; i++)
- printf(" %s=<%s>\n", all_params[i].name, all_params[i].help);
-}
-
-int main(int argc, char *argv[])
-{
- volatile unsigned short *memregs;
- int ret, memdev;
-
- if (argc != 2) {
- usage(argv[0]);
- return 1;
- }
-
- memdev = open("/dev/mem", O_RDWR);
- if (memdev == -1)
- {
- perror("open(/dev/mem) failed");
- return 1;
- }
-
- memregs = mmap(0, 0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0xc0000000);
- if (memregs == MAP_FAILED)
- {
- perror("mmap(memregs) failed");
- close(memdev);
- return 1;
- }
-
- ret = pollux_set(memregs, argv[1]);
-
- munmap((void *)memregs, 0x20000);
- close(memdev);
-
- return ret;
-}
-#endif
+++ /dev/null
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-int pollux_set(volatile unsigned short *memregs, const char *str);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-#include "soc.h"
-
-void (*gp2x_video_flip)(void);
-void (*gp2x_video_flip2)(void);
-void (*gp2x_video_changemode_ll)(int bpp);
-void (*gp2x_video_setpalette)(int *pal, int len);
-void (*gp2x_video_RGB_setscaling)(int ln_offs, int W, int H);
-void (*gp2x_video_wait_vsync)(void);
-
-void (*gp2x_set_cpuclk)(unsigned int mhz);
-
-void (*set_lcd_custom_rate)(int is_pal);
-void (*unset_lcd_custom_rate)(void);
-void (*set_lcd_gamma)(int g100, int A_SNs_curve);
-
-void (*set_ram_timings)(void);
-void (*unset_ram_timings)(void);
-int (*gp2x_read_battery)(void);
-
-unsigned int (*gp2x_get_ticks_ms)(void);
-unsigned int (*gp2x_get_ticks_us)(void);
-
-
-gp2x_soc_t soc_detect(void)
-{
- volatile unsigned short *memregs;
- volatile unsigned int *memregl;
- static gp2x_soc_t ret = -2;
- int pollux_chipname[0x30/4 + 1];
- char *pollux_chipname_c = (char *)pollux_chipname;
- int memdev;
- int i;
-
- if ((int)ret != -2)
- /* already detected */
- return ret;
-
- memdev = open("/dev/mem", O_RDONLY);
- if (memdev == -1)
- {
- perror("open(/dev/mem)");
- ret = -1;
- return -1;
- }
-
- memregs = mmap(0, 0x20000, PROT_READ, MAP_SHARED, memdev, 0xc0000000);
- if (memregs == MAP_FAILED)
- {
- perror("mmap(memregs)");
- close(memdev);
- ret = -1;
- return -1;
- }
- memregl = (volatile void *)memregs;
-
- if (memregs[0x1836>>1] == 0x2330)
- {
- printf("looks like this is MMSP2\n");
- ret = SOCID_MMSP2;
- goto out;
- }
-
- /* perform word reads. Byte reads might also work,
- * but we don't want to play with that. */
- for (i = 0; i < 0x30; i += 4)
- {
- pollux_chipname[i >> 2] = memregl[(0x1f810 + i) >> 2];
- }
- pollux_chipname_c[0x30] = 0;
-
- for (i = 0; i < 0x30; i++)
- {
- unsigned char c = pollux_chipname_c[i];
- if (c < 0x20 || c > 0x7f)
- goto not_pollux_like;
- }
-
- printf("found pollux-like id: \"%s\"\n", pollux_chipname_c);
-
- if (strncmp(pollux_chipname_c, "MAGICEYES-LEAPFROG-LF1000", 25) ||
- strncmp(pollux_chipname_c, "MAGICEYES-POLLUX", 16))
- {
- ret = SOCID_POLLUX;
- goto out;
- }
-
-not_pollux_like:
-out:
- munmap((void *)memregs, 0x20000);
- close(memdev);
- return ret;
-}
-
+++ /dev/null
-typedef enum {
- SOCID_MMSP2 = 1,
- SOCID_POLLUX,
-} gp2x_soc_t;
-
-gp2x_soc_t soc_detect(void);
-
-void mmsp2_init(void);
-void mmsp2_finish(void);
-
-void pollux_init(void);
-void pollux_finish(void);
-
-void dummy_init(void);
-void dummy_finish(void);
-
-/* SoC specific functions */
-extern void (*gp2x_video_flip)(void);
-extern void (*gp2x_video_flip2)(void);
-/* negative bpp means rotated mode (for Wiz) */
-extern void (*gp2x_video_changemode_ll)(int bpp);
-extern void (*gp2x_video_setpalette)(int *pal, int len);
-extern void (*gp2x_video_RGB_setscaling)(int ln_offs, int W, int H);
-extern void (*gp2x_video_wait_vsync)(void);
-
-extern void (*gp2x_set_cpuclk)(unsigned int mhz);
-
-extern void (*set_lcd_custom_rate)(int is_pal);
-extern void (*unset_lcd_custom_rate)(void);
-extern void (*set_lcd_gamma)(int g100, int A_SNs_curve);
-
-extern void (*set_ram_timings)(void);
-extern void (*unset_ram_timings)(void);
-extern int (*gp2x_read_battery)(void);
-
-/* gettimeofday is not suitable for Wiz, at least fw 1.1 or lower */
-extern unsigned int (*gp2x_get_ticks_ms)(void);
-extern unsigned int (*gp2x_get_ticks_us)(void);
+++ /dev/null
-/* dummy code for qemu testing, etc */
-#include <stdlib.h>
-
-#include "soc.h"
-#include "../common/emu.h"
-
-extern void *gp2x_screens[4];
-
-extern unsigned int plat_get_ticks_ms_good(void);
-extern unsigned int plat_get_ticks_us_good(void);
-
-/* video stuff */
-static void gp2x_video_flip_(void)
-{
-}
-
-/* doulblebuffered flip */
-static void gp2x_video_flip2_(void)
-{
-}
-
-static void gp2x_video_changemode_ll_(int bpp)
-{
-}
-
-static void gp2x_video_setpalette_(int *pal, int len)
-{
-}
-
-static void gp2x_video_RGB_setscaling_(int ln_offs, int W, int H)
-{
-}
-
-static void gp2x_video_wait_vsync_(void)
-{
-}
-
-/* RAM timings */
-static void set_ram_timings_(void)
-{
-}
-
-static void unset_ram_timings_(void)
-{
-}
-
-/* LCD refresh */
-static void set_lcd_custom_rate_(int is_pal)
-{
-}
-
-static void unset_lcd_custom_rate_(void)
-{
-}
-
-static void set_lcd_gamma_(int g100, int A_SNs_curve)
-{
-}
-
-static int gp2x_read_battery_(void)
-{
- return 0;
-}
-
-void dummy_init(void)
-{
- int i;
- g_screen_ptr = malloc(320 * 240 * 2);
- for (i = 0; i < array_size(gp2x_screens); i++)
- gp2x_screens[i] = g_screen_ptr;
-
- gp2x_video_flip = gp2x_video_flip_;
- gp2x_video_flip2 = gp2x_video_flip2_;
- gp2x_video_changemode_ll = gp2x_video_changemode_ll_;
- gp2x_video_setpalette = gp2x_video_setpalette_;
- gp2x_video_RGB_setscaling = gp2x_video_RGB_setscaling_;
- gp2x_video_wait_vsync = gp2x_video_wait_vsync_;
-
- set_lcd_custom_rate = set_lcd_custom_rate_;
- unset_lcd_custom_rate = unset_lcd_custom_rate_;
- set_lcd_gamma = set_lcd_gamma_;
-
- set_ram_timings = set_ram_timings_;
- unset_ram_timings = unset_ram_timings_;
- gp2x_read_battery = gp2x_read_battery_;
-
- gp2x_get_ticks_ms = plat_get_ticks_ms_good;
- gp2x_get_ticks_us = plat_get_ticks_us_good;
-}
-
-void dummy_finish(void)
-{
- free(gp2x_screens[0]);
-}
-
+++ /dev/null
-/*
- * PicoDrive
- * (C) notaz, 2006-2009
- *
- * This work is licensed under the terms of MAME license.
- * See COPYING file in the top-level directory.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-#include "soc.h"
-#include "soc_mmsp2.h"
-#include "plat_gp2x.h"
-#include "../common/emu.h"
-#include "../common/plat.h"
-#include "../common/arm_utils.h"
-#include "940ctl.h"
-
-volatile unsigned short *gp2x_memregs;
-volatile unsigned long *gp2x_memregl;
-extern void *gp2x_screens[4];
-static int screensel = 0;
-
-int memdev = -1; /* used by code940 */
-static int touchdev = -1;
-static int touchcal[7] = { 6203, 0, -1501397, 0, -4200, 16132680, 65536 };
-
-#define FRAMEBUFF_SIZE 0x30000
-#define FRAMEBUFF_WHOLESIZE (FRAMEBUFF_SIZE*4) // 320*240*2 + some more
-#define FRAMEBUFF_ADDR0 (0x4000000 - FRAMEBUFF_WHOLESIZE)
-#define FRAMEBUFF_ADDR1 (FRAMEBUFF_ADDR0 + FRAMEBUFF_SIZE)
-#define FRAMEBUFF_ADDR2 (FRAMEBUFF_ADDR1 + FRAMEBUFF_SIZE)
-#define FRAMEBUFF_ADDR3 (FRAMEBUFF_ADDR2 + FRAMEBUFF_SIZE)
-
-static const int gp2x_screenaddrs[4] = { FRAMEBUFF_ADDR0, FRAMEBUFF_ADDR1, FRAMEBUFF_ADDR2, FRAMEBUFF_ADDR3 };
-static int gp2x_screenaddrs_use[4];
-
-static char gamma_was_changed = 0;
-static char cpuclk_was_changed = 0;
-static unsigned short gp2x_screenaddr_old[4];
-static unsigned short memtimex_old[2];
-static unsigned short reg0910;
-
-/* video stuff */
-static void gp2x_video_flip_(void)
-{
- unsigned short lsw = (unsigned short) gp2x_screenaddrs_use[screensel&3];
- unsigned short msw = (unsigned short)(gp2x_screenaddrs_use[screensel&3] >> 16);
-
- gp2x_memregs[0x2910>>1] = msw;
- gp2x_memregs[0x2914>>1] = msw;
- gp2x_memregs[0x290E>>1] = lsw;
- gp2x_memregs[0x2912>>1] = lsw;
-
- // jump to other buffer:
- g_screen_ptr = gp2x_screens[++screensel&3];
-}
-
-/* doulblebuffered flip */
-static void gp2x_video_flip2_(void)
-{
- unsigned short msw = (unsigned short)(gp2x_screenaddrs_use[screensel&1] >> 16);
-
- gp2x_memregs[0x2910>>1] = msw;
- gp2x_memregs[0x2914>>1] = msw;
- gp2x_memregs[0x290E>>1] = 0;
- gp2x_memregs[0x2912>>1] = 0;
-
- // jump to other buffer:
- g_screen_ptr = gp2x_screens[++screensel&1];
-}
-
-static void gp2x_video_changemode_ll_(int bpp)
-{
- gp2x_memregs[0x28DA>>1] = (((bpp+1)/8)<<9)|0xAB; /*8/15/16/24bpp...*/
- gp2x_memregs[0x290C>>1] = 320*((bpp+1)/8); /*line width in bytes*/
-}
-
-static void gp2x_video_setpalette_(int *pal, int len)
-{
- unsigned short *g = (unsigned short *)pal;
- volatile unsigned short *memreg = &gp2x_memregs[0x295A>>1];
-
- gp2x_memregs[0x2958>>1] = 0;
-
- len *= 2;
- while (len--)
- *memreg = *g++;
-}
-
-static void gp2x_video_RGB_setscaling_(int ln_offs, int W, int H)
-{
- float escalaw, escalah;
- int bpp = (gp2x_memregs[0x28DA>>1]>>9)&0x3;
- unsigned short scalw;
-
- // set offset
- gp2x_screenaddrs_use[0] = gp2x_screenaddrs[0] + ln_offs * 320 * bpp;
- gp2x_screenaddrs_use[1] = gp2x_screenaddrs[1] + ln_offs * 320 * bpp;
- gp2x_screenaddrs_use[2] = gp2x_screenaddrs[2] + ln_offs * 320 * bpp;
- gp2x_screenaddrs_use[3] = gp2x_screenaddrs[3] + ln_offs * 320 * bpp;
-
- escalaw = 1024.0; // RGB Horiz LCD
- escalah = 320.0; // RGB Vert LCD
-
- if (gp2x_memregs[0x2800>>1]&0x100) //TV-Out
- {
- escalaw=489.0; // RGB Horiz TV (PAL, NTSC)
- if (gp2x_memregs[0x2818>>1] == 287) //PAL
- escalah=274.0; // RGB Vert TV PAL
- else if (gp2x_memregs[0x2818>>1] == 239) //NTSC
- escalah=331.0; // RGB Vert TV NTSC
- }
-
- // scale horizontal
- scalw = (unsigned short)((float)escalaw *(W/320.0));
- /* if there is no horizontal scaling, vertical doesn't work.
- * Here is a nasty wrokaround... */
- if (H != 240 && W == 320) scalw--;
- gp2x_memregs[0x2906>>1]=scalw;
- // scale vertical
- gp2x_memregl[0x2908>>2]=(unsigned long)((float)escalah *bpp *(H/240.0));
-}
-
-static void gp2x_video_wait_vsync_(void)
-{
- unsigned short v = gp2x_memregs[0x1182>>1];
- while (!((v ^ gp2x_memregs[0x1182>>1]) & 0x10))
- spend_cycles(1024);
-}
-
-/* 940 */
-void pause940(int yes)
-{
- if (yes)
- gp2x_memregs[0x0904>>1] &= 0xFFFE;
- else
- gp2x_memregs[0x0904>>1] |= 1;
-}
-
-void reset940(int yes, int bank)
-{
- gp2x_memregs[0x3B48>>1] = ((yes&1) << 7) | (bank & 0x03);
-}
-
-/*
- * CPU clock
- * Fout = (m * Fin) / (p * 2^s)
- * m = MDIV+8, p = PDIV+2, s = SDIV
- *
- * m = (Fout * p * 2^s) / Fin
- */
-
-#define SYS_CLK_FREQ 7372800
-
-static void gp2x_set_cpuclk_(unsigned int mhz)
-{
- unsigned int mdiv, pdiv, sdiv = 0;
- unsigned int v;
- int i;
-
- pdiv = 3;
- mdiv = (mhz * pdiv * 1000000) / SYS_CLK_FREQ;
- if (mdiv & ~0xff) {
- fprintf(stderr, "invalid cpuclk MHz: %u\n", mhz);
- return;
- }
- v = ((mdiv-8)<<8) | ((pdiv-2)<<2) | sdiv;
- gp2x_memregs[0x910>>1] = v;
-
- for (i = 0; i < 10000; i++)
- if (!(gp2x_memregs[0x902>>1] & 1))
- break;
-
- cpuclk_was_changed = 1;
-}
-
-/* RAM timings */
-#define TIMING_CHECK(t, adj, mask) \
- t += adj; \
- if (t & ~mask) \
- goto bad
-
-static void set_ram_timing_vals(int tCAS, int tRC, int tRAS, int tWR, int tMRD, int tRFC, int tRP, int tRCD)
-{
- int i;
- TIMING_CHECK(tCAS, -2, 0x1);
- TIMING_CHECK(tRC, -1, 0xf);
- TIMING_CHECK(tRAS, -1, 0xf);
- TIMING_CHECK(tWR, -1, 0xf);
- TIMING_CHECK(tMRD, -1, 0xf);
- TIMING_CHECK(tRFC, -1, 0xf);
- TIMING_CHECK(tRP, -1, 0xf);
- TIMING_CHECK(tRCD, -1, 0xf);
-
- /* get spend_cycles() into cache */
- spend_cycles(1);
-
- gp2x_memregs[0x3802>>1] = ((tMRD & 0xF) << 12) | ((tRFC & 0xF) << 8) | ((tRP & 0xF) << 4) | (tRCD & 0xF);
- gp2x_memregs[0x3804>>1] = 0x8000 | ((tCAS & 1) << 12) | ((tRC & 0xF) << 8) | ((tRAS & 0xF) << 4) | (tWR & 0xF);
-
- /* be sure we don't access the mem while it's being reprogrammed */
- spend_cycles(128*1024);
- for (i = 0; i < 8*1024; i++)
- if (!(gp2x_memregs[0x3804>>1] & 0x8000))
- break;
-
- printf("RAM timings set.\n");
- return;
-bad:
- fprintf(stderr, "RAM timings invalid.\n");
-}
-
-static void set_ram_timings_(void)
-{
- /* craigix: --cas 2 --trc 6 --tras 4 --twr 1 --tmrd 1 --trfc 1 --trp 2 --trcd 2 */
- set_ram_timing_vals(2, 6, 4, 1, 1, 1, 2, 2);
-}
-
-static void unset_ram_timings_(void)
-{
- gp2x_memregs[0x3802>>1] = memtimex_old[0];
- gp2x_memregs[0x3804>>1] = memtimex_old[1] | 0x8000;
- printf("RAM timings reset to startup values.\n");
-}
-
-/* LCD refresh */
-typedef struct
-{
- unsigned short reg, valmask, val;
-}
-reg_setting;
-
-/* 120.00 97/0/2/7|25/ 7/ 7/11/37 */
-static const reg_setting lcd_rate_120[] =
-{
- { 0x0914, 0xffff, (97<<8)|(0<<2)|2 }, /* UPLLSETVREG */
- { 0x0924, 0xff00, (2<<14)|(7<<8) }, /* DISPCSETREG */
- { 0x281A, 0x00ff, 25 }, /* .HSWID(T2) */
- { 0x281C, 0x00ff, 7 }, /* .HSSTR(T8) */
- { 0x281E, 0x00ff, 7 }, /* .HSEND(T7) */
- { 0x2822, 0x01ff, 11 }, /* .VSEND (T9) */
- { 0x2826, 0x0ff0, 37<<4 }, /* .DESTR(T3) */
- { 0, 0, 0 }
-};
-
-/* 100.00 96/0/2/7|29/25/53/15/37 */
-static const reg_setting lcd_rate_100[] =
-{
- { 0x0914, 0xffff, (96<<8)|(0<<2)|2 }, /* UPLLSETVREG */
- { 0x0924, 0xff00, (2<<14)|(7<<8) }, /* DISPCSETREG */
- { 0x281A, 0x00ff, 29 }, /* .HSWID(T2) */
- { 0x281C, 0x00ff, 25 }, /* .HSSTR(T8) */
- { 0x281E, 0x00ff, 53 }, /* .HSEND(T7) */
- { 0x2822, 0x01ff, 15 }, /* .VSEND (T9) */
- { 0x2826, 0x0ff0, 37<<4 }, /* .DESTR(T3) */
- { 0, 0, 0 }
-};
-
-static reg_setting lcd_rate_defaults[] =
-{
- { 0x0914, 0xffff, 0 },
- { 0x0924, 0xff00, 0 },
- { 0x281A, 0x00ff, 0 },
- { 0x281C, 0x00ff, 0 },
- { 0x281E, 0x00ff, 0 },
- { 0x2822, 0x01ff, 0 },
- { 0x2826, 0x0ff0, 0 },
- { 0, 0, 0 }
-};
-
-static void get_reg_setting(reg_setting *set)
-{
- for (; set->reg; set++)
- {
- unsigned short val = gp2x_memregs[set->reg >> 1];
- val &= set->valmask;
- set->val = val;
- }
-}
-
-static void set_reg_setting(const reg_setting *set)
-{
- for (; set->reg; set++)
- {
- unsigned short val = gp2x_memregs[set->reg >> 1];
- val &= ~set->valmask;
- val |= set->val;
- gp2x_memregs[set->reg >> 1] = val;
- }
-}
-
-static void set_lcd_custom_rate_(int is_pal)
-{
- if (gp2x_memregs[0x2800>>1] & 0x100) // tv-out
- return;
-
- printf("setting custom LCD refresh (%d Hz)... ", is_pal ? 100 : 120);
- fflush(stdout);
-
- set_reg_setting(is_pal ? lcd_rate_100 : lcd_rate_120);
- printf("done.\n");
-}
-
-static void unset_lcd_custom_rate_(void)
-{
- printf("reset to prev LCD refresh.\n");
- set_reg_setting(lcd_rate_defaults);
-}
-
-static void set_lcd_gamma_(int g100, int A_SNs_curve)
-{
- float gamma = (float) g100 / 100;
- int i;
- gamma = 1 / gamma;
-
- /* enable gamma */
- gp2x_memregs[0x2880>>1] &= ~(1<<12);
-
- gp2x_memregs[0x295C>>1] = 0;
- for (i = 0; i < 256; i++)
- {
- unsigned char g;
- unsigned short s;
- const unsigned short grey50=143, grey75=177, grey25=97;
- double blah;
-
- if (A_SNs_curve)
- {
- // The next formula is all about gaussian interpolation
- blah = (( -128 * exp(-powf((float) i/64.0f + 2.0f , 2.0f))) +
- ( -64 * exp(-powf((float) i/64.0f + 1.0f , 2.0f))) +
- (grey25 * exp(-powf((float) i/64.0f - 1.0f , 2.0f))) +
- (grey50 * exp(-powf((float) i/64.0f - 2.0f , 2.0f))) +
- (grey75 * exp(-powf((float) i/64.0f - 3.0f , 2.0f))) +
- ( 256 * exp(-powf((float) i/64.0f - 4.0f , 2.0f))) +
- ( 320 * exp(-powf((float) i/64.0f - 5.0f , 2.0f))) +
- ( 384 * exp(-powf((float) i/64.0f - 6.0f , 2.0f)))) / 1.772637;
- blah += 0.5;
- }
- else
- {
- blah = i;
- }
-
- g = (unsigned char)(255.0 * pow(blah/255.0, gamma));
- //printf("%d : %d\n", i, g);
- s = (g<<8) | g;
- gp2x_memregs[0x295E>>1]= s;
- gp2x_memregs[0x295E>>1]= g;
- }
-
- gamma_was_changed = 1;
-}
-
-static int gp2x_read_battery_(void)
-{
- return -1; /* TODO? */
-}
-
-/* these are not quite MMSP2 related,
- * more to GP2X F100/F200 consoles themselves. */
-typedef struct ucb1x00_ts_event
-{
- unsigned short pressure;
- unsigned short x;
- unsigned short y;
- unsigned short pad;
- struct timeval stamp;
-} UCB1X00_TS_EVENT;
-
-int gp2x_touchpad_read(int *x, int *y)
-{
- UCB1X00_TS_EVENT event;
- static int zero_seen = 0;
- int retval;
-
- if (touchdev < 0) return -1;
-
- retval = read(touchdev, &event, sizeof(event));
- if (retval <= 0) {
- perror("touch read failed");
- return -1;
- }
- // this is to ignore the messed-up 4.1.x driver
- if (event.pressure == 0) zero_seen = 1;
-
- if (x) *x = (event.x * touchcal[0] + touchcal[2]) >> 16;
- if (y) *y = (event.y * touchcal[4] + touchcal[5]) >> 16;
- // printf("read %i %i %i\n", event.pressure, *x, *y);
-
- return zero_seen ? event.pressure : 0;
-}
-
-static void proc_set(const char *path, const char *val)
-{
- FILE *f;
- char tmp[16];
-
- f = fopen(path, "w");
- if (f == NULL) {
- printf("failed to open: %s\n", path);
- return;
- }
-
- fprintf(f, "0\n");
- fclose(f);
-
- printf("\"%s\" is set to: ", path);
- f = fopen(path, "r");
- if (f == NULL) {
- printf("(open failed)\n");
- return;
- }
-
- fgets(tmp, sizeof(tmp), f);
- printf("%s", tmp);
- fclose(f);
-}
-
-
-void mmsp2_init(void)
-{
- int i;
-
- memdev = open("/dev/mem", O_RDWR);
- if (memdev == -1)
- {
- perror("open(\"/dev/mem\")");
- exit(1);
- }
-
- gp2x_memregs = mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0xc0000000);
- if (gp2x_memregs == MAP_FAILED)
- {
- perror("mmap(memregs)");
- exit(1);
- }
- gp2x_memregl = (unsigned long *) gp2x_memregs;
-
- gp2x_memregs[0x2880>>1] &= ~0x383; // disable cursor, subpict, osd, video layers
-
- gp2x_screens[0] = mmap(0, FRAMEBUFF_WHOLESIZE, PROT_WRITE, MAP_SHARED,
- memdev, gp2x_screenaddrs[0]);
- if (gp2x_screens[0] == MAP_FAILED)
- {
- perror("mmap(g_screen_ptr)");
- exit(1);
- }
- printf("framebuffers:\n");
- printf(" %08x -> %p\n", gp2x_screenaddrs[0], gp2x_screens[0]);
- for (i = 1; i < 4; i++)
- {
- gp2x_screens[i] = (char *) gp2x_screens[i - 1] + FRAMEBUFF_SIZE;
- printf(" %08x -> %p\n", gp2x_screenaddrs[i], gp2x_screens[i]);
- }
-
- g_screen_ptr = gp2x_screens[0];
- screensel = 0;
-
- gp2x_screenaddr_old[0] = gp2x_memregs[0x290E>>1];
- gp2x_screenaddr_old[1] = gp2x_memregs[0x2910>>1];
- gp2x_screenaddr_old[2] = gp2x_memregs[0x2912>>1];
- gp2x_screenaddr_old[3] = gp2x_memregs[0x2914>>1];
-
- memcpy(gp2x_screenaddrs_use, gp2x_screenaddrs, sizeof(gp2x_screenaddrs));
-
- /* save startup values: LCD refresh */
- get_reg_setting(lcd_rate_defaults);
-
- /* CPU and RAM timings */
- reg0910 = gp2x_memregs[0x0910>>1];
- memtimex_old[0] = gp2x_memregs[0x3802>>1];
- memtimex_old[1] = gp2x_memregs[0x3804>>1];
-
- /* touchscreen */
- touchdev = open("/dev/touchscreen/wm97xx", O_RDONLY);
- if (touchdev >= 0) {
- FILE *pcf = fopen("/etc/pointercal", "r");
- if (pcf) {
- fscanf(pcf, "%d %d %d %d %d %d %d", &touchcal[0], &touchcal[1],
- &touchcal[2], &touchcal[3], &touchcal[4], &touchcal[5], &touchcal[6]);
- fclose(pcf);
- }
- printf("found touchscreen/wm97xx\n");
- }
-
- /* disable Linux read-ahead */
- proc_set("/proc/sys/vm/max-readahead", "0\n");
- proc_set("/proc/sys/vm/min-readahead", "0\n");
-
- /* code940 portion */
- sharedmem940_init();
-
- gp2x_video_flip = gp2x_video_flip_;
- gp2x_video_flip2 = gp2x_video_flip2_;
- gp2x_video_changemode_ll = gp2x_video_changemode_ll_;
- gp2x_video_setpalette = gp2x_video_setpalette_;
- gp2x_video_RGB_setscaling = gp2x_video_RGB_setscaling_;
- gp2x_video_wait_vsync = gp2x_video_wait_vsync_;
-
- gp2x_set_cpuclk = gp2x_set_cpuclk_;
-
- set_lcd_custom_rate = set_lcd_custom_rate_;
- unset_lcd_custom_rate = unset_lcd_custom_rate_;
- set_lcd_gamma = set_lcd_gamma_;
-
- set_ram_timings = set_ram_timings_;
- unset_ram_timings = unset_ram_timings_;
- gp2x_read_battery = gp2x_read_battery_;
-
- gp2x_get_ticks_ms = plat_get_ticks_ms_good;
- gp2x_get_ticks_us = plat_get_ticks_us_good;
-}
-
-void mmsp2_finish(void)
-{
- reset940(1, 3);
- pause940(1);
- sharedmem940_finish();
-
- gp2x_video_RGB_setscaling_(0, 320, 240);
- gp2x_video_changemode_ll_(16);
-
- gp2x_memregs[0x290E>>1] = gp2x_screenaddr_old[0];
- gp2x_memregs[0x2910>>1] = gp2x_screenaddr_old[1];
- gp2x_memregs[0x2912>>1] = gp2x_screenaddr_old[2];
- gp2x_memregs[0x2914>>1] = gp2x_screenaddr_old[3];
-
- unset_lcd_custom_rate_();
- if (gamma_was_changed)
- set_lcd_gamma_(100, 0);
- unset_ram_timings_();
- if (cpuclk_was_changed)
- gp2x_memregs[0x910>>1] = reg0910;
-
- munmap(gp2x_screens[0], FRAMEBUFF_WHOLESIZE);
- munmap((void *)gp2x_memregs, 0x10000);
- close(memdev);
- if (touchdev >= 0)
- close(touchdev);
-}
-
+++ /dev/null
-
-extern int memdev;
-extern volatile unsigned short *gp2x_memregs;
-extern volatile unsigned long *gp2x_memregl;
-
-/* 940 core */
-void pause940(int yes);
-void reset940(int yes, int bank);
-
+++ /dev/null
-/*
- * PicoDrive
- * (C) notaz, 2009,2010
- *
- * This work is licensed under the terms of MAME license.
- * See COPYING file in the top-level directory.
- */
-/*
- * <random_info=mem_map>
- * 00000000-029fffff linux (42MB)
- * 02a00000-02dfffff fb (4MB, 153600B really used)
- * 02e00000-02ffffff sound dma (2MB)
- * 03000000-03ffffff MPEGDEC (?, 16MB)
- * </random_info>
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <linux/fb.h>
-
-#include "soc.h"
-#include "plat_gp2x.h"
-#include "../common/emu.h"
-#include "../common/plat.h"
-#include "../common/arm_utils.h"
-#include "pollux_set.h"
-
-static volatile unsigned short *memregs;
-static volatile unsigned int *memregl;
-static int memdev = -1;
-static int battdev = -1;
-
-extern void *gp2x_screens[4];
-
-#define fb_buf_count 4
-static unsigned int fb_paddr[fb_buf_count];
-static int fb_work_buf;
-static int fbdev = -1;
-
-static char cpuclk_was_changed = 0;
-static unsigned short memtimex_old[2];
-static unsigned int pllsetreg0_old;
-static unsigned int timer_drift; // count per real second
-static int last_pal_setting = 0;
-
-
-/* misc */
-static void pollux_set_fromenv(const char *env_var)
-{
- const char *set_string;
- set_string = getenv(env_var);
- if (set_string)
- pollux_set(memregs, set_string);
- else
- printf("env var %s not defined.\n", env_var);
-}
-
-/* video stuff */
-static void pollux_video_flip(int buf_count)
-{
- memregl[0x406C>>2] = fb_paddr[fb_work_buf];
- memregl[0x4058>>2] |= 0x10;
- fb_work_buf++;
- if (fb_work_buf >= buf_count)
- fb_work_buf = 0;
- g_screen_ptr = gp2x_screens[fb_work_buf];
-}
-
-static void gp2x_video_flip_(void)
-{
- pollux_video_flip(fb_buf_count);
-}
-
-/* doulblebuffered flip */
-static void gp2x_video_flip2_(void)
-{
- pollux_video_flip(2);
-}
-
-static void gp2x_video_changemode_ll_(int bpp)
-{
- static int prev_bpp = 0;
- int code = 0, bytes = 2;
- int rot_cmd[2] = { 0, 0 };
- unsigned int r;
- char buff[32];
- int ret;
-
- if (bpp == prev_bpp)
- return;
- prev_bpp = bpp;
-
- printf("changemode: %dbpp rot=%d\n", abs(bpp), bpp < 0);
-
- /* negative bpp means rotated mode */
- rot_cmd[0] = (bpp < 0) ? 6 : 5;
- ret = ioctl(fbdev, _IOW('D', 90, int[2]), rot_cmd);
- if (ret < 0)
- perror("rot ioctl failed");
- memregl[0x4004>>2] = (bpp < 0) ? 0x013f00ef : 0x00ef013f;
- memregl[0x4000>>2] |= 1 << 3;
-
- /* the above ioctl resets LCD timings, so set them here */
- snprintf(buff, sizeof(buff), "POLLUX_LCD_TIMINGS_%s", last_pal_setting ? "PAL" : "NTSC");
- pollux_set_fromenv(buff);
-
- switch (abs(bpp))
- {
- case 8:
- code = 0x443a;
- bytes = 1;
- break;
-
- case 15:
- case 16:
- code = 0x4432;
- bytes = 2;
- break;
-
- default:
- printf("unhandled bpp request: %d\n", abs(bpp));
- return;
- }
-
- memregl[0x405c>>2] = bytes;
- memregl[0x4060>>2] = bytes * (bpp < 0 ? 240 : 320);
-
- r = memregl[0x4058>>2];
- r = (r & 0xffff) | (code << 16) | 0x10;
- memregl[0x4058>>2] = r;
-}
-
-static void gp2x_video_setpalette_(int *pal, int len)
-{
- /* pollux palette is 16bpp only.. */
- int i;
- for (i = 0; i < len; i++)
- {
- int c = pal[i];
- c = ((c >> 8) & 0xf800) | ((c >> 5) & 0x07c0) | ((c >> 3) & 0x001f);
- memregl[0x4070>>2] = (i << 24) | c;
- }
-}
-
-static void gp2x_video_RGB_setscaling_(int ln_offs, int W, int H)
-{
- /* maybe a job for 3d hardware? */
-}
-
-static void gp2x_video_wait_vsync_(void)
-{
- while (!(memregl[0x308c>>2] & (1 << 10)))
- spend_cycles(128);
- memregl[0x308c>>2] |= 1 << 10;
-}
-
-/* CPU clock */
-static void gp2x_set_cpuclk_(unsigned int mhz)
-{
- char buff[24];
- snprintf(buff, sizeof(buff), "cpuclk=%u", mhz);
- pollux_set(memregs, buff);
-
- cpuclk_was_changed = 1;
-}
-
-/* RAM timings */
-static void set_ram_timings_(void)
-{
- pollux_set_fromenv("POLLUX_RAM_TIMINGS");
-}
-
-static void unset_ram_timings_(void)
-{
- int i;
-
- memregs[0x14802>>1] = memtimex_old[0];
- memregs[0x14804>>1] = memtimex_old[1] | 0x8000;
-
- for (i = 0; i < 0x100000; i++)
- if (!(memregs[0x14804>>1] & 0x8000))
- break;
-
- printf("RAM timings reset to startup values.\n");
-}
-
-/* LCD refresh */
-static void set_lcd_custom_rate_(int is_pal)
-{
- /* just remember PAL/NTSC. We always set timings in _changemode_ll() */
- last_pal_setting = is_pal;
-}
-
-static void unset_lcd_custom_rate_(void)
-{
-}
-
-static void set_lcd_gamma_(int g100, int A_SNs_curve)
-{
- /* hm, the LCD possibly can do it (but not POLLUX) */
-}
-
-static int gp2x_read_battery_(void)
-{
- unsigned short magic_val = 0;
-
- if (battdev < 0)
- return -1;
- if (read(battdev, &magic_val, sizeof(magic_val)) != sizeof(magic_val))
- return -1;
- switch (magic_val) {
- default:
- case 1: return 100;
- case 2: return 66;
- case 3: return 40;
- case 4: return 0;
- }
-}
-
-#define TIMER_BASE3 0x1980
-#define TIMER_REG(x) memregl[(TIMER_BASE3 + x) >> 2]
-
-static unsigned int gp2x_get_ticks_us_(void)
-{
- TIMER_REG(0x08) = 0x4b; /* run timer, latch value */
- return TIMER_REG(0);
-}
-
-static unsigned int gp2x_get_ticks_ms_(void)
-{
- /* approximate /= 1000 */
- unsigned long long v64;
- v64 = (unsigned long long)gp2x_get_ticks_us_() * 4294968;
- return v64 >> 32;
-}
-
-static void timer_cleanup(void)
-{
- TIMER_REG(0x40) = 0x0c; /* be sure clocks are on */
- TIMER_REG(0x08) = 0x23; /* stop the timer, clear irq in case it's pending */
- TIMER_REG(0x00) = 0; /* clear counter */
- TIMER_REG(0x40) = 0; /* clocks off */
- TIMER_REG(0x44) = 0; /* dividers back to default */
-}
-
-/* note: both PLLs are programmed the same way,
- * the databook incorrectly states that PLL1 differs */
-static int decode_pll(unsigned int reg)
-{
- long long v;
- int p, m, s;
-
- p = (reg >> 18) & 0x3f;
- m = (reg >> 8) & 0x3ff;
- s = reg & 0xff;
-
- if (p == 0)
- p = 1;
-
- v = 27000000; // master clock
- v = v * m / (p << s);
- return v;
-}
-
-int pollux_get_real_snd_rate(int req_rate)
-{
- int clk0_src, clk1_src, rate, div;
-
- clk0_src = (memregl[0xdbc4>>2] >> 1) & 7;
- clk1_src = (memregl[0xdbc8>>2] >> 1) & 7;
- if (clk0_src > 1 || clk1_src != 7) {
- fprintf(stderr, "get_real_snd_rate: bad clk sources: %d %d\n", clk0_src, clk1_src);
- return req_rate;
- }
-
- rate = decode_pll(clk0_src ? memregl[0xf008>>2] : memregl[0xf004>>2]);
-
- // apply divisors
- div = ((memregl[0xdbc4>>2] >> 4) & 0x3f) + 1;
- rate /= div;
- div = ((memregl[0xdbc8>>2] >> 4) & 0x3f) + 1;
- rate /= div;
- rate /= 64;
-
- //printf("rate %d\n", rate);
- rate -= rate * timer_drift / 1000000;
- printf("adjusted rate: %d\n", rate);
-
- if (rate < 8000-1000 || rate > 44100+1000) {
- fprintf(stderr, "get_real_snd_rate: got bad rate: %d\n", rate);
- return req_rate;
- }
-
- return rate;
-}
-
-void pollux_init(void)
-{
- struct fb_fix_screeninfo fbfix;
- int i, ret, rate, timer_div;
-
- memdev = open("/dev/mem", O_RDWR);
- if (memdev == -1) {
- perror("open(/dev/mem) failed");
- exit(1);
- }
-
- memregs = mmap(0, 0x20000, PROT_READ|PROT_WRITE, MAP_SHARED, memdev, 0xc0000000);
- if (memregs == MAP_FAILED) {
- perror("mmap(memregs) failed");
- exit(1);
- }
- memregl = (volatile void *)memregs;
-
- fbdev = open("/dev/fb0", O_RDWR);
- if (fbdev < 0) {
- perror("can't open fbdev");
- exit(1);
- }
-
- ret = ioctl(fbdev, FBIOGET_FSCREENINFO, &fbfix);
- if (ret == -1) {
- perror("ioctl(fbdev) failed");
- exit(1);
- }
-
- printf("framebuffer: \"%s\" @ %08lx\n", fbfix.id, fbfix.smem_start);
- fb_paddr[0] = fbfix.smem_start;
-
- gp2x_screens[0] = mmap(0, 320*240*2*fb_buf_count, PROT_READ|PROT_WRITE,
- MAP_SHARED, memdev, fb_paddr[0]);
- if (gp2x_screens[0] == MAP_FAILED)
- {
- perror("mmap(gp2x_screens) failed");
- exit(1);
- }
- memset(gp2x_screens[0], 0, 320*240*2*fb_buf_count);
-
- printf(" %p -> %08x\n", gp2x_screens[0], fb_paddr[0]);
- for (i = 1; i < fb_buf_count; i++)
- {
- fb_paddr[i] = fb_paddr[i-1] + 320*240*2;
- gp2x_screens[i] = (char *)gp2x_screens[i-1] + 320*240*2;
- printf(" %p -> %08x\n", gp2x_screens[i], fb_paddr[i]);
- }
- fb_work_buf = 0;
- g_screen_ptr = gp2x_screens[0];
-
- battdev = open("/dev/pollux_batt", O_RDONLY);
- if (battdev < 0)
- perror("Warning: could't open pollux_batt");
-
- /* find what PLL1 runs at, for the timer */
- rate = decode_pll(memregl[0xf008>>2]);
- printf("PLL1 @ %dHz\n", rate);
-
- /* setup timer */
- timer_div = (rate + 500000) / 1000000;
- if (1 <= timer_div && timer_div <= 256) {
- timer_drift = (rate - (timer_div * 1000000)) / timer_div;
-
- if (TIMER_REG(0x08) & 8) {
- fprintf(stderr, "warning: timer in use, overriding!\n");
- timer_cleanup();
- }
-
- TIMER_REG(0x44) = ((timer_div - 1) << 4) | 2; /* using PLL1, divide by it's rate */
- TIMER_REG(0x40) = 0x0c; /* clocks on */
- TIMER_REG(0x08) = 0x6b; /* run timer, clear irq, latch value */
-
- gp2x_get_ticks_ms = gp2x_get_ticks_ms_;
- gp2x_get_ticks_us = gp2x_get_ticks_us_;
- }
- else {
- fprintf(stderr, "warning: could not make use of timer\n");
-
- // those functions are actually not good at all on Wiz kernel
- gp2x_get_ticks_ms = plat_get_ticks_ms_good;
- gp2x_get_ticks_us = plat_get_ticks_us_good;
- }
-
- pllsetreg0_old = memregl[0xf004>>2];
- memtimex_old[0] = memregs[0x14802>>1];
- memtimex_old[1] = memregs[0x14804>>1];
-
- gp2x_video_flip = gp2x_video_flip_;
- gp2x_video_flip2 = gp2x_video_flip2_;
- gp2x_video_changemode_ll = gp2x_video_changemode_ll_;
- gp2x_video_setpalette = gp2x_video_setpalette_;
- gp2x_video_RGB_setscaling = gp2x_video_RGB_setscaling_;
- gp2x_video_wait_vsync = gp2x_video_wait_vsync_;
-
- /* some firmwares have sys clk on PLL0, we can't adjust CPU clock
- * by reprogramming the PLL0 then, as it overclocks system bus */
- if ((memregl[0xf000>>2] & 0x03000030) == 0x01000000)
- gp2x_set_cpuclk = gp2x_set_cpuclk_;
- else {
- fprintf(stderr, "unexpected PLL config (%08x), overclocking disabled\n",
- memregl[0xf000>>2]);
- gp2x_set_cpuclk = NULL;
- }
-
- set_lcd_custom_rate = set_lcd_custom_rate_;
- unset_lcd_custom_rate = unset_lcd_custom_rate_;
- set_lcd_gamma = set_lcd_gamma_;
-
- set_ram_timings = set_ram_timings_;
- unset_ram_timings = unset_ram_timings_;
- gp2x_read_battery = gp2x_read_battery_;
-}
-
-void pollux_finish(void)
-{
- /* switch to default fb mem, turn portrait off */
- memregl[0x406C>>2] = fb_paddr[0];
- memregl[0x4058>>2] |= 0x10;
- close(fbdev);
-
- gp2x_video_changemode_ll_(16);
- unset_ram_timings_();
- if (cpuclk_was_changed) {
- memregl[0xf004>>2] = pllsetreg0_old;
- memregl[0xf07c>>2] |= 0x8000;
- }
- timer_cleanup();
-
- munmap((void *)memregs, 0x20000);
- close(memdev);
- if (battdev >= 0)
- close(battdev);
-}
-
+++ /dev/null
-
-int pollux_get_real_snd_rate(int req_rate);
--- /dev/null
+/*
+ * (C) Gražvydas "notaz" Ignotas, 2006-2009,2013
+ *
+ * This work is licensed under the terms of any of these licenses
+ * (at your option):
+ * - GNU GPL, version 2 or later.
+ * - GNU LGPL, version 2.1 or later.
+ * - MAME license.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <linux/fb.h>
+#include <sys/mman.h>
+
+#include "../libpicofe/gp2x/plat_gp2x.h"
+#include "../libpicofe/gp2x/soc.h"
+#include "../common/arm_utils.h"
+#include "../common/emu.h"
+#include "plat.h"
+
+#define FRAMEBUFF_SIZE 0x30000
+#define FRAMEBUFF_WHOLESIZE (FRAMEBUFF_SIZE*4) // 320*240*2 + some more
+#define FRAMEBUFF_ADDR0 (0x4000000 - FRAMEBUFF_WHOLESIZE)
+#define FRAMEBUFF_ADDR1 (FRAMEBUFF_ADDR0 + FRAMEBUFF_SIZE)
+#define FRAMEBUFF_ADDR2 (FRAMEBUFF_ADDR1 + FRAMEBUFF_SIZE)
+#define FRAMEBUFF_ADDR3 (FRAMEBUFF_ADDR2 + FRAMEBUFF_SIZE)
+
+static const int gp2x_screenaddrs[4] = { FRAMEBUFF_ADDR0, FRAMEBUFF_ADDR1, FRAMEBUFF_ADDR2, FRAMEBUFF_ADDR3 };
+static int gp2x_screenaddrs_use[4];
+
+static unsigned short gp2x_screenaddr_old[4];
+static int screensel;
+
+static void gp2x_video_flip_(void)
+{
+ unsigned short lsw = (unsigned short) gp2x_screenaddrs_use[screensel&3];
+ unsigned short msw = (unsigned short)(gp2x_screenaddrs_use[screensel&3] >> 16);
+
+ memregs[0x2910>>1] = msw;
+ memregs[0x2914>>1] = msw;
+ memregs[0x290E>>1] = lsw;
+ memregs[0x2912>>1] = lsw;
+
+ // jump to other buffer:
+ g_screen_ptr = gp2x_screens[++screensel&3];
+}
+
+/* doulblebuffered flip */
+static void gp2x_video_flip2_(void)
+{
+ unsigned short msw = (unsigned short)(gp2x_screenaddrs_use[screensel&1] >> 16);
+
+ memregs[0x2910>>1] = msw;
+ memregs[0x2914>>1] = msw;
+ memregs[0x290E>>1] = 0;
+ memregs[0x2912>>1] = 0;
+
+ // jump to other buffer:
+ g_screen_ptr = gp2x_screens[++screensel&1];
+}
+
+static void gp2x_video_changemode_ll_(int bpp)
+{
+printf("changemode %d\n", bpp);
+ memregs[0x28DA>>1] = (((bpp+1)/8)<<9)|0xAB; /*8/15/16/24bpp...*/
+ memregs[0x290C>>1] = 320*((bpp+1)/8); /*line width in bytes*/
+}
+
+static void gp2x_video_setpalette_(int *pal, int len)
+{
+ unsigned short *g = (unsigned short *)pal;
+ volatile unsigned short *memreg = &memregs[0x295A>>1];
+
+ memregs[0x2958>>1] = 0;
+
+ len *= 2;
+ while (len--)
+ *memreg = *g++;
+}
+
+static void gp2x_video_RGB_setscaling_(int ln_offs, int W, int H)
+{
+ float escalaw, escalah;
+ int bpp = (memregs[0x28DA>>1]>>9)&0x3;
+ unsigned short scalw;
+
+ // set offset
+ gp2x_screenaddrs_use[0] = gp2x_screenaddrs[0] + ln_offs * 320 * bpp;
+ gp2x_screenaddrs_use[1] = gp2x_screenaddrs[1] + ln_offs * 320 * bpp;
+ gp2x_screenaddrs_use[2] = gp2x_screenaddrs[2] + ln_offs * 320 * bpp;
+ gp2x_screenaddrs_use[3] = gp2x_screenaddrs[3] + ln_offs * 320 * bpp;
+
+ escalaw = 1024.0; // RGB Horiz LCD
+ escalah = 320.0; // RGB Vert LCD
+
+ if (memregs[0x2800>>1]&0x100) //TV-Out
+ {
+ escalaw=489.0; // RGB Horiz TV (PAL, NTSC)
+ if (memregs[0x2818>>1] == 287) //PAL
+ escalah=274.0; // RGB Vert TV PAL
+ else if (memregs[0x2818>>1] == 239) //NTSC
+ escalah=331.0; // RGB Vert TV NTSC
+ }
+
+ // scale horizontal
+ scalw = (unsigned short)((float)escalaw *(W/320.0));
+ /* if there is no horizontal scaling, vertical doesn't work.
+ * Here is a nasty wrokaround... */
+ if (H != 240 && W == 320) scalw--;
+ memregs[0x2906>>1]=scalw;
+ // scale vertical
+ memregl[0x2908>>2]=(unsigned long)((float)escalah *bpp *(H/240.0));
+}
+
+static void gp2x_video_wait_vsync_(void)
+{
+ unsigned short v = memregs[0x1182>>1];
+ while (!((v ^ memregs[0x1182>>1]) & 0x10))
+ spend_cycles(1024);
+}
+
+
+void vid_mmsp2_init(void)
+{
+ int i;
+
+ gp2x_screens[0] = mmap(0, FRAMEBUFF_WHOLESIZE, PROT_WRITE, MAP_SHARED,
+ memdev, gp2x_screenaddrs[0]);
+ if (gp2x_screens[0] == MAP_FAILED)
+ {
+ perror("mmap(g_screen_ptr)");
+ exit(1);
+ }
+ printf("framebuffers:\n");
+ printf(" %08x -> %p\n", gp2x_screenaddrs[0], gp2x_screens[0]);
+ for (i = 1; i < 4; i++)
+ {
+ gp2x_screens[i] = (char *) gp2x_screens[i - 1] + FRAMEBUFF_SIZE;
+ printf(" %08x -> %p\n", gp2x_screenaddrs[i], gp2x_screens[i]);
+ }
+
+ g_screen_ptr = gp2x_screens[0];
+ screensel = 0;
+
+ gp2x_screenaddr_old[0] = memregs[0x290E>>1];
+ gp2x_screenaddr_old[1] = memregs[0x2910>>1];
+ gp2x_screenaddr_old[2] = memregs[0x2912>>1];
+ gp2x_screenaddr_old[3] = memregs[0x2914>>1];
+
+ memcpy(gp2x_screenaddrs_use, gp2x_screenaddrs, sizeof(gp2x_screenaddrs));
+
+ gp2x_video_flip = gp2x_video_flip_;
+ gp2x_video_flip2 = gp2x_video_flip2_;
+ gp2x_video_changemode_ll = gp2x_video_changemode_ll_;
+ gp2x_video_setpalette = gp2x_video_setpalette_;
+ gp2x_video_RGB_setscaling = gp2x_video_RGB_setscaling_;
+ gp2x_video_wait_vsync = gp2x_video_wait_vsync_;
+}
+
+void vid_mmsp2_finish(void)
+{
+ gp2x_video_RGB_setscaling_(0, 320, 240);
+ gp2x_video_changemode_ll_(16);
+
+ memregs[0x290E>>1] = gp2x_screenaddr_old[0];
+ memregs[0x2910>>1] = gp2x_screenaddr_old[1];
+ memregs[0x2912>>1] = gp2x_screenaddr_old[2];
+ memregs[0x2914>>1] = gp2x_screenaddr_old[3];
+
+ munmap(gp2x_screens[0], FRAMEBUFF_WHOLESIZE);
+}
--- /dev/null
+/*
+ * (C) Gražvydas "notaz" Ignotas, 2009,2013
+ *
+ * This work is licensed under the terms of any of these licenses
+ * (at your option):
+ * - GNU GPL, version 2 or later.
+ * - GNU LGPL, version 2.1 or later.
+ * - MAME license.
+ * See the COPYING file in the top-level directory.
+ *
+ * <random_info=mem_map>
+ * 00000000-029fffff linux (42MB)
+ * 02a00000-02dfffff fb (4MB, 153600B really used)
+ * 02e00000-02ffffff sound dma (2MB)
+ * 03000000-03ffffff MPEGDEC (?, 16MB)
+ * </random_info>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <linux/fb.h>
+#include <unistd.h>
+
+#include "../libpicofe/gp2x/soc.h"
+#include "../libpicofe/gp2x/plat_gp2x.h"
+#include "../libpicofe/gp2x/pollux_set.h"
+#include "../common/emu.h"
+#include "../common/arm_utils.h"
+#include "plat.h"
+
+#define fb_buf_count 4
+static unsigned int fb_paddr[fb_buf_count];
+static int fb_work_buf;
+static int fbdev = -1;
+
+static unsigned short memtimex_old[2];
+static int last_pal_setting = 0;
+
+
+/* misc */
+static void pollux_set_fromenv(const char *env_var)
+{
+ const char *set_string;
+ set_string = getenv(env_var);
+ if (set_string)
+ pollux_set(memregs, set_string);
+ else
+ printf("env var %s not defined.\n", env_var);
+}
+
+/* video stuff */
+static void pollux_video_flip(int buf_count)
+{
+ memregl[0x406C>>2] = fb_paddr[fb_work_buf];
+ memregl[0x4058>>2] |= 0x10;
+ fb_work_buf++;
+ if (fb_work_buf >= buf_count)
+ fb_work_buf = 0;
+ g_screen_ptr = gp2x_screens[fb_work_buf];
+}
+
+static void gp2x_video_flip_(void)
+{
+ pollux_video_flip(fb_buf_count);
+}
+
+/* doulblebuffered flip */
+static void gp2x_video_flip2_(void)
+{
+ pollux_video_flip(2);
+}
+
+static void gp2x_video_changemode_ll_(int bpp)
+{
+ static int prev_bpp = 0;
+ int code = 0, bytes = 2;
+ int rot_cmd[2] = { 0, 0 };
+ unsigned int r;
+ char buff[32];
+ int ret;
+
+ if (bpp == prev_bpp)
+ return;
+ prev_bpp = bpp;
+
+ printf("changemode: %dbpp rot=%d\n", abs(bpp), bpp < 0);
+
+ /* negative bpp means rotated mode */
+ rot_cmd[0] = (bpp < 0) ? 6 : 5;
+ ret = ioctl(fbdev, _IOW('D', 90, int[2]), rot_cmd);
+ if (ret < 0)
+ perror("rot ioctl failed");
+ memregl[0x4004>>2] = (bpp < 0) ? 0x013f00ef : 0x00ef013f;
+ memregl[0x4000>>2] |= 1 << 3;
+
+ /* the above ioctl resets LCD timings, so set them here */
+ snprintf(buff, sizeof(buff), "POLLUX_LCD_TIMINGS_%s", last_pal_setting ? "PAL" : "NTSC");
+ pollux_set_fromenv(buff);
+
+ switch (abs(bpp))
+ {
+ case 8:
+ code = 0x443a;
+ bytes = 1;
+ break;
+
+ case 15:
+ case 16:
+ code = 0x4432;
+ bytes = 2;
+ break;
+
+ default:
+ printf("unhandled bpp request: %d\n", abs(bpp));
+ return;
+ }
+
+ memregl[0x405c>>2] = bytes;
+ memregl[0x4060>>2] = bytes * (bpp < 0 ? 240 : 320);
+
+ r = memregl[0x4058>>2];
+ r = (r & 0xffff) | (code << 16) | 0x10;
+ memregl[0x4058>>2] = r;
+}
+
+static void gp2x_video_setpalette_(int *pal, int len)
+{
+ /* pollux palette is 16bpp only.. */
+ int i;
+ for (i = 0; i < len; i++)
+ {
+ int c = pal[i];
+ c = ((c >> 8) & 0xf800) | ((c >> 5) & 0x07c0) | ((c >> 3) & 0x001f);
+ memregl[0x4070>>2] = (i << 24) | c;
+ }
+}
+
+static void gp2x_video_RGB_setscaling_(int ln_offs, int W, int H)
+{
+ /* maybe a job for 3d hardware? */
+}
+
+static void gp2x_video_wait_vsync_(void)
+{
+ while (!(memregl[0x308c>>2] & (1 << 10)))
+ spend_cycles(128);
+ memregl[0x308c>>2] |= 1 << 10;
+}
+
+/* RAM timings */
+static void set_ram_timings_(void)
+{
+ pollux_set_fromenv("POLLUX_RAM_TIMINGS");
+}
+
+static void unset_ram_timings_(void)
+{
+ int i;
+
+ memregs[0x14802>>1] = memtimex_old[0];
+ memregs[0x14804>>1] = memtimex_old[1] | 0x8000;
+
+ for (i = 0; i < 0x100000; i++)
+ if (!(memregs[0x14804>>1] & 0x8000))
+ break;
+
+ printf("RAM timings reset to startup values.\n");
+}
+
+void vid_pollux_init(void)
+{
+ struct fb_fix_screeninfo fbfix;
+ int i, ret;
+
+ fbdev = open("/dev/fb0", O_RDWR);
+ if (fbdev < 0) {
+ perror("can't open fbdev");
+ exit(1);
+ }
+
+ ret = ioctl(fbdev, FBIOGET_FSCREENINFO, &fbfix);
+ if (ret == -1) {
+ perror("ioctl(fbdev) failed");
+ exit(1);
+ }
+
+ printf("framebuffer: \"%s\" @ %08lx\n", fbfix.id, fbfix.smem_start);
+ fb_paddr[0] = fbfix.smem_start;
+
+ gp2x_screens[0] = mmap(0, 320*240*2*fb_buf_count, PROT_READ|PROT_WRITE,
+ MAP_SHARED, memdev, fb_paddr[0]);
+ if (gp2x_screens[0] == MAP_FAILED)
+ {
+ perror("mmap(gp2x_screens) failed");
+ exit(1);
+ }
+ memset(gp2x_screens[0], 0, 320*240*2*fb_buf_count);
+
+ printf(" %p -> %08x\n", gp2x_screens[0], fb_paddr[0]);
+ for (i = 1; i < fb_buf_count; i++)
+ {
+ fb_paddr[i] = fb_paddr[i-1] + 320*240*2;
+ gp2x_screens[i] = (char *)gp2x_screens[i-1] + 320*240*2;
+ printf(" %p -> %08x\n", gp2x_screens[i], fb_paddr[i]);
+ }
+ fb_work_buf = 0;
+ g_screen_ptr = gp2x_screens[0];
+
+ set_ram_timings_();
+
+ gp2x_video_flip = gp2x_video_flip_;
+ gp2x_video_flip2 = gp2x_video_flip2_;
+ gp2x_video_changemode_ll = gp2x_video_changemode_ll_;
+ gp2x_video_setpalette = gp2x_video_setpalette_;
+ gp2x_video_RGB_setscaling = gp2x_video_RGB_setscaling_;
+ gp2x_video_wait_vsync = gp2x_video_wait_vsync_;
+}
+
+void vid_pollux_finish(void)
+{
+ munmap(gp2x_screens[0], 320*240*2 * fb_buf_count);
+ close(fbdev);
+ fbdev = -1;
+
+ unset_ram_timings_();
+}
-Subproject commit c54d04fd84f59c60c6ecdbd2502fbda5de735b4b
+Subproject commit 7ceadd9993ea84078e9d74d79215419e06496f90
mee_range_hide("layer_w", MA_OPT3_LAYER_W, g_layer_cw, 160, 800), \
mee_range_hide("layer_h", MA_OPT3_LAYER_H, g_layer_ch, 60, 480), \
-#define MENU_OPTIONS_ADV \
- 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),
-
-#define menu_main_plat_draw NULL
+#define MENU_OPTIONS_ADV
static menu_entry e_menu_gfx_options[];
static menu_entry e_menu_options[];
void pnd_menu_init(void)
{
- int i;
-
- i = me_id2offset(e_menu_options, MA_OPT_CPU_CLOCKS);
- e_menu_options[i].name = "Max CPU clock";
-
me_enable(e_menu_keyconfig, MA_CTRL_DEADZONE, 0);
}