-// (c) Copyright 2006 notaz, All rights reserved.\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
void vidConvCpyRGB32 (void *to, void *from, int pixels);\r
void vidConvCpyRGB32sh(void *to, void *from, int pixels);\r
void vidConvCpyRGB32hi(void *to, void *from, int pixels);\r
-void vidCpyM2_40col(void *dest, void *src);\r
-void vidCpyM2_32col(void *dest, void *src);\r
-void vidCpyM2_32col_nobord(void *dest, void *src);\r
+void vidcpy_m2(void *dest, void *src, int m32col, int with_32c_border);\r
+void vidcpy_m2_rot(void *dest, void *src, int m32col, int with_32c_border);\r
void spend_cycles(int c); // utility\r
\r
+void rotated_blit8 (void *dst, void *linesx4, int y, int is_32col);\r
+void rotated_blit16(void *dst, void *linesx4, int y, int is_32col);\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
\r
-@ mode2 blitter for 40 cols\r
-.global vidCpyM2_40col @ void *dest, void *src\r
-\r
-vidCpyM2_40col:\r
+@ mode2 blitter\r
+.global vidcpy_m2 @ void *dest, void *src, int m32col, int with_32c_border\r
+vidcpy_m2:\r
stmfd sp!, {r4-r6,lr}\r
\r
mov r12, #224 @ lines\r
+ add r0, r0, #320*8\r
add r1, r1, #8\r
+ mov lr, #0\r
+\r
+ tst r2, r2\r
+ movne lr, #64\r
+ tstne r3, r3\r
+ addne r0, r0, #32\r
\r
-vidCpyM2_40_loop_out:\r
+vidCpyM2_loop_out:\r
mov r6, #10\r
-vidCpyM2_40_loop:\r
+ sub r6, r6, lr, lsr #5 @ -= 2 in 32col mode\r
+vidCpyM2_loop:\r
subs r6, r6, #1\r
- ldmia r1!, {r2-r5}\r
- stmia r0!, {r2-r5}\r
- ldmia r1!, {r2-r5}\r
- stmia r0!, {r2-r5}\r
- bne vidCpyM2_40_loop\r
+ ldmia r1!, {r2-r5}\r
+ stmia r0!, {r2-r5}\r
+ ldmia r1!, {r2-r5}\r
+ stmia r0!, {r2-r5}\r
+ bne vidCpyM2_loop\r
+\r
subs r12,r12,#1\r
+ add r0, r0, lr\r
add r1, r1, #8\r
- bne vidCpyM2_40_loop_out\r
-\r
- ldmfd sp!, {r4-r6,lr}\r
- bx lr\r
+ add r1, r1, lr\r
+ bne vidCpyM2_loop_out\r
\r
+ ldmfd sp!, {r4-r6,pc}\r
\r
-@ mode2 blitter for 32 cols\r
-.global vidCpyM2_32col @ void *dest, void *src\r
\r
-vidCpyM2_32col:\r
- stmfd sp!, {r4-r6,lr}\r
-\r
- mov r12, #224 @ lines\r
+.global vidcpy_m2_rot @ void *dest, void *src, int m32col, int with_32c_border\r
+vidcpy_m2_rot:\r
+ stmfd sp!,{r4-r8,lr}\r
add r1, r1, #8\r
- add r0, r0, #32\r
-\r
-vidCpyM2_32_loop_out:\r
- mov r6, #8\r
-vidCpyM2_32_loop:\r
- subs r6, r6, #1\r
- ldmia r1!, {r2-r5}\r
- stmia r0!, {r2-r5}\r
- ldmia r1!, {r2-r5}\r
- stmia r0!, {r2-r5}\r
- bne vidCpyM2_32_loop\r
- subs r12,r12,#1\r
- add r0, r0, #64\r
- add r1, r1, #8+64\r
- bne vidCpyM2_32_loop_out\r
-\r
- ldmfd sp!, {r4-r6,lr}\r
- bx lr\r
-\r
-\r
-@ mode2 blitter for 32 cols with no borders\r
-.global vidCpyM2_32col_nobord @ void *dest, void *src\r
+ tst r2, r2\r
+ subne r1, r1, #32 @ adjust\r
+\r
+ mov r4, r0\r
+ mov r5, r1\r
+ mov r6, r2\r
+ mov r7, #8+4\r
+\r
+vidcpy_m2_rot_loop:\r
+ @ a bit lame but oh well..\r
+ mov r0, r4\r
+ mov r1, r5\r
+ mov r2, r7\r
+ mov r3, r6\r
+ mov r8, #328\r
+ adr lr, after_rot_blit8\r
+ stmfd sp!,{r4-r8,lr}\r
+ b rotated_blit8_2\r
+\r
+after_rot_blit8:\r
+ add r5, r5, #328*4\r
+ add r7, r7, #4\r
+ cmp r7, #224+8+4\r
+ ldmgefd sp!,{r4-r8,pc}\r
+ b vidcpy_m2_rot_loop\r
+\r
+\r
+.global rotated_blit8 @ void *dst, void *linesx4, u32 y, int is_32col\r
+rotated_blit8:\r
+ stmfd sp!,{r4-r8,lr}\r
+ mov r8, #320\r
+\r
+rotated_blit8_2:\r
+ add r0, r0, #(240*320)\r
+ sub r0, r0, #(240+4) @ y starts from 4\r
+ add r0, r0, r2\r
+\r
+ tst r3, r3\r
+ subne r0, r0, #(240*32)\r
+ addne r1, r1, #32\r
+ movne lr, #256/4\r
+ moveq lr, #320/4\r
+\r
+rotated_blit_loop8:\r
+ mov r6, r1\r
+ ldr r2, [r6], r8\r
+ ldr r3, [r6], r8\r
+ ldr r4, [r6], r8\r
+ ldr r5, [r6], r8\r
+\r
+ mov r6, r2, lsl #24\r
+ mov r6, r6, lsr #8\r
+ orr r6, r6, r3, lsl #24\r
+ mov r6, r6, lsr #8\r
+ orr r6, r6, r4, lsl #24\r
+ mov r6, r6, lsr #8\r
+ orr r6, r6, r5, lsl #24\r
+ str r6, [r0], #-240\r
+\r
+ and r6, r3, #0xff00\r
+ and r7, r2, #0xff00\r
+ orr r6, r6, r7, lsr #8\r
+ and r7, r4, #0xff00\r
+ orr r6, r6, r7, lsl #8\r
+ and r7, r5, #0xff00\r
+ orr r6, r6, r7, lsl #16\r
+ str r6, [r0], #-240\r
+\r
+ and r6, r4, #0xff0000\r
+ and r7, r2, #0xff0000\r
+ orr r6, r6, r7, lsr #16\r
+ and r7, r3, #0xff0000\r
+ orr r6, r6, r7, lsr #8\r
+ and r7, r5, #0xff0000\r
+ orr r6, r6, r7, lsl #8\r
+ str r6, [r0], #-240\r
+\r
+ mov r6, r5, lsr #24\r
+ mov r6, r6, lsl #8\r
+ orr r6, r6, r4, lsr #24\r
+ mov r6, r6, lsl #8\r
+ orr r6, r6, r3, lsr #24\r
+ mov r6, r6, lsl #8\r
+ orr r6, r6, r2, lsr #24\r
+ str r6, [r0], #-240\r
+\r
+ subs lr, lr, #1\r
+ add r1, r1, #4\r
+ bne rotated_blit_loop8\r
+\r
+ ldmfd sp!,{r4-r8,pc}\r
+\r
+\r
+@ input: r2-r5\r
+@ output: r7,r8\r
+@ trash: r6\r
+.macro rb_line_low\r
+ mov r6, r2, lsl #16\r
+ mov r7, r3, lsl #16\r
+ orr r7, r7, r6, lsr #16\r
+ mov r6, r4, lsl #16\r
+ mov r8, r5, lsl #16\r
+ orr r8, r8, r6, lsr #16\r
+.endm\r
\r
-vidCpyM2_32col_nobord:\r
- stmfd sp!, {r4-r6,lr}\r
+.macro rb_line_hi\r
+ mov r6, r2, lsr #16\r
+ mov r7, r3, lsr #16\r
+ orr r7, r6, r7, lsl #16\r
+ mov r6, r4, lsr #16\r
+ mov r8, r5, lsr #16\r
+ orr r8, r6, r8, lsl #16\r
+.endm\r
\r
- mov r12, #224 @ lines\r
+.global rotated_blit16 @ void *dst, void *linesx4, u32 y, int is_32col\r
+rotated_blit16:\r
+ stmfd sp!,{r4-r8,lr}\r
+\r
+ add r0, r0, #(240*320)*2\r
+ sub r0, r0, #(240+4)*2 @ y starts from 4\r
+ add r0, r0, r2, lsl #1\r
+\r
+ tst r3, r3\r
+ subne r0, r0, #(240*32)*2\r
+ addne r1, r1, #32*2\r
+ movne lr, #256/4\r
+ moveq lr, #320/4\r
+\r
+rotated_blit_loop16:\r
+ ldr r2, [r1, #320*0*2]\r
+ ldr r3, [r1, #320*1*2]\r
+ ldr r4, [r1, #320*2*2]\r
+ ldr r5, [r1, #320*3*2]\r
+ rb_line_low\r
+ stmia r0, {r7,r8}\r
+ sub r0, r0, #240*2\r
+ rb_line_hi\r
+ stmia r0, {r7,r8}\r
+ sub r0, r0, #240*2\r
+\r
+ ldr r2, [r1, #320*0*2+4]\r
+ ldr r3, [r1, #320*1*2+4]\r
+ ldr r4, [r1, #320*2*2+4]\r
+ ldr r5, [r1, #320*3*2+4]\r
+ rb_line_low\r
+ stmia r0, {r7,r8}\r
+ sub r0, r0, #240*2\r
+ rb_line_hi\r
+ stmia r0, {r7,r8}\r
+ sub r0, r0, #240*2\r
+\r
+ subs lr, lr, #1\r
add r1, r1, #8\r
- b vidCpyM2_32_loop_out\r
+ bne rotated_blit_loop16\r
+\r
+ ldmfd sp!,{r4-r8,pc}\r
\r
\r
.global spend_cycles @ c\r
\r
bx lr\r
\r
-\r
\r
/* always using built-in font */\r
\r
-#define mk_text_out(name, type, val) \\r
+#define mk_text_out(name, type, val, topleft, step_x, step_y) \\r
void name(int x, int y, const char *text) \\r
{ \\r
int i, l, len = strlen(text); \\r
- type *screen = (type *)g_screen_ptr + x + y * g_screen_width; \\r
+ type *screen = (type *)(topleft) + x * step_x + y * step_y; \\r
\\r
- for (i = 0; i < len; i++, screen += 8) \\r
+ for (i = 0; i < len; i++, screen += 8 * step_x) \\r
{ \\r
for (l = 0; l < 8; l++) \\r
{ \\r
unsigned char fd = fontdata8x8[text[i] * 8 + l];\\r
- type *s = screen + l * g_screen_width; \\r
- if (fd&0x80) s[0] = val; \\r
- if (fd&0x40) s[1] = val; \\r
- if (fd&0x20) s[2] = val; \\r
- if (fd&0x10) s[3] = val; \\r
- if (fd&0x08) s[4] = val; \\r
- if (fd&0x04) s[5] = val; \\r
- if (fd&0x02) s[6] = val; \\r
- if (fd&0x01) s[7] = val; \\r
+ type *s = screen + l * step_y; \\r
+ if (fd&0x80) s[step_x * 0] = val; \\r
+ if (fd&0x40) s[step_x * 1] = val; \\r
+ if (fd&0x20) s[step_x * 2] = val; \\r
+ if (fd&0x10) s[step_x * 3] = val; \\r
+ if (fd&0x08) s[step_x * 4] = val; \\r
+ if (fd&0x04) s[step_x * 5] = val; \\r
+ if (fd&0x02) s[step_x * 6] = val; \\r
+ if (fd&0x01) s[step_x * 7] = val; \\r
} \\r
} \\r
}\r
\r
-mk_text_out(emu_textOut8, unsigned char, 0xf0)\r
-mk_text_out(emu_textOut16, unsigned short, 0xffff)\r
+mk_text_out(emu_text_out8, unsigned char, 0xf0, g_screen_ptr, 1, g_screen_width)\r
+mk_text_out(emu_text_out16, unsigned short, 0xffff, g_screen_ptr, 1, g_screen_width)\r
+mk_text_out(emu_text_out8_rot, unsigned char, 0xf0,\r
+ (char *)g_screen_ptr + (g_screen_width - 1) * g_screen_height, -g_screen_height, 1)\r
+mk_text_out(emu_text_out16_rot, unsigned short, 0xffff,\r
+ (short *)g_screen_ptr + (g_screen_width - 1) * g_screen_height, -g_screen_height, 1)\r
\r
#undef mk_text_out\r
\r
#define EOPT_CONFIRM_LOAD (1<<11)
#define EOPT_A_SN_GAMMA (1<<12)
#define EOPT_PSYNC (1<<13)
+#define EOPT_GIZ_SCANLN (1<<14)
+#define EOPT_GIZ_DBLBUF (1<<15)
+#define EOPT_VSYNC_MODE (1<<16)
+#define EOPT_SHOW_RTC (1<<17)
+#define EOPT_NO_FRMLIMIT (1<<18)
+#define EOPT_WIZ_TEAR_FIX (1<<19)
enum {
EOPT_SCALE_NONE = 0,
};
typedef struct _currentConfig_t {
- // char lastRomFile[512];
- int EmuOpt; // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves,
- // mmuhack, no_save_cfg_on_exit, <unused>, 16_bit_mode
- // craigix_ram, confirm_save, show_cd_leds, confirm_load
- // A_SNs_gamma, perfect_vsync, giz_scanlines, giz_dblbuff
- // vsync_mode, show_clock, no_frame_limitter
- int s_PicoOpt; // for old cfg files only
+ int EmuOpt;
+ int s_PicoOpt;
int s_PsndRate;
int s_PicoRegion;
int s_PicoAutoRgnOrder;
int emu_check_save_file(int slot);
void emu_setSaveStateCbs(int gz);
+void emu_text_out8 (int x, int y, const char *text);
+void emu_text_out16(int x, int y, const char *text);
+void emu_text_out8_rot (int x, int y, const char *text);
+void emu_text_out16_rot(int x, int y, const char *text);
+
void emu_make_path(char *buff, const char *end, int size);
void emu_update_input(void);
-void emu_textOut8 (int x, int y, const char *text);
-void emu_textOut16(int x, int y, const char *text);
void emu_get_game_name(char *str150);
void emu_set_fastforward(int set_on);
int emu_cd_check(int *pregion, char *fname_in);
{\r
mee_cust ("Renderer", MA_OPT_RENDERER, mh_opt_render, mgn_opt_renderer),\r
mee_range_cust("Scaling", MA_OPT_SCALING, currentConfig.scaling, 0, 3, mgn_opt_scaling),\r
+ mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX),\r
mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma),\r
mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA),\r
mee_onoff ("Perfect vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_PSYNC),\r
MA_OPT_LOADCFG,
MA_OPT_INTERLACED, /* giz */
MA_OPT_ROTATION, /* uiq */
+ MA_OPT_TEARING_FIX, /* wiz */
MA_OPT2_GAMMA,
MA_OPT2_A_SN_GAMMA,
MA_OPT2_DBLBUFF, /* giz */
#include "../common/arm_utils.h"\r
#include "../common/menu.h"\r
#include "../common/emu.h"\r
+#include "../common/input.h"\r
#include "../../pico/pico_int.h"\r
#include "../../pico/sound/ym2612.h"\r
#include "../../pico/sound/mix.h"\r
if (crashed_940)\r
{\r
unsigned char ucData[1024];\r
- int nRead, i, nLen = 0;\r
+ int nRead, nLen = 0;\r
char binpath[512];\r
FILE *fp;\r
\r
text_out16(10, 100, "failed to open required file:");\r
text_out16(10, 110, CODE940_FILE);\r
gp2x_video_flip2();\r
+ in_menu_wait(PBTN_MOK|PBTN_MBACK, 100);\r
printf("failed to open %s\n", binpath);\r
exit(1);\r
}\r
\r
static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
static struct timeval noticeMsgTime = { 0, 0 }; // when started showing\r
-static int osd_fps_x;\r
-static int gp2x_old_gamma = 100;\r
static char noticeMsg[40];\r
static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];\r
unsigned char *PicoDraw2FB = PicoDraw2FB_;\r
+static int osd_fps_x;\r
\r
+extern void *gp2x_screens[4];\r
\r
void plat_status_msg(const char *format, ...)\r
{\r
gp2x_soc_t soc;\r
\r
memset(&defaultConfig, 0, sizeof(defaultConfig));\r
- defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS | 0x600; // | <- confirm_save, cd_leds\r
+ defaultConfig.EmuOpt = 0x9d | EOPT_RAM_TIMINGS|EOPT_CONFIRM_SAVE|EOPT_EN_CD_LEDS;\r
defaultConfig.s_PicoOpt = 0x0f | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES;\r
defaultConfig.s_PsndRate = 44100;\r
defaultConfig.s_PicoRegion = 0; // auto\r
soc = soc_detect();\r
if (soc == SOCID_MMSP2)\r
defaultConfig.s_PicoOpt |= POPT_EXT_FM;\r
+ else if (soc == SOCID_POLLUX)\r
+ defaultConfig.EmuOpt |= EOPT_WIZ_TEAR_FIX;\r
}\r
\r
-static void osd_text(int x, int y, const char *text)\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
- if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\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_textOut8(x, y, text);\r
- } else {\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_textOut16(x, y, text);\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 osd_text8_rot(int x, int y, const char *text)\r
+{\r
+ int len = strlen(text) * 8;\r
+ char *p = (char *)g_screen_ptr + 240*(320-x) + y;\r
+\r
+ while (len--) {\r
+ memset(p, 0xe0, 8);\r
+ p -= 240;\r
}\r
+\r
+ emu_text_out8_rot(x, y, text);\r
+}\r
+\r
+static void osd_text16_rot(int x, int y, const char *text)\r
+{\r
+ int len = strlen(text) * 8;\r
+ short *p = (short *)g_screen_ptr + 240*(320-x) + y;\r
+\r
+ while (len--) {\r
+ memset(p, 0, 8*2);\r
+ p -= 240;\r
+ }\r
+\r
+ emu_text_out16_rot(x, y, text);\r
}\r
\r
static void draw_cd_leds(void)\r
{\r
- int old_reg;\r
- old_reg = Pico_mcd->s68k_regs[0];\r
+ int led_reg, pitch, scr_offs, led_offs;\r
+ led_reg = Pico_mcd->s68k_regs[0];\r
+\r
+ if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {\r
+ pitch = 240;\r
+ led_offs = -pitch * 6;\r
+ scr_offs = pitch * (320 - 4);\r
+ } else {\r
+ pitch = 320;\r
+ led_offs = 4;\r
+ scr_offs = pitch * 2 + 4;\r
+ }\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 col_g = (old_reg & 2) ? 0xc0c0c0c0 : 0xe0e0e0e0;\r
- unsigned int col_r = (old_reg & 1) ? 0xd0d0d0d0 : 0xe0e0e0e0;\r
- *(unsigned int *)((char *)g_screen_ptr + 320*2+ 4) =\r
- *(unsigned int *)((char *)g_screen_ptr + 320*3+ 4) =\r
- *(unsigned int *)((char *)g_screen_ptr + 320*4+ 4) = col_g;\r
- *(unsigned int *)((char *)g_screen_ptr + 320*2+12) =\r
- *(unsigned int *)((char *)g_screen_ptr + 320*3+12) =\r
- *(unsigned int *)((char *)g_screen_ptr + 320*4+12) = col_r;\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 *p = (unsigned int *)((short *)g_screen_ptr + 320*2+4);\r
- unsigned int col_g = (old_reg & 2) ? 0x06000600 : 0;\r
- unsigned int col_r = (old_reg & 1) ? 0xc000c000 : 0;\r
- *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += 320/2 - 12/2;\r
- *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r; p += 320/2 - 12/2;\r
- *p++ = col_g; *p++ = col_g; p+=2; *p++ = col_r; *p++ = col_r;\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 void draw_pico_ptr(void)\r
{\r
unsigned short *p = (unsigned short *)g_screen_ptr;\r
+ int x, y, pitch = 320;\r
\r
// only if pen enabled and for 16bit modes\r
- if (pico_inp_mode == 0 || (PicoOpt&0x10) || !(currentConfig.EmuOpt&0x80)) return;\r
+ if (pico_inp_mode == 0 || (PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP))\r
+ return;\r
\r
- if (!(Pico.video.reg[12]&1) && !(PicoOpt&POPT_DIS_32C_BORDER))\r
- p += 32;\r
+ x = pico_pen_x + PICO_PEN_ADJUST_X;\r
+ y = pico_pen_y + PICO_PEN_ADJUST_Y;\r
+ if (!(Pico.video.reg[12]&1) && !(PicoOpt & POPT_DIS_32C_BORDER))\r
+ x += 32;\r
\r
- p += 320 * (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
+ if (EOPT_WIZ_TEAR_FIX) {\r
+ pitch = 240;\r
+ p += (319 - x) * pitch + y;\r
+ } else\r
+ p += x + y * pitch;\r
+\r
+ p[0] ^= 0xffff;\r
+ p[pitch-1] ^= 0xffff;\r
+ p[pitch] ^= 0xffff;\r
+ p[pitch+1] ^= 0xffff;\r
+ p[pitch*2] ^= 0xffff;\r
}\r
\r
static int EmuScanBegin16(unsigned int num)\r
return 0;\r
}\r
\r
+/* rot thing for Wiz */\r
+static unsigned char __attribute__((aligned(4))) rot_buff[320*4*2];\r
+\r
+static int EmuScanBegin16_rot(unsigned int num)\r
+{\r
+ DrawLineDest = rot_buff + (num & 3) * 320 * 2;\r
+ return 0;\r
+}\r
+\r
+static int EmuScanEnd16_rot(unsigned int num)\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
+\r
+static int EmuScanBegin8_rot(unsigned int num)\r
+{\r
+ DrawLineDest = rot_buff + (num & 3) * 320;\r
+ return 0;\r
+}\r
+\r
+static int EmuScanEnd8_rot(unsigned int num)\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) = NULL;\r
+static void (*vidcpyM2)(void *dest, void *src, int m32col, int with_32c_border) = NULL;\r
\r
static void blit(const char *fps, const char *notice)\r
{\r
if (PicoRead16Hook == PicoSVPRead16)\r
memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328);\r
// do actual copy\r
- vidCpyM2((unsigned char *)g_screen_ptr+320*8, PicoDraw2FB+328*8);\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
{\r
draw_pico_ptr();\r
\r
gp2x_video_flip();\r
-\r
- if (!(PicoOpt & POPT_ALT_RENDERER)) {\r
- if (!(Pico.video.reg[1]&8)) {\r
- if (currentConfig.EmuOpt & EOPT_16BPP)\r
- DrawLineDest = (unsigned short *) g_screen_ptr + 320*8;\r
- else\r
- DrawLineDest = (unsigned char *) g_screen_ptr + 320*8;\r
- } else {\r
- DrawLineDest = g_screen_ptr;\r
- }\r
- }\r
}\r
\r
// clears whole screen or just the notice area (in all buffers)\r
static void clearArea(int full)\r
{\r
- if ((PicoOpt&0x10)||!(currentConfig.EmuOpt&0x80)) {\r
+ int is_8bit = (PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP);\r
+ if (!full && (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX)) {\r
+ /* ugh.. */\r
+ int i, u, *p;\r
+ if (is_8bit) {\r
+ for (i = 0; i < 4; i++) {\r
+ p = (int *)gp2x_screens[i] + (240-8) / 4;\r
+ for (u = 320; u > 0; u--, p += 240/4)\r
+ p[0] = p[1] = 0xe0e0e0e0;\r
+ }\r
+ } else {\r
+ for (i = 0; i < 4; i++) {\r
+ p = (int *)gp2x_screens[i] + (240-8)*2 / 4;\r
+ for (u = 320; u > 0; u--, p += 240*2/4)\r
+ p[0] = p[1] = p[2] = p[3] = 0;\r
+ }\r
+ }\r
+ return;\r
+ }\r
+\r
+ if (is_8bit) {\r
// 8-bit renderers\r
if (full) gp2x_memset_all_buffers(0, 0xe0, 320*240);\r
else gp2x_memset_all_buffers(320*232, 0xe0, 320*8);\r
\r
static void vidResetMode(void)\r
{\r
+ PicoScanEnd = NULL;\r
+\r
if (PicoOpt & POPT_ALT_RENDERER) {\r
- gp2x_video_changemode(8);\r
- } else if (currentConfig.EmuOpt & EOPT_16BPP) {\r
- gp2x_video_changemode(16);\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
- PicoScanBegin = EmuScanBegin16;\r
- } else {\r
- gp2x_video_changemode(8);\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
- PicoScanBegin = EmuScanBegin8;\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
}\r
+\r
if ((PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP)) {\r
// setup pal for 8-bit modes\r
localPal[0xc0] = 0x0000c000; // MCD LEDs\r
gp2x_video_flip();\r
}\r
Pico.m.dirtyPal = 1;\r
+\r
// reset scaling\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
\r
PicoDrawSetColorFormat(1);\r
PicoScanBegin = EmuScanBegin16;\r
+ PicoScanEnd = NULL;\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+320*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 pemu_loop(void)\r
{\r
- static int gp2x_old_clock = -1, EmuOpt_old = 0;\r
+ static int gp2x_old_clock = -1, EmuOpt_old = 0, pal_old = 0;\r
+ static int gp2x_old_gamma = 100;\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
printf("updated gamma to %i, A_SN's curve: %i\n", currentConfig.gamma, !!(currentConfig.EmuOpt&0x1000));\r
}\r
\r
- if ((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_PSYNC) {\r
+ if (((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_PSYNC) || Pico.m.pal != pal_old) {\r
if (currentConfig.EmuOpt & EOPT_PSYNC)\r
set_lcd_custom_rate(Pico.m.pal);\r
else\r
gp2x_make_fb_bufferable(currentConfig.EmuOpt & EOPT_MMUHACK);\r
\r
EmuOpt_old = currentConfig.EmuOpt;\r
+ pal_old = Pico.m.pal;\r
fpsbuff[0] = 0;\r
\r
// make sure we are in correct mode\r
if (PicoAHW & PAHW_MCD) PicoCDBufferInit();\r
\r
// calc vsync offset to sync timing code with vsync\r
- if (currentConfig.EmuOpt&0x2000) {\r
+ if (currentConfig.EmuOpt & EOPT_PSYNC) {\r
gettimeofday(&tval, 0);\r
gp2x_video_wait_vsync();\r
gettimeofday(&tval, 0);\r
{\r
int scalex = 320;\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
+ if (!(modes & 4) && (PicoOpt & POPT_DIS_32C_BORDER)) {\r
+ scalex = 256;\r
+ osd_fps_x = OSD_FPS_X - 64;\r
}\r
/* want vertical scaling and game is not in 240 line mode */\r
if (currentConfig.scaling == EOPT_SCALE_HW_HV && !(modes&8))\r
SRam.changed = 0;\r
}\r
\r
- // if in 8bit mode, generate 16bit image for menu background\r
- if ((PicoOpt & POPT_ALT_RENDERER) || !(currentConfig.EmuOpt & EOPT_16BPP))\r
- pemu_forced_frame(POPT_EN_SOFTSCALE);\r
+ // do menu background to be sure it's right\r
+ pemu_forced_frame(POPT_EN_SOFTSCALE);\r
}\r
\r
const char *plat_get_credits(void)\r
{ BTN_A, IN_BINDTYPE_PLAYER12, 6 }, /* A */
{ BTN_START, IN_BINDTYPE_PLAYER12, 7 },
{ BTN_SELECT, IN_BINDTYPE_EMU, PEVB_MENU },
- { BTN_Y, IN_BINDTYPE_EMU, PEVB_SWITCH_RND },
+// { BTN_Y, IN_BINDTYPE_EMU, PEVB_SWITCH_RND },
{ BTN_L, IN_BINDTYPE_EMU, PEVB_STATE_SAVE },
{ BTN_R, IN_BINDTYPE_EMU, PEVB_STATE_LOAD },
{ BTN_VOL_UP, IN_BINDTYPE_EMU, PEVB_VOL_UP },
memset(g_screen_ptr, 0, 320*240*2);
}
- // copy to buffer2
+ // 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);
+ memset(gp2x_screens[1], 0, 320*240*2);
+ gp2x_video_flip2();
+ gp2x_video_wait_vsync();
+ gp2x_video_wait_vsync();
+
// switch to 16bpp
gp2x_video_changemode_ll(16);
gp2x_video_RGB_setscaling(0, 320, 240);
- gp2x_video_flip2();
}
void plat_video_menu_begin(void)
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;
/* SoC specific functions */
extern void (*gp2x_video_flip)(void);
extern void (*gp2x_video_flip2)(void);
+/* negative bpp means rotated mode (for Wiz) */
extern void (*gp2x_video_changemode_ll)(int bpp);
extern void (*gp2x_video_setpalette)(int *pal, int len);
extern void (*gp2x_video_RGB_setscaling)(int ln_offs, int W, int H);
static char cpuclk_was_changed = 0;
static unsigned short memtimex_old[2];
static unsigned int pllsetreg0;
+static int last_pal_setting = 0;
/* video stuff */
static void gp2x_video_changemode_ll_(int bpp)
{
+ static int prev_bpp = 0;
int code = 0, bytes = 2;
+ int rot_cmd[2] = { 0, 0 };
unsigned int r;
- switch (bpp)
+ int ret;
+
+ if (bpp == prev_bpp)
+ return;
+ prev_bpp = bpp;
+
+ printf("changemode: %dbpp rot=%d\n", abs(bpp), bpp < 0);
+
+ /* negative bpp means rotated mode */
+ rot_cmd[0] = (bpp < 0) ? 6 : 5;
+ ret = ioctl(fbdev, _IOW('D', 90, int[2]), rot_cmd);
+ if (ret < 0)
+ perror("rot ioctl failed");
+ memregl[0x4004>>2] = (bpp < 0) ? 0x013f00ef : 0x00ef013f;
+ memregl[0x4000>>2] |= 1 << 3;
+
+ /* the above ioctl resets LCD timings, so set them here */
+ set_lcd_custom_rate(last_pal_setting);
+
+ switch (abs(bpp))
{
case 8:
code = 0x443a;
break;
default:
- printf("unhandled bpp request: %d\n", bpp);
+ printf("unhandled bpp request: %d\n", abs(bpp));
return;
}
memregl[0x405c>>2] = bytes;
- memregl[0x4060>>2] = bytes * 320;
+ memregl[0x4060>>2] = bytes * (bpp < 0 ? 240 : 320);
r = memregl[0x4058>>2];
r = (r & 0xffff) | (code << 16) | 0x10;
snprintf(buff, sizeof(buff), "POLLUX_LCD_TIMINGS_%s", is_pal ? "PAL" : "NTSC");
pollux_set_fromenv(buff);
+ last_pal_setting = is_pal;
}
static void unset_lcd_custom_rate_(void)
/* switch to default fb mem, turn portrait off */
memregl[0x406C>>2] = fb_paddr[0];
memregl[0x4058>>2] |= 0x10;
-// wiz_lcd_set_portrait(0);
close(fbdev);
gp2x_video_changemode_ll_(16);
-#define VERSION "1.52"\r
+#define VERSION "1.55"\r
\r
p = (int *) ((unsigned char *) g_screen_ptr+x+g_screen_width*(y+h));\r
for (i = len; i; i--, p++) *p = 0xe0e0e0e0;\r
}\r
- emu_textOut8(x, y, text);\r
+ emu_text_out8(x, y, text);\r
} else {\r
int *p, i, h;\r
x &= ~1; // align x\r
p = (int *) ((unsigned short *) g_screen_ptr+x+g_screen_width*(y+h));\r
for (i = len; i; i--, p++) *p = 0;//(*p>>2)&0x39e7;\r
}\r
- textOut16(x, y, text);\r
+ text_out16(x, y, text);\r
}\r
}\r
\r
memset32_uncached(p, 0, len);
}
if (is_active) { tmp = psp_screen; psp_screen = screen; } // nasty pointer tricks
- emu_textOut16(x, 264, text);
+ emu_text_out16(x, 264, text);
if (is_active) psp_screen = tmp;
}
p = (int *) ((int)p & ~3); // align
memset32_uncached(p, 0, len);
}
- emu_textOut16(2, 256, text);
+ emu_text_out16(2, 256, text);
}
#endif