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

📄 a6dll.pas

📁 3D GameStudio 的Delphi开发包
💻 PAS
字号:
//////////////////////////////////////////////////////////////////////
// Acknex engine DLL/EXE header for C++
// (c) Conitec / jcl 2004
//////////////////////////////////////////////////////////////////////
//
// Delphi Conversion for creating an A6_5x Engine plugin dll done by
// Michal Messerschmidt aka LazyDog of Lazy Dog Software
// (www.LazyDogSoftware.com)
//
// SDK Version 6.50.6
//
// tested on Delphi 5,6,7,2005 & 2006
//////////////////////////////////////////////////////////////////////

Unit A6DLL;

Interface

{$DEFINE USEWINDOWSUNIT}

{$IFDEF USEWINDOWSUNIT}
Uses Windows;
{$ENDIF}

Type Var_  = Type LongInt;      // use of the 2nd "Type" makes code completion show Var_ instead of LongInt
     PVar_ = ^Var_;             // also compiler catches any attempt to assign to a Var_ without using _VAR helper function

     {$IFNDEF USEWINDOWSUNIT}
     PPoint = ^TPoint;
     TPoint = record
       x: Longint;
       y: Longint;
     end;

     PRect = ^TRect;
     TRect = record
       case Integer of
        0: (Left, Top, Right, Bottom: Integer);
        1: (TopLeft, BottomRight: TPoint);
     end;
     
     DWORD = Longword;

     {$IFDEF VER130} //Delphi 5
     PByte = ^Byte;
     PSingle = ^Single;
     PLongint = ^Longint;
     {$ENDIF}
     {$ENDIF}

{$I 'ATypes.pas'}               // engine structs and flags

//////////////////////////////////////////////////////////////////////
Type

// define a struct with pointers to all exported engine variables
PEngine_Vars = ^TEngine_Vars;
TEngine_Vars = Packed Record
                 {$I 'avars.pas'}
               end;

var ev : PEngine_Vars; 

{$I 'afuncsDLL.pas'}	// include a list of engine functions


//helper functions to move variables to/from c-script & engine
//names kept the same as the A5 sdk
function Int2Fix(i : LongInt) : Var_;  // int -> var
function Fix2Int(x : Var_)  : LongInt; // var -> int
function Float2Fix(f : Double) : Var_; // double -> var
function Fix2Float(x : Var_) : Double; // var -> float

//helper functions to move variables to/from c-script & engine
//these are identical to the above but use the same names as the A6 sdk
function _VAR(i : LongInt) : Var_; overload; // int -> var
function _VAR(f : double) : Var_; overload;  // double -> var, overloaded
function _INT(x : Var_) : LongInt;           // var -> int
function _FLOAT(x : Var_) : Double;          // var -> float
function _CHR(s : PString) : PChar; 	     // STRING* -> char*

// Reading and writing to engine variables requires you to use the correct data type
//
//
// to set an engine variable
//
// ev.max_loops^ := _VAR(100);  or  ev.max_loops^ := Int2Fix(100);
// ev.fps_max^   := _VAR(60);   or  ev.fps_max^   := Int2Fix(60);
//
// read an int from an engine variable
//
// I := _INT(ev.max_loops^);    or   I := Fix2Int(ev.max_loops^);
// I := _INT(ev.fps_max^);      or   I := fix2Int(ev.fps_max^);
//
// read a float from an engine variable
//
// f := _FLOAT(Entity.pan);     or   f := Fix2Float(Entity.pan);

IMPLEMENTATION

function Int2Fix(i : LongInt) : Var_;  // int -> var
begin
  Result := i shl 10;
end;

function Fix2Int(x : Var_) : LongInt;  // var -> long
begin
  Result := x shr 10;
end;

function Float2Fix(f : Double) : Var_; // double -> var
begin
  Result := trunc(f * (1 shl 10));
end;

function Fix2Float(x : Var_) : Double; // var -> float

var d : Double;
begin
  d := x;
  Result := d / (1 shl 10);
end;

function _VAR(i : LongInt) : Var_;     // int -> var
begin
  Result := i shl 10;
end;

function _VAR(f : double) : Var_;      // double -> var, overloaded
begin
  Result := trunc(f * (1 shl 10));
end;

function _INT(x : Var_) : LongInt;     // var -> int
begin
  Result := x shr 10;
end;

function _FLOAT(x : Var_) : Double;    // var -> float

var d : Double;
begin
  d := x;
  Result := d / (1 shl 10);
end;

function _CHR(s : PString) : PChar;      // STRING* -> char*
begin
  Result := s.char;
end;

end.

⌨️ 快捷键说明

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