|
|
@ -27,8 +27,8 @@ static Cell screen[MAX_SCREEN_SIZE]; |
|
|
|
* Cursor position and attributes |
|
|
|
* Cursor position and attributes |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static struct { |
|
|
|
static struct { |
|
|
|
Coordinate x; //!< X coordinate
|
|
|
|
int x; //!< X coordinate
|
|
|
|
Coordinate y; //!< Y coordinate
|
|
|
|
int y; //!< Y coordinate
|
|
|
|
bool visible; //!< Visible
|
|
|
|
bool visible; //!< Visible
|
|
|
|
bool inverse; //!< Inverse colors
|
|
|
|
bool inverse; //!< Inverse colors
|
|
|
|
Color fg; //!< Foreground color for writing
|
|
|
|
Color fg; //!< Foreground color for writing
|
|
|
@ -39,19 +39,19 @@ static struct { |
|
|
|
* Saved cursor position, used with the SCP RCP commands |
|
|
|
* Saved cursor position, used with the SCP RCP commands |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static struct { |
|
|
|
static struct { |
|
|
|
Coordinate x; |
|
|
|
int x; |
|
|
|
Coordinate y; |
|
|
|
int y; |
|
|
|
} cursor_sav; |
|
|
|
} cursor_sav; |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Active screen width |
|
|
|
* Active screen width |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static Coordinate W = SCREEN_DEF_W; |
|
|
|
static int W = SCREEN_DEF_W; |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Active screen height |
|
|
|
* Active screen height |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static Coordinate H = SCREEN_DEF_H; |
|
|
|
static int H = SCREEN_DEF_H; |
|
|
|
|
|
|
|
|
|
|
|
// XXX volatile is probably not needed
|
|
|
|
// XXX volatile is probably not needed
|
|
|
|
static volatile int notifyLock = 0; |
|
|
|
static volatile int notifyLock = 0; |
|
|
@ -193,7 +193,7 @@ screen_clear_line(ClearMode mode) |
|
|
|
* @param rows - new height |
|
|
|
* @param rows - new height |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
screen_resize(Coordinate rows, Coordinate cols) |
|
|
|
screen_resize(int rows, int cols) |
|
|
|
{ |
|
|
|
{ |
|
|
|
NOTIFY_LOCK(); |
|
|
|
NOTIFY_LOCK(); |
|
|
|
// sanitize
|
|
|
|
// sanitize
|
|
|
@ -277,7 +277,7 @@ done: |
|
|
|
* Set cursor position |
|
|
|
* Set cursor position |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
screen_cursor_set(Coordinate x, Coordinate y) |
|
|
|
screen_cursor_set(int y, int x) |
|
|
|
{ |
|
|
|
{ |
|
|
|
NOTIFY_LOCK(); |
|
|
|
NOTIFY_LOCK(); |
|
|
|
if (x >= W) x = W - 1; |
|
|
|
if (x >= W) x = W - 1; |
|
|
@ -287,11 +287,21 @@ screen_cursor_set(Coordinate x, Coordinate y) |
|
|
|
NOTIFY_DONE(); |
|
|
|
NOTIFY_DONE(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Set cursor position |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
|
|
|
|
screen_cursor_get(int *y, int *x) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
*x = cursor.x; |
|
|
|
|
|
|
|
*y = cursor.y; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Set cursor X position |
|
|
|
* Set cursor X position |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
screen_cursor_set_x(Coordinate x) |
|
|
|
screen_cursor_set_x(int x) |
|
|
|
{ |
|
|
|
{ |
|
|
|
NOTIFY_LOCK(); |
|
|
|
NOTIFY_LOCK(); |
|
|
|
if (x >= W) x = W - 1; |
|
|
|
if (x >= W) x = W - 1; |
|
|
@ -303,7 +313,7 @@ screen_cursor_set_x(Coordinate x) |
|
|
|
* Set cursor Y position |
|
|
|
* Set cursor Y position |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
screen_cursor_set_y(Coordinate y) |
|
|
|
screen_cursor_set_y(int y) |
|
|
|
{ |
|
|
|
{ |
|
|
|
NOTIFY_LOCK(); |
|
|
|
NOTIFY_LOCK(); |
|
|
|
if (y >= H) y = H - 1; |
|
|
|
if (y >= H) y = H - 1; |
|
|
@ -315,7 +325,7 @@ screen_cursor_set_y(Coordinate y) |
|
|
|
* Relative cursor move |
|
|
|
* Relative cursor move |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
void ICACHE_FLASH_ATTR |
|
|
|
screen_cursor_move(int dx, int dy) |
|
|
|
screen_cursor_move(int dy, int dx) |
|
|
|
{ |
|
|
|
{ |
|
|
|
NOTIFY_LOCK(); |
|
|
|
NOTIFY_LOCK(); |
|
|
|
int move; |
|
|
|
int move; |
|
|
@ -431,6 +441,18 @@ screen_set_bright_fg(void) |
|
|
|
|
|
|
|
|
|
|
|
//endregion
|
|
|
|
//endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Check if coords are in range |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param y |
|
|
|
|
|
|
|
* @param x |
|
|
|
|
|
|
|
* @return OK |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
bool ICACHE_FLASH_ATTR screen_isCoordValid(int y, int x) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return x >= 0 && y >= 0 && x < W && y < H; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Set a character in the cursor color, move to right with wrap. |
|
|
|
* Set a character in the cursor color, move to right with wrap. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -448,23 +470,31 @@ screen_putchar(char ch) |
|
|
|
goto done; |
|
|
|
goto done; |
|
|
|
|
|
|
|
|
|
|
|
case '\n': |
|
|
|
case '\n': |
|
|
|
screen_cursor_move(0, 1); |
|
|
|
screen_cursor_move(1, 0); |
|
|
|
goto done; |
|
|
|
goto done; |
|
|
|
|
|
|
|
|
|
|
|
case 8: // BS
|
|
|
|
case 8: // BS
|
|
|
|
if (cursor.x > 0) cursor.x--; |
|
|
|
if (cursor.x > 0) { |
|
|
|
|
|
|
|
cursor.x--; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// wrap around start of line
|
|
|
|
|
|
|
|
if (cursor.y>0) { |
|
|
|
|
|
|
|
cursor.x=W-1; |
|
|
|
|
|
|
|
cursor.y--; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
// erase target cell
|
|
|
|
// erase target cell
|
|
|
|
c = &screen[cursor.x + cursor.y * W]; |
|
|
|
c = &screen[cursor.x + cursor.y * W]; |
|
|
|
c->c = ' '; |
|
|
|
c->c = ' '; |
|
|
|
goto done; |
|
|
|
goto done; |
|
|
|
|
|
|
|
|
|
|
|
case 9: // TAB
|
|
|
|
case 9: // TAB
|
|
|
|
|
|
|
|
if (cursor.x<((W-1)-(W-1)%4)) { |
|
|
|
c->c = ' '; |
|
|
|
c->c = ' '; |
|
|
|
// nested recurs >:( but it's ok
|
|
|
|
do { |
|
|
|
screen_putchar(' '); |
|
|
|
|
|
|
|
screen_putchar(' '); |
|
|
|
|
|
|
|
screen_putchar(' '); |
|
|
|
|
|
|
|
screen_putchar(' '); |
|
|
|
screen_putchar(' '); |
|
|
|
|
|
|
|
} while(cursor.x%4!=0); |
|
|
|
|
|
|
|
} |
|
|
|
goto done; |
|
|
|
goto done; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|