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
unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, tile_count, [spritep]...
int rendstatus = 0;
int DrawScanline = 0;
int rendstatus, rendstatus_old;
int DrawScanline;
int PicoDrawMask = -1;
static int skip_next_line=0;
@ -79,7 +79,6 @@ void DrawTilesFromCache(int *hc, int sh, int rlim);
void DrawSpritesSHi(unsigned char *sprited);
void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);
void FinalizeLineBGR444(int sh);
void FinalizeLineRGB555(int sh);
void *blockcpy(void *dst, const void *src, size_t n);
void blockcpy_or(void *dst, void *src, size_t n, int pat);
#else
@ -1160,20 +1159,24 @@ unsigned short HighPal[0x100];
#ifndef _ASM_DRAW_C
void PicoDoHighPal555(int sh)
{
unsigned int *spal, *dpal;
unsigned short *pal=HighPal;
int i, t;
Pico.m.dirtyPal = 0;
{
unsigned int *spal=(void *)Pico.cram;
unsigned int *dpal=(void *)HighPal;
for (i = 0x3f/2; i >= 0; i--)
spal = (void *)Pico.cram;
dpal = (void *)HighPal;
for (i = 0; i < 0x40; i++) {
unsigned int t = spal[i];
#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
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
t |= (t >> 3) & 0x18e318e3;
dpal[i] = t;
}
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 char *ps=HighCol+8;
@ -1265,7 +1268,7 @@ static void FinalizeLineRGB555(int sh)
static void FinalizeLine8bit(int sh)
{
unsigned char *pd=DrawLineDest;
unsigned char *pd = DrawLineDest;
int len, rs = rendstatus;
static int dirty_count;
@ -1287,7 +1290,8 @@ static void FinalizeLine8bit(int sh)
if (Pico.video.reg[12]&1) {
len = 320;
} else {
if (!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32;
if (!(PicoOpt & POPT_DIS_32C_BORDER))
pd += 32;
len = 256;
}
@ -1407,12 +1411,22 @@ PICO_INTERNAL void PicoFrameStart(void)
if (Pico.video.reg[1] & 8)
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)
Pico.m.dirtyPal = 2; // reset dirty if needed
DrawScanline=0;
PrepareSprites(1);
skip_next_line=0;
}
static void DrawBlankedLine(int line, int offs)

View file

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

View file

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

View file

@ -4,7 +4,7 @@
// Pico Library - Header File
// (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.
// 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
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
#define POPT_EN_FM (1<< 0) // 00 000x
#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_SHHI_DONE (1<<7) // layer sh/hi already processed
#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;
extern int rendstatus, rendstatus_old;
extern unsigned short HighPal[0x100];
// Draw2.c

View file

@ -186,6 +186,7 @@ extern struct DrZ80 drZ80;
#define z80_int() drZ80.Z80_IRQ = 1
#define z80_cyclesLeft drZ80.cycles
#define z80_pc() (drZ80.Z80PC - drZ80.Z80PC_BASE)
#elif defined(_USE_CZ80)
#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_cyclesLeft (CZ80.ICount - CZ80.ExtraCycles)
#define z80_pc() Cz80_Get_Reg(&CZ80, CZ80_PC)
#else
@ -416,6 +418,7 @@ int CM_compareRun(int cyc, int is_sub);
PICO_INTERNAL void PicoFrameStart(void);
void PicoDrawSync(int to, int blank_last_line);
void BackFill(int reg7, int sh);
void FinalizeLineRGB555(int sh);
extern int DrawScanline;
#define MAX_LINE_SPRITES 29
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 cycles_line = is_pal ? 58020 : 58293; /* (226.6 : 227.7) * 256 */
int cycles_done = 0, cycles_aim = 0;
int skip = PicoSkipFrame;
int lines_vis = 192;
int hint; // Hint counter
int y;
@ -246,7 +247,7 @@ void PicoFrameMS(void)
{
pv->v_counter = Pico.m.scanline = y;
if (y < lines_vis)
if (y < lines_vis && !skip)
PicoLineMode4(y);
if (y <= lines_vis)

View file

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