extern void write_log (const char *, ...);
#endif
extern void write_dlog (const TCHAR *, ...);
+extern int read_log(void);
extern void flush_log (void);
extern TCHAR *setconsolemode (TCHAR *buffer, int maxlen);
static int serial_period_hsyncs, serial_period_hsync_counter;
static int ninebit;
static int lastbitcycle_active_hsyncs;
+static bool gotlogwrite;
static unsigned int lastbitcycle;
int serdev;
int seriallog = 0, log_sercon = 0;
serial_check_irq();
checksend();
- if (seriallog)
+ if (seriallog) {
+ gotlogwrite = true;
write_log(_T("%c"), dochar(serdatshift));
+ }
if (serper == 372) {
if (enforcermode & 2) {
extern void hsyncstuff(void);
hsyncstuff();
#endif
+ if (seriallog && !data_in_serdatr && gotlogwrite) {
+ int ch = read_log();
+ if (ch > 0) {
+ serdatr = ch | 0x100;
+ data_in_serdatr = 1;
+ serial_check_irq ();
+ }
+ }
+
if (lastbitcycle_active_hsyncs > 0)
lastbitcycle_active_hsyncs--;
if (sermap2 && sermap_enabled && !data_in_serdatr) {
static int debugger_type = -1;
extern BOOL debuggerinitializing;
extern int lof_store;
+static int console_input_linemode = -1;
int always_flush_log = 1;
#define WRITE_LOG_BUF_SIZE 4096
return GetConsoleWindow ();
}
+static void set_console_input_mode(int line)
+{
+ if (console_input_linemode < 0)
+ return;
+ if (line == console_input_linemode)
+ return;
+ SetConsoleMode (stdinput, ENABLE_PROCESSED_INPUT | ENABLE_PROCESSED_OUTPUT | (line ? (ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT) : 0));
+ console_input_linemode = line;
+}
+
static void getconsole (void)
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
stdinput = GetStdHandle (STD_INPUT_HANDLE);
stdoutput = GetStdHandle (STD_OUTPUT_HANDLE);
SetConsoleMode (stdinput, ENABLE_PROCESSED_INPUT|ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_PROCESSED_OUTPUT);
+ console_input_linemode = 1;
SetConsoleCP (65001);
SetConsoleOutputCP (65001);
if (GetConsoleScreenBufferInfo (stdoutput, &csbi)) {
consoleopen = 0;
}
+int read_log(void)
+{
+#if 0
+ return -1;
+#else
+ if (consoleopen >= 0)
+ return -1;
+ set_console_input_mode(0);
+ INPUT_RECORD irbuf;
+ DWORD numread;
+ for (;;) {
+ if (!PeekConsoleInput(stdinput, &irbuf, 1, &numread))
+ return -1;
+ if (!numread)
+ return -1;
+ if (!ReadConsoleInput(stdinput, &irbuf, 1, &numread))
+ return -1;
+ if (irbuf.EventType != KEY_EVENT)
+ continue;
+ if (!irbuf.Event.KeyEvent.bKeyDown)
+ continue;
+ int ch = irbuf.Event.KeyEvent.uChar.AsciiChar;
+ if (ch == 0)
+ continue;
+ return ch;
+ }
+#endif
+}
+
static void writeconsole_2 (const TCHAR *buffer)
{
DWORD temp;
{
*out = 0;
+ set_console_input_mode(1);
if (consoleopen > 0) {
return console_get_gui (out, maxlen);
} else if (realconsole) {