------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -- 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. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -- Experimental minimal terminal rogue-like game in Ada programming language. I used to write a lot of Ada programs some time ago, then went in full C and assembly mode, and came -- back to Ada, but realized that I keep my folders messy... Since it's bothersome to find my old Ada projects and share them here, I decided that the most easy thing to do is to -- write a new program in Ada, a tiny game. Work in progress, it's messy and ugly for now... ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ with ada.text_io; with core; package body screen is ------------------------------------------------------------------------------------------ procedure delete is begin ada.text_io.put (core.ESCAPE & "[2J"); end delete; procedure offset is begin ada.text_io.put (core.ESCAPE & "[H"); end offset; procedure hide_cursor is begin ada.text_io.put (core.ESCAPE & "[?25l"); end hide_cursor; procedure show_cursor is begin ada.text_io.put (core.ESCAPE & "[?25h"); end show_cursor; procedure new_line is begin ada.text_io.put (core.CARRIAGE_RETURN & core.LINE_FEED); end new_line; procedure render_character (symbol : character := ' '; colour : character := core.colour.white; effect : character := core.effect.normal; y : height := 0; x : width := 0) is begin symbol_matrix (y, x) := symbol; colour_matrix (y, x) := colour; effect_matrix (y, x) := effect; end render_character; procedure render_buffer is format : string (1 .. 12) := core.ESCAPE & "[E;3CmS" & core.ESCAPE & "[0m"; begin offset; for y in height loop for x in width loop format (8) := symbol_matrix (y, x); format (6) := colour_matrix (y, x); format (3) := effect_matrix (y, x); ada.text_io.put (format); end loop; new_line; end loop; end render_buffer; ------------------------------------------------------------------------------------------ end screen;