@ to 00000000 rrr00000 ggg00000 bbb00000 ...\r
\r
@ lr = 0x00e000e0, out: r3=lower_pix, r2=higher_pix; trashes rin\r
-@ if sh==2, r8=0x00404040 (sh!=0 destroys flags!)\r
.macro convRGB32_2 rin sh=0\r
and r2, lr, \rin, lsr #4 @ blue\r
and r3, \rin, lr\r
.endif\r
\r
orr r2, r2, r2, lsr #3\r
+.if \sh == 1\r
+ str r2, [r0, #0x40*2*4]\r
+.endif\r
str r2, [r0], #4\r
.endm\r
\r
\r
-.global vidConvCpyRGB32 @ void *to, void *from, int pixels\r
+.global bgr444_to_rgb32 @ void *to, void *from\r
\r
-vidConvCpyRGB32:\r
+bgr444_to_rgb32:\r
stmfd sp!, {r4-r7,lr}\r
\r
- mov r12, r2, lsr #3 @ repeats\r
+ mov r12, #0x40>>3 @ repeats\r
mov lr, #0x00e00000\r
orr lr, lr, #0x00e0\r
\r
convRGB32_2 r5\r
convRGB32_2 r6\r
convRGB32_2 r7\r
-\r
bgt .loopRGB32\r
\r
- ldmfd sp!, {r4-r7,lr}\r
- bx lr\r
+ ldmfd sp!, {r4-r7,pc}\r
\r
\r
-.global vidConvCpyRGB32sh @ void *to, void *from, int pixels\r
+.global bgr444_to_rgb32_sh @ void *to, void *from\r
\r
-vidConvCpyRGB32sh:\r
+bgr444_to_rgb32_sh:\r
stmfd sp!, {r4-r7,lr}\r
\r
- mov r12, r2, lsr #3 @ repeats\r
+ mov r12, #0x40>>3 @ repeats\r
+ add r0, r0, #0x40*4\r
mov lr, #0x00e00000\r
orr lr, lr, #0x00e0\r
\r
convRGB32_2 r5, 1\r
convRGB32_2 r6, 1\r
convRGB32_2 r7, 1\r
-\r
bgt .loopRGB32sh\r
\r
- ldmfd sp!, {r4-r7,lr}\r
- bx lr\r
-\r
-\r
-.global vidConvCpyRGB32hi @ void *to, void *from, int pixels\r
-\r
-vidConvCpyRGB32hi:\r
- stmfd sp!, {r4-r7,lr}\r
-\r
- mov r12, r2, lsr #3 @ repeats\r
- mov lr, #0x00e00000\r
- orr lr, lr, #0x00e0\r
+ mov r12, #0x40>>3 @ repeats\r
+ sub r1, r1, #0x40*2\r
\r
.loopRGB32hi:\r
ldmia r1!, {r4-r7}\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
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
// 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
return;\r
\r
vidResetMode();\r
+ rendstatus_old = -1;\r
\r
if (PicoOpt & POPT_ALT_RENDERER) {\r
emu_status_msg(" 8bit fast renderer");\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 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
// to 00000000 rrr00000 ggg00000 bbb00000 ...
// TODO: rm when gp2x/emu.c is no longer used
-void vidConvCpyRGB32 (void *to, void *from, int pixels)
+void bgr444_to_rgb32(void *to, void *from)
{
unsigned short *ps = from;
unsigned int *pd = to;
+ int pixels;
- for (; pixels; pixels--, ps++, pd++)
+ for (pixels = 0x40; pixels; pixels--, ps++, pd++)
{
*pd = ((*ps<<20)&0xe00000) | ((*ps<<8)&0xe000) | ((*ps>>4)&0xe0);
*pd |= *pd >> 3;
}
}
-void vidConvCpyRGB32sh(void *to, void *from, int pixels)
+void bgr444_to_rgb32_sh(void *to, void *from)
{
unsigned short *ps = from;
unsigned int *pd = to;
+ int pixels;
- for (; pixels; pixels--, ps++, pd++)
+ pd += 0x40;
+ for (pixels = 0x40; pixels; pixels--, ps++, pd++)
{
*pd = ((*ps<<20)&0xe00000) | ((*ps<<8)&0xe000) | ((*ps>>4)&0xe0);
*pd >>= 1;
*pd |= *pd >> 3;
+ pd[0x40*2] = *pd;
}
-}
-
-void vidConvCpyRGB32hi(void *to, void *from, int pixels)
-{
- unsigned short *ps = from;
- unsigned int *pd = to;
- for (; pixels; pixels--, ps++, pd++)
+ ps -= 0x40;
+ for (pixels = 0x40; pixels; pixels--, ps++, pd++)
{
*pd = ((*ps<<20)&0xe00000) | ((*ps<<8)&0xe000) | ((*ps>>4)&0xe0);
continue;