DEFINES += _ASM_CD_MEMORY_C
OBJS += pico/cd/memory_arm.o
endif
+ifeq "$(asm_32xdraw)" "1"
+DEFINES += _ASM_32X_DRAW
+OBJS += pico/32x/draw_arm.o
+endif
DIRS += cpu/Cyclone cpu/Cyclone/proj cpu/Cyclone/tools cpu/DrZ80
#include <unistd.h>
#endif
#include "config.h"
+#include "plat.h"
#include "input.h"
#include "lprintf.h"
case MA_OPT2_GAMMA: return defaultConfig.gamma;
case MA_OPT_FRAMESKIP: return defaultConfig.Frameskip;
case MA_OPT_CPU_CLOCKS: return defaultConfig.CPUclock;
+ case MA_OPT_RENDERER: return defaultConfig.renderer;
case MA_OPT_SAVE_SLOT:
default:
case MA_OPT_CONFIRM_STATES:
return !((defaultConfig.EmuOpt ^ currentConfig.EmuOpt) &
(EOPT_CONFIRM_LOAD|EOPT_CONFIRM_SAVE)) == 0;
- case MA_OPT_RENDERER:
- return ((defaultConfig.s_PicoOpt ^ PicoOpt) & POPT_ALT_RENDERER) == 0 &&
- ((defaultConfig.EmuOpt ^ currentConfig.EmuOpt) & EOPT_16BPP) == 0;
case MA_CDOPT_READAHEAD:
return defaultConfig.s_PicoCDBuffers == PicoCDBuffers;
default:break;
static int custom_read(menu_entry *me, const char *var, const char *val)
{
char *tmp;
- int tmpi;
+ int i;
switch (me->id)
{
case MA_OPT_RENDERER:
- if (strcasecmp(var, "Renderer") != 0) return 0;
- if (strcasecmp(val, "8bit fast") == 0 || strcasecmp(val, "fast") == 0) {
- PicoOpt |= POPT_ALT_RENDERER;
- }
- else if (strcasecmp(val, "16bit accurate") == 0 || strcasecmp(val, "accurate") == 0) {
- PicoOpt &= ~POPT_ALT_RENDERER;
- currentConfig.EmuOpt |= 0x80;
- }
- else if (strcasecmp(val, "8bit accurate") == 0) {
- PicoOpt &= ~POPT_ALT_RENDERER;
- currentConfig.EmuOpt &= ~0x80;
- }
- else
+ if (strcasecmp(var, "Renderer") != 0 || renderer_names == NULL)
return 0;
- return 1;
+
+ for (i = 0; renderer_names[i] != NULL; i++) {
+ if (strcasecmp(val, renderer_names[i]) == 0) {
+ currentConfig.renderer = i;
+ return 1;
+ }
+ }
+ return 0;
case MA_OPT_SCALING:
#ifdef __GP2X__
case MA_OPT2_SQUIDGEHACK:
if (strcasecmp(var, "Squidgehack") != 0) return 0;
- tmpi = atoi(val);
- if (tmpi) *(int *)me->var |= me->mask;
- else *(int *)me->var &= ~me->mask;
+ i = atoi(val);
+ if (i) *(int *)me->var |= me->mask;
+ else *(int *)me->var &= ~me->mask;
return 1;
case MA_CDOPT_READAHEAD:
\r
void emu_32x_startup(void)\r
{\r
- plat_video_toggle_renderer(0, 1, 0);\r
+ plat_video_toggle_renderer(0, 0);\r
system_announce();\r
}\r
\r
PicoStateProgressCB = NULL;\r
}\r
}\r
- if ((which & PEV_SWITCH_RND) && !(PicoAHW & PAHW_32X))\r
+ if (which & PEV_SWITCH_RND)\r
{\r
- plat_video_toggle_renderer(1, 0, 0);\r
+ plat_video_toggle_renderer(1, 0);\r
}\r
if (which & (PEV_SSLOT_PREV|PEV_SSLOT_NEXT))\r
{\r
{\r
if ((currentConfig.EmuOpt & EOPT_NO_FRMLIMIT) && currentConfig.Frameskip >= 0)\r
pframes_done = 0;\r
- else {\r
+ else\r
pframes_done -= target_fps;\r
- /* don't allow it to drift during heavy slowdowns */\r
- if (pframes_done < -5) {\r
- reset_timing = 1;\r
- continue;\r
- }\r
- if (pframes_done < -2)\r
- pframes_done = -2;\r
+ if (pframes_done < -2) {\r
+ /* don't drag more than 2 frames behind */\r
+ pframes_done = -2;\r
+ timestamp_base = timestamp - 2 * target_frametime;\r
}\r
- timestamp_base += ms_to_ticks(1000);\r
+ else\r
+ timestamp_base += ms_to_ticks(1000);\r
}\r
\r
diff = timestamp - timestamp_base;\r
else if (diff > diff_lim)\r
{\r
/* no time left for this frame - skip */\r
- if (diff - diff_lim >= ms_to_ticks(200)) {\r
- /* if too much behind, reset instead */\r
- reset_timing = 1;\r
+ /* limit auto frameskip to 8 */\r
+ if (frames_done / 8 <= frames_shown) {\r
+ emu_update_input();\r
+ skip_frame(diff < diff_lim + target_frametime * 16);\r
+ pframes_done++; frames_done++;\r
continue;\r
}\r
- emu_update_input();\r
- skip_frame(diff < diff_lim + target_frametime * 2);\r
- pframes_done++; frames_done++;\r
- continue;\r
}\r
\r
emu_update_input();\r
#define EOPT_GZIP_SAVES (1<<3)
#define EOPT_MMUHACK (1<<4)
#define EOPT_NO_AUTOSVCFG (1<<5)
-#define EOPT_16BPP (1<<7)
+#define EOPT_16BPP (1<<7) // depreceted for .renderer
#define EOPT_RAM_TIMINGS (1<<8)
#define EOPT_CONFIRM_SAVE (1<<9)
#define EOPT_EN_CD_LEDS (1<<10)
float hscale32, hscale40; // psp: horizontal scale
int gamma2; // psp: black level
int turbo_rate;
+ int renderer;
+ int renderer32x;
} currentConfig_t;
extern currentConfig_t currentConfig, defaultConfig;
#else\r
#define MENU_OPTIONS_GFX\r
#define MENU_OPTIONS_ADV\r
-#define mgn_opt_renderer NULL /* TODO */\r
#define menu_main_plat_draw NULL\r
#endif\r
\r
\r
// ------------ 32X options menu ------------\r
\r
+static const char *get_rname(const char **rn, int val, int *offs)\r
+{\r
+ int i, len, found = -1, maxlen = 0;\r
+\r
+ for (i = 0; rn[i] != NULL; i++) {\r
+ len = strlen(rn[i]);\r
+ if (len > maxlen)\r
+ maxlen = len;\r
+ if (i == val)\r
+ found = i;\r
+ }\r
+\r
+ *offs = 3 - maxlen;\r
+ if (found >= 0)\r
+ return rn[found];\r
+ return "???";\r
+}\r
+\r
+static const char *mgn_opt_renderer32x(menu_id id, int *offs)\r
+{\r
+ return get_rname(renderer_names32x, currentConfig.renderer32x, offs);\r
+}\r
+\r
static menu_entry e_menu_32x_options[] =\r
{\r
- mee_onoff("32X enabled", MA_32XOPT_ENABLE_32X, PicoOpt, POPT_EN_32X),\r
- mee_onoff("PWM sound", MA_32XOPT_PWM, PicoOpt, POPT_EN_PWM),\r
+ mee_onoff ("32X enabled", MA_32XOPT_ENABLE_32X, PicoOpt, POPT_EN_32X),\r
+ mee_range_cust("32X renderer", MA_32XOPT_RENDERER, currentConfig.renderer32x, 0, 0, mgn_opt_renderer32x),\r
+ mee_onoff ("PWM sound", MA_32XOPT_PWM, PicoOpt, POPT_EN_PWM),\r
mee_end,\r
};\r
\r
static int menu_loop_32x_options(menu_id id, int keys)\r
{\r
static int sel = 0;\r
+ int i, c;\r
+\r
+ for (c = 0; renderer_names32x != NULL && renderer_names32x[c] != NULL; )\r
+ c++;\r
+ i = me_id2offset(e_menu_32x_options, MA_32XOPT_RENDERER);\r
+ e_menu_32x_options[i].max = c > 0 ? (c - 1) : 0;\r
+\r
me_loop(e_menu_32x_options, &sel, NULL);\r
return 0;\r
}\r
\r
// ------------ gfx options menu ------------\r
\r
-static int mh_opt_render(menu_id id, int keys)\r
+static const char *mgn_opt_renderer(menu_id id, int *offs)\r
{\r
- plat_video_toggle_renderer((keys & PBTN_RIGHT) ? 1 : 0, 0, 1);\r
- return 0;\r
+ return get_rname(renderer_names, currentConfig.renderer, offs);\r
}\r
\r
static menu_entry e_menu_gfx_options[] =\r
{\r
- mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer),\r
+ mee_range_cust("Renderer", MA_OPT_RENDERER, currentConfig.renderer, 0, 0, mgn_opt_renderer),\r
MENU_OPTIONS_GFX\r
mee_end,\r
};\r
static int menu_loop_gfx_options(menu_id id, int keys)\r
{\r
static int sel = 0;\r
+ int i, c;\r
+\r
+ for (c = 0; renderer_names != NULL && renderer_names[c] != NULL; )\r
+ c++;\r
+ i = me_id2offset(e_menu_gfx_options, MA_OPT_RENDERER);\r
+ e_menu_gfx_options[i].max = c > 0 ? (c - 1) : 0;\r
+ me_enable(e_menu_gfx_options, MA_OPT_RENDERER, renderer_names != NULL);\r
+\r
me_loop(e_menu_gfx_options, &sel, NULL);\r
return 0;\r
}\r
MA_CDOPT_BETTER_SYNC,
MA_CDOPT_DONE,
MA_32XOPT_ENABLE_32X,
+ MA_32XOPT_RENDERER,
MA_32XOPT_PWM,
MA_CTRL_PLAYER1,
MA_CTRL_PLAYER2,
/* stuff to be implemented by platform code */
extern char cpu_clk_name[];
+extern const char **renderer_names;
+extern const char **renderer_names32x;
void pemu_prep_defconfig(void);
void pemu_validate_config(void);
void plat_video_flip(void);
void plat_video_wait_vsync(void);
-void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu);
+void plat_video_toggle_renderer(int change, int menu_call);
void plat_update_volume(int has_changed, int is_up);
asm_misc = 1\r
asm_cdpico = 1\r
asm_cdmemory = 1\r
+asm_32xdraw = 1\r
#profile = 1\r
#drc_debug = 3\r
\r
-// (c) Copyright 2006-2009 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
+/*\r
+ * (c) Copyright 2006-2010 notaz, All rights reserved.\r
+ *\r
+ * For performance reasons 3 renderers are exported for both MD and 32x modes:\r
+ * - 16bpp line renderer\r
+ * - 8bpp line renderer (slightly faster)\r
+ * - 8bpp tile renderer\r
+ * In 32x mode:\r
+ * - 32x layer is overlayed on top of 16bpp one\r
+ * - line internal one done on PicoDraw2FB, then mixed with 32x\r
+ * - tile internal one done on PicoDraw2FB, then mixed with 32x\r
+ */\r
\r
#include <stdio.h>\r
#include <stdlib.h>\r
static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];\r
unsigned char *PicoDraw2FB = PicoDraw2FB_;\r
static int osd_fps_x, osd_y;\r
+const char *renderer_names_[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };\r
+const char *renderer_names32x_[] = { "accurate", "faster ", "fastest ", NULL };\r
+const char **renderer_names = renderer_names_;\r
+const char **renderer_names32x = renderer_names32x_;\r
+enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT };\r
\r
extern void *gp2x_screens[4];\r
\r
gp2x_soc_t soc;\r
\r
defaultConfig.CPUclock = default_cpu_clock;\r
+ defaultConfig.renderer32x = RT_8BIT_FAST;\r
\r
soc = soc_detect();\r
if (soc == SOCID_MMSP2)\r
currentConfig.CPUclock = default_cpu_clock;\r
}\r
\r
+static int get_renderer(void)\r
+{\r
+ if (PicoAHW & PAHW_32X)\r
+ return currentConfig.renderer32x;\r
+ else\r
+ return currentConfig.renderer;\r
+}\r
+\r
+static void change_renderer(int diff)\r
+{\r
+ int *r;\r
+ if (PicoAHW & PAHW_32X)\r
+ r = ¤tConfig.renderer32x;\r
+ else\r
+ r = ¤tConfig.renderer;\r
+ *r += diff;\r
+ if (*r >= RT_COUNT)\r
+ *r = 0;\r
+ else if (*r < 0)\r
+ *r = RT_COUNT - 1;\r
+}\r
+\r
+#define is_16bit_mode() \\r
+ (get_renderer() == RT_16BIT || (PicoAHW & PAHW_32X))\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
scr_offs = pitch * 2 + 4;\r
}\r
\r
- if ((PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP)) {\r
+ if (!is_16bit_mode()) {\r
#define p(x) px[(x) >> 2]\r
// 8-bit modes\r
unsigned int *px = (unsigned int *)((char *)g_screen_ptr + scr_offs);\r
int x, y, pitch = 320;\r
\r
// only if pen enabled and for 16bit modes\r
- if (pico_inp_mode == 0 || (PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP))\r
+ if (pico_inp_mode == 0 || currentConfig.EmuOpt != RT_16BIT)\r
return;\r
\r
x = pico_pen_x + PICO_PEN_ADJUST_X;\r
p[pitch*2] ^= 0xffff;\r
}\r
\r
-static int EmuScanBegin16(unsigned int num)\r
-{\r
- DrawLineDest = (unsigned short *) g_screen_ptr + g_screen_width * num;\r
-\r
- return 0;\r
-}\r
-\r
-static int EmuScanBegin8(unsigned int num)\r
-{\r
- DrawLineDest = (unsigned char *) g_screen_ptr + g_screen_width * num;\r
-\r
- return 0;\r
-}\r
-\r
/* rot thing for Wiz */\r
static unsigned char __attribute__((aligned(4))) rot_buff[320*4*2];\r
\r
int emu_opt = currentConfig.EmuOpt;\r
int ret;\r
\r
- if (PicoOpt & POPT_ALT_RENDERER)\r
+ if (PicoAHW & PAHW_32X)\r
+ ; // nothing to do\r
+ else if (get_renderer() == RT_8BIT_FAST)\r
{\r
// 8bit fast renderer\r
if (Pico.m.dirtyPal) {\r
vidcpyM2(g_screen_ptr, PicoDraw2FB+328*8,\r
!(Pico.video.reg[12] & 1), !(PicoOpt & POPT_DIS_32C_BORDER));\r
}\r
- else if (!(emu_opt & EOPT_16BPP))\r
+ else if (get_renderer() == RT_8BIT_ACC)\r
{\r
// 8bit accurate renderer\r
if (Pico.m.dirtyPal)\r
\r
void plat_video_flip(void)\r
{\r
+ int stride = g_screen_width;\r
gp2x_video_flip();\r
+\r
+ if (is_16bit_mode())\r
+ stride *= 2;\r
+ PicoDrawSetOutBuf(g_screen_ptr, stride);\r
}\r
\r
/* XXX */\r
\r
void plat_status_msg_clear(void)\r
{\r
- int is_8bit = (PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP);\r
+ int is_8bit = !is_16bit_mode();\r
if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
/* ugh.. */\r
int i, u, *p;\r
\r
static void vidResetMode(void)\r
{\r
+ int gp2x_mode = 16;\r
+ int renderer = get_renderer();\r
+\r
+ PicoScanBegin = NULL;\r
PicoScanEnd = NULL;\r
\r
- if (PicoOpt & POPT_ALT_RENDERER) {\r
- if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
- gp2x_video_changemode(-8);\r
- vidcpyM2 = vidcpy_m2_rot;\r
- osd_text = osd_text8_rot;\r
- } else {\r
- gp2x_video_changemode(8);\r
- vidcpyM2 = vidcpy_m2;\r
- osd_text = osd_text8;\r
- }\r
- }\r
- else if (currentConfig.EmuOpt & EOPT_16BPP) {\r
- PicoDrawSetColorFormat(1);\r
+ switch (renderer) {\r
+ case RT_16BIT:\r
+ PicoOpt &= ~POPT_ALT_RENDERER;\r
+ PicoDrawSetOutFormat(PDF_RGB555, 0);\r
+ PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);\r
if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
- gp2x_video_changemode(-16);\r
PicoScanBegin = EmuScanBegin16_rot;\r
PicoScanEnd = EmuScanEnd16_rot;\r
- osd_text = osd_text16_rot;\r
- } else {\r
- gp2x_video_changemode(16);\r
- PicoScanBegin = EmuScanBegin16;\r
- osd_text = osd_text16;\r
}\r
- }\r
- else {\r
- PicoDrawSetColorFormat(2);\r
+ break;\r
+ case RT_8BIT_ACC:\r
+ PicoOpt &= ~POPT_ALT_RENDERER;\r
+ PicoDrawSetOutFormat(PDF_8BIT, 0);\r
+ PicoDrawSetOutBuf(g_screen_ptr, g_screen_width);\r
if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
- gp2x_video_changemode(-8);\r
PicoScanBegin = EmuScanBegin8_rot;\r
PicoScanEnd = EmuScanEnd8_rot;\r
- osd_text = osd_text8_rot;\r
- } else {\r
- gp2x_video_changemode(8);\r
- PicoScanBegin = EmuScanBegin8;\r
- osd_text = osd_text8;\r
}\r
+ gp2x_mode = 8;\r
+ break;\r
+ case RT_8BIT_FAST:\r
+ PicoOpt |= POPT_ALT_RENDERER;\r
+ PicoDrawSetOutFormat(PDF_NONE, 0);\r
+ if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX)\r
+ vidcpyM2 = vidcpy_m2_rot;\r
+ else\r
+ vidcpyM2 = vidcpy_m2;\r
+ gp2x_mode = 8;\r
+ break;\r
}\r
\r
- if ((PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP)) {\r
+ if (is_16bit_mode())\r
+ osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text16_rot : osd_text16;\r
+ else\r
+ osd_text = (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) ? osd_text8_rot : osd_text8;\r
+\r
+ if (PicoAHW & PAHW_32X) {\r
+ // rules change in 32X world\r
+ if (renderer != RT_16BIT) {\r
+ PicoDrawSetOutFormat(PDF_NONE, 0);\r
+ PicoScanBegin = NULL;\r
+ PicoScanEnd = NULL;\r
+ }\r
+ PicoScan32xBegin = NULL;\r
+ PicoScan32xEnd = NULL;\r
+ if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
+ PicoScan32xBegin = EmuScanBegin16_rot;\r
+ PicoScan32xEnd = EmuScanEnd16_rot;\r
+ }\r
+ // Wiz 16bit is an exception, uses line rendering due to rotation mess\r
+ if (renderer == RT_16BIT && (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX)) {\r
+ PicoDrawSetOutFormat(PDF_RGB555, 1);\r
+ PicoDraw32xSetFrameMode(0, 0);\r
+ }\r
+ else {\r
+ PicoDraw32xSetFrameMode(1, (renderer == RT_16BIT) ? 1 : 0);\r
+ }\r
+ PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);\r
+ gp2x_mode = 16;\r
+ }\r
+\r
+ if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX)\r
+ gp2x_mode = -gp2x_mode;\r
+ gp2x_video_changemode(gp2x_mode);\r
+\r
+ if (!is_16bit_mode()) {\r
// setup pal for 8-bit modes\r
localPal[0xc0] = 0x0000c000; // MCD LEDs\r
localPal[0xd0] = 0x00c00000;\r
make_local_pal = (PicoAHW & PAHW_SMS) ? make_local_pal_sms : make_local_pal_md;\r
}\r
\r
-void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu)\r
+void plat_video_toggle_renderer(int change, int is_menu_call)\r
{\r
- if (force_16bpp) {\r
- PicoOpt &= ~POPT_ALT_RENDERER;\r
- currentConfig.EmuOpt |= EOPT_16BPP;\r
- }\r
- /* alt, 16bpp, 8bpp */\r
- else if (PicoOpt & POPT_ALT_RENDERER) {\r
- PicoOpt &= ~POPT_ALT_RENDERER;\r
- if (is_next)\r
- currentConfig.EmuOpt |= EOPT_16BPP;\r
- } else if (!(currentConfig.EmuOpt & EOPT_16BPP)) {\r
- if (is_next)\r
- PicoOpt |= POPT_ALT_RENDERER;\r
- else\r
- currentConfig.EmuOpt |= EOPT_16BPP;\r
- } else {\r
- currentConfig.EmuOpt &= ~EOPT_16BPP;\r
- if (!is_next)\r
- PicoOpt |= POPT_ALT_RENDERER;\r
- }\r
+ change_renderer(change);\r
\r
- if (is_menu)\r
+ if (is_menu_call)\r
return;\r
\r
vidResetMode();\r
rendstatus_old = -1;\r
\r
- if (PicoOpt & POPT_ALT_RENDERER) {\r
- emu_status_msg(" 8bit fast renderer");\r
- } else if (currentConfig.EmuOpt & EOPT_16BPP) {\r
- emu_status_msg("16bit accurate renderer");\r
- } else {\r
- emu_status_msg(" 8bit accurate renderer");\r
- }\r
+ if (PicoAHW & PAHW_32X)\r
+ emu_status_msg(renderer_names32x[get_renderer()]);\r
+ else\r
+ emu_status_msg(renderer_names[get_renderer()]);\r
}\r
\r
#if 0 // TODO\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;\r
- currentConfig.EmuOpt |= EOPT_16BPP;\r
\r
- PicoDrawSetColorFormat(1);\r
- PicoScanBegin = EmuScanBegin16;\r
+ PicoDrawSetOutFormat(PDF_RGB555, 1);\r
+ PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);\r
+ PicoDraw32xSetFrameMode(0, 0);\r
+ PicoScanBegin = NULL;\r
PicoScanEnd = NULL;\r
Pico.m.dirtyPal = 1;\r
PicoFrameDrawOnly();\r
\r
PicoOpt = po_old;\r
- currentConfig.EmuOpt = eo_old;\r
}\r
\r
void plat_debug_cat(char *str)\r
gp2x_video_RGB_setscaling(0, scalex, 240);\r
\r
// clear whole screen in all buffers\r
- if ((PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP))\r
+ if (!is_16bit_mode())\r
gp2x_memset_all_buffers(0, 0xe0, 320*240);\r
else\r
gp2x_memset_all_buffers(0, 0, 320*240*2);\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
- PicoScanBegin = EmuScanBegin16;\r
+ PicoDrawSetOutFormat(PDF_RGB555, 1);\r
+ PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);\r
+ PicoDraw32xSetFrameMode(0, 0);\r
+ PicoScanBegin = NULL;\r
PicoScanEnd = NULL;\r
- PicoDrawSetColorFormat(1);\r
Pico.m.dirtyPal = 1;\r
PicoFrame();\r
\r
// ------------ gfx options menu ------------
-static const char *mgn_opt_renderer(menu_id id, int *offs)
-{
- *offs = -11;
- if (PicoOpt & POPT_ALT_RENDERER)
- return " 8bit fast";
- else if (currentConfig.EmuOpt & EOPT_16BPP)
- return "16bit accurate";
- else
- return " 8bit accurate";
-}
-
static const char *mgn_opt_scaling(menu_id id, int *offs)
{
*offs = -13;
#define SCREEN_WIDTH 320\r
#define SCREEN_HEIGHT 240\r
\r
-// draw.c\r
-#define OVERRIDE_HIGHCOL 0\r
-\r
// draw2.c\r
#define START_ROW 0 // which row of tiles to start rendering at?\r
#define END_ROW 28 // ..end\r
.equiv START_ROW, 0\r
.equiv END_ROW, 28\r
\r
-.equiv OVERRIDE_HIGHCOL, 0\r
.equiv UNALIGNED_DRAWLINEDEST, 0\r
\r
@ this should be set to one only for GP2X port\r
\r
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
char cpu_clk_name[] = "unused";\r
+const char *renderer_names_[] = { "16bit accurate", " 8bit accurate", " 8bit fast", NULL };\r
+const char *renderer_names32x_[] = { "accurate", "faster ", "fastest ", NULL };\r
+const char **renderer_names = renderer_names_;\r
+const char **renderer_names32x = renderer_names32x_;\r
+enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT };\r
\r
\r
void pemu_prep_defconfig(void)\r
led_offs = 4;\r
scr_offs = pitch * 2 + 4;\r
\r
- if ((PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP)) {\r
+ if (currentConfig.renderer != RT_16BIT) {\r
#define p(x) px[(x) >> 2]\r
// 8-bit modes\r
unsigned int *px = (unsigned int *)((char *)g_screen_ptr + scr_offs);\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_finalize_frame(const char *fps, const char *notice)\r
{\r
+ if (currentConfig.renderer != RT_16BIT && !(PicoAHW & PAHW_32X)) {\r
+ unsigned short *pd = (unsigned short *)g_screen_ptr + 8 * g_screen_width;\r
+ unsigned char *ps = PicoDraw2FB + 328*8 + 8;\r
+ unsigned short *pal = HighPal;\r
+ int i, x;\r
+ if (Pico.m.dirtyPal)\r
+ PicoDrawUpdateHighPal();\r
+ for (i = 0; i < 224; i++, ps += 8)\r
+ for (x = 0; x < 320; x++)\r
+ *pd++ = pal[*ps++];\r
+ }\r
+\r
if (notice || (currentConfig.EmuOpt & EOPT_SHOW_FPS)) {\r
if (notice)\r
osd_text(4, g_screen_height - 8, notice);\r
draw_cd_leds();\r
}\r
\r
-void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu)\r
+static void apply_renderer(void)\r
+{\r
+ PicoScanBegin = NULL;\r
+ PicoScanEnd = NULL;\r
+\r
+ switch (currentConfig.renderer) {\r
+ case RT_16BIT:\r
+ PicoOpt &= ~POPT_ALT_RENDERER;\r
+ PicoDrawSetOutFormat(PDF_RGB555, 0);\r
+ PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);\r
+ break;\r
+ case RT_8BIT_ACC:\r
+ PicoOpt &= ~POPT_ALT_RENDERER;\r
+ PicoDrawSetOutFormat(PDF_8BIT, 0);\r
+ PicoDrawSetOutBuf(PicoDraw2FB + 8, 328);\r
+ break;\r
+ case RT_8BIT_FAST:\r
+ PicoOpt |= POPT_ALT_RENDERER;\r
+ PicoDrawSetOutFormat(PDF_NONE, 0);\r
+ break;\r
+ }\r
+\r
+ if (PicoAHW & PAHW_32X) {\r
+ int only_32x = 0;\r
+ if (currentConfig.renderer == RT_16BIT)\r
+ only_32x = 1;\r
+ else\r
+ PicoDrawSetOutFormat(PDF_NONE, 0);\r
+ PicoDraw32xSetFrameMode(1, only_32x);\r
+ PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);\r
+ }\r
+}\r
+\r
+void plat_video_toggle_renderer(int change, int is_menu)\r
{\r
- // this will auto-select SMS/32X renderers\r
- PicoDrawSetColorFormat(1);\r
+ currentConfig.renderer += change;\r
+ if (currentConfig.renderer >= RT_COUNT)\r
+ currentConfig.renderer = 0;\r
+ else if (currentConfig.renderer < 0)\r
+ currentConfig.renderer = RT_COUNT - 1;\r
+\r
+ if (!is_menu)\r
+ apply_renderer();\r
+\r
+ emu_status_msg(renderer_names[currentConfig.renderer]);\r
}\r
\r
void plat_video_menu_enter(int is_rom_loaded)\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
+ PicoDrawSetOutFormat(PDF_RGB555, 0);\r
\r
Pico.m.dirtyPal = 1;\r
PicoFrameDrawOnly();\r
\r
void pemu_loop_prep(void)\r
{\r
- PicoDrawSetColorFormat(1);\r
- PicoScanBegin = EmuScanBegin16;\r
+ apply_renderer();\r
osd_text = osd_text16;\r
\r
pemu_sound_start();\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
+ PicoDrawSetOutFormat(PDF_RGB555, 0);\r
Pico.m.dirtyPal = 1;\r
PicoFrame();\r
\r
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
-// draw.c
-#define OVERRIDE_HIGHCOL 0
-
// draw2.c
#define START_ROW 0 // which row of tiles to start rendering at?
#define END_ROW 28 // ..end
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
+const char **renderer_names = NULL;\r
+const char **renderer_names32x = NULL;\r
char cpu_clk_name[] = "unused";\r
\r
\r
{\r
int len = strlen(text)*8;\r
\r
- if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
+ if (0) {\r
int *p, i, h;\r
x &= ~3; // align x\r
len = (len+3) >> 2;\r
// if (!((Pico_mcd->s68k_regs[0] ^ old_reg) & 3)) return; // no change // mmu hack problems?\r
old_reg = Pico_mcd->s68k_regs[0];\r
\r
- if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
+ if (0) {\r
// 8-bit modes\r
unsigned int col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
draw_cd_leds();\r
}\r
\r
-void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu)\r
+void plat_video_toggle_renderer(int change, int is_menu)\r
{\r
// this will auto-select SMS/32X renderers\r
- PicoDrawSetColorFormat(1);\r
+ PicoDrawSetOutFormat(PDF_RGB555, 1);\r
}\r
\r
void plat_video_menu_enter(int is_rom_loaded)\r
void pemu_forced_frame(int opts)\r
{\r
int po_old = PicoOpt;\r
- int eo_old = currentConfig.EmuOpt;\r
\r
PicoOpt &= ~0x10;\r
PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites\r
- currentConfig.EmuOpt |= 0x80;\r
\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
memset32(fbdev_buffers[i], 0, g_screen_width * g_screen_height * 2 / 4);\r
\r
#ifdef USE_320_SCREEN\r
- PicoDrawSetColorFormat(1);\r
+ PicoDrawSetOutFormat(PDF_RGB555, 1);\r
PicoScanBegin = EmuScanBegin16;\r
#else\r
if (PicoAHW & PAHW_32X) {\r
DrawLineDest = (unsigned short *)temp_frame;\r
- PicoDrawSetColorFormat(1);\r
+ PicoDrawSetOutFormat(PDF_RGB555, 1);\r
PicoScanBegin = NULL;\r
PicoScanEnd = EmuScanEnd16_32x;\r
} else {\r
- PicoDrawSetColorFormat(-1);\r
+ PicoDrawSetOutFormat(PDF_NONE, 0);\r
PicoScanBegin = NULL;\r
PicoScanEnd = EmuScanEnd16;\r
}\r
PicoOpt |= POPT_EN_SOFTSCALE|POPT_ACC_SPRITES;\r
currentConfig.EmuOpt |= EOPT_16BPP;\r
\r
- PicoDrawSetColorFormat(1);\r
+ PicoDrawSetOutFormat(PDF_RGB555, 1);\r
Pico.m.dirtyPal = 1;\r
PicoFrame();\r
\r
mee_onoff ("Status line in main menu", MA_OPT2_STATUS_LINE, currentConfig.EmuOpt, EOPT_SHOW_RTC),
#define menu_main_plat_draw NULL
-#define mgn_opt_renderer NULL
#define SCREEN_WIDTH 800\r
#define SCREEN_HEIGHT 480\r
\r
-// draw.c\r
-#define OVERRIDE_HIGHCOL 0\r
-\r
// draw2.c\r
#define START_ROW 0 // which row of tiles to start rendering at?\r
#define END_ROW 28 // ..end\r
.equiv START_ROW, 0\r
.equiv END_ROW, 28\r
\r
-.equiv OVERRIDE_HIGHCOL, 0\r
.equiv UNALIGNED_DRAWLINEDEST, 0\r
\r
@ this should be set to one only for GP2X port\r
sceGuTexImage(0,512,512,512,(char *)VRAM_STUFF + 16);
// slow rend.
- PicoDrawSetColorFormat(-1);
+ PicoDrawSetOutFormat(PDF_NONE, 0);
PicoScanBegin = EmuScanSlowBegin;
PicoScanEnd = EmuScanSlowEnd;
memset32((int *)VRAM_CACHED_STUFF + 512*232/4, 0xe0e0e0e0, 512*8/4);
memset32_uncached((int *)psp_screen + 512*264*2/4, 0, 512*8*2/4);
- PicoDrawSetColorFormat(-1);
+ PicoDrawSetOutFormat(PDF_NONE, 0);
PicoScanBegin = EmuScanSlowBegin;
PicoScanEnd = EmuScanSlowEnd;
EmuScanPrepare();
\r
// draw.c\r
#define USE_BGR555 1\r
-#define OVERRIDE_HIGHCOL 1\r
\r
// draw2.c\r
#define START_ROW 0 // which row of tiles to start rendering at?\r
static unsigned short screen_buff[320 * 240];
static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];
unsigned char *PicoDraw2FB = PicoDraw2FB_;
+const char **renderer_names = NULL;
+const char **renderer_names32x = NULL;
char cpu_clk_name[] = "unused";
{
}
-static int EmuScanBegin16(unsigned int num)
-{
- DrawLineDest = (unsigned short *) g_screen_ptr + g_screen_width * num;
-
- return 0;
-}
-
void pemu_loop_prep(void)
{
- PicoDrawSetColorFormat(1);
- PicoScanBegin = EmuScanBegin16;
+ PicoDrawSetOutFormat(PDF_RGB555, 1);
+ PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
pemu_sound_start();
}
{
}
-void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu)
+void plat_video_toggle_renderer(int change, int is_menu)
{
// this will auto-select SMS/32X renderers
- PicoDrawSetColorFormat(1);
+ PicoDrawSetOutFormat(PDF_RGB555, 1);
}
void emu_video_mode_change(int start_line, int line_count, int is_32cols)
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
-// draw.c
-#define OVERRIDE_HIGHCOL 0
-
// draw2.c
#define START_ROW 0 // which row of tiles to start rendering at?
#define END_ROW 28 // ..end