35 static int console_width, console_height;
37 static Uint8 *color_ram;
39 #define CHARACTER_SET_DEFINER_8X16 static const Uint8 chargen[]
41 #undef CHARACTER_SET_DEFINER_8X16
42 static const Uint8 console_colors[3*16] = {
60 static int serial_delay;
61 static Uint8 kbd_queue[16];
62 static int kbd_queue_len;
63 static int kbd_waiting = 0;
64 static int input_waiting;
68 static void conraw_clear (
void )
70 memset(
video_ram, 0x20, console_width * console_height);
71 memset(color_ram, cursor.text_color, console_width * console_height);
76 static void conraw_scroll (
void )
79 memmove(color_ram, color_ram + console_width, console_width * (console_height - 1));
80 memset(
video_ram + console_width * (console_height - 1), 0x20, console_width);
81 memset(color_ram + console_width * (console_height - 1), cursor.text_color, console_width);
84 static void conraw_down (
void )
86 if (cursor.y == console_height - 1)
95 color_ram[cursor.y * console_width + cursor.x] = cursor.text_color;
96 if (cursor.x == console_width - 1) {
113 }
else if (
data == 10) {
115 }
else if (
data == 8) {
118 }
else if (
data < 32) {
120 conraw_putch(
'A' +
data);
126 cursor.phase_counter = 0;
140 return kbd_queue_len ? 0xFF : 0;
149 int ret = kbd_queue[0];
151 memmove(kbd_queue, kbd_queue + 1, kbd_queue_len);
163 if (cursor.blinking) {
164 if (cursor.phase_counter >= delay) {
165 cursor.phase = !cursor.phase;
166 cursor.phase_counter = 0;
168 cursor.phase_counter++;
177 int cursor_line = (cursor.phase && cursor.visible) ? cursor.y : -1;
180 for (
int y = 0;
y < console_height;
y++) {
182 for (
int x = 0;
x < console_width;
x++) {
190 if (row > 12 || kbd_waiting) {
192 fg =
palette[cursor.cursor_color];
195 for (
int bpos = 0; bpos < 8; bpos++, chln <<= 1)
196 *pixel++ = (chln & 0x80) ? fg : bg;
222 static void queue_key (
Uint8 k )
226 if (kbd_queue_len <
sizeof kbd_queue)
227 kbd_queue[kbd_queue_len++] = k;
238 if (ev->state == SDL_PRESSED) {
239 int k = ev->keysym.sym;
240 DEBUGPRINT(
"KEY: %d [%c]\n", k, (k >= 0x20 && k < 127) ? k :
'?');
243 if (k < 32 || k == 127) {
250 void emu_callback_key_texteditng_sdl ( SDL_TextEditingEvent *ev )
261 if (*p >= 0x20 && *p < 127)
268 int console_init (
int width,
int height,
int zoom_percent,
int *map_to_ram,
int baud_emu )
270 int screen_width = width * 9;
272 int window_width = screen_width * zoom_percent / 100;
273 int window_height = screen_height * zoom_percent / 100;
281 screen_width, screen_height,
282 screen_width, screen_height,
283 window_width, window_height,
299 color_ram =
memory + 0x10000 - width * height;
308 serial_delay = (11 * 1000000) / baud_emu;
312 console_width = width;
313 console_height = height;
314 DEBUGPRINT(
"CONSOLE: %dx%d characters, %dx%d pixels, serial delay is %d usecs" NL, width, height, screen_width, screen_height, serial_delay);
316 cursor.text_color = 1;
321 cursor.phase_counter = 0;
322 cursor.cursor_color = 2;
323 SDL_StartTextInput();