gfx.c
changeset 4171 5c6e60c392c3
parent 3798 b1f5290b36b1
child 4300 c7e43c47a2b9
equal deleted inserted replaced
4170:81bafc4dd1b9 4171:5c6e60c392c3
   675 	}
   675 	}
   676 }
   676 }
   677 
   677 
   678 typedef struct BlitterParams {
   678 typedef struct BlitterParams {
   679 	int start_x, start_y;
   679 	int start_x, start_y;
   680 	const byte* sprite;
   680 	const byte *sprite;
   681 	const byte* sprite_org;
   681 	const byte *sprite_org;
   682 	Pixel *dst;
   682 	Pixel *dst;
   683 	int mode;
   683 	int mode;
   684 	int width, height;
   684 	int width, height;
   685 	int width_org;
   685 	int width_org;
   686 	int height_org;
   686 	int height_org;
   688 	byte info;
   688 	byte info;
   689 } BlitterParams;
   689 } BlitterParams;
   690 
   690 
   691 static void GfxBlitTileZoomIn(BlitterParams *bp)
   691 static void GfxBlitTileZoomIn(BlitterParams *bp)
   692 {
   692 {
   693 	const byte* src_o = bp->sprite;
   693 	const byte *src_o = bp->sprite;
   694 	const byte* src;
   694 	const byte *src;
   695 	int num, skip;
   695 	int num, skip;
   696 	byte done;
   696 	byte done;
   697 	Pixel *dst;
   697 	Pixel *dst;
   698 	const byte* ctab;
   698 	const byte *ctab;
   699 
   699 
   700 	if (bp->mode & 1) {
   700 	if (bp->mode & 1) {
   701 		src_o += ReadLE16Aligned(src_o + bp->start_y * 2);
   701 		src_o += ReadLE16Aligned(src_o + bp->start_y * 2);
   702 
   702 
   703 		do {
   703 		do {
   890 	}
   890 	}
   891 }
   891 }
   892 
   892 
   893 static void GfxBlitTileZoomMedium(BlitterParams *bp)
   893 static void GfxBlitTileZoomMedium(BlitterParams *bp)
   894 {
   894 {
   895 	const byte* src_o = bp->sprite;
   895 	const byte *src_o = bp->sprite;
   896 	const byte* src;
   896 	const byte *src;
   897 	int num, skip;
   897 	int num, skip;
   898 	byte done;
   898 	byte done;
   899 	Pixel *dst;
   899 	Pixel *dst;
   900 	const byte* ctab;
   900 	const byte *ctab;
   901 
   901 
   902 	if (bp->mode & 1) {
   902 	if (bp->mode & 1) {
   903 		src_o += ReadLE16Aligned(src_o + bp->start_y * 2);
   903 		src_o += ReadLE16Aligned(src_o + bp->start_y * 2);
   904 		do {
   904 		do {
   905 			do {
   905 			do {
  1095 	}
  1095 	}
  1096 }
  1096 }
  1097 
  1097 
  1098 static void GfxBlitTileZoomOut(BlitterParams *bp)
  1098 static void GfxBlitTileZoomOut(BlitterParams *bp)
  1099 {
  1099 {
  1100 	const byte* src_o = bp->sprite;
  1100 	const byte *src_o = bp->sprite;
  1101 	const byte* src;
  1101 	const byte *src;
  1102 	int num, skip;
  1102 	int num, skip;
  1103 	byte done;
  1103 	byte done;
  1104 	Pixel *dst;
  1104 	Pixel *dst;
  1105 	const byte* ctab;
  1105 	const byte *ctab;
  1106 
  1106 
  1107 	if (bp->mode & 1) {
  1107 	if (bp->mode & 1) {
  1108 		src_o += ReadLE16Aligned(src_o + bp->start_y * 2);
  1108 		src_o += ReadLE16Aligned(src_o + bp->start_y * 2);
  1109 		for (;;) {
  1109 		for (;;) {
  1110 			do {
  1110 			do {
  1311 	}
  1311 	}
  1312 }
  1312 }
  1313 
  1313 
  1314 static void GfxBlitZoomOutUncomp(BlitterParams *bp)
  1314 static void GfxBlitZoomOutUncomp(BlitterParams *bp)
  1315 {
  1315 {
  1316 	const byte* src = bp->sprite;
  1316 	const byte *src = bp->sprite;
  1317 	Pixel *dst = bp->dst;
  1317 	Pixel *dst = bp->dst;
  1318 	int height = bp->height;
  1318 	int height = bp->height;
  1319 	int width = bp->width;
  1319 	int width = bp->width;
  1320 	int i;
  1320 	int i;
  1321 
  1321 
  1359 	}
  1359 	}
  1360 }
  1360 }
  1361 
  1361 
  1362 typedef void (*BlitZoomFunc)(BlitterParams *bp);
  1362 typedef void (*BlitZoomFunc)(BlitterParams *bp);
  1363 
  1363 
  1364 static void GfxMainBlitter(const Sprite* sprite, int x, int y, int mode)
  1364 static void GfxMainBlitter(const Sprite *sprite, int x, int y, int mode)
  1365 {
  1365 {
  1366 	const DrawPixelInfo* dpi = _cur_dpi;
  1366 	const DrawPixelInfo *dpi = _cur_dpi;
  1367 	int start_x, start_y;
  1367 	int start_x, start_y;
  1368 	byte info;
  1368 	byte info;
  1369 	BlitterParams bp;
  1369 	BlitterParams bp;
  1370 	int zoom_mask = ~((1 << dpi->zoom) - 1);
  1370 	int zoom_mask = ~((1 << dpi->zoom) - 1);
  1371 
  1371 
  1494 #define EXTR(p, q) (((uint16)(_timer_counter * (p)) * (q)) >> 16)
  1494 #define EXTR(p, q) (((uint16)(_timer_counter * (p)) * (q)) >> 16)
  1495 #define EXTR2(p, q) (((uint16)(~_timer_counter * (p)) * (q)) >> 16)
  1495 #define EXTR2(p, q) (((uint16)(~_timer_counter * (p)) * (q)) >> 16)
  1496 
  1496 
  1497 void DoPaletteAnimations(void)
  1497 void DoPaletteAnimations(void)
  1498 {
  1498 {
  1499 	const Colour* s;
  1499 	const Colour *s;
  1500 	Colour* d;
  1500 	Colour *d;
  1501 	/* Amount of colors to be rotated.
  1501 	/* Amount of colors to be rotated.
  1502 	 * A few more for the DOS palette, because the water colors are
  1502 	 * A few more for the DOS palette, because the water colors are
  1503 	 * 245-254 for DOS and 217-226 for Windows.  */
  1503 	 * 245-254 for DOS and 217-226 for Windows.  */
  1504 	const ExtraPaletteValues *ev = &_extra_palette_values;
  1504 	const ExtraPaletteValues *ev = &_extra_palette_values;
  1505 	int c = _use_dos_palette ? 38 : 28;
  1505 	int c = _use_dos_palette ? 38 : 28;
  1710 
  1710 
  1711 #if defined(_DEBUG)
  1711 #if defined(_DEBUG)
  1712 static void DbgScreenRect(int left, int top, int right, int bottom)
  1712 static void DbgScreenRect(int left, int top, int right, int bottom)
  1713 {
  1713 {
  1714 	DrawPixelInfo dp;
  1714 	DrawPixelInfo dp;
  1715 	DrawPixelInfo* old;
  1715 	DrawPixelInfo *old;
  1716 
  1716 
  1717 	old = _cur_dpi;
  1717 	old = _cur_dpi;
  1718 	_cur_dpi = &dp;
  1718 	_cur_dpi = &dp;
  1719 	dp = _screen;
  1719 	dp = _screen;
  1720 	GfxFillRect(left, top, right - 1, bottom - 1, rand() & 255);
  1720 	GfxFillRect(left, top, right - 1, bottom - 1, rand() & 255);
  1862 void MarkWholeScreenDirty(void)
  1862 void MarkWholeScreenDirty(void)
  1863 {
  1863 {
  1864 	SetDirtyBlocks(0, 0, _screen.width, _screen.height);
  1864 	SetDirtyBlocks(0, 0, _screen.width, _screen.height);
  1865 }
  1865 }
  1866 
  1866 
  1867 bool FillDrawPixelInfo(DrawPixelInfo* n, const DrawPixelInfo* o, int left, int top, int width, int height)
  1867 bool FillDrawPixelInfo(DrawPixelInfo *n, const DrawPixelInfo *o, int left, int top, int width, int height)
  1868 {
  1868 {
  1869 	int t;
  1869 	int t;
  1870 
  1870 
  1871 	if (o == NULL) o = _cur_dpi;
  1871 	if (o == NULL) o = _cur_dpi;
  1872 
  1872