2 * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
4 * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and
5 * Jerremy Koot (jkoot@snes9x.com)
7 * Super FX C emulator code
8 * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and
10 * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_.
12 * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson.
13 * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_.
14 * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com).
16 * DOS port code contains the works of other authors. See headers in
19 * Snes9x homepage: http://www.snes9x.com
21 * Permission to use, copy, modify and distribute Snes9x in both binary and
22 * source form, for non-commercial purposes, is hereby granted without fee,
23 * providing that this license information and copyright notice appear with
24 * all copies and any derived work.
26 * This software is provided 'as-is', without any express or implied
27 * warranty. In no event shall the authors be held liable for any damages
28 * arising from the use of this software.
30 * Snes9x is freeware for PERSONAL USE only. Commercial users should
31 * seek permission of the copyright holders first. Commercial use includes
32 * charging money for Snes9x or software derived from Snes9x.
34 * The copyright holders request that bug fixes and improvements to the code
35 * should be forwarded to them so everyone can benefit from the modifications
38 * Super NES and Super Nintendo Entertainment System are trademarks of
39 * Nintendo Co., Limited and its subsidiary companies.
53 extern uint32 HeadMask [4];
54 extern uint32 TailMask [5];
56 uint8 ConvertTile (uint8 *pCache, uint32 TileAddr)
58 register uint8 *tp = &Memory.VRAM[TileAddr];
59 uint32 *p = (uint32 *) pCache;
69 for (line = 8; line != 0; line--, tp += 2)
72 if ((pix = *(tp + 0)))
74 p1 |= odd_high[0][pix >> 4];
75 p2 |= odd_low[0][pix & 0xf];
77 if ((pix = *(tp + 1)))
79 p1 |= even_high[0][pix >> 4];
80 p2 |= even_low[0][pix & 0xf];
82 if ((pix = *(tp + 16)))
84 p1 |= odd_high[1][pix >> 4];
85 p2 |= odd_low[1][pix & 0xf];
87 if ((pix = *(tp + 17)))
89 p1 |= even_high[1][pix >> 4];
90 p2 |= even_low[1][pix & 0xf];
92 if ((pix = *(tp + 32)))
94 p1 |= odd_high[2][pix >> 4];
95 p2 |= odd_low[2][pix & 0xf];
97 if ((pix = *(tp + 33)))
99 p1 |= even_high[2][pix >> 4];
100 p2 |= even_low[2][pix & 0xf];
102 if ((pix = *(tp + 48)))
104 p1 |= odd_high[3][pix >> 4];
105 p2 |= odd_low[3][pix & 0xf];
107 if ((pix = *(tp + 49)))
109 p1 |= even_high[3][pix >> 4];
110 p2 |= even_low[3][pix & 0xf];
119 for (line = 8; line != 0; line--, tp += 2)
122 if ((pix = *(tp + 0)))
124 p1 |= odd_high[0][pix >> 4];
125 p2 |= odd_low[0][pix & 0xf];
127 if ((pix = *(tp + 1)))
129 p1 |= even_high[0][pix >> 4];
130 p2 |= even_low[0][pix & 0xf];
132 if ((pix = *(tp + 16)))
134 p1 |= odd_high[1][pix >> 4];
135 p2 |= odd_low[1][pix & 0xf];
137 if ((pix = *(tp + 17)))
139 p1 |= even_high[1][pix >> 4];
140 p2 |= even_low[1][pix & 0xf];
149 for (line = 8; line != 0; line--, tp += 2)
152 if ((pix = *(tp + 0)))
154 p1 |= odd_high[0][pix >> 4];
155 p2 |= odd_low[0][pix & 0xf];
157 if ((pix = *(tp + 1)))
159 p1 |= even_high[0][pix >> 4];
160 p2 |= even_low[0][pix & 0xf];
168 return (non_zero ? TRUE : BLANK_TILE);
171 INLINE void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
173 register uint8 Pixel;
174 uint8 *Screen = gfx->S + Offset;
175 uint8 *Depth = gfx->DB + Offset;
178 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \
180 Screen [N] = (uint8) gfx->ScreenColors [Pixel]; \
181 Depth [N] = gfx->Z2; \
191 INLINE void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
193 register uint8 Pixel;
194 uint8 *Screen = gfx->S + Offset;
195 uint8 *Depth = gfx->DB + Offset;
198 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \
200 Screen [N] = (uint8) gfx->ScreenColors [Pixel]; \
201 Depth [N] = gfx->Z2; \
211 inline void WRITE_4PIXELSHI16 (uint32 Offset, uint8 *Pixels)
214 uint16 *Screen = (uint16 *) GFX.S + Offset;
215 uint8 *Depth = GFX.DB + Offset;
218 if (GFX.Z1 > Depth [N] && (Pixel = Pixels[2*N])) \
220 Screen [N] = GFX.ScreenColors [Pixel]; \
221 Depth [N] = GFX.Z2; \
231 inline void WRITE_4PIXELSHI16_FLIPPED (uint32 Offset, uint8 *Pixels)
234 uint16 *Screen = (uint16 *) GFX.S + Offset;
235 uint8 *Depth = GFX.DB + Offset;
238 if (GFX.Z1 > Depth [N] && (Pixel = Pixels[6 - 2*N])) \
240 Screen [N] = GFX.ScreenColors [Pixel]; \
241 Depth [N] = GFX.Z2; \
251 INLINE void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
253 register uint8 Pixel;
254 uint8 *Screen = gfx->S + Offset;
255 uint8 *Depth = gfx->DB + Offset;
258 if (gfx->Z1 > Depth [0] && (Pixel = Pixels[N])) \
260 Screen [N * 2] = Screen [N * 2 + 1] = (uint8) gfx->ScreenColors [Pixel]; \
261 Depth [N * 2] = Depth [N * 2 + 1] = gfx->Z2; \
271 INLINE void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
273 register uint8 Pixel;
274 uint8 *Screen = gfx->S + Offset;
275 uint8 *Depth = gfx->DB + Offset;
278 if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \
280 Screen [N * 2] = Screen [N * 2 + 1] = (uint8) gfx->ScreenColors [Pixel]; \
281 Depth [N * 2] = Depth [N * 2 + 1] = gfx->Z2; \
291 INLINE void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
293 register uint8 Pixel;
294 uint8 *Screen = gfx->S + Offset;
295 uint8 *Depth = gfx->DB + Offset;
298 if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \
300 Screen [N * 2] = Screen [N * 2 + 1] = Screen [gfx->RealPitch + N * 2] = \
301 Screen [gfx->RealPitch + N * 2 + 1] = (uint8) gfx->ScreenColors [Pixel]; \
302 Depth [N * 2] = Depth [N * 2 + 1] = Depth [gfx->RealPitch + N * 2] = \
303 Depth [gfx->RealPitch + N * 2 + 1] = gfx->Z2; \
313 INLINE void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
315 register uint8 Pixel;
316 uint8 *Screen = gfx->S + Offset;
317 uint8 *Depth = gfx->DB + Offset;
320 if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \
322 Screen [N * 2] = Screen [N * 2 + 1] = Screen [gfx->RealPitch + N * 2] = \
323 Screen [gfx->RealPitch + N * 2 + 1] = (uint8) gfx->ScreenColors [Pixel]; \
324 Depth [N * 2] = Depth [N * 2 + 1] = Depth [gfx->RealPitch + N * 2] = \
325 Depth [gfx->RealPitch + N * 2 + 1] = gfx->Z2; \
335 void DrawTile (uint32 Tile, uint32 Offset, uint32 StartLine,
336 uint32 LineCount, struct SGFX * gfx)
342 RENDER_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4)
345 void DrawClippedTile (uint32 Tile, uint32 Offset,
346 uint32 StartPixel, uint32 Width,
347 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
353 RENDER_CLIPPED_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4)
356 void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine,
357 uint32 LineCount, struct SGFX * gfx)
363 RENDER_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8)
366 void DrawClippedTilex2 (uint32 Tile, uint32 Offset,
367 uint32 StartPixel, uint32 Width,
368 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
374 RENDER_CLIPPED_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8)
377 void DrawTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartLine,
378 uint32 LineCount, struct SGFX * gfx)
384 RENDER_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8)
387 void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset,
388 uint32 StartPixel, uint32 Width,
389 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
395 RENDER_CLIPPED_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8)
398 void DrawLargePixel (uint32 Tile, uint32 Offset,
399 uint32 StartPixel, uint32 Pixels,
400 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
404 register uint8 *sp = gfx->S + Offset;
405 uint8 *Depth = gfx->DB + Offset;
407 #define PLOT_PIXEL(screen, pixel) (pixel)
409 RENDER_TILE_LARGE (((uint8) gfx->ScreenColors [pixel]), PLOT_PIXEL)
412 INLINE void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
414 register uint32 Pixel;
415 uint16 *Screen = (uint16 *) gfx->S + Offset;
416 uint8 *Depth = gfx->DB + Offset;
419 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \
421 Screen [N] = gfx->ScreenColors [Pixel]; \
422 Depth [N] = gfx->Z2; \
432 INLINE void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
434 register uint32 Pixel;
435 uint16 *Screen = (uint16 *) gfx->S + Offset;
436 uint8 *Depth = gfx->DB + Offset;
439 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \
441 Screen [N] = gfx->ScreenColors [Pixel]; \
442 Depth [N] = gfx->Z2; \
452 INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
454 register uint32 Pixel;
455 uint16 *Screen = (uint16 *) gfx->S + Offset;
456 uint8 *Depth = gfx->DB + Offset;
459 if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \
461 Screen [N * 2] = Screen [N * 2 + 1] = gfx->ScreenColors [Pixel]; \
462 Depth [N * 2] = Depth [N * 2 + 1] = gfx->Z2; \
472 INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
474 register uint32 Pixel;
475 uint16 *Screen = (uint16 *) gfx->S + Offset;
476 uint8 *Depth = gfx->DB + Offset;
479 if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \
481 Screen [N * 2] = Screen [N * 2 + 1] = gfx->ScreenColors [Pixel]; \
482 Depth [N * 2] = Depth [N * 2 + 1] = gfx->Z2; \
492 INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
494 register uint32 Pixel;
495 uint16 *Screen = (uint16 *) gfx->S + Offset;
496 uint8 *Depth = gfx->DB + Offset;
499 if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \
501 Screen [N * 2] = Screen [N * 2 + 1] = Screen [(gfx->RealPitch >> 1) + N * 2] = \
502 Screen [(gfx->RealPitch >> 1) + N * 2 + 1] = gfx->ScreenColors [Pixel]; \
503 Depth [N * 2] = Depth [N * 2 + 1] = Depth [(gfx->RealPitch >> 1) + N * 2] = \
504 Depth [(gfx->RealPitch >> 1) + N * 2 + 1] = gfx->Z2; \
514 INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
516 register uint32 Pixel;
517 uint16 *Screen = (uint16 *) gfx->S + Offset;
518 uint8 *Depth = gfx->DB + Offset;
521 if (gfx->Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \
523 Screen [N * 2] = Screen [N * 2 + 1] = Screen [(gfx->RealPitch >> 1) + N * 2] = \
524 Screen [(gfx->RealPitch >> 1) + N * 2 + 1] = gfx->ScreenColors [Pixel]; \
525 Depth [N * 2] = Depth [N * 2 + 1] = Depth [(gfx->RealPitch >> 1) + N * 2] = \
526 Depth [(gfx->RealPitch >> 1) + N * 2 + 1] = gfx->Z2; \
536 void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine,
537 uint32 LineCount, struct SGFX * gfx)
542 RENDER_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4)
545 void DrawClippedTile16 (uint32 Tile, uint32 Offset,
546 uint32 StartPixel, uint32 Width,
547 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
553 RENDER_CLIPPED_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4)
556 void DrawTile16x2 (uint32 Tile, uint32 Offset, uint32 StartLine,
557 uint32 LineCount, struct SGFX * gfx)
562 RENDER_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8)
565 void DrawClippedTile16x2 (uint32 Tile, uint32 Offset,
566 uint32 StartPixel, uint32 Width,
567 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
573 RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8)
576 void DrawTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartLine,
577 uint32 LineCount, struct SGFX * gfx)
582 RENDER_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8)
585 void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset,
586 uint32 StartPixel, uint32 Width,
587 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
593 RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8)
596 void DrawLargePixel16 (uint32 Tile, uint32 Offset,
597 uint32 StartPixel, uint32 Pixels,
598 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
602 register uint16 *sp = (uint16 *) gfx->S + Offset;
603 uint8 *Depth = gfx->DB + Offset;
606 RENDER_TILE_LARGE (gfx->ScreenColors [pixel], PLOT_PIXEL)
609 INLINE void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
611 register uint32 Pixel;
612 uint16 *Screen = (uint16 *) gfx->S + Offset;
613 uint8 *Depth = gfx->ZBuffer + Offset;
614 uint8 *SubDepth = gfx->SubZBuffer + Offset;
617 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \
621 if (SubDepth [N] != 1) \
622 Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \
623 Screen [gfx->Delta + N]); \
625 Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \
629 Screen [N] = gfx->ScreenColors [Pixel]; \
630 Depth [N] = gfx->Z2; \
641 INLINE void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
643 register uint32 Pixel;
644 uint16 *Screen = (uint16 *) gfx->S + Offset;
645 uint8 *Depth = gfx->ZBuffer + Offset;
646 uint8 *SubDepth = gfx->SubZBuffer + Offset;
649 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \
653 if (SubDepth [N] != 1) \
654 Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \
655 Screen [gfx->Delta + N]); \
657 Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \
661 Screen [N] = gfx->ScreenColors [Pixel]; \
662 Depth [N] = gfx->Z2; \
673 INLINE void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
675 register uint32 Pixel;
676 uint16 *Screen = (uint16 *) gfx->S + Offset;
677 uint8 *Depth = gfx->ZBuffer + Offset;
678 uint8 *SubDepth = gfx->SubZBuffer + Offset;
681 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \
685 if (SubDepth [N] != 1) \
686 Screen [N] = (uint16) (COLOR_ADD1_2 (gfx->ScreenColors [Pixel], \
687 Screen [gfx->Delta + N])); \
689 Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \
693 Screen [N] = gfx->ScreenColors [Pixel]; \
694 Depth [N] = gfx->Z2; \
705 INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
707 register uint32 Pixel;
708 uint16 *Screen = (uint16 *) gfx->S + Offset;
709 uint8 *Depth = gfx->ZBuffer + Offset;
710 uint8 *SubDepth = gfx->SubZBuffer + Offset;
713 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \
717 if (SubDepth [N] != 1) \
718 Screen [N] = (uint16) (COLOR_ADD1_2 (gfx->ScreenColors [Pixel], \
719 Screen [gfx->Delta + N])); \
721 Screen [N] = COLOR_ADD (gfx->ScreenColors [Pixel], \
725 Screen [N] = gfx->ScreenColors [Pixel]; \
726 Depth [N] = gfx->Z2; \
737 INLINE void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
739 register uint32 Pixel;
740 uint16 *Screen = (uint16 *) gfx->S + Offset;
741 uint8 *Depth = gfx->ZBuffer + Offset;
742 uint8 *SubDepth = gfx->SubZBuffer + Offset;
745 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \
749 if (SubDepth [N] != 1) \
750 Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \
751 Screen [gfx->Delta + N]); \
753 Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \
757 Screen [N] = gfx->ScreenColors [Pixel]; \
758 Depth [N] = gfx->Z2; \
769 INLINE void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
771 register uint32 Pixel;
772 uint16 *Screen = (uint16 *) gfx->S + Offset;
773 uint8 *Depth = gfx->ZBuffer + Offset;
774 uint8 *SubDepth = gfx->SubZBuffer + Offset;
777 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \
781 if (SubDepth [N] != 1) \
782 Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \
783 Screen [gfx->Delta + N]); \
785 Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \
789 Screen [N] = gfx->ScreenColors [Pixel]; \
790 Depth [N] = gfx->Z2; \
801 INLINE void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
803 register uint32 Pixel;
804 uint16 *Screen = (uint16 *) gfx->S + Offset;
805 uint8 *Depth = gfx->ZBuffer + Offset;
806 uint8 *SubDepth = gfx->SubZBuffer + Offset;
809 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \
813 if (SubDepth [N] != 1) \
814 Screen [N] = (uint16) COLOR_SUB1_2 (gfx->ScreenColors [Pixel], \
815 Screen [gfx->Delta + N]); \
817 Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \
821 Screen [N] = gfx->ScreenColors [Pixel]; \
822 Depth [N] = gfx->Z2; \
833 INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
835 register uint32 Pixel;
836 uint16 *Screen = (uint16 *) gfx->S + Offset;
837 uint8 *Depth = gfx->ZBuffer + Offset;
838 uint8 *SubDepth = gfx->SubZBuffer + Offset;
841 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \
845 if (SubDepth [N] != 1) \
846 Screen [N] = (uint16) COLOR_SUB1_2 (gfx->ScreenColors [Pixel], \
847 Screen [gfx->Delta + N]); \
849 Screen [N] = (uint16) COLOR_SUB (gfx->ScreenColors [Pixel], \
853 Screen [N] = gfx->ScreenColors [Pixel]; \
854 Depth [N] = gfx->Z2; \
866 void DrawTile16Add (uint32 Tile, uint32 Offset, uint32 StartLine,
867 uint32 LineCount, struct SGFX * gfx)
872 RENDER_TILE(WRITE_4PIXELS16_ADD, WRITE_4PIXELS16_FLIPPED_ADD, 4)
875 void DrawClippedTile16Add (uint32 Tile, uint32 Offset,
876 uint32 StartPixel, uint32 Width,
877 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
883 RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADD, WRITE_4PIXELS16_FLIPPED_ADD, 4)
886 void DrawTile16Add1_2 (uint32 Tile, uint32 Offset, uint32 StartLine,
887 uint32 LineCount, struct SGFX * gfx)
892 RENDER_TILE(WRITE_4PIXELS16_ADD1_2, WRITE_4PIXELS16_FLIPPED_ADD1_2, 4)
895 void DrawClippedTile16Add1_2 (uint32 Tile, uint32 Offset,
896 uint32 StartPixel, uint32 Width,
897 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
903 RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADD1_2, WRITE_4PIXELS16_FLIPPED_ADD1_2, 4)
906 void DrawTile16Sub (uint32 Tile, uint32 Offset, uint32 StartLine,
907 uint32 LineCount, struct SGFX * gfx)
912 RENDER_TILE(WRITE_4PIXELS16_SUB, WRITE_4PIXELS16_FLIPPED_SUB, 4)
915 void DrawClippedTile16Sub (uint32 Tile, uint32 Offset,
916 uint32 StartPixel, uint32 Width,
917 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
923 RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB, WRITE_4PIXELS16_FLIPPED_SUB, 4)
926 void DrawTile16Sub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine,
927 uint32 LineCount, struct SGFX * gfx)
932 RENDER_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4)
935 void DrawClippedTile16Sub1_2 (uint32 Tile, uint32 Offset,
936 uint32 StartPixel, uint32 Width,
937 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
943 RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4)
946 INLINE void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
948 register uint32 Pixel;
949 uint16 *Screen = (uint16 *) gfx->S + Offset;
950 uint8 *Depth = gfx->ZBuffer + Offset;
951 uint8 *SubDepth = gfx->SubZBuffer + Offset;
954 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \
956 if (SubDepth [N] == 1) \
957 Screen [N] = (uint16) (COLOR_ADD1_2 (gfx->ScreenColors [Pixel], \
958 gfx->FixedColour)); \
960 Screen [N] = gfx->ScreenColors [Pixel];\
961 Depth [N] = gfx->Z2; \
972 INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
974 register uint32 Pixel;
975 uint16 *Screen = (uint16 *) gfx->S + Offset;
976 uint8 *Depth = gfx->ZBuffer + Offset;
977 uint8 *SubDepth = gfx->SubZBuffer + Offset;
980 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \
982 if (SubDepth [N] == 1) \
983 Screen [N] = (uint16) (COLOR_ADD1_2 (gfx->ScreenColors [Pixel], \
984 gfx->FixedColour)); \
986 Screen [N] = gfx->ScreenColors [Pixel];\
987 Depth [N] = gfx->Z2; \
998 INLINE void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
1000 register uint32 Pixel;
1001 uint16 *Screen = (uint16 *) gfx->S + Offset;
1002 uint8 *Depth = gfx->ZBuffer + Offset;
1003 uint8 *SubDepth = gfx->SubZBuffer + Offset;
1006 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[N])) \
1008 if (SubDepth [N] == 1) \
1009 Screen [N] = (uint16) COLOR_SUB1_2 (gfx->ScreenColors [Pixel], \
1010 gfx->FixedColour); \
1012 Screen [N] = gfx->ScreenColors [Pixel]; \
1013 Depth [N] = gfx->Z2; \
1024 INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels, struct SGFX * gfx)
1026 register uint32 Pixel;
1027 uint16 *Screen = (uint16 *) gfx->S + Offset;
1028 uint8 *Depth = gfx->ZBuffer + Offset;
1029 uint8 *SubDepth = gfx->SubZBuffer + Offset;
1032 if (gfx->Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \
1034 if (SubDepth [N] == 1) \
1035 Screen [N] = (uint16) COLOR_SUB1_2 (gfx->ScreenColors [Pixel], \
1036 gfx->FixedColour); \
1038 Screen [N] = gfx->ScreenColors [Pixel]; \
1039 Depth [N] = gfx->Z2; \
1050 void DrawTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, uint32 StartLine,
1051 uint32 LineCount, struct SGFX * gfx)
1056 RENDER_TILE(WRITE_4PIXELS16_ADDF1_2, WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4)
1059 void DrawClippedTile16FixedAdd1_2 (uint32 Tile, uint32 Offset,
1060 uint32 StartPixel, uint32 Width,
1061 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
1067 RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADDF1_2,
1068 WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4)
1071 void DrawTile16FixedSub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine,
1072 uint32 LineCount, struct SGFX * gfx)
1077 RENDER_TILE(WRITE_4PIXELS16_SUBF1_2, WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4)
1080 void DrawClippedTile16FixedSub1_2 (uint32 Tile, uint32 Offset,
1081 uint32 StartPixel, uint32 Width,
1082 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
1088 RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUBF1_2,
1089 WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4)
1092 void DrawLargePixel16Add (uint32 Tile, uint32 Offset,
1093 uint32 StartPixel, uint32 Pixels,
1094 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
1098 register uint16 *sp = (uint16 *) gfx->S + Offset;
1099 uint8 *Depth = gfx->ZBuffer + Offset;
1100 register uint16 pixel;
1102 #define LARGE_ADD_PIXEL(s, p) \
1103 (Depth [z + gfx->DepthDelta] ? (Depth [z + gfx->DepthDelta] != 1 ? \
1104 COLOR_ADD (p, *(s + gfx->Delta)) : \
1105 COLOR_ADD (p, gfx->FixedColour)) \
1108 RENDER_TILE_LARGE (gfx->ScreenColors [pixel], LARGE_ADD_PIXEL)
1111 void DrawLargePixel16Add1_2 (uint32 Tile, uint32 Offset,
1112 uint32 StartPixel, uint32 Pixels,
1113 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
1117 register uint16 *sp = (uint16 *) gfx->S + Offset;
1118 uint8 *Depth = gfx->ZBuffer + Offset;
1119 register uint16 pixel;
1121 #define LARGE_ADD_PIXEL1_2(s, p) \
1122 ((uint16) (Depth [z + gfx->DepthDelta] ? (Depth [z + gfx->DepthDelta] != 1 ? \
1123 COLOR_ADD1_2 (p, *(s + gfx->Delta)) : \
1124 COLOR_ADD (p, gfx->FixedColour)) \
1127 RENDER_TILE_LARGE (gfx->ScreenColors [pixel], LARGE_ADD_PIXEL1_2)
1130 void DrawLargePixel16Sub (uint32 Tile, uint32 Offset,
1131 uint32 StartPixel, uint32 Pixels,
1132 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
1136 register uint16 *sp = (uint16 *) gfx->S + Offset;
1137 uint8 *Depth = gfx->ZBuffer + Offset;
1138 register uint16 pixel;
1140 #define LARGE_SUB_PIXEL(s, p) \
1141 (Depth [z + gfx->DepthDelta] ? (Depth [z + gfx->DepthDelta] != 1 ? \
1142 COLOR_SUB (p, *(s + gfx->Delta)) : \
1143 COLOR_SUB (p, gfx->FixedColour)) \
1146 RENDER_TILE_LARGE (gfx->ScreenColors [pixel], LARGE_SUB_PIXEL)
1149 void DrawLargePixel16Sub1_2 (uint32 Tile, uint32 Offset,
1150 uint32 StartPixel, uint32 Pixels,
1151 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
1155 register uint16 *sp = (uint16 *) gfx->S + Offset;
1156 uint8 *Depth = gfx->ZBuffer + Offset;
1159 #define LARGE_SUB_PIXEL1_2(s, p) \
1160 (Depth [z + gfx->DepthDelta] ? (Depth [z + gfx->DepthDelta] != 1 ? \
1161 COLOR_SUB1_2 (p, *(s + gfx->Delta)) : \
1162 COLOR_SUB (p, gfx->FixedColour)) \
1165 RENDER_TILE_LARGE (gfx->ScreenColors [pixel], LARGE_SUB_PIXEL1_2)
1168 void DrawHiResTile16 (uint32 Tile, uint32 Offset, uint32 StartLine,
1169 uint32 LineCount, struct SGFX * gfx)
1174 RENDER_TILEHI(WRITE_4PIXELSHI16, WRITE_4PIXELSHI16_FLIPPED, 4)
1177 void DrawHiResClippedTile16 (uint32 Tile, uint32 Offset,
1178 uint32 StartPixel, uint32 Width,
1179 uint32 StartLine, uint32 LineCount, struct SGFX * gfx)
1185 RENDER_CLIPPED_TILEHI(WRITE_4PIXELSHI16, WRITE_4PIXELSHI16_FLIPPED, 4)