[CHANGE] Print jumps to next line if needed
This commit is contained in:
10
ascii.cpp
10
ascii.cpp
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user