sms wip: random tweaks, refactoring (palette, sound stuff, etc)

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@764 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2009-08-28 20:16:33 +00:00
parent 460603fa81
commit 19954be196
13 changed files with 168 additions and 136 deletions

View file

@ -53,8 +53,8 @@ int HighPreSpr[80*2+1]; // slightly preprocessed sprites
#define SPRL_LO_ABOVE_HI 0x10 // low priority sprites may be on top of hi #define SPRL_LO_ABOVE_HI 0x10 // low priority sprites may be on top of hi
unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, tile_count, [spritep]... unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, tile_count, [spritep]...
int rendstatus = 0; int rendstatus, rendstatus_old;
int DrawScanline = 0; int DrawScanline;
int PicoDrawMask = -1; int PicoDrawMask = -1;
static int skip_next_line=0; static int skip_next_line=0;
@ -79,7 +79,6 @@ void DrawTilesFromCache(int *hc, int sh, int rlim);
void DrawSpritesSHi(unsigned char *sprited); void DrawSpritesSHi(unsigned char *sprited);
void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells); void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);
void FinalizeLineBGR444(int sh); void FinalizeLineBGR444(int sh);
void FinalizeLineRGB555(int sh);
void *blockcpy(void *dst, const void *src, size_t n); void *blockcpy(void *dst, const void *src, size_t n);
void blockcpy_or(void *dst, void *src, size_t n, int pat); void blockcpy_or(void *dst, void *src, size_t n, int pat);
#else #else
@ -1160,20 +1159,24 @@ unsigned short HighPal[0x100];
#ifndef _ASM_DRAW_C #ifndef _ASM_DRAW_C
void PicoDoHighPal555(int sh) void PicoDoHighPal555(int sh)
{ {
unsigned int *spal, *dpal;
unsigned short *pal=HighPal; unsigned short *pal=HighPal;
int i, t; int i, t;
Pico.m.dirtyPal = 0; Pico.m.dirtyPal = 0;
{ spal = (void *)Pico.cram;
unsigned int *spal=(void *)Pico.cram; dpal = (void *)HighPal;
unsigned int *dpal=(void *)HighPal;
for (i = 0x3f/2; i >= 0; i--) for (i = 0; i < 0x40; i++) {
unsigned int t = spal[i];
#ifdef USE_BGR555 #ifdef USE_BGR555
dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4); t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4);
#else #else
dpal[i] = ((spal[i]&0x000f000f)<<12)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)>>7); t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);
#endif #endif
t |= (t >> 3) & 0x18e318e3;
dpal[i] = t;
} }
if (sh) if (sh)
@ -1227,7 +1230,7 @@ static void FinalizeLineBGR444(int sh)
} }
static void FinalizeLineRGB555(int sh) void FinalizeLineRGB555(int sh)
{ {
unsigned short *pd=DrawLineDest; unsigned short *pd=DrawLineDest;
unsigned char *ps=HighCol+8; unsigned char *ps=HighCol+8;
@ -1265,7 +1268,7 @@ static void FinalizeLineRGB555(int sh)
static void FinalizeLine8bit(int sh) static void FinalizeLine8bit(int sh)
{ {
unsigned char *pd=DrawLineDest; unsigned char *pd = DrawLineDest;
int len, rs = rendstatus; int len, rs = rendstatus;
static int dirty_count; static int dirty_count;
@ -1287,7 +1290,8 @@ static void FinalizeLine8bit(int sh)
if (Pico.video.reg[12]&1) { if (Pico.video.reg[12]&1) {
len = 320; len = 320;
} else { } else {
if (!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32; if (!(PicoOpt & POPT_DIS_32C_BORDER))
pd += 32;
len = 256; len = 256;
} }
@ -1407,12 +1411,22 @@ PICO_INTERNAL void PicoFrameStart(void)
if (Pico.video.reg[1] & 8) if (Pico.video.reg[1] & 8)
rendstatus |= PDRAW_240LINES; rendstatus |= PDRAW_240LINES;
DrawScanline = 0;
skip_next_line = 0;
if (rendstatus != rendstatus_old) {
rendstatus_old = rendstatus;
emu_video_mode_change((rendstatus & PDRAW_240LINES) ? 0 : 8,
(rendstatus & PDRAW_240LINES) ? 240 : 224,
(Pico.video.reg[12] & 1) ? 0 : 1);
}
if (PicoOpt & POPT_ALT_RENDERER)
return;
if (Pico.m.dirtyPal) if (Pico.m.dirtyPal)
Pico.m.dirtyPal = 2; // reset dirty if needed Pico.m.dirtyPal = 2; // reset dirty if needed
DrawScanline=0;
PrepareSprites(1); PrepareSprites(1);
skip_next_line=0;
} }
static void DrawBlankedLine(int line, int offs) static void DrawBlankedLine(int line, int offs)

View file

@ -190,17 +190,26 @@ static void DrawDisplayM4(int scanline)
void PicoFrameStartMode4(void) void PicoFrameStartMode4(void)
{ {
int lines = 192;
skip_next_line = 0; skip_next_line = 0;
screen_offset = 24; screen_offset = 24;
rendstatus = PDRAW_192LINES; rendstatus = 0;
if ((Pico.video.reg[0] & 6) == 6 && (Pico.video.reg[1] & 0x18)) { if ((Pico.video.reg[0] & 6) == 6 && (Pico.video.reg[1] & 0x18)) {
rendstatus &= ~PDRAW_192LINES;
if (Pico.video.reg[1] & 0x08) { if (Pico.video.reg[1] & 0x08) {
screen_offset = 0;
rendstatus |= PDRAW_240LINES; rendstatus |= PDRAW_240LINES;
screen_offset = 0;
lines = 240;
} }
else // it's 224 lines else {
screen_offset = 8; screen_offset = 8;
lines = 224;
}
}
if (rendstatus != rendstatus_old) {
rendstatus_old = rendstatus;
emu_video_mode_change(screen_offset, lines, 1);
} }
} }
@ -251,28 +260,22 @@ void PicoDoHighPal555M4(void)
static void FinalizeLineRGB555M4(void) static void FinalizeLineRGB555M4(void)
{ {
unsigned short *pd=DrawLineDest;
unsigned char *ps=HighCol+8;
unsigned short *pal=HighPal;
int i;
if (Pico.m.dirtyPal) if (Pico.m.dirtyPal)
PicoDoHighPal555M4(); PicoDoHighPal555M4();
if (!(PicoOpt & POPT_DIS_32C_BORDER)) // standard FinalizeLine can finish it for us,
pd += 32; // with features like scaling and such
FinalizeLineRGB555(0);
for (i = 256/4; i > 0; i--) {
*pd++ = pal[*ps++];
*pd++ = pal[*ps++];
*pd++ = pal[*ps++];
*pd++ = pal[*ps++];
}
} }
static void FinalizeLine8bitM4(void) static void FinalizeLine8bitM4(void)
{ {
memcpy32(DrawLineDest, (int *)(HighCol+8), 256/4); unsigned char *pd = DrawLineDest;
if (!(PicoOpt & POPT_DIS_32C_BORDER))
pd += 32;
memcpy32((int *)pd, (int *)(HighCol+8), 256/4);
} }
void PicoDrawSetColorFormatMode4(int which) void PicoDrawSetColorFormatMode4(int which)

View file

@ -293,20 +293,19 @@ void PicoFrame(void)
{ {
Pico.m.frame_count++; Pico.m.frame_count++;
if (PicoAHW & PAHW_MCD) { if (PicoAHW & PAHW_SMS) {
PicoFrameMCD(); PicoFrameMS();
return; return;
} }
else if (PicoAHW & PAHW_SMS) {
PicoFrameMS(); if (PicoAHW & PAHW_MCD) {
PicoFrameMCD();
return; return;
} }
//if(Pico.video.reg[12]&0x2) Pico.video.status ^= 0x10; // change odd bit in interlace mode //if(Pico.video.reg[12]&0x2) Pico.video.status ^= 0x10; // change odd bit in interlace mode
if (!(PicoOpt&POPT_ALT_RENDERER)) PicoFrameStart();
PicoFrameStart();
PicoFrameHints(); PicoFrameHints();
} }

View file

@ -4,7 +4,7 @@
// Pico Library - Header File // Pico Library - Header File
// (c) Copyright 2004 Dave, All rights reserved. // (c) Copyright 2004 Dave, All rights reserved.
// (c) Copyright 2006-2008 notaz, All rights reserved. // (c) Copyright 2006-2009 notaz, All rights reserved.
// Free for non-commercial use. // Free for non-commercial use.
// For commercial use, separate licencing terms must be obtained. // For commercial use, separate licencing terms must be obtained.
@ -31,6 +31,9 @@ extern void mp3_update(int *buffer, int length, int stereo);
// used by SVP dynarec // used by SVP dynarec
extern void cache_flush_d_inval_i(const void *start_addr, const void *end_addr); extern void cache_flush_d_inval_i(const void *start_addr, const void *end_addr);
// this one should handle display mode changes
extern void emu_video_mode_change(int start_line, int line_count, int is_32cols);
// Pico.c // Pico.c
#define POPT_EN_FM (1<< 0) // 00 000x #define POPT_EN_FM (1<< 0) // 00 000x
#define POPT_EN_PSG (1<< 1) #define POPT_EN_PSG (1<< 1)
@ -172,8 +175,7 @@ extern int PicoDrawMask;
#define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3) #define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3)
#define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed #define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed
#define PDRAW_240LINES (1<<8) // 240 line display (224 if not set) #define PDRAW_240LINES (1<<8) // 240 line display (224 if not set)
#define PDRAW_192LINES (1<<9) // 192 line display (for SMS games) extern int rendstatus, rendstatus_old;
extern int rendstatus;
extern unsigned short HighPal[0x100]; extern unsigned short HighPal[0x100];
// Draw2.c // Draw2.c

View file

@ -186,6 +186,7 @@ extern struct DrZ80 drZ80;
#define z80_int() drZ80.Z80_IRQ = 1 #define z80_int() drZ80.Z80_IRQ = 1
#define z80_cyclesLeft drZ80.cycles #define z80_cyclesLeft drZ80.cycles
#define z80_pc() (drZ80.Z80PC - drZ80.Z80PC_BASE)
#elif defined(_USE_CZ80) #elif defined(_USE_CZ80)
#include "../cpu/cz80/cz80.h" #include "../cpu/cz80/cz80.h"
@ -195,6 +196,7 @@ extern struct DrZ80 drZ80;
#define z80_int() Cz80_Set_IRQ(&CZ80, 0, HOLD_LINE) #define z80_int() Cz80_Set_IRQ(&CZ80, 0, HOLD_LINE)
#define z80_cyclesLeft (CZ80.ICount - CZ80.ExtraCycles) #define z80_cyclesLeft (CZ80.ICount - CZ80.ExtraCycles)
#define z80_pc() Cz80_Get_Reg(&CZ80, CZ80_PC)
#else #else
@ -416,6 +418,7 @@ int CM_compareRun(int cyc, int is_sub);
PICO_INTERNAL void PicoFrameStart(void); PICO_INTERNAL void PicoFrameStart(void);
void PicoDrawSync(int to, int blank_last_line); void PicoDrawSync(int to, int blank_last_line);
void BackFill(int reg7, int sh); void BackFill(int reg7, int sh);
void FinalizeLineRGB555(int sh);
extern int DrawScanline; extern int DrawScanline;
#define MAX_LINE_SPRITES 29 #define MAX_LINE_SPRITES 29
extern unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; extern unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES];

View file

@ -235,6 +235,7 @@ void PicoFrameMS(void)
int lines = is_pal ? 313 : 262; int lines = is_pal ? 313 : 262;
int cycles_line = is_pal ? 58020 : 58293; /* (226.6 : 227.7) * 256 */ int cycles_line = is_pal ? 58020 : 58293; /* (226.6 : 227.7) * 256 */
int cycles_done = 0, cycles_aim = 0; int cycles_done = 0, cycles_aim = 0;
int skip = PicoSkipFrame;
int lines_vis = 192; int lines_vis = 192;
int hint; // Hint counter int hint; // Hint counter
int y; int y;
@ -246,7 +247,7 @@ void PicoFrameMS(void)
{ {
pv->v_counter = Pico.m.scanline = y; pv->v_counter = Pico.m.scanline = y;
if (y < lines_vis) if (y < lines_vis && !skip)
PicoLineMode4(y); PicoLineMode4(y);
if (y <= lines_vis) if (y <= lines_vis)

View file

@ -398,7 +398,6 @@ PICO_INTERNAL void PsndGetSamples(int y)
PICO_INTERNAL void PsndGetSamplesMS(void) PICO_INTERNAL void PsndGetSamplesMS(void)
{ {
int *buf32 = PsndBuffer;
int stereo = (PicoOpt & 8) >> 3; int stereo = (PicoOpt & 8) >> 3;
int length = PsndLen; int length = PsndLen;
@ -415,8 +414,12 @@ PICO_INTERNAL void PsndGetSamplesMS(void)
if (PicoOpt & POPT_EN_PSG) if (PicoOpt & POPT_EN_PSG)
SN76496Update(PsndOut, length, stereo); SN76496Update(PsndOut, length, stereo);
// convert + limit to normal 16bit output // upmix to "stereo" if needed
PsndMix_32_to_16l(PsndOut, buf32, length); if (stereo) {
int i = length, *p = (void *)PsndOut;
while (i--)
*p |= *p << 16;
}
if (PicoWriteSound != NULL) if (PicoWriteSound != NULL)
PicoWriteSound(length); PicoWriteSound(length);

View file

@ -3,9 +3,9 @@
// For commercial use, separate licencing terms must be obtained. // For commercial use, separate licencing terms must be obtained.
void vidConvCpyRGB32 (void *to, void *from, int pixels); void bgr444_to_rgb32(void *to, void *from);
void vidConvCpyRGB32sh(void *to, void *from, int pixels); void bgr444_to_rgb32_sh(void *to, void *from);
void vidConvCpyRGB32hi(void *to, void *from, int pixels);
void vidcpy_m2(void *dest, void *src, int m32col, int with_32c_border); void vidcpy_m2(void *dest, void *src, int m32col, int with_32c_border);
void vidcpy_m2_rot(void *dest, void *src, int m32col, int with_32c_border); void vidcpy_m2_rot(void *dest, void *src, int m32col, int with_32c_border);
void spend_cycles(int c); // utility void spend_cycles(int c); // utility

View file

@ -13,7 +13,6 @@
@ to 00000000 rrr00000 ggg00000 bbb00000 ... @ to 00000000 rrr00000 ggg00000 bbb00000 ...
@ lr = 0x00e000e0, out: r3=lower_pix, r2=higher_pix; trashes rin @ lr = 0x00e000e0, out: r3=lower_pix, r2=higher_pix; trashes rin
@ if sh==2, r8=0x00404040 (sh!=0 destroys flags!)
.macro convRGB32_2 rin sh=0 .macro convRGB32_2 rin sh=0
and r2, lr, \rin, lsr #4 @ blue and r2, lr, \rin, lsr #4 @ blue
and r3, \rin, lr and r3, \rin, lr
@ -59,16 +58,19 @@
.endif .endif
orr r2, r2, r2, lsr #3 orr r2, r2, r2, lsr #3
.if \sh == 1
str r2, [r0, #0x40*2*4]
.endif
str r2, [r0], #4 str r2, [r0], #4
.endm .endm
.global vidConvCpyRGB32 @ void *to, void *from, int pixels .global bgr444_to_rgb32 @ void *to, void *from
vidConvCpyRGB32: bgr444_to_rgb32:
stmfd sp!, {r4-r7,lr} stmfd sp!, {r4-r7,lr}
mov r12, r2, lsr #3 @ repeats mov r12, #0x40>>3 @ repeats
mov lr, #0x00e00000 mov lr, #0x00e00000
orr lr, lr, #0x00e0 orr lr, lr, #0x00e0
@ -80,19 +82,18 @@ vidConvCpyRGB32:
convRGB32_2 r5 convRGB32_2 r5
convRGB32_2 r6 convRGB32_2 r6
convRGB32_2 r7 convRGB32_2 r7
bgt .loopRGB32 bgt .loopRGB32
ldmfd sp!, {r4-r7,lr} ldmfd sp!, {r4-r7,pc}
bx lr
.global vidConvCpyRGB32sh @ void *to, void *from, int pixels .global bgr444_to_rgb32_sh @ void *to, void *from
vidConvCpyRGB32sh: bgr444_to_rgb32_sh:
stmfd sp!, {r4-r7,lr} stmfd sp!, {r4-r7,lr}
mov r12, r2, lsr #3 @ repeats mov r12, #0x40>>3 @ repeats
add r0, r0, #0x40*4
mov lr, #0x00e00000 mov lr, #0x00e00000
orr lr, lr, #0x00e0 orr lr, lr, #0x00e0
@ -104,21 +105,10 @@ vidConvCpyRGB32sh:
convRGB32_2 r5, 1 convRGB32_2 r5, 1
convRGB32_2 r6, 1 convRGB32_2 r6, 1
convRGB32_2 r7, 1 convRGB32_2 r7, 1
bgt .loopRGB32sh bgt .loopRGB32sh
ldmfd sp!, {r4-r7,lr} mov r12, #0x40>>3 @ repeats
bx lr sub r1, r1, #0x40*2
.global vidConvCpyRGB32hi @ void *to, void *from, int pixels
vidConvCpyRGB32hi:
stmfd sp!, {r4-r7,lr}
mov r12, r2, lsr #3 @ repeats
mov lr, #0x00e00000
orr lr, lr, #0x00e0
.loopRGB32hi: .loopRGB32hi:
ldmia r1!, {r4-r7} ldmia r1!, {r4-r7}

View file

@ -1332,7 +1332,7 @@ void emu_loop(void)
{ {
int pframes_done; /* "period" frames, used for sync */ int pframes_done; /* "period" frames, used for sync */
int frames_done, frames_shown; /* actual frames for fps counter */ int frames_done, frames_shown; /* actual frames for fps counter */
int oldmodes, target_fps, target_frametime; int target_fps, target_frametime;
unsigned int timestamp_base = 0, timestamp_fps; unsigned int timestamp_base = 0, timestamp_fps;
char *notice_msg = NULL; char *notice_msg = NULL;
char fpsbuff[24]; char fpsbuff[24];
@ -1341,8 +1341,8 @@ void emu_loop(void)
fpsbuff[0] = 0; fpsbuff[0] = 0;
/* make sure we are in correct mode */ /* make sure we are in correct mode */
oldmodes = ((Pico.video.reg[12]&1)<<2) ^ 0xc;
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;
rendstatus_old = -1;
/* number of ticks per frame */ /* number of ticks per frame */
if (Pico.m.pal) { if (Pico.m.pal) {
@ -1371,7 +1371,6 @@ void emu_loop(void)
{ {
unsigned int timestamp; unsigned int timestamp;
int diff, diff_lim; int diff, diff_lim;
int modes;
timestamp = get_ticks(); timestamp = get_ticks();
if (reset_timing) { if (reset_timing) {
@ -1398,13 +1397,6 @@ void emu_loop(void)
} }
} }
// check for mode changes
modes = ((Pico.video.reg[12]&1)<<2) | (Pico.video.reg[1]&8);
if (modes != oldmodes) {
oldmodes = modes;
pemu_video_mode_change(!(modes & 4), (modes & 8));
}
// second changed? // second changed?
if (timestamp - timestamp_fps >= ms_to_ticks(1000)) if (timestamp - timestamp_fps >= ms_to_ticks(1000))
{ {

View file

@ -9,7 +9,6 @@ void pemu_prep_defconfig(void);
void pemu_loop_prep(void); void pemu_loop_prep(void);
void pemu_loop_end(void); void pemu_loop_end(void);
void pemu_forced_frame(int opts); void pemu_forced_frame(int opts);
void pemu_video_mode_change(int is_32col, int is_240_lines);
void pemu_update_display(const char *fps, const char *notice_msg); void pemu_update_display(const char *fps, const char *notice_msg);
void pemu_sound_start(void); void pemu_sound_start(void);

View file

@ -36,7 +36,7 @@ extern int crashed_940;
static short __attribute__((aligned(4))) sndBuffer[2*(44100+100)/50]; static short __attribute__((aligned(4))) sndBuffer[2*(44100+100)/50];
static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)];
unsigned char *PicoDraw2FB = PicoDraw2FB_; unsigned char *PicoDraw2FB = PicoDraw2FB_;
static int osd_fps_x; static int osd_fps_x, osd_y;
extern void *gp2x_screens[4]; extern void *gp2x_screens[4];
@ -265,21 +265,66 @@ static int EmuScanEnd8_rot(unsigned int num)
return 0; return 0;
} }
int localPal[0x100]; static int localPal[0x100];
static void (*vidcpyM2)(void *dest, void *src, int m32col, int with_32c_border) = NULL; static void (*vidcpyM2)(void *dest, void *src, int m32col, int with_32c_border);
static int (*make_local_pal)(int fast_mode);
static int make_local_pal_md(int fast_mode)
{
int pallen = 0xc0;
bgr444_to_rgb32(localPal, Pico.cram);
if (fast_mode)
return 0x40;
if (Pico.video.reg[0xC] & 8) { // shadow/hilight mode
bgr444_to_rgb32_sh(localPal, Pico.cram);
localPal[0xc0] = 0x0000c000;
localPal[0xd0] = 0x00c00000;
localPal[0xe0] = 0x00000000; // reserved pixels for OSD
localPal[0xf0] = 0x00ffffff;
pallen = 0x100;
}
else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes
bgr444_to_rgb32(localPal+0x40, HighPal);
bgr444_to_rgb32(localPal+0x80, HighPal+0x40);
}
else
memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess
return pallen;
}
static int make_local_pal_sms(int fast_mode)
{
unsigned short *spal = Pico.cram;
unsigned int *dpal = (void *)localPal;
unsigned int i, t;
for (i = 0x40; i > 0; i--) {
t = *spal++;
t = ((t & 0x0003) << 22) | ((t & 0x000c) << 12) | ((t & 0x0030) << 2);
t |= t >> 2;
t |= t >> 4;
*dpal++ = t;
}
return 0x40;
}
void pemu_update_display(const char *fps, const char *notice) void pemu_update_display(const char *fps, const char *notice)
{ {
int emu_opt = currentConfig.EmuOpt; int emu_opt = currentConfig.EmuOpt;
int ret;
if (PicoOpt & POPT_ALT_RENDERER) if (PicoOpt & POPT_ALT_RENDERER)
{ {
// 8bit fast renderer // 8bit fast renderer
if (Pico.m.dirtyPal) { if (Pico.m.dirtyPal) {
Pico.m.dirtyPal = 0; Pico.m.dirtyPal = 0;
vidConvCpyRGB32(localPal, Pico.cram, 0x40); ret = make_local_pal(1);
// feed new palette to our device // feed new palette to our device
gp2x_video_setpalette(localPal, 0x40); gp2x_video_setpalette(localPal, ret);
} }
// a hack for VR // a hack for VR
if (PicoRead16Hook == PicoSVPRead16) if (PicoRead16Hook == PicoSVPRead16)
@ -293,43 +338,17 @@ void pemu_update_display(const char *fps, const char *notice)
// 8bit accurate renderer // 8bit accurate renderer
if (Pico.m.dirtyPal) if (Pico.m.dirtyPal)
{ {
int pallen = 0xc0;
Pico.m.dirtyPal = 0; Pico.m.dirtyPal = 0;
if (Pico.video.reg[0xC]&8) // shadow/hilight mode ret = make_local_pal(0);
{ gp2x_video_setpalette(localPal, ret);
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
vidConvCpyRGB32sh(localPal+0x40, Pico.cram, 0x40);
vidConvCpyRGB32hi(localPal+0x80, Pico.cram, 0x40);
memcpy32(localPal+0xc0, localPal+0x40, 0x40);
pallen = 0x100;
}
else if (rendstatus & PDRAW_SONIC_MODE) { // mid-frame palette changes
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
vidConvCpyRGB32(localPal+0x40, HighPal, 0x40);
vidConvCpyRGB32(localPal+0x80, HighPal+0x40, 0x40);
}
else {
vidConvCpyRGB32(localPal, Pico.cram, 0x40);
memcpy32(localPal+0x80, localPal, 0x40); // for spr prio mess
}
if (pallen > 0xc0) {
localPal[0xc0] = 0x0000c000;
localPal[0xd0] = 0x00c00000;
localPal[0xe0] = 0x00000000; // reserved pixels for OSD
localPal[0xf0] = 0x00ffffff;
}
gp2x_video_setpalette(localPal, pallen);
} }
} }
if (notice || (emu_opt & 2)) { if (notice || (emu_opt & 2)) {
int h = 232;
if (currentConfig.scaling == EOPT_SCALE_HW_HV && !(Pico.video.reg[1]&8))
h -= 8;
if (notice) if (notice)
osd_text(4, h, notice); osd_text(4, osd_y, notice);
if (emu_opt & 2) if (emu_opt & 2)
osd_text(osd_fps_x, h, fps); osd_text(osd_fps_x, osd_y, fps);
} }
if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD)) if ((emu_opt & 0x400) && (PicoAHW & PAHW_MCD))
draw_cd_leds(); draw_cd_leds();
@ -474,6 +493,9 @@ static void vidResetMode(void)
if (currentConfig.scaling == EOPT_SCALE_HW_HV && !(Pico.video.reg[1]&8)) if (currentConfig.scaling == EOPT_SCALE_HW_HV && !(Pico.video.reg[1]&8))
gp2x_video_RGB_setscaling(8, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 224); gp2x_video_RGB_setscaling(8, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 224);
else gp2x_video_RGB_setscaling(0, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 240); else gp2x_video_RGB_setscaling(0, (PicoOpt&0x100)&&!(Pico.video.reg[12]&1) ? 256 : 320, 240);
// palette converters for 8bit modes
make_local_pal = (PicoAHW & PAHW_SMS) ? make_local_pal_sms : make_local_pal_md;
} }
void plat_video_toggle_renderer(int is_next, int is_menu) void plat_video_toggle_renderer(int is_next, int is_menu)
@ -498,6 +520,7 @@ void plat_video_toggle_renderer(int is_next, int is_menu)
return; return;
vidResetMode(); vidResetMode();
rendstatus_old = -1;
if (PicoOpt & POPT_ALT_RENDERER) { if (PicoOpt & POPT_ALT_RENDERER) {
emu_status_msg(" 8bit fast renderer"); emu_status_msg(" 8bit fast renderer");
@ -694,18 +717,21 @@ void plat_debug_cat(char *str)
{ {
} }
void pemu_video_mode_change(int is_32col, int is_240_lines) void emu_video_mode_change(int start_line, int line_count, int is_32cols)
{ {
int scalex = 320; int scalex = 320;
osd_fps_x = OSD_FPS_X; osd_fps_x = OSD_FPS_X;
if (is_32col && (PicoOpt & POPT_DIS_32C_BORDER)) { osd_y = 232;
if (is_32cols && (PicoOpt & POPT_DIS_32C_BORDER)) {
scalex = 256; scalex = 256;
osd_fps_x = OSD_FPS_X - 64; osd_fps_x = OSD_FPS_X - 64;
} }
/* want vertical scaling and game is not in 240 line mode */ /* want vertical scaling and game is not in 240 line mode */
if (currentConfig.scaling == EOPT_SCALE_HW_HV && !is_240_lines) if (currentConfig.scaling == EOPT_SCALE_HW_HV) {
gp2x_video_RGB_setscaling(8, scalex, 224); gp2x_video_RGB_setscaling(start_line, scalex, line_count);
else osd_y = start_line + line_count - 8;
} else
gp2x_video_RGB_setscaling(0, scalex, 240); gp2x_video_RGB_setscaling(0, scalex, 240);
// clear whole screen in all buffers // clear whole screen in all buffers
@ -819,6 +845,7 @@ void pemu_loop_end(void)
int eo_old = currentConfig.EmuOpt; int eo_old = currentConfig.EmuOpt;
pemu_sound_stop(); pemu_sound_stop();
memset32(g_screen_ptr, 0, 320*240*2/4);
/* do one more frame for menu bg */ /* do one more frame for menu bg */
PicoOpt &= ~POPT_ALT_RENDERER; PicoOpt &= ~POPT_ALT_RENDERER;

View file

@ -3,37 +3,36 @@
// to 00000000 rrr00000 ggg00000 bbb00000 ... // to 00000000 rrr00000 ggg00000 bbb00000 ...
// TODO: rm when gp2x/emu.c is no longer used // 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 short *ps = from;
unsigned int *pd = to; 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 = ((*ps<<20)&0xe00000) | ((*ps<<8)&0xe000) | ((*ps>>4)&0xe0);
*pd |= *pd >> 3; *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 short *ps = from;
unsigned int *pd = to; 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 = ((*ps<<20)&0xe00000) | ((*ps<<8)&0xe000) | ((*ps>>4)&0xe0);
*pd >>= 1; *pd >>= 1;
*pd |= *pd >> 3; *pd |= *pd >> 3;
pd[0x40*2] = *pd;
} }
}
void vidConvCpyRGB32hi(void *to, void *from, int pixels) ps -= 0x40;
{ for (pixels = 0x40; pixels; pixels--, ps++, pd++)
unsigned short *ps = from;
unsigned int *pd = to;
for (; pixels; pixels--, ps++, pd++)
{ {
*pd = ((*ps<<20)&0xe00000) | ((*ps<<8)&0xe000) | ((*ps>>4)&0xe0); *pd = ((*ps<<20)&0xe00000) | ((*ps<<8)&0xe000) | ((*ps>>4)&0xe0);
continue; continue;