\r
PicoDrawUpdateHighPal();\r
\r
- if ((PicoIn.AHW & PAHW_SMS) && (Pico.m.hardware & 0x3) == 0x3)\r
- len = 160;\r
- else if (Pico.video.reg[12]&1) len = 320;\r
- else len = 256;\r
+ len = 256;\r
+ if ((PicoIn.AHW & PAHW_SMS) && (Pico.m.hardware & (PMS_HW_GG|PMS_HW_LCD)) == (PMS_HW_GG|PMS_HW_LCD))\r
+ len = 160;\r
+ else if (!(PicoIn.AHW & PAHW_SMS) && (Pico.video.reg[12]&1))\r
+ len = 320;\r
+ if ((PicoIn.AHW & PAHW_SMS) && (Pico.video.reg[0] & 0x20) && len == 256)\r
+ len -= 8, ps += 8;\r
\r
if ((*est->PicoOpt & POPT_EN_SOFTSCALE) && len < 320) {\r
- if (len == 256) {\r
+ if (len >= 240 && len <= 256) {\r
+ pd += (256-len)>>1;\r
switch (PicoIn.filter) {\r
case 3: h_upscale_bl4_4_5(pd, 320, ps, 256, len, f_pal); break;\r
case 2: h_upscale_bl2_4_5(pd, 320, ps, 256, len, f_pal); break;\r
Pico.m.dirtyPal = 2;\r
}\r
\r
- if ((PicoIn.AHW & PAHW_SMS) && (Pico.m.hardware & 0x3) == 0x3)\r
- len = 160;\r
- else if (Pico.video.reg[12]&1) len = 320;\r
- else len = 256;\r
+ len = 256;\r
+ if ((PicoIn.AHW & PAHW_SMS) && (Pico.m.hardware & (PMS_HW_GG|PMS_HW_LCD)) == (PMS_HW_GG|PMS_HW_LCD))\r
+ len = 160;\r
+ else if (!(PicoIn.AHW & PAHW_SMS) && (Pico.video.reg[12]&1))\r
+ len = 320;\r
+ if ((PicoIn.AHW & PAHW_SMS) && (Pico.video.reg[0] & 0x20) && len == 256)\r
+ len -= 8, ps += 8;\r
\r
if (DrawLineDestIncrement == 0)\r
pd = est->HighCol+8;\r
if (!sh && (est->rendstatus & PDRAW_SONIC_MODE))\r
pal = est->SonicPalCount*0x40;\r
// Smoothing can't be used with CLUT, hence it's always Nearest Neighbour.\r
- if (len == 256)\r
+ if (len >= 240)\r
// use reverse version since src and dest ptr may be the same.\r
rh_upscale_nn_4_5(pd, 320, ps, 256, len, f_or);\r
else\r
ldr r4, [r5]\r
ldr r7, [r5, #OFS_PicoIn_AHW-OFS_PicoIn_opt]\r
ldrb r12,[r8, #OFS_Pico_video_reg+12]\r
+ ldrb r6, [r8, #OFS_Pico_video_reg+0]\r
ldr r2, [r8, #OFS_Pico_m_hardware]\r
add r1, r1, #8\r
\r
- tst r7, #0x10\r
- beq .fl_no20colRGB555\r
+ tst r7, #0x10 @ SMS ?\r
+ beq .fl_noSMS\r
+\r
and r7, r2, #0x3\r
cmp r7, #0x3 @ Game Gear, LCD?\r
- bne .fl_no20colRGB555\r
+ beq .fl_gg20col\r
+\r
+ tst r6, #0x20\r
+ movne r2, #248/8 @ len = 248\r
+ addne r1, r1, #8 @ ps += 8\r
+ moveq r2, #256/8 @ len = 256\r
+ b .fl_check32scaling\r
\r
+.fl_gg20col:\r
mov r2, #160/8 @ len = 160\r
tst r4, #0x4000 @ EN_SOFTSCALE?\r
bne .fl_20scale_RGB555 @ scale 160->320\r
- beq .fl_checkborder\r
+ b .fl_checkborder\r
\r
-.fl_no20colRGB555:\r
+.fl_noSMS:\r
tst r12, #1 @ h32?\r
movne r2, #320/8 @ len = 320\r
- bne .fl_no32colRGB555\r
- moveq r2, #256/8 @ len = 256\r
+ bne .fl_40colRGB555\r
+ mov r2, #256/8 @ len = 256\r
+\r
+.fl_check32scaling:\r
tst r4, #0x4000 @ EN_SOFTSCALE?\r
+ rsbne r7, r2, #256/8\r
+ addne r0, r0, r7, lsl #3 @ pd += (256-len)>>1\r
bne .fl_32scale_RGB555 @ scale 256->320\r
\r
.fl_checkborder:\r
tst r4, #0x0100 @ DIS_32C_BORDER?\r
- rsbeq r4, r2, #320/8 @ pd += (320-len)/2\r
- addeq r0, r0, r4, lsl #3\r
+ rsbeq r7, r2, #320/8 @ pd += (320-len)/2\r
+ addeq r0, r0, r7, lsl #3\r
\r
-.fl_no32colRGB555:\r
+.fl_40colRGB555:\r
#ifdef UNALIGNED_DRAWLINEDEST\r
@ this is basically for Gizmondo, which has unaligned odd lines in the framebuffer\r
tst r0, #2\r
cmp r0, r1\r
bhs blockcpyhi\r
\r
- mov r2, r2, lsr #4\r
+ subs r2, r2, #16\r
+ blt blockcpy2\r
blockcpy_loop:\r
ldmia r1!, {r3-r5,r12}\r
- subs r2, r2, #1\r
+ subs r2, r2, #16\r
stmia r0!, {r3-r5,r12}\r
- bne blockcpy_loop\r
+ bge blockcpy_loop\r
+\r
+blockcpy2:\r
+ adds r2, r2, #16-4\r
+ ldmltfd sp!, {r4,r5}\r
+ bxlt lr\r
+\r
+blockcpy_loop2:\r
+ ldr r3, [r1], #4\r
+ subs r2, r2, #4\r
+ str r3, [r0], #4\r
+ bge blockcpy_loop2\r
+\r
ldmfd sp!, {r4,r5}\r
bx lr\r
\r
blockcpyhi:\r
add r0, r0, r2\r
add r1, r1, r2\r
- mov r2, r2, lsr #4\r
+\r
+ subs r2, r2, #16\r
+ blt blockcpyhi2\r
blockcpyhi_loop:\r
ldmdb r1!, {r3-r5,r12}\r
- subs r2, r2, #1\r
+ subs r2, r2, #16\r
stmdb r0!, {r3-r5,r12}\r
- bne blockcpyhi_loop\r
+ bge blockcpyhi_loop\r
+\r
+blockcpyhi2:\r
+ adds r2, r2, #16-4\r
+ ldmltfd sp!, {r4,r5}\r
+ bxlt lr\r
+\r
+blockcpyhi_loop2:\r
+ ldr r3, [r1, #-4]!\r
+ subs r2, r2, #4\r
+ str r3, [r0, #-4]!\r
+ bge blockcpyhi_loop2\r
+\r
ldmfd sp!, {r4,r5}\r
bx lr\r
\r
cmp r0, r1\r
bhs blockcpyhi_or\r
\r
- mov r2, r2, lsr #4\r
+ subs r2, r2, #16\r
+ blt blockcpy_or2\r
blockcpy_loop_or:\r
ldmia r1!, {r4-r6,r12}\r
- subs r2, r2, #1\r
+ subs r2, r2, #16\r
orr r4, r4, r3\r
orr r5, r5, r3\r
orr r6, r6, r3\r
orr r12,r12,r3\r
stmia r0!, {r4-r6,r12}\r
- bne blockcpy_loop_or\r
+ bge blockcpy_loop_or\r
+\r
+blockcpy_or2:\r
+ adds r2, r2, #16-4\r
+ ldmltfd sp!, {r4-r6}\r
+ bxlt lr\r
+\r
+blockcpy_loop_or2:\r
+ ldr r4, [r1], #4\r
+ subs r2, r2, #4\r
+ orr r4, r4, r3\r
+ str r4, [r0], #4\r
+ bge blockcpy_loop_or2\r
+\r
ldmfd sp!, {r4-r6}\r
bx lr\r
\r
blockcpyhi_or:\r
add r0, r0, r2\r
add r1, r1, r2\r
- mov r2, r2, lsr #4\r
+\r
+ subs r2, r2, #16\r
+ blt blockcpyhi_or2\r
blockcpyhi_loop_or:\r
ldmdb r1!, {r4-r6,r12}\r
- subs r2, r2, #1\r
+ subs r2, r2, #16\r
orr r4, r4, r3\r
orr r5, r5, r3\r
orr r6, r6, r3\r
orr r12,r12,r3\r
stmdb r0!, {r4-r6,r12}\r
- bne blockcpyhi_loop_or\r
+ bge blockcpyhi_loop_or\r
+\r
+blockcpyhi_or2:\r
+ adds r2, r2, #16-4\r
+ ldmltfd sp!, {r4-r6}\r
+ bxlt lr\r
+\r
+blockcpyhi_loop_or2:\r
+ ldr r4, [r1, #-4]!\r
+ subs r2, r2, #4\r
+ orr r4, r4, r3\r
+ str r4, [r0, #-4]!\r
+ bge blockcpyhi_loop_or2\r
+\r
ldmfd sp!, {r4-r6}\r
bx lr\r
\r
{
struct PicoVideo *pv = &Pico.video;
u8 *sat;
- int xoff = 8; // relative to HighCol, which is (screen - 8)
+ int xoff = line_offset;
int sprite_base, addr_mask;
int zoomed = pv->reg[1] & 0x1; // zoomed sprites, e.g. Earthworm Jim
unsigned int pack;
int i, s, h, m;
if (pv->reg[0] & 8)
- xoff = 0;
- xoff += line_offset;
+ xoff -= 8; // sprite shift
if ((Pico.m.hardware & (PMS_HW_GG|PMS_HW_LCD)) == (PMS_HW_GG|PMS_HW_LCD))
xoff -= 48; // GG LCD, adjust to center 160 px
// make sprite pixel map by merging the 4 bitplanes
pack = ((pack | (pack>>16)) | ((pack | (pack>>16))>>8)) & 0xff;
if (!m) m = CollisionDetect(sprites_map, sprites_x[s], pack, zoomed);
+ // no collision detection in 1st column if it's masked
+ if (pv->reg[0] & 0x20)
+ sprites_map[1] = 0;
}
s++;
}
if (scanline < 16 && (pv->reg[0] & 0x40))
dx = 0; // hscroll disabled for top 2 rows (e.g. Fantasy Zone II)
- tilex = ((-dx >> 3) + cellskip) & 0x1f;
+ tilex = (32 - (dx >> 3) + cellskip) & 0x1f;
ty = (line & 7) << 1; // Y-Offset into tile
cells = maxcells - cellskip;
- dx = ((dx - 1) & 7) + 1;
- if (dx != 8)
- cells++; // have hscroll, need to draw 1 cell more
+ dx = (dx & 7);
dx += cellskip << 3;
dx += line_offset;
// tiles
if (!(pv->debug_p & PVD_KILL_B)) {
if ((Pico.m.hardware & (PMS_HW_GG|PMS_HW_LCD)) == (PMS_HW_GG|PMS_HW_LCD)) {
- // on GG render only the center 160 px
- DrawStripM4(nametab , dx | ((cells-12)<< 16),(tilex+6) | (ty << 16));
+ // on GG render only the center 160 px, but mind hscroll
+ DrawStripM4(nametab , (dx-8) | ((cells-11)<< 16),(tilex+5) | (ty << 16));
} else if (pv->reg[0] & 0x80) {
// vscroll disabled for rightmost 8 columns (e.g. Gauntlet)
int dx2 = dx + (cells-8)*8, tilex2 = tilex + (cells-8), ty2 = scanline&7;
- DrawStripM4(nametab, dx | ((cells-8) << 16), tilex | (ty << 16));
- DrawStripM4(nametab2, dx2 | (8 << 16), tilex2 | (ty2 << 17));
+ DrawStripM4(nametab, dx | ((cells-8) << 16), tilex | (ty << 16));
+ DrawStripM4(nametab2, dx2 | (8 << 16), tilex2 | (ty2 << 17));
} else
- DrawStripM4(nametab , dx | ( cells << 16), tilex | (ty << 16));
+ DrawStripM4(nametab , dx | ( cells << 16), tilex | (ty << 16));
}
// sprites
if ((pv->reg[0] & 0x20) && (Pico.m.hardware & (PMS_HW_GG|PMS_HW_LCD)) != (PMS_HW_GG|PMS_HW_LCD)) {
// first column masked with background, caculate offset to start of line
- dx = (dx&~0x1f) / 4;
+ dx = line_offset / 4;
ty = ((pv->reg[7]&0x0f)|0x10) * 0x01010101;
- ((u32 *)Pico.est.HighCol)[dx+2] = ((u32 *)Pico.est.HighCol)[dx+3] = ty;
+ ((u32 *)Pico.est.HighCol)[dx] = ((u32 *)Pico.est.HighCol)[dx+1] = ty;
}
}
struct PicoVideo *pv = &Pico.video;
unsigned int pack;
u8 *sat;
- int xoff = 8; // relative to HighCol, which is (screen - 8)
+ int xoff;
int sprite_base, addr_mask;
int zoomed = pv->reg[1] & 0x1; // zoomed sprites
int i, s, h, m;
- xoff += line_offset;
+ xoff = line_offset;
sat = (u8 *)PicoMem.vramb + ((pv->reg[5] & 0x7e) << 7);
if (pv->reg[1] & 2) {
tilex = cellskip & 0x1f;
cells = maxcells - cellskip;
- dx = (cellskip << 3) + line_offset + 8;
+ dx = (cellskip << 3) + line_offset;
// tiles
if (!(pv->debug_p & PVD_KILL_B))
tilex = cellskip & 0x1f;
cells = maxcells - cellskip;
- dx = (cellskip << 3) + line_offset + 8;
+ dx = (cellskip << 3) + line_offset;
// tiles
if (!(pv->debug_p & PVD_KILL_B))
tilex = cellskip & 0x1f;
cells = maxcells - cellskip;
- dx = (cellskip << 3) + line_offset + 8;
+ dx = (cellskip << 3) + line_offset;
// tiles
if (!(pv->debug_p & PVD_KILL_B))
tilex = cellskip & 0x1f;
cells = maxcells - cellskip;
- dx = (cellskip << 3) + line_offset + 8;
+ dx = (cellskip << 3) + line_offset;
// tiles
if (!(pv->debug_p & PVD_KILL_B))
void PicoFrameStartSMS(void)
{
int lines = 192, columns = 256, loffs, coffs;
+
skip_next_line = 0;
loffs = screen_offset = 24; // 192 lines is really 224 with top/bottom bars
Pico.est.rendstatus = PDRAW_32_COLS;
// Copy LCD enable flag for easier handling
Pico.m.hardware &= ~PMS_HW_LCD;
- if (PicoIn.opt & POPT_EN_GG_LCD)
+ if ((PicoIn.opt & POPT_EN_GG_LCD) && (Pico.m.hardware & PMS_HW_GG))
Pico.m.hardware |= PMS_HW_LCD;
+ if (!(Pico.m.hardware & PMS_HW_LCD) && (mode & 4) && (Pico.video.reg[0] & 0x20)) {
+ // SMS mode 4 with 1st column blanked
+ columns = 248;
+ Pico.est.rendstatus |= PDRAW_SMS_BLANK_1;
+ }
if ((Pico.m.hardware & (PMS_HW_GG|PMS_HW_LCD)) == (PMS_HW_GG|PMS_HW_LCD)) {
// GG LCD always has 160x144 regardless of settings
screen_offset = 24; // nonetheless the vdp timing has 224 lines
lines = 224;
break;
}
- if (PicoIn.opt & POPT_EN_SOFTSCALE) {
+
+ line_offset = 8; // FinalizeLine requires HighCol+8
+ // ugh... nonetheless has offset in 8-bit fast mode if 1st col blanked!
+ coffs = (FinalizeLineSMS == NULL && columns == 248 ? 8 : 0);
+ if (FinalizeLineSMS != NULL && (PicoIn.opt & POPT_EN_SOFTSCALE)) {
+ // softscaling always generates 320px, but no scaling in 8bit fast
coffs = 0;
columns = 320;
- } else
- coffs = PicoIn.opt & POPT_DIS_32C_BORDER ? 0:(320-columns)/2;
- line_offset = (FinalizeLineSMS == NULL ? coffs : 0);
-
- if (FinalizeLineSMS == FinalizeLineRGB555SMS)
- line_offset = 0 /* done in FinalizeLine */;
+ } else if (!(PicoIn.opt & POPT_DIS_32C_BORDER)) {
+ line_offset -= coffs;
+ coffs = (320-columns) / 2;
+ if (FinalizeLineSMS == NULL)
+ line_offset += coffs; // ... else centering done in FinalizeLine
+ }
if (Pico.est.rendstatus != rendstatus_old || lines != rendlines) {
emu_video_mode_change(loffs, lines, coffs, columns);
/* Palette for TMS9918 mode, see https://www.smspower.org/Development/Palette */
// RGB values: #000000 #000000 #21c842 #5edc78 #5455ed #7d76fc #d4524d #42ebf5
// #fc5554 #ff7978 #d4c154 #e6ce80 #21b03b #c95bba #cccccc #ffffff
-static u16 tmspal[32] = {
+static u16 tmspal[] = {
// SMS palette
0x0000, 0x0000, 0x00a0, 0x00f0, 0x0a00, 0x0f00, 0x0005, 0x0ff0,
0x000a, 0x000f, 0x00aa, 0x00ff, 0x0050, 0x0f0f, 0x0aaa, 0x0fff,
- // GG palette
+ // TMS palette
0x0000, 0x0000, 0x04c2, 0x07d6, 0x0e55, 0x0f77, 0x055c, 0x0ee4,
0x055f, 0x077f, 0x05bc, 0x08ce, 0x03a2, 0x0b5c, 0x0ccc, 0x0fff,
+ // SMS palette, closer to the TMS one
+ 0x0000, 0x0000, 0x05f0, 0x05f5, 0x0a50, 0x0f55, 0x055a, 0x0ff0,
+ 0x055f, 0x0aaf, 0x05aa, 0x05af, 0x00a0, 0x0f5f, 0x0aaa, 0x0fff,
};
void PicoDoHighPal555SMS(void)
unsigned int t;
int i, j;
- if (FinalizeLineSMS != FinalizeLine8bitSMS || Pico.m.dirtyPal == 2)
+ if (FinalizeLineSMS == FinalizeLineRGB555SMS || Pico.m.dirtyPal == 2)
Pico.m.dirtyPal = 0;
- // use hardware palette for 16bit accurate mode
- if (FinalizeLineSMS == FinalizeLineRGB555SMS)
+ // use hardware palette if not in 8bit accurate mode
+ if (FinalizeLineSMS != FinalizeLine8bitSMS)
spal = (void *)PicoMem.cram;
/* SMS 6 bit cram data was already converted to MD/GG format by vdp write,
{
case PDF_8BIT: FinalizeLineSMS = FinalizeLine8bitSMS; break;
case PDF_RGB555: FinalizeLineSMS = FinalizeLineRGB555SMS; break;
- // there's no fast renderer yet, just treat it like PDF_8BIT
- default: FinalizeLineSMS = FinalizeLine8bitSMS;
+ default: FinalizeLineSMS = NULL; // no multiple palettes, no scaling
PicoDrawSetInternalBuf(Pico.est.Draw2FB, 328); break;
}
rendstatus_old = -1;
#define PDRAW_SKIP_FRAME (1<<10) // frame is skipped\r
#define PDRAW_30_ROWS (1<<11) // 30 rows mode (240 lines)\r
#define PDRAW_32X_SCALE (1<<12) // scale CLUT layer for 32X\r
+#define PDRAW_SMS_BLANK_1 (1<<13) // 1st column blanked\r
extern int rendstatus_old;\r
extern int rendlines;\r
\r
if ((a&0x6000) != 0x2000) return;
if (Pico.ms.mapper != PMS_MAP_XOR && Pico.ms.mapper) return;
- elprintf(EL_Z80BNK, "bank 32k %04x %02x @ %04x", a, d, z80_pc());
+ elprintf(EL_Z80BNK, "bank xor %04x %02x @ %04x", a, d, z80_pc());
Pico.ms.mapper = PMS_MAP_XOR;
Pico.ms.carthw[0] = d;
}
}
-// TMR product codes and hardware type for know 50Hz-only games
+// TMR product codes and hardware type for known 50Hz-only games
static u32 region_pal[] = { // cf. GX+, core/cart_hw/sms_cartc.c
0x40207067 /* Addams Family */, 0x40207020 /* Back.Future 3 */,
0x40207058 /* Battlemaniacs */, 0x40007105 /* Cal.Games 2 */,
#include "../pico_types.h"
#include "resampler.h"
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
static double besseli0(double x)
{
unsigned i;
void bgr444_to_rgb32(void *to, void *from, unsigned entries);\r
void bgr444_to_rgb32_sh(void *to, void *from);\r
\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 vidcpy_8bit(void *dest, void *src, int x_y, int w_h);\r
+void vidcpy_8bit_rot(void *dest, void *src, int x_y, int w_h);\r
+\r
void spend_cycles(int c); // utility\r
\r
void rotated_blit8 (void *dst, void *linesx4, int y, int is_32col);\r
\r
@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
\r
-\r
-@ mode2 blitter\r
-.global vidcpy_m2 @ void *dest, void *src, int m32col, int with_32c_border\r
-vidcpy_m2:\r
+.global vidcpy_8bit @ void *dest, void *src, int x_y, int w_h\r
+vidcpy_8bit:\r
stmfd sp!, {r4-r6,lr}\r
\r
- mov r12, #224 @ lines\r
- add r0, r0, #320*8\r
+ mov r12, r2, lsl #16 @ y\r
+\r
+ mov r4, r12, lsr #16-8 @ 320*y = 256*y+64*y\r
+ add r4, r4, r12, lsr #16-6\r
+ add r0, r0, r4 @ pd += 320*y + x\r
+ add r0, r0, r2, lsr #16\r
+\r
+ add r4, r4, r12, lsr #16-3 @ 328*y = 320*y + 8*y\r
+ add r1, r1, r4 @ ps += 328*y + x + 8\r
+ add r1, r1, r2, lsr #16\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
- addne r1, r1, #32\r
+ mov lr, r3, lsr #16 @ w\r
+ mov r12, r3, lsl #16 @ h\r
\r
-vidCpyM2_loop_out:\r
- mov r6, #10\r
- sub r6, r6, lr, lsr #5 @ -= 2 in 32col mode\r
-vidCpyM2_loop:\r
+vidCpy8bit_loop_out:\r
+ lsrs r6, lr, #5\r
+@ beq vidCpy8bit_loop_end\r
+vidCpy8bit_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_loop\r
-\r
- subs r12,r12,#1\r
- add r0, r0, lr\r
- add r1, r1, #8\r
- add r1, r1, lr\r
- bne vidCpyM2_loop_out\r
+ bne vidCpy8bit_loop\r
+\r
+ ands r6, lr, #0x0018\r
+ beq vidCpy8bit_loop_end\r
+vidCpy8bit_loop2:\r
+ ldmia r1!, {r2-r3}\r
+ subs r6, r6, #8\r
+ stmia r0!, {r2-r3}\r
+ bne vidCpy8bit_loop2\r
+\r
+vidCpy8bit_loop_end:\r
+ subs r12,r12,#1<<16\r
+ add r0, r0, #320\r
+ sub r0, r0, lr\r
+ add r1, r1, #328\r
+ sub r1, r1, lr\r
+ bne vidCpy8bit_loop_out\r
\r
ldmfd sp!, {r4-r6,pc}\r
\r
\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
+.global vidcpy_8bit_rot @ void *dest, void *src, int x_y, int w_h\r
+vidcpy_8bit_rot:\r
+ stmfd sp!, {r4-r10,lr}\r
+\r
+ mov r12, r2, lsl #16 @ y\r
+\r
+ add r0, r0, r12, lsr #16 @ pd += y + (319-x)*240\r
+ mov r4, #320\r
+ sub r4, r4, #1\r
+ sub r4, r4, r2, lsr #16 @ (319-x)\r
+ add r0, r0, r4, lsl #8\r
+ sub r0, r0, r4, lsl #4\r
+\r
+ mov r4, r12, lsr #16-8 @ 328*y = 256*y + 64*y + 8*y\r
+ add r4, r4, r12, lsr #16-6\r
+ add r4, r4, r12, lsr #16-3\r
+ add r1, r1, r4 @ ps += 328*y + x + 8\r
+ add r1, r1, r2, lsr #16\r
add r1, r1, #8\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
+\r
+ mov lr, r3, lsr #16 @ w\r
+ mov r12, r3, lsl #16 @ h\r
+\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
+vidCpy8bitrot_loop_out:\r
+ mov r10, r0\r
+ lsrs r9, lr, #2\r
+@ beq vidCpy8bitrot_loop_end\r
+vidCpy8bitrot_loop:\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 r9, r9, #1\r
+ add r1, r1, #4\r
+ bne vidCpy8bitrot_loop\r
+\r
+vidCpy8bitrot_loop_end:\r
+ subs r12,r12,#4<<16\r
+ add r0, r10, #4\r
+ sub r1, r1, lr\r
+ add r1, r1, #4*328\r
+ bne vidCpy8bitrot_loop_out\r
+\r
+ ldmfd sp!, {r4-r10,pc}\r
\r
\r
.global rotated_blit8 @ void *dst, void *linesx4, u32 y, int is_32col\r
}
}
-static void menu_enter(int is_rom_loaded)
-{
- plat_video_menu_enter(is_rom_loaded);
- menu_w = menu_h = 0;
-}
-
static void menu_draw_prep(void)
{
if (menu_w == g_menuscreen_w && menu_h == g_menuscreen_h)
PicoTmpStateRestore(tmp_state);
}
+static void menu_enter(int is_rom_loaded)
+{
+ plat_video_menu_enter(is_rom_loaded);
+ menu_w = menu_h = 0;
+ menu_draw_prep();
+}
+
// --------- loading ROM screen ----------
static int cdload_called = 0;
{\r
if (doing_bg_frame)\r
return RT_16BIT;\r
- if ((PicoIn.AHW & PAHW_SMS) && currentConfig.renderer == RT_8BIT_FAST)\r
- return RT_8BIT_ACC; // 8bpp fast is not there (yet?)\r
if (PicoIn.AHW & PAHW_32X)\r
return currentConfig.renderer32x;\r
else\r
p[pitch*2] ^= 0xffff;\r
}\r
\r
+static void clear_1st_column(int firstcol, int firstline, int linecount)\r
+{\r
+ int size = is_16bit_mode() ? 2 : 1;\r
+ int black = is_16bit_mode() ? 0 : 0xe0;\r
+ int i;\r
+\r
+ // SMS 1st column blanked, replace with black\r
+ if ((currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) && !doing_bg_frame) {\r
+ int pitch = 240*size;\r
+ char *p = (char *)g_screen_ptr + (319-(firstcol-8))*pitch;\r
+ for (i = 0; i < 8; i++, p -= pitch)\r
+ memset(p+(firstline)*size, black, linecount*size);\r
+ } else {\r
+ int pitch = 320*size;\r
+ char *p = (char *)g_screen_ptr + (firstline)*pitch;\r
+ for (i = 0; i < linecount; i++, p += pitch)\r
+ memset(p+(firstcol-8)*size, black, 8*size);\r
+ }\r
+}\r
+\r
/* rot thing for Wiz */\r
static unsigned char __attribute__((aligned(4))) rot_buff[320*4*2];\r
\r
if ((num & 3) != 3)\r
return 0;\r
rotated_blit8(g_screen_ptr, rot_buff, num + 1,\r
- !(Pico.video.reg[12] & 1));\r
+ !(Pico.video.reg[12] & 1) && !(PicoIn.opt & POPT_EN_SOFTSCALE));\r
return 0;\r
}\r
\r
static int localPal[0x100];\r
static int localPalSize;\r
\r
-static void (*vidcpyM2)(void *dest, void *src, int m32col, int with_32c_border);\r
+static void (*vidcpy8bit)(void *dest, void *src, int x_y, int w_h);\r
static int (*make_local_pal)(int fast_mode);\r
\r
static int make_local_pal_md(int fast_mode)\r
bgr444_to_rgb32(localPal+i*0x40, tmspal, 32);\r
memcpy(localPal+i*0x40+0x20, localPal+i*0x40, 0x20*4);\r
}\r
+ } else if (fast_mode) {\r
+ for (i = 0;i >= 0; i--) {\r
+ bgr444_to_rgb32(localPal+i*0x40, PicoMem.cram+i*0x40, 32);\r
+ memcpy(localPal+i*0x40+0x20, localPal+i*0x40, 0x20*4);\r
+ }\r
} else {\r
for (i = Pico.est.SonicPalCount; i >= 0; i--) {\r
bgr444_to_rgb32(localPal+i*0x40, Pico.est.SonicPal+i*0x40, 32);\r
return (Pico.est.SonicPalCount+1)*0x40;\r
}\r
\r
+static int is_1stblanked;\r
+static int firstline, linecount;\r
+static int firstcol, colcount;\r
+\r
void pemu_finalize_frame(const char *fps, const char *notice)\r
{\r
int emu_opt = currentConfig.EmuOpt;\r
\r
- if (PicoIn.AHW & PAHW_32X)\r
+ if (is_16bit_mode())\r
localPalSize = 0; // nothing to do\r
else if (get_renderer() == RT_8BIT_FAST)\r
{\r
if (PicoIn.AHW & PAHW_SVP)\r
memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328/4);\r
// clear top and bottom of overlap trash\r
- if (!(Pico.est.rendstatus & PDRAW_30_ROWS)) {\r
- memset32((int *)(Pico.est.Draw2FB+8*(224+8)), 0xe0e0e0e0, 328*8/4);\r
- memset32((int *)(Pico.est.Draw2FB), 0xe0e0e0e0, 328*8/4);\r
+ if (firstline >= 8) {\r
+ unsigned char *p = Pico.est.Draw2FB + firstline*328;\r
+ memset32((int *)(p- 8*328), 0xe0e0e0e0, 328*8/4);\r
+ memset32((int *)(p+linecount*328), 0xe0e0e0e0, 328*8/4);\r
}\r
// do actual copy\r
- vidcpyM2(g_screen_ptr, Pico.est.Draw2FB+328*8,\r
- !(Pico.video.reg[12] & 1), !(PicoIn.opt & POPT_DIS_32C_BORDER));\r
+ vidcpy8bit(g_screen_ptr, Pico.est.Draw2FB,\r
+ (firstcol << 16) | firstline, (colcount << 16) | linecount);\r
}\r
else if (get_renderer() == RT_8BIT_ACC)\r
{\r
if (Pico.m.dirtyPal)\r
localPalSize = make_local_pal(0);\r
}\r
- else localPalSize = 0; // no palette in 16bit mode\r
+\r
+ if (is_1stblanked)\r
+ clear_1st_column(firstcol, firstline, linecount);\r
\r
if (notice)\r
osd_text(4, osd_y, notice);\r
case RT_8BIT_FAST:\r
PicoIn.opt |= POPT_ALT_RENDERER;\r
PicoDrawSetOutFormat(PDF_NONE, 0);\r
- vidcpyM2 = vidcpy_m2;\r
+ vidcpy8bit = vidcpy_8bit;\r
gp2x_mode = 8;\r
break;\r
default:\r
if ((PicoIn.AHW & PAHW_32X) || renderer == RT_16BIT) {\r
emu_scan_begin = EmuScanBegin16_rot;\r
emu_scan_end = EmuScanEnd16_rot;\r
+ memset(rot_buff, 0, 320*4*2);\r
}\r
else if (renderer == RT_8BIT_ACC) {\r
emu_scan_begin = EmuScanBegin8_rot;\r
emu_scan_end = EmuScanEnd8_rot;\r
+ memset(rot_buff, 0xe0, 320*4);\r
}\r
else if (renderer == RT_8BIT_FAST)\r
- vidcpyM2 = vidcpy_m2_rot;\r
+ vidcpy8bit = vidcpy_8bit_rot;\r
}\r
\r
PicoDrawSetCallbacks(emu_scan_begin, emu_scan_end);\r
int scalex = 320, scaley = 240;\r
int ln_offs = 0;\r
\r
- /* NTSC always has 224 visible lines, anything smaller has bars */\r
- if (line_count < 224 && line_count > 144) {\r
- start_line -= (224-line_count) /2;\r
- line_count = 224;\r
- }\r
+ if (currentConfig.vscaling != EOPT_SCALE_NONE &&\r
+ (is_16bit_mode() || get_renderer() != RT_8BIT_FAST)) {\r
+ /* NTSC always has 224 visible lines, anything smaller has bars */\r
+ if (line_count < 224 && line_count > 144) {\r
+ start_line -= (224-line_count) /2;\r
+ line_count = 224;\r
+ }\r
\r
- /* line doubling for swscaling, also needed for bg frames */\r
- if (currentConfig.vscaling == EOPT_SCALE_SW && line_count < 240) {\r
- ld_lines = ld_left = 2*line_count / (240 - line_count);\r
- PicoDrawSetCallbacks(EmuScanBegin16_ld, EmuScanEnd16_ld);\r
+ /* line doubling for swscaling, also needed for bg frames */\r
+ if (currentConfig.vscaling == EOPT_SCALE_SW && line_count < 240) {\r
+ ld_lines = ld_left = 2*line_count / (240 - line_count);\r
+ PicoDrawSetCallbacks(EmuScanBegin16_ld,EmuScanEnd16_ld);\r
+ }\r
}\r
\r
+ /* blanking for SMS with 1st tile blanked */\r
+ is_1stblanked = (col_count == 248);\r
+ firstline = start_line; linecount = line_count;\r
+ firstcol = start_col; colcount = col_count;\r
+\r
if (doing_bg_frame)\r
return;\r
\r
Pico.m.dirtyPal = 1;\r
PicoIn.opt &= ~POPT_DIS_32C_BORDER;\r
gp2x_current_bpp = 16;\r
+ // always render in screen 3 since menu uses 0-2\r
+ g_screen_ptr = gp2x_screens[3];\r
\r
if (!no_scale)\r
no_scale = currentConfig.scaling == EOPT_SCALE_NONE;\r
emu_cmn_forced_frame(no_scale, do_emu, g_screen_ptr);\r
\r
+ if (is_1stblanked)\r
+ clear_1st_column(firstcol, firstline, linecount);\r
+\r
g_menubg_src_ptr = g_screen_ptr;\r
doing_bg_frame = 0;\r
}\r
{\r
pemu_sound_stop();\r
\r
+ if (g_screen_ptr == gp2x_screens[0]) {\r
+ /* currently on screen 3, which is needed for forced_frame */\r
+ int size = gp2x_current_bpp / 8;\r
+ gp2x_memcpy_all_buffers(g_screen_ptr, 0, 320*240 * size);\r
+ gp2x_video_flip();\r
+ }\r
/* do one more frame for menu bg */\r
pemu_forced_frame(0, 1);\r
}\r
// calculate the borders of the real image inside the picodrive image
vout_width = (vout_16bit ? VOUT_MAX_WIDTH : VOUT_8BIT_WIDTH);
vout_height = (vout_16bit ? VOUT_MAX_HEIGHT : VOUT_8BIT_HEIGHT);
- vout_offset = (vout_16bit ? 0 : 8); // 8bit has 8 px overlap area on the left
+ vout_offset = (vout_16bit ? 0 : col_count == 248 ? 16 : 8); // 8bit has overlap area on the left
padding = (struct retro_hw_ps2_insets){start_line, vout_offset, vout_height - line_count - start_line, vout_width - col_count - vout_offset};
int pxsz = (vout_16bit ? 2 : 1); // pixel size: RGB = 16 bits, CLUT = 8 bits
int x;
if (Pico.m.dirtyPal)
PicoDrawUpdateHighPal();
+ /* 8 bit renderers have an extra offset for SMS wíth 1st tile blanked */
+ if (vout_width == 248)
+ ps += 8;
/* Copy, and skip the leftmost 8 columns again */
for (i = 0; i < vout_height; i++, ps += 8) {
for (x = 0; x < vout_width; x+=4) {
* See COPYING file in the top-level directory.
*/
+#include <string.h>
+
// Convert 0000bbb0 ggg0rrr0 0000bbb0 ggg0rrr0
// to 00000000 rrr00000 ggg00000 bbb00000 ...
// TODO: rm when gp2x/emu.c is no longer used
}
}
-void vidcpy_m2(void *dest, void *src, int m32col, int with_32c_border)
+#define X (x_y >> 16)
+#define Y (x_y & 0xffff)
+#define W (w_h >> 16)
+#define H (w_h & 0xffff)
+
+// gp2x: 0-> X wiz: Y <-0
+// | |
+// v v
+//
+// Y X
+
+void vidcpy_8bit(void *dest, void *src, int x_y, int w_h)
{
unsigned char *pd = dest, *ps = src;
- int i, u;
+ int i;
- if (m32col) {
- for (i = 0; i < 224; i++)
- {
- ps += 8;
- ps += 32;
- pd += 32;
- for (u = 0; u < 256; u++)
- *pd++ = *ps++;
- ps += 32;
- pd += 32;
- }
- } else {
- for (i = 0; i < 224; i++)
- {
- ps += 8;
- for (u = 0; u < 320; u++)
- *pd++ = *ps++;
- }
+ pd += X + Y*320;
+ ps += X + Y*328 + 8;
+ for (i = 0; i < H; i++) {
+ memcpy(pd, ps, W);
+ ps += 328; pd += 320;
}
}
-void vidcpy_m2_rot(void *dest, void *src, int m32col, int with_32c_border)
+void vidcpy_8bit_rot(void *dest, void *src, int x_y, int w_h)
{
+ unsigned char *pd = dest, *ps = src;
+ int i, u;
+
+ pd += Y + (319-X)*240;
+ ps += X + Y*328 + 8;
+ for (i = 0; i < H; i += 4) {
+ unsigned char *p = (void *)ps;
+ unsigned int *q = (void *)pd;
+ for (u = 0; u < W; u++) {
+ *q = (p[3*328]<<24) + (p[2*328]<<16) + (p[1*328]<<8) + p[0*328];
+ p += 1;
+ q -= 240/4;
+ }
+ ps += 4*328; pd += 4;
+ }
}
void rotated_blit8 (void *dst, void *linesx4, int y, int is_32col)
{
+ unsigned char *pd = dst, *ps = linesx4;
+ int x, w, u;
+
+ x = (is_32col ? 32 : 0);
+ w = (is_32col ? 256 : 320);
+ y -= 4;
+
+ pd += y + (319-x)*240;
+ ps += x;
+
+ unsigned char *p = (void *)ps;
+ unsigned int *q = (void *)pd;
+ for (u = 0; u < w; u++) {
+ *q = (p[3*328]<<24) + (p[2*328]<<16) + (p[1*328]<<8) + p[0*328];
+ p += 1;
+ q -= 240/4;
+ }
}
void rotated_blit16(void *dst, void *linesx4, int y, int is_32col)
{
+ unsigned short *pd = dst, *ps = linesx4;
+ int x, w, u;
+
+ x = (is_32col ? 32 : 0);
+ w = (is_32col ? 256 : 320);
+ y -= 4;
+
+ pd += y + (319-x)*240;
+ ps += x;
+
+ unsigned short *p = (void *)ps;
+ unsigned int *q = (void *)pd;
+ for (u = 0; u < w; u++) {
+ q[0] = (p[1*328]<<16) + p[0*328];
+ q[1] = (p[3*328]<<16) + p[2*328];
+ p += 1;
+ q -= 2*240/4;
+ }
}
if (currentConfig.scaling == EOPT_SCALE_SW && out_w <= 256) {\r
if (currentConfig.vscaling == EOPT_SCALE_SW && out_h <= 224)\r
// h+v scaling\r
- upscale = out_w >= 256 ? upscale_256_224_hv: upscale_160_144_hv;\r
+ upscale = out_w >= 240 ? upscale_256_224_hv: upscale_160_144_hv;\r
else\r
// h scaling\r
- upscale = out_w >= 256 ? upscale_256_____h : upscale_160_____h;\r
+ upscale = out_w >= 240 ? upscale_256_____h : upscale_160_____h;\r
} else if (currentConfig.vscaling == EOPT_SCALE_SW && out_h <= 224)\r
// v scaling\r
- upscale = out_w >= 256 ? upscale_____224_v : upscale_____144_v;\r
+ upscale = out_w >= 240 ? upscale_____224_v : upscale_____144_v;\r
if (!upscale) {\r
// no scaling\r
for (y = 0; y < out_h; y++)\r
\r
PicoDrawUpdateHighPal();\r
\r
+ if (out_w == 248 && currentConfig.scaling == EOPT_SCALE_SW)\r
+ pd += (320 - out_w*320/256) / 2; // SMS with 1st tile blanked, recenter\r
screen_blit(pd, g_screen_ppitch, ps, 328, Pico.est.HighPal);\r
}\r
\r
\r
static void apply_renderer(void)\r
{\r
- PicoIn.opt &= ~(POPT_ALT_RENDERER|POPT_EN_SOFTSCALE|POPT_DIS_32C_BORDER);\r
+ PicoIn.opt |= POPT_DIS_32C_BORDER;\r
+ PicoIn.opt &= ~(POPT_ALT_RENDERER|POPT_EN_SOFTSCALE);\r
if (is_16bit_mode()) {\r
if (currentConfig.scaling == EOPT_SCALE_SW)\r
PicoIn.opt |= POPT_EN_SOFTSCALE;\r
- else if (currentConfig.scaling == EOPT_SCALE_HW)\r
- // hw scaling, render without any padding\r
- PicoIn.opt |= POPT_DIS_32C_BORDER;\r
PicoIn.filter = currentConfig.filter;\r
- } else\r
- PicoIn.opt |= POPT_DIS_32C_BORDER;\r
+ }\r
\r
switch (get_renderer()) {\r
case RT_16BIT:\r
\r
switch (currentConfig.scaling) {\r
case EOPT_SCALE_HW:\r
- screen_w = out_w;\r
- screen_x = 0;\r
+ // mind aspect ratio for SMS with 1st column blanked\r
+ screen_w = (out_w == 248 ? 256 : out_w);\r
+ screen_x = (screen_w - out_w)/2;\r
break;\r
case EOPT_SCALE_SW:\r
screen_x = (screen_w - 320)/2;\r
g_vertices[1].y = fbimg_yoffs + fbimg_height;
if (!is_16bit_mode()) {
// 8-bit modes have an 8 px overlap area on the left
- g_vertices[0].u += 8; g_vertices[1].u += 8;
+ int offs = out_w == 248 ? 16 : 8;
+ g_vertices[0].u += offs; g_vertices[1].u += offs;
}
if (border_hack) {
g_vertices[0].u++; g_vertices[1].u--;
// SMS palette
0x0000, 0x0000, 0x00a0, 0x00f0, 0x0500, 0x0f00, 0x0005, 0x0ff0,
0x000a, 0x000f, 0x0055, 0x00ff, 0x0050, 0x0f0f, 0x0555, 0x0fff,
+ // TMS palette
+ 0x0000, 0x0000, 0x04c2, 0x07d6, 0x0e55, 0x0f77, 0x055c, 0x0ee4,
+ 0x055f, 0x077f, 0x05bc, 0x08ce, 0x03a2, 0x0b5c, 0x0ccc, 0x0fff,
};
int i;
if (!(Pico.video.reg[0] & 0x4)) {
+ int sg = !!(Pico.m.hardware & PMS_HW_SG);
for (i = Pico.est.SonicPalCount; i >= 0; i--)
- do_pal_convert(localPal+i*0x40, tmspal, currentConfig.gamma, currentConfig.gamma2);
+ do_pal_convert(localPal+i*0x40, tmspal+sg*0x10, currentConfig.gamma, currentConfig.gamma2);
} else {
for (i = Pico.est.SonicPalCount; i >= 0; i--)
do_pal_convert(localPal+i*0x40, Pico.est.SonicPal+i*0x40, currentConfig.gamma, currentConfig.gamma2);
#define MENU_OPTIONS_ADV
+static menu_entry e_menu_sms_options[];
+
void psp_menu_init(void)
{
me_enable(e_menu_sms_options, MA_SMSOPT_GHOSTING, 0);