core, fixes and improvements for type issues

This commit is contained in:
kub 2020-12-29 11:27:11 +01:00
parent 107cdd508b
commit 15eed40550
9 changed files with 128 additions and 126 deletions

View file

@ -171,8 +171,7 @@ void p32x_pwm_irq_event(unsigned int m68k_now)
p32x_pwm_schedule(m68k_now); p32x_pwm_schedule(m68k_now);
} }
unsigned int p32x_pwm_read16(unsigned int a, SH2 *sh2, unsigned int p32x_pwm_read16(u32 a, SH2 *sh2, unsigned int m68k_cycles)
unsigned int m68k_cycles)
{ {
unsigned int d = 0; unsigned int d = 0;
@ -206,8 +205,7 @@ unsigned int p32x_pwm_read16(unsigned int a, SH2 *sh2,
return d; return d;
} }
void p32x_pwm_write16(unsigned int a, unsigned int d, void p32x_pwm_write16(u32 a, unsigned int d, SH2 *sh2, unsigned int m68k_cycles)
SH2 *sh2, unsigned int m68k_cycles)
{ {
unsigned short *fifo; unsigned short *fifo;
int idx; int idx;

View file

@ -92,7 +92,7 @@ static void PicoSVPLine(void)
} }
static int PicoSVPDma(unsigned int source, int len, unsigned short **base, unsigned int *mask) static int PicoSVPDma(u32 source, int len, unsigned short **base, unsigned int *mask)
{ {
if (source < Pico.romsize) // Rom if (source < Pico.romsize) // Rom
{ {

View file

@ -11,7 +11,7 @@
#include "cell_map.c" #include "cell_map.c"
// check: Heart of the alien, jaguar xj 220 // check: Heart of the alien, jaguar xj 220
PICO_INTERNAL void DmaSlowCell(unsigned int source, unsigned int a, int len, unsigned char inc) PICO_INTERNAL void DmaSlowCell(u32 source, u32 a, int len, unsigned char inc)
{ {
unsigned char *base; unsigned char *base;
unsigned int asrc, a2; unsigned int asrc, a2;

View file

@ -53,15 +53,15 @@ static unsigned char DefHighCol[8+320+8];
unsigned char *HighColBase = DefHighCol; unsigned char *HighColBase = DefHighCol;
int HighColIncrement; int HighColIncrement;
static unsigned int DefOutBuff[320*2/2]; static u16 DefOutBuff[320*2];
void *DrawLineDestBase = DefOutBuff; void *DrawLineDestBase = DefOutBuff;
int DrawLineDestIncrement; int DrawLineDestIncrement;
static int HighCacheA[41*2+1]; // caches for high layers static u32 HighCacheA[41*2+1]; // caches for high layers
static int HighCacheB[41*2+1]; static u32 HighCacheB[41*2+1];
static int HighPreSpr[80*2+1]; // slightly preprocessed sprites static u32 HighPreSpr[80*2+1]; // slightly preprocessed sprites
unsigned int VdpSATCache[128]; // VDP sprite cache (1st 32 sprite attr bits) u32 VdpSATCache[128]; // VDP sprite cache (1st 32 sprite attr bits)
// NB don't change any defines without checking their usage in ASM // NB don't change any defines without checking their usage in ASM
@ -104,7 +104,7 @@ struct TileStrip
int line; // Line number in pixels 0x000-0x3ff within the virtual tilemap int line; // Line number in pixels 0x000-0x3ff within the virtual tilemap
int hscroll; // Horizontal scroll value in pixels for the line int hscroll; // Horizontal scroll value in pixels for the line
int xmask; // X-Mask (0x1f - 0x7f) for horizontal wraparound in the tilemap int xmask; // X-Mask (0x1f - 0x7f) for horizontal wraparound in the tilemap
int *hc; // cache for high tile codes and their positions u32 *hc; // cache for high tile codes and their positions
int cells; // cells (tiles) to draw (32 col mode doesn't need to update whole 320) int cells; // cells (tiles) to draw (32 col mode doesn't need to update whole 320)
}; };
@ -114,10 +114,10 @@ void DrawWindow(int tstart, int tend, int prio, int sh,
struct PicoEState *est); struct PicoEState *est);
void DrawAllSprites(unsigned char *sprited, int prio, int sh, void DrawAllSprites(unsigned char *sprited, int prio, int sh,
struct PicoEState *est); struct PicoEState *est);
void DrawTilesFromCache(int *hc, int sh, int rlim, void DrawTilesFromCache(u32 *hc, int sh, int rlim,
struct PicoEState *est); struct PicoEState *est);
void DrawSpritesSHi(unsigned char *sprited, struct PicoEState *est); void DrawSpritesSHi(unsigned char *sprited, struct PicoEState *est);
void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, void DrawLayer(int plane_sh, u32 *hcache, int cellskip, int maxcells,
struct PicoEState *est); struct PicoEState *est);
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);
@ -134,7 +134,7 @@ void blockcpy_or(void *dst, void *src, size_t n, int pat)
#define TileNormMaker_(pix_func,ret) \ #define TileNormMaker_(pix_func,ret) \
{ \ { \
unsigned int t; \ unsigned char t; \
\ \
t = (pack&0x0000f000)>>12; pix_func(0); \ t = (pack&0x0000f000)>>12; pix_func(0); \
t = (pack&0x00000f00)>> 8; pix_func(1); \ t = (pack&0x00000f00)>> 8; pix_func(1); \
@ -149,7 +149,7 @@ void blockcpy_or(void *dst, void *src, size_t n, int pat)
#define TileFlipMaker_(pix_func,ret) \ #define TileFlipMaker_(pix_func,ret) \
{ \ { \
unsigned int t; \ unsigned char t; \
\ \
t = (pack&0x000f0000)>>16; pix_func(0); \ t = (pack&0x000f0000)>>16; pix_func(0); \
t = (pack&0x00f00000)>>20; pix_func(1); \ t = (pack&0x00f00000)>>20; pix_func(1); \
@ -163,24 +163,24 @@ void blockcpy_or(void *dst, void *src, size_t n, int pat)
} }
#define TileNormMaker(funcname, pix_func) \ #define TileNormMaker(funcname, pix_func) \
static void funcname(unsigned char *pd, unsigned int pack, int pal) \ static void funcname(unsigned char *pd, unsigned int pack, unsigned char pal) \
TileNormMaker_(pix_func,) TileNormMaker_(pix_func,)
#define TileFlipMaker(funcname, pix_func) \ #define TileFlipMaker(funcname, pix_func) \
static void funcname(unsigned char *pd, unsigned int pack, int pal) \ static void funcname(unsigned char *pd, unsigned int pack, unsigned char pal) \
TileFlipMaker_(pix_func,) TileFlipMaker_(pix_func,)
#define TileNormMakerAS(funcname, pix_func) \ #define TileNormMakerAS(funcname, pix_func) \
static unsigned funcname(unsigned m, unsigned char *pd, unsigned int pack, int pal) \ static unsigned funcname(unsigned m, unsigned char *pd, unsigned int pack, unsigned char pal) \
TileNormMaker_(pix_func,m) TileNormMaker_(pix_func,m)
#define TileFlipMakerAS(funcname, pix_func) \ #define TileFlipMakerAS(funcname, pix_func) \
static unsigned funcname(unsigned m, unsigned char *pd, unsigned int pack, int pal) \ static unsigned funcname(unsigned m, unsigned char *pd, unsigned int pack, unsigned char pal) \
TileFlipMaker_(pix_func,m) TileFlipMaker_(pix_func,m)
// draw layer or non-s/h sprite pixels (no operator colors) // draw layer or non-s/h sprite pixels (no operator colors)
#define pix_just_write(x) \ #define pix_just_write(x) \
if (t) pd[x]=pal|t if (likely(t)) pd[x]=pal|t
TileNormMaker(TileNorm, pix_just_write) TileNormMaker(TileNorm, pix_just_write)
TileFlipMaker(TileFlip, pix_just_write) TileFlipMaker(TileFlip, pix_just_write)
@ -189,28 +189,26 @@ TileFlipMaker(TileFlip, pix_just_write)
// draw low prio sprite non-s/h pixels in s/h mode // draw low prio sprite non-s/h pixels in s/h mode
#define pix_nonsh(x) \ #define pix_nonsh(x) \
if (t == 0xe) pd[x]=(pal|t)&~0x80; /* disable shadow for color 14 (hw bug?) */ \ if (likely(t)) { \
else if (t) pd[x]=pal|t pd[x]=pal|t; \
if (unlikely(t==0xe)) pd[x]&=~0x80; /* disable shadow for color 14 (hw bug?) */ \
}
TileNormMaker(TileNormNonSH, pix_nonsh) TileNormMaker(TileNormNonSH, pix_nonsh)
TileFlipMaker(TileFlipNonSH, pix_nonsh) TileFlipMaker(TileFlipNonSH, pix_nonsh)
// draw sprite pixels, process operator colors // draw sprite pixels, process operator colors
#define pix_sh(x) \ #define pix_sh(x) \
if (t) { \ if (likely(t)) \
if (t>=0xe) pd[x]|=(t-1)<<6; /* 80 shadow, 40 hilight */ \ pd[x]=(likely(t<0xe) ? pal|t : pd[x]|((t-1)<<6));
else pd[x]=pal|t; \
}
TileNormMaker(TileNormSH, pix_sh) TileNormMaker(TileNormSH, pix_sh)
TileFlipMaker(TileFlipSH, pix_sh) TileFlipMaker(TileFlipSH, pix_sh)
// draw sprite pixels, mark but don't process operator colors // draw sprite pixels, mark but don't process operator colors
#define pix_sh_markop(x) \ #define pix_sh_markop(x) \
if (t) { \ if (likely(t)) \
if (t>=0xe) pd[x]|=0x40; \ pd[x]=(likely(t<0xe) ? pal|t : pd[x]|0x40);
else pd[x]=pal|t; \
}
TileNormMaker(TileNormSH_markop, pix_sh_markop) TileNormMaker(TileNormSH_markop, pix_sh_markop)
TileFlipMaker(TileFlipSH_markop, pix_sh_markop) TileFlipMaker(TileFlipSH_markop, pix_sh_markop)
@ -219,7 +217,7 @@ TileFlipMaker(TileFlipSH_markop, pix_sh_markop)
// draw low prio sprite operator pixels if visible (i.e. marked) // draw low prio sprite operator pixels if visible (i.e. marked)
#define pix_sh_onlyop(x) \ #define pix_sh_onlyop(x) \
if (t>=0xe && (pd[x]&0x40)) \ if (unlikely(t>=0xe && (pd[x]&0x40))) \
pd[x]=(pd[x]&~0x40)|((t-1)<<6) pd[x]=(pd[x]&~0x40)|((t-1)<<6)
#ifndef _ASM_DRAW_C #ifndef _ASM_DRAW_C
@ -233,7 +231,8 @@ TileFlipMaker(TileFlipSH_onlyop_lp, pix_sh_onlyop)
// draw high prio sprite pixels (AS) // draw high prio sprite pixels (AS)
#define pix_as(x) \ #define pix_as(x) \
if (t && (m & (1<<(x+8)))) m &= ~(1<<(x+8)), pd[x] = pal | t if (likely(t && (m & (1<<(x+8))))) \
m &= ~(1<<(x+8)), pd[x] = pal|t
TileNormMakerAS(TileNormAS, pix_as) TileNormMakerAS(TileNormAS, pix_as)
TileFlipMakerAS(TileFlipAS, pix_as) TileFlipMakerAS(TileFlipAS, pix_as)
@ -241,10 +240,9 @@ TileFlipMakerAS(TileFlipAS, pix_as)
// draw high prio sprite pixels, process operator colors (AS) // draw high prio sprite pixels, process operator colors (AS)
// NB sprite+planes: h+s->n, h+[nh]->h, s+[nhs]->s, hence mask h before op // NB sprite+planes: h+s->n, h+[nh]->h, s+[nhs]->s, hence mask h before op
#define pix_sh_as(x) \ #define pix_sh_as(x) \
if (t && (m & (1<<(x+8)))) { \ if (likely(t && (m & (1<<(x+8))))) { \
m &= ~(1<<(x+8)); \ m &= ~(1<<(x+8)); \
if (t>=0xe) pd[x]=(pd[x]&~0x40)|((t-1)<<6); \ pd[x]=(likely(t<0xe) ? pal|t : (pd[x]&~0x40)|((t-1)<<6)); \
else pd[x] = pal | t; \
} }
TileNormMakerAS(TileNormSH_AS, pix_sh_as) TileNormMakerAS(TileNormSH_AS, pix_sh_as)
@ -252,7 +250,7 @@ TileFlipMakerAS(TileFlipSH_AS, pix_sh_as)
// draw only sprite operator pixels (AS) // draw only sprite operator pixels (AS)
#define pix_sh_as_onlyop(x) \ #define pix_sh_as_onlyop(x) \
if (t && (m & (1<<(x+8)))) { \ if (likely(t && (m & (1<<(x+8))))) { \
m &= ~(1<<(x+8)); \ m &= ~(1<<(x+8)); \
pix_sh_onlyop(x); \ pix_sh_onlyop(x); \
} }
@ -262,7 +260,7 @@ TileFlipMakerAS(TileFlipSH_AS_onlyop_lp, pix_sh_as_onlyop)
// mark low prio sprite pixels (AS) // mark low prio sprite pixels (AS)
#define pix_sh_as_onlymark(x) \ #define pix_sh_as_onlymark(x) \
if (t) m &= ~(1<<(x+8)) if (likely(t)) m &= ~(1<<(x+8))
TileNormMakerAS(TileNormAS_onlymark, pix_sh_as_onlymark) TileNormMakerAS(TileNormAS_onlymark, pix_sh_as_onlymark)
TileFlipMakerAS(TileFlipAS_onlymark, pix_sh_as_onlymark) TileFlipMakerAS(TileFlipAS_onlymark, pix_sh_as_onlymark)
@ -272,7 +270,7 @@ TileFlipMakerAS(TileFlipAS_onlymark, pix_sh_as_onlymark)
// forced both layer draw (through debug reg) // forced both layer draw (through debug reg)
#define pix_and(x) \ #define pix_and(x) \
pal |= 0xc0; /* leave s/h bits untouched in pixel "and" */ \ pal |= 0xc0; /* leave s/h bits untouched in pixel "and" */ \
pd[x] &= pal | t pd[x] &= pal|t
TileNormMaker(TileNorm_and, pix_and) TileNormMaker(TileNorm_and, pix_and)
TileFlipMaker(TileFlip_and, pix_and) TileFlipMaker(TileFlip_and, pix_and)
@ -280,9 +278,9 @@ TileFlipMaker(TileFlip_and, pix_and)
// forced sprite draw (through debug reg) // forced sprite draw (through debug reg)
#define pix_sh_as_and(x) \ #define pix_sh_as_and(x) \
pal |= 0xc0; /* leave s/h bits untouched in pixel "and" */ \ pal |= 0xc0; /* leave s/h bits untouched in pixel "and" */ \
if (m & (1<<(x+8))) { \ if (likely(m & (1<<(x+8)))) { \
m &= ~(1<<(x+8)); \ m &= ~(1<<(x+8)); \
if (t<0xe) pd[x] &= pal | t; \ if (t<0xe) pd[x] &= pal|t; \
} }
TileNormMakerAS(TileNormSH_AS_and, pix_sh_as_and) TileNormMakerAS(TileNormSH_AS_and, pix_sh_as_and)
@ -295,7 +293,7 @@ TileFlipMakerAS(TileFlipSH_AS_and, pix_sh_as_and)
static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip) static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)
{ {
unsigned char *pd = Pico.est.HighCol; unsigned char *pd = Pico.est.HighCol;
int *hc = ts->hc; u32 *hc = ts->hc;
int tilex, dx, ty, cells; int tilex, dx, ty, cells;
int oldcode = -1, blank = -1; // The tile we know is blank int oldcode = -1, blank = -1; // The tile we know is blank
unsigned int pal = 0, pack = 0, sh; unsigned int pal = 0, pack = 0, sh;
@ -329,7 +327,7 @@ static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)
pal = ((code>>9)&0x30) | sh; // shadow pal = ((code>>9)&0x30) | sh; // shadow
pack = *(unsigned int *)(PicoMem.vram + addr); pack = *(u32 *)(PicoMem.vram + addr);
if (!pack) if (!pack)
blank = code; blank = code;
} }
@ -356,7 +354,7 @@ static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)
static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip) static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
{ {
unsigned char *pd = Pico.est.HighCol; unsigned char *pd = Pico.est.HighCol;
int *hc = ts->hc; u32 *hc = ts->hc;
int tilex, dx, ty = 0, addr = 0, cell = 0, nametabadd = 0; int tilex, dx, ty = 0, addr = 0, cell = 0, nametabadd = 0;
int oldcode = -1, blank = -1; // The tile we know is blank int oldcode = -1, blank = -1; // The tile we know is blank
unsigned int pal = 0, scan = Pico.est.DrawScanline, sh, plane; unsigned int pal = 0, scan = Pico.est.DrawScanline, sh, plane;
@ -418,7 +416,7 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
} }
pack = (code & 0x1000 ? ty^0xe : ty); // Y-flip pack = (code & 0x1000 ? ty^0xe : ty); // Y-flip
pack = *(unsigned int *)(PicoMem.vram + addr+pack); pack = *(u32 *)(PicoMem.vram + addr+pack);
if (!pack) if (!pack)
blank = code; blank = code;
@ -445,7 +443,7 @@ static
void DrawStripInterlace(struct TileStrip *ts, int plane_sh) void DrawStripInterlace(struct TileStrip *ts, int plane_sh)
{ {
unsigned char *pd = Pico.est.HighCol; unsigned char *pd = Pico.est.HighCol;
int *hc = ts->hc; u32 *hc = ts->hc;
int tilex = 0, dx = 0, ty = 0, cells; int tilex = 0, dx = 0, ty = 0, cells;
int oldcode = -1, blank = -1; // The tile we know is blank int oldcode = -1, blank = -1; // The tile we know is blank
unsigned int pal = 0, pack = 0, sh; unsigned int pal = 0, pack = 0, sh;
@ -478,7 +476,7 @@ void DrawStripInterlace(struct TileStrip *ts, int plane_sh)
pal = ((code>>9)&0x30) | sh; // shadow pal = ((code>>9)&0x30) | sh; // shadow
pack = *(unsigned int *)(PicoMem.vram + addr); pack = *(u32 *)(PicoMem.vram + addr);
if (!pack) if (!pack)
blank = code; blank = code;
} }
@ -504,7 +502,7 @@ void DrawStripInterlace(struct TileStrip *ts, int plane_sh)
// -------------------------------------------- // --------------------------------------------
#ifndef _ASM_DRAW_C #ifndef _ASM_DRAW_C
static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, static void DrawLayer(int plane_sh, u32 *hcache, int cellskip, int maxcells,
struct PicoEState *est) struct PicoEState *est)
{ {
struct PicoVideo *pvid=&Pico.video; struct PicoVideo *pvid=&Pico.video;
@ -628,7 +626,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
addr=(code&0x7ff)<<4; addr=(code&0x7ff)<<4;
if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
pack = *(unsigned int *)(PicoMem.vram + addr); pack = *(u32 *)(PicoMem.vram + addr);
if (!pack) { if (!pack) {
blank = code; blank = code;
continue; continue;
@ -670,7 +668,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh,
addr=(code&0x7ff)<<4; addr=(code&0x7ff)<<4;
if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip
pack = *(unsigned int *)(PicoMem.vram + addr); pack = *(u32 *)(PicoMem.vram + addr);
if (!pack) { if (!pack) {
blank = code; blank = code;
continue; continue;
@ -699,7 +697,7 @@ static void DrawTilesFromCacheShPrep(void)
} }
} }
static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est) static void DrawTilesFromCache(u32 *hc, int sh, int rlim, struct PicoEState *est)
{ {
unsigned char *pd = Pico.est.HighCol; unsigned char *pd = Pico.est.HighCol;
int code, dx; int code, dx;
@ -797,12 +795,13 @@ last_cut_tile:
// Index + 0 : hhhhvvvv ab--hhvv yyyyyyyy yyyyyyyy // a: offscreen h, b: offs. v, h: horiz. size // Index + 0 : hhhhvvvv ab--hhvv yyyyyyyy yyyyyyyy // a: offscreen h, b: offs. v, h: horiz. size
// Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8 // Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8
static void DrawSprite(int *sprite, int sh, int w) static void DrawSprite(u32 *sprite, int sh, int w)
{ {
void (*fTileFunc)(unsigned char *pd, unsigned int pack, int pal); void (*fTileFunc)(unsigned char *pd, unsigned int pack, unsigned char pal);
unsigned char *pd = Pico.est.HighCol; unsigned char *pd = Pico.est.HighCol;
int width=0,height=0; int width=0,height=0;
int row=0,code=0; int row=0;
u32 code=0;
int pal; int pal;
int tile=0,delta=0; int tile=0,delta=0;
int sx, sy; int sx, sy;
@ -848,7 +847,7 @@ static void DrawSprite(int *sprite, int sh, int w)
if(sx<=0) continue; if(sx<=0) continue;
if(sx>=328) break; // Offscreen if(sx>=328) break; // Offscreen
pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); pack = *(u32 *)(PicoMem.vram + (tile & 0x7fff));
fTileFunc(pd + sx, pack, pal); fTileFunc(pd + sx, pack, pal);
} }
} }
@ -894,7 +893,7 @@ static void DrawSpriteInterlace(unsigned int *sprite)
if(sx<=0) continue; if(sx<=0) continue;
if(sx>=328) break; // Offscreen if(sx>=328) break; // Offscreen
pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); pack = *(u32 *)(PicoMem.vram + (tile & 0x7fff));
if (code & 0x0800) TileFlip(pd + sx, pack, pal); if (code & 0x0800) TileFlip(pd + sx, pack, pal);
else TileNorm(pd + sx, pack, pal); else TileNorm(pd + sx, pack, pal);
} }
@ -917,7 +916,7 @@ static NOINLINE void DrawAllSpritesInterlace(int pri, int sh)
unsigned int *sprite; unsigned int *sprite;
int code, sx, sy, height; int code, sx, sy, height;
sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite sprite=(u32 *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
// get sprite info // get sprite info
code = sprite[0]; code = sprite[0];
@ -959,11 +958,11 @@ static NOINLINE void DrawAllSpritesInterlace(int pri, int sh)
*/ */
static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est) static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)
{ {
static void (*tilefuncs[2][2][2])(unsigned char *, unsigned, int) = { static void (*tilefuncs[2][2][2])(unsigned char *, unsigned, unsigned char) = {
{ {NULL, NULL}, {TileNorm, TileFlip} }, { {NULL, NULL}, {TileNorm, TileFlip} },
{ {TileNormSH_onlyop_lp, TileFlipSH_onlyop_lp}, {TileNormSH, TileFlipSH} } { {TileNormSH_onlyop_lp, TileFlipSH_onlyop_lp}, {TileNormSH, TileFlipSH} }
}; // [sh?][hi?][flip?] }; // [sh?][hi?][flip?]
void (*fTileFunc)(unsigned char *pd, unsigned int pack, int pal); void (*fTileFunc)(unsigned char *pd, unsigned int pack, unsigned char pal);
unsigned char *pd = Pico.est.HighCol; unsigned char *pd = Pico.est.HighCol;
unsigned char *p; unsigned char *p;
int cnt, w; int cnt, w;
@ -979,7 +978,8 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)
w = p[cnt]; // possibly clipped width of last sprite w = p[cnt]; // possibly clipped width of last sprite
for (cnt--; cnt >= 0; cnt--, w = 0) for (cnt--; cnt >= 0; cnt--, w = 0)
{ {
int *sprite, code, pal, tile, sx, sy; u32 *sprite, code;
int pal, tile, sx, sy;
int offs, delta, width, height, row; int offs, delta, width, height, row;
offs = (p[cnt] & 0x7f) * 2; offs = (p[cnt] & 0x7f) * 2;
@ -1016,7 +1016,7 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)
if(sx<=0) continue; if(sx<=0) continue;
if(sx>=328) break; // Offscreen if(sx>=328) break; // Offscreen
pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); pack = *(u32 *)(PicoMem.vram + (tile & 0x7fff));
fTileFunc(pd + sx, pack, pal); fTileFunc(pd + sx, pack, pal);
} }
} }
@ -1025,11 +1025,11 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)
static void DrawSpritesHiAS(unsigned char *sprited, int sh) static void DrawSpritesHiAS(unsigned char *sprited, int sh)
{ {
static unsigned (*tilefuncs[2][2][2])(unsigned, unsigned char *, unsigned, int) = { static unsigned (*tilefuncs[2][2][2])(unsigned, unsigned char *, unsigned, unsigned char) = {
{ {TileNormAS_onlymark, TileFlipAS_onlymark}, {TileNormAS, TileFlipAS} }, { {TileNormAS_onlymark, TileFlipAS_onlymark}, {TileNormAS, TileFlipAS} },
{ {TileNormSH_AS_onlyop_lp, TileFlipSH_AS_onlyop_lp}, {TileNormSH_AS, TileFlipSH_AS} } { {TileNormSH_AS_onlyop_lp, TileFlipSH_AS_onlyop_lp}, {TileNormSH_AS, TileFlipSH_AS} }
}; // [sh?][hi?][flip?] }; // [sh?][hi?][flip?]
unsigned (*fTileFunc)(unsigned m, unsigned char *pd, unsigned int pack, int pal); unsigned (*fTileFunc)(unsigned m, unsigned char *pd, unsigned int pack, unsigned char pal);
unsigned char *pd = Pico.est.HighCol; unsigned char *pd = Pico.est.HighCol;
unsigned char mb[sizeof(DefHighCol)/8]; unsigned char mb[sizeof(DefHighCol)/8];
unsigned char *p, *mp; unsigned char *p, *mp;
@ -1047,7 +1047,8 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh)
// Go through sprites: // Go through sprites:
for (entry = 0; entry < cnt; entry++) for (entry = 0; entry < cnt; entry++)
{ {
int *sprite, code, pal, tile, sx, sy; u32 *sprite, code;
int pal, tile, sx, sy;
int offs, delta, width, height, row; int offs, delta, width, height, row;
offs = (p[entry] & 0x7f) * 2; offs = (p[entry] & 0x7f) * 2;
@ -1084,7 +1085,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh)
if(sx>=328) break; // Offscreen if(sx>=328) break; // Offscreen
pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); pack = *(u32 *)(PicoMem.vram + (tile & 0x7fff));
m |= mp[1] << 8; // next mask byte m |= mp[1] << 8; // next mask byte
// shift mask bits to bits 8-15 for easier load/store handling // shift mask bits to bits 8-15 for easier load/store handling
@ -1127,7 +1128,7 @@ static void DrawStripForced(struct TileStrip *ts, int cellskip)
pal = (code>>9)&0x30; pal = (code>>9)&0x30;
} }
pack = *(unsigned int *)(PicoMem.vram + addr); pack = *(u32 *)(PicoMem.vram + addr);
if (code & 0x0800) TileFlip_and(pd + dx, pack, pal); if (code & 0x0800) TileFlip_and(pd + dx, pack, pal);
else TileNorm_and(pd + dx, pack, pal); else TileNorm_and(pd + dx, pack, pal);
@ -1191,7 +1192,7 @@ static void DrawStripVSRamForced(struct TileStrip *ts, int plane_sh, int cellski
} }
pack = code & 0x1000 ? ty^0xe : ty; // Y-flip pack = code & 0x1000 ? ty^0xe : ty; // Y-flip
pack = *(unsigned int *)(PicoMem.vram + addr+pack); pack = *(u32 *)(PicoMem.vram + addr+pack);
if (code & 0x0800) TileFlip_and(pd + dx, pack, pal); if (code & 0x0800) TileFlip_and(pd + dx, pack, pal);
else TileNorm_and(pd + dx, pack, pal); else TileNorm_and(pd + dx, pack, pal);
@ -1225,7 +1226,7 @@ void DrawStripInterlaceForced(struct TileStrip *ts)
pal = (code>>9)&0x30; // shadow pal = (code>>9)&0x30; // shadow
pack = *(unsigned int *)(PicoMem.vram + addr); pack = *(u32 *)(PicoMem.vram + addr);
} }
if (code & 0x0800) TileFlip_and(pd + dx, pack, pal); if (code & 0x0800) TileFlip_and(pd + dx, pack, pal);
@ -1305,7 +1306,7 @@ static void DrawLayerForced(int plane_sh, int cellskip, int maxcells,
static void DrawSpritesForced(unsigned char *sprited) static void DrawSpritesForced(unsigned char *sprited)
{ {
unsigned (*fTileFunc)(unsigned m, unsigned char *pd, unsigned int pack, int pal); unsigned (*fTileFunc)(unsigned m, unsigned char *pd, unsigned int pack, unsigned char pal);
unsigned char *pd = Pico.est.HighCol; unsigned char *pd = Pico.est.HighCol;
unsigned char mb[sizeof(DefHighCol)/8]; unsigned char mb[sizeof(DefHighCol)/8];
unsigned char *p, *mp; unsigned char *p, *mp;
@ -1323,7 +1324,8 @@ static void DrawSpritesForced(unsigned char *sprited)
// Go through sprites: // Go through sprites:
for (entry = 0; entry < cnt; entry++) for (entry = 0; entry < cnt; entry++)
{ {
int *sprite, code, pal, tile, sx, sy; u32 *sprite, code;
int pal, tile, sx, sy;
int offs, delta, width, height, row; int offs, delta, width, height, row;
offs = (p[entry] & 0x7f) * 2; offs = (p[entry] & 0x7f) * 2;
@ -1361,7 +1363,7 @@ static void DrawSpritesForced(unsigned char *sprited)
if(sx>=328) break; // Offscreen if(sx>=328) break; // Offscreen
pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); pack = *(u32 *)(PicoMem.vram + (tile & 0x7fff));
m |= mp[1] << 8; // next mask byte m |= mp[1] << 8; // next mask byte
// shift mask bits to bits 8-15 for easier load/store handling // shift mask bits to bits 8-15 for easier load/store handling
@ -1395,7 +1397,7 @@ static NOINLINE void PrepareSprites(int max_lines)
const struct PicoEState *est=&Pico.est; const struct PicoEState *est=&Pico.est;
int u,link=0,sh; int u,link=0,sh;
int table=0; int table=0;
int *pd = HighPreSpr; u32 *pd = HighPreSpr;
int max_sprites = 80, max_width = 328; int max_sprites = 80, max_width = 328;
int max_line_sprites = 20; // 20 sprites, 40 tiles int max_line_sprites = 20; // 20 sprites, 40 tiles
@ -1418,7 +1420,7 @@ static NOINLINE void PrepareSprites(int max_lines)
unsigned int *sprite; unsigned int *sprite;
int code, code2, sx, sy, hv, height, width; int code, code2, sx, sy, hv, height, width;
sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite sprite=(u32 *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
// parse sprite info. the 1st half comes from the VDPs internal cache, // parse sprite info. the 1st half comes from the VDPs internal cache,
// the 2nd half is read from VRAM // the 2nd half is read from VRAM
@ -1521,7 +1523,7 @@ static void DrawAllSprites(unsigned char *sprited, int prio, int sh,
w = p[cnt]; // possibly clipped width of last sprite w = p[cnt]; // possibly clipped width of last sprite
for (cnt--; cnt >= 0; cnt--, w = 0) for (cnt--; cnt >= 0; cnt--, w = 0)
{ {
int *sp = HighPreSpr + (p[cnt]&0x7f) * 2; u32 *sp = HighPreSpr + (p[cnt]&0x7f) * 2;
if ((p[cnt] >> 7) != prio) continue; if ((p[cnt] >> 7) != prio) continue;
DrawSprite(sp, sh, w); DrawSprite(sp, sh, w);
} }

View file

@ -25,8 +25,8 @@
static unsigned char PicoDraw2FB_[(8+320) * (8+240+8) + 8]; static unsigned char PicoDraw2FB_[(8+320) * (8+240+8) + 8];
static int HighCache2A[2*41*(TILE_ROWS+1)+1+1]; // caches for high layers static u32 HighCache2A[2*41*(TILE_ROWS+1)+1+1]; // caches for high layers
static int HighCache2B[2*41*(TILE_ROWS+1)+1+1]; static u32 HighCache2B[2*41*(TILE_ROWS+1)+1+1];
unsigned short *PicoCramHigh=PicoMem.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now) unsigned short *PicoCramHigh=PicoMem.cram; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to use
@ -35,9 +35,9 @@ void (*PicoPrepareCram)()=0; // prepares PicoCramHigh for renderer to
// stuff available in asm: // stuff available in asm:
#ifdef _ASM_DRAW_C #ifdef _ASM_DRAW_C
void BackFillFull(void *dst, int reg7); void BackFillFull(void *dst, int reg7);
void DrawLayerFull(int plane, int *hcache, int planestart, int planeend, void DrawLayerFull(int plane, u32 *hcache, int planestart, int planeend,
struct PicoEState *est); struct PicoEState *est);
void DrawTilesFromCacheF(int *hc, struct PicoEState *est); void DrawTilesFromCacheF(u32 *hc, struct PicoEState *est);
void DrawWindowFull(int start, int end, int prio, struct PicoEState *est); void DrawWindowFull(int start, int end, int prio, struct PicoEState *est);
void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est); void DrawSpriteFull(unsigned int *sprite, struct PicoEState *est);
#else #else
@ -52,7 +52,7 @@ static int TileXnormYnorm(unsigned char *pd,int addr,unsigned char pal, struct P
if ((pvid->reg[12]&6) == 6) inc = 4; if ((pvid->reg[12]&6) == 6) inc = 4;
#endif #endif
for(i=8; i; i--, addr+=inc, pd += LINE_WIDTH) { for(i=8; i; i--, addr+=inc, pd += LINE_WIDTH) {
pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels pack=*(u32 *)(PicoMem.vram+addr); // Get 8 pixels
if(!pack) continue; if(!pack) continue;
t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal); t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);
@ -78,7 +78,7 @@ static int TileXflipYnorm(unsigned char *pd,int addr,unsigned char pal, struct P
if ((pvid->reg[12]&6) == 6) inc = 4; if ((pvid->reg[12]&6) == 6) inc = 4;
#endif #endif
for(i=8; i; i--, addr+=inc, pd += LINE_WIDTH) { for(i=8; i; i--, addr+=inc, pd += LINE_WIDTH) {
pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels pack=*(u32 *)(PicoMem.vram+addr); // Get 8 pixels
if(!pack) continue; if(!pack) continue;
t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal); t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);
@ -104,7 +104,7 @@ static int TileXnormYflip(unsigned char *pd,int addr,unsigned char pal, struct P
#endif #endif
addr+=14; addr+=14;
for(i=8; i; i--, addr-=inc, pd += LINE_WIDTH) { for(i=8; i; i--, addr-=inc, pd += LINE_WIDTH) {
pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels pack=*(u32 *)(PicoMem.vram+addr); // Get 8 pixels
if(!pack) continue; if(!pack) continue;
t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal); t=pack&0x0000f000; if (t) pd[0]=(unsigned char)((t>>12)|pal);
@ -131,7 +131,7 @@ static int TileXflipYflip(unsigned char *pd,int addr,unsigned char pal, struct P
#endif #endif
addr+=14; addr+=14;
for(i=8; i; i--, addr-=inc, pd += LINE_WIDTH) { for(i=8; i; i--, addr-=inc, pd += LINE_WIDTH) {
pack=*(unsigned int *)(PicoMem.vram+addr); // Get 8 pixels pack=*(u32 *)(PicoMem.vram+addr); // Get 8 pixels
if(!pack) continue; if(!pack) continue;
t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal); t=pack&0x000f0000; if (t) pd[0]=(unsigned char)((t>>16)|pal);
@ -215,7 +215,7 @@ static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)
} }
static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend, static void DrawLayerFull(int plane, u32 *hcache, int planestart, int planeend,
struct PicoEState *est) struct PicoEState *est)
{ {
struct PicoVideo *pvid=&Pico.video; struct PicoVideo *pvid=&Pico.video;
@ -347,9 +347,10 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend,
} }
static void DrawTilesFromCacheF(int *hc, struct PicoEState *est) static void DrawTilesFromCacheF(u32 *hc, struct PicoEState *est)
{ {
int code, addr, zero = 0, vscroll; u32 code;
int addr, zero = 0, vscroll;
unsigned int prevy=0xFFFFFFFF; unsigned int prevy=0xFFFFFFFF;
// unsigned short *pal; // unsigned short *pal;
unsigned char pal; unsigned char pal;
@ -481,7 +482,7 @@ static void DrawAllSpritesFull(int prio, int maxwidth)
unsigned int *sprite=NULL; unsigned int *sprite=NULL;
int code, code2, sx, sy, height; int code, code2, sx, sy, height;
sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite sprite=(u32 *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite
// get sprite info // get sprite info
code = sprite[0]; code = sprite[0];

View file

@ -145,7 +145,7 @@ static void draw_sprites(int scanline)
// now draw all sprites backwards // now draw all sprites backwards
for (--s; s >= 0; s--) { for (--s; s >= 0; s--) {
pack = *(unsigned int *)(PicoMem.vram + sprites_addr[s]); pack = *(u32 *)(PicoMem.vram + sprites_addr[s]);
TileNormM4(sprites_x[s], pack, 0x10); TileNormM4(sprites_x[s], pack, 0x10);
} }
} }
@ -161,7 +161,7 @@ static void draw_strip_low(const unsigned short *nametab, int dx, int cells, int
for (; cells > 0; dx += 8, tilex_ty_prio++, cells--) for (; cells > 0; dx += 8, tilex_ty_prio++, cells--)
{ {
unsigned int pack; unsigned int pack;
int code; unsigned code;
code = nametab[tilex_ty_prio & 0x1f]; code = nametab[tilex_ty_prio & 0x1f];
@ -176,7 +176,7 @@ static void draw_strip_low(const unsigned short *nametab, int dx, int cells, int
pal = (code>>7) & 0x10; pal = (code>>7) & 0x10;
} }
pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */ pack = *(u32 *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */
if (pack == 0) TileBGM4(dx, pal); if (pack == 0) TileBGM4(dx, pal);
else if (code & 0x0200) TileFlipM4Low(dx, pack, pal); else if (code & 0x0200) TileFlipM4Low(dx, pack, pal);
else TileNormM4Low(dx, pack, pal); else TileNormM4Low(dx, pack, pal);
@ -192,7 +192,7 @@ static void draw_strip_high(const unsigned short *nametab, int dx, int cells, in
for (; cells > 0; dx += 8, tilex_ty_prio++, cells--) for (; cells > 0; dx += 8, tilex_ty_prio++, cells--)
{ {
unsigned int pack; unsigned int pack;
int code; unsigned code;
code = nametab[tilex_ty_prio & 0x1f]; code = nametab[tilex_ty_prio & 0x1f];
if (code == blank) if (code == blank)
@ -211,7 +211,7 @@ static void draw_strip_high(const unsigned short *nametab, int dx, int cells, in
pal = (code>>7) & 0x10; pal = (code>>7) & 0x10;
} }
pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */ pack = *(u32 *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */
if (pack == 0) { if (pack == 0) {
blank = code; blank = code;
continue; continue;

View file

@ -354,7 +354,7 @@ struct PicoEState
int rendstatus; int rendstatus;
void *DrawLineDest; // draw destination void *DrawLineDest; // draw destination
unsigned char *HighCol; unsigned char *HighCol;
int *HighPreSpr; u32 *HighPreSpr;
struct Pico *Pico; struct Pico *Pico;
void *PicoMem_vram; void *PicoMem_vram;
void *PicoMem_cram; void *PicoMem_cram;
@ -671,7 +671,7 @@ extern unsigned char *HighColBase;
extern int HighColIncrement; extern int HighColIncrement;
extern void *DrawLineDestBase; extern void *DrawLineDestBase;
extern int DrawLineDestIncrement; extern int DrawLineDestIncrement;
extern unsigned int VdpSATCache[128]; extern u32 VdpSATCache[128];
// draw2.c // draw2.c
void PicoDraw2SetOutBuf(void *dest); void PicoDraw2SetOutBuf(void *dest);
@ -686,10 +686,10 @@ void PicoDrawSetOutputMode4(pdso_t which);
// memory.c // memory.c
PICO_INTERNAL void PicoMemSetup(void); PICO_INTERNAL void PicoMemSetup(void);
unsigned int PicoRead8_io(unsigned int a); u32 PicoRead8_io(u32 a);
unsigned int PicoRead16_io(unsigned int a); u32 PicoRead16_io(u32 a);
void PicoWrite8_io(unsigned int a, unsigned int d); void PicoWrite8_io(u32 a, u32 d);
void PicoWrite16_io(unsigned int a, unsigned int d); void PicoWrite16_io(u32 a, u32 d);
// pico/memory.c // pico/memory.c
PICO_INTERNAL void PicoMemSetupPico(void); PICO_INTERNAL void PicoMemSetupPico(void);
@ -727,14 +727,14 @@ int gfx_context_save(unsigned char *state);
int gfx_context_load(const unsigned char *state); int gfx_context_load(const unsigned char *state);
// cd/gfx_dma.c // cd/gfx_dma.c
void DmaSlowCell(unsigned int source, unsigned int a, int len, unsigned char inc); void DmaSlowCell(u32 source, u32 a, int len, unsigned char inc);
// cd/memory.c // cd/memory.c
PICO_INTERNAL void PicoMemSetupCD(void); PICO_INTERNAL void PicoMemSetupCD(void);
unsigned int PicoRead8_mcd_io(unsigned int a); u32 PicoRead8_mcd_io(u32 a);
unsigned int PicoRead16_mcd_io(unsigned int a); u32 PicoRead16_mcd_io(u32 a);
void PicoWrite8_mcd_io(unsigned int a, unsigned int d); void PicoWrite8_mcd_io(u32 a, u32 d);
void PicoWrite16_mcd_io(unsigned int a, unsigned int d); void PicoWrite16_mcd_io(u32 a, u32 d);
void pcd_state_loaded_mem(void); void pcd_state_loaded_mem(void);
// pico.c // pico.c
@ -844,7 +844,7 @@ void ym2612_unpack_state(void);
// videoport.c // videoport.c
extern unsigned SATaddr, SATmask; extern u32 SATaddr, SATmask;
static __inline void UpdateSAT(u32 a, u32 d) static __inline void UpdateSAT(u32 a, u32 d)
{ {
unsigned num = (a^SATaddr) >> 3; unsigned num = (a^SATaddr) >> 3;
@ -862,15 +862,15 @@ static __inline void VideoWriteVRAM(u32 a, u16 d)
UpdateSAT(a, d); UpdateSAT(a, d);
} }
PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d); PICO_INTERNAL_ASM void PicoVideoWrite(u32 a,unsigned short d);
PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a); PICO_INTERNAL_ASM u32 PicoVideoRead(u32 a);
unsigned char PicoVideoRead8DataH(int is_from_z80); unsigned char PicoVideoRead8DataH(int is_from_z80);
unsigned char PicoVideoRead8DataL(int is_from_z80); unsigned char PicoVideoRead8DataL(int is_from_z80);
unsigned char PicoVideoRead8CtlH(int is_from_z80); unsigned char PicoVideoRead8CtlH(int is_from_z80);
unsigned char PicoVideoRead8CtlL(int is_from_z80); unsigned char PicoVideoRead8CtlL(int is_from_z80);
unsigned char PicoVideoRead8HV_H(int is_from_z80); unsigned char PicoVideoRead8HV_H(int is_from_z80);
unsigned char PicoVideoRead8HV_L(int is_from_z80); unsigned char PicoVideoRead8HV_L(int is_from_z80);
extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask); extern int (*PicoDmaHook)(u32 source, int len, unsigned short **base, unsigned int *mask);
void PicoVideoFIFOSync(int cycles); void PicoVideoFIFOSync(int cycles);
int PicoVideoFIFOHint(void); int PicoVideoFIFOHint(void);
void PicoVideoFIFOMode(int active, int h40); void PicoVideoFIFOMode(int active, int h40);
@ -996,10 +996,8 @@ enum {
extern int Pico32xDrawMode; extern int Pico32xDrawMode;
// 32x/pwm.c // 32x/pwm.c
unsigned int p32x_pwm_read16(unsigned int a, SH2 *sh2, unsigned int p32x_pwm_read16(u32 a, SH2 *sh2, unsigned int m68k_cycles);
unsigned int m68k_cycles); void p32x_pwm_write16(u32 a, unsigned int d, SH2 *sh2, unsigned int m68k_cycles);
void p32x_pwm_write16(unsigned int a, unsigned int d,
SH2 *sh2, unsigned int m68k_cycles);
void p32x_pwm_update(int *buf32, int length, int stereo); void p32x_pwm_update(int *buf32, int length, int stereo);
void p32x_pwm_ctl_changed(void); void p32x_pwm_ctl_changed(void);
void p32x_pwm_schedule(unsigned int m68k_now); void p32x_pwm_schedule(unsigned int m68k_now);

View file

@ -6,15 +6,16 @@
#define _H_FM_FM_ #define _H_FM_FM_
/* compiler dependence */ /* compiler dependence */
#include <stdint.h>
#ifndef UINT8 #ifndef UINT8
typedef unsigned char UINT8; /* unsigned 8bit */ typedef uint8_t UINT8; /* unsigned 8bit */
typedef unsigned short UINT16; /* unsigned 16bit */ typedef uint16_t UINT16; /* unsigned 16bit */
typedef unsigned int UINT32; /* unsigned 32bit */ typedef uint32_t UINT32; /* unsigned 32bit */
#endif #endif
#ifndef INT8 #ifndef INT8
typedef signed char INT8; /* signed 8bit */ typedef int8_t INT8; /* signed 8bit */
typedef signed short INT16; /* signed 16bit */ typedef int16_t INT16; /* signed 16bit */
typedef signed int INT32; /* signed 32bit */ typedef int32_t INT32; /* signed 32bit */
#endif #endif
#if 1 #if 1

View file

@ -20,7 +20,7 @@ extern const unsigned short vdpsl2cyc_32[], vdpsl2cyc_40[];
static int blankline; // display disabled for this line static int blankline; // display disabled for this line
unsigned SATaddr, SATmask; // VRAM addr of sprite attribute table u32 SATaddr, SATmask; // VRAM addr of sprite attribute table
int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask) = NULL; int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask) = NULL;
@ -335,7 +335,7 @@ static NOINLINE void VideoWriteVRAM128(u32 a, u16 d)
u32 b = ((a & 2) >> 1) | ((a & 0x400) >> 9) | (a & 0x3FC) | ((a & 0x1F800) >> 1); u32 b = ((a & 2) >> 1) | ((a & 0x400) >> 9) | (a & 0x3FC) | ((a & 0x1F800) >> 1);
((u8 *)PicoMem.vram)[b] = d; ((u8 *)PicoMem.vram)[b] = d;
if (!((u16)(b^SATaddr) & SATmask)) if (!(u16)((b^SATaddr) & SATmask))
Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES;
if (((a^SATaddr) & SATmask) == 0) if (((a^SATaddr) & SATmask) == 0)
@ -402,7 +402,7 @@ static int GetDmaLength(void)
return len; return len;
} }
static void DmaSlow(int len, unsigned int source) static void DmaSlow(int len, u32 source)
{ {
u32 inc = Pico.video.reg[0xf]; u32 inc = Pico.video.reg[0xf];
u32 a = Pico.video.addr | (Pico.video.addr_u << 16); u32 a = Pico.video.addr | (Pico.video.addr_u << 16);
@ -881,9 +881,10 @@ update_irq:
static u32 VideoSr(const struct PicoVideo *pv) static u32 VideoSr(const struct PicoVideo *pv)
{ {
unsigned int c, d = pv->status;
unsigned int hp = pv->reg[12]&1 ? 15*488/210+1 : 15*488/171+1; // HBLANK start unsigned int hp = pv->reg[12]&1 ? 15*488/210+1 : 15*488/171+1; // HBLANK start
unsigned int hl = pv->reg[12]&1 ? 37*488/210+1 : 28*488/171+1; // HBLANK len unsigned int hl = pv->reg[12]&1 ? 37*488/210+1 : 28*488/171+1; // HBLANK len
unsigned int c;
u32 d = pv->status;
c = SekCyclesDone() - Pico.t.m68c_line_start; c = SekCyclesDone() - Pico.t.m68c_line_start;
if (c - hp < hl) if (c - hp < hl)
@ -897,14 +898,14 @@ static u32 VideoSr(const struct PicoVideo *pv)
return d; return d;
} }
PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) PICO_INTERNAL_ASM u32 PicoVideoRead(u32 a)
{ {
a &= 0x1c; a &= 0x1c;
if (a == 0x04) // control port if (a == 0x04) // control port
{ {
struct PicoVideo *pv = &Pico.video; struct PicoVideo *pv = &Pico.video;
unsigned int d = VideoSr(pv); u32 d = VideoSr(pv);
if (pv->pending) { if (pv->pending) {
CommandChange(pv); CommandChange(pv);
pv->pending = 0; pv->pending = 0;
@ -930,14 +931,15 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)
// check: Sonic 3D Blast bonus, Cannon Fodder, Chase HQ II, 3 Ninjas kick back, Road Rash 3, Skitchin', Wheel of Fortune // check: Sonic 3D Blast bonus, Cannon Fodder, Chase HQ II, 3 Ninjas kick back, Road Rash 3, Skitchin', Wheel of Fortune
if ((a&0x1c)==0x08) if ((a&0x1c)==0x08)
{ {
unsigned int d; unsigned int c;
u32 d;
d = (SekCyclesDone() - Pico.t.m68c_line_start) & 0x1ff; // FIXME c = (SekCyclesDone() - Pico.t.m68c_line_start) & 0x1ff; // FIXME
if (Pico.video.reg[0]&2) if (Pico.video.reg[0]&2)
d = Pico.video.hv_latch; d = Pico.video.hv_latch;
else if (Pico.video.reg[12]&1) else if (Pico.video.reg[12]&1)
d = hcounts_40[d/2] | (Pico.video.v_counter << 8); d = hcounts_40[c/2] | (Pico.video.v_counter << 8);
else d = hcounts_32[d/2] | (Pico.video.v_counter << 8); else d = hcounts_32[c/2] | (Pico.video.v_counter << 8);
elprintf(EL_HVCNT, "hv: %02x %02x [%u] @ %06x", d, Pico.video.v_counter, SekCyclesDone(), SekPc); elprintf(EL_HVCNT, "hv: %02x %02x [%u] @ %06x", d, Pico.video.v_counter, SekCyclesDone(), SekPc);
return d; return d;