unit IMP_AsphyreDef;
interface
uses
  Types,
  Classes,
  SysUtils,
  AsphyreDef,
  Variants,
  BASE_SYS,
  BASE_EXTERN,
  PaxScripter;
procedure RegisterIMP_AsphyreDef;
implementation
function cRGB41(r, g, b: Cardinal; a: Cardinal = 255): TColor4; 
begin
  result := AsphyreDef.cRGB4(R,G,B,A);
end;
function cRGB42(r1, g1, b1, a1, r2, g2, b2, a2: Cardinal): TColor4; 
begin
  result := AsphyreDef.cRGB4(R1,G1,B1,A1,R2,G2,B2,A2);
end;
function cColor43(Color: Cardinal): TColor4; 
begin
  result := AsphyreDef.cColor4(COLOR);
end;
function cColor44(Color1, Color2, Color3, Color4: Cardinal): TColor4; 
begin
  result := AsphyreDef.cColor4(COLOR1,COLOR2,COLOR3,COLOR4);
end;
function cGray45(Gray: Cardinal): TColor4; 
begin
  result := AsphyreDef.cGray4(GRAY);
end;
function cGray46(Gray1, Gray2, Gray3, Gray4: Cardinal): TColor4; 
begin
  result := AsphyreDef.cGray4(GRAY1,GRAY2,GRAY3,GRAY4);
end;
function cAlpha47(Alpha: Cardinal): TColor4; 
begin
  result := AsphyreDef.cAlpha4(ALPHA);
end;
function cAlpha48(Alpha1, Alpha2, Alpha3, Alpha4: Cardinal): TColor4; 
begin
  result := AsphyreDef.cAlpha4(ALPHA1,ALPHA2,ALPHA3,ALPHA4);
end;
function cColorAlpha49(Color, Alpha: Cardinal): TColor4; 
begin
  result := AsphyreDef.cColorAlpha4(COLOR,ALPHA);
end;
function cColorAlpha410(Color1, Color2, Color3, Color4, Alpha1, Alpha2, Alpha3,
 Alpha4: Cardinal): TColor4; 
begin
  result := AsphyreDef.cColorAlpha4(COLOR1,COLOR2,COLOR3,COLOR4,ALPHA1,ALPHA2,ALPHA3,ALPHA4);
end;
procedure _cGray1(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
   result.AsCardinal := AsphyreDef.cGray1(Params[0].AsCardinal);
end;
procedure _cAlpha1(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
   result.AsCardinal := AsphyreDef.cAlpha1(Params[0].AsCardinal);
end;
procedure _NextPowerOfTwo(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
   result.AsInteger := AsphyreDef.NextPowerOfTwo(Params[0].AsInteger);
end;
procedure _IsPowerOfTwo(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
   result.AsBoolean := AsphyreDef.IsPowerOfTwo(Params[0].AsInteger);
end;
procedure _CeilPowerOfTwo(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
   result.AsInteger := AsphyreDef.CeilPowerOfTwo(Params[0].AsInteger);
end;
procedure _FloorPowerOfTwo(MethodBody: TPAXMethodBody);
begin
  with MethodBody do
   result.AsInteger := AsphyreDef.FloorPowerOfTwo(Params[0].AsInteger);
end;
procedure RegisterIMP_AsphyreDef;
var H: Integer;
begin
  H := -1;//RegisterNamespace('AsphyreDef', -1);
  RegisterConstant('fsTargaCompressed', $00000001, H);
  RegisterConstant('fsTargaFlipped', $00000002, H);
  RegisterConstant('fsTargaMirrored', $00000004, H);
  RegisterConstant('fsJpegProgressive', $00000008, H);
  RegisterConstant('fsJpegGrayscale', $00000010, H);
  RegisterRTTIType(TypeInfo(TImageFormat));
  RegisterRTTIType(TypeInfo(TAsphyreQuality));
  RegisterRTTIType(TypeInfo(TAlphaLevel));
  RegisterRTTIType(TypeInfo(TColorFormat));
  RegisterRTTIType(TypeInfo(TBlendCoef));
  RegisterRTTIType(TypeInfo(TBlendOp));
  RegisterConstant('fxNone', $00000001, H);
  RegisterConstant('fxAdd', $00000104, H);
  RegisterConstant('fxBlend', $00000504, H);
  RegisterConstant('fxShadow', $00000500, H);
  RegisterConstant('fxMultiply', $00000200, H);
  RegisterConstant('fxInvMultiply', $00000300, H);
  RegisterConstant('fxBlendNA', $00000302, H);
  RegisterConstant('fxSub', $00010104, H);
  RegisterConstant('fxRevSub', $00020104, H);
  RegisterConstant('fxMax', $00040101, H);
  RegisterConstant('fxMin', $00030101, H);
  RegisterRoutine('function Blend2Fx(SrcBlend, DestBlend: TBlendCoef; BlendOp: TBlendOp): Cardinal;', @Blend2Fx, H);
  RegisterRoutine('procedure Fx2Blend(Effect: Cardinal; out SrcBlend, DestBlend: TBlendCoef; out BlendOp: TBlendOp);', @Fx2Blend, H);
  RegisterRoutine('function Point2(x, y: Real): TPoint2;', @Point2, H);
  RegisterRoutine('function Point4(x1, y1, x2, y2, x3, y3, x4, y4: Real): TPoint4;', @Point4, H);
  RegisterRoutine('function pRect4(const Rect: TRect): TPoint4;', @pRect4, H);
  RegisterRoutine('function pBounds4(_Left, _Top, _Width, _Height: Real): TPoint4;', @pBounds4, H);
  RegisterRoutine('function pBounds4s(_Left, _Top, _Width, _Height, Theta: Real): TPoint4;', @pBounds4s, H);
  RegisterRoutine('function pBounds4sc(_Left, _Top, _Width, _Height, Theta: Real): TPoint4;', @pBounds4sc, H);
  RegisterRoutine('function pMirror4(const Point4: TPoint4): TPoint4;', @pMirror4, H);
  RegisterRoutine('function pFlip4(const Point4: TPoint4): TPoint4;', @pFlip4, H);
  RegisterRoutine('function pShift4(const Points: TPoint4; const ShiftBy: TPoint2): TPoint4;', @pShift4, H);
  RegisterRoutine('function pRotate4(const Origin, Size, Middle: TPoint2; Angle: Real; Theta: Real): TPoint4;', @pRotate4, H);
  RegisterRoutine('function pRotate4c(const Origin, Size: TPoint2; Angle: Real; Theta: Real): TPoint4;', @pRotate4c, H);
  RegisterRoutine('function cRGB4(r, g, b: Cardinal; a: Cardinal = 255): TColor4; overload;', @cRGB41, H);
  RegisterRoutine('function cRGB4(r1, g1, b1, a1, r2, g2, b2, a2: Cardinal): TColor4; overload;', @cRGB42, H);
  RegisterRoutine('function cColor4(Color: Cardinal): TColor4; overload;', @cColor43, H);
  RegisterRoutine('function cColor4(Color1, Color2, Color3, Color4: Cardinal): TColor4; overload;', @cColor44, H);
  RegisterRoutine('function cGray4(Gray: Cardinal): TColor4; overload;', @cGray45, H);
  RegisterRoutine('function cGray4(Gray1, Gray2, Gray3, Gray4: Cardinal): TColor4; overload;', @cGray46, H);
  RegisterRoutine('function cAlpha4(Alpha: Cardinal): TColor4; overload;', @cAlpha47, H);
  RegisterRoutine('function cAlpha4(Alpha1, Alpha2, Alpha3, Alpha4: Cardinal): TColor4; overload;', @cAlpha48, H);
  RegisterRoutine('function cColorAlpha4(Color, Alpha: Cardinal): TColor4; overload;', @cColorAlpha49, H);
  RegisterRoutine('function cColorAlpha4(Color1, Color2, Color3, Color4, Alpha1, Alpha2, Alpha3, Alpha4: Cardinal): TColor4; overload;', @cColorAlpha410, H);
  RegisterRoutine('function cRGB1(r, g, b: Cardinal; a: Cardinal = 255): Cardinal;', @cRGB1, H);
  RegisterStdRoutineEx('cGray1', _cGray1,1,[typeCARDINAL,typeCARDINAL], H);
  RegisterStdRoutineEx('cAlpha1', _cAlpha1,1,[typeCARDINAL,typeCARDINAL], H);
  RegisterRoutine('function tPattern(Pattern: Integer): TTexCoord;', @tPattern, H);
  RegisterRoutine('function tPatternEx(Pattern: Integer; Mirror, Flip: Boolean): TTexCoord;', @tPatternEx, H);
  RegisterRoutine('function PointInRect(const Point: TPoint; const Rect: TRect): Boolean;', @PointInRect, H);
  RegisterRoutine('function RectInRect(const Rect1, Rect2: TRect): Boolean;', @RectInRect, H);
  RegisterRoutine('function OverlapRect(const Rect1, Rect2: TRect): Boolean;', @OverlapRect, H);
  RegisterStdRoutineEx('NextPowerOfTwo', _NextPowerOfTwo,1,[typeINTEGER,typeINTEGER], H);
  RegisterStdRoutineEx('IsPowerOfTwo', _IsPowerOfTwo,1,[typeINTEGER,typeBOOLEAN], H);
  RegisterStdRoutineEx('CeilPowerOfTwo', _CeilPowerOfTwo,1,[typeINTEGER,typeINTEGER], H);
  RegisterStdRoutineEx('FloorPowerOfTwo', _FloorPowerOfTwo,1,[typeINTEGER,typeINTEGER], H);
  RegisterRoutine('function LoadTextFile(const FileName: string; out Text: string): Boolean;', @LoadTextFile, H);
end;
initialization
  RegisterIMP_AsphyreDef;
end.
