if (cmd&0x80) CommandDma();\r
}\r
\r
-static __inline void DrawSync(int blank_on)\r
+static void DrawSync(int blank_on)\r
{\r
if (Pico.m.scanline < 224 && !(PicoOpt & POPT_ALT_RENDERER) &&\r
!PicoSkipFrame && DrawScanline <= Pico.m.scanline) {\r
+ifneq ($(DEBUG),)
+CFLAGS += -ggdb
+endif
+ifeq "$(profile)" "1"
+CFLAGS += -fprofile-generate
+endif
+ifeq "$(profile)" "2"
+CFLAGS += -fprofile-use
+endif
+
+# === Pico core ===
+# Pico
+OBJS += pico/area.o pico/cart.o pico/memory.o pico/pico.o pico/sek.o pico/z80if.o \
+ pico/videoport.o pico/draw2.o pico/draw.o pico/mode4.o pico/sms.o \
+ pico/misc.o pico/eeprom.o pico/patch.o pico/debug.o
+# CD
+OBJS += pico/cd/pico.o pico/cd/memory.o pico/cd/sek.o pico/cd/LC89510.o \
+ pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \
+ pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o
+# 32X
+OBJS += pico/32x/32x.o pico/32x/memory.o pico/32x/draw.o pico/32x/pwm.o
+# Pico
+OBJS += pico/pico/pico.o pico/pico/memory.o pico/pico/xpcm.o
+# carthw
+OBJS += pico/carthw/carthw.o
+# SVP
+OBJS += pico/carthw/svp/svp.o pico/carthw/svp/memory.o \
+ pico/carthw/svp/ssp16.o
+# sound
+OBJS += pico/sound/sound.o
+OBJS += pico/sound/sn76496.o pico/sound/ym2612.o
+
# === CPU cores ===
# --- M68k ---
ifeq "$(use_musashi)" "1"
endif
+DIRS += platform platform/common pico pico/cd pico/pico pico/32x pico/sound pico/carthw/svp \
+ cpu cpu/musashi cpu/cz80 cpu/fame cpu/sh2/mame cpu/drc
+
+
+# common rules
+.c.o:
+ @echo ">>>" $<
+ $(CC) $(CFLAGS) -c $< -o $@
+.s.o:
+ @echo ">>>" $<
+ $(CC) $(CFLAGS) -c $< -o $@
+
+clean_prof:
+ find ../.. -name '*.gcno' -delete
+ find ../.. -name '*.gcda' -delete
+
+mkdirs:
+ mkdir -p $(DIRS)
+
+../../tools/textfilter: ../../tools/textfilter.c
+ make -C ../../tools/ textfilter
+
+
# random deps
pico/carthw/svp/compiler.o : ../../cpu/drc/emit_$(ARCH).c
cpu/sh2/compiler.o : ../../cpu/drc/emit_$(ARCH).c
endif
-.c.o:
- @echo ">>>" $<
- $(CC) $(CFLAGS) -c $< -o $@
+DIRS += cpu/Cyclone cpu/Cyclone/proj cpu/Cyclone/tools cpu/DrZ80
-.S.o:
- @echo ">>>" $<
- $(CC) $(CFLAGS) -c $< -o $@
-
-
-../../tools/textfilter: ../../tools/textfilter.c
- make -C ../../tools/ textfilter
-
-clean_prof:
- find ../.. -name '*.gcno' -delete
- find ../.. -name '*.gcda' -delete
-
-mkdirs:
- mkdir -p $(DIRS)
# build helix libs
../common/helix/$(CROSS)helix-mp3.a:
- make -C ../common/helix clean all
-
+ make -C ../common/helix CROSS=$(CROSS) clean all
cfg_buff_512[511] = 0;\r
}\r
\r
+void emu_prep_defconfig(void)\r
+{\r
+ memset(&defaultConfig, 0, sizeof(defaultConfig));\r
+ defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_CONFIRM_SAVE|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_SVP_DRC|POPT_ACC_SPRITES |\r
+ POPT_EN_32X|POPT_EN_PWM;\r
+ defaultConfig.s_PsndRate = 44100;\r
+ defaultConfig.s_PicoRegion = 0; // auto\r
+ defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP\r
+ defaultConfig.s_PicoCDBuffers = 0;\r
+ defaultConfig.Frameskip = -1; // auto\r
+ defaultConfig.volume = 50;\r
+ defaultConfig.gamma = 100;\r
+ defaultConfig.scaling = 0;\r
+ defaultConfig.turbo_rate = 15;\r
+\r
+ // platform specific overrides\r
+ pemu_prep_defconfig();\r
+}\r
+\r
void emu_set_defconfig(void)\r
{\r
memcpy(¤tConfig, &defaultConfig, sizeof(currentConfig));\r
}\r
}\r
\r
- plat_validate_config();\r
+ pemu_validate_config();\r
\r
// some sanity checks\r
#ifdef PSP\r
int emu_save_load_game(int load, int sram);
void emu_reset_game(void);
+void emu_prep_defconfig(void);
void emu_set_defconfig(void);
int emu_read_config(int game, int no_defaults);
int emu_write_config(int game);
\r
/* in_init() must go before config, config accesses in_ fwk */\r
in_init();\r
- pemu_prep_defconfig();\r
+ emu_prep_defconfig();\r
emu_read_config(0, 0);\r
config_readlrom(PicoConfigFile);\r
\r
#include <pico/patch.h>\r
\r
static char static_buff[64];\r
-char menu_error_msg[64] = { 0, };\r
static int menu_error_time = 0;\r
+char menu_error_msg[64] = { 0, };\r
+void *g_menubg_ptr;\r
\r
#ifndef UIQ3\r
\r
}\r
\r
\r
+static void menu_darken_bg(void *dst, void *src, int pixels, int darker)\r
+{\r
+ unsigned int *dest = dst;\r
+ unsigned int *sorc = src;\r
+ pixels /= 2;\r
+ if (darker)\r
+ {\r
+ while (pixels--)\r
+ {\r
+ unsigned int p = *sorc++;\r
+ *dest++ = ((p&0xf79ef79e)>>1) - ((p&0xc618c618)>>3);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ while (pixels--)\r
+ {\r
+ unsigned int p = *sorc++;\r
+ *dest++ = (p&0xf79ef79e)>>1;\r
+ }\r
+ }\r
+}\r
+\r
+static void menu_enter(int is_rom_loaded)\r
+{\r
+ if (is_rom_loaded)\r
+ {\r
+ // darken the active framebuffer\r
+ menu_darken_bg(g_menubg_ptr, g_screen_ptr, g_screen_width * g_screen_height, 1);\r
+ }\r
+ else\r
+ {\r
+ char buff[256];\r
+\r
+ // should really only happen once, on startup..\r
+ emu_make_path(buff, "skin/background.png", sizeof(buff));\r
+ if (readpng(g_menubg_ptr, buff, READPNG_BG) < 0)\r
+ memset(g_menubg_ptr, 0, g_screen_width * g_screen_height * 2);\r
+ }\r
+\r
+ plat_video_menu_enter(is_rom_loaded);\r
+}\r
+\r
static int me_id2offset(const menu_entry *ent, menu_id id)\r
{\r
int i;\r
plat_video_menu_begin();\r
\r
if (!rom_loaded)\r
- menu_darken_bg(g_screen_ptr, g_screen_width * g_screen_height, 0);\r
+ menu_darken_bg(g_screen_ptr, g_screen_ptr, g_screen_width * g_screen_height, 0);\r
\r
len = strlen(fname);\r
if (len > g_screen_width/6)\r
static void draw_dirlist(char *curdir, struct dirent **namelist, int n, int sel)\r
{\r
int max_cnt, start, i, x, pos;\r
+ void *darken_ptr;\r
\r
max_cnt = g_screen_height / me_sfont_h;\r
start = max_cnt / 2 - sel;\r
// if (!rom_loaded)\r
// menu_darken_bg(gp2x_screen, 320*240, 0);\r
\r
- menu_darken_bg((short *)g_screen_ptr + g_screen_width * max_cnt/2 * 10, g_screen_width * 8, 0);\r
+ darken_ptr = (short *)g_screen_ptr + g_screen_width * max_cnt/2 * 10;\r
+ menu_darken_bg(darken_ptr, darken_ptr, g_screen_width * 8, 0);\r
\r
x = 5 + me_mfont_w + 1;\r
if (start - 2 >= 0)\r
\r
/* do a frame and fetch menu bg */\r
pemu_forced_frame(POPT_EN_SOFTSCALE);\r
- plat_video_menu_enter(1);\r
+ menu_enter(1);\r
\r
memcpy(Pico.vram, tmp_vram, sizeof(Pico.vram));\r
memcpy(Pico.cram, tmp_cram, sizeof(Pico.cram));\r
case 1: draw_frame_debug(); break;\r
case 2: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);\r
pemu_forced_frame(0);\r
- menu_darken_bg(g_screen_ptr, g_screen_width * g_screen_height, 0);\r
+ menu_darken_bg(g_screen_ptr, g_screen_ptr, g_screen_width * g_screen_height, 0);\r
PDebugShowSpriteStats((unsigned short *)g_screen_ptr + (g_screen_height/2 - 240/2)*g_screen_width +\r
g_screen_width/2 - 320/2, g_screen_width); break;\r
case 3: memset(g_screen_ptr, 0, g_screen_width * g_screen_height * 2);\r
me_enable(e_menu_main, MA_MAIN_RESET_GAME, rom_loaded);\r
me_enable(e_menu_main, MA_MAIN_PATCHES, PicoPatches != NULL);\r
\r
- plat_video_menu_enter(rom_loaded);\r
+ menu_enter(rom_loaded);\r
in_set_blocking(1);\r
me_loop(e_menu_main, &sel, menu_main_plat_draw);\r
\r
{\r
int ret = 1, sel = 0;\r
\r
- plat_video_menu_enter(rom_loaded);\r
+ menu_enter(rom_loaded);\r
\r
in_set_blocking(1);\r
me_loop(e_menu_tray, &sel, NULL);\r
e_menu_gfx_options[i].need_to_save = 0;\r
}\r
\r
-/* TODO: rename */\r
-void menu_darken_bg(void *dst, int pixels, int darker)\r
-{\r
- unsigned int *screen = dst;\r
- pixels /= 2;\r
- if (darker)\r
- {\r
- while (pixels--)\r
- {\r
- unsigned int p = *screen;\r
- *screen++ = ((p&0xf79ef79e)>>1) - ((p&0xc618c618)>>3);\r
- }\r
- }\r
- else\r
- {\r
- while (pixels--)\r
- {\r
- unsigned int p = *screen;\r
- *screen++ = (p&0xf79ef79e)>>1;\r
- }\r
- }\r
-}\r
-\r
/* hidden options for config engine only */\r
static menu_entry e_menu_hidden[] =\r
{\r
extern me_bind_action me_ctrl_actions[15];
extern me_bind_action emuctrl_actions[]; // platform code
+extern void *g_menubg_ptr;
+
void menu_init(void);
void menu_plat_setup(int is_wiz);
void text_out16(int x, int y, const char *texto, ...);
menu_entry *me_list_get_first(void);
menu_entry *me_list_get_next(void);
-void menu_darken_bg(void *dst, int pixels, int darker);
-
extern char cpu_clk_name[];
void pemu_prep_defconfig(void);
+void pemu_validate_config(void);
void pemu_loop_prep(void);
void pemu_loop_end(void);
void pemu_forced_frame(int opts);
void plat_video_wait_vsync(void);
void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu);
-void plat_validate_config(void);
void plat_update_volume(int has_changed, int is_up);
int plat_is_dir(const char *path);
void pemu_prep_defconfig(void)
{
- memset(&defaultConfig, 0, sizeof(defaultConfig));
- defaultConfig.EmuOpt = 0x1d | 0x680; // | confirm_save, cd_leds, 16bit rend
- defaultConfig.s_PicoOpt = 0x0f | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES;
defaultConfig.s_PsndRate = 22050;
- defaultConfig.s_PicoRegion = 0; // auto
- defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP
defaultConfig.s_PicoCDBuffers = 0;
- defaultConfig.Frameskip = -1; // auto
- defaultConfig.volume = 50;
defaultConfig.KeyBinds[ 2] = 1<<0; // SACB RLDU
defaultConfig.KeyBinds[ 3] = 1<<1;
defaultConfig.KeyBinds[ 0] = 1<<2;
defaultConfig.KeyBinds[12] = 1<<29; // vol up
defaultConfig.KeyBinds[11] = 1<<30; // vol down
defaultConfig.scaling = 0;
- defaultConfig.turbo_rate = 15;
}
asm_misc = 1\r
asm_cdpico = 1\r
asm_cdmemory = 1\r
-amalgamate = 0\r
#profile = 1\r
#drc_debug = 3\r
\r
CFLAGS += -Wall -Winline -I../.. -I.\r
ifeq ($(DEBUG),)\r
CFLAGS += -O3 -fomit-frame-pointer -fstrict-aliasing -ffast-math\r
-else\r
-CFLAGS += -ggdb\r
-endif\r
-ifeq "$(profile)" "1"\r
-CFLAGS += -fprofile-generate\r
-endif\r
-ifeq "$(profile)" "2"\r
-CFLAGS += -fprofile-use\r
endif\r
CFLAGS += -mcpu=arm920t -mtune=arm920t\r
ASFLAGS = -mcpu=arm920t -mfloat-abi=soft\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.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 \\r
platform/linux/sndout_oss.o platform/linux/plat.o platform/linux/in_evdev.o\r
\r
-# Pico\r
-ifeq "$(amalgamate)" "1"\r
-OBJS += ../../picoAll.o\r
-else\r
-OBJS += pico/area.o pico/cart.o pico/memory.o pico/pico.o pico/sek.o pico/z80if.o \\r
- pico/videoport.o pico/draw2.o pico/draw.o pico/mode4.o pico/sms.o \\r
- pico/misc.o pico/eeprom.o pico/patch.o pico/debug.o\r
-# Pico - CD\r
-OBJS += pico/cd/pico.o pico/cd/memory.o pico/cd/sek.o pico/cd/LC89510.o \\r
- pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \\r
- pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o\r
-endif\r
-# Pico - 32X\r
-OBJS += pico/32x/32x.o pico/32x/memory.o pico/32x/draw.o pico/32x/pwm.o\r
-# Pico - Pico\r
-OBJS += pico/pico/pico.o pico/pico/memory.o pico/pico/xpcm.o\r
-# Pico - carthw\r
-OBJS += pico/carthw/carthw.o pico/carthw/svp/svp.o pico/carthw/svp/memory.o \\r
- pico/carthw/svp/ssp16.o pico/carthw/svp/compiler.o pico/carthw/svp/stub_arm.o\r
-\r
-# Pico - sound\r
-ifneq "$(amalgamate)" "1"\r
-OBJS += pico/sound/sound.o\r
-endif\r
-OBJS += pico/sound/mix_arm.o\r
-OBJS += pico/sound/sn76496.o pico/sound/ym2612.o\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
-CFLAGS += $(addprefix -D,$(DEFINES))\r
-\r
vpath %.c = ../..\r
vpath %.s = ../..\r
vpath %.S = ../..\r
\r
-DIRS = platform platform/gp2x platform/linux platform/common pico pico/cd pico/pico pico/32x \\r
- pico/sound pico/carthw/svp zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools \\r
- cpu/mz80 cpu/DrZ80 cpu/sh2/mame cpu/drc\r
+DIRS += platform/gp2x platform/linux zlib unzip \r
\r
\r
all: mkdirs PicoDrive\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
extern void *gp2x_screens[4];\r
\r
-int plat_get_root_dir(char *dst, int len)\r
-{\r
- extern char **g_argv;\r
- int j;\r
-\r
- strncpy(dst, g_argv[0], len);\r
- len -= 32; // reserve\r
- if (len < 0) len = 0;\r
- dst[len] = 0;\r
- for (j = strlen(dst); j > 0; j--)\r
- if (dst[j] == '/') { dst[j+1] = 0; break; }\r
-\r
- return j + 1;\r
-}\r
-\r
\r
static void scaling_update(void)\r
{\r
{\r
gp2x_soc_t soc;\r
\r
- memset(&defaultConfig, 0, sizeof(defaultConfig));\r
- defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_CONFIRM_SAVE|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_SVP_DRC|POPT_ACC_SPRITES |\r
- POPT_EN_32X|POPT_EN_PWM;\r
- defaultConfig.s_PsndRate = 44100;\r
- defaultConfig.s_PicoRegion = 0; // auto\r
- defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP\r
- defaultConfig.s_PicoCDBuffers = 0;\r
- defaultConfig.Frameskip = -1; // auto\r
defaultConfig.CPUclock = default_cpu_clock;\r
- defaultConfig.volume = 50;\r
- defaultConfig.gamma = 100;\r
- defaultConfig.scaling = 0;\r
- defaultConfig.turbo_rate = 15;\r
\r
soc = soc_detect();\r
if (soc == SOCID_MMSP2)\r
defaultConfig.EmuOpt |= EOPT_WIZ_TEAR_FIX|EOPT_SHOW_RTC;\r
}\r
\r
+void pemu_validate_config(void)\r
+{\r
+ gp2x_soc_t soc;\r
+\r
+ soc = soc_detect();\r
+ if (soc != SOCID_MMSP2)\r
+ PicoOpt &= ~POPT_EXT_FM;\r
+ if (soc != SOCID_POLLUX)\r
+ currentConfig.EmuOpt &= ~EOPT_WIZ_TEAR_FIX;\r
+\r
+ if (currentConfig.gamma < 10 || currentConfig.gamma > 300)\r
+ currentConfig.gamma = 100;\r
+\r
+ if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 1024)\r
+ currentConfig.CPUclock = default_cpu_clock;\r
+}\r
+\r
static void (*osd_text)(int x, int y, const char *text);\r
\r
static void osd_text8(int x, int y, const char *text)\r
}\r
}\r
\r
- if (notice || (emu_opt & 2)) {\r
+ if (notice || (emu_opt & EOPT_SHOW_FPS)) {\r
if (notice)\r
osd_text(4, osd_y, notice);\r
if (emu_opt & 2)\r
osd_text(osd_fps_x, osd_y, fps);\r
}\r
- if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))\r
+ if ((PicoAHW & PAHW_MCD) && (emu_opt & EOPT_EN_CD_LEDS))\r
draw_cd_leds();\r
if (PicoAHW & PAHW_PICO)\r
draw_pico_ptr();\r
}
#ifdef FAKE_IN_GP2X
+volatile unsigned short *gp2x_memregs;
+gp2x_soc_t soc_detect(void) { return -1; }
+
static int in_gp2x_get_fake_bits(void)
{
extern int current_keys;
void plat_video_menu_enter(int is_rom_loaded)
{
- if (is_rom_loaded)
- {
- // darken the active framebuffer
- memset(g_screen_ptr, 0, 320*8*2);
- menu_darken_bg((char *)g_screen_ptr + 320*8*2, 320*224, 1);
- memset((char *)g_screen_ptr + 320*232*2, 0, 320*8*2);
- }
- else
- {
- char buff[256];
-
- // should really only happen once, on startup..
- emu_make_path(buff, "skin/background.png", sizeof(buff));
- if (readpng(g_screen_ptr, buff, READPNG_BG) < 0)
- memset(g_screen_ptr, 0, 320*240*2);
- }
-
- // copy to buffer2, switch to black
- gp2x_memcpy_buffers((1<<2), g_screen_ptr, 0, 320*240*2);
-
/* try to switch nicely avoiding tearing on Wiz */
gp2x_video_wait_vsync();
memset(gp2x_screens[0], 0, 320*240*2);
gp2x_video_flip2();
}
-void plat_validate_config(void)
-{
- gp2x_soc_t soc;
-
- soc = soc_detect();
- if (soc != SOCID_MMSP2)
- PicoOpt &= ~POPT_EXT_FM;
- if (soc != SOCID_POLLUX)
- currentConfig.EmuOpt &= ~EOPT_WIZ_TEAR_FIX;
-
- if (currentConfig.gamma < 10 || currentConfig.gamma > 300)
- currentConfig.gamma = 100;
-
- if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 1024)
- currentConfig.CPUclock = default_cpu_clock;
-}
-
void plat_early_init(void)
{
gp2x_soc_t soc;
gp2x_memset_all_buffers(0, 0, 320*240*2);
+ // use buffer2 for menubg (using only buffers 0, 1 in menu)
+ g_menubg_ptr = gp2x_screens[2];
+
// snd
sndout_oss_init();
}
ARCH = x86
endif
-ifeq "$(profile)" "1"
-CFLAGS += -O3 -Wall
-CFLAGS += -ftracer -fstrength-reduce -funroll-loops -fomit-frame-pointer -fstrict-aliasing -ffast-math
-CFLAGS += -fprofile-generate
-else
-CFLAGS += -ggdb -Wall -falign-functions=2
-endif
DEFINES = _UNZIP_SUPPORT IO_STATS IN_EVDEV
+CFLAGS += -ggdb -Wall -falign-functions=2
CFLAGS += -I../.. -I.
LDFLAGS += -lm -lpng
ifeq "$(ARCH)" "arm"
CC = $(CROSS)gcc
# frontend
-OBJS += platform/gp2x/emu.o blit.o in_evdev.o plat.o sndout_oss.o gp2x.o log_io.o
+OBJS += io.o emu.o blit.o in_evdev.o plat.o sndout_oss.o log_io.o
# common
OBJS += platform/common/main.o platform/common/emu.o platform/common/menu.o \
ifeq "$(fake_in_gp2x)" "1"
DEFINES += IN_GP2X FAKE_IN_GP2X
OBJS += platform/gp2x/in_gp2x.o
+DIRS += platform/gp2x
endif
-# Pico
-OBJS += pico/area.o pico/cart.o pico/memory.o pico/pico.o pico/sek.o \
- pico/videoport.o pico/draw2.o pico/draw.o pico/z80if.o pico/patch.o \
- pico/mode4.o pico/sms.o pico/misc.o pico/eeprom.o pico/debug.o
-# Pico - CD
-OBJS += pico/cd/pico.o pico/cd/memory.o pico/cd/sek.o pico/cd/LC89510.o \
- pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \
- pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o
-# Pico - 32X
-OBJS += pico/32x/32x.o pico/32x/memory.o pico/32x/draw.o pico/32x/pwm.o
-# Pico - Pico
-OBJS += pico/pico/pico.o pico/pico/memory.o pico/pico/xpcm.o
-# Pico - sound
-OBJS += pico/sound/sound.o pico/sound/sn76496.o pico/sound/ym2612.o pico/sound/mix.o
-# Pico - carthw
-OBJS += pico/carthw/carthw.o pico/carthw/svp/svp.o pico/carthw/svp/memory.o \
- pico/carthw/svp/ssp16.o pico/carthw/svp/compiler.o
ifeq "$(ARCH)" "arm"
OBJS += pico/carthw/svp/stub_arm.o
endif
+OBJS += pico/sound/mix.o
+OBJS += pico/carthw/svp/compiler.o
+
# zlib
OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \
zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o
# unzip
OBJS += unzip/unzip.o unzip/unzip_stream.o
-CFLAGS += $(addprefix -D,$(DEFINES))
-
vpath %.c = ../..
vpath %.s = ../..
vpath %.S = ../..
vpath %.asm = ../..
-DIRS = platform/linux platform/gp2x platform/common pico pico/cd pico/pico pico/sound pico/carthw/svp \
- pico/32x zlib unzip cpu cpu/musashi cpu/fame cpu/mz80 cpu/cz80 cpu/sh2/mame cpu/drc
+DIRS += platform/linux
all: mkdirs PicoDrive
include ../common/common.mak
+include ../common/revision.mak
+
+CFLAGS += $(addprefix -D,$(DEFINES))
clean: tidy
@$(RM) PicoDrive
@echo ">>>" $@
$(CC) $(CFLAGS) $^ $(LDFLAGS) -Wl,-Map=PicoDrive.map -o $@
-mkdirs:
- @mkdir -p $(DIRS)
-
-include ../common/revision.mak
-
-.c.o:
- @echo ">>>" $<
- $(CC) $(CFLAGS) -c $< -o $@
-.s.o:
- @echo ">>>" $<
- $(CC) $(CFLAGS) -c $< -o $@
%.o : %.asm
@echo ">>>" $<
nasm -f elf $< -o $@
--- /dev/null
+// (c) Copyright 2006-2009 notaz, All rights reserved.\r
+// Free for non-commercial use.\r
+\r
+// For commercial use, separate licencing terms must be obtained.\r
+\r
+#include <stdio.h>\r
+#include <unistd.h>\r
+\r
+#include "../common/emu.h"\r
+#include "../common/menu.h"\r
+#include "../common/plat.h"\r
+#include "../common/arm_utils.h"\r
+#include "../linux/sndout_oss.h"\r
+#include "version.h"\r
+\r
+#include <pico/pico_int.h>\r
+\r
+\r
+static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
+unsigned char temp_frame[320 * 240 * 2];\r
+unsigned char *PicoDraw2FB = temp_frame;\r
+static int osd_fps_x;\r
+char cpu_clk_name[] = "unused";\r
+\r
+extern void update_screen(void);\r
+\r
+\r
+void pemu_prep_defconfig(void)\r
+{\r
+ // XXX: move elsewhere\r
+ g_menubg_ptr = temp_frame;\r
+}\r
+\r
+void pemu_validate_config(void)\r
+{\r
+ extern int PicoOpt;\r
+// PicoOpt &= ~POPT_EXT_FM;\r
+ PicoOpt &= ~POPT_EN_SVP_DRC;\r
+}\r
+\r
+// FIXME: dupes from GP2X, need cleanup\r
+static void (*osd_text)(int x, int y, const char *text);\r
+\r
+static void osd_text8(int x, int y, const char *text)\r
+{\r
+ int len = strlen(text)*8;\r
+ int *p, i, h, offs;\r
+\r
+ len = (len+3) >> 2;\r
+ for (h = 0; h < 8; h++) {\r
+ offs = (x + g_screen_width * (y+h)) & ~3;\r
+ p = (int *) ((char *)g_screen_ptr + offs);\r
+ for (i = len; i; i--, p++)\r
+ *p = 0xe0e0e0e0;\r
+ }\r
+ emu_text_out8(x, y, text);\r
+}\r
+\r
+static void osd_text16(int x, int y, const char *text)\r
+{\r
+ int len = strlen(text)*8;\r
+ int *p, i, h, offs;\r
+\r
+ len = (len+1) >> 1;\r
+ for (h = 0; h < 8; h++) {\r
+ offs = (x + g_screen_width * (y+h)) & ~1;\r
+ p = (int *) ((short *)g_screen_ptr + offs);\r
+ for (i = len; i; i--, p++)\r
+ *p = (*p >> 2) & 0x39e7;\r
+ }\r
+ emu_text_out16(x, y, text);\r
+}\r
+\r
+static void draw_cd_leds(void)\r
+{\r
+ int led_reg, pitch, scr_offs, led_offs;\r
+ led_reg = Pico_mcd->s68k_regs[0];\r
+\r
+ pitch = 320;\r
+ led_offs = 4;\r
+ scr_offs = pitch * 2 + 4;\r
+\r
+ if ((PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP)) {\r
+ #define p(x) px[(x) >> 2]\r
+ // 8-bit modes\r
+ unsigned int *px = (unsigned int *)((char *)g_screen_ptr + scr_offs);\r
+ unsigned int col_g = (led_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
+ unsigned int col_r = (led_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
+ p(pitch*0) = p(pitch*1) = p(pitch*2) = col_g;\r
+ p(pitch*0 + led_offs) = p(pitch*1 + led_offs) = p(pitch*2 + led_offs) = col_r;\r
+ #undef p\r
+ } else {\r
+ #define p(x) px[(x)*2 >> 2] = px[((x)*2 >> 2) + 1]\r
+ // 16-bit modes\r
+ unsigned int *px = (unsigned int *)((short *)g_screen_ptr + scr_offs);\r
+ unsigned int col_g = (led_reg & 2) ? 0x06000600 : 0;\r
+ unsigned int col_r = (led_reg & 1) ? 0xc000c000 : 0;\r
+ p(pitch*0) = p(pitch*1) = p(pitch*2) = col_g;\r
+ p(pitch*0 + led_offs) = p(pitch*1 + led_offs) = p(pitch*2 + led_offs) = col_r;\r
+ #undef p\r
+ }\r
+}\r
+\r
+static int EmuScanBegin16(unsigned int num)\r
+{\r
+ DrawLineDest = (unsigned short *)g_screen_ptr + num * g_screen_width;\r
+\r
+ return 0;\r
+}\r
+\r
+void pemu_update_display(const char *fps, const char *notice)\r
+{\r
+ if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {\r
+ if (notice)\r
+ osd_text(4, g_screen_height - 8, notice);\r
+ if (currentConfig.EmuOpt & EOPT_SHOW_FPS)\r
+ osd_text(osd_fps_x, g_screen_height - 8, fps);\r
+ }\r
+ if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))\r
+ draw_cd_leds();\r
+\r
+ update_screen();\r
+}\r
+\r
+void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu)\r
+{\r
+ // this will auto-select SMS/32X renderers\r
+ PicoDrawSetColorFormat(1);\r
+}\r
+\r
+void plat_video_menu_enter(int is_rom_loaded)\r
+{\r
+}\r
+\r
+void plat_video_menu_begin(void)\r
+{\r
+ memcpy32(g_screen_ptr, g_menubg_ptr, g_screen_width * g_screen_height * 2 / 4);\r
+}\r
+\r
+void plat_video_menu_end(void)\r
+{\r
+ update_screen();\r
+}\r
+\r
+void plat_status_msg_clear(void)\r
+{\r
+ unsigned short *d = (unsigned short *)g_screen_ptr + g_screen_width * g_screen_height;\r
+ int l = g_screen_width * 8;\r
+ memset32((int *)(d - l), 0, l * 2 / 4);\r
+}\r
+\r
+void plat_status_msg_busy_next(const char *msg)\r
+{\r
+ plat_status_msg_clear();\r
+ pemu_update_display("", msg);\r
+ emu_status_msg("");\r
+ reset_timing = 1;\r
+}\r
+\r
+void plat_status_msg_busy_first(const char *msg)\r
+{\r
+// memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
+ plat_status_msg_busy_next(msg);\r
+}\r
+\r
+void plat_update_volume(int has_changed, int is_up)\r
+{\r
+}\r
+\r
+void pemu_forced_frame(int opts)\r
+{\r
+ int po_old = PicoOpt;\r
+ int eo_old = currentConfig.EmuOpt;\r
+\r
+ PicoOpt &= ~POPT_ALT_RENDERER;\r
+ PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites\r
+ currentConfig.EmuOpt |= EOPT_16BPP;\r
+\r
+ PicoDrawSetColorFormat(1);\r
+ PicoScanBegin = EmuScanBegin16;\r
+\r
+ Pico.m.dirtyPal = 1;\r
+ PicoFrameDrawOnly();\r
+\r
+ PicoOpt = po_old;\r
+ currentConfig.EmuOpt = eo_old;\r
+}\r
+\r
+static void updateSound(int len)\r
+{\r
+ len <<= 1;\r
+ if (PicoOpt & POPT_EN_STEREO)\r
+ len <<= 1;\r
+\r
+ if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))\r
+ return;\r
+\r
+ /* avoid writing audio when lagging behind to prevent audio lag */\r
+ if (PicoSkipFrame != 2)\r
+ sndout_oss_write(PsndOut, len);\r
+}\r
+\r
+void pemu_sound_start(void)\r
+{\r
+ static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;\r
+ int target_fps = Pico.m.pal ? 50 : 60;\r
+\r
+ PsndOut = NULL;\r
+\r
+ if (currentConfig.EmuOpt & EOPT_EN_SOUND)\r
+ {\r
+ int snd_excess_add;\r
+ if (PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old)\r
+ PsndRerate(Pico.m.frame_count ? 1 : 0);\r
+\r
+ snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;\r
+ printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",\r
+ PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal);\r
+ sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);\r
+ sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
+ PicoWriteSound = updateSound;\r
+ plat_update_volume(0, 0);\r
+ memset(sndBuffer, 0, sizeof(sndBuffer));\r
+ PsndOut = sndBuffer;\r
+ PsndRate_old = PsndRate;\r
+ PicoOpt_old = PicoOpt;\r
+ pal_old = Pico.m.pal;\r
+ }\r
+}\r
+\r
+void pemu_sound_stop(void)\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 plat_debug_cat(char *str)\r
+{\r
+}\r
+\r
+void emu_video_mode_change(int start_line, int line_count, int is_32cols)\r
+{\r
+ osd_fps_x = 260;\r
+\r
+ // clear whole screen in all buffers\r
+ memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
+}\r
+\r
+void pemu_loop_prep(void)\r
+{\r
+ PicoDrawSetColorFormat(1);\r
+ PicoScanBegin = EmuScanBegin16;\r
+ osd_text = osd_text16;\r
+\r
+ pemu_sound_start();\r
+}\r
+\r
+void pemu_loop_end(void)\r
+{\r
+ int po_old = PicoOpt;\r
+ int eo_old = currentConfig.EmuOpt;\r
+\r
+ pemu_sound_stop();\r
+ memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
+\r
+ /* do one more frame for menu bg */\r
+ PicoOpt &= ~POPT_ALT_RENDERER;\r
+ PicoOpt |= POPT_EN_SOFTSCALE|POPT_ACC_SPRITES;\r
+ currentConfig.EmuOpt |= EOPT_16BPP;\r
+\r
+ PicoDrawSetColorFormat(1);\r
+ Pico.m.dirtyPal = 1;\r
+ PicoFrame();\r
+\r
+ PicoOpt = po_old;\r
+ currentConfig.EmuOpt = eo_old;\r
+}\r
+\r
+void plat_wait_till_us(unsigned int us_to)\r
+{\r
+ unsigned int now;\r
+\r
+ now = plat_get_ticks_us();\r
+\r
+ while ((signed int)(us_to - now) > 512)\r
+ {\r
+ usleep(1024);\r
+ now = plat_get_ticks_us();\r
+ }\r
+}\r
+\r
+void plat_video_wait_vsync(void)\r
+{\r
+}\r
+\r
+const char *plat_get_credits(void)\r
+{\r
+ return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n"\r
+ "Credits:\n"\r
+ "fDave: Cyclone 68000 core,\n"\r
+ " base code of PicoDrive\n"\r
+ "Reesy & FluBBa: DrZ80 core\n"\r
+ "MAME devs: YM2612 and SN76496 cores\n"\r
+ "rlyeh and others: minimal SDK\n"\r
+ "Squidge: mmuhack\n"\r
+ "Dzz: ARM940 sample\n"\r
+ "GnoStiC / Puck2099: USB joy code\n"\r
+ "craigix: GP2X hardware\n"\r
+ "ketchupgun: skin design\n"\r
+ "\n"\r
+ "special thanks (for docs, ideas):\n"\r
+ " Charles MacDonald, Haze,\n"\r
+ " Stephane Dallongeville,\n"\r
+ " Lordus, Exophase, Rokas,\n"\r
+ " Nemesis, Tasco Deluxe";\r
+}\r
-/* faking/emulating gp2x by using xlib */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <errno.h>
-#include "../gp2x/version.h"
#include "../common/emu.h"
#include "../common/menu.h"
-#include "../common/readpng.h"
#include "sndout_oss.h"
+#include "version.h"
#include "log_io.h"
unsigned long current_keys = 0;
-static int current_bpp = 8;
+static int current_bpp = 16;
static int current_pal[256];
static const char *verstring = "PicoDrive " VERSION;
static int scr_changed = 0, scr_w = SCREEN_WIDTH, scr_h = SCREEN_HEIGHT;
-void *gp2x_screens[4];
-
-// dummies
-int mix_32_to_16l_level;
-int crashed_940 = 0;
-int default_cpu_clock = 123;
-void *gp2x_memregs = NULL;
/* ifndef is for qemu build without video out */
#ifndef ARM
static void realloc_screen(void)
{
void *old = g_screen_ptr;
- int i;
g_screen_width = scr_w;
g_screen_height = scr_h;
g_screen_ptr = calloc(g_screen_width * g_screen_height * 2, 1);
free(old);
scr_changed = 0;
-
- for (i = 0; i < 4; i++)
- gp2x_screens[i] = g_screen_ptr;
}
-/* gp2x/emu.c stuff, most to be rm'd */
-static void gp2x_video_flip_(void)
+void update_screen(void)
{
#ifndef ARM
unsigned int *image;
#endif
}
-static void gp2x_video_changemode_ll_(int bpp)
-{
- current_bpp = bpp;
-}
-
-static void gp2x_video_setpalette_(int *pal, int len)
-{
- memcpy(current_pal, pal, len*4);
-}
-
-void gp2x_memcpy_all_buffers(void *data, int offset, int len)
-{
-}
-
-void gp2x_memset_all_buffers(int offset, int byte, int len)
-{
- memset((char *)g_screen_ptr + offset, byte, len);
-}
-
-void gp2x_video_changemode(int bpp)
-{
- gp2x_video_changemode_ll_(bpp);
-}
-
-void gp2x_make_fb_bufferable(int yes)
-{
-}
-
-int soc_detect(void)
-{
- return 0;
-}
-
-/* plat */
-static char menu_bg_buffer[320*240*2];
-char cpu_clk_name[16] = "GP2X CPU clocks";
-
-void plat_video_menu_enter(int is_rom_loaded)
-{
- if (is_rom_loaded)
- {
- // darken the active framebuffer
- memset(g_screen_ptr, 0, 320*8*2);
- menu_darken_bg((char *)g_screen_ptr + 320*8*2, 320*224, 1);
- memset((char *)g_screen_ptr + 320*232*2, 0, 320*8*2);
- }
- else
- {
- char buff[256];
-
- // should really only happen once, on startup..
- emu_make_path(buff, "skin/background.png", sizeof(buff));
- if (readpng(g_screen_ptr, buff, READPNG_BG) < 0)
- memset(g_screen_ptr, 0, 320*240*2);
- }
-
- memcpy(menu_bg_buffer, g_screen_ptr, 320*240*2);
-
- // switch to 16bpp
- gp2x_video_changemode_ll_(16);
- gp2x_video_flip_();
-}
-
-void plat_video_menu_begin(void)
-{
- memcpy(g_screen_ptr, menu_bg_buffer, 320*240*2);
-}
-
-void plat_video_menu_end(void)
-{
- gp2x_video_flip_();
-}
-
-void plat_validate_config(void)
-{
- extern int PicoOpt;
-// PicoOpt &= ~POPT_EXT_FM;
- PicoOpt &= ~(1<<17); // POPT_EN_SVP_DRC
-}
-
void plat_early_init(void)
{
}
sndout_oss_exit();
}
-/* nasty */
-static void do_nothing()
-{
-}
-
-void *gp2x_video_flip = gp2x_video_flip_;
-void *gp2x_video_flip2 = gp2x_video_flip_;
-void *gp2x_video_changemode_ll = gp2x_video_changemode_ll_;
-void *gp2x_video_setpalette = gp2x_video_setpalette_;
-
-void *gp2x_video_RGB_setscaling = do_nothing;
-void *gp2x_video_wait_vsync = do_nothing;
-void *gp2x_set_cpuclk = do_nothing;
-void *gp2x_read_battery = do_nothing;
-void *set_lcd_custom_rate = do_nothing;
-void *unset_lcd_custom_rate = do_nothing;
-void *set_lcd_gamma = do_nothing;
-void *set_ram_timings = do_nothing;
-void *unset_ram_timings = do_nothing;
-
-/* joy */
-int gp2x_touchpad_read(int *x, int *y)
-{
- return -1;
-}
-
/* misc */
-void spend_cycles(int c)
-{
- usleep(c/200);
-}
-
int mp3_get_bitrate(FILE *f, int size)
{
return 128;
{
}
-void cache_flush_d_inval_i()
-{
-}
-
/* lprintf */
void lprintf(const char *fmt, ...)
{
#include <stdio.h>
+#include <string.h>
#include <dirent.h>
#include <sys/time.h>
#include <time.h>
return 0;
}
+int plat_get_root_dir(char *dst, int len)
+{
+ extern char **g_argv;
+ int j;
+
+ strncpy(dst, g_argv[0], len);
+ len -= 32; // reserve
+ if (len < 0) len = 0;
+ dst[len] = 0;
+ for (j = strlen(dst); j > 0; j--)
+ if (dst[j] == '/') { dst[j+1] = 0; break; }
+
+ return j + 1;
+}
+
#ifdef __GP2X__
/* Wiz has a borked gettimeofday().. */
#define plat_get_ticks_ms plat_get_ticks_ms_good
#export CROSS = arm-none-linux-gnueabi-\r
+CROSS ?= $(CROSS_COMPILE)\r
LIBROOT = /home/notaz/dev/pnd/libroot\r
\r
# settings\r
-#mz80 = 1\r
-#cz80 = 1\r
-#debug_cyclone = 1\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
-amalgamate = 0\r
#profile = 1\r
-#use_musashi = 1\r
-#use_famec = 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_memory = 0\r
asm_cdmemory = 0\r
-else\r
-use_cyclone = 1\r
endif\r
\r
-DEFINC = -I../.. -I. -DARM -DPANDORA -DIN_EVDEV\r
-COPT_COMMON = -Wall -Winline -mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a -I$(LIBROOT)/include\r
+ARCH = arm\r
+DEFINES += ARM PANDORA IN_EVDEV\r
+CFLAGS += -I../.. -I. -I$(LIBROOT)/include\r
+CFLAGS += -Wall -Winline -mcpu=cortex-a8 -mtune=cortex-a8 -march=armv7-a\r
ifeq ($(DEBUG),)\r
-COPT_COMMON += -O2 # -ftracer -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math\r
-else\r
-COPT_COMMON += -ggdb\r
-endif\r
-ifeq "$(profile)" "1"\r
-COPT_COMMON += -fprofile-generate\r
-endif\r
-ifeq "$(profile)" "2"\r
-COPT_COMMON += -fprofile-use\r
+CFLAGS += -O2 -fomit-frame-pointer -fstrict-aliasing -ffast-math\r
endif\r
-CFLAGS = $(COPT_COMMON)\r
-SFLAGS = $(CFLAGS)\r
+LDFLAGS += -lm -lpng -L$(LIBROOT)/lib -static\r
ASFLAGS = -mcpu=cortex-a8\r
CC = $(CROSS)gcc\r
STRIP = $(CROSS)strip\r
OBJCOPY = $(CROSS)objcopy\r
\r
# frontend\r
-OBJS += pandora.o emu.o asm_utils.o plat.o\r
+OBJS += pandora.o emu.o asm_utils.o\r
\r
# common\r
OBJS += platform/common/emu.o platform/common/menu.o platform/common/fonts.o platform/common/config.o \\r
platform/common/readpng.o platform/common/input.o platform/common/main.o \\r
platform/linux/in_evdev.o platform/linux/sndout_oss.o platform/linux/plat.o\r
\r
-# Pico\r
-ifeq "$(amalgamate)" "1"\r
-OBJS += ../../picoAll.o\r
-else\r
-OBJS += pico/area.o pico/cart.o pico/memory.o pico/misc.o pico/pico.o pico/sek.o \\r
- pico/videoport.o pico/draw2.o pico/draw.o pico/patch.o pico/debug.o\r
-# Pico - CD\r
-OBJS += pico/cd/pico.o pico/cd/memory.o pico/cd/sek.o pico/cd/LC89510.o \\r
- pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \\r
- pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o\r
-endif\r
-# Pico - Pico\r
-OBJS += pico/pico/pico.o pico/pico/memory.o pico/pico/xpcm.o\r
-# Pico - carthw\r
-OBJS += pico/carthw/carthw.o pico/carthw/svp/svp.o pico/carthw/svp/memory.o \\r
- pico/carthw/svp/ssp16.o pico/carthw/svp/compiler.o pico/carthw/svp/stub_arm.o\r
-\r
-# Pico - sound\r
-ifneq "$(amalgamate)" "1"\r
-OBJS += pico/sound/sound.o\r
-endif\r
+# ARM stuff\r
+OBJS += pico/carthw/svp/compiler.o pico/carthw/svp/stub_arm.o\r
OBJS += pico/sound/mix_arm.o\r
-OBJS += pico/sound/sn76496.o pico/sound/ym2612.o\r
+\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
# unzip\r
OBJS += unzip/unzip.o unzip/unzip_stream.o\r
-# debug\r
-ifeq "$(debug_cyclone)" "1"\r
-OBJS += pico/DebugCPU.o cpu/musashi/m68kdasm.o\r
-endif\r
-# CPU cores\r
-ifeq "$(use_musashi)" "1"\r
-DEFINC += -DEMU_M68K\r
-OBJS += cpu/musashi/m68kops.o cpu/musashi/m68kcpu.o\r
-endif\r
-ifeq "$(use_cyclone)" "1"\r
-DEFINC += -DEMU_C68K\r
-OBJS += cpu/Cyclone/proj/Cyclone.o cpu/Cyclone/tools/idle.o\r
-endif\r
-ifeq "$(use_famec)" "1"\r
-DEFINC += -DEMU_F68K\r
-OBJS += cpu/fame/famec.o\r
-endif\r
-# drz80/mz80\r
-ifeq "$(mz80)" "1"\r
-DEFINC += -D_USE_MZ80\r
-OBJS += cpu/mz80/mz80.o\r
-else\r
-ifeq "$(cz80)" "1"\r
-DEFINC += -D_USE_CZ80\r
-OBJS += cpu/cz80/cz80.o\r
-else\r
-DEFINC += -D_USE_DRZ80\r
-OBJS += cpu/DrZ80/drz80.o\r
-endif\r
-endif\r
\r
vpath %.c = ../..\r
vpath %.s = ../..\r
vpath %.S = ../..\r
-DIRS = platform platform/gp2x platform/linux platform/common pico pico/cd pico/pico pico/sound pico/carthw/svp \\r
- zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools cpu/mz80 cpu/DrZ80\r
-\r
+DIRS += platform/linux zlib unzip\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
PicoDrive : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a\r
@echo ">>>" $@\r
- $(CC) -o $@ $(CFLAGS) $^ -lm -Wl,-Map=PicoDrive.map -lpng -L$(LIBROOT)/lib -static\r
+ $(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS) -Wl,-Map=PicoDrive.map\r
ifeq ($(DEBUG),)\r
$(STRIP) $@\r
endif\r
// For commercial use, separate licencing terms must be obtained.\r
\r
#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <sys/time.h>\r
-#include <stdarg.h>\r
\r
-#include "../common/arm_utils.h"\r
-#include "../common/fonts.h"\r
#include "../common/emu.h"\r
#include "../common/menu.h"\r
-#include "../common/config.h"\r
-#include "../common/input.h"\r
+#include "../common/plat.h"\r
+#include "../common/arm_utils.h"\r
#include "../linux/sndout_oss.h"\r
#include "asm_utils.h"\r
+#include "version.h"\r
\r
#include <pico/pico_int.h>\r
-#include <pico/patch.h>\r
-#include <pico/sound/mix.h>\r
-#include <zlib/zlib.h>\r
-\r
-//#define PFRAMES\r
-#define BENCHMARK\r
-//#define USE_320_SCREEN 1\r
\r
-#ifdef BENCHMARK\r
-#define OSD_FPS_X (800-200)\r
-#else\r
-#define OSD_FPS_X (800-120)\r
-#endif\r
+#define USE_320_SCREEN 1\r
\r
\r
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
+static unsigned char temp_frame[g_screen_width * g_screen_height * 2];\r
+unsigned char *PicoDraw2FB = temp_frame;\r
static int osd_fps_x;\r
-unsigned char *PicoDraw2FB = NULL; // temporary buffer for alt renderer\r
-\r
-#define PICO_PEN_ADJUST_X 4\r
-#define PICO_PEN_ADJUST_Y 2\r
-static int pico_pen_x = 0, pico_pen_y = 240/2;\r
-\r
-\r
-int plat_get_root_dir(char *dst, int len)\r
-{\r
- extern char **g_argv;\r
- int j;\r
+char cpu_clk_name[] = "unused";\r
\r
- strncpy(dst, g_argv[0], len);\r
- len -= 32; // reserve\r
- if (len < 0) len = 0;\r
- dst[len] = 0;\r
- for (j = strlen(dst); j > 0; j--)\r
- if (dst[j] == '/') { dst[j+1] = 0; break; }\r
-\r
- return j + 1;\r
-}\r
\r
void pemu_prep_defconfig(void)\r
{\r
- memset(&defaultConfig, 0, sizeof(defaultConfig));\r
- defaultConfig.EmuOpt = 0x8f | 0x00600; // | <- confirm_save, cd_leds\r
- defaultConfig.s_PicoOpt = 0x0f | POPT_EXT_FM|POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC;\r
- defaultConfig.s_PicoOpt |= POPT_ACC_SPRITES|POPT_EN_MCD_GFX;\r
- defaultConfig.EmuOpt &= ~8; // no save gzip\r
- defaultConfig.s_PsndRate = 44100;\r
- defaultConfig.s_PicoRegion = 0;\r
- defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP\r
- defaultConfig.s_PicoCDBuffers = 0;\r
- defaultConfig.Frameskip = 0;\r
- defaultConfig.CPUclock = 200;\r
- defaultConfig.volume = 50;\r
- defaultConfig.scaling = 0;\r
- defaultConfig.turbo_rate = 15;\r
+ // XXX: move elsewhere\r
+ g_menubg_ptr = temp_frame;\r
}\r
\r
-static void textOut16(int x, int y, const char *text)\r
+void pemu_validate_config(void)\r
{\r
- int i,l,len=strlen(text);\r
- unsigned int *screen = (unsigned int *)((unsigned short *)g_screen_ptr + (x&~1) + y*g_screen_width);\r
-\r
- for (i = 0; i < len; i++)\r
- {\r
- for (l=0;l<16;)\r
- {\r
- unsigned char fd = fontdata8x8[((text[i])*8)+l/2];\r
- unsigned int *d = &screen[l*g_screen_width/2];\r
- if (fd&0x80) d[0]=0xffffffff;\r
- if (fd&0x40) d[1]=0xffffffff;\r
- if (fd&0x20) d[2]=0xffffffff;\r
- if (fd&0x10) d[3]=0xffffffff;\r
- if (fd&0x08) d[4]=0xffffffff;\r
- if (fd&0x04) d[5]=0xffffffff;\r
- if (fd&0x02) d[6]=0xffffffff;\r
- if (fd&0x01) d[7]=0xffffffff;\r
- l++; d = &screen[l*g_screen_width/2];\r
- if (fd&0x80) d[0]=0xffffffff;\r
- if (fd&0x40) d[1]=0xffffffff;\r
- if (fd&0x20) d[2]=0xffffffff;\r
- if (fd&0x10) d[3]=0xffffffff;\r
- if (fd&0x08) d[4]=0xffffffff;\r
- if (fd&0x04) d[5]=0xffffffff;\r
- if (fd&0x02) d[6]=0xffffffff;\r
- if (fd&0x01) d[7]=0xffffffff;\r
- l++;\r
- }\r
- screen += 8;\r
- }\r
}\r
\r
-\r
+// FIXME: cleanup\r
static void osd_text(int x, int y, const char *text)\r
{\r
int len = strlen(text)*8;\r
}\r
}\r
\r
-static void draw_pico_ptr(void)\r
-{\r
- unsigned short *p = (unsigned short *)g_screen_ptr;\r
-\r
- // only if pen enabled and for 16bit modes\r
- if (pico_inp_mode == 0 || (PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) return;\r
-\r
- if (!(Pico.video.reg[12]&1) && !(PicoOpt&POPT_DIS_32C_BORDER))\r
- p += 32;\r
-\r
- p += g_screen_width * (pico_pen_y + PICO_PEN_ADJUST_Y);\r
- p += pico_pen_x + PICO_PEN_ADJUST_X;\r
- p[0] ^= 0xffff;\r
- p[319] ^= 0xffff;\r
- p[320] ^= 0xffff;\r
- p[321] ^= 0xffff;\r
- p[640] ^= 0xffff;\r
-}\r
-\r
#ifdef USE_320_SCREEN\r
\r
static int EmuScanBegin16(unsigned int num)\r
\r
#endif // USE_320_SCREEN\r
\r
-int localPal[0x100];\r
-static void (*vidCpyM2)(void *dest, void *src) = NULL;\r
-\r
-static void blit(const char *fps, const char *notice)\r
+void pemu_update_display(const char *fps, const char *notice)\r
{\r
- int emu_opt = currentConfig.EmuOpt;\r
-\r
- if (PicoOpt&0x10)\r
- {\r
- // 8bit fast renderer\r
- if (Pico.m.dirtyPal) {\r
- Pico.m.dirtyPal = 0;\r
- vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
- // feed new palette to our device\r
- // gp2x_video_setpalette(localPal, 0x40);\r
- }\r
- // a hack for VR\r
- if (PicoAHW & PAHW_SVP)\r
- memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328);\r
- // do actual copy\r
- vidCpyM2((unsigned char *)g_screen_ptr+g_screen_width*8, PicoDraw2FB+328*8);\r
- }\r
- else if (!(emu_opt&0x80))\r
- {\r
- // 8bit accurate renderer\r
- if (Pico.m.dirtyPal)\r
- {\r
- int pallen = 0xc0;\r
- Pico.m.dirtyPal = 0;\r
- if (Pico.video.reg[0xC]&8) // shadow/hilight mode\r
- {\r
- vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
- vidConvCpyRGB32sh(localPal+0x40, Pico.cram, 0x40);\r
- vidConvCpyRGB32hi(localPal+0x80, Pico.cram, 0x40);\r
- memcpy32(localPal+0xc0, localPal+0x40, 0x40);\r
- pallen = 0x100;\r
- }\r
- else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes\r
- vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
- vidConvCpyRGB32(localPal+0x40, HighPal, 0x40);\r
- vidConvCpyRGB32(localPal+0x80, HighPal+0x40, 0x40);\r
- pallen = 0xc0;\r
- }\r
- else {\r
- vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
- memcpy32(localPal+0x80, localPal, 0x40);\r
- }\r
- if (pallen > 0xc0) {\r
- localPal[0xc0] = 0x0000c000;\r
- localPal[0xd0] = 0x00c00000;\r
- localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
- localPal[0xf0] = 0x00ffffff;\r
- }\r
- // gp2x_video_setpalette(localPal, pallen);\r
- }\r
+ if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {\r
+ if (notice)\r
+ osd_text(4, 460, notice);\r
+ if (currentConfig.EmuOpt & EOPT_SHOW_FPS)\r
+ osd_text(osd_fps_x, 460, fps);\r
}\r
-\r
- if (notice || (emu_opt & 2)) {\r
- int h = g_screen_height-16;\r
- if (currentConfig.scaling == 2 && !(Pico.video.reg[1]&8)) h -= 16;\r
- if (notice) osd_text(4, h, notice);\r
- if (emu_opt & 2)\r
- osd_text(osd_fps_x, h, fps);\r
- }\r
- if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))\r
+ if ((PicoAHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS))\r
draw_cd_leds();\r
- if (PicoAHW & PAHW_PICO)\r
- draw_pico_ptr();\r
+}\r
\r
- //gp2x_video_wait_vsync();\r
- // gp2x_video_flip();\r
+void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu)\r
+{\r
+ // this will auto-select SMS/32X renderers\r
+ PicoDrawSetColorFormat(1);\r
}\r
\r
+void plat_video_menu_enter(int is_rom_loaded)\r
+{\r
+}\r
\r
-// clears whole screen or just the notice area (in all buffers)\r
-static void clearArea(int full)\r
+void plat_video_menu_begin(void)\r
{\r
- if (full) memset(g_screen_ptr, 0, g_screen_width*g_screen_height*2);\r
- else memset((short *)g_screen_ptr + g_screen_width * (g_screen_height - 16), 0,\r
- g_screen_width * 16 * 2);\r
+ memcpy32(g_screen_ptr, g_menubg_ptr, g_screen_width * g_screen_height * 2 / 4);\r
}\r
\r
+void plat_video_menu_end(void)\r
+{\r
+}\r
\r
-static void vidResetMode(void)\r
+void plat_status_msg_clear(void)\r
{\r
-#if 0\r
- if (PicoOpt&0x10) {\r
- gp2x_video_changemode(8);\r
- } else if (currentConfig.EmuOpt&0x80) {\r
- gp2x_video_changemode(16);\r
-#ifdef USE_320_SCREEN\r
- PicoDrawSetColorFormat(1);\r
- PicoScanBegin = EmuScanBegin16;\r
-#else\r
- PicoDrawSetColorFormat(-1);\r
- PicoScanEnd = EmuScanEnd16;\r
-#endif\r
- } else {\r
- gp2x_video_changemode(8);\r
- PicoDrawSetColorFormat(2);\r
- PicoScanBegin = EmuScanBegin8;\r
- }\r
- if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
- // setup pal for 8-bit modes\r
- localPal[0xc0] = 0x0000c000; // MCD LEDs\r
- localPal[0xd0] = 0x00c00000;\r
- localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
- localPal[0xf0] = 0x00ffffff;\r
- gp2x_video_setpalette(localPal, 0x100);\r
- gp2x_memset_all_buffers(0, 0xe0, 320*240);\r
- gp2x_video_flip();\r
- }\r
- Pico.m.dirtyPal = 1;\r
- // reset scaling\r
- if (currentConfig.scaling == 2 && !(Pico.video.reg[1]&8))\r
- gp2x_video_RGB_setscaling(8, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 224);\r
- else gp2x_video_RGB_setscaling(0, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 240);\r
-#else\r
-#ifdef USE_320_SCREEN\r
- PicoDrawSetColorFormat(1);\r
- PicoScanBegin = EmuScanBegin16;\r
-#else\r
- PicoDrawSetColorFormat(-1);\r
- PicoScanEnd = EmuScanEnd16;\r
-#endif\r
-#endif\r
+ unsigned short *d = (unsigned short *)g_screen_ptr + g_screen_width * g_screen_height;\r
+ int l = g_screen_width * 8;\r
+ memset32((int *)(d - l), 0, l * 2 / 4);\r
}\r
\r
+void plat_status_msg_busy_next(const char *msg)\r
+{\r
+ plat_status_msg_clear();\r
+ pemu_update_display("", msg);\r
+ emu_status_msg("");\r
+ reset_timing = 1;\r
+}\r
\r
-static void update_volume(int has_changed, int is_up)\r
+void plat_status_msg_busy_first(const char *msg)\r
+{\r
+// memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
+ plat_status_msg_busy_next(msg);\r
+}\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
\r
if (has_changed)\r
{\r
- if (vol < 5 && (PicoOpt&8) && 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
+ if (is_up) {\r
+ if (vol < 99) vol++;\r
+ } else {\r
+ if (vol > 0) vol--;\r
}\r
- sprintf(noticeMsg, "VOL: %02i", vol);\r
- gettimeofday(¬iceMsgTime, 0);\r
+ wait_frames = 0;\r
+ sndout_oss_setvol(vol, vol);\r
+ currentConfig.volume = vol;\r
+ emu_status_msg("VOL: %02i", vol);\r
prev_frame = Pico.m.frame_count;\r
}\r
-\r
- // set the right mixer func\r
- if (!(PicoOpt&8)) return; // just use defaults for mono\r
- if (vol >= 5)\r
- PsndMix_32_to_16l = mix_32_to_16l_stereo;\r
- else {\r
- mix_32_to_16l_level = 5 - vol;\r
- PsndMix_32_to_16l = mix_32_to_16l_stereo_lvl;\r
- }\r
-}\r
-\r
-\r
-static void updateSound(int len)\r
-{\r
- if (PicoOpt&8) len<<=1;\r
-\r
- /* avoid writing audio when lagging behind to prevent audio lag */\r
- if (PicoSkipFrame != 2)\r
- sndout_oss_write(PsndOut, len<<1);\r
}\r
\r
-\r
-static void SkipFrame(int do_audio)\r
-{\r
- PicoSkipFrame=do_audio ? 1 : 2;\r
- PicoFrame();\r
- PicoSkipFrame=0;\r
-}\r
-\r
-\r
void pemu_forced_frame(int opts)\r
{\r
int po_old = PicoOpt;\r
PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites\r
currentConfig.EmuOpt |= 0x80;\r
\r
- //vidResetMode();\r
#ifdef USE_320_SCREEN\r
PicoDrawSetColorFormat(1);\r
PicoScanBegin = EmuScanBegin16;\r
Pico.m.dirtyPal = 1;\r
PicoFrameDrawOnly();\r
\r
-/*\r
- if (!(Pico.video.reg[12]&1)) {\r
- vidCpyM2 = vidCpyM2_32col;\r
- clearArea(1);\r
- } else vidCpyM2 = vidCpyM2_40col;\r
-\r
- vidCpyM2((unsigned char *)g_screen_ptr+g_screen_width*8, PicoDraw2FB+328*8);\r
- vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
- gp2x_video_setpalette(localPal, 0x40);\r
-*/\r
PicoOpt = po_old;\r
currentConfig.EmuOpt = eo_old;\r
}\r
\r
-void plat_debug_cat(char *str)\r
-{\r
-}\r
-\r
-static void simpleWait(int thissec, int lim_time)\r
+static void updateSound(int len)\r
{\r
- struct timeval tval;\r
+ len <<= 1;\r
+ if (PicoOpt & POPT_EN_STEREO)\r
+ len <<= 1;\r
\r
- spend_cycles(1024);\r
- gettimeofday(&tval, 0);\r
- if (thissec != tval.tv_sec) tval.tv_usec+=1000000;\r
+ if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && !sndout_oss_can_write(len))\r
+ return;\r
\r
- while (tval.tv_usec < lim_time)\r
- {\r
- spend_cycles(1024);\r
- gettimeofday(&tval, 0);\r
- if (thissec != tval.tv_sec) tval.tv_usec+=1000000;\r
- }\r
+ /* avoid writing audio when lagging behind to prevent audio lag */\r
+ if (PicoSkipFrame != 2)\r
+ sndout_oss_write(PsndOut, len);\r
}\r
\r
void pemu_sound_start(void)\r
sndout_oss_start(PsndRate, 16, (PicoOpt&8)>>3);\r
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
PicoWriteSound = updateSound;\r
- update_volume(0, 0);\r
+ plat_update_volume(0, 0);\r
memset(sndBuffer, 0, sizeof(sndBuffer));\r
PsndOut = sndBuffer;\r
PsndRate_old = PsndRate;\r
// don't need to do anything, writes will block by themselves\r
}\r
\r
-void pemu_loop(void)\r
+void plat_debug_cat(char *str)\r
{\r
- char fpsbuff[24]; // fps count c string\r
- struct timeval tval; // timing\r
- int pframes_done, pframes_shown, pthissec; // "period" frames, used for sync\r
- int frames_done, frames_shown, thissec; // actual frames\r
- int oldmodes = 0, target_fps, target_frametime, lim_time, vsync_offset, i;\r
- char *notice = 0;\r
-\r
- printf("entered emu_Loop()\n");\r
-\r
- fpsbuff[0] = 0;\r
-\r
- // make sure we are in correct mode\r
- vidResetMode();\r
- Pico.m.dirtyPal = 1;\r
- oldmodes = ((Pico.video.reg[12]&1)<<2) ^ 0xc;\r
-\r
- // pal/ntsc might have changed, reset related stuff\r
- target_fps = Pico.m.pal ? 50 : 60;\r
- target_frametime = 1000000/target_fps;\r
- reset_timing = 1;\r
-\r
- pemu_sound_start();\r
-\r
- // prepare CD buffer\r
- if (PicoAHW & PAHW_MCD) PicoCDBufferInit();\r
-\r
- // calc vsync offset to sync timing code with vsync\r
- if (currentConfig.EmuOpt&0x2000) {\r
- gettimeofday(&tval, 0);\r
- //gp2x_video_wait_vsync();\r
- gettimeofday(&tval, 0);\r
- vsync_offset = tval.tv_usec;\r
- while (vsync_offset >= target_frametime)\r
- vsync_offset -= target_frametime;\r
- if (!vsync_offset) vsync_offset++;\r
- printf("vsync_offset: %i\n", vsync_offset);\r
- } else\r
- vsync_offset = 0;\r
-\r
- frames_done = frames_shown = thissec =\r
- pframes_done = pframes_shown = pthissec = 0;\r
-\r
- // loop\r
- while (engineState == PGS_Running)\r
- {\r
- int modes;\r
-\r
- gettimeofday(&tval, 0);\r
- if (reset_timing) {\r
- reset_timing = 0;\r
- pthissec = tval.tv_sec;\r
- pframes_shown = pframes_done = tval.tv_usec/target_frametime;\r
- }\r
+}\r
\r
- // show notice message?\r
- if (noticeMsgTime.tv_sec)\r
- {\r
- static int noticeMsgSum;\r
- if((tval.tv_sec*1000000+tval.tv_usec) - (noticeMsgTime.tv_sec*1000000+noticeMsgTime.tv_usec) > 2000000) { // > 2.0 sec\r
- noticeMsgTime.tv_sec = noticeMsgTime.tv_usec = 0;\r
- clearArea(0);\r
- notice = 0;\r
- } else {\r
- int sum = noticeMsg[0]+noticeMsg[1]+noticeMsg[2];\r
- if (sum != noticeMsgSum) { clearArea(0); noticeMsgSum = sum; }\r
- notice = noticeMsg;\r
- }\r
- }\r
+void emu_video_mode_change(int start_line, int line_count, int is_32cols)\r
+{\r
+ osd_fps_x = 260;\r
\r
- // check for mode changes\r
- modes = ((Pico.video.reg[12]&1)<<2)|(Pico.video.reg[1]&8);\r
- if (modes != oldmodes)\r
- {\r
- int scalex = g_screen_width;\r
- osd_fps_x = OSD_FPS_X;\r
- if (modes & 4) {\r
- vidCpyM2 = vidCpyM2_40col;\r
- } else {\r
- if (PicoOpt & 0x100) {\r
- vidCpyM2 = vidCpyM2_32col_nobord;\r
- scalex = 256;\r
- osd_fps_x = OSD_FPS_X - 64;\r
- } else {\r
- vidCpyM2 = vidCpyM2_32col;\r
- }\r
- }\r
- //if (currentConfig.scaling == 2 && !(modes&8)) // want vertical scaling and game is not in 240 line mode\r
- // gp2x_video_RGB_setscaling(8, scalex, 224);\r
- // else gp2x_video_RGB_setscaling(0, scalex, 240);\r
- oldmodes = modes;\r
- clearArea(1);\r
- }\r
+ // clear whole screen in all buffers\r
+ memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
+}\r
\r
- // second changed?\r
- if (thissec != tval.tv_sec)\r
- {\r
-#ifdef BENCHMARK\r
- static int bench = 0, bench_fps = 0, bench_fps_s = 0, bfp = 0, bf[4];\r
- if (++bench == 4) {\r
- bench = 0;\r
- bench_fps_s = bench_fps / 4;\r
- bf[bfp++ & 3] = bench_fps / 4;\r
- bench_fps = 0;\r
- }\r
- bench_fps += frames_shown;\r
- sprintf(fpsbuff, "%3i/%3i/%3i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2);\r
- printf("%s\n", fpsbuff);\r
+void pemu_loop_prep(void)\r
+{\r
+#ifdef USE_320_SCREEN\r
+ PicoDrawSetColorFormat(1);\r
+ PicoScanBegin = EmuScanBegin16;\r
#else\r
- if (currentConfig.EmuOpt & 2) {\r
- sprintf(fpsbuff, "%3i/%3i", frames_shown, frames_done);\r
- if (fpsbuff[5] == 0) { fpsbuff[5] = fpsbuff[6] = ' '; fpsbuff[7] = 0; }\r
- }\r
-#endif\r
- frames_shown = frames_done = 0;\r
- thissec = tval.tv_sec;\r
- }\r
-#ifdef PFRAMES\r
- sprintf(fpsbuff, "%i", Pico.m.frame_count);\r
+ PicoDrawSetColorFormat(-1);\r
+ PicoScanEnd = EmuScanEnd16;\r
#endif\r
\r
- if (pthissec != tval.tv_sec)\r
- {\r
- if (PsndOut == 0 && currentConfig.Frameskip >= 0) {\r
- pframes_done = pframes_shown = 0;\r
- } else {\r
- // it is quite common for this implementation to leave 1 fame unfinished\r
- // when second changes, but we don't want buffer to starve.\r
- if(PsndOut && pframes_done < target_fps && pframes_done > target_fps-5) {\r
- emu_update_input();\r
- SkipFrame(1); pframes_done++;\r
- }\r
-\r
- pframes_done -= target_fps; if (pframes_done < 0) pframes_done = 0;\r
- pframes_shown -= target_fps; if (pframes_shown < 0) pframes_shown = 0;\r
- if (pframes_shown > pframes_done) pframes_shown = pframes_done;\r
- }\r
- pthissec = tval.tv_sec;\r
- }\r
+ pemu_sound_start();\r
+}\r
\r
- lim_time = (pframes_done+1) * target_frametime + vsync_offset;\r
- if (currentConfig.Frameskip >= 0) // frameskip enabled\r
- {\r
- for(i = 0; i < currentConfig.Frameskip; i++) {\r
- emu_update_input();\r
- SkipFrame(1); pframes_done++; frames_done++;\r
- if (PsndOut && !reset_timing) { // do framelimitting if sound is enabled\r
- gettimeofday(&tval, 0);\r
- if (pthissec != tval.tv_sec) tval.tv_usec+=1000000;\r
- if (tval.tv_usec < lim_time) { // we are too fast\r
- simpleWait(pthissec, lim_time);\r
- }\r
- }\r
- lim_time += target_frametime;\r
- }\r
- }\r
- else if (tval.tv_usec > lim_time) // auto frameskip\r
- {\r
- // no time left for this frame - skip\r
- if (tval.tv_usec - lim_time >= 300000) {\r
- /* something caused a slowdown for us (disk access? cache flush?)\r
- * try to recover by resetting timing... */\r
- reset_timing = 1;\r
- continue;\r
- }\r
- emu_update_input();\r
- SkipFrame(tval.tv_usec < lim_time+target_frametime*2); pframes_done++; frames_done++;\r
- continue;\r
- }\r
+void pemu_loop_end(void)\r
+{\r
+ int po_old = PicoOpt;\r
+ int eo_old = currentConfig.EmuOpt;\r
\r
- emu_update_input();\r
- PicoFrame();\r
+ pemu_sound_stop();\r
+ memset32(g_screen_ptr, 0, g_screen_width * g_screen_height * 2 / 4);\r
\r
- // check time\r
- gettimeofday(&tval, 0);\r
- if (pthissec != tval.tv_sec) tval.tv_usec+=1000000;\r
+ /* do one more frame for menu bg */\r
+ PicoOpt &= ~POPT_ALT_RENDERER;\r
+ PicoOpt |= POPT_EN_SOFTSCALE|POPT_ACC_SPRITES;\r
+ currentConfig.EmuOpt |= EOPT_16BPP;\r
\r
- if (currentConfig.Frameskip < 0 && tval.tv_usec - lim_time >= 300000) // slowdown detection\r
- reset_timing = 1;\r
-#if 1\r
- else if (PsndOut != NULL || currentConfig.Frameskip < 0)\r
- {\r
- // sleep or vsync if we are still too fast\r
- // usleep sleeps for ~20ms minimum, so it is not a solution here\r
- if (!reset_timing && tval.tv_usec < lim_time)\r
- {\r
- // we are too fast\r
- if (vsync_offset) {\r
- if (lim_time - tval.tv_usec > target_frametime/2)\r
- simpleWait(pthissec, lim_time - target_frametime/4);\r
- // gp2x_video_wait_vsync();\r
- } else {\r
- simpleWait(pthissec, lim_time);\r
- }\r
- }\r
- }\r
-#endif\r
- blit(fpsbuff, notice);\r
+ PicoDrawSetColorFormat(1);\r
+ Pico.m.dirtyPal = 1;\r
+ PicoFrame();\r
\r
- pframes_done++; pframes_shown++;\r
- frames_done++; frames_shown++;\r
- }\r
+ PicoOpt = po_old;\r
+ currentConfig.EmuOpt = eo_old;\r
+}\r
\r
- emu_set_fastforward(0);\r
+/* XXX: avoid busy wait somehow? */\r
+void plat_wait_till_us(unsigned int us_to)\r
+{\r
+ unsigned int now;\r
\r
- if (PicoAHW & PAHW_MCD) PicoCDBufferFree();\r
+ spend_cycles(1024);\r
+ now = plat_get_ticks_us();\r
\r
- // save SRAM\r
- if ((currentConfig.EmuOpt & EOPT_EN_SRAM) && SRam.changed) {\r
- /* FIXME: plat_status_msg_busy_first */\r
- emu_state_cb("Writing SRAM/BRAM..");\r
- emu_save_load_game(0, 1);\r
- SRam.changed = 0;\r
+ while ((signed int)(us_to - now) > 512)\r
+ {\r
+ spend_cycles(1024);\r
+ now = plat_get_ticks_us();\r
}\r
+}\r
\r
- // if in 8bit mode, generate 16bit image for menu background\r
- if ((PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80))\r
- pemu_forced_frame(POPT_EN_SOFTSCALE);\r
+void plat_video_wait_vsync(void)\r
+{\r
}\r
\r
+const char *plat_get_credits(void)\r
+{\r
+ return "PicoDrive v" VERSION " (c) notaz, 2006-2009\n\n\n"\r
+ "Credits:\n"\r
+ "fDave: Cyclone 68000 core,\n"\r
+ " base code of PicoDrive\n"\r
+ "Reesy & FluBBa: DrZ80 core\n"\r
+ "MAME devs: YM2612 and SN76496 cores\n"\r
+ "rlyeh and others: minimal SDK\n"\r
+ "Squidge: mmuhack\n"\r
+ "Dzz: ARM940 sample\n"\r
+ "GnoStiC / Puck2099: USB joy code\n"\r
+ "craigix: GP2X hardware\n"\r
+ "ketchupgun: skin design\n"\r
+ "\n"\r
+ "special thanks (for docs, ideas):\n"\r
+ " Charles MacDonald, Haze,\n"\r
+ " Stephane Dallongeville,\n"\r
+ " Lordus, Exophase, Rokas,\n"\r
+ " Nemesis, Tasco Deluxe";\r
+}\r
#include "../linux/sndout_oss.h"\r
#include "../common/arm_linux.h"\r
#include "../common/emu.h"\r
-#include "pandora.h"\r
\r
static int fbdev = -1;\r
\r
#define SCREEN_MAP_SIZE (800*480*2)\r
static void *screen = MAP_FAILED;\r
\r
-/* common */\r
-void pnd_init(void)\r
+void plat_early_init(void)\r
+{\r
+}\r
+\r
+void plat_init(void)\r
{\r
printf("entering init()\n"); fflush(stdout);\r
\r
printf("exitting init()\n"); fflush(stdout);\r
}\r
\r
-void pnd_exit(void)\r
+void plat_finish(void)\r
{\r
if (screen != MAP_FAILED)\r
munmap(screen, SCREEN_MAP_SIZE);\r
va_end(vl);\r
}\r
\r
-\r
-/* fake GP2X */\r
-/*\r
-void set_gamma(int g100, int A_SNs_curve) {}\r
-void set_FCLK(unsigned MHZ) {}\r
-void set_LCD_custom_rate(int rate) {}\r
-void unset_LCD_custom_rate(void) {}\r
-void Pause940(int yes) {}\r
-void Reset940(int yes, int bank) {}\r
-*/\r
--- /dev/null
+#define VERSION "1.70"\r
+\r
void pemu_prep_defconfig(void)
{
- memset(&defaultConfig, 0, sizeof(defaultConfig));
- defaultConfig.EmuOpt = 0x1d | 0x680; // | <- confirm_save, cd_leds, acc rend
- defaultConfig.s_PicoOpt = 0x0f | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_MCD_GFX|POPT_ACC_SPRITES;
defaultConfig.s_PsndRate = 22050;
- defaultConfig.s_PicoRegion = 0; // auto
- defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP
defaultConfig.s_PicoCDBuffers = 64;
- defaultConfig.Frameskip = -1; // auto
defaultConfig.CPUclock = 333;
defaultConfig.KeyBinds[ 4] = 1<<0; // SACB RLDU
defaultConfig.KeyBinds[ 6] = 1<<1;
defaultConfig.scale = 1.20; // fullscreen
defaultConfig.hscale40 = 1.25;
defaultConfig.hscale32 = 1.56;
- defaultConfig.turbo_rate = 15;
}
#use_musashi = 1
use_fame = 1
-#use_mz80 = 1
+use_cz80 = 1
+use_sh2drc = 1
+#use_sh2mame = 1
-include Makefile.local
+ARCH ?= x86
CC = $(CROSS)gcc
CXX = $(CROSS)g++
LD = $(CROSS)ld
platform/common/config.o platform/common/fonts.o platform/common/readpng.o \
platform/common/input.o
-# Pico
-OBJS += pico/area.o pico/cart.o pico/memory.o pico/pico.o pico/sek.o \
- pico/videoport.o pico/draw2.o pico/draw.o pico/z80if.o pico/patch.o \
- pico/mode4.o pico/sms.o pico/misc.o pico/eeprom.o pico/debug.o
-# Pico - CD
-OBJS += pico/cd/pico.o pico/cd/memory.o pico/cd/sek.o pico/cd/LC89510.o \
- pico/cd/cd_sys.o pico/cd/cd_file.o pico/cd/cue.o pico/cd/gfx_cd.o \
- pico/cd/area.o pico/cd/misc.o pico/cd/pcm.o pico/cd/buffering.o
-# Pico - 32X
-OBJS += pico/32x/32x.o pico/32x/memory.o pico/32x/draw.o pico/32x/pwm.o
-# Pico - Pico
-OBJS += pico/pico/pico.o pico/pico/memory.o pico/pico/xpcm.o
-# Pico - sound
-OBJS += pico/sound/sound.o pico/sound/sn76496.o pico/sound/ym2612.o pico/sound/mix.o
-# Pico - carthw
-OBJS += pico/carthw/carthw.o pico/carthw/svp/svp.o pico/carthw/svp/memory.o \
- pico/carthw/svp/ssp16.o pico/carthw/svp/compiler.o
+OBJS += pico/carthw/svp/compiler.o
+OBJS += pico/sound/mix.o
# zlib
OBJS += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \
zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o zlib/uncompr.o
# unzip
OBJS += unzip/unzip.o unzip/unzip_stream.o
-# CPU cores
-ifeq "$(use_musashi)" "1"
-DEFINES += EMU_M68K
-OBJS += cpu/musashi/m68kops.o cpu/musashi/m68kcpu.o
-#OBJS += cpu/musashi/m68kdasm.o
-endif
-ifeq "$(use_fame)" "1"
-DEFINES += EMU_F68K
-OBJS += cpu/fame/famec.o
-endif
-# z80
-ifeq "$(use_mz80)" "1"
-DEFINES += _USE_MZ80
-OBJS += cpu/mz80/mz80.o
-else
-DEFINES += _USE_CZ80
-OBJS += cpu/cz80/cz80.o
-endif
-# sh2
-OBJS += cpu/sh2mame/sh2pico.o
-# misc
-ifeq "$(use_fame)" "1"
-ifeq "$(use_musashi)" "1"
-OBJS += pico/debugCPU.o
-endif
-endif
CFLAGS += $(addprefix -D,$(DEFINES))
CXXFLAGS = $(CFLAGS)
vpath %.c = ../..
-DIRS = platform platform/gp2x platform/common pico pico/cd pico/pico pico/sound pico/carthw/svp \
- pico/32x zlib unzip cpu cpu/musashi cpu/fame cpu/mz80 cpu/cz80 cpu/sh2mame
+DIRS += zlib unzip
TARGET = PicoDrive.exe
-
all: mkdirs $(TARGET)
+
+include ../common/common.mak
+include ../common/revision.mak
+
clean: tidy
@$(RM) $(TARGET)
tidy:
$(CC) $(CFLAGS) $^ $(LDFLAGS) -lm -lpng -Wl,-Map=$(TARGET).map -o $@
$(STRIP) $@
-mkdirs:
- @mkdir -p $(DIRS)
-
-include ../common/revision.mak
-
-pico/carthw/svp/compiler.o : ../../pico/carthw/svp/gen_arm.c
-pico/pico.o pico/cd/pico.o : ../../pico/pico_cmn.c ../../pico/pico_int.h
-pico/memory.o pico/cd/memory.o : ../../pico/pico_int.h ../../pico/memory.h
-
-../../cpu/musashi/m68kops.c :
- @make -C ../../cpu/musashi
-
-cpu/mz80/mz80.o : ../../cpu/mz80/mz80.asm
- @echo $@
- @nasm -f elf $< -o $@
-
-../../cpu/mz80/mz80.asm :
- @make -C ../../cpu/mz80/
-
-.c.o:
- @echo ">>>" $<
- $(CC) $(CFLAGS) -c $< -o $@
-.s.o:
- @echo ">>>" $<
- $(CC) $(CFLAGS) -c $< -o $@
-
-
-cpu/fame/famec.o : ../../cpu/fame/famec.c ../../cpu/fame/famec_opcodes.h
- @echo ">>>" $<
- $(CC) $(CFLAGS) -Wno-unused -c $< -o $@
-
# ----------- release -----------
ifneq ($(findstring rel,$(MAKECMDGOALS)),)
ifeq ($(VER),)
{\r
/* in_init() must go before config, config accesses in_ fwk */\r
in_init();\r
- pemu_prep_defconfig();\r
+ emu_prep_defconfig();\r
emu_read_config(0, 0);\r
config_readlrom(PicoConfigFile);\r
\r
void pemu_prep_defconfig(void)
{
memset(&defaultConfig, 0, sizeof(defaultConfig));
- defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_CONFIRM_SAVE|EOPT_EN_CD_LEDS;
- defaultConfig.s_PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 |
- POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_ACC_SPRITES |
- POPT_EN_32X|POPT_EN_PWM;
defaultConfig.s_PicoOpt|= POPT_6BTN_PAD; // for xmen proto
- defaultConfig.s_PsndRate = 44100;
- defaultConfig.s_PicoRegion = 0; // auto
- defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP
defaultConfig.s_PicoCDBuffers = 0;
defaultConfig.Frameskip = 0;
}
+void pemu_validate_config(void)
+{
+}
+
static int EmuScanBegin16(unsigned int num)
{
DrawLineDest = (unsigned short *) g_screen_ptr + g_screen_width * num;
{
}
-void plat_validate_config(void)
-{
-}
-
void plat_update_volume(int has_changed, int is_up)
{
}