From 5a1f28c7b0728b010874eb1f89a166e07935a5ce Mon Sep 17 00:00:00 2001 From: David Griffith Date: Sat, 16 May 2015 03:41:59 -0700 Subject: [PATCH] Line spacing cleanup. Assorted curly-bracket disambiguation. --- src/common/buffer.c | 9 +-- src/common/err.c | 6 +- src/common/fastmem.c | 50 ++++++--------- src/common/hotkey.c | 20 +++--- src/common/main.c | 27 +------- src/common/math.c | 44 +++++-------- src/common/object.c | 39 ++++++------ src/common/process.c | 56 +++++++---------- src/common/quetzal.c | 4 +- src/common/random.c | 6 +- src/common/redirect.c | 10 ++- src/common/screen.c | 138 +++++++++++++++++------------------------ src/common/sound.c | 12 ++-- src/common/stream.c | 29 +++------ src/common/table.c | 14 ++--- src/common/text.c | 66 ++++++++------------ src/common/variable.c | 25 ++++---- src/curses/ux_blorb.c | 4 -- src/curses/ux_pic.c | 5 -- src/curses/ux_screen.c | 4 +- src/curses/ux_text.c | 53 +++++++--------- 21 files changed, 232 insertions(+), 389 deletions(-) diff --git a/src/common/buffer.c b/src/common/buffer.c index 261fd39..db8a1b7 100644 --- a/src/common/buffer.c +++ b/src/common/buffer.c @@ -36,7 +36,6 @@ static zchar prev_c = 0; * Copy the contents of the text buffer to the output streams. * */ - void flush_buffer (void) { static bool locked = FALSE; @@ -77,7 +76,6 @@ void flush_buffer (void) * High level output function. * */ - void print_char (zchar c) { static bool flag = FALSE; @@ -96,8 +94,6 @@ void print_char (zchar c) /* Flush the buffer before a whitespace or after a hyphen */ if (c == ' ' || c == ZC_INDENT || c == ZC_GAP || (prev_c == '-' && c != '-')) - - flush_buffer (); /* Set the flag if this is part one of a style or font change */ @@ -122,16 +118,15 @@ void print_char (zchar c) }/* print_char */ + /* * new_line * * High level newline function. * */ - void new_line (void) { - flush_buffer (); stream_new_line (); }/* new_line */ @@ -143,11 +138,9 @@ void new_line (void) * Initialize buffer variables. * */ - void init_buffer(void) { memset(buffer, 0, sizeof (zchar) * TEXT_BUFFER_SIZE); bufpos = 0; prev_c = 0; } - diff --git a/src/common/err.c b/src/common/err.c index ff1b679..74c1af6 100644 --- a/src/common/err.c +++ b/src/common/err.c @@ -73,7 +73,6 @@ static void print_long (unsigned long value, int base); * Initialise error reporting. * */ - void init_err (void) { int i; @@ -84,6 +83,7 @@ void init_err (void) error_count[i] = 0; } + /* * runtime_error * @@ -93,7 +93,6 @@ void init_err (void) * errnum : Numeric code for error (1 to ERR_NUM_ERRORS) * */ - void runtime_error (int errnum) { int wasfirst; @@ -131,16 +130,15 @@ void runtime_error (int errnum) } new_line (); } - } /* report_error */ + /* * print_long * * Print an unsigned 32bit number in decimal or hex. * */ - static void print_long (unsigned long value, int base) { unsigned long i; diff --git a/src/common/fastmem.c b/src/common/fastmem.c index 3000104..7a519bf 100644 --- a/src/common/fastmem.c +++ b/src/common/fastmem.c @@ -104,13 +104,13 @@ static zbyte *undo_mem = NULL, *prev_zmp, *undo_diff; static int undo_count = 0; + /* * get_header_extension * * Read a value from the header extension (former mouse table). * */ - zword get_header_extension (int entry) { zword addr; @@ -126,13 +126,13 @@ zword get_header_extension (int entry) }/* get_header_extension */ + /* * set_header_extension * * Set an entry in the header extension (former mouse table). * */ - void set_header_extension (int entry, zword val) { zword addr; @@ -145,13 +145,13 @@ void set_header_extension (int entry, zword val) }/* set_header_extension */ + /* * restart_header * * Set all header fields which hold information about the interpreter. * */ - void restart_header (void) { zword screen_x_size; @@ -204,13 +204,13 @@ void restart_header (void) }/* restart_header */ + /* * init_memory * * Allocate memory and load the story file. * */ - void init_memory (void) { long size; @@ -252,10 +252,6 @@ void init_memory (void) /* Open story file */ -/* - if ((story_fp = os_path_open(f_setup.story_file, "rb")) == NULL) - os_fatal ("Cannot open story file"); -*/ if ((story_fp = os_load_story()) == NULL) os_fatal ("Cannot open story file"); @@ -385,6 +381,7 @@ void init_memory (void) }/* init_memory */ + /* * init_undo * @@ -393,7 +390,6 @@ void init_memory (void) * during the game, e.g. for loading sounds or pictures. * */ - void init_undo (void) { void far *reserved; @@ -420,13 +416,13 @@ void init_undo (void) }/* init_undo */ + /* * free_undo * * Free count undo blocks from the beginning of the undo list. * */ - static void free_undo (int count) { undo_t *p; @@ -447,13 +443,13 @@ static void free_undo (int count) last_undo = NULL; }/* free_undo */ + /* * reset_memory * * Close the story file and deallocate memory. * */ - void reset_memory (void) { if (story_fp) @@ -473,16 +469,15 @@ void reset_memory (void) zmp = NULL; }/* reset_memory */ + /* * storeb * * Write a byte value to the dynamic Z-machine memory. * */ - void storeb (zword addr, zbyte value) { - if (addr >= h_dynamic_size) runtime_error (ERR_STORE_RANGE); @@ -507,28 +502,27 @@ void storeb (zword addr, zbyte value) }/* storeb */ + /* * storew * * Write a word value to the dynamic Z-machine memory. * */ - void storew (zword addr, zword value) { - storeb ((zword) (addr + 0), hi (value)); storeb ((zword) (addr + 1), lo (value)); }/* storew */ + /* * z_restart, re-load dynamic area, clear the stack and set the PC. * * no zargs used * */ - void z_restart (void) { static bool first_restart = TRUE; @@ -565,6 +559,7 @@ void z_restart (void) }/* z_restart */ + /* * get_default_name * @@ -572,10 +567,8 @@ void z_restart (void) * copy it to a string. * */ - static void get_default_name (char *default_name, zword addr) { - if (addr != 0) { zbyte len; @@ -607,6 +600,7 @@ static void get_default_name (char *default_name, zword addr) }/* get_default_name */ + /* * z_restore, restore [a part of] a Z-machine state from disk * @@ -615,7 +609,6 @@ static void get_default_name (char *default_name, zword addr) * zargs[2] = address of suggested file name * */ - void z_restore (void) { char new_name[MAX_FILE_NAME + 1]; @@ -712,6 +705,7 @@ finished: }/* z_restore */ + /* * mem_diff * @@ -722,7 +716,6 @@ finished: * Returns the number of bytes copied to diff. * */ - static long mem_diff (zbyte *a, zbyte *b, zword mem_size, zbyte *diff) { unsigned size = mem_size; @@ -757,13 +750,13 @@ static long mem_diff (zbyte *a, zbyte *b, zword mem_size, zbyte *diff) return p - diff; }/* mem_diff */ + /* * mem_undiff * * Applies a quetzal-like diff to dest * */ - static void mem_undiff (zbyte *diff, long diff_length, zbyte *dest) { zbyte c; @@ -793,13 +786,13 @@ static void mem_undiff (zbyte *diff, long diff_length, zbyte *dest) } }/* mem_undiff */ + /* * restore_undo * * This function does the dirty work for z_restore_undo. * */ - int restore_undo (void) { long pc = curr_undo->pc; @@ -831,20 +824,20 @@ int restore_undo (void) }/* restore_undo */ + /* * z_restore_undo, restore a Z-machine state from memory. * * no zargs used * */ - void z_restore_undo (void) { - store ((zword) restore_undo ()); }/* z_restore_undo */ + /* * z_save, save [a part of] the Z-machine state to disk. * @@ -853,7 +846,6 @@ void z_restore_undo (void) * zargs[2] = address of suggested file name * */ - void z_save (void) { char new_name[MAX_FILE_NAME + 1]; @@ -918,7 +910,6 @@ void z_save (void) /* Success */ success = 1; - } finished: @@ -930,13 +921,13 @@ finished: }/* z_save */ + /* * save_undo * * This function does the dirty work for z_save_undo. * */ - int save_undo (void) { long diff_size; @@ -996,27 +987,26 @@ int save_undo (void) }/* save_undo */ + /* * z_save_undo, save the current Z-machine state for a future undo. * * no zargs used * */ - void z_save_undo (void) { - store ((zword) save_undo ()); }/* z_save_undo */ + /* * z_verify, check the story file integrity. * * no zargs used * */ - void z_verify (void) { zword checksum = 0; diff --git a/src/common/hotkey.c b/src/common/hotkey.c index 25237cb..ac8f568 100644 --- a/src/common/hotkey.c +++ b/src/common/hotkey.c @@ -39,7 +39,6 @@ extern void seed_random (int); * ...allows user to toggle cheating options on/off. * */ - static bool hot_key_debugging (void) { @@ -55,13 +54,13 @@ static bool hot_key_debugging (void) }/* hot_key_debugging */ + /* * hot_key_help * * ...displays a list of all hot keys. * */ - static bool hot_key_help (void) { print_string ("Help\n"); @@ -81,16 +80,15 @@ static bool hot_key_help (void) { }/* hot_key_help */ + /* * hot_key_playback * * ...allows user to turn playback on. * */ - static bool hot_key_playback (void) { - print_string ("Playback on\n"); if (!istream_replay) @@ -100,13 +98,13 @@ static bool hot_key_playback (void) }/* hot_key_playback */ + /* * hot_key_recording * * ...allows user to turn recording on/off. * */ - static bool hot_key_recording (void) { @@ -125,13 +123,13 @@ static bool hot_key_recording (void) }/* hot_key_recording */ + /* * hot_key_seed * * ...allows user to seed the random number seed. * */ - static bool hot_key_seed (void) { @@ -144,13 +142,13 @@ static bool hot_key_seed (void) }/* hot_key_seed */ + /* * hot_key_undo * * ...allows user to undo the previous turn. * */ - static bool hot_key_undo (void) { @@ -174,16 +172,15 @@ static bool hot_key_undo (void) }/* hot_key_undo */ + /* * hot_key_restart * * ...allows user to start a new game. * */ - static bool hot_key_restart (void) { - print_string ("New game\n"); if (read_yes_or_no ("Do you wish to restart")) { @@ -195,13 +192,13 @@ static bool hot_key_restart (void) }/* hot_key_restart */ + /* * hot_key_quit * * ...allows user to exit the game. * */ - static bool hot_key_quit (void) { @@ -216,6 +213,7 @@ static bool hot_key_quit (void) }/* hot_key_quit */ + /* * handle_hot_key * @@ -223,10 +221,8 @@ static bool hot_key_quit (void) * true to abort the current input action. * */ - bool handle_hot_key (zchar key) { - if (cwin == 0) { bool aborting; diff --git a/src/common/main.c b/src/common/main.c index 8170f70..6367cce 100644 --- a/src/common/main.c +++ b/src/common/main.c @@ -20,9 +20,7 @@ /* * This is an interpreter for Infocom V1 to V6 games. It also supports - * the recently defined V7 and V8 games. Please report bugs to - * - * s.jokisch@avu.de + * the recently defined V7 and V8 games. * */ @@ -117,23 +115,6 @@ bool enable_scripting = FALSE; bool enable_scrolling = FALSE; bool enable_buffering = FALSE; -/* User options */ - -/* -int option_attribute_assignment = 0; -int option_attribute_testing = 0; -int option_context_lines = 0; -int option_object_locating = 0; -int option_object_movement = 0; -int option_left_margin = 0; -int option_right_margin = 0; -int option_ignore_errors = 0; -int option_piracy = 0; -int option_undo_slots = MAX_UNDO_SLOTS; -int option_expand_abbreviations = 0; -int option_script_cols = 80; -*/ - int option_sound = 1; char *option_zcode_path; @@ -142,30 +123,28 @@ char *option_zcode_path; long reserve_mem = 0; + /* * z_piracy, branch if the story file is a legal copy. * * no zargs used * */ - void z_piracy (void) { - branch (!f_setup.piracy); }/* z_piracy */ + /* * main * * Prepare and run the game. * */ - int cdecl main (int argc, char *argv[]) { - os_init_setup (); os_process_arguments (argc, argv); diff --git a/src/common/math.c b/src/common/math.c index 83f0818..fdc7cad 100644 --- a/src/common/math.c +++ b/src/common/math.c @@ -27,14 +27,13 @@ * zargs[1] = second value * */ - void z_add (void) { - store ((zword) ((short) zargs[0] + (short) zargs[1])); }/* z_add */ + /* * z_and, bitwise AND operation. * @@ -42,14 +41,13 @@ void z_add (void) * zargs[1] = second value * */ - void z_and (void) { - store ((zword) (zargs[0] & zargs[1])); }/* z_and */ + /* * z_art_shift, arithmetic SHIFT operation. * @@ -57,10 +55,8 @@ void z_and (void) * zargs[1] = #positions to shift left (positive) or right * */ - void z_art_shift (void) { - if ((short) zargs[1] > 0) store ((zword) ((short) zargs[0] << (short) zargs[1])); else @@ -68,6 +64,7 @@ void z_art_shift (void) }/* z_art_shift */ + /* * z_div, signed 16bit division. * @@ -75,10 +72,8 @@ void z_art_shift (void) * zargs[1] = second value * */ - void z_div (void) { - if (zargs[1] == 0) runtime_error (ERR_DIV_ZERO); @@ -86,6 +81,7 @@ void z_div (void) }/* z_div */ + /* * z_je, branch if the first value equals any of the following. * @@ -95,10 +91,8 @@ void z_div (void) * zargs[3] = fourth value (optional) * */ - void z_je (void) { - branch ( zargc > 1 && (zargs[0] == zargs[1] || ( zargc > 2 && (zargs[0] == zargs[2] || ( @@ -106,6 +100,7 @@ void z_je (void) }/* z_je */ + /* * z_jg, branch if the first value is greater than the second. * @@ -113,14 +108,13 @@ void z_je (void) * zargs[1] = second value * */ - void z_jg (void) { - branch ((short) zargs[0] > (short) zargs[1]); }/* z_jg */ + /* * z_jl, branch if the first value is less than the second. * @@ -128,28 +122,26 @@ void z_jg (void) * zargs[1] = second value * */ - void z_jl (void) { - branch ((short) zargs[0] < (short) zargs[1]); }/* z_jl */ + /* * z_jz, branch if value is zero. * * zargs[0] = value * */ - void z_jz (void) { - branch ((short) zargs[0] == 0); }/* z_jz */ + /* * z_log_shift, logical SHIFT operation. * @@ -157,10 +149,8 @@ void z_jz (void) * zargs[1] = #positions to shift left (positive) or right (negative) * */ - void z_log_shift (void) { - if ((short) zargs[1] > 0) store ((zword) (zargs[0] << (short) zargs[1])); else @@ -168,6 +158,7 @@ void z_log_shift (void) }/* z_log_shift */ + /* * z_mod, remainder after signed 16bit division. * @@ -175,10 +166,8 @@ void z_log_shift (void) * zargs[1] = second value * */ - void z_mod (void) { - if (zargs[1] == 0) runtime_error (ERR_DIV_ZERO); @@ -186,6 +175,7 @@ void z_mod (void) }/* z_mod */ + /* * z_mul, 16bit multiplication. * @@ -193,28 +183,26 @@ void z_mod (void) * zargs[1] = second value * */ - void z_mul (void) { - store ((zword) ((short) zargs[0] * (short) zargs[1])); }/* z_mul */ + /* * z_not, bitwise NOT operation. * * zargs[0] = value * */ - void z_not (void) { - store ((zword) ~zargs[0]); }/* z_not */ + /* * z_or, bitwise OR operation. * @@ -222,14 +210,13 @@ void z_not (void) * zargs[1] = second value * */ - void z_or (void) { - store ((zword) (zargs[0] | zargs[1])); }/* z_or */ + /* * z_sub, 16bit substraction. * @@ -237,14 +224,13 @@ void z_or (void) * zargs[1] = second value * */ - void z_sub (void) { - store ((zword) ((short) zargs[0] - (short) zargs[1])); }/* z_sub */ + /* * z_test, branch if all the flags of a bit mask are set in a value. * @@ -252,10 +238,8 @@ void z_sub (void) * zargs[1] = bit mask * */ - void z_test (void) { - branch ((zargs[0] & zargs[1]) == zargs[1]); }/* z_test */ diff --git a/src/common/object.c b/src/common/object.c index ca40f5e..296f654 100644 --- a/src/common/object.c +++ b/src/common/object.c @@ -34,13 +34,13 @@ #define O4_PROPERTY_OFFSET 12 #define O4_SIZE 14 + /* * object_address * * Calculate the address of an object. * */ - static zword object_address (zword obj) { /* zchar obj_num[10]; */ @@ -64,13 +64,13 @@ static zword object_address (zword obj) }/* object_address */ + /* * object_name * * Return the address of the given object's name. * */ - zword object_name (zword object) { zword obj_addr; @@ -91,6 +91,7 @@ zword object_name (zword object) }/* object_name */ + /* * first_property * @@ -98,7 +99,6 @@ zword object_name (zword object) * an object. * */ - static zword first_property (zword obj) { zword prop_addr; @@ -118,13 +118,13 @@ static zword first_property (zword obj) }/* first_property */ + /* * next_property * * Calculate the address of the next property in a property list. * */ - static zword next_property (zword prop_addr) { zbyte value; @@ -155,13 +155,13 @@ static zword next_property (zword prop_addr) }/* next_property */ + /* * unlink_object * * Unlink an object from its parent and siblings. * */ - static void unlink_object (zword object) { zword obj_addr; @@ -257,6 +257,7 @@ static void unlink_object (zword object) }/* unlink_object */ + /* * z_clear_attr, clear an object attribute. * @@ -264,7 +265,6 @@ static void unlink_object (zword object) * zargs[1] = number of attribute to be cleared * */ - void z_clear_attr (void) { zword obj_addr; @@ -305,6 +305,7 @@ void z_clear_attr (void) }/* z_clear_attr */ + /* * z_jin, branch if the first object is inside the second. * @@ -312,7 +313,6 @@ void z_clear_attr (void) * zargs[1] = second object * */ - void z_jin (void) { zword obj_addr; @@ -366,13 +366,13 @@ void z_jin (void) }/* z_jin */ + /* * z_get_child, store the child of an object. * * zargs[0] = object * */ - void z_get_child (void) { zword obj_addr; @@ -427,6 +427,7 @@ void z_get_child (void) }/* z_get_child */ + /* * z_get_next_prop, store the number of the first or next property. * @@ -434,7 +435,6 @@ void z_get_child (void) * zargs[1] = address of current property (0 gets the first property) * */ - void z_get_next_prop (void) { zword prop_addr; @@ -478,13 +478,13 @@ void z_get_next_prop (void) }/* z_get_next_prop */ + /* * z_get_parent, store the parent of an object. * * zargs[0] = object * */ - void z_get_parent (void) { zword obj_addr; @@ -536,6 +536,7 @@ void z_get_parent (void) }/* z_get_parent */ + /* * z_get_prop, store the value of an object property. * @@ -543,7 +544,6 @@ void z_get_parent (void) * zargs[1] = number of property to be examined * */ - void z_get_prop (void) { zword prop_addr; @@ -603,6 +603,7 @@ void z_get_prop (void) }/* z_get_prop */ + /* * z_get_prop_addr, store the address of an object property. * @@ -610,7 +611,6 @@ void z_get_prop (void) * zargs[1] = number of property to be examined * */ - void z_get_prop_addr (void) { zword prop_addr; @@ -656,13 +656,13 @@ void z_get_prop_addr (void) }/* z_get_prop_addr */ + /* * z_get_prop_len, store the length of an object property. * * zargs[0] = address of property to be examined * */ - void z_get_prop_len (void) { zword addr; @@ -693,13 +693,13 @@ void z_get_prop_len (void) }/* z_get_prop_len */ + /* * z_get_sibling, store the sibling of an object. * * zargs[0] = object * */ - void z_get_sibling (void) { zword obj_addr; @@ -745,6 +745,7 @@ void z_get_sibling (void) }/* z_get_sibling */ + /* * z_insert_obj, make an object the first child of another object. * @@ -752,7 +753,6 @@ void z_get_sibling (void) * zargs[1] = destination object * */ - void z_insert_obj (void) { zword obj1 = zargs[0]; @@ -820,6 +820,7 @@ void z_insert_obj (void) }/* z_insert_obj */ + /* * z_put_prop, set the value of an object property. * @@ -828,7 +829,6 @@ void z_insert_obj (void) * zargs[2] = value to set property to * */ - void z_put_prop (void) { zword prop_addr; @@ -876,16 +876,15 @@ void z_put_prop (void) }/* z_put_prop */ + /* * z_remove_obj, unlink an object from its parent and siblings. * * zargs[0] = object * */ - void z_remove_obj (void) { - /* If we are monitoring object movements display a short note */ if (f_setup.object_movement) { @@ -901,6 +900,7 @@ void z_remove_obj (void) }/* z_remove_obj */ + /* * z_set_attr, set an object attribute. * @@ -908,7 +908,6 @@ void z_remove_obj (void) * zargs[1] = number of attribute to set * */ - void z_set_attr (void) { zword obj_addr; @@ -955,6 +954,7 @@ void z_set_attr (void) }/* z_set_attr */ + /* * z_test_attr, branch if an object attribute is set. * @@ -962,7 +962,6 @@ void z_set_attr (void) * zargs[1] = number of attribute to test * */ - void z_test_attr (void) { zword obj_addr; diff --git a/src/common/process.c b/src/common/process.c index e4cf88e..9847071 100644 --- a/src/common/process.c +++ b/src/common/process.c @@ -177,7 +177,6 @@ void (*ext_opcodes[0x1d]) (void) = { * Initialize process variables. * */ - void init_process (void) { finished = 0; @@ -190,7 +189,6 @@ void init_process (void) * Load an operand, either a variable or a constant. * */ - static void load_operand (zbyte type) { zword value; @@ -223,6 +221,7 @@ static void load_operand (zbyte type) }/* load_operand */ + /* * load_all_operands * @@ -230,7 +229,6 @@ static void load_operand (zbyte type) * for a VAR or EXT opcode. * */ - static void load_all_operands (zbyte specifier) { int i; @@ -248,13 +246,13 @@ static void load_all_operands (zbyte specifier) }/* load_all_operands */ + /* * interpret * * Z-code interpreter main loop * */ - void interpret (void) { @@ -313,6 +311,7 @@ void interpret (void) }/* interpret */ + /* * call * @@ -322,7 +321,6 @@ void interpret (void) * can be 0 (z_call_s), 1 (z_call_n) or 2 (direct call). * */ - void call (zword routine, int argc, zword *args, int ct) { long pc; @@ -388,6 +386,7 @@ void call (zword routine, int argc, zword *args, int ct) }/* call */ + /* * ret * @@ -397,7 +396,6 @@ void call (zword routine, int argc, zword *args, int ct) * and we must exit the interpreter loop. * */ - void ret (zword value) { long pc; @@ -430,6 +428,7 @@ void ret (zword value) }/* ret */ + /* * branch * @@ -444,7 +443,6 @@ void ret (zword value) * return true. * */ - void branch (bool flag) { long pc; @@ -484,13 +482,13 @@ void branch (bool flag) }/* branch */ + /* * store * * Store an operand, either as a variable or pushed on the stack. * */ - void store (zword value) { zbyte variable; @@ -508,6 +506,7 @@ void store (zword value) }/* store */ + /* * direct_call * @@ -520,7 +519,6 @@ void store (zword value) * The interpreter returns the result value on the stack. * */ - int direct_call (zword addr) { zword saved_zargs[8]; @@ -556,13 +554,13 @@ int direct_call (zword addr) }/* direct_call */ + /* * __extended__ * * Load and execute an extended opcode. * */ - static void __extended__ (void) { zbyte opcode; @@ -578,34 +576,33 @@ static void __extended__ (void) }/* __extended__ */ + /* * __illegal__ * * Exit game because an unknown opcode has been hit. * */ - static void __illegal__ (void) { - runtime_error (ERR_ILL_OPCODE); }/* __illegal__ */ + /* * z_catch, store the current stack frame for later use with z_throw. * * no zargs used * */ - void z_catch (void) { - store (frame_count); }/* z_catch */ + /* * z_throw, go back to the given stack frame and return the given value. * @@ -613,10 +610,8 @@ void z_catch (void) * zargs[1] = stack frame * */ - void z_throw (void) { - if (zargs[1] > frame_count) runtime_error (ERR_BAD_FRAME); @@ -628,6 +623,7 @@ void z_throw (void) }/* z_throw */ + /* * z_call_n, call a subroutine and discard its result. * @@ -637,15 +633,14 @@ void z_throw (void) * zargs[7] = seventh argument (optional) * */ - void z_call_n (void) { - if (zargs[0] != 0) call (zargs[0], zargc - 1, zargs + 1, 1); }/* z_call_n */ + /* * z_call_s, call a subroutine and store its result. * @@ -655,10 +650,8 @@ void z_call_n (void) * zargs[7] = seventh argument (optional) * */ - void z_call_s (void) { - if (zargs[0] != 0) call (zargs[0], zargc - 1, zargs + 1, 0); else @@ -666,16 +659,15 @@ void z_call_s (void) }/* z_call_s */ + /* * z_check_arg_count, branch if subroutine was called with >= n arg's. * * zargs[0] = number of arguments * */ - void z_check_arg_count (void) { - if (fp == stack + STACK_SIZE) branch (zargs[0] == 0); else @@ -683,13 +675,13 @@ void z_check_arg_count (void) }/* z_check_arg_count */ + /* * z_jump, jump unconditionally to the given address. * * zargs[0] = PC relative address * */ - void z_jump (void) { long pc; @@ -705,86 +697,80 @@ void z_jump (void) }/* z_jump */ + /* * z_nop, no operation. * * no zargs used * */ - void z_nop (void) { - /* Do nothing */ }/* z_nop */ + /* * z_quit, stop game and exit interpreter. * * no zargs used * */ - void z_quit (void) { - finished = 9999; }/* z_quit */ + /* * z_ret, return from a subroutine with the given value. * * zargs[0] = value to return * */ - void z_ret (void) { - ret (zargs[0]); }/* z_ret */ + /* * z_ret_popped, return from a subroutine with a value popped off the stack. * * no zargs used * */ - void z_ret_popped (void) { - ret (*sp++); }/* z_ret_popped */ + /* * z_rfalse, return from a subroutine with false (0). * * no zargs used * */ - void z_rfalse (void) { - ret (0); }/* z_rfalse */ + /* * z_rtrue, return from a subroutine with true (1). * * no zargs used * */ - void z_rtrue (void) { - ret (1); }/* z_rtrue */ diff --git a/src/common/quetzal.c b/src/common/quetzal.c index df3be02..3ef73e2 100644 --- a/src/common/quetzal.c +++ b/src/common/quetzal.c @@ -131,11 +131,11 @@ static bool read_long (FILE *f, zlong *result) return TRUE; } + /* * Restore a saved game using Quetzal format. Return 2 if OK, 0 if an error * occurred before any damage was done, -1 on a fatal error. */ - zword restore_quetzal (FILE *svf, FILE *stf) { zlong ifzslen, currlen, tmpl; @@ -418,10 +418,10 @@ zword restore_quetzal (FILE *svf, FILE *stf) return (progress == GOT_ALL ? 2 : fatal); } + /* * Save a game using Quetzal format. Return 1 if OK, 0 if failed. */ - zword save_quetzal (FILE *svf, FILE *stf) { zlong ifzslen = 0, cmemlen = 0, stkslen = 0; diff --git a/src/common/random.c b/src/common/random.c index 6ea14d8..541a32d 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -25,13 +25,13 @@ static long A = 1; static int interval = 0; static int counter = 0; + /* * seed_random * * Set the seed value for the random number generator. * */ - void seed_random (int value) { @@ -48,16 +48,15 @@ void seed_random (int value) }/* seed_random */ + /* * z_random, store a random number or set the random number seed. * * zargs[0] = range (positive) or seed value (negative) * */ - void z_random () { - if ((short) zargs[0] <= 0) { /* set random seed */ seed_random (- (short) zargs[0]); @@ -76,7 +75,6 @@ void z_random () } store ((zword) (result % zargs[0] + 1)); - } }/* z_random */ diff --git a/src/common/redirect.c b/src/common/redirect.c index 7815abf..19ccc96 100644 --- a/src/common/redirect.c +++ b/src/common/redirect.c @@ -33,16 +33,15 @@ static struct { zword total; } redirect[MAX_NESTING]; + /* * memory_open * * Begin output redirection to the memory of the Z-machine. * */ - void memory_open (zword table, zword xsize, bool buffering) { - if (++depth < MAX_NESTING) { if (!buffering) @@ -67,13 +66,13 @@ void memory_open (zword table, zword xsize, bool buffering) }/* memory_open */ + /* * memory_new_line * * Redirect a newline to the memory of the Z-machine. * */ - void memory_new_line (void) { zword size; @@ -98,13 +97,13 @@ void memory_new_line (void) }/* memory_new_line */ + /* * memory_word * * Redirect a string of characters to the memory of the Z-machine. * */ - void memory_word (const zchar *s) { zword size; @@ -142,16 +141,15 @@ void memory_word (const zchar *s) }/* memory_word */ + /* * memory_close * * End of output redirection. * */ - void memory_close (void) { - if (depth >= 0) { if (redirect[depth].xsize != 0xffff) diff --git a/src/common/screen.c b/src/common/screen.c index 97b5505..6d3e4f5 100644 --- a/src/common/screen.c +++ b/src/common/screen.c @@ -61,10 +61,8 @@ Zwindow * curwinrec() { return cwp;} * current window. * */ - static zword winarg0 (void) { - if (h_version == V6 && (short) zargs[0] == -3) return cwin; @@ -75,6 +73,7 @@ static zword winarg0 (void) }/* winarg0 */ + /* * winarg2 * @@ -83,10 +82,8 @@ static zword winarg0 (void) * V6 opcodes: set_cursor, set_margins, set_colour. * */ - static zword winarg2 (void) { - if (zargc < 3 || (short) zargs[2] == -3) return cwin; @@ -97,29 +94,28 @@ static zword winarg2 (void) }/* winarg2 */ + /* * update_cursor * * Move the hardware cursor to make it match the window properties. * */ - static void update_cursor (void) { - os_set_cursor ( cwp->y_pos + cwp->y_cursor - 1, cwp->x_pos + cwp->x_cursor - 1); }/* update_cursor */ + /* * reset_cursor * * Reset the cursor of a given window to its initial position. * */ - static void reset_cursor (zword win) { int lines = 0; @@ -135,16 +131,15 @@ static void reset_cursor (zword win) }/* reset_cursor */ + /* * set_more_prompts * * Turn more prompts on/off. * */ - void set_more_prompts (bool flag) { - if (flag && !more_prompts) cwp->line_count = 0; @@ -152,20 +147,20 @@ void set_more_prompts (bool flag) }/* set_more_prompts */ + /* * units_left * * Return the #screen units from the cursor to the end of the line. * */ - static int units_left (void) { - return cwp->x_size - cwp->right - cwp->x_cursor + 1; }/* units_left */ + /* * get_max_width * @@ -173,10 +168,8 @@ static int units_left (void) * connection with the extended output stream #3 call in V6. * */ - zword get_max_width (zword win) { - if (h_version == V6) { if (win >= 8) @@ -188,6 +181,7 @@ zword get_max_width (zword win) }/* get_max_width */ + /* * countdown * @@ -195,16 +189,15 @@ zword get_max_width (zword win) * counter hits zero. This is a helper function for screen_new_line. * */ - static void countdown (void) { - if (cwp->nl_countdown != 0) if (--cwp->nl_countdown == 0) direct_call (cwp->nl_routine); }/* countdown */ + /* * screen_new_line * @@ -214,7 +207,6 @@ static void countdown (void) void screen_new_line (void) { - if (discarding) return; /* Handle newline interrupts at the start (for most cases) */ @@ -280,6 +272,7 @@ void screen_new_line (void) }/* screen_new_line */ + /* * screen_char * @@ -309,6 +302,7 @@ void screen_char (zchar c) }/* screen_char */ + /* * screen_word * @@ -317,7 +311,6 @@ void screen_char (zchar c) * enable_wrapping flag. * */ - void screen_word (const zchar *s) { int width; @@ -365,13 +358,13 @@ void screen_word (const zchar *s) }/* screen_word */ + /* * screen_write_input * * Display an input line on the screen. This is required during playback. * */ - void screen_write_input (const zchar *buf, zchar key) { int width; @@ -386,6 +379,7 @@ void screen_write_input (const zchar *buf, zchar key) }/* screen_write_input */ + /* * screen_erase_input * @@ -394,10 +388,8 @@ void screen_write_input (const zchar *buf, zchar key) * playback. * */ - void screen_erase_input (const zchar *buf) { - if (buf[0] != 0) { int width = os_string_width (buf); @@ -417,13 +409,13 @@ void screen_erase_input (const zchar *buf) }/* screen_erase_input */ + /* * console_read_input * * Read an input line from the keyboard and return the terminating key. * */ - zchar console_read_input (int max, zchar *buf, zword timeout, bool continued) { zchar key; @@ -461,13 +453,13 @@ zchar console_read_input (int max, zchar *buf, zword timeout, bool continued) }/* console_read_input */ + /* * console_read_key * * Read a single keystroke and return it. * */ - zchar console_read_key (zword timeout) { zchar key; @@ -483,6 +475,7 @@ zchar console_read_key (zword timeout) }/* console_read_key */ + /* * update_attributes * @@ -490,7 +483,6 @@ zchar console_read_key (zword timeout) * of the current window. * */ - static void update_attributes (void) { zword attr = cwp->attribute; @@ -511,6 +503,7 @@ static void update_attributes (void) }/* update_attributes */ + /* * refresh_text_style * @@ -519,7 +512,6 @@ static void update_attributes (void) * uses the set_text_style opcode. * */ - void refresh_text_style (void) { zword style; @@ -542,6 +534,7 @@ void refresh_text_style (void) }/* refresh_text_style */ + /* * set_window * @@ -549,10 +542,8 @@ void refresh_text_style (void) * properties such as colours, text style, cursor position and size. * */ - static void set_window (zword win) { - flush_buffer (); cwin = win; cwp = wp + win; @@ -579,13 +570,13 @@ static void set_window (zword win) }/* set_window */ + /* * erase_window * * Erase a window to background colour. * */ - void erase_window (zword win) { zword y = wp[win].y_pos; @@ -609,6 +600,7 @@ void erase_window (zword win) }/* erase_window */ + /* * split_window * @@ -616,7 +608,6 @@ void erase_window (zword win) * window appears below the status line. * */ - void split_window (zword height) { zword stat_height = 0; @@ -658,13 +649,13 @@ void split_window (zword height) }/* split_window */ + /* * erase_screen * * Erase the entire screen to background colour. * */ - static void erase_screen (zword win) { int i; @@ -684,13 +675,13 @@ static void erase_screen (zword win) /* #ifdef AMIGA */ + /* * resize_screen * * Try to adapt the window properties to a new screen size. * */ - void resize_screen (void) { @@ -708,16 +699,15 @@ void resize_screen (void) /* #endif */ + /* * restart_screen * * Prepare the screen for a new game. * */ - void restart_screen (void) { - /* Use default settings */ os_set_colour (h_default_foreground, h_default_background); @@ -772,6 +762,7 @@ void restart_screen (void) }/* restart_screen */ + /* * validate_click * @@ -780,7 +771,6 @@ void restart_screen (void) * memory of the header extension table and return true. * */ - bool validate_click (void) { @@ -818,6 +808,7 @@ bool validate_click (void) }/* validate_click */ + /* * screen_mssg_on * @@ -826,10 +817,8 @@ bool validate_click (void) * stream with maximum priority. * */ - void screen_mssg_on (void) { - if (cwin == 0) { /* messages in window 0 only */ os_set_text_style (0); @@ -843,16 +832,15 @@ void screen_mssg_on (void) }/* screen_mssg_on */ + /* * screen_mssg_off * * Stop printing a "debugging" message. * */ - void screen_mssg_off (void) { - if (cwin == 0) { /* messages in window 0 only */ screen_new_line (); @@ -863,16 +851,15 @@ void screen_mssg_off (void) }/* screen_mssg_off */ + /* * z_buffer_mode, turn text buffering on/off. * * zargs[0] = new text buffering flag (0 or 1) * */ - void z_buffer_mode (void) { - /* Infocom's V6 games rarely use the buffer_mode opcode. If they do then only to print text immediately, without any delay. This was used to give the player some sign of life while the game was @@ -895,6 +882,7 @@ void z_buffer_mode (void) }/* z_buffer_mode */ + /* * z_draw_picture, draw a picture. * @@ -903,7 +891,6 @@ void z_buffer_mode (void) * zargs[2] = x-coordinate of top left corner * */ - void z_draw_picture (void) { zword pic = zargs[0]; @@ -964,13 +951,13 @@ void z_draw_picture (void) }/* z_draw_picture */ + /* * z_erase_line, erase the line starting at the cursor position. * * zargs[0] = 1 + #units to erase (1 clears to the end of the line) * */ - void z_erase_line (void) { zword pixels = zargs[0]; @@ -992,6 +979,7 @@ void z_erase_line (void) }/* z_erase_line */ + /* * z_erase_picture, erase a picture with background colour. * @@ -1000,7 +988,6 @@ void z_erase_line (void) * zargs[2] = x-coordinate of top left corner (optional) * */ - void z_erase_picture (void) { int height, width; @@ -1024,16 +1011,15 @@ void z_erase_picture (void) }/* z_erase_picture */ + /* * z_erase_window, erase a window or the screen to background colour. * * zargs[0] = window (-3 current, -2 screen, -1 screen & unsplit) * */ - void z_erase_window (void) { - flush_buffer (); if ((short) zargs[0] == -1 || (short) zargs[0] == -2) @@ -1043,13 +1029,13 @@ void z_erase_window (void) }/* z_erase_window */ + /* * z_get_cursor, write the cursor coordinates into a table. * * zargs[0] = address to write information to * */ - void z_get_cursor (void) { zword y, x; @@ -1069,6 +1055,7 @@ void z_get_cursor (void) }/* z_get_cursor */ + /* * z_get_wind_prop, store the value of a window property. * @@ -1076,10 +1063,8 @@ void z_get_cursor (void) * zargs[1] = number of window property to be stored * */ - void z_get_wind_prop (void) { - flush_buffer (); if (zargs[1] >= 16) @@ -1089,20 +1074,20 @@ void z_get_wind_prop (void) }/* z_get_wind_prop */ + /* * z_mouse_window, select a window as mouse window. * * zargs[0] = window number (-3 is the current) or -1 for the screen * */ - void z_mouse_window (void) { - mwin = ((short) zargs[0] == -1) ? -1 : winarg0 (); }/* z_mouse_window */ + /* * z_move_window, place a window on the screen. * @@ -1111,7 +1096,6 @@ void z_mouse_window (void) * zargs[2] = x-coordinate * */ - void z_move_window (void) { zword win = winarg0 (); @@ -1126,6 +1110,7 @@ void z_move_window (void) }/* z_move_window */ + /* * z_picture_data, get information on a picture or the graphics file. * @@ -1133,7 +1118,6 @@ void z_move_window (void) * zargs[1] = address to write information to * */ - void z_picture_data (void) { zword pic = zargs[0]; @@ -1169,16 +1153,15 @@ void z_picture_data (void) }/* z_picture_data */ + /* * z_picture_table, prepare a group of pictures for faster display. * * zargs[0] = address of table holding the picture numbers * */ - void z_picture_table (void) { - /* This opcode is used by Shogun and Zork Zero when the player encounters built-in games such as Peggleboz. Nowadays it is not very helpful to hold the picture data in memory because @@ -1186,6 +1169,7 @@ void z_picture_table (void) }/* z_picture_table */ + /* * z_print_table, print ASCII text in a rectangular area. * @@ -1195,7 +1179,6 @@ void z_picture_table (void) * zargs[3] = number of char's to skip between lines (optional) * */ - void z_print_table (void) { zword addr = zargs[0]; @@ -1245,6 +1228,7 @@ void z_print_table (void) }/* z_print_table */ + /* * z_put_wind_prop, set the value of a window property. * @@ -1253,10 +1237,8 @@ void z_print_table (void) * zargs[2] = value to set window property to * */ - void z_put_wind_prop (void) { - flush_buffer (); if (zargs[1] >= 16) @@ -1266,6 +1248,7 @@ void z_put_wind_prop (void) }/* z_put_wind_prop */ + /* * z_scroll_window, scroll a window up or down. * @@ -1273,7 +1256,6 @@ void z_put_wind_prop (void) * zargs[1] = #screen units to scroll up (positive) or down (negative) * */ - void z_scroll_window (void) { zword win = winarg0 (); @@ -1300,6 +1282,7 @@ void z_scroll_window (void) }/* z_scroll_window */ + /* * z_set_colour, set the foreground and background colours. * @@ -1308,7 +1291,6 @@ void z_scroll_window (void) * zargs[2] = window (-3 is the current one, optional) * */ - void z_set_colour (void) { zword win = (h_version == V6) ? winarg2 () : 0; @@ -1364,13 +1346,13 @@ void z_set_colour (void) }/* z_set_colour */ + /* * z_set_font, set the font for text output and store the previous font. * * zargs[0] = number of font or 0 to keep current font * */ - void z_set_font (void) { zword win = (h_version == V6) ? cwin : 0; @@ -1398,6 +1380,7 @@ void z_set_font (void) }/* z_set_font */ + /* * z_set_cursor, set the cursor position or turn the cursor on/off. * @@ -1406,7 +1389,6 @@ void z_set_font (void) * zargs[2] = window (-3 is the current one, optional) * */ - void z_set_cursor (void) { zword win = (h_version == V6) ? winarg2 () : 1; @@ -1465,6 +1447,7 @@ void z_set_cursor (void) }/* z_set_cursor */ + /* * z_set_margins, set the left and right margins of a window. * @@ -1473,7 +1456,6 @@ void z_set_cursor (void) * zargs[2] = window (-3 is the current one, optional) * */ - void z_set_margins (void) { zword win = winarg2 (); @@ -1496,13 +1478,13 @@ void z_set_margins (void) }/* z_set_margins */ + /* * z_set_text_style, set the style for text output. * * zargs[0] = style flags to set or 0 to reset text style * */ - void z_set_text_style (void) { zword win = (h_version == V6) ? cwin : 0; @@ -1517,27 +1499,26 @@ void z_set_text_style (void) }/* z_set_text_style */ + /* * z_set_window, select the current window. * * zargs[0] = window to be selected (-3 is the current one) * */ - void z_set_window (void) { - set_window (winarg0 ()); }/* z_set_window */ + /* * pad_status_line * * Pad the status line with spaces up to the given position. * */ - static void pad_status_line (int column) { int spaces; @@ -1553,13 +1534,13 @@ static void pad_status_line (int column) }/* pad_status_line */ + /* * z_show_status, display the status line for V1 to V3 games. * * no zargs used * */ - void z_show_status (void) { zword global0; @@ -1654,20 +1635,20 @@ void z_show_status (void) }/* z_show_status */ + /* * z_split_window, split the screen into an upper (1) and lower (0) window. * * zargs[0] = height of upper window in screen units (V6) or #lines * */ - void z_split_window (void) { - split_window (zargs[0]); }/* z_split_window */ + /* * z_window_size, change the width and height of a window. * @@ -1676,7 +1657,6 @@ void z_split_window (void) * zargs[2] = new width in screen units * */ - void z_window_size (void) { zword win = winarg0 (); @@ -1693,6 +1673,7 @@ void z_window_size (void) }/* z_window_size */ + /* * z_window_style, set / clear / toggle window attributes. * @@ -1701,7 +1682,6 @@ void z_window_size (void) * zargs[2] = operation to perform (optional, defaults to 0) * */ - void z_window_style (void) { zword win = winarg0 (); @@ -1728,33 +1708,32 @@ void z_window_style (void) }/* z_window_style */ + /* * get_window_colours * * Get the colours for a given window. * */ - void get_window_colours (zword win, zbyte* fore, zbyte* back) { - *fore = lo (wp[win].colour); *back = hi (wp[win].colour); }/* get_window_colours */ + /* * get_window_font * * Get the font for a given window. * */ - zword get_window_font (zword win) { zword font = wp[win].font; - if (font == TEXT_FONT) + if (font == TEXT_FONT) { if (h_version != V6) { @@ -1769,49 +1748,44 @@ zword get_window_font (zword win) font = FIXED_WIDTH_FONT; } - + } return font; }/* get_window_font */ + /* * colour_in_use * * Check if a colour is set in any window. * */ - int colour_in_use (zword colour) { int max = (h_version == V6) ? 8 : 2; int i; for (i = 0; i < max; i++) { - zword bg = hi (wp[i].colour); zword fg = lo (wp[i].colour); if (colour == fg || colour == bg) return 1; - - } return 0; }/* colour_in_use */ + /* * get_current_window * * Get the currently active window. * */ - zword get_current_window (void) { - return cwp - wp; }/* get_current_window */ - diff --git a/src/common/sound.c b/src/common/sound.c index 50f2e9e..0004d0c 100644 --- a/src/common/sound.c +++ b/src/common/sound.c @@ -39,13 +39,13 @@ static int next_volume = 0; static bool locked = FALSE; static bool playing = FALSE; + /* * init_sound * * Initialize sound variables. * */ - void init_sound (void) { locked = FALSE; @@ -59,10 +59,8 @@ void init_sound (void) * Call the IO interface to play a sample. * */ - static void start_sample (int number, int volume, int repeats, zword eos) { - static zbyte lh_repeats[] = { 0x00, 0x00, 0x00, 0x01, 0xff, 0x00, 0x01, 0x01, 0x01, 0x01, @@ -80,6 +78,7 @@ static void start_sample (int number, int volume, int repeats, zword eos) }/* start_sample */ + /* * start_next_sample * @@ -88,10 +87,8 @@ static void start_sample (int number, int volume, int repeats, zword eos) * immediately follow other samples. * */ - static void start_next_sample (void) { - if (next_sample != 0) start_sample (next_sample, next_volume, 0, 0); @@ -100,6 +97,7 @@ static void start_next_sample (void) }/* start_next_sample */ + /* * end_of_sound * @@ -108,10 +106,8 @@ static void start_next_sample (void) * interrupt (which requires extremely careful programming). * */ - void end_of_sound (void) { - #if defined(DJGPP) && defined(SOUND_SUPPORT) end_of_sound_flag = 0; #endif @@ -129,6 +125,7 @@ void end_of_sound (void) }/* end_of_sound */ + /* * z_sound_effect, load / play / stop / discard a sound effect. * @@ -141,7 +138,6 @@ void end_of_sound (void) * Repeats are stored in the high byte, 255 is infinite loop. * */ - void z_sound_effect (void) { zword number = zargs[0]; diff --git a/src/common/stream.c b/src/common/stream.c index ed37baa..ce2ed5c 100644 --- a/src/common/stream.c +++ b/src/common/stream.c @@ -59,16 +59,15 @@ extern zchar console_read_input (int, zchar *, zword, bool); extern int direct_call (zword); + /* * stream_mssg_on * * Start printing a "debugging" message. * */ - void stream_mssg_on (void) { - flush_buffer (); if (ostream_screen) @@ -80,16 +79,15 @@ void stream_mssg_on (void) }/* stream_mssg_on */ + /* * stream_mssg_off * * Stop printing a "debugging" message. * */ - void stream_mssg_off (void) { - flush_buffer (); if (ostream_screen) @@ -101,6 +99,7 @@ void stream_mssg_off (void) }/* stream_mssg_off */ + /* * z_output_stream, open or close an output stream. * @@ -109,10 +108,8 @@ void stream_mssg_off (void) * zargs[2] = width of redirected output (stream 3 only, optional) * */ - void z_output_stream (void) { - flush_buffer (); switch ((short) zargs[0]) { @@ -138,16 +135,15 @@ void z_output_stream (void) }/* z_output_stream */ + /* * stream_char * * Send a single character to the output stream. * */ - void stream_char (zchar c) { - if (ostream_screen) screen_char (c); if (ostream_script && enable_scripting) @@ -155,16 +151,15 @@ void stream_char (zchar c) }/* stream_char */ + /* * stream_word * * Send a string of characters to the output streams. * */ - void stream_word (const zchar *s) { - if (ostream_memory && !message) memory_word (s); @@ -180,18 +175,16 @@ void stream_word (const zchar *s) }/* stream_word */ + /* * stream_new_line * * Send a newline to the output streams. * */ - void stream_new_line (void) { - if (ostream_memory && !message) - memory_new_line (); else { @@ -205,16 +198,15 @@ void stream_new_line (void) }/* stream_new_line */ + /* * z_input_stream, select an input stream. * * zargs[0] = input stream to be selected * */ - void z_input_stream (void) { - flush_buffer (); if (zargs[0] == 0 && istream_replay) @@ -224,15 +216,14 @@ void z_input_stream (void) }/* z_input_stream */ + /* * stream_read_key * * Read a single keystroke from the current input stream. * */ - -zchar stream_read_key ( zword timeout, zword routine, - bool hot_keys ) +zchar stream_read_key ( zword timeout, zword routine, bool hot_keys ) { zchar key = ZC_BAD; @@ -287,13 +278,13 @@ continue_input: }/* stream_read_key */ + /* * stream_read_input * * Read a line of input from the current input stream. * */ - zchar stream_read_input ( int max, zchar *buf, zword timeout, zword routine, bool hot_keys, diff --git a/src/common/table.c b/src/common/table.c index 192053d..864fa63 100644 --- a/src/common/table.c +++ b/src/common/table.c @@ -20,6 +20,7 @@ #include "frotz.h" + /* * z_copy_table, copy a table or fill it with zeroes. * @@ -31,7 +32,6 @@ * if zargs[1] is negative the table _must_ be copied forwards. * */ - void z_copy_table (void) { zword addr; @@ -62,6 +62,7 @@ void z_copy_table (void) }/* z_copy_table */ + /* * z_loadb, store a value from a table of bytes. * @@ -69,7 +70,6 @@ void z_copy_table (void) * zargs[1] = index of table entry to store * */ - void z_loadb (void) { zword addr = zargs[0] + zargs[1]; @@ -81,6 +81,7 @@ void z_loadb (void) }/* z_loadb */ + /* * z_loadw, store a value from a table of words. * @@ -88,7 +89,6 @@ void z_loadb (void) * zargs[1] = index of table entry to store * */ - void z_loadw (void) { zword addr = zargs[0] + 2 * zargs[1]; @@ -100,6 +100,7 @@ void z_loadw (void) }/* z_loadw */ + /* * z_scan_table, find and store the address of a target within a table. * @@ -112,7 +113,6 @@ void z_loadw (void) * it's a byte array. The lower bits hold the address step. * */ - void z_scan_table (void) { zword addr = zargs[1]; @@ -160,6 +160,7 @@ finished: }/* z_scan_table */ + /* * z_storeb, write a byte into a table of bytes. * @@ -168,14 +169,13 @@ finished: * zargs[2] = value to be written * */ - void z_storeb (void) { - storeb ((zword) (zargs[0] + zargs[1]), zargs[2]); }/* z_storeb */ + /* * z_storew, write a word into a table of words. * @@ -184,10 +184,8 @@ void z_storeb (void) * zargs[2] = value to be written * */ - void z_storew (void) { - storew ((zword) (zargs[0] + 2 * zargs[1]), zargs[2]); }/* z_storew */ diff --git a/src/common/text.c b/src/common/text.c index e1ea02c..9784c39 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -46,16 +46,15 @@ static zchar zscii_to_latin1[] = { 0xa3, 0x00, 0x00, 0xa1, 0xbf }; + /* * translate_from_zscii * * Map a ZSCII character onto the ISO Latin-1 alphabet. * */ - zchar translate_from_zscii (zbyte c) { - if (c == 0xfc) return ZC_MENU_CLICK; if (c == 0xfd) @@ -98,13 +97,13 @@ zchar translate_from_zscii (zbyte c) }/* translate_from_zscii */ + /* * translate_to_zscii * * Map an ISO Latin-1 character onto the ZSCII alphabet. * */ - zbyte translate_to_zscii (zchar c) { int i; @@ -158,16 +157,15 @@ zbyte translate_to_zscii (zchar c) }/* translate_to_zscii */ + /* * alphabet * * Return a character from one of the three character sets. * */ - static zchar alphabet (int set, int index) { - if (h_alphabet != 0) { /* game uses its own alphabet */ zbyte c; @@ -190,13 +188,13 @@ static zchar alphabet (int set, int index) }/* alphabet */ + /* * load_string * * Copy a ZSCII string from the memory to the global "decoded" string. * */ - static void load_string (zword addr, zword length) { int resolution = (h_version <= V3) ? 2 : 3; @@ -217,6 +215,7 @@ static void load_string (zword addr, zword length) }/* load_string */ + /* * encode_text * @@ -230,7 +229,6 @@ static void load_string (zword addr, zword length) * the minimum and maximum Z-characters. * */ - static void encode_text (int padding) { static zchar again[] = { 'a', 'g', 'a', 'i', 'n', 0 }; @@ -306,13 +304,13 @@ static void encode_text (int padding) }/* encode_text */ + /* * z_check_unicode, test if a unicode character can be read and printed. * * zargs[0] = Unicode * */ - void z_check_unicode (void) { zword c = zargs[0]; @@ -328,6 +326,7 @@ void z_check_unicode (void) }/* z_check_unicode */ + /* * z_encode_text, encode a ZSCII string for use in a dictionary. * @@ -340,7 +339,6 @@ void z_check_unicode (void) * three 16bit words. * */ - void z_encode_text (void) { int i; @@ -354,6 +352,7 @@ void z_encode_text (void) }/* z_encode_text */ + /* * decode_text * @@ -374,9 +373,7 @@ void z_encode_text (void) * The last type is only used for word completion. * */ - #define outchar(c) if (st==VOCABULARY) *ptr++=c; else print_char(c) - static void decode_text (enum string_type st, zword addr) { zchar *ptr; @@ -517,72 +514,67 @@ static void decode_text (enum string_type st, zword addr) *ptr = 0; }/* decode_text */ - #undef outchar + /* * z_new_line, print a new line. * * no zargs used * */ - void z_new_line (void) { - new_line (); }/* z_new_line */ + /* * z_print, print a string embedded in the instruction stream. * * no zargs used * */ - void z_print (void) { - decode_text (EMBEDDED_STRING, 0); }/* z_print */ + /* * z_print_addr, print a string from the lower 64KB. * * zargs[0] = address of string to print * */ - void z_print_addr (void) { - decode_text (LOW_STRING, zargs[0]); }/* z_print_addr */ + /* * z_print_char print a single ZSCII character. * * zargs[0] = ZSCII character to be printed * */ - void z_print_char (void) { - print_char (translate_from_zscii (zargs[0])); }/* z_print_char */ + /* * z_print_form, print a formatted table. * * zargs[0] = address of formatted table to be printed * */ - void z_print_form (void) { zword count; @@ -618,13 +610,13 @@ void z_print_form (void) }/* z_print_form */ + /* * print_num * * Print a signed 16bit number. * */ - void print_num (zword value) { int i; @@ -644,27 +636,26 @@ void print_num (zword value) }/* print_num */ + /* * z_print_num, print a signed number. * * zargs[0] = number to print * */ - void z_print_num (void) { - print_num (zargs[0]); }/* z_print_num */ + /* * print_object * * Print an object description. * */ - void print_object (zword object) { zword addr = object_name (object); @@ -686,57 +677,54 @@ void print_object (zword object) }/* print_object */ + /* * z_print_obj, print an object description. * * zargs[0] = number of object to be printed * */ - void z_print_obj (void) { - print_object (zargs[0]); }/* z_print_obj */ + /* * z_print_paddr, print the string at the given packed address. * * zargs[0] = packed address of string to be printed * */ - void z_print_paddr (void) { - decode_text (HIGH_STRING, zargs[0]); }/* z_print_paddr */ + /* * z_print_ret, print the string at PC, print newline then return true. * * no zargs used * */ - void z_print_ret (void) { - decode_text (EMBEDDED_STRING, 0); new_line (); ret (1); }/* z_print_ret */ + /* * print_string * * Print a string of ASCII characters. * */ - void print_string (const char *s) { char c; @@ -750,20 +738,20 @@ void print_string (const char *s) }/* print_string */ + /* * z_print_unicode * * zargs[0] = Unicode * */ - void z_print_unicode (void) { - print_char ((zargs[0] <= 0xff) ? zargs[0] : '?'); }/* z_print_unicode */ + /* * lookup_text * @@ -777,7 +765,6 @@ void z_print_unicode (void) * The return value is 0 if the search fails. * */ - static zword lookup_text (int padding, zword dct) { zword entry_addr; @@ -860,6 +847,7 @@ static zword lookup_text (int padding, zword dct) }/* lookup_text */ + /* * tokenise_text * @@ -871,7 +859,6 @@ static zword lookup_text (int padding, zword dct) * times with different dictionaries); otherwise they are zero. * */ - static void tokenise_text (zword text, zword length, zword from, zword parse, zword dct, bool flag) { zword addr; @@ -903,13 +890,13 @@ static void tokenise_text (zword text, zword length, zword from, zword parse, zw }/* tokenise_text */ + /* * tokenise_line * * Split an input line into words and translate the words to tokens. * */ - void tokenise_line (zword text, zword token, zword dct, bool flag) { zword addr1; @@ -1004,6 +991,7 @@ void tokenise_line (zword text, zword token, zword dct, bool flag) }/* tokenise_line */ + /* * z_tokenise, make a lexical analysis of a ZSCII string. * @@ -1013,10 +1001,8 @@ void tokenise_line (zword text, zword token, zword dct, bool flag) * zargs[3] = set when unknown words cause empty slots (optional) * */ - void z_tokenise (void) { - /* Supply default arguments */ if (zargc < 3) @@ -1030,6 +1016,7 @@ void z_tokenise (void) }/* z_tokenise */ + /* * completion * @@ -1049,7 +1036,6 @@ void z_tokenise (void) * to the last word that results in the only possible completion. * */ - int completion (const zchar *buffer, zchar *result) { zword minaddr; diff --git a/src/common/variable.c b/src/common/variable.c index 02b533d..45dec19 100644 --- a/src/common/variable.c +++ b/src/common/variable.c @@ -20,13 +20,13 @@ #include "frotz.h" + /* * z_dec, decrement a variable. * * zargs[0] = variable to decrement * */ - void z_dec (void) { zword value; @@ -44,6 +44,7 @@ void z_dec (void) }/* z_dec */ + /* * z_dec_chk, decrement a variable and branch if now less than value. * @@ -51,7 +52,6 @@ void z_dec (void) * zargs[1] = value to check variable against * */ - void z_dec_chk (void) { zword value; @@ -71,13 +71,13 @@ void z_dec_chk (void) }/* z_dec_chk */ + /* * z_inc, increment a variable. * * zargs[0] = variable to increment * */ - void z_inc (void) { zword value; @@ -95,6 +95,7 @@ void z_inc (void) }/* z_inc */ + /* * z_inc_chk, increment a variable and branch if now greater than value. * @@ -102,7 +103,6 @@ void z_inc (void) * zargs[1] = value to check variable against * */ - void z_inc_chk (void) { zword value; @@ -122,13 +122,13 @@ void z_inc_chk (void) }/* z_inc_chk */ + /* * z_load, store the value of a variable. * * zargs[0] = variable to store * */ - void z_load (void) { zword value; @@ -146,20 +146,20 @@ void z_load (void) }/* z_load */ + /* * z_pop, pop a value off the game stack and discard it. * * no zargs used * */ - void z_pop (void) { - sp++; }/* z_pop */ + /* * z_pop_stack, pop n values off the game or user stack and discard them. * @@ -167,10 +167,8 @@ void z_pop (void) * zargs[1] = address of user stack (optional) * */ - void z_pop_stack (void) { - if (zargc == 2) { /* it's a user stack */ zword size; @@ -185,6 +183,7 @@ void z_pop_stack (void) }/* z_pop_stack */ + /* * z_pull, pop a value off... * @@ -197,7 +196,6 @@ void z_pop_stack (void) * zargs[0] = variable to write value to * */ - void z_pull (void) { zword value; @@ -238,20 +236,20 @@ void z_pull (void) }/* z_pull */ + /* * z_push, push a value onto the game stack. * * zargs[0] = value to push onto the stack * */ - void z_push (void) { - *--sp = zargs[0]; }/* z_push */ + /* * z_push_stack, push a value onto a user stack then branch if successful. * @@ -259,7 +257,6 @@ void z_push (void) * zargs[1] = address of user stack * */ - void z_push_stack (void) { zword size; @@ -280,6 +277,7 @@ void z_push_stack (void) }/* z_push_stack */ + /* * z_store, write a value to a variable. * @@ -287,7 +285,6 @@ void z_push_stack (void) * zargs[1] = value to write * */ - void z_store (void) { zword value = zargs[1]; diff --git a/src/curses/ux_blorb.c b/src/curses/ux_blorb.c index a71c59f..723ad8f 100644 --- a/src/curses/ux_blorb.c +++ b/src/curses/ux_blorb.c @@ -70,7 +70,3 @@ double ReadExtended(const unsigned char *bytes) return -f; return f; } - - -/* /home/dave/zcode/mystory.z5 */ -/* /home/dave/zcode/mystory.blb */ diff --git a/src/curses/ux_pic.c b/src/curses/ux_pic.c index 1fe77a1..fd4e0d2 100644 --- a/src/curses/ux_pic.c +++ b/src/curses/ux_pic.c @@ -271,11 +271,6 @@ void os_draw_picture (int num, int row, int col) * v */ - - - - - if ((height == 1) && (width == 1)) safe_mvaddch(row, col, plus); else if (height == 1) { diff --git a/src/curses/ux_screen.c b/src/curses/ux_screen.c index 52ee4ca..8ad4e7f 100644 --- a/src/curses/ux_screen.c +++ b/src/curses/ux_screen.c @@ -32,6 +32,7 @@ #include "ux_frotz.h" + /* * os_erase_area * @@ -43,7 +44,6 @@ * being erased. This is not relevant for the curses interface. * */ - void os_erase_area (int top, int left, int bottom, int right, int win) { int y, x, i, j; @@ -77,6 +77,7 @@ void os_erase_area (int top, int left, int bottom, int right, int win) } }/* os_erase_area */ + /* * os_scroll_area * @@ -85,7 +86,6 @@ void os_erase_area (int top, int left, int bottom, int right, int win) * colour. Top left coordinates are (1,1). The cursor stays put. * */ - void os_scroll_area (int top, int left, int bottom, int right, int units) { top--; left--; bottom--; right--; diff --git a/src/curses/ux_text.c b/src/curses/ux_text.c index 9fa1dbf..2850c74 100644 --- a/src/curses/ux_text.c +++ b/src/curses/ux_text.c @@ -65,17 +65,15 @@ static char latin1_to_ascii[] = * be changed. * */ - int os_font_data (int font, int *height, int *width) { - if (font == TEXT_FONT) { *height = 1; *width = 1; return 1; /* Truth in advertising */ } return 0; - }/* os_font_data */ + #ifdef COLOR_SUPPORT /* * unix_convert @@ -83,7 +81,6 @@ int os_font_data (int font, int *height, int *width) * Converts frotz's (and Infocom's) color values to ncurses color values. * */ - static int unix_convert(int color) { switch(color) { @@ -100,6 +97,7 @@ static int unix_convert(int color) } #endif + /* * os_set_colour * @@ -129,7 +127,6 @@ static int unix_convert(int color) * remarks on os_peek_colour. * */ - void os_set_colour (int new_foreground, int new_background) { if (new_foreground == 1) new_foreground = h_default_foreground; @@ -153,6 +150,7 @@ void os_set_colour (int new_foreground, int new_background) os_set_text_style(u_setup.current_text_style); }/* os_set_colour */ + /* * os_set_text_style * @@ -164,7 +162,6 @@ void os_set_colour (int new_foreground, int new_background) * FIXED_WIDTH_STYLE * */ - void os_set_text_style (int new_style) { int temp = 0; @@ -176,6 +173,7 @@ void os_set_text_style (int new_style) attrset(temp ^ u_setup.current_color); }/* os_set_text_style */ + /* * os_set_font * @@ -183,14 +181,13 @@ void os_set_text_style (int new_style) * choose fonts which aren't supported by the interface. * */ - void os_set_font (int new_font) { - /* Not implemented */ }/* os_set_font */ + /* * os_display_char * @@ -202,7 +199,6 @@ void os_set_font (int new_font) * bottom right corner. * */ - void os_display_char (zchar c) { @@ -237,22 +233,20 @@ void os_display_char (zchar c) addch(' '); addch(' '); return; } - }/* os_display_char */ + /* * os_display_string * * Pass a string of characters to os_display_char. * */ - void os_display_string (const zchar *s) { - zchar c; - while ((c = (unsigned char) *s++) != 0) + while ((c = (unsigned char) *s++) != 0) { if (c == ZC_NEW_FONT || c == ZC_NEW_STYLE) { @@ -263,20 +257,21 @@ void os_display_string (const zchar *s) if (c == ZC_NEW_STYLE) os_set_text_style (arg); - } else os_display_char (c); + } else + os_display_char (c); + } }/* os_display_string */ + /* * os_char_width * * Return the width of the character in screen units. * */ - int os_char_width (zchar c) { - if (c >= ZC_LATIN1_MIN && c <= ZC_LATIN1_MAX && u_setup.plain_ascii) { int width = 0; @@ -296,9 +291,9 @@ int os_char_width (zchar c) return width; } return 1; - }/* os_char_width*/ + /* * os_string_width * @@ -309,40 +304,36 @@ int os_char_width (zchar c) * NEW_FONT - next character is a new font * */ - int os_string_width (const zchar *s) { int width = 0; zchar c; - while ((c = *s++) != 0) - - if (c == ZC_NEW_STYLE || c == ZC_NEW_FONT) { - - s++; - /* No effect */ - - } else width += os_char_width(c); + while ((c = *s++) != 0) { + if (c == ZC_NEW_STYLE || c == ZC_NEW_FONT) { + s++; + /* No effect */ + } else + width += os_char_width(c); + } return width; - }/* os_string_width */ + /* * os_set_cursor * * Place the text cursor at the given coordinates. Top left is (1,1). * */ - void os_set_cursor (int y, int x) { - /* Curses thinks the top left is (0,0) */ move(--y, --x); - }/* os_set_cursor */ + /* * os_more_prompt * @@ -350,7 +341,6 @@ void os_set_cursor (int y, int x) * prompt from the screen. * */ - void os_more_prompt (void) { int saved_style, saved_x, saved_y; @@ -367,5 +357,4 @@ void os_more_prompt (void) addstr(" "); move(saved_y, saved_x); os_set_text_style(saved_style); - }/* os_more_prompt */ -- 2.34.1