Working on console interaction...
This commit is contained in:
14
ascii.cpp
14
ascii.cpp
@@ -261,6 +261,10 @@ bool btnp(uint8_t i) {
|
|||||||
return key_just_pressed == i;
|
return key_just_pressed == i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t whichbtn() {
|
||||||
|
return key_just_pressed;
|
||||||
|
}
|
||||||
|
|
||||||
int mousex() {
|
int mousex() {
|
||||||
return mouse_x;
|
return mouse_x;
|
||||||
}
|
}
|
||||||
@@ -350,6 +354,16 @@ void debug_one_line_up() {
|
|||||||
debug_cursor = debug_total_size-debug_line_size;
|
debug_cursor = debug_total_size-debug_line_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void debugchr(const uint8_t chr) {
|
||||||
|
if (chr == 8) {
|
||||||
|
debug_text[debug_cursor--] = 32;
|
||||||
|
debug_text[debug_cursor] = 32;
|
||||||
|
} else {
|
||||||
|
debug_text[debug_cursor++] = chr;
|
||||||
|
if (debug_cursor >= debug_total_size) debug_one_line_up();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void debug(const char *str) {
|
void debug(const char *str) {
|
||||||
const int len = SDL_strlen(str);
|
const int len = SDL_strlen(str);
|
||||||
for (int i=0; i<len;++i) {
|
for (int i=0; i<len;++i) {
|
||||||
|
|||||||
2
ascii.h
2
ascii.h
@@ -122,6 +122,7 @@ void print(const char *str, int x = -1, int y = -1);
|
|||||||
|
|
||||||
bool btn(uint8_t i);
|
bool btn(uint8_t i);
|
||||||
bool btnp(uint8_t i);
|
bool btnp(uint8_t i);
|
||||||
|
uint8_t whichbtn();
|
||||||
|
|
||||||
int mousex();
|
int mousex();
|
||||||
int mousey();
|
int mousey();
|
||||||
@@ -154,6 +155,7 @@ int rnd(int x);
|
|||||||
|
|
||||||
const char* tostr(int val);
|
const char* tostr(int val);
|
||||||
|
|
||||||
|
void debugchr(const uint8_t chr);
|
||||||
void debug(const char *str);
|
void debug(const char *str);
|
||||||
void pdebug();
|
void pdebug();
|
||||||
|
|
||||||
|
|||||||
9
main.cpp
9
main.cpp
@@ -3,6 +3,15 @@
|
|||||||
int current_editor = 0;
|
int current_editor = 0;
|
||||||
|
|
||||||
void do_terminal() {
|
void do_terminal() {
|
||||||
|
const uint8_t key = whichbtn();
|
||||||
|
if (key != KEY_UNKNOWN) {
|
||||||
|
if (key < 30) debugchr(key+61);
|
||||||
|
else if (key < 39) debugchr(key+19);
|
||||||
|
else if (key == KEY_0) debugchr(key+9);
|
||||||
|
else if (key == KEY_RETURN) debug(" ");
|
||||||
|
else if (key == KEY_SPACE) debugchr(32);
|
||||||
|
else if (key == KEY_BACKSPACE) debugchr(8);
|
||||||
|
}
|
||||||
cls(0);
|
cls(0);
|
||||||
pdebug();
|
pdebug();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user