From 7382d0d9d5fb81d3bfbc21ee2f3426baa3e2d85a Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 27 May 2024 16:38:18 -0400 Subject: [PATCH] Some more Raylib functions... --- source/core.adb | 16 +++++++++++++++- source/core.ads | 4 ++++ source/ray.ads | 12 +++++++----- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/source/core.adb b/source/core.adb index 5b68500..ff5bad8 100644 --- a/source/core.adb +++ b/source/core.adb @@ -154,6 +154,20 @@ package body core is ------------------------------------------------------------------------------------------ + function compress (data : in address; size : in integer; used : out integer) return address is + begin + return address (ray.compress (ray.pointer (data), size, used)); + end compress; + + ------------------------------------------------------------------------------------------ + + function decompress (data : in address; size : in integer; used : out integer) return address is + begin + return address (ray.decompress (ray.pointer (data), size, used)); + end decompress; + + ------------------------------------------------------------------------------------------ + function c_string (ada_string : string) return string is begin return (ada_string & character'val (0)); @@ -260,7 +274,7 @@ package body core is procedure import_text (data : in out string_box_data; file_path : in string) is begin - data.text := to_unbounded_string (to_ada (ray.load_text (c_string (file_path)))) & character'val (0); + data.text := to_unbounded_string (to_ada (ray.load_text (c_string (file_path)).all)) & character'val (0); end import_text; ------------------------------------------------------------------------------------------ diff --git a/source/core.ads b/source/core.ads index 749575d..d94d827 100644 --- a/source/core.ads +++ b/source/core.ads @@ -51,6 +51,7 @@ package core is subtype long_string is string (1 .. 72); type pointer is access procedure; + type address is new ray.pointer; type vector is record x, y : integer; end record; type sprite is record index, width, height, frames, states : integer; end record; @@ -127,6 +128,9 @@ package core is function time return float; + function compress (data : in address; size : in integer; used : out integer) return address; + function decompress (data : in address; size : in integer; used : out integer) return address; + function c_string (ada_string : in string) return string; function random (minimum, maximum : in integer) return integer; diff --git a/source/ray.ads b/source/ray.ads index 428932b..6776684 100644 --- a/source/ray.ads +++ b/source/ray.ads @@ -181,18 +181,20 @@ package ray is function get_time return long_float with import => true, convention => c, external_name => "GetTime"; - --~void OpenURL(const char *url); - - function load_text (file : in string) return char_array with import => true, convention => c, external_name => "LoadFileText"; + function load_text (file : in string) return access char_array with import => true, convention => c, external_name => "LoadFileText"; function mouse_wheel_move return float with import => true, convention => c, external_name => "GetMouseWheelMove"; + --~void OpenURL(const char *url); + --~procedure unload_file (data : in access string) with import => true, convention => c, external_name => "UnloadFileText"; --~bool SaveFileText(const char *fileName, char *text); --~FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool scanSubdirs); --~void UnloadDirectoryFiles(FilePathList files); - --~unsigned char *CompressData(const unsigned char *data, int dataSize, int *compDataSize); - --~unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); + + function compress (data : in pointer; size : in integer; used : out integer) return pointer with import => true, convention => c, external_name => "CompressData"; + function decompress (data : in pointer; size : in integer; used : out integer) return pointer with import => true, convention => c, external_name => "DecompressData"; + --~void SetTextLineSpacing(int spacing); --~Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); --~bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2);