\r
extern int crashed_940;\r
\r
-static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
+static short __attribute__((aligned(4))) sndBuffer[2*(44100+100)/50];\r
static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];\r
unsigned char *PicoDraw2FB = PicoDraw2FB_;\r
-static int osd_fps_x;\r
+static int osd_fps_x, osd_y;\r
\r
extern void *gp2x_screens[4];\r
\r
if (!(Pico.video.reg[12]&1) && !(PicoOpt & POPT_DIS_32C_BORDER))\r
x += 32;\r
\r
- if (EOPT_WIZ_TEAR_FIX) {\r
+ if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
pitch = 240;\r
p += (319 - x) * pitch + y;\r
} else\r
\r
static int EmuScanBegin16(unsigned int num)\r
{\r
- if (!(Pico.video.reg[1]&8)) num += 8;\r
DrawLineDest = (unsigned short *) g_screen_ptr + g_screen_width * num;\r
\r
return 0;\r
\r
static int EmuScanBegin8(unsigned int num)\r
{\r
- if (!(Pico.video.reg[1]&8)) num += 8;\r
DrawLineDest = (unsigned char *) g_screen_ptr + g_screen_width * num;\r
\r
return 0;\r
{\r
if ((num & 3) != 3)\r
return 0;\r
- if (!(Pico.video.reg[1] & 8))\r
- num += 8;\r
rotated_blit16(g_screen_ptr, rot_buff, num + 1,\r
!(Pico.video.reg[12] & 1) && !(PicoOpt & POPT_EN_SOFTSCALE));\r
return 0;\r
{\r
if ((num & 3) != 3)\r
return 0;\r
- if (!(Pico.video.reg[1] & 8))\r
- num += 8;\r
rotated_blit8(g_screen_ptr, rot_buff, num + 1,\r
!(Pico.video.reg[12] & 1));\r
return 0;\r
}\r
\r
-int localPal[0x100];\r
-static void (*vidcpyM2)(void *dest, void *src, int m32col, int with_32c_border) = NULL;\r
+static int localPal[0x100];\r
+static void (*vidcpyM2)(void *dest, void *src, int m32col, int with_32c_border);\r
+static int (*make_local_pal)(int fast_mode);\r
+\r
+static int make_local_pal_md(int fast_mode)\r
+{\r
+ int pallen = 0xc0;\r
+\r
+ bgr444_to_rgb32(localPal, Pico.cram);\r
+ if (fast_mode)\r
+ return 0x40;\r
+\r
+ if (Pico.video.reg[0xC] & 8) { // shadow/hilight mode\r
+ bgr444_to_rgb32_sh(localPal, Pico.cram);\r
+ localPal[0xc0] = 0x0000c000;\r
+ localPal[0xd0] = 0x00c00000;\r
+ localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
+ localPal[0xf0] = 0x00ffffff;\r
+ pallen = 0x100;\r
+ }\r
+ else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes\r
+ bgr444_to_rgb32(localPal+0x40, HighPal);\r
+ bgr444_to_rgb32(localPal+0x80, HighPal+0x40);\r
+ }\r
+ else\r
+ memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess\r
+\r
+ return pallen;\r
+}\r
+\r
+static int make_local_pal_sms(int fast_mode)\r
+{\r
+ unsigned short *spal = Pico.cram;\r
+ unsigned int *dpal = (void *)localPal;\r
+ unsigned int i, t;\r
+\r
+ for (i = 0x40; i > 0; i--) {\r
+ t = *spal++;\r
+ t = ((t & 0x0003) << 22) | ((t & 0x000c) << 12) | ((t & 0x0030) << 2);\r
+ t |= t >> 2;\r
+ t |= t >> 4;\r
+ *dpal++ = t;\r
+ }\r
+\r
+ return 0x40;\r
+}\r
\r
void pemu_update_display(const char *fps, const char *notice)\r
{\r
int emu_opt = currentConfig.EmuOpt;\r
+ int ret;\r
\r
if (PicoOpt & POPT_ALT_RENDERER)\r
{\r
// 8bit fast renderer\r
if (Pico.m.dirtyPal) {\r
Pico.m.dirtyPal = 0;\r
- vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
+ ret = make_local_pal(1);\r
// feed new palette to our device\r
- gp2x_video_setpalette(localPal, 0x40);\r
+ gp2x_video_setpalette(localPal, ret);\r
}\r
// a hack for VR\r
- if (PicoRead16Hook == PicoSVPRead16)\r
+ if (PicoAHW & PAHW_SVP)\r
memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328);\r
// do actual copy\r
vidcpyM2(g_screen_ptr, PicoDraw2FB+328*8,\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
- }\r
- else {\r
- vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
- memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess\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
+ ret = make_local_pal(0);\r
+ gp2x_video_setpalette(localPal, ret);\r
}\r
}\r
\r
if (notice || (emu_opt & 2)) {\r
- int h = 232;\r
- if (currentConfig.scaling == EOPT_SCALE_HW_HV && !(Pico.video.reg[1]&8))\r
- h -= 8;\r
if (notice)\r
- osd_text(4, h, notice);\r
+ osd_text(4, osd_y, notice);\r
if (emu_opt & 2)\r
- osd_text(osd_fps_x, h, fps);\r
+ osd_text(osd_fps_x, osd_y, fps);\r
}\r
if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))\r
draw_cd_leds();\r
if (currentConfig.scaling == EOPT_SCALE_HW_HV && !(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
+\r
+ // palette converters for 8bit modes\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 is_menu)\r
+void plat_video_toggle_renderer(int is_next, int force_16bpp, int is_menu)\r
{\r
+ if (force_16bpp) {\r
+ PicoOpt &= ~POPT_ALT_RENDERER;\r
+ currentConfig.EmuOpt |= EOPT_16BPP;\r
+ }\r
/* alt, 16bpp, 8bpp */\r
- if (PicoOpt & POPT_ALT_RENDERER) {\r
+ else if (PicoOpt & POPT_ALT_RENDERER) {\r
PicoOpt &= ~POPT_ALT_RENDERER;\r
if (is_next)\r
currentConfig.EmuOpt |= EOPT_16BPP;\r
return;\r
\r
vidResetMode();\r
+ rendstatus_old = -1;\r
\r
if (PicoOpt & POPT_ALT_RENDERER) {\r
emu_status_msg(" 8bit fast renderer");\r
int is_stereo = (PicoOpt & POPT_EN_STEREO) ? 1 : 0;\r
int target_fps = Pico.m.pal ? 50 : 60;\r
int frame_samples, snd_excess_add;\r
+ int snd_rate_oss = PsndRate;\r
gp2x_soc_t soc;\r
\r
soc = soc_detect();\r
+ if (soc == SOCID_POLLUX) {\r
+ /* POLLUX pain: DPLL1 / mclk_div / bitclk_div / 4 */\r
+ switch (PsndRate) {\r
+ case 44100: PsndRate = 44171; break; // 44170.673077\r
+ case 22050: PsndRate = 22086; break; // 22085.336538\r
+ case 11025: PsndRate = 11043; break; // 11042.668269\r
+ default: break;\r
+ }\r
+ }\r
\r
#define SOUND_RERATE_FLAGS (POPT_EN_FM|POPT_EN_PSG|POPT_EN_STEREO|POPT_EXT_FM|POPT_EN_MCD_CDDA)\r
if (PsndRate != PsndRate_old || Pico.m.pal != pal_old || ((PicoOpt & POPT_EXT_FM) && crashed_940) ||\r
printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n",\r
PsndRate, PsndLen, snd_excess_add, is_stereo, Pico.m.pal);\r
sndout_oss_setvol(currentConfig.volume, currentConfig.volume);\r
- sndout_oss_start(PsndRate, frame_samples, is_stereo);\r
+ sndout_oss_start(snd_rate_oss, frame_samples, is_stereo);\r
\r
/* Wiz's sound hardware needs more prebuffer */\r
if (soc == SOCID_POLLUX)\r
\r
void pemu_sound_stop(void)\r
{\r
+ /* get back from Wiz pain */\r
+ switch (PsndRate) {\r
+ case 44171: PsndRate = 44100; break;\r
+ case 22086: PsndRate = 22050; break;\r
+ case 11043: PsndRate = 11025; break;\r
+ default: break;\r
+ }\r
}\r
\r
void pemu_sound_wait(void)\r
{\r
}\r
\r
-void pemu_video_mode_change(int is_32col, int is_240_lines)\r
+void emu_video_mode_change(int start_line, int line_count, int is_32cols)\r
{\r
int scalex = 320;\r
osd_fps_x = OSD_FPS_X;\r
- if (is_32col && (PicoOpt & POPT_DIS_32C_BORDER)) {\r
+ osd_y = 232;\r
+ if (is_32cols && (PicoOpt & POPT_DIS_32C_BORDER)) {\r
scalex = 256;\r
osd_fps_x = OSD_FPS_X - 64;\r
}\r
+\r
/* want vertical scaling and game is not in 240 line mode */\r
- if (currentConfig.scaling == EOPT_SCALE_HW_HV && !is_240_lines)\r
- gp2x_video_RGB_setscaling(8, scalex, 224);\r
- else\r
+ if (currentConfig.scaling == EOPT_SCALE_HW_HV) {\r
+ gp2x_video_RGB_setscaling(start_line, scalex, line_count);\r
+ osd_y = start_line + line_count - 8;\r
+ } else\r
gp2x_video_RGB_setscaling(0, scalex, 240);\r
\r
// clear whole screen in all buffers\r
int po_old = PicoOpt;\r
int eo_old = currentConfig.EmuOpt;\r
\r
+ pemu_sound_stop();\r
+ memset32(g_screen_ptr, 0, 320*240*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