36 static int console_width, console_height;
38 static Uint8 *color_ram;
40 #define CHARACTER_SET_DEFINER_8X16 static const Uint8 chargen[]
42 #undef CHARACTER_SET_DEFINER_8X16
43 static const Uint8 console_colors[3*16] = {
61 static int serial_delay;
62 static Uint8 kbd_queue[16];
63 static int kbd_queue_len;
64 static int kbd_waiting = 0;
65 static int input_waiting;
70 static void conraw_clear (
void )
72 memset(
video_ram, 0x20, console_width * console_height);
73 memset(color_ram, cursor.text_color, console_width * console_height);
78 static void conraw_scroll (
void )
81 memmove(color_ram, color_ram + console_width, console_width * (console_height - 1));
82 memset(
video_ram + console_width * (console_height - 1), 0x20, console_width);
83 memset(color_ram + console_width * (console_height - 1), cursor.text_color, console_width);
86 static void conraw_down (
void )
88 if (cursor.y == console_height - 1)
97 color_ram[cursor.y * console_width + cursor.x] = cursor.text_color;
98 if (cursor.x == console_width - 1) {
108 static char escape_buffer[100];
114 int l = strlen(escape_buffer);
115 escape_buffer[l++] =
data;
116 escape_buffer[l] = 0;
117 }
else if (
data == 27) {
120 escape_buffer[0] = 0;
121 }
else if (
data == 13) {
123 }
else if (
data == 10) {
125 }
else if (
data == 8) {
128 }
else if (
data < 32) {
130 conraw_putch(
'A' +
data);
136 cursor.phase_counter = 0;
151 return kbd_queue_len ? 0xFF : 0;
160 int ret = kbd_queue[0];
162 memmove(kbd_queue, kbd_queue + 1, kbd_queue_len);
174 if (cursor.blinking) {
175 if (cursor.phase_counter >= delay) {
176 cursor.phase = !cursor.phase;
177 cursor.phase_counter = 0;
179 cursor.phase_counter++;
188 int cursor_line = (cursor.phase && cursor.visible) ? cursor.y : -1;
191 for (
int y = 0;
y < console_height;
y++) {
193 for (
int x = 0;
x < console_width;
x++) {
201 if (row > 12 || kbd_waiting) {
203 fg =
palette[cursor.cursor_color];
206 for (
int bpos = 0; bpos < 8; bpos++, chln <<= 1)
207 *pixel++ = (chln & 0x80) ? fg : bg;
233 static void queue_key (
Uint8 k )
237 if (kbd_queue_len <
sizeof kbd_queue)
238 kbd_queue[kbd_queue_len++] = k;
249 if (ev->state == SDL_PRESSED) {
250 int k = ev->keysym.sym;
251 DEBUGPRINT(
"KEY: %d [%c]\n", k, (k >= 0x20 && k < 127) ? k :
'?');
254 if (k < 32 || k == 127) {
261 void emu_callback_key_texteditng_sdl ( SDL_TextEditingEvent *ev )
272 if (*p >= 0x20 && *p < 127)
281 int screen_width = width * 9;
283 int window_width = screen_width * zoom_percent / 100;
284 int window_height = screen_height * zoom_percent / 100;
292 screen_width, screen_height,
293 screen_width, screen_height,
294 window_width, window_height,
310 color_ram = color_mapped ? color_mapped :
xemu_malloc(width * height);
311 console_width = width;
312 console_height = height;
313 DEBUGPRINT(
"CONSOLE: %dx%d characters, %dx%d pixels, serial delay is %d usecs" NL, width, height, screen_width, screen_height, serial_delay);
315 cursor.text_color = 1;
320 cursor.phase_counter = 0;
321 cursor.cursor_color = 2;
323 SDL_StartTextInput();