From 15eed405502838bc63b5cd58d33f78b7f4d91484 Mon Sep 17 00:00:00 2001 From: kub Date: Tue, 29 Dec 2020 11:27:11 +0100 Subject: [PATCH] core, fixes and improvements for type issues --- pico/32x/pwm.c | 6 +- pico/carthw/svp/svp.c | 2 +- pico/cd/gfx_dma.c | 2 +- pico/draw.c | 138 +++++++++++++++++++++--------------------- pico/draw2.c | 25 ++++---- pico/mode4.c | 10 +-- pico/pico_int.h | 36 ++++++----- pico/sound/ym2612.h | 13 ++-- pico/videoport.c | 22 ++++--- 9 files changed, 128 insertions(+), 126 deletions(-) diff --git a/pico/32x/pwm.c b/pico/32x/pwm.c index ec4bdb3e..8fccc98e 100644 --- a/pico/32x/pwm.c +++ b/pico/32x/pwm.c @@ -171,8 +171,7 @@ void p32x_pwm_irq_event(unsigned int m68k_now) p32x_pwm_schedule(m68k_now); } -unsigned int p32x_pwm_read16(unsigned int a, SH2 *sh2, - unsigned int m68k_cycles) +unsigned int p32x_pwm_read16(u32 a, SH2 *sh2, unsigned int m68k_cycles) { unsigned int d = 0; @@ -206,8 +205,7 @@ unsigned int p32x_pwm_read16(unsigned int a, SH2 *sh2, return d; } -void p32x_pwm_write16(unsigned int a, unsigned int d, - SH2 *sh2, unsigned int m68k_cycles) +void p32x_pwm_write16(u32 a, unsigned int d, SH2 *sh2, unsigned int m68k_cycles) { unsigned short *fifo; int idx; diff --git a/pico/carthw/svp/svp.c b/pico/carthw/svp/svp.c index c50eb850..8bde7792 100644 --- a/pico/carthw/svp/svp.c +++ b/pico/carthw/svp/svp.c @@ -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 { diff --git a/pico/cd/gfx_dma.c b/pico/cd/gfx_dma.c index 354fc213..76777d22 100644 --- a/pico/cd/gfx_dma.c +++ b/pico/cd/gfx_dma.c @@ -11,7 +11,7 @@ #include "cell_map.c" // 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 int asrc, a2; diff --git a/pico/draw.c b/pico/draw.c index a9e7bde0..27a48a87 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -53,15 +53,15 @@ static unsigned char DefHighCol[8+320+8]; unsigned char *HighColBase = DefHighCol; int HighColIncrement; -static unsigned int DefOutBuff[320*2/2]; +static u16 DefOutBuff[320*2]; void *DrawLineDestBase = DefOutBuff; int DrawLineDestIncrement; -static int HighCacheA[41*2+1]; // caches for high layers -static int HighCacheB[41*2+1]; -static int HighPreSpr[80*2+1]; // slightly preprocessed sprites +static u32 HighCacheA[41*2+1]; // caches for high layers +static u32 HighCacheB[41*2+1]; +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 @@ -104,7 +104,7 @@ struct TileStrip int line; // Line number in pixels 0x000-0x3ff within the virtual tilemap int hscroll; // Horizontal scroll value in pixels for the line 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) }; @@ -114,10 +114,10 @@ void DrawWindow(int tstart, int tend, int prio, int sh, struct PicoEState *est); void DrawAllSprites(unsigned char *sprited, int prio, int sh, struct PicoEState *est); -void DrawTilesFromCache(int *hc, int sh, int rlim, +void DrawTilesFromCache(u32 *hc, int sh, int rlim, 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); void *blockcpy(void *dst, const void *src, size_t n); 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) \ { \ - unsigned int t; \ + unsigned char t; \ \ t = (pack&0x0000f000)>>12; pix_func(0); \ 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) \ { \ - unsigned int t; \ + unsigned char t; \ \ t = (pack&0x000f0000)>>16; pix_func(0); \ 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) \ -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,) #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,) #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) #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) // draw layer or non-s/h sprite pixels (no operator colors) #define pix_just_write(x) \ - if (t) pd[x]=pal|t + if (likely(t)) pd[x]=pal|t TileNormMaker(TileNorm, 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 #define pix_nonsh(x) \ - if (t == 0xe) pd[x]=(pal|t)&~0x80; /* disable shadow for color 14 (hw bug?) */ \ - else if (t) pd[x]=pal|t + if (likely(t)) { \ + pd[x]=pal|t; \ + if (unlikely(t==0xe)) pd[x]&=~0x80; /* disable shadow for color 14 (hw bug?) */ \ + } TileNormMaker(TileNormNonSH, pix_nonsh) TileFlipMaker(TileFlipNonSH, pix_nonsh) // draw sprite pixels, process operator colors #define pix_sh(x) \ - if (t) { \ - if (t>=0xe) pd[x]|=(t-1)<<6; /* 80 shadow, 40 hilight */ \ - else pd[x]=pal|t; \ - } + if (likely(t)) \ + pd[x]=(likely(t<0xe) ? pal|t : pd[x]|((t-1)<<6)); TileNormMaker(TileNormSH, pix_sh) TileFlipMaker(TileFlipSH, pix_sh) // draw sprite pixels, mark but don't process operator colors #define pix_sh_markop(x) \ - if (t) { \ - if (t>=0xe) pd[x]|=0x40; \ - else pd[x]=pal|t; \ - } + if (likely(t)) \ + pd[x]=(likely(t<0xe) ? pal|t : pd[x]|0x40); TileNormMaker(TileNormSH_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) #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) #ifndef _ASM_DRAW_C @@ -233,7 +231,8 @@ TileFlipMaker(TileFlipSH_onlyop_lp, pix_sh_onlyop) // draw high prio sprite pixels (AS) #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) TileFlipMakerAS(TileFlipAS, pix_as) @@ -241,10 +240,9 @@ TileFlipMakerAS(TileFlipAS, pix_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 #define pix_sh_as(x) \ - if (t && (m & (1<<(x+8)))) { \ + if (likely(t && (m & (1<<(x+8))))) { \ m &= ~(1<<(x+8)); \ - if (t>=0xe) pd[x]=(pd[x]&~0x40)|((t-1)<<6); \ - else pd[x] = pal | t; \ + pd[x]=(likely(t<0xe) ? pal|t : (pd[x]&~0x40)|((t-1)<<6)); \ } TileNormMakerAS(TileNormSH_AS, pix_sh_as) @@ -252,7 +250,7 @@ TileFlipMakerAS(TileFlipSH_AS, pix_sh_as) // draw only sprite operator pixels (AS) #define pix_sh_as_onlyop(x) \ - if (t && (m & (1<<(x+8)))) { \ + if (likely(t && (m & (1<<(x+8))))) { \ m &= ~(1<<(x+8)); \ pix_sh_onlyop(x); \ } @@ -262,7 +260,7 @@ TileFlipMakerAS(TileFlipSH_AS_onlyop_lp, pix_sh_as_onlyop) // mark low prio sprite pixels (AS) #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) 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) #define pix_and(x) \ pal |= 0xc0; /* leave s/h bits untouched in pixel "and" */ \ - pd[x] &= pal | t + pd[x] &= pal|t TileNormMaker(TileNorm_and, pix_and) TileFlipMaker(TileFlip_and, pix_and) @@ -280,9 +278,9 @@ TileFlipMaker(TileFlip_and, pix_and) // forced sprite draw (through debug reg) #define pix_sh_as_and(x) \ 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)); \ - if (t<0xe) pd[x] &= pal | t; \ + if (t<0xe) pd[x] &= pal|t; \ } 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) { unsigned char *pd = Pico.est.HighCol; - int *hc = ts->hc; + u32 *hc = ts->hc; int tilex, dx, ty, cells; int oldcode = -1, blank = -1; // The tile we know is blank 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 - pack = *(unsigned int *)(PicoMem.vram + addr); + pack = *(u32 *)(PicoMem.vram + addr); if (!pack) 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) { 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 oldcode = -1, blank = -1; // The tile we know is blank 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 = *(unsigned int *)(PicoMem.vram + addr+pack); + pack = *(u32 *)(PicoMem.vram + addr+pack); if (!pack) blank = code; @@ -445,7 +443,7 @@ static void DrawStripInterlace(struct TileStrip *ts, int plane_sh) { unsigned char *pd = Pico.est.HighCol; - int *hc = ts->hc; + u32 *hc = ts->hc; int tilex = 0, dx = 0, ty = 0, cells; int oldcode = -1, blank = -1; // The tile we know is blank 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 - pack = *(unsigned int *)(PicoMem.vram + addr); + pack = *(u32 *)(PicoMem.vram + addr); if (!pack) blank = code; } @@ -504,7 +502,7 @@ void DrawStripInterlace(struct TileStrip *ts, int plane_sh) // -------------------------------------------- #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 PicoVideo *pvid=&Pico.video; @@ -628,7 +626,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, addr=(code&0x7ff)<<4; if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip - pack = *(unsigned int *)(PicoMem.vram + addr); + pack = *(u32 *)(PicoMem.vram + addr); if (!pack) { blank = code; continue; @@ -670,7 +668,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, addr=(code&0x7ff)<<4; if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip - pack = *(unsigned int *)(PicoMem.vram + addr); + pack = *(u32 *)(PicoMem.vram + addr); if (!pack) { blank = code; 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; 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 + 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; int width=0,height=0; - int row=0,code=0; + int row=0; + u32 code=0; int pal; int tile=0,delta=0; int sx, sy; @@ -848,7 +847,7 @@ static void DrawSprite(int *sprite, int sh, int w) if(sx<=0) continue; if(sx>=328) break; // Offscreen - pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); + pack = *(u32 *)(PicoMem.vram + (tile & 0x7fff)); fTileFunc(pd + sx, pack, pal); } } @@ -894,7 +893,7 @@ static void DrawSpriteInterlace(unsigned int *sprite) if(sx<=0) continue; 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); else TileNorm(pd + sx, pack, pal); } @@ -917,7 +916,7 @@ static NOINLINE void DrawAllSpritesInterlace(int pri, int sh) unsigned int *sprite; 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 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 (*tilefuncs[2][2][2])(unsigned char *, unsigned, int) = { + static void (*tilefuncs[2][2][2])(unsigned char *, unsigned, unsigned char) = { { {NULL, NULL}, {TileNorm, TileFlip} }, { {TileNormSH_onlyop_lp, TileFlipSH_onlyop_lp}, {TileNormSH, TileFlipSH} } }; // [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 *p; 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 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; 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>=328) break; // Offscreen - pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); + pack = *(u32 *)(PicoMem.vram + (tile & 0x7fff)); 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 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} }, { {TileNormSH_AS_onlyop_lp, TileFlipSH_AS_onlyop_lp}, {TileNormSH_AS, TileFlipSH_AS} } }; // [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 mb[sizeof(DefHighCol)/8]; unsigned char *p, *mp; @@ -1047,7 +1047,8 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) // Go through sprites: 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; offs = (p[entry] & 0x7f) * 2; @@ -1084,7 +1085,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) 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 // 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; } - pack = *(unsigned int *)(PicoMem.vram + addr); + pack = *(u32 *)(PicoMem.vram + addr); if (code & 0x0800) TileFlip_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 = *(unsigned int *)(PicoMem.vram + addr+pack); + pack = *(u32 *)(PicoMem.vram + addr+pack); if (code & 0x0800) TileFlip_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 - pack = *(unsigned int *)(PicoMem.vram + addr); + pack = *(u32 *)(PicoMem.vram + addr); } 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) { - 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 mb[sizeof(DefHighCol)/8]; unsigned char *p, *mp; @@ -1323,7 +1324,8 @@ static void DrawSpritesForced(unsigned char *sprited) // Go through sprites: 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; offs = (p[entry] & 0x7f) * 2; @@ -1361,7 +1363,7 @@ static void DrawSpritesForced(unsigned char *sprited) 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 // 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; int u,link=0,sh; int table=0; - int *pd = HighPreSpr; + u32 *pd = HighPreSpr; int max_sprites = 80, max_width = 328; int max_line_sprites = 20; // 20 sprites, 40 tiles @@ -1418,7 +1420,7 @@ static NOINLINE void PrepareSprites(int max_lines) unsigned int *sprite; 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, // 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 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; DrawSprite(sp, sh, w); } diff --git a/pico/draw2.c b/pico/draw2.c index ec1a12c7..a1adaeea 100644 --- a/pico/draw2.c +++ b/pico/draw2.c @@ -25,8 +25,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 int HighCache2B[2*41*(TILE_ROWS+1)+1+1]; +static u32 HighCache2A[2*41*(TILE_ROWS+1)+1+1]; // caches for high layers +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) 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: #ifdef _ASM_DRAW_C 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); -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 DrawSpriteFull(unsigned int *sprite, struct PicoEState *est); #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; #endif 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; 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; #endif 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; 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 addr+=14; 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; 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 addr+=14; 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; 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 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 short *pal; unsigned char pal; @@ -481,7 +482,7 @@ static void DrawAllSpritesFull(int prio, int maxwidth) unsigned int *sprite=NULL; 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 code = sprite[0]; diff --git a/pico/mode4.c b/pico/mode4.c index 8de41aed..f8ce6467 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -145,7 +145,7 @@ static void draw_sprites(int scanline) // now draw all sprites backwards 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); } } @@ -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--) { unsigned int pack; - int code; + unsigned code; 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; } - 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); else if (code & 0x0200) TileFlipM4Low(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--) { unsigned int pack; - int code; + unsigned code; code = nametab[tilex_ty_prio & 0x1f]; 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; } - pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */ + pack = *(u32 *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */ if (pack == 0) { blank = code; continue; diff --git a/pico/pico_int.h b/pico/pico_int.h index 411d9f93..b4b9a85a 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -354,7 +354,7 @@ struct PicoEState int rendstatus; void *DrawLineDest; // draw destination unsigned char *HighCol; - int *HighPreSpr; + u32 *HighPreSpr; struct Pico *Pico; void *PicoMem_vram; void *PicoMem_cram; @@ -671,7 +671,7 @@ extern unsigned char *HighColBase; extern int HighColIncrement; extern void *DrawLineDestBase; extern int DrawLineDestIncrement; -extern unsigned int VdpSATCache[128]; +extern u32 VdpSATCache[128]; // draw2.c void PicoDraw2SetOutBuf(void *dest); @@ -686,10 +686,10 @@ void PicoDrawSetOutputMode4(pdso_t which); // memory.c PICO_INTERNAL void PicoMemSetup(void); -unsigned int PicoRead8_io(unsigned int a); -unsigned int PicoRead16_io(unsigned int a); -void PicoWrite8_io(unsigned int a, unsigned int d); -void PicoWrite16_io(unsigned int a, unsigned int d); +u32 PicoRead8_io(u32 a); +u32 PicoRead16_io(u32 a); +void PicoWrite8_io(u32 a, u32 d); +void PicoWrite16_io(u32 a, u32 d); // pico/memory.c PICO_INTERNAL void PicoMemSetupPico(void); @@ -727,14 +727,14 @@ int gfx_context_save(unsigned char *state); int gfx_context_load(const unsigned char *state); // 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 PICO_INTERNAL void PicoMemSetupCD(void); -unsigned int PicoRead8_mcd_io(unsigned int a); -unsigned int PicoRead16_mcd_io(unsigned int a); -void PicoWrite8_mcd_io(unsigned int a, unsigned int d); -void PicoWrite16_mcd_io(unsigned int a, unsigned int d); +u32 PicoRead8_mcd_io(u32 a); +u32 PicoRead16_mcd_io(u32 a); +void PicoWrite8_mcd_io(u32 a, u32 d); +void PicoWrite16_mcd_io(u32 a, u32 d); void pcd_state_loaded_mem(void); // pico.c @@ -844,7 +844,7 @@ void ym2612_unpack_state(void); // videoport.c -extern unsigned SATaddr, SATmask; +extern u32 SATaddr, SATmask; static __inline void UpdateSAT(u32 a, u32 d) { unsigned num = (a^SATaddr) >> 3; @@ -862,15 +862,15 @@ static __inline void VideoWriteVRAM(u32 a, u16 d) UpdateSAT(a, d); } -PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d); -PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a); +PICO_INTERNAL_ASM void PicoVideoWrite(u32 a,unsigned short d); +PICO_INTERNAL_ASM u32 PicoVideoRead(u32 a); unsigned char PicoVideoRead8DataH(int is_from_z80); unsigned char PicoVideoRead8DataL(int is_from_z80); unsigned char PicoVideoRead8CtlH(int is_from_z80); unsigned char PicoVideoRead8CtlL(int is_from_z80); unsigned char PicoVideoRead8HV_H(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); int PicoVideoFIFOHint(void); void PicoVideoFIFOMode(int active, int h40); @@ -996,10 +996,8 @@ enum { extern int Pico32xDrawMode; // 32x/pwm.c -unsigned int p32x_pwm_read16(unsigned int a, SH2 *sh2, - unsigned int m68k_cycles); -void p32x_pwm_write16(unsigned int a, unsigned int d, - SH2 *sh2, unsigned int m68k_cycles); +unsigned int p32x_pwm_read16(u32 a, SH2 *sh2, unsigned int m68k_cycles); +void p32x_pwm_write16(u32 a, unsigned int d, SH2 *sh2, unsigned int m68k_cycles); void p32x_pwm_update(int *buf32, int length, int stereo); void p32x_pwm_ctl_changed(void); void p32x_pwm_schedule(unsigned int m68k_now); diff --git a/pico/sound/ym2612.h b/pico/sound/ym2612.h index e73c9732..9b4fd720 100644 --- a/pico/sound/ym2612.h +++ b/pico/sound/ym2612.h @@ -6,15 +6,16 @@ #define _H_FM_FM_ /* compiler dependence */ +#include #ifndef UINT8 -typedef unsigned char UINT8; /* unsigned 8bit */ -typedef unsigned short UINT16; /* unsigned 16bit */ -typedef unsigned int UINT32; /* unsigned 32bit */ +typedef uint8_t UINT8; /* unsigned 8bit */ +typedef uint16_t UINT16; /* unsigned 16bit */ +typedef uint32_t UINT32; /* unsigned 32bit */ #endif #ifndef INT8 -typedef signed char INT8; /* signed 8bit */ -typedef signed short INT16; /* signed 16bit */ -typedef signed int INT32; /* signed 32bit */ +typedef int8_t INT8; /* signed 8bit */ +typedef int16_t INT16; /* signed 16bit */ +typedef int32_t INT32; /* signed 32bit */ #endif #if 1 diff --git a/pico/videoport.c b/pico/videoport.c index e8604c33..8e42e309 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -20,7 +20,7 @@ extern const unsigned short vdpsl2cyc_32[], vdpsl2cyc_40[]; 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; @@ -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); ((u8 *)PicoMem.vram)[b] = d; - if (!((u16)(b^SATaddr) & SATmask)) + if (!(u16)((b^SATaddr) & SATmask)) Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; if (((a^SATaddr) & SATmask) == 0) @@ -402,7 +402,7 @@ static int GetDmaLength(void) return len; } -static void DmaSlow(int len, unsigned int source) +static void DmaSlow(int len, u32 source) { u32 inc = Pico.video.reg[0xf]; u32 a = Pico.video.addr | (Pico.video.addr_u << 16); @@ -881,9 +881,10 @@ update_irq: 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 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; if (c - hp < hl) @@ -897,14 +898,14 @@ static u32 VideoSr(const struct PicoVideo *pv) return d; } -PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) +PICO_INTERNAL_ASM u32 PicoVideoRead(u32 a) { a &= 0x1c; if (a == 0x04) // control port { struct PicoVideo *pv = &Pico.video; - unsigned int d = VideoSr(pv); + u32 d = VideoSr(pv); if (pv->pending) { CommandChange(pv); 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 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) d = Pico.video.hv_latch; else if (Pico.video.reg[12]&1) - d = hcounts_40[d/2] | (Pico.video.v_counter << 8); - else d = hcounts_32[d/2] | (Pico.video.v_counter << 8); + d = hcounts_40[c/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); return d; -- 2.39.5