[CHANGE] Print jumps to next line if needed

This commit is contained in:
2021-12-13 15:09:30 +01:00
parent 788c5d6c6e
commit e5798f4b71

View File

@@ -322,15 +322,17 @@ void print(const char *str, int x, int y) {
if (x >= 0) cursor_x = min(x, screen_width-1);
if (y >= 0) cursor_y = min(y, screen_height-1);
int len = SDL_strlen(str);
if ((cursor_x+len) > screen_width) len -= ((cursor_x+len) - screen_width);
const int pos = cursor_x+cursor_y*screen_width;
if (pos+len > screen_width*screen_height) len -= ((pos+len) - screen_width*screen_height);
//int offset = x+y*screen_width;
for (int i=0; i < len; ++i) {
CHRSCR(cursor_x+i, cursor_y) = str[i];
if (current_mode != 0) COLSCR(cursor_x+i, cursor_y) = current_color;
char_screen[pos+i] = str[i];
if (current_mode != 0) color_screen[pos+i] = current_color;
//char_screen[offset+i] = str[i];
//if (current_mode != 0) color_screen[offset+i] = current_color;
}
cursor_x += len;
cursor_x = (pos+len)%screen_width;
cursor_y = (pos+len)/screen_width;
}
bool btn(uint8_t i) {