bool is_terminator (zchar key) { if (key == ZC_TIME_OUT) return TRUE; if (key == ZC_RETURN) return TRUE; if (key >= ZC_HKEY_MIN && key <= ZC_HKEY_MAX) return TRUE; #if 0 if (h_terminating_keys != 0) if (key >= ZC_ARROW_MIN && key <= ZC_MENU_CLICK) { zword addr = h_terminating_keys; zbyte c; do { LOW_BYTE (addr, c) if (c == 255 || key == translate_from_zscii (c)) return TRUE; addr++; } while (c != 0); }
static zchar replay_char (void) { int c; if ((c = replay_code ()) != EOF) { if (c != '\n') { if (c < 1000) { c = translate_from_zscii (c); if (c == ZC_SINGLE_CLICK || c == ZC_DOUBLE_CLICK) { mouse_x = replay_code (); mouse_y = replay_code (); } return c; } else return ZC_HKEY_MIN + c - 1000; } ungetc ('\n', pfp); return ZC_RETURN; } else return ZC_BAD; }/* replay_char */
zchar Processor::replay_char() { int c; if ((c = replay_code()) != EOF) { if (c != '\n') { if (c < 1000) { c = translate_from_zscii(c); if (c == ZC_SINGLE_CLICK || c == ZC_DOUBLE_CLICK) { mouse_x = replay_code(); mouse_y = replay_code(); } return c; } else { return ZC_HKEY_MIN + c - 1000; } } pfp->unputBuffer("\n", 1); return ZC_RETURN; } else { return ZC_BAD; } }
bool Processor::is_terminator(zchar key) { if (key == ZC_TIME_OUT) return true; if (key == ZC_RETURN) return true; if (key >= ZC_HKEY_MIN && key <= ZC_HKEY_MAX) return true; if (h_terminating_keys != 0) { if (key >= ZC_ARROW_MIN && key <= ZC_MENU_CLICK) { zword addr = h_terminating_keys; zbyte c; do { LOW_BYTE(addr, c); if (c == 255 || key == translate_from_zscii(c)) return true; addr++; } while (c != 0); } } return false; }
void Processor::load_string (zword addr, zword length) { int i = 0; if (_resolution == 0) find_resolution(); while (i < 3 * _resolution) { if (i < length) { zbyte c; LOW_BYTE(addr, c); addr++; _decoded[i++] = translate_from_zscii(c); } else { _decoded[i++] = 0; } } }
void Processor::z_read() { zchar buffer[INPUT_BUFFER_SIZE]; zword addr; zchar key; zbyte max, size; zbyte c; int i; // Supply default arguments if (zargc < 3) zargs[2] = 0; // Get maximum input size addr = zargs[0]; LOW_BYTE(addr, max); if (h_version <= V4) max--; if (max >= INPUT_BUFFER_SIZE) max = INPUT_BUFFER_SIZE - 1; // Get initial input size if (h_version >= V5) { addr++; LOW_BYTE(addr, size); } else { size = 0; } // Copy initial input to local buffer for (i = 0; i < size; i++) { addr++; LOW_BYTE(addr, c); buffer[i] = translate_from_zscii(c); } buffer[i] = 0; // Draw status line for V1 to V3 games if (h_version <= V3) z_show_status(); // Read input from current input stream key = stream_read_input( max, buffer, // buffer and size zargs[2], // timeout value zargs[3], // timeout routine false, // enable hot keys h_version == V6 // no script in V6 ); if (key == ZC_BAD) return; // Perform save_undo for V1 to V4 games if (h_version <= V4) save_undo(); // Copy local buffer back to dynamic memory for (i = 0; buffer[i] != 0; i++) { if (key == ZC_RETURN) { buffer[i] = unicode_tolower (buffer[i]); } storeb((zword)(zargs[0] + ((h_version <= V4) ? 1 : 2) + i), translate_to_zscii(buffer[i])); } // Add null character (V1-V4) or write input length into 2nd byte if (h_version <= V4) storeb((zword)(zargs[0] + 1 + i), 0); else storeb((zword)(zargs[0] + 1), i); // Tokenise line if a token buffer is present if (key == ZC_RETURN && zargs[1] != 0) tokenise_line (zargs[0], zargs[1], 0, false); // Store key if (h_version >= V5) store(translate_to_zscii(key)); }