📄 gfxdraw2d16sprite.pas
字号:
//////////////////////////////////////////////////////////////////////
// //
// gfxDraw2D16Sprite.pas: Render metacode for 16 color sprites with //
// 2D 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 16 color sprite using 2D mapping
var
hsize, vsize: byte;
pix: uint16;
sx, sy: integer;
x, x0, base: integer;
pal: uint32;
{$INCLUDE gfxDrawPixelInc.pas}
// Rot/scale
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 shr 3) shl 10 + (y and 7) shl 2;
base := base + $10000;
// Do some clipping
pal := (entry^.c shr 12) shl 5 + 512;
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 the sprite
if entry^.b and SPRITE_B_FLIP_X <> 0 then begin
for x := x0 to entry^.run-1 do begin
// Read the pixel
pix := VRAM[base + (7-x and 7) shr 1 + ((hsize-8) shr 3 - x shr 3) shl 5];
if Odd(x) then pix := pix and $F else pix := pix shr 4;
// Try to draw the pixel
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 + pal]))^;
{$INCLUDE gfxDrawPixel.pas}
end;
end else
for x := x0 to entry^.run-1 do begin
// Read the pixel
pix := VRAM[base + (x and 7) shr 1 + (x shr 3) shl 5];
if Odd(x) then pix := pix shr 4 else pix := pix and $F;
// Try to draw the pixel
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 + pal]))^;
{$INCLUDE gfxDrawPixel.pas}
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -