Unit PR_BDEF;

Interface

Uses pr_defs, progdefs, math, strings, console;

Const PR_BUILTS = 255;

Var  pr_numbuiltins : byte;
     pr_builtins    : Array[1..PR_BUILTS] Of Procedure;

Function G_FLOAT(o : longint) : float;
Function G_INT(o : longint) : longint;
Function G_VECTOR(o : longint) : vec3_tp;
Function G_EDICT(o : longint) : edict_tp;
Function G_STRING(o : longint) : PChar;
function memfloat(p : pointer) : float;
function intfloat(i : longint) : float;
function memlong(p : pointer) : longint;
Procedure SET_G_VECTOR(o : longint; v : vec3_tp);
Procedure SUB_Null;

Implementation

function memfloat(p : pointer) : float;
Var f : float;
    a : array[1..4] of byte absolute f;
    pp : PChar;
begin
  pp := p;
  a[1] := Byte(pp^);
  a[2] := Byte((pp+1)^);
  a[3] := Byte((pp+2)^);
  a[4] := Byte((pp+3)^);
  memfloat := f;
end;

function intfloat(i : longint) : float;
Var f : float;
    a : array[1..4] of byte absolute f;
    pp : PChar;
begin
  pp := @i;
  a[1] := Byte(pp^);
  a[2] := Byte((pp+1)^);
  a[3] := Byte((pp+2)^);
  a[4] := Byte((pp+3)^);
  intfloat := f;
end;


function memlong(p : pointer) : longint;
Var f : longint;
    a : array[1..4] of byte absolute f;
    pp : PChar;
begin
  pp := p;
  a[1] := Byte(pp^);
  a[2] := Byte((pp+1)^);
  a[3] := Byte((pp+2)^);
  a[4] := Byte((pp+3)^);
  memlong := f;
end;

Function G_FLOAT(o : longint) : float;
Begin
  G_FLOAT := memfloat(@pr_globals^[o]);
End;

Function G_INT(o : longint) : longint;
Begin
  G_INT := memlong(@pr_globals^[o]);
End;

Procedure SET_G_INT(o : longint; v : longint);
Begin
  Move(v, pr_globals^[o], 4);
End;

Function G_VECTOR(o : longint) : vec3_tp;
Begin
  G_VECTOR := vec3_tp(@pr_globals^[o]);
End;

Procedure SET_G_VECTOR(o : longint; v : vec3_tp);
Begin
  Move(v^, pr_globals^[o], 12);
End;

Function G_EDICT(o : longint) : edict_tp;
Begin
  G_EDICT := edict_tp(@pr_globals^[o]);
End;

Function G_STRING(o : longint) : PChar;
Begin
  G_STRING := @pr_strings^[memlong(@pr_globals^[o])];
End;

Procedure SUB_Null; Begin End;

end.