📄 tile.cpp
字号:
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)}#ifdef USE_GLIDE#if 0void DrawTile3dfx (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount){ TILE_PREAMBLE float x = Offset % GFX.Pitch; float y = Offset / GFX.Pitch; Glide.sq [0].x = Glide.x_offset + x * Glide.x_scale; Glide.sq [0].y = Glide.y_offset + y * Glide.y_scale; Glide.sq [1].x = Glide.x_offset + (x + 8.0) * Glide.x_scale; Glide.sq [1].y = Glide.y_offset + y * Glide.y_scale; Glide.sq [2].x = Glide.x_offset + (x + 8.0) * Glide.x_scale; Glide.sq [2].y = Glide.y_offset + (y + LineCount) * Glide.y_scale; Glide.sq [3].x = Glide.x_offset + x * Glide.x_scale; Glide.sq [3].y = Glide.y_offset + (y + LineCount) * Glide.y_scale; if (!(Tile & (V_FLIP | H_FLIP))) { // Normal Glide.sq [0].tmuvtx [0].sow = 0.0; Glide.sq [0].tmuvtx [0].tow = StartLine; Glide.sq [1].tmuvtx [0].sow = 8.0; Glide.sq [1].tmuvtx [0].tow = StartLine; Glide.sq [2].tmuvtx [0].sow = 8.0; Glide.sq [2].tmuvtx [0].tow = StartLine + LineCount; Glide.sq [3].tmuvtx [0].sow = 0.0; Glide.sq [3].tmuvtx [0].tow = StartLine + LineCount; } else if (!(Tile & V_FLIP)) { // Flipped Glide.sq [0].tmuvtx [0].sow = 8.0; Glide.sq [0].tmuvtx [0].tow = StartLine; Glide.sq [1].tmuvtx [0].sow = 0.0; Glide.sq [1].tmuvtx [0].tow = StartLine; Glide.sq [2].tmuvtx [0].sow = 0.0; Glide.sq [2].tmuvtx [0].tow = StartLine + LineCount; Glide.sq [3].tmuvtx [0].sow = 8.0; Glide.sq [3].tmuvtx [0].tow = StartLine + LineCount; } else if (Tile & H_FLIP) { // Horizontal and vertical flip Glide.sq [0].tmuvtx [0].sow = 8.0; Glide.sq [0].tmuvtx [0].tow = StartLine + LineCount; Glide.sq [1].tmuvtx [0].sow = 0.0; Glide.sq [1].tmuvtx [0].tow = StartLine + LineCount; Glide.sq [2].tmuvtx [0].sow = 0.0; Glide.sq [2].tmuvtx [0].tow = StartLine; Glide.sq [3].tmuvtx [0].sow = 8.0; Glide.sq [3].tmuvtx [0].tow = StartLine; } else { // Vertical flip only Glide.sq [0].tmuvtx [0].sow = 0.0; Glide.sq [0].tmuvtx [0].tow = StartLine + LineCount; Glide.sq [1].tmuvtx [0].sow = 8.0; Glide.sq [1].tmuvtx [0].tow = StartLine + LineCount; Glide.sq [2].tmuvtx [0].sow = 8.0; Glide.sq [2].tmuvtx [0].tow = StartLine; Glide.sq [3].tmuvtx [0].sow = 0.0; Glide.sq [3].tmuvtx [0].tow = StartLine; } grTexDownloadMipMapLevel (GR_TMU0, Glide.texture_mem_start, GR_LOD_8, GR_LOD_8, GR_ASPECT_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH, (void *) pCache); grTexSource (GR_TMU0, Glide.texture_mem_start, GR_MIPMAPLEVELMASK_BOTH, &Glide.texture); grDrawTriangle (&Glide.sq [0], &Glide.sq [3], &Glide.sq [2]); grDrawTriangle (&Glide.sq [0], &Glide.sq [1], &Glide.sq [2]);}void DrawClippedTile3dfx (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)}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -