Welcome to Emulationworld

Forum Index | FAQ | New User | Login | Search

Make a New PostPrevious ThreadView All ThreadsNext ThreadShow in Flat Mode*

SubjectRe: Tile Renderers Reply to this message
Posted byfinaldave
Posted on07/27/04 04:27 PM

> > Megadrive has 2 scroll planes A and B, with 4-bit 8x8 tiles from 4 palettes.
> > Colour 0 is transparent. A tile can be selected high or low priority by a bit
> > and can be flips x and y. All stuff I'm sure you know, but just to remind you
> > ;-)
> Is the character (pattern) data packed like graphics in the NES (i.e. one byte
> holds the lsbits of a tileline and other bytes hold other bits)?
4-bytes holds 8 pixels like this:

static int TileNorm(unsigned char *pd,int addr,int pal)
unsigned int pack=0; int t=0;

pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels
if (pack==0) return 1;

t=pack&0xf; pack>>=4; if (t) pd[3]=(unsigned char)(pal|t);
t=pack&0xf; pack>>=4; if (t) pd[2]=(unsigned char)(pal|t);
t=pack&0xf; pack>>=4; if (t) pd[1]=(unsigned char)(pal|t);
t=pack&0xf; pack>>=4; if (t) pd[0]=(unsigned char)(pal|t);
t=pack&0xf; pack>>=4; if (t) pd[7]=(unsigned char)(pal|t);
t=pack&0xf; pack>>=4; if (t) pd[6]=(unsigned char)(pal|t);
t=pack&0xf; pack>>=4; if (t) pd[5]=(unsigned char)(pal|t);
t=pack ; if (t) pd[4]=(unsigned char)(pal|t);

return 0;

Note the funny order is just because ARM is little endian, the nibbles are really in order on the Megadrive

> If so, you
> might want to consider unpacking the tile data into something more accessible (I
> got a 10% speed boost in my NES emulator by doing so). I managed to do this
> while still using the same amount of memory.

I'm not sure really - one 32-bit value does seem quite nice for throwing around.

You learn something old everyday...

Entire Thread
Subject  Posted byPosted On
*Tile Renderers  finaldave07/26/04 10:21 AM
.*Re: Tile Renderers  erikduijs07/28/04 09:46 AM
..*Re: Tile Renderers  finaldave07/28/04 05:24 PM
...*Re: Tile Renderers  Bart T.07/28/04 09:10 PM
....*Re: Tile Renderers  finaldave07/29/04 07:43 AM
.....*Re: Tile Renderers  Bart T.07/29/04 10:39 AM
......*Re: Tile Renderers  Jan_Klaassen07/29/04 11:32 AM
.......*Re: Tile Renderers  Bart T.07/29/04 02:54 PM
........*Re: Tile Renderers  finaldave07/29/04 06:46 PM
........*Re: Tile Renderers  Jan_Klaassen07/29/04 06:11 PM
.*Re: Tile Renderers  Hyde07/27/04 04:04 PM
...Re: Tile Renderers  finaldave07/27/04 04:27 PM
.*Re: Tile Renderers  Jan_Klaassen07/27/04 09:58 AM
..*Re: Tile Renderers  finaldave07/27/04 04:22 PM
...*Re: Tile Renderers  Jan_Klaassen07/28/04 11:00 AM
.*Re: Tile Renderers  Bart T.07/27/04 00:38 AM
..*Re: Tile Renderers  Stainless01/12/06 11:58 AM