xhads/source/core.ads

177 lines
7.7 KiB
Ada

with ada.text_io, ada.strings, ada.strings.unbounded, interfaces.c;
use ada.text_io, ada.strings, ada.strings.unbounded, interfaces.c;
package core is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
type terminal_colour is (
grey, red, green, yellow, blue, pink,
cyan, white
);
type terminal_effect is (
normal, bold, italic, underline, blink, invert
);
type echo_status is (
failure, warning, success, comment
);
type signal_code is (
signal_none, signal_space, signal_zero, signal_one, signal_two, signal_three,
signal_four, signal_five, signal_six, signal_seven, signal_eight, signal_nine,
signal_a, signal_b, signal_c, signal_d, signal_e, signal_f,
signal_g, signal_h, signal_i, signal_j, signal_k, signal_l,
signal_m, signal_n, signal_o, signal_p, signal_q, signal_r,
signal_s, signal_t, signal_u, signal_v, signal_w, signal_x,
signal_y, signal_z, signal_grave, signal_escape, signal_enter, signal_tab,
signal_backspace, signal_right, signal_left, signal_down, signal_up, signal_kp_0,
signal_kp_1, signal_kp_2, signal_kp_3, signal_kp_4, signal_kp_5, signal_kp_6,
signal_kp_7, signal_kp_8, signal_kp_9, signal_kp_subtract, signal_kp_add, signal_left_shift,
signal_left_control
);
subtype short_string is string (1 .. 24);
subtype long_string is string (1 .. 72);
type sprite is
record
index, width, height, frames, states : integer;
end record;
type font is
record
index, size, pad : integer;
end record;
type vector_2 is
record
x, y : integer;
end record;
type volatile is
record
data : unbounded_string := null_unbounded_string;
rows : integer := 0;
columns : integer := 0;
end record;
------------------------------------------------------------------------------------------
-- C
cursor_x : integer with import => true, convention => c;
cursor_y : integer with import => true, convention => c;
cursor_mode : integer with import => true, convention => c;
signal_mode : integer with import => true, convention => c;
engine_active : boolean with import => true, convention => c;
framerate : integer with import => true, convention => c;
------------------------------------------------------------------------------------------
icon : constant natural := 32;
base : constant natural := 32;
gameplay_framerate : constant natural := 60;
animation_framerate : constant natural := 6;
global_time : natural := 0;
gameplay_time : natural := 0;
animation_time : natural := 0;
hexagon_grid_sprite : sprite;
hexagon_fill_sprite : sprite;
camera : vector_2 := (0, 0);
text_box : volatile;
fonts : array (0 .. 3) of font;
------------------------------------------------------------------------------------------
-- C
procedure die with import => true, convention => c;
function random_integer (minimum, maximum : in integer) return integer with import => true, convention => c;
procedure engine_configure with import => true, convention => c;
procedure engine_synchronize with import => true, convention => c;
function window_width return integer with import => true, convention => c;
function window_height return integer with import => true, convention => c;
procedure render_sprite (sprite, x, y, u, v, width, height : in integer) with import => true, convention => c;
procedure render_string (text : in string; x, y, colour, index, size, pad : in integer) with import => true, convention => c;
procedure render_vector (x1, y1, x2, y2 : in integer) with import => true, convention => c;
function import_texture (file_path : in string) return integer with import => true, convention => c;
function import_sound (file_path : in string) return integer with import => true, convention => c;
function import_font (file_path : in string) return integer with import => true, convention => c;
function sprite_width (index : in integer) return integer with import => true, convention => c;
function sprite_height (index : in integer) return integer with import => true, convention => c;
procedure play_sound (index : in integer) with import => true, convention => c;
procedure stop_sound (index : in integer) with import => true, convention => c;
procedure loop_sound (index : in integer) with import => true, convention => c;
------------------------------------------------------------------------------------------
-- Fortran
procedure ai_synchronize (level : in integer) with import => true, convention => fortran;
------------------------------------------------------------------------------------------
procedure terminal (colour : in terminal_colour := white; effect : in terminal_effect := normal);
procedure echo (status : in echo_status; message : in string);
procedure dash;
procedure semi_dash;
procedure configure;
procedure synchronize;
procedure draw_state_box (x, y : in integer);
function flip_coin return integer;
function roll_dice return integer;
function by_chance (chance : in integer) return integer;
function c_string (ada_string : in string) return string;
function clip (value, minimum, maximum : in integer) return integer;
function load_sprite (file_path : in string; frames, states : in integer) return sprite;
-- load_song
function load_font (file_path : in string; size, pad : in integer) return font;
procedure crop (data : in sprite; x, y, u, v, width, height : in integer);
procedure view (data : in sprite; x, y, u, v, width, height : in integer);
procedure draw (data : in sprite; x, y : in integer);
procedure move (data : in sprite; x, y, frame, state : in integer);
procedure line (origin, offset : in vector_2);
procedure write (text : in string; x, y : in integer; colour : in integer := 16#A37A28#; data : in font := fonts (0));
procedure debug (text : in string);
procedure hexagonal_grid (x, y, width, height : in integer; fill : in boolean);
function lowercase (text : in string) return string;
function uppercase (text : in string) return string;
procedure draw_central_grid (x, y, width, height : in integer);
procedure draw_squared_grid (x, y, width, height : in integer);
procedure draw_hexagon_grid (x, y, width, height : in integer);
function read_text_box return string;
procedure write_text_box (text : in string);
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end core;