From feb7ddabab930359c045128134d942894ff5f4f8 Mon Sep 17 00:00:00 2001 From: aliaspider Date: Fri, 13 Nov 2015 01:10:59 +0100 Subject: build bix for non ARM platforms. (still not functional) --- src/apu.h | 5 +- src/asmmemfuncs.h | 8 +- src/cpuexec.c | 10 +- src/cpuexec.h | 20 +- src/snes9x.h | 3 +- src/tile_c.c | 1127 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/tile_c.cpp | 1127 ----------------------------------------------------- 7 files changed, 1162 insertions(+), 1138 deletions(-) create mode 100644 src/tile_c.c delete mode 100644 src/tile_c.cpp (limited to 'src') diff --git a/src/apu.h b/src/apu.h index 2beef0d..ccf68dc 100644 --- a/src/apu.h +++ b/src/apu.h @@ -107,8 +107,9 @@ STATIC inline void S9xAPUUnpackStatus() { IAPU._Zero = ((IAPU.P & Zero) == 0) | (IAPU.P & Negative); - +#ifdef ASMCPU if (!Settings.asmspc700) +#endif { IAPU._Carry = (IAPU.P & Carry); IAPU._Overflow = (IAPU.P & Overflow); @@ -117,6 +118,7 @@ STATIC inline void S9xAPUUnpackStatus() STATIC inline void S9xAPUPackStatus() { +#ifdef ASMCPU if (Settings.asmspc700) { IAPU.P &= ~(Zero | Negative); @@ -125,6 +127,7 @@ STATIC inline void S9xAPUPackStatus() } else +#endif { IAPU.P &= ~(Zero | Negative | Carry | Overflow); if (IAPU._Carry) IAPU.P |= Carry; diff --git a/src/asmmemfuncs.h b/src/asmmemfuncs.h index 6380ad0..538ce76 100644 --- a/src/asmmemfuncs.h +++ b/src/asmmemfuncs.h @@ -204,10 +204,10 @@ ); _dst; \ }) #else -#define memset32(_dst, _c, _count) memset(_dst, _c, _count) -#define memset16(_dst, _c, _count) memset(_dst, _c, _count) -#define memcpy32(_dst, _src, _count) memcpy(_dst, _src, _count) -#define memcpy16(_dst, _src, _count) memcpy(_dst, _src, _count) +#define memset32(_dst, _c, _count) memset(_dst, _c, (_count)<<2) +#define memset16(_dst, _c, _count) memset(_dst, _c, (_count)<<1) +#define memcpy32(_dst, _src, _count) memcpy(_dst, _src, (_count)<<2) +#define memcpy16(_dst, _src, _count) memcpy(_dst, _src, (_count)<<1) #endif #endif diff --git a/src/cpuexec.c b/src/cpuexec.c index 9306390..faed0fa 100644 --- a/src/cpuexec.c +++ b/src/cpuexec.c @@ -332,7 +332,8 @@ S9xMainLoop(void) if (Settings.APUEnabled == 1) { #ifdef USE_SA1 - if (Settings.SA1) S9xMainLoop_SA1_APU(); + if (Settings.SA1) + S9xMainLoop_SA1_APU(); else #endif S9xMainLoop_NoSA1_APU(); @@ -340,10 +341,11 @@ S9xMainLoop(void) else { #ifdef USE_SA1 - if (Settings.SA1) S9xMainLoop_SA1_NoAPU(); - else S9xMainLoop_NoSA1_NoAPU(); + if (Settings.SA1) + S9xMainLoop_SA1_NoAPU(); + else #endif - + S9xMainLoop_NoSA1_NoAPU(); } #else if (Settings.asmspc700) asmMainLoop_spcAsm(&CPU); diff --git a/src/cpuexec.h b/src/cpuexec.h index 9ccfa71..40ea4d6 100644 --- a/src/cpuexec.h +++ b/src/cpuexec.h @@ -190,7 +190,7 @@ extern "C" { void asm_APU_EXECUTE(int Mode); void asm_APU_EXECUTE2(void); }*/ - +#ifdef ASMCPU #define asm_APU_EXECUTE(MODE)\ {\ if (CPU.APU_APUExecuting == MODE) {\ @@ -231,6 +231,24 @@ void asm_APU_EXECUTE2(void); }\ }\ } +#else + +#define asm_APU_EXECUTE(MODE)\ + do { if (CPU.APU_APUExecuting == MODE) \ + while (CPU.APU_Cycles <= CPU.Cycles)\ + {\ + CPU.APU_Cycles += S9xAPUCycles [*IAPU.PC];\ + (*S9xApuOpcodes[*IAPU.PC]) ();\ + }}while(0) +#define asm_APU_EXECUTE2() \ + if (CPU.APU_APUExecuting == 1) do\ + {\ + CPU.APU_Cycles += S9xAPUCycles [*IAPU.PC];\ + (*S9xApuOpcodes[*IAPU.PC]) ();\ + } while (CPU.APU_Cycles < CPU.NextEvent) + +#endif + #endif diff --git a/src/snes9x.h b/src/snes9x.h index e3f8f1d..e72b758 100644 --- a/src/snes9x.h +++ b/src/snes9x.h @@ -395,8 +395,9 @@ typedef struct bool8 DaffyDuck; uint8 APURAMInitialValue; bool8 SDD1Pack; - +#ifdef ASMCPU bool8 asmspc700; +#endif bool8 SpeedHacks; #ifdef __WIN32__ int SoundDriver; diff --git a/src/tile_c.c b/src/tile_c.c new file mode 100644 index 0000000..9bdc05f --- /dev/null +++ b/src/tile_c.c @@ -0,0 +1,1127 @@ +/* + * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. + * + * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and + * Jerremy Koot (jkoot@snes9x.com) + * + * Super FX C emulator code + * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and + * Gary Henderson. + * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_. + * + * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson. + * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_. + * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com). + * + * DOS port code contains the works of other authors. See headers in + * individual files. + * + * Snes9x homepage: http://www.snes9x.com + * + * Permission to use, copy, modify and distribute Snes9x in both binary and + * source form, for non-commercial purposes, is hereby granted without fee, + * providing that this license information and copyright notice appear with + * all copies and any derived work. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event shall the authors be held liable for any damages + * arising from the use of this software. + * + * Snes9x is freeware for PERSONAL USE only. Commercial users should + * seek permission of the copyright holders first. Commercial use includes + * charging money for Snes9x or software derived from Snes9x. + * + * The copyright holders request that bug fixes and improvements to the code + * should be forwarded to them so everyone can benefit from the modifications + * in future versions. + * + * Super NES and Super Nintendo Entertainment System are trademarks of + * Nintendo Co., Limited and its subsidiary companies. + */ +#include "snes9x.h" + +#include "memmap.h" +#include "ppu.h" +#include "display.h" +#include "gfx.h" +#include "tile.h" + + +extern uint32 HeadMask [4]; +extern uint32 TailMask [5]; + +uint8 ConvertTile (uint8 *pCache, uint32 TileAddr) +{ + register uint8 *tp = &Memory.VRAM[TileAddr]; + uint32 *p = (uint32 *) pCache; + uint32 non_zero = 0; + uint8 line; + + switch (BG.BitShift) + { + case 8: + for (line = 8; line != 0; line--, tp += 2) + { + uint32 p1 = 0; + uint32 p2 = 0; + register uint8 pix; + + if ((pix = *(tp + 0))) + { + p1 |= odd_high[0][pix >> 4]; + p2 |= odd_low[0][pix & 0xf]; + } + if ((pix = *(tp + 1))) + { + p1 |= even_high[0][pix >> 4]; + p2 |= even_low[0][pix & 0xf]; + } + if ((pix = *(tp + 16))) + { + p1 |= odd_high[1][pix >> 4]; + p2 |= odd_low[1][pix & 0xf]; + } + if ((pix = *(tp + 17))) + { + p1 |= even_high[1][pix >> 4]; + p2 |= even_low[1][pix & 0xf]; + } + if ((pix = *(tp + 32))) + { + p1 |= odd_high[2][pix >> 4]; + p2 |= odd_low[2][pix & 0xf]; + } + if ((pix = *(tp + 33))) + { + p1 |= even_high[2][pix >> 4]; + p2 |= even_low[2][pix & 0xf]; + } + if ((pix = *(tp + 48))) + { + p1 |= odd_high[3][pix >> 4]; + p2 |= odd_low[3][pix & 0xf]; + } + if ((pix = *(tp + 49))) + { + p1 |= even_high[3][pix >> 4]; + p2 |= even_low[3][pix & 0xf]; + } + *p++ = p1; + *p++ = p2; + non_zero |= p1 | p2; + } + break; + + case 4: + for (line = 8; line != 0; line--, tp += 2) + { + uint32 p1 = 0; + uint32 p2 = 0; + register uint8 pix; + if ((pix = *(tp + 0))) + { + p1 |= odd_high[0][pix >> 4]; + p2 |= odd_low[0][pix & 0xf]; + } + if ((pix = *(tp + 1))) + { + p1 |= even_high[0][pix >> 4]; + p2 |= even_low[0][pix & 0xf]; + } + if ((pix = *(tp + 16))) + { + p1 |= odd_high[1][pix >> 4]; + p2 |= odd_low[1][pix & 0xf]; + } + if ((pix = *(tp + 17))) + { + p1 |= even_high[1][pix >> 4]; + p2 |= even_low[1][pix & 0xf]; + } + *p++ = p1; + *p++ = p2; + non_zero |= p1 | p2; + } + break; + + case 2: + for (line = 8; line != 0; line--, tp += 2) + { + uint32 p1 = 0; + uint32 p2 = 0; + register uint8 pix; + if ((pix = *(tp + 0))) + { + p1 |= odd_high[0][pix >> 4]; + p2 |= odd_low[0][pix & 0xf]; + } + if ((pix = *(tp + 1))) + { + p1 |= even_high[0][pix >> 4]; + p2 |= even_low[0][pix & 0xf]; + } + *p++ = p1; + *p++ = p2; + non_zero |= p1 | p2; + } + break; + } + return (non_zero ? TRUE : BLANK_TILE); +} + +inline void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) +{ + uint8 Pixel; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ + { \ + Screen [N] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +inline void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels) +{ + uint8 Pixel; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + { \ + Screen [N] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +inline void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels) +{ + uint8 Pixel; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [0] && (Pixel = Pixels[N])) \ + { \ + Screen [N * 2] = Screen [N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +inline void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) +{ + uint8 Pixel; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ + { \ + Screen [N * 2] = Screen [N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +inline void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels) +{ + uint8 Pixel; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ + { \ + Screen [N * 2] = Screen [N * 2 + 1] = Screen [GFX.RealPitch + N * 2] = \ + Screen [GFX.RealPitch + N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = Depth [GFX.RealPitch + N * 2] = \ + Depth [GFX.RealPitch + N * 2 + 1] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +inline void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) +{ + uint8 Pixel; + uint8 *Screen = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ + { \ + Screen [N * 2] = Screen [N * 2 + 1] = Screen [GFX.RealPitch + N * 2] = \ + Screen [GFX.RealPitch + N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = Depth [GFX.RealPitch + N * 2] = \ + Depth [GFX.RealPitch + N * 2 + 1] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +void DrawTile (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) +} + +void DrawClippedTile (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) +} + +void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8) +} + +void DrawClippedTilex2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8) +} + +void DrawTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8) +} + +void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8) +} + +void DrawLargePixel (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + + register uint8 *sp = GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + uint8 pixel; +#define PLOT_PIXEL(screen, pixel) (pixel) + + RENDER_TILE_LARGE (((uint8) GFX.ScreenColors [pixel]), PLOT_PIXEL) +} + +inline void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ + { \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +inline void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + { \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +inline void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ + { \ + Screen [N * 2] = Screen [N * 2 + 1] = GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +inline void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ + { \ + Screen [N * 2] = Screen [N * 2 + 1] = GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +inline void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ + { \ + Screen [N * 2] = Screen [N * 2 + 1] = Screen [(GFX.RealPitch >> 1) + N * 2] = \ + Screen [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = Depth [(GFX.RealPitch >> 1) + N * 2] = \ + Depth [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +inline void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ + { \ + Screen [N * 2] = Screen [N * 2 + 1] = Screen [(GFX.RealPitch >> 1) + N * 2] = \ + Screen [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.ScreenColors [Pixel]; \ + Depth [N * 2] = Depth [N * 2 + 1] = Depth [(GFX.RealPitch >> 1) + N * 2] = \ + Depth [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) +#undef FN +} + +void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4) +} + +void DrawClippedTile16 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4) +} + +void DrawTile16x2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8) +} + +void DrawClippedTile16x2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8) +} + +void DrawTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8) +} + +void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8) +} + +void DrawLargePixel16 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.DB + Offset; + uint16 pixel; + + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], PLOT_PIXEL) +} + +inline void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ + { \ + if (SubDepth [N]) \ + { \ + if (SubDepth [N] != 1) \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ + else \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ + } \ + else \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +inline void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + { \ + if (SubDepth [N]) \ + { \ + if (SubDepth [N] != 1) \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ + else \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ + } \ + else \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +inline void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ + { \ + if (SubDepth [N]) \ + { \ + if (SubDepth [N] != 1) \ + Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N])); \ + else \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ + } \ + else \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +inline void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + { \ + if (SubDepth [N]) \ + { \ + if (SubDepth [N] != 1) \ + Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N])); \ + else \ + Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ + } \ + else \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +inline void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ + { \ + if (SubDepth [N]) \ + { \ + if (SubDepth [N] != 1) \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ + else \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ + } \ + else \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +inline void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + { \ + if (SubDepth [N]) \ + { \ + if (SubDepth [N] != 1) \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ + else \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ + } \ + else \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +inline void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ + { \ + if (SubDepth [N]) \ + { \ + if (SubDepth [N] != 1) \ + Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ + else \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ + } \ + else \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +inline void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + { \ + if (SubDepth [N]) \ + { \ + if (SubDepth [N] != 1) \ + Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ + Screen [GFX.Delta + N]); \ + else \ + Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ + } \ + else \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + + +void DrawTile16Add (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16_ADD, WRITE_4PIXELS16_FLIPPED_ADD, 4) +} + +void DrawClippedTile16Add (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADD, WRITE_4PIXELS16_FLIPPED_ADD, 4) +} + +void DrawTile16Add1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16_ADD1_2, WRITE_4PIXELS16_FLIPPED_ADD1_2, 4) +} + +void DrawClippedTile16Add1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADD1_2, WRITE_4PIXELS16_FLIPPED_ADD1_2, 4) +} + +void DrawTile16Sub (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16_SUB, WRITE_4PIXELS16_FLIPPED_SUB, 4) +} + +void DrawClippedTile16Sub (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB, WRITE_4PIXELS16_FLIPPED_SUB, 4) +} + +void DrawTile16Sub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4) +} + +void DrawClippedTile16Sub1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4) +} + +inline void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ + { \ + if (SubDepth [N] == 1) \ + Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ + GFX.FixedColour)); \ + else \ + Screen [N] = GFX.ScreenColors [Pixel];\ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +inline void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + { \ + if (SubDepth [N] == 1) \ + Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ + GFX.FixedColour)); \ + else \ + Screen [N] = GFX.ScreenColors [Pixel];\ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +inline void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ + { \ + if (SubDepth [N] == 1) \ + Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ + else \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +inline void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) +{ + uint32 Pixel; + uint16 *Screen = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint8 *SubDepth = GFX.SubZBuffer + Offset; + +#define FN(N) \ + if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ + { \ + if (SubDepth [N] == 1) \ + Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ + GFX.FixedColour); \ + else \ + Screen [N] = GFX.ScreenColors [Pixel]; \ + Depth [N] = GFX.Z2; \ + } + + FN(0) + FN(1) + FN(2) + FN(3) + +#undef FN +} + +void DrawTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16_ADDF1_2, WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4) +} + +void DrawClippedTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADDF1_2, + WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4) +} + +void DrawTile16FixedSub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, + uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + RENDER_TILE(WRITE_4PIXELS16_SUBF1_2, WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4) +} + +void DrawClippedTile16FixedSub1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Width, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + register uint8 *bp; + + TILE_CLIP_PREAMBLE + RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUBF1_2, + WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4) +} + +void DrawLargePixel16Add (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint16 pixel; + +#define LARGE_ADD_PIXEL(s, p) \ +(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_ADD (p, *(s + GFX.Delta)) : \ + COLOR_ADD (p, GFX.FixedColour)) \ + : p) + + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_ADD_PIXEL) +} + +void DrawLargePixel16Add1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint16 pixel; + +#define LARGE_ADD_PIXEL1_2(s, p) \ +((uint16) (Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_ADD1_2 (p, *(s + GFX.Delta)) : \ + COLOR_ADD (p, GFX.FixedColour)) \ + : p)) + + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_ADD_PIXEL1_2) +} + +void DrawLargePixel16Sub (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint16 pixel; + +#define LARGE_SUB_PIXEL(s, p) \ +(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_SUB (p, *(s + GFX.Delta)) : \ + COLOR_SUB (p, GFX.FixedColour)) \ + : p) + + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_SUB_PIXEL) +} + +void DrawLargePixel16Sub1_2 (uint32 Tile, uint32 Offset, + uint32 StartPixel, uint32 Pixels, + uint32 StartLine, uint32 LineCount) +{ + TILE_PREAMBLE + + register uint16 *sp = (uint16 *) GFX.S + Offset; + uint8 *Depth = GFX.ZBuffer + Offset; + uint16 pixel; + +#define LARGE_SUB_PIXEL1_2(s, p) \ +(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ + COLOR_SUB1_2 (p, *(s + GFX.Delta)) : \ + COLOR_SUB (p, GFX.FixedColour)) \ + : p) + + RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_SUB_PIXEL1_2) +} diff --git a/src/tile_c.cpp b/src/tile_c.cpp deleted file mode 100644 index 9bdc05f..0000000 --- a/src/tile_c.cpp +++ /dev/null @@ -1,1127 +0,0 @@ -/* - * Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - * - * (c) Copyright 1996 - 2001 Gary Henderson (gary.henderson@ntlworld.com) and - * Jerremy Koot (jkoot@snes9x.com) - * - * Super FX C emulator code - * (c) Copyright 1997 - 1999 Ivar (ivar@snes9x.com) and - * Gary Henderson. - * Super FX assembler emulator code (c) Copyright 1998 zsKnight and _Demo_. - * - * DSP1 emulator code (c) Copyright 1998 Ivar, _Demo_ and Gary Henderson. - * C4 asm and some C emulation code (c) Copyright 2000 zsKnight and _Demo_. - * C4 C code (c) Copyright 2001 Gary Henderson (gary.henderson@ntlworld.com). - * - * DOS port code contains the works of other authors. See headers in - * individual files. - * - * Snes9x homepage: http://www.snes9x.com - * - * Permission to use, copy, modify and distribute Snes9x in both binary and - * source form, for non-commercial purposes, is hereby granted without fee, - * providing that this license information and copyright notice appear with - * all copies and any derived work. - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event shall the authors be held liable for any damages - * arising from the use of this software. - * - * Snes9x is freeware for PERSONAL USE only. Commercial users should - * seek permission of the copyright holders first. Commercial use includes - * charging money for Snes9x or software derived from Snes9x. - * - * The copyright holders request that bug fixes and improvements to the code - * should be forwarded to them so everyone can benefit from the modifications - * in future versions. - * - * Super NES and Super Nintendo Entertainment System are trademarks of - * Nintendo Co., Limited and its subsidiary companies. - */ -#include "snes9x.h" - -#include "memmap.h" -#include "ppu.h" -#include "display.h" -#include "gfx.h" -#include "tile.h" - - -extern uint32 HeadMask [4]; -extern uint32 TailMask [5]; - -uint8 ConvertTile (uint8 *pCache, uint32 TileAddr) -{ - register uint8 *tp = &Memory.VRAM[TileAddr]; - uint32 *p = (uint32 *) pCache; - uint32 non_zero = 0; - uint8 line; - - switch (BG.BitShift) - { - case 8: - for (line = 8; line != 0; line--, tp += 2) - { - uint32 p1 = 0; - uint32 p2 = 0; - register uint8 pix; - - if ((pix = *(tp + 0))) - { - p1 |= odd_high[0][pix >> 4]; - p2 |= odd_low[0][pix & 0xf]; - } - if ((pix = *(tp + 1))) - { - p1 |= even_high[0][pix >> 4]; - p2 |= even_low[0][pix & 0xf]; - } - if ((pix = *(tp + 16))) - { - p1 |= odd_high[1][pix >> 4]; - p2 |= odd_low[1][pix & 0xf]; - } - if ((pix = *(tp + 17))) - { - p1 |= even_high[1][pix >> 4]; - p2 |= even_low[1][pix & 0xf]; - } - if ((pix = *(tp + 32))) - { - p1 |= odd_high[2][pix >> 4]; - p2 |= odd_low[2][pix & 0xf]; - } - if ((pix = *(tp + 33))) - { - p1 |= even_high[2][pix >> 4]; - p2 |= even_low[2][pix & 0xf]; - } - if ((pix = *(tp + 48))) - { - p1 |= odd_high[3][pix >> 4]; - p2 |= odd_low[3][pix & 0xf]; - } - if ((pix = *(tp + 49))) - { - p1 |= even_high[3][pix >> 4]; - p2 |= even_low[3][pix & 0xf]; - } - *p++ = p1; - *p++ = p2; - non_zero |= p1 | p2; - } - break; - - case 4: - for (line = 8; line != 0; line--, tp += 2) - { - uint32 p1 = 0; - uint32 p2 = 0; - register uint8 pix; - if ((pix = *(tp + 0))) - { - p1 |= odd_high[0][pix >> 4]; - p2 |= odd_low[0][pix & 0xf]; - } - if ((pix = *(tp + 1))) - { - p1 |= even_high[0][pix >> 4]; - p2 |= even_low[0][pix & 0xf]; - } - if ((pix = *(tp + 16))) - { - p1 |= odd_high[1][pix >> 4]; - p2 |= odd_low[1][pix & 0xf]; - } - if ((pix = *(tp + 17))) - { - p1 |= even_high[1][pix >> 4]; - p2 |= even_low[1][pix & 0xf]; - } - *p++ = p1; - *p++ = p2; - non_zero |= p1 | p2; - } - break; - - case 2: - for (line = 8; line != 0; line--, tp += 2) - { - uint32 p1 = 0; - uint32 p2 = 0; - register uint8 pix; - if ((pix = *(tp + 0))) - { - p1 |= odd_high[0][pix >> 4]; - p2 |= odd_low[0][pix & 0xf]; - } - if ((pix = *(tp + 1))) - { - p1 |= even_high[0][pix >> 4]; - p2 |= even_low[0][pix & 0xf]; - } - *p++ = p1; - *p++ = p2; - non_zero |= p1 | p2; - } - break; - } - return (non_zero ? TRUE : BLANK_TILE); -} - -inline void WRITE_4PIXELS (uint32 Offset, uint8 *Pixels) -{ - uint8 Pixel; - uint8 *Screen = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ - { \ - Screen [N] = (uint8) GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -inline void WRITE_4PIXELS_FLIPPED (uint32 Offset, uint8 *Pixels) -{ - uint8 Pixel; - uint8 *Screen = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ - { \ - Screen [N] = (uint8) GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -inline void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels) -{ - uint8 Pixel; - uint8 *Screen = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [0] && (Pixel = Pixels[N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -inline void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) -{ - uint8 Pixel; - uint8 *Screen = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -inline void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels) -{ - uint8 Pixel; - uint8 *Screen = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [GFX.RealPitch + N * 2] = \ - Screen [GFX.RealPitch + N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [GFX.RealPitch + N * 2] = \ - Depth [GFX.RealPitch + N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -inline void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) -{ - uint8 Pixel; - uint8 *Screen = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [GFX.RealPitch + N * 2] = \ - Screen [GFX.RealPitch + N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [GFX.RealPitch + N * 2] = \ - Depth [GFX.RealPitch + N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -void DrawTile (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) -} - -void DrawClippedTile (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) -} - -void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8) -} - -void DrawClippedTilex2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8) -} - -void DrawTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8) -} - -void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8) -} - -void DrawLargePixel (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - - register uint8 *sp = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - uint8 pixel; -#define PLOT_PIXEL(screen, pixel) (pixel) - - RENDER_TILE_LARGE (((uint8) GFX.ScreenColors [pixel]), PLOT_PIXEL) -} - -inline void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ - { \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -inline void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ - { \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -inline void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -inline void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -inline void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [(GFX.RealPitch >> 1) + N * 2] = \ - Screen [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [(GFX.RealPitch >> 1) + N * 2] = \ - Depth [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -inline void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [(GFX.RealPitch >> 1) + N * 2] = \ - Screen [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [(GFX.RealPitch >> 1) + N * 2] = \ - Depth [(GFX.RealPitch >> 1) + N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4) -} - -void DrawClippedTile16 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4) -} - -void DrawTile16x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8) -} - -void DrawClippedTile16x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8) -} - -void DrawTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8) -} - -void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8) -} - -void DrawLargePixel16 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - - register uint16 *sp = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - uint16 pixel; - - RENDER_TILE_LARGE (GFX.ScreenColors [pixel], PLOT_PIXEL) -} - -inline void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ - { \ - if (SubDepth [N]) \ - { \ - if (SubDepth [N] != 1) \ - Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ - Screen [GFX.Delta + N]); \ - else \ - Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ - GFX.FixedColour); \ - } \ - else \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -inline void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ - { \ - if (SubDepth [N]) \ - { \ - if (SubDepth [N] != 1) \ - Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ - Screen [GFX.Delta + N]); \ - else \ - Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ - GFX.FixedColour); \ - } \ - else \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -inline void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ - { \ - if (SubDepth [N]) \ - { \ - if (SubDepth [N] != 1) \ - Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ - Screen [GFX.Delta + N])); \ - else \ - Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ - GFX.FixedColour); \ - } \ - else \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -inline void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ - { \ - if (SubDepth [N]) \ - { \ - if (SubDepth [N] != 1) \ - Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ - Screen [GFX.Delta + N])); \ - else \ - Screen [N] = COLOR_ADD (GFX.ScreenColors [Pixel], \ - GFX.FixedColour); \ - } \ - else \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -inline void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ - { \ - if (SubDepth [N]) \ - { \ - if (SubDepth [N] != 1) \ - Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ - Screen [GFX.Delta + N]); \ - else \ - Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ - GFX.FixedColour); \ - } \ - else \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -inline void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ - { \ - if (SubDepth [N]) \ - { \ - if (SubDepth [N] != 1) \ - Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ - Screen [GFX.Delta + N]); \ - else \ - Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ - GFX.FixedColour); \ - } \ - else \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -inline void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ - { \ - if (SubDepth [N]) \ - { \ - if (SubDepth [N] != 1) \ - Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ - Screen [GFX.Delta + N]); \ - else \ - Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ - GFX.FixedColour); \ - } \ - else \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -inline void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ - { \ - if (SubDepth [N]) \ - { \ - if (SubDepth [N] != 1) \ - Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ - Screen [GFX.Delta + N]); \ - else \ - Screen [N] = (uint16) COLOR_SUB (GFX.ScreenColors [Pixel], \ - GFX.FixedColour); \ - } \ - else \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - - -void DrawTile16Add (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16_ADD, WRITE_4PIXELS16_FLIPPED_ADD, 4) -} - -void DrawClippedTile16Add (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADD, WRITE_4PIXELS16_FLIPPED_ADD, 4) -} - -void DrawTile16Add1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16_ADD1_2, WRITE_4PIXELS16_FLIPPED_ADD1_2, 4) -} - -void DrawClippedTile16Add1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADD1_2, WRITE_4PIXELS16_FLIPPED_ADD1_2, 4) -} - -void DrawTile16Sub (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16_SUB, WRITE_4PIXELS16_FLIPPED_SUB, 4) -} - -void DrawClippedTile16Sub (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB, WRITE_4PIXELS16_FLIPPED_SUB, 4) -} - -void DrawTile16Sub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4) -} - -void DrawClippedTile16Sub1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4) -} - -inline void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ - { \ - if (SubDepth [N] == 1) \ - Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ - GFX.FixedColour)); \ - else \ - Screen [N] = GFX.ScreenColors [Pixel];\ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -inline void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ - { \ - if (SubDepth [N] == 1) \ - Screen [N] = (uint16) (COLOR_ADD1_2 (GFX.ScreenColors [Pixel], \ - GFX.FixedColour)); \ - else \ - Screen [N] = GFX.ScreenColors [Pixel];\ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -inline void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[N])) \ - { \ - if (SubDepth [N] == 1) \ - Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ - GFX.FixedColour); \ - else \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -inline void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) -{ - uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint8 *SubDepth = GFX.SubZBuffer + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N] && (Pixel = Pixels[3 - N])) \ - { \ - if (SubDepth [N] == 1) \ - Screen [N] = (uint16) COLOR_SUB1_2 (GFX.ScreenColors [Pixel], \ - GFX.FixedColour); \ - else \ - Screen [N] = GFX.ScreenColors [Pixel]; \ - Depth [N] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) - -#undef FN -} - -void DrawTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16_ADDF1_2, WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4) -} - -void DrawClippedTile16FixedAdd1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16_ADDF1_2, - WRITE_4PIXELS16_FLIPPED_ADDF1_2, 4) -} - -void DrawTile16FixedSub1_2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16_SUBF1_2, WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4) -} - -void DrawClippedTile16FixedSub1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUBF1_2, - WRITE_4PIXELS16_FLIPPED_SUBF1_2, 4) -} - -void DrawLargePixel16Add (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - - register uint16 *sp = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint16 pixel; - -#define LARGE_ADD_PIXEL(s, p) \ -(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ - COLOR_ADD (p, *(s + GFX.Delta)) : \ - COLOR_ADD (p, GFX.FixedColour)) \ - : p) - - RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_ADD_PIXEL) -} - -void DrawLargePixel16Add1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - - register uint16 *sp = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint16 pixel; - -#define LARGE_ADD_PIXEL1_2(s, p) \ -((uint16) (Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ - COLOR_ADD1_2 (p, *(s + GFX.Delta)) : \ - COLOR_ADD (p, GFX.FixedColour)) \ - : p)) - - RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_ADD_PIXEL1_2) -} - -void DrawLargePixel16Sub (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - - register uint16 *sp = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint16 pixel; - -#define LARGE_SUB_PIXEL(s, p) \ -(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ - COLOR_SUB (p, *(s + GFX.Delta)) : \ - COLOR_SUB (p, GFX.FixedColour)) \ - : p) - - RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_SUB_PIXEL) -} - -void DrawLargePixel16Sub1_2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Pixels, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - - register uint16 *sp = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.ZBuffer + Offset; - uint16 pixel; - -#define LARGE_SUB_PIXEL1_2(s, p) \ -(Depth [z + GFX.DepthDelta] ? (Depth [z + GFX.DepthDelta] != 1 ? \ - COLOR_SUB1_2 (p, *(s + GFX.Delta)) : \ - COLOR_SUB (p, GFX.FixedColour)) \ - : p) - - RENDER_TILE_LARGE (GFX.ScreenColors [pixel], LARGE_SUB_PIXEL1_2) -} -- cgit v1.2.3