#include <string.h>
#include "frotz.h"
-extern void stream_char (zword);
-extern void stream_word (const zword *);
+extern void stream_char (zchar);
+extern void stream_word (const zchar *);
extern void stream_new_line (void);
-static zword buffer[TEXT_BUFFER_SIZE];
+static zchar buffer[TEXT_BUFFER_SIZE];
static int bufpos = 0;
-static zword prev_c = 0;
+static zchar prev_c = 0;
/*
* flush_buffer
* High level output function.
*
*/
-
-void print_char (zword c)
+void print_char (zchar c)
{
static bool flag = FALSE;
need_newline_at_exit = TRUE;
*/
void init_buffer(void)
{
- memset(buffer, 0, sizeof (zword) * TEXT_BUFFER_SIZE);
+ memset(buffer, 0, sizeof (zchar) * TEXT_BUFFER_SIZE);
bufpos = 0;
prev_c = 0;
}
extern void set_more_prompts (bool);
-extern bool is_terminator (zword);
+extern bool is_terminator (zchar);
extern bool read_yes_or_no (const char *);
*
*/
-void script_char (zword c)
+void script_char (zchar c)
{
if (c == ZC_INDENT && script_width != 0)
*
*/
-void script_word (const zword *s)
+void script_word (const zchar *s)
{
int width;
int i;
*
*/
-void script_write_input (const zword *buf, zword key)
+void script_write_input (const zchar *buf, zchar key)
{
int width;
int i;
*
*/
-void script_erase_input (const zword *buf)
+void script_erase_input (const zchar *buf)
{
int width;
int i;
*
*/
-static void record_char (zword c)
+static void record_char (zchar c)
{
if (c != ZC_RETURN) {
*
*/
-void record_write_key (zword key)
+void record_write_key (zchar key)
{
record_char (key);
*
*/
-void record_write_input (const zword *buf, zword key)
+void record_write_input (const zchar *buf, zchar key)
{
- zword c;
+ zchar c;
while ((c = *buf++) != 0)
record_char (c);
*
*/
-static zword replay_char (void)
+static zchar replay_char (void)
{
int c;
*
*/
-zword replay_read_key (void)
+zchar replay_read_key (void)
{
- zword key;
+ zchar key;
key = replay_char ();
*
*/
-zword replay_read_input (zword *buf)
+zchar replay_read_input (zchar *buf)
{
- zword c;
+ zchar c;
for (;;) {
* Unix side, please let me know and please test it to make sure it
* doesn't mess with command history.
*/
-/*
+
#ifdef MSDOS_16BIT
typedef unsigned char zchar;
#else
typedef unsigned short zchar;
#endif
-*/
-
-typedef unsigned char zchar;
enum story {
ZORK1,
/*** Various global functions ***/
-zword translate_from_zscii (zbyte);
-zbyte translate_to_zscii (zword);
+zchar translate_from_zscii (zbyte);
+zbyte translate_to_zscii (zchar);
void flush_buffer (void);
void new_line (void);
-void print_char (zword);
+void print_char (zchar);
void print_num (zword);
void print_object (zword);
void print_string (const char *);
void end_of_sound (void);
-int completion (const zword *buffer, zword *result);
+int completion (const zchar *buffer, zchar *result);
-bool is_terminator (zword);
-void read_string (int max, zword *buffer);
+bool is_terminator (zchar);
+void read_string (int max, zchar *buffer);
bool read_yes_or_no (const char *);
void screen_new_line (void);
/*** Interface functions ***/
void os_beep (int);
-int os_char_width (zword);
-void os_display_char (zword);
-void os_display_string (const zword *);
+int os_char_width (zchar);
+void os_display_char (zchar);
+void os_display_string (const zchar *);
void os_draw_picture (int, int, int);
void os_erase_area (int, int, int, int, int);
void os_fatal (const char *, ...);
void os_process_arguments (int, char *[]);
int os_random_seed (void);
char *os_read_file_name (const char *, int);
-zword os_read_key (int, int);
-zword os_read_line (int, zword *, int, int, int);
+zchar os_read_key (int, int);
+zchar os_read_line (int, zchar *, int, int, int);
void os_reset_screen (void);
void os_restart_game (int);
void os_scroll_area (int, int, int, int, int);
void os_stop_sample ();
int os_storyfile_seek (FILE *, long, int);
int os_storyfile_tell (FILE *);
-int os_string_width (const zword *);
+int os_string_width (const zchar *);
void os_init_setup (void);
void os_warn (const char *, ...);
void os_quit (void);
extern int save_undo (void);
-extern zword stream_read_key (zword, zword, bool);
-extern zword stream_read_input (int, zword *, zword, zword, bool, bool);
+extern zchar stream_read_key (zword, zword, bool);
+extern zchar stream_read_input (int, zchar *, zword, zword, bool, bool);
extern void tokenise_line (zword, zword, zword, bool);
zword unicode_tolower (zword);
*
*/
-bool is_terminator (zword key)
+bool is_terminator (zchar key)
{
if (key == ZC_TIME_OUT)
bool read_yes_or_no (const char *s)
{
- zword key;
+ zchar key;
print_string (s);
print_string ("? (y/n) >");
*
*/
-void read_string (int max, zword *buffer)
+void read_string (int max, zchar *buffer)
{
- zword key;
+ zchar key;
buffer[0] = 0;
int read_number (void)
{
- zword buffer[6];
+ zchar buffer[6];
int value = 0;
int i;
void z_read (void)
{
- zword buffer[INPUT_BUFFER_SIZE];
+ zchar buffer[INPUT_BUFFER_SIZE];
zword addr;
- zword key;
+ zchar key;
zbyte max, size;
zbyte c;
int i;
void z_read_char (void)
{
- zword key;
+ zchar key;
/* Supply default arguments */
* Redirect a string of characters to the memory of the Z-machine.
*
*/
-
-void memory_word (const zword *s)
+void memory_word (const zchar *s)
{
zword size;
zword addr;
- zword c;
+ zchar c;
if (h_version == V6) {
*
*/
-void screen_char (zword c)
+void screen_char (zchar c)
{
int width;
* enable_wrapping flag.
*
*/
-
-void screen_word (const zword *s)
+void screen_word (const zchar *s)
{
int width;
if (!enable_wrapping) {
- zword c;
+ zchar c;
while ((c = *s++) != 0)
* Display an input line on the screen. This is required during playback.
*
*/
-
-void screen_write_input (const zword *buf, zword key)
+void screen_write_input (const zchar *buf, zchar key)
{
int width;
* playback.
*
*/
-
-void screen_erase_input (const zword *buf)
+void screen_erase_input (const zchar *buf)
{
if (buf[0] != 0) {
* Read an input line from the keyboard and return the terminating key.
*
*/
-
-zword console_read_input (int max, zword *buf, zword timeout, bool continued)
+zchar console_read_input (int max, zchar *buf, zword timeout, bool continued)
{
- zword key;
+ zchar key;
int i;
/* Make sure there is some space for input */
* Read a single keystroke and return it.
*
*/
-
-zword console_read_key (zword timeout)
+zchar console_read_key (zword timeout)
{
- zword key;
+ zchar key;
int i;
key = os_read_key (timeout, cursor);
extern zword object_name (zword);
-static zword decoded[10];
+static zchar decoded[10];
static zword encoded[3];
/*
* Map a ZSCII character into Unicode.
*
*/
-
-zword translate_from_zscii (zbyte c)
+zchar translate_from_zscii (zbyte c)
{
if (c == 0xfc)
} else return '?';
}
- return (zword) c;
+ return c;
}/* translate_from_zscii */
* Convert a Unicode character to ZSCII, returning 0 on failure.
*
*/
-
-zbyte unicode_to_zscii (zword c)
+zbyte unicode_to_zscii (zchar c)
{
int i;
*
*/
-zbyte translate_to_zscii (zword c)
+zbyte translate_to_zscii (zchar c)
{
if (c == ZC_SINGLE_CLICK)
* Return a character from one of the three character sets.
*
*/
-
-static zword alphabet (int set, int index)
+static zchar alphabet (int set, int index)
{
if (h_alphabet != 0) { /* game uses its own alphabet */
*/
static void encode_text (int padding)
{
- static zword again[] = { 'a', 'g', 'a', 'i', 'n', 0, 0, 0, 0 };
- static zword examine[] = { 'e', 'x', 'a', 'm', 'i', 'n', 'e', 0, 0 };
- static zword wait[] = { 'w', 'a', 'i', 't', 0, 0, 0, 0, 0 };
+ static zchar again[] = { 'a', 'g', 'a', 'i', 'n', 0 };
+ static zchar examine[] = { 'e', 'x', 'a', 'm', 'i', 'n', 'e', 0 };
+ static zchar wait[] = { 'w', 'a', 'i', 't', 0 };
zbyte zchars[12];
- const zword *ptr = decoded;
- zword c;
+ const zchar *ptr = decoded;
+ zchar c;
int resolution = (h_version <= V3) ? 2 : 3;
int i = 0;
store (3);
else if (c == 0xa0)
store (1);
- else if (c >= 0xa1)
- /* being optimistic, we can print and input
- * all unicode characters
+ else if (c >= 0xa1)
+ /* being optimistic, we can print and input
+ * all unicode characters
*/
store (3);
else
#define outchar(c) if (st==VOCABULARY) *ptr++=c; else print_char(c)
static void decode_text (enum string_type st, zword addr)
{
- zword *ptr;
+ zchar *ptr;
long byte_addr;
- zword c2;
+ zchar c2;
zword code;
zbyte c, prev_c = 0;
int shift_state = 0;
* to the last word that results in the only possible completion.
*
*/
-
-int completion (const zword *buffer, zword *result)
+int completion (const zchar *buffer, zchar *result)
{
zword minaddr;
zword maxaddr;
- zword *ptr;
- zword c;
+ zchar *ptr;
+ zchar c;
int len;
int i;
#include "ux_frotz.h"
-static int start_of_prev_word(int, const zword*);
-static int end_of_next_word(int, const zword*, int);
+static int start_of_prev_word(int, const zchar*);
+static int end_of_next_word(int, const zchar*, int);
static struct timeval global_timeout;
static zword **history_view = history_buffer; /* What the user is looking at. */
#define history_end (history_buffer + MAX_HISTORY - 1)
-extern bool is_terminator (zword);
-extern void read_string (int, zword *);
-extern int completion (const zword *, zword *);
+extern bool is_terminator (zchar);
+extern void read_string (int, zchar *);
+extern int completion (const zchar *, zchar *);
#ifndef wint_t
typedef unsigned int wint_t;
* Add the given string to the next available history buffer slot.
*
*/
-static void unix_add_to_history(zword *str)
+static void unix_add_to_history(zchar *str)
{
if (*history_next != NULL)
free( *history_next);
- *history_next = (zword *)malloc(zwordstrlen(str) + 1);
+ *history_next = (zchar *)malloc(zwordstrlen(str) + 1);
zwordstrncpy( *history_next, str, zwordstrlen(str) + 1);
RING_INC( history_next, history_buffer, history_end);
history_view = history_next; /* Reset user frame after each line */
* Only lines of at most maxlen characters will be considered. In addition
* the first searchlen characters of the history entry must match those of str.
*/
-static int unix_history_back(zword *str, int searchlen, int maxlen)
+static int unix_history_back(zchar *str, int searchlen, int maxlen)
{
- zword **prev = history_view;
+ zchar **prev = history_view;
do {
RING_DEC( history_view, history_buffer, history_end);
*
* Opposite of unix_history_back, and works in the same way.
*/
-static int unix_history_forward(zword *str, int searchlen, int maxlen)
+static int unix_history_forward(zchar *str, int searchlen, int maxlen)
{
zword **prev = history_view;
}
#ifdef USE_UTF8
-static void utf8_mvaddstr(int y, int x, zword * buf)
+static void utf8_mvaddstr(int y, int x, zchar * buf)
{
- zword *bp = buf;
+ zchar *bp = buf;
move(y,x);
while(*bp) {
* to implement word completion (similar to tcsh under Unix).
*
*/
-zword os_read_line (int bufmax, zword *buf, int timeout, int width,
+zchar os_read_line (int bufmax, zchar *buf, int timeout, int width,
int continued)
{
int ch, y, x, len = strlen( (char *)buf);
#warning "Bill -- fix this for wide characters"
{
int status;
- zword extension[10], saved_char;
+ zchar extension[10], saved_char;
saved_char = buf[scrpos];
buf[scrpos] = '\0';
* return it. Input aborts after timeout/10 seconds.
*
*/
-zword os_read_key (int timeout, int cursor)
+zchar os_read_key (int timeout, int cursor)
{
- zword c;
+ zchar c;
refresh();
if (!cursor) curs_set(0);
unix_set_global_timeout(timeout);
- c = unix_read_char(0);
+ c = (zchar) unix_read_char(0);
if (!cursor) curs_set(1);
return c;
char *tempname;
zchar answer[4];
char path_separator[2];
- zword file_name[FILENAME_MAX + 1];
+ zchar file_name[FILENAME_MAX + 1];
path_separator[0] = PATH_SEPARATOR;
path_separator[1] = 0;
* param buf input buffer
* returns new position
*/
-static int start_of_prev_word(int currpos, const zword* buf) {
+static int start_of_prev_word(int currpos, const zchar* buf) {
int i, j;
for (i = currpos - 1; i > 0 && buf[i] == ' '; i--) {}
j = i;
* param len length of buf
* returns new position
*/
-static int end_of_next_word(int currpos, const zword* buf, int len) {
+static int end_of_next_word(int currpos, const zchar* buf, int len) {
int i;
for (i = currpos; i < len && buf[i] == ' '; i++) {}
for (; i < len && buf[i] != ' '; i++) {}
* bottom right corner.
*
*/
-void os_display_char (zword c)
+void os_display_char (zchar c)
{
if (c >= ZC_LATIN1_MIN) {
if (u_setup.plain_ascii) {
* Pass a string of characters to os_display_char.
*
*/
-void os_display_string (const zword *s)
+void os_display_string (const zchar *s)
{
- zword c;
+ zchar c;
while ((c = *s++) != 0) {
* Return the width of the character in screen units.
*
*/
-int os_char_width (zword c)
+int os_char_width (zchar c)
{
if (c >= ZC_LATIN1_MIN && u_setup.plain_ascii) {
* NEW_FONT - next character is a new font
*
*/
-int os_string_width (const zword *s)
+int os_string_width (const zchar *s)
{
int width = 0;
- zword c;
+ zchar c;
while ((c = *s++) != 0) {