mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
sms: more md-consistent drawing
This commit is contained in:
parent
1c25c32c11
commit
eaa147519f
1 changed files with 34 additions and 42 deletions
76
pico/mode4.c
76
pico/mode4.c
|
@ -26,48 +26,34 @@ static int screen_offset;
|
||||||
pd[x] = pal|t; \
|
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 char *pd = Pico.est.HighCol + sx;
|
||||||
unsigned int pack, t;
|
unsigned int t;
|
||||||
|
|
||||||
pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */
|
PLANAR_PIXEL(0, 0)
|
||||||
if (pack)
|
PLANAR_PIXEL(1, 1)
|
||||||
{
|
PLANAR_PIXEL(2, 2)
|
||||||
PLANAR_PIXEL(0, 0)
|
PLANAR_PIXEL(3, 3)
|
||||||
PLANAR_PIXEL(1, 1)
|
PLANAR_PIXEL(4, 4)
|
||||||
PLANAR_PIXEL(2, 2)
|
PLANAR_PIXEL(5, 5)
|
||||||
PLANAR_PIXEL(3, 3)
|
PLANAR_PIXEL(6, 6)
|
||||||
PLANAR_PIXEL(4, 4)
|
PLANAR_PIXEL(7, 7)
|
||||||
PLANAR_PIXEL(5, 5)
|
|
||||||
PLANAR_PIXEL(6, 6)
|
|
||||||
PLANAR_PIXEL(7, 7)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1; /* Tile blank */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 char *pd = Pico.est.HighCol + sx;
|
||||||
unsigned int pack, t;
|
unsigned int t;
|
||||||
|
|
||||||
pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */
|
PLANAR_PIXEL(0, 7)
|
||||||
if (pack)
|
PLANAR_PIXEL(1, 6)
|
||||||
{
|
PLANAR_PIXEL(2, 5)
|
||||||
PLANAR_PIXEL(0, 7)
|
PLANAR_PIXEL(3, 4)
|
||||||
PLANAR_PIXEL(1, 6)
|
PLANAR_PIXEL(4, 3)
|
||||||
PLANAR_PIXEL(2, 5)
|
PLANAR_PIXEL(5, 2)
|
||||||
PLANAR_PIXEL(3, 4)
|
PLANAR_PIXEL(6, 1)
|
||||||
PLANAR_PIXEL(4, 3)
|
PLANAR_PIXEL(7, 0)
|
||||||
PLANAR_PIXEL(5, 2)
|
|
||||||
PLANAR_PIXEL(6, 1)
|
|
||||||
PLANAR_PIXEL(7, 0)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1; /* Tile blank */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw_sprites(int scanline)
|
static void draw_sprites(int scanline)
|
||||||
|
@ -75,6 +61,7 @@ static void draw_sprites(int scanline)
|
||||||
struct PicoVideo *pv = &Pico.video;
|
struct PicoVideo *pv = &Pico.video;
|
||||||
unsigned int sprites_addr[8];
|
unsigned int sprites_addr[8];
|
||||||
unsigned int sprites_x[8];
|
unsigned int sprites_x[8];
|
||||||
|
unsigned int pack;
|
||||||
unsigned char *sat;
|
unsigned char *sat;
|
||||||
int xoff = 8; // relative to HighCol, which is (screen - 8)
|
int xoff = 8; // relative to HighCol, which is (screen - 8)
|
||||||
int sprite_base, addr_mask;
|
int sprite_base, addr_mask;
|
||||||
|
@ -115,8 +102,10 @@ static void draw_sprites(int scanline)
|
||||||
pv->status |= SR_C;
|
pv->status |= SR_C;
|
||||||
|
|
||||||
// now draw all sprites backwards
|
// now draw all sprites backwards
|
||||||
for (--s; s >= 0; s--)
|
for (--s; s >= 0; s--) {
|
||||||
TileNormM4(sprites_x[s], sprites_addr[s], 0x10);
|
pack = *(unsigned int *)(PicoMem.vram + sprites_addr[s]);
|
||||||
|
TileNormM4(sprites_x[s], pack, 0x10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tilex_ty_prio merged to reduce register pressure
|
// tilex_ty_prio merged to reduce register pressure
|
||||||
|
@ -128,7 +117,8 @@ static void draw_strip(const unsigned short *nametab, int dx, int cells, int til
|
||||||
// Draw tiles across screen:
|
// Draw tiles across screen:
|
||||||
for (; cells > 0; dx += 8, tilex_ty_prio++, cells--)
|
for (; cells > 0; dx += 8, tilex_ty_prio++, cells--)
|
||||||
{
|
{
|
||||||
int code, zero;
|
unsigned int pack;
|
||||||
|
int code;
|
||||||
|
|
||||||
code = nametab[tilex_ty_prio & 0x1f];
|
code = nametab[tilex_ty_prio & 0x1f];
|
||||||
if (code == blank)
|
if (code == blank)
|
||||||
|
@ -147,11 +137,13 @@ static void draw_strip(const unsigned short *nametab, int dx, int cells, int til
|
||||||
pal = (code>>7) & 0x10;
|
pal = (code>>7) & 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code&0x0200) zero = TileFlipM4(dx, addr, pal);
|
pack = *(unsigned int *)(PicoMem.vram + addr); /* Get 4 bitplanes / 8 pixels */
|
||||||
else zero = TileNormM4(dx, addr, pal);
|
if (pack == 0) {
|
||||||
|
blank = code;
|
||||||
if (zero)
|
continue;
|
||||||
blank = code; // We know this tile is blank now
|
}
|
||||||
|
if (code & 0x0200) TileFlipM4(dx, pack, pal);
|
||||||
|
else TileNormM4(dx, pack, pal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue