////////////////////////////////////////////////////////////////////// // // // gfxDraw1D256Sprite.pas: Render metacode for 256 color sprites // // with 1D mapping // // // // The contents of this file are subject to the Bottled Light // // Public License Version 1.0 (the "License"); you may not use this // // file except in compliance with the License. You may obtain a // // copy of the License at http://www.bottledlight.com/BLPL/ // // // // Software distributed under the License is distributed on an // // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or // // implied. See the License for the specific language governing // // rights and limitations under the License. // // // // The Original Code is the Mappy VM Core, released April 1st, 2003 // // The Initial Developer of the Original Code is Bottled Light, // // Inc. Portions created by Bottled Light, Inc. are Copyright // // (C) 2001 - 2003 Bottled Light, Inc. All Rights Reserved. // // // // Author(s): // // Michael Noland (joat), michael@bottledlight.com // // // // Changelog: // // 1.0: First public release (April 1st, 2003) // // // ////////////////////////////////////////////////////////////////////// // Draw a 256 color sprite using 1D mapping var hsize, vsize: byte; pix: uint16; sx, sy: integer; x, x0, base: integer; {$INCLUDE gfxDrawPixelInc.pas} hsize := entry^.width; vsize := entry^.height; sx := entry^.x; sy := entry^.y; // Calculate the sprite image base if entry^.b and SPRITE_B_FLIP_Y <> 0 then y := vsize-y-1; base := (entry^.c and $3FF) shl 5; base := base + (y shl 3) and 63 + (y shr 3) * hsize * 8; base := base + $10000; // Do some clipping if sx < 0 then x0 := -sx else x0 := 0; if sx+entry^.run > 240 then Exit; ids := @(Puint8Array(ids)^[sx+x0]); wins := @(Puint8Array(wins)^[sx+x0]); line := @(Puint16Array(line)^[sx+x0]); // Draw a sprite if entry^.b and SPRITE_B_FLIP_X <> 0 then begin for x := x0 to entry^.run-1 do begin pix := VRAM[base + 7-x and 7 + ((hsize-x-1) shr 3) shl 6]; if (pix <> 0) {$IFNDEF OBJWIN}and (wins^ and mask <> 0){$ENDIF} or ((pix = 0) and (not latchXparent) and (mclock > 0)) then begin pix := Puint16(@(palette[pix shl 1 + 512]))^; {$INCLUDE gfxDrawPixel.pas} end; end else begin for x := x0 to entry^.run-1 do begin pix := VRAM[base + x and 7 + (x shr 3) shl 6]; if (pix <> 0) {$IFNDEF OBJWIN}and (wins^ and mask <> 0){$ENDIF} or ((pix = 0) and (not latchXparent) and (mclock > 0)) then begin pix := Puint16(@(palette[pix shl 1 + 512]))^; {$INCLUDE gfxDrawPixel.pas} end; end; end;