1 /* FCE Ultra - NES/Famicom Emulator
3 * Copyright notice for this file:
4 * Copyright (C) 2002 Ben Parnell
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "../../types.h"
26 static uint32 *palettetranslate=0;
27 static int Bpp; // BYTES per pixel
30 int InitBlitToHigh(int b, uint32 rmask, uint32 gmask, uint32 bmask)
38 palettetranslate=malloc(65536*4);
40 palettetranslate=malloc(256*4);
50 void KillBlitToHigh(void)
52 free(palettetranslate);
55 void SetPaletteBlitToHigh(uint8 *src)
61 cshiftl[0]=cshiftl[1]=cshiftl[2]=-1;
64 for(x=0,y=-1,z=0;x<32;x++)
68 if(cshiftl[a]==-1) cshiftl[a]=x;
82 lower=(src[((x&255)<<2)]>>cshiftr[0])<<cshiftl[0];
83 lower|=(src[((x&255)<<2)+1]>>cshiftr[1])<<cshiftl[1];
84 lower|=(src[((x&255)<<2)+2]>>cshiftr[2])<<cshiftl[2];
85 upper=(src[((x>>8)<<2)]>>cshiftr[0])<<cshiftl[0];
86 upper|=(src[((x>>8)<<2)+1]>>cshiftr[1])<<cshiftl[1];
87 upper|=(src[((x>>8)<<2)+2]>>cshiftr[2])<<cshiftl[2];
89 palettetranslate[x]=lower|(upper<<16);
98 t=src[(x<<2)]<<cshiftl[0];
99 t|=src[(x<<2)+1]<<cshiftl[1];
100 t|=src[(x<<2)+2]<<cshiftl[2];
102 palettetranslate[x]=t;
108 void Blit8To8(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, int yscale, int efx)
113 pinc=pitch-(xr*xscale);
114 if(xscale!=1 || yscale!=1)
118 for(y=yr;y;y--,/*dest+=pinc,*/src+=272-xr)
120 int doo=yscale-(yscale>>1);
123 for(x=xr;x;x--,src++)
128 *(uint8 *)dest=*(uint8 *)src;
135 //src-=xr*(yscale-(yscale>>1));
136 dest+=pitch*(yscale>>1);
144 for(y=yr;y;y--,/*dest+=pinc,*/src+=272-xr)
149 for(x=xr;x;x--,src++)
154 *(uint8 *)dest=*(uint8 *)src;
168 for(y=yr;y;y--,dest+=pinc,src+=272-xr)
169 for(x=xr;x;x-=4,dest+=4,src+=4)
170 *(uint32 *)dest=*(uint32 *)src;
174 void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch)
187 *(uint32 *)dest=palettetranslate[(uint32)*src];
197 pinc=pitch-(xr+xr+xr);
203 tmp=palettetranslate[(uint32)*src];
204 *(uint16*)dest=(uint16)tmp;
205 *&dest[2]=(uint8)(tmp>>16);
220 *(uint32 *)dest=palettetranslate[*(uint16 *)src];