Texture, sound and font data now uses heap instead of a stack.

This commit is contained in:
Ognjen Milan Robovic 2024-03-17 16:08:50 -04:00
parent b173b130d5
commit 2e303d8372
4 changed files with 36 additions and 25 deletions

View File

@ -7,9 +7,9 @@ package body core is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
type colour is range 0 .. 2 ** 32 - 1;
--
-- Quick fix...
type rectangle is record x, y, width, height : integer; end record;
--
-- Fucking abomination...
type texture_data is record id : natural; width, height, mipmaps, format : integer; end record;
type sound_data is record buffer, processor : integer; sampleRate, sampleSize, channels, frameCount : natural; end record;
type font_data is record baseSize, glyphCount, glyphPadding : integer; id : texture_data; recs, glyphs : integer; end record;
@ -45,20 +45,24 @@ package body core is
--
procedure play_sound (data : in sound_data) with import => true, convention => c, external_name => "PlaySound";
procedure stop_sound (data : in sound_data) with import => true, convention => c, external_name => "StopSound";
--
-- What the fuck...
procedure draw_texture (data : in texture_data; s, d : in rectangle; o : in vector; rotation : in float; tint : in colour) with import => true, convention => c, external_name => "DrawTexturePro";
procedure draw_string (data : in font_data; text : in string; p, o : in vector; r, t, s : in float; tint : in colour) with import => true, convention => c, external_name => "DrawTextPro";
procedure draw_vector (x1, y1, x2, y2 : in integer; tint : in colour) with import => true, convention => c, external_name => "DrawLine";
--
-- Please...
function get_random_value (minimum, maximum : in integer) return integer with import => true, convention => c, external_name => "GetRandomValue";
texture_count : integer := 0;
sound_count : integer := 0;
font_count : integer := 1;
texture_array : array (0 .. 1600) of texture_data;
sound_array : array (0 .. 2) of sound_data;
font_array : array (1 .. 4) of font_data;
type texture_data_array is array (natural range <>) of texture_data;
type sound_data_array is array (natural range <>) of sound_data;
type font_data_array is array (natural range <>) of font_data;
texture_array : access texture_data_array;
sound_array : access sound_data_array;
font_array : access font_data_array;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -439,25 +443,21 @@ package body core is
------------------------------------------------------------------------------------------
procedure configure is
begin
echo (comment, "Configuring core game engine components...");
--
hexagon_grid_sprite := load_sprite ("./sprite/ui/hexagon_grid_tile.png", 1, 1);
hexagon_fill_sprite := load_sprite ("./sprite/ui/hexagon_fill_tile.png", 1, 1);
end configure;
------------------------------------------------------------------------------------------
procedure initialize is
begin
engine_active := true;
texture_array := new texture_data_array (0 .. 1600);
sound_array := new sound_data_array (0 .. 2);
font_array := new font_data_array (1 .. 4);
--
error_callback (7);
error_callback (0);
initialize_video (1800, 900, "Chads of Might & Magic");
initialize_audio;
--
limit_framerate (60);
--
hexagon_grid_sprite := load_sprite ("./sprite/ui/hexagon_grid_tile.png", 1, 1);
hexagon_fill_sprite := load_sprite ("./sprite/ui/hexagon_fill_tile.png", 1, 1);
end initialize;
------------------------------------------------------------------------------------------

View File

@ -128,7 +128,6 @@ package core is
procedure write_text_box (text : in string);
procedure configure;
procedure initialize;
procedure deinitialize;
procedure synchronize;

View File

@ -98,7 +98,6 @@ begin
core.echo (core.comment, "Xhads is free software, you can redistribute it and modify it under the terms of the GNU General Public License by Free Software Foundation.");
core.dash;
core.configure;
core.initialize;
ui.configure;

View File

@ -1,14 +1,27 @@
.POSIX:
default:
gfortran -fPIC -Wall -Wextra -Ofast -fno-underscoring -fstack-check -c -o ai.o ai.f90
gcc -g -ansi -Wall -Wextra -Wpedantic -Ofast -fstack-check -c -fPIC -o system.o system.c
#
gnatmake -g -O3 -fstack-check -c main.adb
gnatbind main.ali
gcc -g -ansi -Wall -Wextra -Wpedantic -Ofast -fstack-check -c -fPIC -o raylib.o raylib.c
gnatlink main.ali system.o raylib.o ai.o -o xhads -lraylib -lc -lgfortran
gnatlink -o xhads main.ali -lraylib
mv xhads ../xhads
#~ gfortran -fPIC -Wall -Wextra -Ofast -fno-underscoring -fstack-check -c -o ai.o ai.f90
#~ gcc -g -ansi -Wall -Wextra -Wpedantic -Ofast -fstack-check -c -fPIC -o system.o system.c
#
#~ gnatmake -g -O3 -fstack-check -c main.adb
#~ gnatbind main.ali
#~ gcc -g -ansi -Wall -Wextra -Wpedantic -Ofast -fstack-check -c -fPIC -o raylib.o raylib.c
#~ gnatlink main.ali system.o raylib.o ai.o -o xhads -lraylib -lc -lgfortran
#~ gnatmake -g -O3 -fstack-check -c main.adb -lraylib
#~ mv xhads ../xhads
#~ gfortran -fPIC -Wall -Wextra -Ofast -fno-underscoring -fstack-check -c -o ai.o ai.f90
#~ gcc -g -ansi -Wall -Wextra -Wpedantic -Ofast -fstack-check -c -fPIC -o system.o system.c
#
#~ gnatmake -g -O3 -fstack-check -c main.adb
#~ gnatbind main.ali
#~ gcc -g -ansi -Wall -Wextra -Wpedantic -Ofast -fstack-check -c -fPIC -o raylib.o raylib.c
#~ gnatlink main.ali system.o raylib.o ai.o -o xhads -lraylib -lc -lgfortran
#~ mv xhads ../xhads
#
#~ gnatmake -g -O3 -fstack-check -c main.adb
#~ gnatbind main.ali