⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 draw.inc

📁 著名的游戏开发库Allegro4.2.0 for DELPHI
💻 INC
📖 第 1 页 / 共 2 页
字号:
begin
  assert(bmp <> nil);
  assert(sprite <> nil);
  assert(bmp^.vtable^.color_depth = sprite^.vtable^.color_depth);

  bmp^.vtable^.draw_sprite_h_flip(bmp, sprite, x, y);
end;

procedure draw_sprite_vh_flip(bmp, sprite: P_BITMAP; x, y: sint32);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);
  assert(bmp^.vtable^.color_depth = sprite^.vtable^.color_depth);

  bmp^.vtable^.draw_sprite_vh_flip(bmp, sprite, x, y);
end;

procedure draw_trans_sprite(bmp, sprite: P_BITMAP; x, y: sint32);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);

  if (sprite^.vtable^.color_depth = 32) then
  begin
    assert(@bmp^.vtable^.draw_trans_rgba_sprite <> nil);
    bmp^.vtable^.draw_trans_rgba_sprite(bmp, sprite, x, y);
  end else
  begin
    assert((bmp^.vtable^.color_depth = sprite^.vtable^.color_depth) or
             ((bmp^.vtable^.color_depth = 32) and
              (sprite^.vtable^.color_depth = 8)));
    bmp^.vtable^.draw_trans_sprite(bmp, sprite, x, y);
  end;
end;

procedure draw_lit_sprite(bmp, sprite: P_BITMAP; x, y, color: sint32);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);
  assert(bmp^.vtable^.color_depth = sprite^.vtable^.color_depth);

  bmp^.vtable^.draw_lit_sprite(bmp, sprite, x, y, color);
end;

procedure draw_gouraud_sprite(bmp, sprite: P_BITMAP; x, y, c1, c2, c3, c4: sint32);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);
  assert(bmp^.vtable^.color_depth = sprite^.vtable^.color_depth);

  bmp^.vtable^.draw_gouraud_sprite(bmp, sprite, x, y, c1, c2, c3, c4);
end;

procedure draw_character_ex(bmp, sprite: P_BITMAP; x, y, color, bg: sint32);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);
  assert(sprite^.vtable^.color_depth = 8);

  bmp^.vtable^.draw_character(bmp, sprite, x, y, color, bg);
end;

procedure rotate_sprite(bmp, sprite: P_BITMAP; x, y: sint32; angle: fixed);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);

  bmp^.vtable^.pivot_scaled_sprite_flip(bmp, sprite, (x shl 16) + (sprite^.w * $10000) div 2,
			     			      (y shl 16) + (sprite^.h * $10000) div 2,
			     			      sprite^.w shl 15, sprite^.h shl 15,
			     			      angle, $10000, 0);
end;

procedure rotate_sprite_v_flip(bmp, sprite: P_BITMAP; x, y: sint32; angle: fixed);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);

  bmp^.vtable^.pivot_scaled_sprite_flip(bmp, sprite, (x shl 16) + (sprite^.w * $10000) div 2,
			     			      (y shl 16) + (sprite^.h * $10000) div 2,
			     			      sprite^.w shl 15, sprite^.h shl 15,
			     			      angle, $10000, 1);
end;

procedure rotate_scaled_sprite(bmp, sprite: P_BITMAP; x, y: sint32; angle, scale: fixed);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);
  assert(bmp^.vtable^.color_depth = sprite^.vtable^.color_depth);

  bmp^.vtable^.pivot_scaled_sprite_flip(bmp, sprite, (x shl 16) + (sprite^.w * scale) div 2,
			     			      (y shl 16) + (sprite^.h * scale) div 2,
			     			      sprite^.w shl 15, sprite^.h shl 15,
			     			      angle, scale, 0);
end;

procedure rotate_scaled_sprite_v_flip(bmp, sprite: P_BITMAP; x, y: sint32; angle, scale: fixed);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);

  bmp^.vtable^.pivot_scaled_sprite_flip(bmp, sprite, (x shl 16) + (sprite^.w * scale) div 2,
			     			      (y shl 16) + (sprite^.h * scale) div 2,
			     			      sprite^.w shl 15, sprite^.h shl 15,
			     			      angle, scale, 1);
end;

procedure pivot_sprite(bmp, sprite: P_BITMAP; x, y, cx, cy: sint32; angle: fixed);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);

  bmp^.vtable^.pivot_scaled_sprite_flip(bmp, sprite, x shl 16, y shl 16, cx shl 16, cy shl 16, angle, $10000, 0);
end;

procedure pivot_sprite_v_flip(bmp, sprite: P_BITMAP; x, y, cx, cy: sint32; angle: fixed);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);

  bmp^.vtable^.pivot_scaled_sprite_flip(bmp, sprite, x shl 16, y shl 16, cx shl 16, cy shl 16, angle, $10000, 1);
end;

procedure pivot_scaled_sprite(bmp, sprite: P_BITMAP; x, y, cx, cy: sint32; angle, scale: fixed);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);

  bmp^.vtable^.pivot_scaled_sprite_flip(bmp, sprite, x shl 16, y shl 16, cx shl 16, cy shl 16, angle, scale, 0);
end;


procedure pivot_scaled_sprite_v_flip(bmp, sprite: P_BITMAP; x, y, cx, cy: sint32; angle, scale: fixed);
begin
  assert(bmp <> nil);
  assert(sprite <> nil);

  bmp^.vtable^.pivot_scaled_sprite_flip(bmp, sprite, x shl 16, y shl 16, cx shl 16, cy shl 16, angle, scale, 1);
end;

procedure _putpixel(bmp: P_BITMAP; x, y, color: sint32); assembler;
{
  eax = bmp ecx = y edx = x
}
asm
  push  ebx
  mov   bl,byte ptr [color]
  mov   eax,[bmp + y * 4 + BITMAP.line]
  mov   [eax + x],bl
  pop   ebx
end;

function _getpixel(bmp: P_BITMAP; x, y: sint32): sint32; assembler;
asm
  mov   eax,[bmp + y * 4 + BITMAP.line]
  movzx eax,byte ptr [eax + x]
end;

procedure _putpixel15(bmp: P_BITMAP; x, y, color: sint32); assembler;
asm
  push  ebx
  mov   bx,word ptr [color]
  mov   eax,[bmp + y * 4 + BITMAP.line]
  mov   [eax + x * 2],bx
  pop   ebx
end;

function _getpixel15(bmp: P_BITMAP; x, y: sint32): sint32; assembler;
asm
  mov   eax,[bmp + y * 4 + BITMAP.line]
  mov   eax,[eax + x * 2]
  and   eax,$7FFF
end;

procedure _putpixel16(bmp: P_BITMAP; x, y, color: sint32); assembler;
asm
  push  ebx
  mov   bx,word ptr [color]
  mov   eax,[bmp + y * 4 + BITMAP.line]
  mov   [eax + x * 2],bx
  pop   ebx
end;

function _getpixel16(bmp: P_BITMAP; x, y: sint32): sint32; assembler;
asm
  mov   eax,[bmp + y * 4 + BITMAP.line]
  mov   eax,[eax + x * 2]
  and   eax,$FFFF
end;

procedure _putpixel24(bmp: P_BITMAP; x, y, color: sint32); assembler;
asm
  push  ebx
  mov   ebx,edx
  add   edx,ebx
  add   edx,ebx

  mov   ebx,[color]
  mov   eax,[bmp + y * 4 + BITMAP.line]
  mov   [eax + x],bx
  shr   ebx,16
  mov   [eax + x + 2],bl
  pop   ebx
end;

function _getpixel24(bmp: P_BITMAP; x, y: sint32): sint32; assembler;
asm
  push  ebx
  mov   ebx,edx
  add   edx,ebx
  add   edx,ebx

  mov   eax,[bmp + y * 4 + BITMAP.line]
  mov   eax,[eax + x]
  and   eax,$FFFFFFFF
  pop   ebx
end;

procedure _putpixel32(bmp: P_BITMAP; x, y, color: sint32); assembler;
asm
  push  ebx
  mov   ebx,[color]
  mov   eax,[bmp + y * 4 + BITMAP.line]
  mov   [eax + x * 4],ebx
  pop   ebx
end;

function _getpixel32(bmp: P_BITMAP; x, y: sint32): sint32; assembler;
asm
  mov   eax,[bmp + y * 4 + BITMAP.line]
  mov   eax,[eax + x * 4]
end;
{$ENDIF ALLEGRO_IMPLEMENTATION}
{$IFDEF ALLEGRO_LOADVARIABLE}
{$ENDIF ALLEGRO_LOADVARIABLE}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -