xabina/core.adb

78 lines
2.8 KiB
Ada
Raw Normal View History

2023-10-15 11:00:07 -04:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2023 - Ognjen 'xolatile' Milan Robovic
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Xabina is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either
-- version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
-- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
with ada.text_io;
2023-10-15 12:35:38 -04:00
package body core is
2023-10-15 11:00:07 -04:00
------------------------------------------------------------------------------------------
2023-10-15 16:17:17 -04:00
r : natural := 1;
function randomize (minimum : natural;
maximum : natural) return natural is
begin
r := r + 1;
return minimum + (r mod maximum);
end randomize;
2023-10-15 11:00:07 -04:00
2023-10-15 12:35:38 -04:00
procedure screen_delete is
2023-10-15 12:15:04 -04:00
begin
ada.text_io.put (escape & "[2J");
2023-10-15 12:35:38 -04:00
end screen_delete;
2023-10-15 12:15:04 -04:00
2023-10-15 12:35:38 -04:00
procedure screen_offset is
2023-10-15 12:15:04 -04:00
begin
ada.text_io.put (escape & "[H");
2023-10-15 12:35:38 -04:00
end screen_offset;
2023-10-15 12:15:04 -04:00
2023-10-15 12:35:38 -04:00
procedure screen_hide_cursor is
2023-10-15 12:15:04 -04:00
begin
ada.text_io.put (escape & "[?25l");
2023-10-15 12:35:38 -04:00
end screen_hide_cursor;
2023-10-15 12:15:04 -04:00
2023-10-15 12:35:38 -04:00
procedure screen_show_cursor is
2023-10-15 12:15:04 -04:00
begin
ada.text_io.put (escape & "[?25h");
2023-10-15 12:35:38 -04:00
end screen_show_cursor;
2023-10-15 12:15:04 -04:00
2023-10-15 12:35:38 -04:00
procedure screen_new_line is
2023-10-15 12:15:04 -04:00
begin
ada.text_io.put (carriage_return & line_feed);
2023-10-15 12:35:38 -04:00
end screen_new_line;
2023-10-15 11:00:07 -04:00
2023-10-15 14:31:43 -04:00
procedure render_character (symbol : character;
colour : character;
effect : character;
y : screen_height;
x : screen_width) is
2023-10-15 11:00:07 -04:00
begin
2023-10-15 12:35:38 -04:00
screen_symbol (y, x) := symbol;
screen_colour (y, x) := colour;
screen_effect (y, x) := effect;
2023-10-15 11:00:07 -04:00
end render_character;
procedure render_buffer is
2023-10-15 12:15:04 -04:00
format : string (1 .. 12) := escape & "[E;3CmS" & escape & "[0m";
2023-10-15 11:00:07 -04:00
begin
2023-10-15 12:35:38 -04:00
screen_offset;
for y in screen_height
2023-10-15 11:00:07 -04:00
loop
2023-10-15 12:35:38 -04:00
for x in screen_width
2023-10-15 11:00:07 -04:00
loop
2023-10-15 12:35:38 -04:00
format (8) := screen_symbol (y, x);
format (6) := screen_colour (y, x);
format (3) := screen_effect (y, x);
2023-10-15 11:00:07 -04:00
ada.text_io.put (format);
end loop;
2023-10-15 12:35:38 -04:00
screen_new_line;
2023-10-15 11:00:07 -04:00
end loop;
end render_buffer;
------------------------------------------------------------------------------------------
2023-10-15 12:15:04 -04:00
end core;