I hate this... (for now)

This commit is contained in:
Ognjen Milan Robovic 2023-10-04 15:12:51 -04:00
parent bc36408895
commit d60f1c0574
2 changed files with 15 additions and 11 deletions

View File

@ -2,6 +2,8 @@
set -xe
mkdir /usr/include/xolatile
cp xurses.h /usr/include/xolatile/xurses.h
cp xurses.c /usr/include/xolatile/xurses.c

View File

@ -95,23 +95,25 @@ void curses_screen_offset (void) {
}
char * curses_screen_position (int x, int y) {
fatal_failure (x <= -1, "curses_screen_position: X position is beyond the lower bound.");
fatal_failure (y <= -1, "curses_screen_position: Y position is beyond the lower bound.");
fatal_failure (x >= curses_screen_width, "curses_screen_position: X position is beyond the upper bound.");
fatal_failure (y >= curses_screen_height, "curses_screen_position: Y position is beyond the upper bound.");
fatal_failure (x <= -1, "curses_screen_position: X position is below the lower bound.");
fatal_failure (y <= -1, "curses_screen_position: Y position is below the lower bound.");
fatal_failure (x >= curses_screen_width, "curses_screen_position: X position is above the upper bound.");
fatal_failure (y >= curses_screen_height, "curses_screen_position: Y position is above the upper bound.");
return (& curses_screen [CURSES_LENGTH * (y * curses_screen_width + x) + y * CURSES_RETURN + CURSES_OFFSET]);
}
char * curses_format_character (char character, int colour, int effect) {
fatal_failure (character_is_invisible (character), "curses_format_character: Can not format invisible characters.");
fatal_failure (colour >= COLOUR_COUNT, "curses_format_character: Colour is invalid enumeration value.");
fatal_failure (effect >= EFFECT_COUNT, "curses_format_character: Effect is invalid enumeration value.");
log_in (LOG_WARNING, character_is_invisible (character), "curses_format_character: Can not format invisible characters.");
log_in (LOG_FAILURE, colour >= COLOUR_COUNT, "curses_format_character: Colour is invalid enumeration value.");
log_in (LOG_FAILURE, effect >= EFFECT_COUNT, "curses_format_character: Effect is invalid enumeration value.");
curses_format [2] = (char) effect + '0';
curses_format [5] = (char) colour + '0';
curses_format [2] = (char) (effect % EFFECT_COUNT) + '0';
curses_format [5] = (char) (colour % COLOUR_COUNT) + '0';
curses_format [7] = character;
log_out ("curses.log");
return (curses_format);
}
@ -119,8 +121,8 @@ void curses_output_character (char character, int colour, int effect) {
out (curses_format_character (character, colour, effect), CURSES_LENGTH);
}
void curses_render_character (char character, int colour, int effect, int x, int y) {
string_copy_limit (curses_screen_position (x, y), curses_format_character (character, colour, effect), CURSES_LENGTH);
void curses_render_character (char character, int x, int y, int colour, int effect) {
string_copy (curses_screen_position (x, y), curses_format_character (character, colour, effect));
curses_screen_size += CURSES_LENGTH;
}