X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fmode4.c;h=8c06385778d4dd35c9f5b15b072aadf225d7990d;hb=93f9619ed819dee07948416c98ca2f1c70a22666;hp=55e6d1041923382d6378d03cbece0aa708b7832e;hpb=88fd63ad10faa746ef9d7ad7d98a72e51fe2aa86;p=picodrive.git diff --git a/pico/mode4.c b/pico/mode4.c index 55e6d10..8c06385 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -26,48 +26,34 @@ static int screen_offset; pd[x] = pal|t; \ } -static int TileNormM4(int sx, int addr, int pal) +static void TileNormM4(int sx, unsigned int pack, int pal) { unsigned char *pd = Pico.est.HighCol + sx; - unsigned int pack, t; - - pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */ - if (pack) - { - PLANAR_PIXEL(0, 0) - PLANAR_PIXEL(1, 1) - PLANAR_PIXEL(2, 2) - PLANAR_PIXEL(3, 3) - PLANAR_PIXEL(4, 4) - PLANAR_PIXEL(5, 5) - PLANAR_PIXEL(6, 6) - PLANAR_PIXEL(7, 7) - return 0; - } + unsigned int t; - return 1; /* Tile blank */ + PLANAR_PIXEL(0, 0) + PLANAR_PIXEL(1, 1) + PLANAR_PIXEL(2, 2) + PLANAR_PIXEL(3, 3) + PLANAR_PIXEL(4, 4) + PLANAR_PIXEL(5, 5) + PLANAR_PIXEL(6, 6) + PLANAR_PIXEL(7, 7) } -static int TileFlipM4(int sx,int addr,int pal) +static void TileFlipM4(int sx, unsigned int pack, int pal) { unsigned char *pd = Pico.est.HighCol + sx; - unsigned int pack, t; - - pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */ - if (pack) - { - PLANAR_PIXEL(0, 7) - PLANAR_PIXEL(1, 6) - PLANAR_PIXEL(2, 5) - PLANAR_PIXEL(3, 4) - PLANAR_PIXEL(4, 3) - PLANAR_PIXEL(5, 2) - PLANAR_PIXEL(6, 1) - PLANAR_PIXEL(7, 0) - return 0; - } + unsigned int t; - return 1; /* Tile blank */ + PLANAR_PIXEL(0, 7) + PLANAR_PIXEL(1, 6) + PLANAR_PIXEL(2, 5) + PLANAR_PIXEL(3, 4) + PLANAR_PIXEL(4, 3) + PLANAR_PIXEL(5, 2) + PLANAR_PIXEL(6, 1) + PLANAR_PIXEL(7, 0) } static void draw_sprites(int scanline) @@ -75,6 +61,7 @@ static void draw_sprites(int scanline) struct PicoVideo *pv = &Pico.video; unsigned int sprites_addr[8]; unsigned int sprites_x[8]; + unsigned int pack; unsigned char *sat; int xoff = 8; // relative to HighCol, which is (screen - 8) int sprite_base, addr_mask; @@ -91,7 +78,7 @@ static void draw_sprites(int scanline) } sprite_base = (pv->reg[6] & 4) << (13-2-1); - for (i = s = 0; i < 64 && s < 8; i++) + for (i = s = 0; i < 64; i++) { int y; y = sat[i] + 1; @@ -99,6 +86,10 @@ static void draw_sprites(int scanline) break; if (y + h <= scanline || scanline < y) continue; // not on this line + if (s >= 8) { + pv->status |= SR_SOVR; + break; + } sprites_x[s] = xoff + sat[0x80 + i*2]; sprites_addr[s] = sprite_base + ((sat[0x80 + i*2 + 1] & addr_mask) << (5-1)) + @@ -106,9 +97,15 @@ static void draw_sprites(int scanline) s++; } + // really half-assed but better than nothing + if (s > 1) + pv->status |= SR_C; + // now draw all sprites backwards - for (--s; s >= 0; s--) - TileNormM4(sprites_x[s], sprites_addr[s], 0x10); + for (--s; s >= 0; s--) { + pack = *(unsigned int *)(PicoMem.vram + sprites_addr[s]); + TileNormM4(sprites_x[s], pack, 0x10); + } } // tilex_ty_prio merged to reduce register pressure @@ -120,7 +117,8 @@ static void draw_strip(const unsigned short *nametab, int dx, int cells, int til // Draw tiles across screen: for (; cells > 0; dx += 8, tilex_ty_prio++, cells--) { - int code, zero; + unsigned int pack; + int code; code = nametab[tilex_ty_prio & 0x1f]; if (code == blank) @@ -139,11 +137,13 @@ static void draw_strip(const unsigned short *nametab, int dx, int cells, int til pal = (code>>7) & 0x10; } - if (code&0x0200) zero = TileFlipM4(dx, addr, pal); - else zero = TileNormM4(dx, addr, pal); - - if (zero) - blank = code; // We know this tile is blank now + pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */ + if (pack == 0) { + blank = code; + continue; + } + if (code & 0x0200) TileFlipM4(dx, pack, pal); + else TileNormM4(dx, pack, pal); } } @@ -284,10 +284,10 @@ static void FinalizeLine8bitM4(int line) { unsigned char *pd = Pico.est.DrawLineDest; - if (!(PicoOpt & POPT_DIS_32C_BORDER)) + if (!(PicoIn.opt & POPT_DIS_32C_BORDER)) pd += 32; - memcpy32((int *)pd, (int *)(Pico.est.HighCol+8), 256/4); + memcpy(pd, Pico.est.HighCol + 8, 256); } void PicoDrawSetOutputMode4(pdso_t which) @@ -300,3 +300,4 @@ void PicoDrawSetOutputMode4(pdso_t which) } } +// vim:shiftwidth=2:ts=2:expandtab