improve text-only interface

Reposition cursor to top before redraw, so textport updates don't jump

Fix keyboard so tty lower-case key is transmitted as correct key
  code (upper case and let apple2e.cpp handle conversion)
This commit is contained in:
Brad Grantham 2018-06-08 10:01:03 -07:00
parent b925142da1
commit 6745843b0c

View File

@ -21,6 +21,7 @@ using namespace std;
namespace APPLE2Einterface namespace APPLE2Einterface
{ {
bool textport_needs_output[2] = {false, false};
DisplayMode display_mode = TEXT; DisplayMode display_mode = TEXT;
int display_page = 0; // Apple //e page minus 1 (so 0,1 not 1,2) int display_page = 0; // Apple //e page minus 1 (so 0,1 not 1,2)
bool mixed_mode = false; bool mixed_mode = false;
@ -35,8 +36,6 @@ unsigned char textport[2][24][40];
deque<event> event_queue; deque<event> event_queue;
bool force_caps_on = true;
bool event_waiting() bool event_waiting()
{ {
return event_queue.size() > 0; return event_queue.size() > 0;
@ -184,6 +183,8 @@ void poll_keyboard()
} else if(c >= 1 && c<= 26) { } else if(c >= 1 && c<= 26) {
control = true; control = true;
ch = 'A' + c - 1; ch = 'A' + c - 1;
} else if(c >= 'a' && c<= 'z') {
ch = 'A' + c - 'a';
} else { } else {
ch = c; ch = c;
} }
@ -206,6 +207,9 @@ void iterate()
{ {
apply_writes(); apply_writes();
if(textport_needs_output[display_page])
{
printf("\033[0;0H");
printf(".----------------------------------------.\n"); printf(".----------------------------------------.\n");
for(int row = 0; row < 24; row++) { for(int row = 0; row < 24; row++) {
putchar('|'); putchar('|');
@ -216,6 +220,8 @@ void iterate()
puts("|"); puts("|");
} }
printf("`----------------------------------------'\n"); printf("`----------------------------------------'\n");
textport_needs_output[display_page] = false;
}
poll_keyboard(); poll_keyboard();
} }
@ -257,6 +263,7 @@ void write2(int addr, unsigned char data)
if((within_page >= row_offset) && (within_page < row_offset + 40)) { if((within_page >= row_offset) && (within_page < row_offset + 40)) {
int col = within_page - row_offset; int col = within_page - row_offset;
textport[page][row][col] = data; textport[page][row][col] = data;
textport_needs_output[page] = true;
} }
} }