diff options
author | Eugene Sandulenko | 2018-12-18 22:53:30 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2018-12-18 22:53:30 +0100 |
commit | 0dab01862c3c1e34a80a239788a1d81fd9b679fd (patch) | |
tree | 8a2e39089adddaa5dbb03030a9c92dd5c05dbca4 | |
parent | ba00661b3a531834e6f7d648144996540539573c (diff) | |
download | scummvm-rg350-0dab01862c3c1e34a80a239788a1d81fd9b679fd.tar.gz scummvm-rg350-0dab01862c3c1e34a80a239788a1d81fd9b679fd.tar.bz2 scummvm-rg350-0dab01862c3c1e34a80a239788a1d81fd9b679fd.zip |
JANITORIAL: Whitespace fixes
24 files changed, 1363 insertions, 1363 deletions
diff --git a/engines/glk/blorb.h b/engines/glk/blorb.h index dd7e23c64b..18a84a5f08 100644 --- a/engines/glk/blorb.h +++ b/engines/glk/blorb.h @@ -37,7 +37,7 @@ struct ChunkEntry { uint _type; uint _number; uint _id; - size_t _offset; + size_t _offset; size_t _size; Common::String _filename; }; diff --git a/engines/glk/frotz/pics_decoder.cpp b/engines/glk/frotz/pics_decoder.cpp index 0e8287851a..dba1335295 100644 --- a/engines/glk/frotz/pics_decoder.cpp +++ b/engines/glk/frotz/pics_decoder.cpp @@ -38,18 +38,18 @@ PictureDecoder::~PictureDecoder() { Common::SeekableReadStream *PictureDecoder::decode(Common::ReadStream &src, uint flags, const Common::Array<byte> &palette, uint display, size_t width, size_t height) { - static const int raise_bits[4] = { 0x0100, 0x0300, 0x0700, 0x0000 }; + static const int raise_bits[4] = { 0x0100, 0x0300, 0x0700, 0x0000 }; Common::MemoryWriteStreamDynamic out(DisposeAfterUse::NO); byte buf[512]; - byte transparent; - int colour_shift = 0; + byte transparent; + int colour_shift = 0; int first_colour = 0; - int code, prev_code = 0; - int next_entry; - int bits_per_code; - int bits_shift; - int bits; - int bufpos = 0; + int code, prev_code = 0; + int next_entry; + int bits_per_code; + int bits_shift; + int bits; + int bufpos = 0; /* * Write out dimensions of image @@ -57,13 +57,13 @@ Common::SeekableReadStream *PictureDecoder::decode(Common::ReadStream &src, uint out.writeUint16LE(width); out.writeUint16LE(height); - /* Set up the color mapping. This is only used for MCGA pictures; the colour + /* Set up the color mapping. This is only used for MCGA pictures; the colour * map affects every picture on the screen. The first colour to be defined is - * colour 2. Every map defines up to 14 colours (colour 2 to 15). These colours + * colour 2. Every map defines up to 14 colours (colour 2 to 15). These colours * are not related to the standard Z-machine colour scheme which remains unchanged. * (This is based on the Amiga interpreter which had to work with 16 colours. * Colours 0 and 1 were used for text; changing the text colours actually changed - * palette entries 0 and 1. This interface uses the same trick in Amiga mode.) + * palette entries 0 and 1. This interface uses the same trick in Amiga mode.) */ switch (display) { @@ -85,7 +85,7 @@ Common::SeekableReadStream *PictureDecoder::decode(Common::ReadStream &src, uint error("Unsupported mode"); break; } - + // Note: we don't actually use paletted indexes, so adjust colour_shift // relative to first_colour colour_shift -= first_colour; @@ -94,16 +94,16 @@ Common::SeekableReadStream *PictureDecoder::decode(Common::ReadStream &src, uint if (!palette.empty()) out.write(&palette[0], palette.size()); - /* Bit 0 of "flags" indicates that the picture uses a transparent colour, + /* Bit 0 of "flags" indicates that the picture uses a transparent colour, * the top four bits tell us which colour it is. For CGA and MCGA pictures * this is always 0; for EGA pictures it can be any colour between 0 and 15. */ - transparent = 0xff; - if (flags & 1) + transparent = 0xff; + if (flags & 1) transparent = flags >> 12; out.writeByte(transparent); - /* The uncompressed picture is a long sequence of bytes. Every byte holds + /* The uncompressed picture is a long sequence of bytes. Every byte holds * the colour of a pixel, starting at the top left, stopping at the bottom right. * We keep track of our position in the current line. (There is a special case: * CGA pictures with no transparent colour are stored as bit patterns, i.e. @@ -113,39 +113,39 @@ Common::SeekableReadStream *PictureDecoder::decode(Common::ReadStream &src, uint // current_x = 1 + width; // current_y = 1 - 1; - /* The compressed picture is a stream of bits. We read the file byte-wise, + /* The compressed picture is a stream of bits. We read the file byte-wise, * storing the current byte in the variable "bits". Several bits make one code; * the variable "bits_shift" helps us to build the next code. */ - bits_shift = 0; - bits = 0; + bits_shift = 0; + bits = 0; reset_table: - /* Clear the table. We use a table of 3840 entries. Each entry consists of both + /* Clear the table. We use a table of 3840 entries. Each entry consists of both * a value and a reference to another table entry. Following these references * we get a sequence of values. At the start of decompression all table entries * are undefined. Later we see how entries are set and used. */ - next_entry = 1; + next_entry = 1; - /* At the start of decompression 9 bits make one code; during the process this can + /* At the start of decompression 9 bits make one code; during the process this can * rise to 12 bits per code. 9 bits are sufficient to address both 256 literal values * and 256 table entries; 12 bits are sufficient to address both 256 literal values * and all 3840 table entries. The number of bits per code rises with the number of * table entries. When the table is cleared, the number of bits per code drops back to 9. */ - bits_per_code = 9; + bits_per_code = 9; next_code: - /* Read the next code from the graphics file. This requires some confusing bit operations. + /* Read the next code from the graphics file. This requires some confusing bit operations. * Note that low bits always come first. Usually there are a few bits left over from * the previous code; these bits must be used before further bits are read from the * graphics file. */ - code = bits >> (8 - bits_shift); + code = bits >> (8 - bits_shift); - do { + do { bits = src.readByte(); code |= bits << bits_shift; @@ -197,22 +197,22 @@ next_code: code = (short) _tableRef[code]; } - if (next_entry == prev_code) + if (next_entry == prev_code) buf[0] = code; - _tableVal[next_entry] = code; + _tableVal[next_entry] = code; - /* The number of bits per code is incremented when the current number of bits + /* The number of bits per code is incremented when the current number of bits * no longer suffices to address all defined table entries; but in any case * the number of bits may never be greater than 12. */ - next_entry++; + next_entry++; - if (next_entry == raise_bits[bits_per_code - 9]) + if (next_entry == raise_bits[bits_per_code - 9]) bits_per_code++; reverse_buffer: - /* Output the sequence of byte values (pixels). The order of the sequence + /* Output the sequence of byte values (pixels). The order of the sequence * must be reversed. (This is why we have stored the sequence in a buffer; * experiments show that a buffer of 512 bytes suffices.) * @@ -221,9 +221,9 @@ reverse_buffer: * respectively. The pixel may have to be painted several times if the scaling * factor is greater than one. */ - if (display == kCGA && transparent == 0xff) { + if (display == kCGA && transparent == 0xff) { // TODO - } else { + } else { byte v = code; if (v != transparent) { @@ -241,16 +241,16 @@ reverse_buffer: // TODO } } - } + } - /* If there are no more values in the buffer then read the next code from the file. + /* If there are no more values in the buffer then read the next code from the file. * Otherwise fetch the next byte value from the buffer and continue outputing the picture. */ - if (bufpos == 0) + if (bufpos == 0) goto next_code; code = (code & ~0xff) | buf[--bufpos]; - goto reverse_buffer; + goto reverse_buffer; } } // End of namespace Frotz diff --git a/engines/glk/frotz/processor.cpp b/engines/glk/frotz/processor.cpp index 5553b04595..9fcb3b2641 100644 --- a/engines/glk/frotz/processor.cpp +++ b/engines/glk/frotz/processor.cpp @@ -131,7 +131,7 @@ Opcode Processor::ext_opcodes[64] = { &Processor::z_buffer_screen // spec 1.1 }; -Processor::Processor(OSystem *syst, const GlkGameDescription &gameDesc) : +Processor::Processor(OSystem *syst, const GlkGameDescription &gameDesc) : GlkInterface(syst, gameDesc), _finished(0), _sp(nullptr), _fp(nullptr), _frameCount(0), zargc(0), _decoded(nullptr), _encoded(nullptr), _resolution(0), @@ -575,12 +575,12 @@ void Processor::z_rtrue() { } void Processor::z_random() { - if ((short) zargs[0] <= 0) { + if ((short) zargs[0] <= 0) { // set random seed seed_random(- (short) zargs[0]); store(0); - } else { + } else { // generate random number zword result; if (_randomInterval != 0) { @@ -594,22 +594,22 @@ void Processor::z_random() { } store((zword)(result % zargs[0] + 1)); - } + } } void Processor::z_sound_effect() { - zword number = zargs[0]; - zword effect = zargs[1]; - zword volume = zargs[2]; + zword number = zargs[0]; + zword effect = zargs[1]; + zword volume = zargs[2]; - if (zargc < 1) + if (zargc < 1) number = 0; - if (zargc < 2) + if (zargc < 2) effect = EFFECT_PLAY; - if (zargc < 3) + if (zargc < 3) volume = 8; - if (number >= 3 || number == 0) { + if (number >= 3 || number == 0) { _soundLocked = true; if (_storyId == LURKING_HORROR && (number == 9 || number == 16)) { diff --git a/engines/glk/frotz/processor_buffer.cpp b/engines/glk/frotz/processor_buffer.cpp index b8b37ed60e..8b9e4112b9 100644 --- a/engines/glk/frotz/processor_buffer.cpp +++ b/engines/glk/frotz/processor_buffer.cpp @@ -28,39 +28,39 @@ namespace Glk { namespace Frotz { const char *const Processor::ERR_MESSAGES[ERR_NUM_ERRORS] = { - "Text buffer overflow", - "Store out of dynamic memory", - "Division by zero", - "Illegal object", - "Illegal attribute", - "No such property", - "Stack overflow", - "Call to illegal address", - "Call to non-routine", - "Stack underflow", - "Illegal opcode", - "Bad stack frame", - "Jump to illegal address", - "Can't save while in interrupt", - "Nesting stream #3 too deep", - "Illegal window", - "Illegal window property", - "Print at illegal address", - "Illegal dictionary word length", - "@jin called with object 0", - "@get_child called with object 0", - "@get_parent called with object 0", - "@get_sibling called with object 0", - "@get_prop_addr called with object 0", - "@get_prop called with object 0", - "@put_prop called with object 0", - "@clear_attr called with object 0", - "@set_attr called with object 0", - "@test_attr called with object 0", - "@move_object called moving object 0", - "@move_object called moving into object 0", - "@remove_object called with object 0", - "@get_next_prop called with object 0" + "Text buffer overflow", + "Store out of dynamic memory", + "Division by zero", + "Illegal object", + "Illegal attribute", + "No such property", + "Stack overflow", + "Call to illegal address", + "Call to non-routine", + "Stack underflow", + "Illegal opcode", + "Bad stack frame", + "Jump to illegal address", + "Can't save while in interrupt", + "Nesting stream #3 too deep", + "Illegal window", + "Illegal window property", + "Print at illegal address", + "Illegal dictionary word length", + "@jin called with object 0", + "@get_child called with object 0", + "@get_parent called with object 0", + "@get_sibling called with object 0", + "@get_prop_addr called with object 0", + "@get_prop called with object 0", + "@put_prop called with object 0", + "@clear_attr called with object 0", + "@set_attr called with object 0", + "@test_attr called with object 0", + "@move_object called moving object 0", + "@move_object called moving into object 0", + "@remove_object called with object 0", + "@get_next_prop called with object 0" }; void Processor::flush_buffer() { @@ -74,7 +74,7 @@ void Processor::flush_buffer() { // Send the buffer to the output streams _buffer[_bufPos] = '\0'; - + _locked = true; stream_word(_buffer); _locked = false; diff --git a/engines/glk/frotz/processor_input.cpp b/engines/glk/frotz/processor_input.cpp index af5c7dc42c..7c1453d663 100644 --- a/engines/glk/frotz/processor_input.cpp +++ b/engines/glk/frotz/processor_input.cpp @@ -28,30 +28,30 @@ namespace Frotz { #define INPUT_BUFFER_SIZE 200 bool Processor::read_yes_or_no(const char *s) { - zchar key; + zchar key; - print_string(s); - print_string("? (y/n) >"); + print_string(s); + print_string("? (y/n) >"); - key = stream_read_key(0, 0, false); + key = stream_read_key(0, 0, false); - if (key == 'y' || key == 'Y') { + if (key == 'y' || key == 'Y') { print_string("y\n"); return true; - } else { + } else { print_string("n\n"); return false; - } + } } void Processor::read_string(int max, zchar *buffer) { - zchar key; + zchar key; - buffer[0] = 0; + buffer[0] = 0; - do { + do { key = stream_read_input(max, buffer, 0, 0, false, false); - } while (key != ZC_RETURN); + } while (key != ZC_RETURN); } bool Processor::is_terminator(zchar key) { @@ -88,64 +88,64 @@ void Processor::z_make_menu() { } int Processor::read_number() { - zchar buffer[6]; - int value = 0; - int i; + zchar buffer[6]; + int value = 0; + int i; - read_string(5, buffer); + read_string(5, buffer); - for (i = 0; buffer[i] != 0; i++) + for (i = 0; buffer[i] != 0; i++) if (buffer[i] >= '0' && buffer[i] <= '9') - value = 10 * value + buffer[i] - '0'; + value = 10 * value + buffer[i] - '0'; - return value; + return value; } 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) + 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]; + // Get maximum input size + addr = zargs[0]; LOW_BYTE(addr, max); - if (h_version <= V4) + if (h_version <= V4) max--; - if (max >= INPUT_BUFFER_SIZE) + if (max >= INPUT_BUFFER_SIZE) max = INPUT_BUFFER_SIZE - 1; - // Get initial input size - if (h_version >= V5) { + // 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++) { + // 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; + } + buffer[i] = 0; - // Draw status line for V1 to V3 games - if (h_version <= V3) + // 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( + // Read input from current input stream + key = stream_read_input( max, buffer, // buffer and size zargs[2], // timeout value zargs[3], // timeout routine @@ -156,67 +156,67 @@ void Processor::z_read() { if (key == ZC_BAD) return; - // Perform save_undo for V1 to V4 games - if (h_version <= V4) + // 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++) { + // 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) + // Add null character (V1-V4) or write input length into 2nd byte + if (h_version <= V4) storeb((zword) (zargs[0] + 1 + i), 0); - else + else storeb((zword) (zargs[0] + 1), i); - // Tokenise line if a token buffer is present - if (key == ZC_RETURN && zargs[1] != 0) + // 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 key + if (h_version >= V5) store(translate_to_zscii(key)); } void Processor::z_read_char() { - zchar key; + zchar key; - // Supply default arguments - if (zargc < 2) + // Supply default arguments + if (zargc < 2) zargs[1] = 0; - // Read input from the current input stream - key = stream_read_key( + // Read input from the current input stream + key = stream_read_key( zargs[1], // timeout value zargs[2], // timeout routine false // enable hot keys ); - + if (key == ZC_BAD) return; - // Store key - store (translate_to_zscii (key)); + // Store key + store (translate_to_zscii (key)); } void Processor::z_read_mouse(){ - zword btn; + zword btn; - // Read the mouse position, the last menu click and which buttons are down - btn = os_read_mouse(); - hx_mouse_y = mouse_y; - hx_mouse_x = mouse_x; + // Read the mouse position, the last menu click and which buttons are down + btn = os_read_mouse(); + hx_mouse_y = mouse_y; + hx_mouse_x = mouse_x; - storew((zword) (zargs[0] + 0), hx_mouse_y); - storew((zword) (zargs[0] + 2), hx_mouse_x); - storew((zword) (zargs[0] + 4), btn); // mouse button bits - storew((zword) (zargs[0] + 6), menu_selected); // menu selection + storew((zword) (zargs[0] + 0), hx_mouse_y); + storew((zword) (zargs[0] + 2), hx_mouse_x); + storew((zword) (zargs[0] + 4), btn); // mouse button bits + storew((zword) (zargs[0] + 6), menu_selected); // menu selection } } // End of namespace Scott diff --git a/engines/glk/frotz/processor_maths.cpp b/engines/glk/frotz/processor_maths.cpp index 5a2a522cc2..79ff65c5f4 100644 --- a/engines/glk/frotz/processor_maths.cpp +++ b/engines/glk/frotz/processor_maths.cpp @@ -26,29 +26,29 @@ namespace Glk { namespace Frotz { void Processor::z_add() { - store((zword)((short)zargs[0] + (short)zargs[1])); + store((zword)((short)zargs[0] + (short)zargs[1])); } void Processor::z_and() { - store((zword)(zargs[0] & zargs[1])); + store((zword)(zargs[0] & zargs[1])); } void Processor::z_art_shift() { - if ((short)zargs[1] > 0) + if ((short)zargs[1] > 0) store((zword)((short)zargs[0] << (short)zargs[1])); - else + else store((zword)((short)zargs[0] >> - (short)zargs[1])); } void Processor::z_div() { - if (zargs[1] == 0) + if (zargs[1] == 0) runtimeError(ERR_DIV_ZERO); - store((zword)((short)zargs[0] / (short)zargs[1])); + store((zword)((short)zargs[0] / (short)zargs[1])); } void Processor::z_je() { - branch( + branch( zargc > 1 && (zargs[0] == zargs[1] || ( zargc > 2 && (zargs[0] == zargs[2] || ( zargc > 3 && (zargs[0] == zargs[3]))))) @@ -56,45 +56,45 @@ void Processor::z_je() { } void Processor::z_jg() { - branch((short)zargs[0] > (short)zargs[1]); + branch((short)zargs[0] > (short)zargs[1]); } void Processor::z_jl() { - branch((short)zargs[0] < (short)zargs[1]); + branch((short)zargs[0] < (short)zargs[1]); } void Processor::z_jz() { - branch((short)zargs[0] == 0); + branch((short)zargs[0] == 0); } void Processor::z_log_shift() { - if ((short)zargs[1] > 0) + if ((short)zargs[1] > 0) store((zword)(zargs[0] << (short)zargs[1])); - else + else store((zword)(zargs[0] >> - (short)zargs[1])); } void Processor::z_mod() { - if (zargs[1] == 0) + if (zargs[1] == 0) runtimeError(ERR_DIV_ZERO); - store((zword)((short)zargs[0] % (short)zargs[1])); + store((zword)((short)zargs[0] % (short)zargs[1])); } void Processor::z_mul() { - store((zword)((short)zargs[0] * (short)zargs[1])); + store((zword)((short)zargs[0] * (short)zargs[1])); } void Processor::z_not() { - store((zword)~zargs[0]); + store((zword)~zargs[0]); } void Processor::z_or() { - store((zword)(zargs[0] | zargs[1])); + store((zword)(zargs[0] | zargs[1])); } void Processor::z_sub() { - store((zword)((short)zargs[0] - (short)zargs[1])); + store((zword)((short)zargs[0] - (short)zargs[1])); } void Processor::z_test() { diff --git a/engines/glk/frotz/processor_objects.cpp b/engines/glk/frotz/processor_objects.cpp index 13e8a11518..d60dd8b65e 100644 --- a/engines/glk/frotz/processor_objects.cpp +++ b/engines/glk/frotz/processor_objects.cpp @@ -44,688 +44,688 @@ enum O4 { }; zword Processor::object_address(zword obj) { - // Check object number - if (obj > ((h_version <= V3) ? 255 : MAX_OBJECT)) { - print_string("@Attempt to address illegal object "); - print_num(obj); - print_string(". This is normally fatal."); - new_line(); - runtimeError(ERR_ILL_OBJ); - } - - // Return object address - if (h_version <= V3) - return h_objects + ((obj - 1) * O1_SIZE + 62); - else - return h_objects + ((obj - 1) * O4_SIZE + 126); + // Check object number + if (obj > ((h_version <= V3) ? 255 : MAX_OBJECT)) { + print_string("@Attempt to address illegal object "); + print_num(obj); + print_string(". This is normally fatal."); + new_line(); + runtimeError(ERR_ILL_OBJ); + } + + // Return object address + if (h_version <= V3) + return h_objects + ((obj - 1) * O1_SIZE + 62); + else + return h_objects + ((obj - 1) * O4_SIZE + 126); } zword Processor::object_name(zword object) { - zword obj_addr; - zword name_addr; + zword obj_addr; + zword name_addr; - obj_addr = object_address(object); + obj_addr = object_address(object); - // The object name address is found at the start of the properties - if (h_version <= V3) - obj_addr += O1_PROPERTY_OFFSET; - else - obj_addr += O4_PROPERTY_OFFSET; + // The object name address is found at the start of the properties + if (h_version <= V3) + obj_addr += O1_PROPERTY_OFFSET; + else + obj_addr += O4_PROPERTY_OFFSET; LOW_WORD(obj_addr, name_addr); - return name_addr; + return name_addr; } zword Processor::first_property(zword obj) { - zword prop_addr; - zbyte size; + zword prop_addr; + zbyte size; - // Fetch address of object name - prop_addr = object_name (obj); + // Fetch address of object name + prop_addr = object_name (obj); - // Get length of object name + // Get length of object name LOW_BYTE(prop_addr, size); - // Add name length to pointer - return prop_addr + 1 + 2 * size; + // Add name length to pointer + return prop_addr + 1 + 2 * size; } zword Processor::next_property(zword prop_addr) { - zbyte value; + zbyte value; - // Load the current property id + // Load the current property id LOW_BYTE(prop_addr, value); - prop_addr++; - - // Calculate the length of this property - if (h_version <= V3) - value >>= 5; - else if (!(value & 0x80)) - value >>= 6; - else { + prop_addr++; + + // Calculate the length of this property + if (h_version <= V3) + value >>= 5; + else if (!(value & 0x80)) + value >>= 6; + else { LOW_BYTE(prop_addr, value); - value &= 0x3f; + value &= 0x3f; - if (value == 0) + if (value == 0) // demanded by Spec 1.0 value = 64; - } + } - // Add property length to current property pointer - return prop_addr + value + 1; + // Add property length to current property pointer + return prop_addr + value + 1; } void Processor::unlink_object(zword object) { - zword obj_addr; - zword parent_addr; - zword sibling_addr; + zword obj_addr; + zword parent_addr; + zword sibling_addr; - if (object == 0) { - runtimeError(ERR_REMOVE_OBJECT_0); - return; - } + if (object == 0) { + runtimeError(ERR_REMOVE_OBJECT_0); + return; + } - obj_addr = object_address(object); + obj_addr = object_address(object); - if (h_version <= V3) { + if (h_version <= V3) { - zbyte parent; - zbyte younger_sibling; - zbyte older_sibling; - zbyte zero = 0; + zbyte parent; + zbyte younger_sibling; + zbyte older_sibling; + zbyte zero = 0; - // Get parent of object, and return if no parent - obj_addr += O1_PARENT; + // Get parent of object, and return if no parent + obj_addr += O1_PARENT; LOW_BYTE(obj_addr, parent); - if (!parent) - return; + if (!parent) + return; - // Get (older) sibling of object and set both parent and sibling pointers to 0 + // Get (older) sibling of object and set both parent and sibling pointers to 0 SET_BYTE(obj_addr, zero); - obj_addr += O1_SIBLING - O1_PARENT; + obj_addr += O1_SIBLING - O1_PARENT; LOW_BYTE(obj_addr, older_sibling); SET_BYTE(obj_addr, zero); - // Get first child of parent (the youngest sibling of the object) - parent_addr = object_address(parent) + O1_CHILD; + // Get first child of parent (the youngest sibling of the object) + parent_addr = object_address(parent) + O1_CHILD; LOW_BYTE(parent_addr, younger_sibling); - // Remove object from the list of siblings + // Remove object from the list of siblings if (younger_sibling == object) SET_BYTE(parent_addr, older_sibling); - else { - do { - sibling_addr = object_address(younger_sibling) + O1_SIBLING; + else { + do { + sibling_addr = object_address(younger_sibling) + O1_SIBLING; LOW_BYTE(sibling_addr, younger_sibling); - } while (younger_sibling != object); + } while (younger_sibling != object); SET_BYTE(sibling_addr, older_sibling); - } - } else { - zword parent; - zword younger_sibling; - zword older_sibling; - zword zero = 0; - - // Get parent of object, and return if no parent - obj_addr += O4_PARENT; + } + } else { + zword parent; + zword younger_sibling; + zword older_sibling; + zword zero = 0; + + // Get parent of object, and return if no parent + obj_addr += O4_PARENT; LOW_WORD(obj_addr, parent); - if (!parent) - return; + if (!parent) + return; - // Get (older) sibling of object and set both parent and sibling pointers to 0 + // Get (older) sibling of object and set both parent and sibling pointers to 0 SET_WORD(obj_addr, zero); - obj_addr += O4_SIBLING - O4_PARENT; + obj_addr += O4_SIBLING - O4_PARENT; LOW_WORD(obj_addr, older_sibling); SET_WORD(obj_addr, zero); - // Get first child of parent (the youngest sibling of the object) - parent_addr = object_address(parent) + O4_CHILD; + // Get first child of parent (the youngest sibling of the object) + parent_addr = object_address(parent) + O4_CHILD; LOW_WORD(parent_addr, younger_sibling); - // Remove object from the list of siblings + // Remove object from the list of siblings if (younger_sibling == object) { SET_WORD(parent_addr, older_sibling); } else { - do { - sibling_addr = object_address(younger_sibling) + O4_SIBLING; + do { + sibling_addr = object_address(younger_sibling) + O4_SIBLING; LOW_WORD(sibling_addr, younger_sibling); - } while (younger_sibling != object); + } while (younger_sibling != object); SET_WORD(sibling_addr, older_sibling); - } - } + } + } } void Processor::z_clear_attr() { - zword obj_addr; - zbyte value; - - if (_storyId == SHERLOCK) - if (zargs[1] == 48) - return; - - if (zargs[1] > ((h_version <= V3) ? 31 : 47)) - runtimeError(ERR_ILL_ATTR); - - // If we are monitoring attribute assignment display a short note - if (_attribute_assignment) { - stream_mssg_on(); - print_string("@clear_attr "); - print_object(zargs[0]); - print_string(" "); - print_num(zargs[1]); - stream_mssg_off(); - } - - if (zargs[0] == 0) { - runtimeError(ERR_CLEAR_ATTR_0); - return; - } - - // Get attribute address - obj_addr = object_address(zargs[0]) + zargs[1] / 8; - - // Clear attribute bit + zword obj_addr; + zbyte value; + + if (_storyId == SHERLOCK) + if (zargs[1] == 48) + return; + + if (zargs[1] > ((h_version <= V3) ? 31 : 47)) + runtimeError(ERR_ILL_ATTR); + + // If we are monitoring attribute assignment display a short note + if (_attribute_assignment) { + stream_mssg_on(); + print_string("@clear_attr "); + print_object(zargs[0]); + print_string(" "); + print_num(zargs[1]); + stream_mssg_off(); + } + + if (zargs[0] == 0) { + runtimeError(ERR_CLEAR_ATTR_0); + return; + } + + // Get attribute address + obj_addr = object_address(zargs[0]) + zargs[1] / 8; + + // Clear attribute bit LOW_BYTE(obj_addr, value); - value &= ~(0x80 >> (zargs[1] & 7)); + value &= ~(0x80 >> (zargs[1] & 7)); SET_BYTE(obj_addr, value); } void Processor::z_jin() { - zword obj_addr; - - // If we are monitoring object locating display a short note - if (_object_locating) { - stream_mssg_on(); - print_string("@jin "); - print_object(zargs[0]); - print_string(" "); - print_object(zargs[1]); - stream_mssg_off(); - } - - if (zargs[0] == 0) { - runtimeError(ERR_JIN_0); - branch(0 == zargs[1]); - return; - } - - obj_addr = object_address(zargs[0]); - - if (h_version <= V3) { - zbyte parent; - - // Get parent id from object - obj_addr += O1_PARENT; + zword obj_addr; + + // If we are monitoring object locating display a short note + if (_object_locating) { + stream_mssg_on(); + print_string("@jin "); + print_object(zargs[0]); + print_string(" "); + print_object(zargs[1]); + stream_mssg_off(); + } + + if (zargs[0] == 0) { + runtimeError(ERR_JIN_0); + branch(0 == zargs[1]); + return; + } + + obj_addr = object_address(zargs[0]); + + if (h_version <= V3) { + zbyte parent; + + // Get parent id from object + obj_addr += O1_PARENT; LOW_BYTE(obj_addr, parent); - // Branch if the parent is obj2 - branch(parent == zargs[1]); + // Branch if the parent is obj2 + branch(parent == zargs[1]); - } else { - zword parent; + } else { + zword parent; - // Get parent id from object - obj_addr += O4_PARENT; + // Get parent id from object + obj_addr += O4_PARENT; LOW_WORD(obj_addr, parent); - // Branch if the parent is obj2 - branch(parent == zargs[1]); - } + // Branch if the parent is obj2 + branch(parent == zargs[1]); + } } void Processor::z_get_child() { - zword obj_addr; - - // If we are monitoring object locating display a short note - if (_object_locating) { - stream_mssg_on(); - print_string("@get_child "); - print_object(zargs[0]); - stream_mssg_off(); - } - - if (zargs[0] == 0) { - runtimeError(ERR_GET_CHILD_0); - store(0); - branch(false); - return; - } - - obj_addr = object_address(zargs[0]); - - if (h_version <= V3) { - zbyte child; - - // Get child id from object - obj_addr += O1_CHILD; + zword obj_addr; + + // If we are monitoring object locating display a short note + if (_object_locating) { + stream_mssg_on(); + print_string("@get_child "); + print_object(zargs[0]); + stream_mssg_off(); + } + + if (zargs[0] == 0) { + runtimeError(ERR_GET_CHILD_0); + store(0); + branch(false); + return; + } + + obj_addr = object_address(zargs[0]); + + if (h_version <= V3) { + zbyte child; + + // Get child id from object + obj_addr += O1_CHILD; LOW_BYTE(obj_addr, child); - // Store child id and branch - store(child); - branch(child); - } else { - zword child; + // Store child id and branch + store(child); + branch(child); + } else { + zword child; - // Get child id from object - obj_addr += O4_CHILD; + // Get child id from object + obj_addr += O4_CHILD; LOW_WORD(obj_addr, child); - // Store child id and branch - store(child); - branch(child); - } + // Store child id and branch + store(child); + branch(child); + } } void Processor::z_get_next_prop() { - zword prop_addr; - zbyte value; - zbyte mask; + zword prop_addr; + zbyte value; + zbyte mask; - if (zargs[0] == 0) { - runtimeError(ERR_GET_NEXT_PROP_0); - store(0); - return; - } + if (zargs[0] == 0) { + runtimeError(ERR_GET_NEXT_PROP_0); + store(0); + return; + } - // Property id is in bottom five (six) bits - mask = (h_version <= V3) ? 0x1f : 0x3f; + // Property id is in bottom five (six) bits + mask = (h_version <= V3) ? 0x1f : 0x3f; - // Load address of first property - prop_addr = first_property(zargs[0]); + // Load address of first property + prop_addr = first_property(zargs[0]); - if (zargs[1] != 0) { - // Scan down the property list - do { + if (zargs[1] != 0) { + // Scan down the property list + do { LOW_BYTE(prop_addr, value); - prop_addr = next_property(prop_addr); - } while ((value & mask) > zargs[1]); + prop_addr = next_property(prop_addr); + } while ((value & mask) > zargs[1]); - // Exit if the property does not exist - if ((value & mask) != zargs[1]) - runtimeError(ERR_NO_PROP); - } + // Exit if the property does not exist + if ((value & mask) != zargs[1]) + runtimeError(ERR_NO_PROP); + } - // Return the property id + // Return the property id LOW_BYTE(prop_addr, value); - store((zword) (value & mask)); + store((zword) (value & mask)); } void Processor::z_get_parent() { - zword obj_addr; - - // If we are monitoring object locating display a short note - if (_object_locating) { - stream_mssg_on(); - print_string("@get_parent "); - print_object(zargs[0]); - stream_mssg_off(); - } + zword obj_addr; + + // If we are monitoring object locating display a short note + if (_object_locating) { + stream_mssg_on(); + print_string("@get_parent "); + print_object(zargs[0]); + stream_mssg_off(); + } - if (zargs[0] == 0) { - runtimeError(ERR_GET_PARENT_0); - store(0); - return; - } + if (zargs[0] == 0) { + runtimeError(ERR_GET_PARENT_0); + store(0); + return; + } - obj_addr = object_address(zargs[0]); + obj_addr = object_address(zargs[0]); - if (h_version <= V3) { - zbyte parent; + if (h_version <= V3) { + zbyte parent; - // Get parent id from object - obj_addr += O1_PARENT; + // Get parent id from object + obj_addr += O1_PARENT; LOW_BYTE(obj_addr, parent); - // Store parent - store(parent); + // Store parent + store(parent); } else { - zword parent; + zword parent; - // Get parent id from object - obj_addr += O4_PARENT; + // Get parent id from object + obj_addr += O4_PARENT; LOW_WORD(obj_addr, parent); - // Store parent - store(parent); - } + // Store parent + store(parent); + } } void Processor::z_get_prop() { - zword prop_addr; - zword wprop_val; - zbyte bprop_val; - zbyte value; - zbyte mask; - - if (zargs[0] == 0) { - runtimeError(ERR_GET_PROP_0); - store(0); - return; - } - - // Property id is in bottom five (six) bits - mask = (h_version <= V3) ? 0x1f : 0x3f; - - // Load address of first property - prop_addr = first_property(zargs[0]); - - // Scan down the property list - for (;;) { + zword prop_addr; + zword wprop_val; + zbyte bprop_val; + zbyte value; + zbyte mask; + + if (zargs[0] == 0) { + runtimeError(ERR_GET_PROP_0); + store(0); + return; + } + + // Property id is in bottom five (six) bits + mask = (h_version <= V3) ? 0x1f : 0x3f; + + // Load address of first property + prop_addr = first_property(zargs[0]); + + // Scan down the property list + for (;;) { LOW_BYTE(prop_addr, value); - if ((value & mask) <= zargs[1]) - break; - prop_addr = next_property(prop_addr); - } + if ((value & mask) <= zargs[1]) + break; + prop_addr = next_property(prop_addr); + } - if ((value & mask) == zargs[1]) { + if ((value & mask) == zargs[1]) { // property found - // Load property(byte or word sized) - prop_addr++; + // Load property(byte or word sized) + prop_addr++; - if ((h_version <= V3 && !(value & 0xe0)) || (h_version >= V4 && !(value & 0xc0))) { + if ((h_version <= V3 && !(value & 0xe0)) || (h_version >= V4 && !(value & 0xc0))) { LOW_BYTE(prop_addr, bprop_val); - wprop_val = bprop_val; + wprop_val = bprop_val; } else { LOW_WORD(prop_addr, wprop_val); } - } else { + } else { // property not found - // Load default value - prop_addr = h_objects + 2 * (zargs[1] - 1); + // Load default value + prop_addr = h_objects + 2 * (zargs[1] - 1); LOW_WORD(prop_addr, wprop_val); - } + } - // Store the property value - store(wprop_val); + // Store the property value + store(wprop_val); } void Processor::z_get_prop_addr() { - zword prop_addr; - zbyte value; - zbyte mask; + zword prop_addr; + zbyte value; + zbyte mask; - if (zargs[0] == 0) { - runtimeError(ERR_GET_PROP_ADDR_0); - store(0); - return; - } + if (zargs[0] == 0) { + runtimeError(ERR_GET_PROP_ADDR_0); + store(0); + return; + } - if (_storyId == BEYOND_ZORK) - if (zargs[0] > MAX_OBJECT) - { store(0); return; } + if (_storyId == BEYOND_ZORK) + if (zargs[0] > MAX_OBJECT) + { store(0); return; } - // Property id is in bottom five (six) bits - mask = (h_version <= V3) ? 0x1f : 0x3f; + // Property id is in bottom five (six) bits + mask = (h_version <= V3) ? 0x1f : 0x3f; - // Load address of first property - prop_addr = first_property(zargs[0]); + // Load address of first property + prop_addr = first_property(zargs[0]); - // Scan down the property list - for (;;) { + // Scan down the property list + for (;;) { LOW_BYTE(prop_addr, value); - if ((value & mask) <= zargs[1]) - break; - prop_addr = next_property(prop_addr); - } + if ((value & mask) <= zargs[1]) + break; + prop_addr = next_property(prop_addr); + } - // Calculate the property address or return zero - if ((value & mask) == zargs[1]) { + // Calculate the property address or return zero + if ((value & mask) == zargs[1]) { - if (h_version >= V4 && (value & 0x80)) - prop_addr++; - store((zword) (prop_addr + 1)); + if (h_version >= V4 && (value & 0x80)) + prop_addr++; + store((zword) (prop_addr + 1)); - } else { + } else { store(0); } } void Processor::z_get_prop_len() { - zword addr; - zbyte value; + zword addr; + zbyte value; - // Back up the property pointer to the property id - addr = zargs[0] - 1; + // Back up the property pointer to the property id + addr = zargs[0] - 1; LOW_BYTE(addr, value); - // Calculate length of property - if (h_version <= V3) - value = (value >> 5) + 1; - else if (!(value & 0x80)) - value = (value >> 6) + 1; - else { - value &= 0x3f; + // Calculate length of property + if (h_version <= V3) + value = (value >> 5) + 1; + else if (!(value & 0x80)) + value = (value >> 6) + 1; + else { + value &= 0x3f; - if (value == 0) + if (value == 0) value = 64; // demanded by Spec 1.0 - } + } - // Store length of property - store(value); + // Store length of property + store(value); } void Processor::z_get_sibling() { - zword obj_addr; + zword obj_addr; - if (zargs[0] == 0) { - runtimeError(ERR_GET_SIBLING_0); - store(0); - branch(false); - return; - } + if (zargs[0] == 0) { + runtimeError(ERR_GET_SIBLING_0); + store(0); + branch(false); + return; + } - obj_addr = object_address(zargs[0]); + obj_addr = object_address(zargs[0]); - if (h_version <= V3) { - zbyte sibling; + if (h_version <= V3) { + zbyte sibling; - // Get sibling id from object - obj_addr += O1_SIBLING; + // Get sibling id from object + obj_addr += O1_SIBLING; LOW_BYTE(obj_addr, sibling); - // Store sibling and branch - store(sibling); - branch(sibling); + // Store sibling and branch + store(sibling); + branch(sibling); } else { - zword sibling; + zword sibling; - // Get sibling id from object - obj_addr += O4_SIBLING; + // Get sibling id from object + obj_addr += O4_SIBLING; LOW_WORD(obj_addr, sibling); - // Store sibling and branch - store(sibling); - branch(sibling); - } + // Store sibling and branch + store(sibling); + branch(sibling); + } } void Processor::z_insert_obj() { - zword obj1 = zargs[0]; - zword obj2 = zargs[1]; - zword obj1_addr; - zword obj2_addr; - - // If we are monitoring object movements display a short note - if (_object_movement) { - stream_mssg_on(); - print_string("@move_obj "); - print_object(obj1); - print_string(" "); - print_object(obj2); - stream_mssg_off(); - } - - if (obj1 == 0) { - runtimeError(ERR_MOVE_OBJECT_0); - return; - } - - if (obj2 == 0) { - runtimeError(ERR_MOVE_OBJECT_TO_0); - return; - } - - // Get addresses of both objects - obj1_addr = object_address(obj1); - obj2_addr = object_address(obj2); - - // Remove object 1 from current parent - unlink_object(obj1); - - // Make object 1 first child of object 2 - if (h_version <= V3) { - zbyte child; - - obj1_addr += O1_PARENT; + zword obj1 = zargs[0]; + zword obj2 = zargs[1]; + zword obj1_addr; + zword obj2_addr; + + // If we are monitoring object movements display a short note + if (_object_movement) { + stream_mssg_on(); + print_string("@move_obj "); + print_object(obj1); + print_string(" "); + print_object(obj2); + stream_mssg_off(); + } + + if (obj1 == 0) { + runtimeError(ERR_MOVE_OBJECT_0); + return; + } + + if (obj2 == 0) { + runtimeError(ERR_MOVE_OBJECT_TO_0); + return; + } + + // Get addresses of both objects + obj1_addr = object_address(obj1); + obj2_addr = object_address(obj2); + + // Remove object 1 from current parent + unlink_object(obj1); + + // Make object 1 first child of object 2 + if (h_version <= V3) { + zbyte child; + + obj1_addr += O1_PARENT; SET_BYTE(obj1_addr, obj2); - obj2_addr += O1_CHILD; + obj2_addr += O1_CHILD; LOW_BYTE(obj2_addr, child); SET_BYTE(obj2_addr, obj1); - obj1_addr += O1_SIBLING - O1_PARENT; + obj1_addr += O1_SIBLING - O1_PARENT; SET_BYTE(obj1_addr, child); - } else { - zword child; + } else { + zword child; - obj1_addr += O4_PARENT; + obj1_addr += O4_PARENT; SET_WORD(obj1_addr, obj2); - obj2_addr += O4_CHILD; + obj2_addr += O4_CHILD; LOW_WORD(obj2_addr, child); SET_WORD(obj2_addr, obj1); - obj1_addr += O4_SIBLING - O4_PARENT; + obj1_addr += O4_SIBLING - O4_PARENT; SET_WORD(obj1_addr, child); - } + } } void Processor::z_put_prop() { - zword prop_addr; - zword value; - zbyte mask; + zword prop_addr; + zword value; + zbyte mask; - if (zargs[0] == 0) { - runtimeError(ERR_PUT_PROP_0); - return; - } + if (zargs[0] == 0) { + runtimeError(ERR_PUT_PROP_0); + return; + } - // Property id is in bottom five or six bits - mask = (h_version <= V3) ? 0x1f : 0x3f; + // Property id is in bottom five or six bits + mask = (h_version <= V3) ? 0x1f : 0x3f; - // Load address of first property - prop_addr = first_property(zargs[0]); + // Load address of first property + prop_addr = first_property(zargs[0]); - // Scan down the property list - for (;;) { + // Scan down the property list + for (;;) { LOW_BYTE(prop_addr, value); - if ((value & mask) <= zargs[1]) - break; + if ((value & mask) <= zargs[1]) + break; - prop_addr = next_property(prop_addr); - } + prop_addr = next_property(prop_addr); + } - // Exit if the property does not exist - if ((value & mask) != zargs[1]) - runtimeError(ERR_NO_PROP); + // Exit if the property does not exist + if ((value & mask) != zargs[1]) + runtimeError(ERR_NO_PROP); - // Store the new property value (byte or word sized) - prop_addr++; + // Store the new property value (byte or word sized) + prop_addr++; - if ((h_version <= V3 && !(value & 0xe0)) || (h_version >= V4 && !(value & 0xc0))) { - zbyte v = zargs[2]; + if ((h_version <= V3 && !(value & 0xe0)) || (h_version >= V4 && !(value & 0xc0))) { + zbyte v = zargs[2]; SET_BYTE(prop_addr, v); - } else { - zword v = zargs[2]; + } else { + zword v = zargs[2]; SET_WORD(prop_addr, v); - } + } } void Processor::z_remove_obj() { - // If we are monitoring object movements display a short note - if (_object_movement) { - stream_mssg_on(); - print_string("@remove_obj "); - print_object(zargs[0]); - stream_mssg_off(); - } - - // Call unlink_object to do the job - unlink_object(zargs[0]); + // If we are monitoring object movements display a short note + if (_object_movement) { + stream_mssg_on(); + print_string("@remove_obj "); + print_object(zargs[0]); + stream_mssg_off(); + } + + // Call unlink_object to do the job + unlink_object(zargs[0]); } void Processor::z_set_attr() { - zword obj_addr; - zbyte value; - - if (_storyId == SHERLOCK) - if (zargs[1] == 48) - return; - - if (zargs[1] > ((h_version <= V3) ? 31 : 47)) - runtimeError(ERR_ILL_ATTR); - - // If we are monitoring attribute assignment display a short note - if (_attribute_assignment) { - stream_mssg_on(); - print_string("@set_attr "); - print_object(zargs[0]); - print_string(" "); - print_num(zargs[1]); - stream_mssg_off(); - } - - if (zargs[0] == 0) { - runtimeError(ERR_SET_ATTR_0); - return; - } - - // Get attribute address - obj_addr = object_address(zargs[0]) + zargs[1] / 8; - - // Load attribute byte + zword obj_addr; + zbyte value; + + if (_storyId == SHERLOCK) + if (zargs[1] == 48) + return; + + if (zargs[1] > ((h_version <= V3) ? 31 : 47)) + runtimeError(ERR_ILL_ATTR); + + // If we are monitoring attribute assignment display a short note + if (_attribute_assignment) { + stream_mssg_on(); + print_string("@set_attr "); + print_object(zargs[0]); + print_string(" "); + print_num(zargs[1]); + stream_mssg_off(); + } + + if (zargs[0] == 0) { + runtimeError(ERR_SET_ATTR_0); + return; + } + + // Get attribute address + obj_addr = object_address(zargs[0]) + zargs[1] / 8; + + // Load attribute byte LOW_BYTE(obj_addr, value); - // Set attribute bit - value |= 0x80 >> (zargs[1] & 7); + // Set attribute bit + value |= 0x80 >> (zargs[1] & 7); - // Store attribute byte + // Store attribute byte SET_BYTE(obj_addr, value); } void Processor::z_test_attr() { - zword obj_addr; - zbyte value; - - if (zargs[1] > ((h_version <= V3) ? 31 : 47)) - runtimeError(ERR_ILL_ATTR); - - // If we are monitoring attribute testing display a short note - if (_attribute_testing) { - stream_mssg_on(); - print_string("@test_attr "); - print_object(zargs[0]); - print_string(" "); - print_num(zargs[1]); - stream_mssg_off(); - } - - if (zargs[0] == 0) { - runtimeError(ERR_TEST_ATTR_0); - branch(false); - return; - } - - // Get attribute address - obj_addr = object_address(zargs[0]) + zargs[1] / 8; - - // Load attribute byte + zword obj_addr; + zbyte value; + + if (zargs[1] > ((h_version <= V3) ? 31 : 47)) + runtimeError(ERR_ILL_ATTR); + + // If we are monitoring attribute testing display a short note + if (_attribute_testing) { + stream_mssg_on(); + print_string("@test_attr "); + print_object(zargs[0]); + print_string(" "); + print_num(zargs[1]); + stream_mssg_off(); + } + + if (zargs[0] == 0) { + runtimeError(ERR_TEST_ATTR_0); + branch(false); + return; + } + + // Get attribute address + obj_addr = object_address(zargs[0]) + zargs[1] / 8; + + // Load attribute byte LOW_BYTE(obj_addr, value); - // Test attribute - branch(value & (0x80 >> (zargs[1] & 7))); + // Test attribute + branch(value & (0x80 >> (zargs[1] & 7))); } } // End of namespace Scott diff --git a/engines/glk/frotz/processor_streams.cpp b/engines/glk/frotz/processor_streams.cpp index 095ef247fd..11f7932a28 100644 --- a/engines/glk/frotz/processor_streams.cpp +++ b/engines/glk/frotz/processor_streams.cpp @@ -35,16 +35,16 @@ zchar Processor::console_read_key(zword timeout) { } void Processor::scrollback_char(zchar c) { - if (c == ZC_INDENT) - { scrollback_char (' '); scrollback_char (' '); scrollback_char (' '); return; } - if (c == ZC_GAP) - { scrollback_char (' '); scrollback_char (' '); return; } + if (c == ZC_INDENT) + { scrollback_char (' '); scrollback_char (' '); scrollback_char (' '); return; } + if (c == ZC_GAP) + { scrollback_char (' '); scrollback_char (' '); return; } - os_scrollback_char(c); + os_scrollback_char(c); } void Processor::scrollback_word(const zchar *s) { - int i; + int i; for (i = 0; s[i] != 0; i++) { if (s[i] == ZC_NEW_FONT || s[i] == ZC_NEW_STYLE) @@ -55,149 +55,149 @@ void Processor::scrollback_word(const zchar *s) { } void Processor::scrollback_write_input(const zchar *buf, zchar key) { - int i; + int i; - for (i = 0; buf[i] != 0; i++) - scrollback_char (buf[i]); + for (i = 0; buf[i] != 0; i++) + scrollback_char (buf[i]); - if (key == ZC_RETURN) - scrollback_char ('\n'); + if (key == ZC_RETURN) + scrollback_char ('\n'); } void Processor::scrollback_erase_input(const zchar *buf) { - int width; - int i; + int width; + int i; - for (i = 0, width = 0; buf[i] != 0; i++) - width++; + for (i = 0, width = 0; buf[i] != 0; i++) + width++; - os_scrollback_erase(width); + os_scrollback_erase(width); } void Processor::stream_mssg_on() { - flush_buffer(); + flush_buffer(); - if (ostream_screen) - screen_mssg_on(); - if (ostream_script && enable_scripting) + if (ostream_screen) + screen_mssg_on(); + if (ostream_script && enable_scripting) script_mssg_on(); - message = true; + message = true; } void Processor::stream_mssg_off() { - flush_buffer(); + flush_buffer(); - if (ostream_screen) + if (ostream_screen) screen_mssg_off(); - if (ostream_script && enable_scripting) + if (ostream_script && enable_scripting) script_mssg_off(); - message = false; + message = false; } void Processor::stream_char(zchar c) { - if (ostream_screen) + if (ostream_screen) screen_char(c); - if (ostream_script && enable_scripting) + if (ostream_script && enable_scripting) script_char(c); - if (enable_scripting) + if (enable_scripting) scrollback_char(c); } void Processor::stream_word(const zchar *s) { - if (ostream_memory && !message) + if (ostream_memory && !message) memory_word(s); - else { + else { if (ostream_screen) screen_word(s); if (ostream_script && enable_scripting) script_word(s); if (enable_scripting) scrollback_word(s); - } + } } void Processor::stream_new_line() { - if (ostream_memory && !message) + if (ostream_memory && !message) memory_new_line(); - else { + else { if (ostream_screen) screen_new_line(); if (ostream_script && enable_scripting) script_new_line(); if (enable_scripting) os_scrollback_char ('\n'); - } + } } zchar Processor::stream_read_key(zword timeout, zword routine, bool hot_keys) { - zchar key = ZC_BAD; + zchar key = ZC_BAD; - flush_buffer(); + flush_buffer(); - // Read key from current input stream + // Read key from current input stream continue_input: - do { + do { if (istream_replay) key = replay_read_key(); else key = console_read_key(timeout); if (shouldQuit()) return ZC_BAD; - } while (key == ZC_BAD); + } while (key == ZC_BAD); - // Copy key to the command file - if (ostream_record && !istream_replay) + // Copy key to the command file + if (ostream_record && !istream_replay) record_write_key(key); - // Handle timeouts - if (key == ZC_TIME_OUT) + // Handle timeouts + if (key == ZC_TIME_OUT) if (direct_call (routine) == 0) goto continue_input; - // Return key - return key; + // Return key + return key; } zchar Processor::stream_read_input(int max, zchar *buf, zword timeout, zword routine, bool hot_keys, bool no_scripting) { - zchar key = ZC_BAD; - flush_buffer(); + zchar key = ZC_BAD; + flush_buffer(); - // Remove initial input from the transscript file or from the screen - if (ostream_script && enable_scripting && !no_scripting) + // Remove initial input from the transscript file or from the screen + if (ostream_script && enable_scripting && !no_scripting) script_erase_input(buf); - // Read input line from current input stream + // Read input line from current input stream continue_input: - do { + do { if (istream_replay) key = replay_read_input(buf); else key = console_read_input(max, buf, timeout, key != ZC_BAD); if (shouldQuit()) return ZC_BAD; - } while (key == ZC_BAD); + } while (key == ZC_BAD); - // Copy input line to the command file - if (ostream_record && !istream_replay) + // Copy input line to the command file + if (ostream_record && !istream_replay) record_write_input(buf, key); - // Handle timeouts - if (key == ZC_TIME_OUT) + // Handle timeouts + if (key == ZC_TIME_OUT) if (direct_call(routine) == 0) - goto continue_input; + goto continue_input; - // Copy input line to transscript file or to the screen - if (ostream_script && enable_scripting && !no_scripting) + // Copy input line to transscript file or to the screen + if (ostream_script && enable_scripting && !no_scripting) script_write_input(buf, key); - // Return terminating key - return key; + // Return terminating key + return key; } void Processor::script_open() { @@ -487,28 +487,28 @@ void Processor::z_input_stream() { } void Processor::z_output_stream() { - flush_buffer(); - - switch ((short) zargs[0]) { - case 1: ostream_screen = true; - break; - case -1: ostream_screen = false; - break; - case 2: if (!ostream_script) script_open(); - break; - case -2: if (ostream_script) script_close(); - break; - case 3: memory_open(zargs[1], zargs[2], zargc >= 3); - break; - case -3: memory_close(); - break; - case 4: if (!ostream_record) record_open(); - break; - case -4: if (ostream_record) record_close(); - break; + flush_buffer(); + + switch ((short) zargs[0]) { + case 1: ostream_screen = true; + break; + case -1: ostream_screen = false; + break; + case 2: if (!ostream_script) script_open(); + break; + case -2: if (ostream_script) script_close(); + break; + case 3: memory_open(zargs[1], zargs[2], zargc >= 3); + break; + case -3: memory_close(); + break; + case 4: if (!ostream_record) record_open(); + break; + case -4: if (ostream_record) record_close(); + break; default: break; - } + } } void Processor::z_restart() { diff --git a/engines/glk/frotz/processor_table.cpp b/engines/glk/frotz/processor_table.cpp index 57afc760b2..e53dae5709 100644 --- a/engines/glk/frotz/processor_table.cpp +++ b/engines/glk/frotz/processor_table.cpp @@ -26,10 +26,10 @@ namespace Glk { namespace Frotz { void Processor::z_copy_table() { - zword addr; - zword size = zargs[2]; - zbyte value; - int i; + zword addr; + zword size = zargs[2]; + zbyte value; + int i; if (zargs[1] == 0) { // zero table @@ -53,33 +53,33 @@ void Processor::z_copy_table() { } void Processor::z_loadb() { - zword addr = zargs[0] + zargs[1]; - zbyte value; + zword addr = zargs[0] + zargs[1]; + zbyte value; LOW_BYTE(addr, value); - store(value); + store(value); } void Processor::z_loadw() { - zword addr = zargs[0] + 2 * zargs[1]; - zword value; + zword addr = zargs[0] + 2 * zargs[1]; + zword value; LOW_WORD(addr, value); - store(value); + store(value); } void Processor::z_scan_table() { - zword addr = zargs[1]; - int i; + zword addr = zargs[1]; + int i; - // Supply default arguments - if (zargc < 4) + // Supply default arguments + if (zargc < 4) zargs[3] = 0x82; - // Scan byte or word array - for (i = 0; i < zargs[2]; i++) { + // Scan byte or word array + for (i = 0; i < zargs[2]; i++) { if (zargs[3] & 0x80) { // scan word array zword wvalue; @@ -99,21 +99,21 @@ void Processor::z_scan_table() { } addr += zargs[3] & 0x7f; - } + } - addr = 0; + addr = 0; finished: - store(addr); - branch(addr); + store(addr); + branch(addr); } void Processor::z_storeb() { - storeb((zword) (zargs[0] + zargs[1]), zargs[2]); + storeb((zword) (zargs[0] + zargs[1]), zargs[2]); } void Processor::z_storew() { - storew((zword)(zargs[0] + 2 * zargs[1]), zargs[2]); + storew((zword)(zargs[0] + 2 * zargs[1]), zargs[2]); } } // End of namespace Scott diff --git a/engines/glk/frotz/processor_text.cpp b/engines/glk/frotz/processor_text.cpp index abb0430742..9b44d70abb 100644 --- a/engines/glk/frotz/processor_text.cpp +++ b/engines/glk/frotz/processor_text.cpp @@ -26,26 +26,26 @@ namespace Glk { namespace Frotz { zchar Processor::ZSCII_TO_LATIN1[] = { - 0x0e4, 0x0f6, 0x0fc, 0x0c4, 0x0d6, 0x0dc, 0x0df, 0x0bb, - 0x0ab, 0x0eb, 0x0ef, 0x0ff, 0x0cb, 0x0cf, 0x0e1, 0x0e9, - 0x0ed, 0x0f3, 0x0fa, 0x0fd, 0x0c1, 0x0c9, 0x0cd, 0x0d3, - 0x0da, 0x0dd, 0x0e0, 0x0e8, 0x0ec, 0x0f2, 0x0f9, 0x0c0, - 0x0c8, 0x0cc, 0x0d2, 0x0d9, 0x0e2, 0x0ea, 0x0ee, 0x0f4, - 0x0fb, 0x0c2, 0x0ca, 0x0ce, 0x0d4, 0x0db, 0x0e5, 0x0c5, - 0x0f8, 0x0d8, 0x0e3, 0x0f1, 0x0f5, 0x0c3, 0x0d1, 0x0d5, - 0x0e6, 0x0c6, 0x0e7, 0x0c7, 0x0fe, 0x0f0, 0x0de, 0x0d0, - 0x0a3, 0x153, 0x152, 0x0a1, 0x0bf + 0x0e4, 0x0f6, 0x0fc, 0x0c4, 0x0d6, 0x0dc, 0x0df, 0x0bb, + 0x0ab, 0x0eb, 0x0ef, 0x0ff, 0x0cb, 0x0cf, 0x0e1, 0x0e9, + 0x0ed, 0x0f3, 0x0fa, 0x0fd, 0x0c1, 0x0c9, 0x0cd, 0x0d3, + 0x0da, 0x0dd, 0x0e0, 0x0e8, 0x0ec, 0x0f2, 0x0f9, 0x0c0, + 0x0c8, 0x0cc, 0x0d2, 0x0d9, 0x0e2, 0x0ea, 0x0ee, 0x0f4, + 0x0fb, 0x0c2, 0x0ca, 0x0ce, 0x0d4, 0x0db, 0x0e5, 0x0c5, + 0x0f8, 0x0d8, 0x0e3, 0x0f1, 0x0f5, 0x0c3, 0x0d1, 0x0d5, + 0x0e6, 0x0c6, 0x0e7, 0x0c7, 0x0fe, 0x0f0, 0x0de, 0x0d0, + 0x0a3, 0x153, 0x152, 0x0a1, 0x0bf }; zchar Processor::translate_from_zscii(zbyte c) { - if (c == 0xfc) + if (c == 0xfc) return ZC_MENU_CLICK; - if (c == 0xfd) + if (c == 0xfd) return ZC_DOUBLE_CLICK; - if (c == 0xfe) + if (c == 0xfe) return ZC_SINGLE_CLICK; - if (c >= 0x9b && _storyId != BEYOND_ZORK) { + if (c >= 0x9b && _storyId != BEYOND_ZORK) { if (hx_unicode_table != 0) { // game has its own Unicode table zbyte N; @@ -72,15 +72,15 @@ zchar Processor::translate_from_zscii(zbyte c) { return '?'; } } - } + } - return (zchar)c; + return (zchar)c; } zbyte Processor::unicode_to_zscii(zchar c) { - int i; + int i; - if (c >= ZC_LATIN1_MIN) { + if (c >= ZC_LATIN1_MIN) { if (hx_unicode_table != 0) { // game has its own Unicode table zbyte N; @@ -105,34 +105,34 @@ zbyte Processor::unicode_to_zscii(zchar c) { return 0; } - } + } - return (zbyte)c; + return (zbyte)c; } zbyte Processor::translate_to_zscii(zchar c) { - if (c == ZC_SINGLE_CLICK) + if (c == ZC_SINGLE_CLICK) return 0xfe; - if (c == ZC_DOUBLE_CLICK) + if (c == ZC_DOUBLE_CLICK) return 0xfd; - if (c == ZC_MENU_CLICK) + if (c == ZC_MENU_CLICK) return 0xfc; - if (c == 0) + if (c == 0) return 0; - c = unicode_to_zscii (c); - if (c == 0) + c = unicode_to_zscii (c); + if (c == 0) c = '?'; - return (zbyte)c; + return (zbyte)c; } zchar Processor::alphabet(int set, int index) { - if (h_version > V1 && set == 2 && index == 1) + if (h_version > V1 && set == 2 && index == 1) // always newline return '\r'; - if (h_alphabet != 0) { + if (h_alphabet != 0) { // game uses its own alphabet zbyte c; @@ -140,7 +140,7 @@ zchar Processor::alphabet(int set, int index) { LOW_BYTE(addr, c); return translate_from_zscii(c); - } else { + } else { // game uses default alphabet if (set == 0) return 'a' + index; @@ -154,21 +154,21 @@ zchar Processor::alphabet(int set, int index) { } void Processor::find_resolution() { - zword dct = h_dictionary; - zword entry_count; - zbyte sep_count; - zbyte entry_len; + zword dct = h_dictionary; + zword entry_count; + zbyte sep_count; + zbyte entry_len; LOW_BYTE(dct, sep_count); - dct += 1 + sep_count; // skip word separators + dct += 1 + sep_count; // skip word separators LOW_BYTE(dct, entry_len); - dct += 1; // skip entry length + dct += 1; // skip entry length LOW_WORD(dct, entry_count); - dct += 2; // get number of entries + dct += 2; // get number of entries - if (h_version < V9) { + if (h_version < V9) { _resolution = (h_version <= V3) ? 2 : 3; - } else { + } else { zword addr = dct; zword code; @@ -186,16 +186,16 @@ void Processor::find_resolution() { if (2 * _resolution > entry_len) { runtimeError(ERR_DICT_LEN); - } + } - _decoded = (zchar *)malloc (sizeof (zchar) * (3 * _resolution) + 1); - _encoded = (zchar *)malloc (sizeof (zchar) * _resolution); + _decoded = (zchar *)malloc (sizeof (zchar) * (3 * _resolution) + 1); + _encoded = (zchar *)malloc (sizeof (zchar) * _resolution); } void Processor::load_string (zword addr, zword length) { - int i = 0; + int i = 0; - if (_resolution == 0) + if (_resolution == 0) find_resolution(); while (i < 3 * _resolution) { @@ -212,21 +212,21 @@ void Processor::load_string (zword addr, zword length) { } void Processor::encode_text(int padding) { - static const zchar again[] = { 'a', 'g', 'a', 'i', 'n', 0, 0, 0, 0 }; - static const zchar examine[] = { 'e', 'x', 'a', 'm', 'i', 'n', 'e', 0, 0 }; - static const zchar wait[] = { 'w', 'a', 'i', 't', 0, 0, 0, 0, 0 }; + static const zchar again[] = { 'a', 'g', 'a', 'i', 'n', 0, 0, 0, 0 }; + static const zchar examine[] = { 'e', 'x', 'a', 'm', 'i', 'n', 'e', 0, 0 }; + static const zchar wait[] = { 'w', 'a', 'i', 't', 0, 0, 0, 0, 0 }; - zbyte *zchars; - const zchar *ptr; - zchar c; - int i = 0; + zbyte *zchars; + const zchar *ptr; + zchar c; + int i = 0; - if (_resolution == 0) find_resolution(); + if (_resolution == 0) find_resolution(); - zchars = new byte[3 * (_resolution + 1)]; - ptr = _decoded; + zchars = new byte[3 * (_resolution + 1)]; + ptr = _decoded; - // Expand abbreviations that some old Infocom games lack + // Expand abbreviations that some old Infocom games lack if (_expand_abbreviations && (h_version <= V8)) { if (padding == 0x05 && _decoded[1] == 0) { switch (_decoded[0]) { @@ -238,8 +238,8 @@ void Processor::encode_text(int padding) { } } - // Translate string to a sequence of Z-characters - while (i < 3 * _resolution) { + // Translate string to a sequence of Z-characters + while (i < 3 * _resolution) { if ((c = *ptr++) != 0) { int index, set; zbyte c2; @@ -276,13 +276,13 @@ void Processor::encode_text(int padding) { } // Three Z-characters make a 16bit word - for (i = 0; i < _resolution; i++) + for (i = 0; i < _resolution; i++) _encoded[i] = (zchars[3 * i + 0] << 10) | (zchars[3 * i + 1] << 5) | (zchars[3 * i + 2]); - _encoded[_resolution - 1] |= 0x8000; + _encoded[_resolution - 1] |= 0x8000; delete[] zchars; } @@ -625,7 +625,7 @@ void Processor::tokenise_line(zword text, zword token, zword dct, bool flag) { else LOW_BYTE(addr1, c); - // Check for separator + // Check for separator sep_addr = dct; LOW_BYTE(sep_addr, sep_count); @@ -772,13 +772,13 @@ zchar Processor::unicode_tolower(zchar c) { void Processor::z_check_unicode() { - zword c = zargs[0]; - zword result = 0; + zword c = zargs[0]; + zword result = 0; - if (c <= 0x1f) { + if (c <= 0x1f) { if ((c == 0x08) || (c == 0x0d) || (c == 0x1b)) result = 2; - } else if (c <= 0x7e) { + } else if (c <= 0x7e) { result = 3; } else { // we support unicode @@ -789,39 +789,39 @@ void Processor::z_check_unicode() { } void Processor::z_encode_text() { - int i; + int i; - load_string((zword) (zargs[0] + zargs[2]), zargs[1]); + load_string((zword) (zargs[0] + zargs[2]), zargs[1]); - encode_text(0x05); + encode_text(0x05); - for (i = 0; i < _resolution; i++) + for (i = 0; i < _resolution; i++) storew((zword) (zargs[3] + 2 * i), _encoded[i]); } void Processor::z_new_line() { - new_line (); + new_line (); } void Processor::z_print () { - decode_text(EMBEDDED_STRING, 0); + decode_text(EMBEDDED_STRING, 0); } void Processor::z_print_addr() { - decode_text(LOW_STRING, zargs[0]); + decode_text(LOW_STRING, zargs[0]); } void Processor::z_print_char() { - print_char (translate_from_zscii(zargs[0])); + print_char (translate_from_zscii(zargs[0])); } void Processor::z_print_form() { - zword count; - zword addr = zargs[0]; - bool first = true; + zword count; + zword addr = zargs[0]; + bool first = true; - for (;;) { + for (;;) { LOW_WORD(addr, count); addr += 2; @@ -841,43 +841,43 @@ void Processor::z_print_form() { } first = false; - } + } } void Processor::z_print_num() { - print_num (zargs[0]); + print_num (zargs[0]); } void Processor::z_print_obj() { - print_object(zargs[0]); + print_object(zargs[0]); } void Processor::z_print_paddr() { - decode_text (HIGH_STRING, zargs[0]); + decode_text (HIGH_STRING, zargs[0]); } void Processor::z_print_ret() { - decode_text(EMBEDDED_STRING, 0); - new_line(); - ret(1); + decode_text(EMBEDDED_STRING, 0); + new_line(); + ret(1); } void Processor::z_print_unicode() { - if (zargs[0] < 0x20) + if (zargs[0] < 0x20) print_char('?'); - else + else print_char(zargs[0]); } void Processor::z_tokenise() { - // Supply default arguments - if (zargc < 3) + // Supply default arguments + if (zargc < 3) zargs[2] = 0; - if (zargc < 4) + if (zargc < 4) zargs[3] = 0; - // Call tokenise_line to do the real work - tokenise_line(zargs[0], zargs[1], zargs[2], zargs[3] != 0); + // Call tokenise_line to do the real work + tokenise_line(zargs[0], zargs[1], zargs[2], zargs[3] != 0); } } // End of namespace Scott diff --git a/engines/glk/frotz/processor_windows.cpp b/engines/glk/frotz/processor_windows.cpp index 4bd332472f..53d2ae1dac 100644 --- a/engines/glk/frotz/processor_windows.cpp +++ b/engines/glk/frotz/processor_windows.cpp @@ -26,18 +26,18 @@ namespace Glk { namespace Frotz { static struct { - Story story_id; - int pic; - int pic1; - int pic2; + Story story_id; + int pic; + int pic1; + int pic2; } mapper[] = { - { ZORK_ZERO, 5, 497, 498 }, - { ZORK_ZERO, 6, 501, 502 }, - { ZORK_ZERO, 7, 499, 500 }, - { ZORK_ZERO, 8, 503, 504 }, - { ARTHUR, 54, 170, 171 }, - { SHOGUN, 50, 61, 62 }, - { UNKNOWN, 0, 0, 0 } + { ZORK_ZERO, 5, 497, 498 }, + { ZORK_ZERO, 6, 501, 502 }, + { ZORK_ZERO, 7, 499, 500 }, + { ZORK_ZERO, 8, 503, 504 }, + { ARTHUR, 54, 170, 171 }, + { SHOGUN, 50, 61, 62 }, + { UNKNOWN, 0, 0, 0 } }; void Processor::z_draw_picture() { diff --git a/engines/glk/scott/scott.cpp b/engines/glk/scott/scott.cpp index 3d16fed3db..640679c5f3 100644 --- a/engines/glk/scott/scott.cpp +++ b/engines/glk/scott/scott.cpp @@ -112,7 +112,7 @@ void Scott::runGame(Common::SeekableReadStream *gameFile) { if (_gameHeader._lightTime < 1) { _bitFlags |= (1 << LIGHTOUTBIT); if (_items[LIGHT_SOURCE]._location == CARRIED || - _items[LIGHT_SOURCE]._location == MY_LOC) { + _items[LIGHT_SOURCE]._location == MY_LOC) { if (_options & SCOTTLIGHT) output(_("Light has run out! ")); else @@ -122,7 +122,7 @@ void Scott::runGame(Common::SeekableReadStream *gameFile) { _items[LIGHT_SOURCE]._location = DESTROYED; } else if (_gameHeader._lightTime < 25) { if (_items[LIGHT_SOURCE]._location == CARRIED || - _items[LIGHT_SOURCE]._location == MY_LOC) { + _items[LIGHT_SOURCE]._location == MY_LOC) { if (_options & SCOTTLIGHT) { output(_("Light runs out in ")); @@ -229,7 +229,7 @@ int Scott::matchUpItem(const char *text, int loc) { while (ct <= _gameHeader._numItems) { if (!_items[ct]._autoGet.empty() && _items[ct]._location == loc && - xstrncasecmp(_items[ct]._autoGet.c_str(), word, _gameHeader._wordLength) == 0) + xstrncasecmp(_items[ct]._autoGet.c_str(), word, _gameHeader._wordLength) == 0) return ct; ct++; } @@ -331,7 +331,7 @@ void Scott::loadDatabase(Common::SeekableReadStream *f, bool loud) { for (int idx = 0; idx < nr + 1; ++idx) { Room &r = _rooms[idx]; readInts(f, 6, &r._exits[0], &r._exits[1], &r._exits[2], - &r._exits[3], &r._exits[4], &r._exits[5]); + &r._exits[3], &r._exits[4], &r._exits[5]); r._text = readString(f); } @@ -400,7 +400,7 @@ void Scott::look(void) { glk_window_clear(_topWindow); if ((_bitFlags & (1 << DARKBIT)) && _items[LIGHT_SOURCE]._location != CARRIED - && _items[LIGHT_SOURCE]._location != MY_LOC) { + && _items[LIGHT_SOURCE]._location != MY_LOC) { if (_options & YOUARE) display(_topWindow, _("You can't see. It is too dark!\n")); else @@ -517,8 +517,8 @@ Common::Error Scott::saveGameData(strid_t file, const Common::String &desc) { } msg = Common::String::format("%u %d %d %d %d %d\n", - _bitFlags, (_bitFlags & (1 << DARKBIT)) ? 1 : 0, - MY_LOC, _currentCounter, _savedRoom, _gameHeader._lightTime); + _bitFlags, (_bitFlags & (1 << DARKBIT)) ? 1 : 0, + MY_LOC, _currentCounter, _savedRoom, _gameHeader._lightTime); glk_put_string_stream(file, msg.c_str()); for (int ct = 0; ct <= _gameHeader._numItems; ct++) { @@ -543,8 +543,8 @@ Common::Error Scott::loadGameData(strid_t file) { glk_get_line_stream(file, buf, sizeof buf); sscanf(buf, "%u %hd %d %d %d %d\n", - &_bitFlags, &darkFlag, &MY_LOC, &_currentCounter, &_savedRoom, - &_gameHeader._lightTime); + &_bitFlags, &darkFlag, &MY_LOC, &_currentCounter, &_savedRoom, + &_gameHeader._lightTime); // Backward compatibility if (darkFlag) @@ -650,7 +650,7 @@ int Scott::performLine(int ct) { break; case 3: if (_items[dv]._location != CARRIED && - _items[dv]._location != MY_LOC) + _items[dv]._location != MY_LOC) return 0; break; case 4: @@ -802,7 +802,7 @@ doneit: int n = 0; while (i <= _gameHeader._numItems) { if (_items[i]._location == _gameHeader._treasureRoom && - _items[i]._text.hasPrefix("*")) + _items[i]._text.hasPrefix("*")) n++; i++; } @@ -951,7 +951,7 @@ doneit: break; default: error("Unknown action %d [Param begins %d %d]\n", - act[cc], param[pptr], param[pptr + 1]); + act[cc], param[pptr], param[pptr + 1]); break; } } @@ -976,7 +976,7 @@ int Scott::performActions(int vb, int no) { if (vb == 1 && no >= 1 && no <= 6) { int nl; if (_items[LIGHT_SOURCE]._location == MY_LOC || - _items[LIGHT_SOURCE]._location == CARRIED) + _items[LIGHT_SOURCE]._location == CARRIED) d = 0; if (d) output(_("Dangerous to move in the dark! ")); @@ -1015,7 +1015,7 @@ int Scott::performActions(int vb, int no) { vv /= 150; if ((vv == vb) || (doagain && _actions[ct]._vocab == 0)) { if ((vv == 0 && randomPercent(nv)) || doagain || - (vv != 0 && (nv == no || nv == 0))) { + (vv != 0 && (nv == no || nv == 0))) { int f2; if (fl == -1) fl = -2; @@ -1044,7 +1044,7 @@ int Scott::performActions(int vb, int no) { if (fl != 0 && disableSysFunc == 0) { int item; if (_items[LIGHT_SOURCE]._location == MY_LOC || - _items[LIGHT_SOURCE]._location == CARRIED) + _items[LIGHT_SOURCE]._location == CARRIED) d = 0; if (vb == 10 || vb == 18) { // Yes they really _are_ hardcoded values diff --git a/engines/glk/selection.cpp b/engines/glk/selection.cpp index e5e853e50c..185a9a3090 100644 --- a/engines/glk/selection.cpp +++ b/engines/glk/selection.cpp @@ -119,9 +119,9 @@ void WindowMask::putHyperlink(uint linkval, uint x0, uint y0, uint x1, uint y1) } if (tx0 >= _hor - || tx1 >= _hor - || ty0 >= _ver || ty1 >= _ver - || !_links[tx0] || !_links[tx1]) { + || tx1 >= _hor + || ty0 >= _ver || ty1 >= _ver + || !_links[tx0] || !_links[tx1]) { warning("putHyperlink: invalid range given"); return; } @@ -194,7 +194,7 @@ void Selection::clearSelection() { } bool Selection::checkSelection(const Rect &r) const { - Rect select(MIN(_select.left, _select.right), MIN(_select.top, _select.bottom), + Rect select(MIN(_select.left, _select.right), MIN(_select.top, _select.bottom), MAX(_select.left, _select.right), MAX(_select.top, _select.bottom)); if (select.isEmpty()) return false; @@ -223,7 +223,7 @@ bool Selection::getSelection(const Rect &r, int *rx0, int *rx1) const { row_selected = false; if ((cy0 >= upper && cy0 <= lower) - || (cy1 >= upper && cy1 <= lower)) + || (cy1 >= upper && cy1 <= lower)) row_selected = true; if (row >= cy0 && row <= cy1) diff --git a/engines/glk/tads/tads2/ler.cpp b/engines/glk/tads/tads2/ler.cpp index 970fe31d67..d996977f0e 100644 --- a/engines/glk/tads/tads2/ler.cpp +++ b/engines/glk/tads/tads2/ler.cpp @@ -29,102 +29,102 @@ namespace TADS2 { #define TRDLOGERR_PREFIX "\n[An error has occurred within TADS: " int errcxdef::errfmt(char *outbuf, int outbufl, char *fmt, int argc, erradef *argv) { - int outlen = 0; - int argi = 0; - int len; - char buf[20]; - const char *p = nullptr; - char fmtchar; - - while (*fmt != '\0' && outbufl > 1) { - switch(*fmt) { - case '\\': - ++fmt; - len = 1; - switch(*fmt) { - case '\0': - --fmt; - break; - case '\n': - p = "\n"; - break; - case '\t': - p = "\t"; - break; - default: - p = fmt; - break; - } - break; - - case '%': - ++fmt; - fmtchar = *fmt; - if (argi >= argc) fmtchar = 1; // too many - ignore it - switch(fmtchar) { - case '\0': - --fmt; - len = 0; - break; - - case '%': - p = "%"; - len = 1; - break; - - case 'd': - sprintf(buf, "%d", argv[argi].erraint); - len = strlen(buf); - p = buf; - break; - - case 'u': - sprintf(buf, "%u", argv[argi].erraint); - len = strlen(buf); - p = buf; - break; - - case 's': - p = argv[argi].errastr; - len = strlen(p); - break; - - default: - p = ""; - len = 0; - --argi; - break; - } - ++argi; - break; - - default: - p = fmt; - len = 1; - break; - } - - /* copy output that was set up above */ - if (len != 0) { - if (outbufl >= len) { - memcpy(outbuf, p, (size_t)len); - outbufl -= len; - outbuf += len; - } else if (outbufl > 1) { - memcpy(outbuf, p, (size_t)outbufl - 1); - outbufl = 1; - } - outlen += len; - } - ++fmt; - } - - // add a null terminator - if (outbufl != 0) - *outbuf++ = '\0'; - - // return the length - return outlen; + int outlen = 0; + int argi = 0; + int len; + char buf[20]; + const char *p = nullptr; + char fmtchar; + + while (*fmt != '\0' && outbufl > 1) { + switch(*fmt) { + case '\\': + ++fmt; + len = 1; + switch(*fmt) { + case '\0': + --fmt; + break; + case '\n': + p = "\n"; + break; + case '\t': + p = "\t"; + break; + default: + p = fmt; + break; + } + break; + + case '%': + ++fmt; + fmtchar = *fmt; + if (argi >= argc) fmtchar = 1; // too many - ignore it + switch(fmtchar) { + case '\0': + --fmt; + len = 0; + break; + + case '%': + p = "%"; + len = 1; + break; + + case 'd': + sprintf(buf, "%d", argv[argi].erraint); + len = strlen(buf); + p = buf; + break; + + case 'u': + sprintf(buf, "%u", argv[argi].erraint); + len = strlen(buf); + p = buf; + break; + + case 's': + p = argv[argi].errastr; + len = strlen(p); + break; + + default: + p = ""; + len = 0; + --argi; + break; + } + ++argi; + break; + + default: + p = fmt; + len = 1; + break; + } + + /* copy output that was set up above */ + if (len != 0) { + if (outbufl >= len) { + memcpy(outbuf, p, (size_t)len); + outbufl -= len; + outbuf += len; + } else if (outbufl > 1) { + memcpy(outbuf, p, (size_t)outbufl - 1); + outbufl = 1; + } + outlen += len; + } + ++fmt; + } + + // add a null terminator + if (outbufl != 0) + *outbuf++ = '\0'; + + // return the length + return outlen; } void errcxdef::errcxlog(void *ctx0, char *fac, int err, int argc, erradef *argv) { diff --git a/engines/glk/tads/tads2/ler.h b/engines/glk/tads/tads2/ler.h index 8edb945115..57e3e63c2c 100644 --- a/engines/glk/tads/tads2/ler.h +++ b/engines/glk/tads/tads2/ler.h @@ -337,22 +337,22 @@ enum ErrorCode { /* * Special error flag - this is returned from execmd() when preparseCmd * returns a command list. This indicates to voc1cmd that it should try - * the command over again, using the words in the new list. + * the command over again, using the words in the new list. */ #define ERR_PREPRSCMDREDO 30000 /* preparseCmd returned a list */ #define ERR_PREPRSCMDCAN 30001 /* preparseCmd returned 'nil' to cancel */ union erradef { - int erraint; // integer argument - char *errastr; // text string argument + int erraint; // integer argument + char *errastr; // text string argument }; struct errdef { - errdef * errprv; // previous error frame - int errcode; // error code of exception being handled - char errfac[ERRFACMAX+1]; // facility of current error - erradef erraav[10]; // parameters for error - int erraac; // count of parameters in argc + errdef * errprv; // previous error frame + int errcode; // error code of exception being handled + char errfac[ERRFACMAX+1]; // facility of current error + erradef erraav[10]; // parameters for error + int erraac; // count of parameters in argc // jmp_buf errbuf; // jump buffer for current error frame }; @@ -362,21 +362,21 @@ class TADS2; // seek location record for an error message by number struct errmfdef { - uint errmfnum; // error number - size_t errmfseek; // seek location of this message + uint errmfnum; // error number + size_t errmfseek; // seek location of this message }; class errcxdef { public: errdef *errcxptr; // current error frame - void *errcxlgc; // context for error logging callback - int errcxofs; // offset in argument buffer - char errcxbuf[ERRBUFSIZ]; // space for argument strings - Common::SeekableReadStream *errcxfp; // message file, if one is being used - errmfdef *errcxseek; // seek locations of messages in file - uint errcxsksz; // size of errcxseek array - size_t errcxbase; // offset in physical file of logical error file - TADS2 * errcxappctx; // host application context + void *errcxlgc; // context for error logging callback + int errcxofs; // offset in argument buffer + char errcxbuf[ERRBUFSIZ]; // space for argument strings + Common::SeekableReadStream *errcxfp; // message file, if one is being used + errmfdef *errcxseek; // seek locations of messages in file + uint errcxsksz; // size of errcxseek array + size_t errcxbase; // offset in physical file of logical error file + TADS2 * errcxappctx; // host application context public: /** * Format an error message, sprintf-style, using arguments in an @@ -403,45 +403,45 @@ public: // begin protected code #define ERRBEGIN(ctx) \ { \ - errdef fr_; \ - if ((fr_.errcode = setjmp(fr_.errbuf)) == 0) \ - { \ - fr_.errprv = (ctx)->errcxptr; \ - (ctx)->errcxptr = &fr_; + errdef fr_; \ + if ((fr_.errcode = setjmp(fr_.errbuf)) == 0) \ + { \ + fr_.errprv = (ctx)->errcxptr; \ + (ctx)->errcxptr = &fr_; // end protected code, begin error handler #define ERRCATCH(ctx, e) \ - assert(1==1 && (ctx)->errcxptr != fr_.errprv); \ - (ctx)->errcxptr = fr_.errprv; \ - } \ - else \ - { \ - assert(2==2 && (ctx)->errcxptr != fr_.errprv); \ - (e) = fr_.errcode; \ - (ctx)->errcxptr = fr_.errprv; + assert(1==1 && (ctx)->errcxptr != fr_.errprv); \ + (ctx)->errcxptr = fr_.errprv; \ + } \ + else \ + { \ + assert(2==2 && (ctx)->errcxptr != fr_.errprv); \ + (e) = fr_.errcode; \ + (ctx)->errcxptr = fr_.errprv; // retrieve argument (int, string) in current error frame #define errargint(argnum) (fr_.erraav[argnum].erraint) #define errargstr(argnum) (fr_.erraav[argnum].errastr) - + #define ERREND(ctx) \ - } \ + } \ } // end protected code, begin cleanup (no handling; just cleaning up) #define ERRCLEAN(ctx) \ - assert((ctx)->errcxptr != fr_.errprv); \ - (ctx)->errcxptr = fr_.errprv; \ - } \ - else \ - { \ - assert((ctx)->errcxptr != fr_.errprv); \ - (ctx)->errcxptr = fr_.errprv; + assert((ctx)->errcxptr != fr_.errprv); \ + (ctx)->errcxptr = fr_.errprv; \ + } \ + else \ + { \ + assert((ctx)->errcxptr != fr_.errprv); \ + (ctx)->errcxptr = fr_.errprv; #define ERRENDCLN(ctx) \ - errrse(ctx); \ - } \ + errrse(ctx); \ + } \ } @@ -457,7 +457,7 @@ public: #ifdef ERR_NO_MACRO char *errstr(errcxdef *ctx, const char *str, int len); #else /* ERR_NO_MACRO */ - + #define errstr(ctx,str,len) \ ((memcpy(&(ctx)->errcxbuf[(ctx)->errcxofs],str,(size_t)len), \ (ctx)->errcxofs += (len), \ @@ -478,13 +478,13 @@ void errsign(errcxdef *ctx, int e, char *facility); void errjmp(jmp_buf buf, int e); # define errsign(ctx, e, fac) \ (strncpy((ctx)->errcxptr->errfac, fac, ERRFACMAX),\ - (ctx)->errcxptr->errfac[ERRFACMAX]='\0',\ - (ctx)->errcxofs=0, errjmp((ctx)->errcxptr->errbuf, e)) + (ctx)->errcxptr->errfac[ERRFACMAX]='\0',\ + (ctx)->errcxofs=0, errjmp((ctx)->errcxptr->errbuf, e)) # else /* DEBUG */ # define errsign(ctx, e, fac) \ (strncpy((ctx)->errcxptr->errfac, fac, ERRFACMAX),\ - (ctx)->errcxptr->errfac[ERRFACMAX]='\0',\ - (ctx)->errcxofs=0, longjmp((ctx)->errcxptr->errbuf, e)) + (ctx)->errcxptr->errfac[ERRFACMAX]='\0',\ + (ctx)->errcxofs=0, longjmp((ctx)->errcxptr->errbuf, e)) # endif /* DEBUG */ #endif /* ERR_NO_MACRO */ @@ -495,7 +495,7 @@ void errsigf(errcxdef *ctx, char *facility, int err); #else /* ERR_NO_MACRO */ #define errsigf(ctx, fac, e) (errargc(ctx,0),errsign(ctx,e,fac)) #endif /* ERR_NO_MACRO */ - + // signal an error with one argument #define errsigf1(ctx, fac, e, typ1, arg1) \ (errargv(ctx,0,typ1,arg1),errargc(ctx,1),errsign(ctx,e,fac)) @@ -515,7 +515,7 @@ void errrse1(errcxdef *ctx, errdef *fr); # define errrse(ctx) \ (errargc(ctx, fr_.erraac),\ memcpy((ctx)->errcxptr->erraav, fr_.erraav, \ - (size_t)(fr_.erraac*sizeof(erradef))),\ + (size_t)(fr_.erraac*sizeof(erradef))),\ errsign(ctx, fr_.errcode, fr_.errfac)) #endif /* ERR_NO_MACRO */ @@ -525,20 +525,20 @@ void errrse1(errcxdef *ctx, errdef *fr); * parameters from the error currently being handled to the enclosing * frame. This is useful when "keeping" an error being handled - i.e., * the arguments will continue to be used outside of the - * ERRCATCH..ERREND code. + * ERRCATCH..ERREND code. */ #define errkeepargs(ctx) errcopyargs(ctx, &fr_) -/** +/** * copy the parameters for an error from another frame into the current * frame - this can be used when we want to be able to display an error * that occurred in an inner frame within code that is protected by a - * new enclosing error frame + * new enclosing error frame */ #define errcopyargs(ctx, fr) \ (errargc((ctx), (fr)->erraac), \ - memcpy((ctx)->errcxptr->erraav, (fr)->erraav, \ - (size_t)((fr)->erraac*sizeof(erradef)))) + memcpy((ctx)->errcxptr->erraav, (fr)->erraav, \ + (size_t)((fr)->erraac*sizeof(erradef)))) // log error that's been caught, using arguments already caught #define errclog(ctx) \ @@ -576,14 +576,14 @@ void errlogf(errcxdef *ctx, char *facility, int err); // log an error with one argument #define errlogf1(ctx, fac, e, typ1, arg1) \ (errargv(ctx,0,typ1,arg1),errargc(ctx,1),errlogn(ctx,e,fac)) - + // log an error with two arguments #define errlogf2(ctx, fac, e, typ1, arg1, typ2, arg2) \ (errargv(ctx,0,typ1,arg1),errargv(ctx,1,typ2,arg2),\ errargc(ctx,2),errlogn(ctx,e,fac)) /** - * For compatility with old facility-free mechanism, signal with facility "TADS" + * For compatility with old facility-free mechanism, signal with facility "TADS" */ #define errsig(ctx, err) errsigf(ctx, "TADS", err) #define errsig1(c, e, t, a) errsigf1(c,"TADS",e,t,a) @@ -593,10 +593,10 @@ void errlogf(errcxdef *ctx, char *facility, int err); #define errlog2(c, e, t1, a1, t2, a2) errlogf2(c,"TADS",e,t1,a1,t2,a2) #define errsig2(c, e, t1, a1, t2, a2) error("Error occurred") - + // get the text of an error void errmsg(errcxdef *ctx, char *outbuf, uint outbufl, uint err); - + // initialize error subsystem, opening error message file if necessary void errini(errcxdef *ctx, Common::SeekableReadStream *fp); @@ -606,8 +606,8 @@ void lerfre(errcxdef *ctx); // error message structure - number + text struct errmdef { - uint errmerr; // error number - char *errmtxt; // text of error message + uint errmerr; // error number + char *errmtxt; // text of error message }; } // End of namespace TADS2 diff --git a/engines/glk/tads/tads2/regex.h b/engines/glk/tads/tads2/regex.h index 9040a029f3..e945efb65f 100644 --- a/engines/glk/tads/tads2/regex.h +++ b/engines/glk/tads/tads2/regex.h @@ -48,11 +48,11 @@ typedef int re_state_id; /** * Group register structure. Each register keeps track of the starting - * and ending offset of the group's text. + * and ending offset of the group's text. */ struct re_group_register { - const char *start_ofs; - const char *end_ofs; + const char *start_ofs; + const char *end_ofs; }; /** @@ -65,26 +65,26 @@ struct re_group_register { * complete set of transitions out of a particular state. A particular * state can have one character transition, or two epsilon transitions. * Note that we don't need to store the state ID in the tuple, because - * the state ID is the index of the tuple in an array of state tuples. + * the state ID is the index of the tuple in an array of state tuples. */ struct re_tuple { - // the character we must match to transition to the target state - char ch; + // the character we must match to transition to the target state + char ch; - // the target states - re_state_id next_state_1; - re_state_id next_state_2; + // the target states + re_state_id next_state_1; + re_state_id next_state_2; - // character range match table, if used - unsigned char *char_range; + // character range match table, if used + unsigned char *char_range; - // flags - byte flags; + // flags + byte flags; }; /** - * Tuple flags + * Tuple flags */ enum { // this state is the start of a group - the 'ch' value is the group ID @@ -95,25 +95,25 @@ enum { }; /** - * Status codes + * Status codes */ typedef enum { - // success - RE_STATUS_SUCCESS = 0, + // success + RE_STATUS_SUCCESS = 0, - // compilation error - group nesting too deep - RE_STATUS_GROUP_NESTING_TOO_DEEP + // compilation error - group nesting too deep + RE_STATUS_GROUP_NESTING_TOO_DEEP } re_status_t; /** * Regular expression compilation. This tracks the state of the compilation and - * stores the resources associated with the compiled expression. + * stores the resources associated with the compiled expression. */ class re_context { /** * A machine description. Machines are fully described by their initial - * and final state ID's. + * and final state ID's. */ struct re_machine { re_state_id init; ///< the machine's initial state @@ -168,7 +168,7 @@ private: void build_group_matcher(re_machine *machine, int group_num); /** - * Build a concatenation recognizer + * Build a concatenation recognizer */ void build_concat(re_machine *new_machine, re_machine *lhs, re_machine *rhs); @@ -180,7 +180,7 @@ private: void build_group(re_machine *new_machine, re_machine *sub_machine, int group_id); /** - * Build an alternation recognizer + * Build an alternation recognizer */ void build_alter(re_machine *new_machine, re_machine *lhs, re_machine *rhs); @@ -202,12 +202,12 @@ private: * first machine with the resulting machine. If the first machine is a * null machine, this simply replaces the first machine with the second * machine. If the second machine is null, this simply leaves the first - * machine unchanged. + * machine unchanged. */ void alternate_onto(re_machine *dest, re_machine *rhs); /** - * Compile an expression + * Compile an expression */ re_status_t compile(const char *expr, size_t exprlen, re_machine *result_machine); @@ -243,42 +243,42 @@ private: void save_search_str(const char *str, size_t len); public: errcxdef *_errctx; ///< error context - re_state_id _next_state; ///< next available state ID - - /** - * The array of transition tuples. We'll allocate this array and - * expand it as necessary. - */ - Common::Array<re_tuple> _tuple_arr; - - // current group ID - int _cur_group; - - // group registers - re_group_register _regs[RE_GROUP_REG_CNT]; - - /** - * Buffer for retaining a copy of the last string we scanned. We - * retain our own copy of each string, and point the group registers - * into this copy rather than the caller's original string -- this - * ensures that the group registers remain valid even after the - * caller has deallocated the original string. - */ - char *_strbuf; - - /** + re_state_id _next_state; ///< next available state ID + + /** + * The array of transition tuples. We'll allocate this array and + * expand it as necessary. + */ + Common::Array<re_tuple> _tuple_arr; + + // current group ID + int _cur_group; + + // group registers + re_group_register _regs[RE_GROUP_REG_CNT]; + + /** + * Buffer for retaining a copy of the last string we scanned. We + * retain our own copy of each string, and point the group registers + * into this copy rather than the caller's original string -- this + * ensures that the group registers remain valid even after the + * caller has deallocated the original string. + */ + char *_strbuf; + + /** * length of the string currently in the buffer */ - size_t _curlen; + size_t _curlen; - /** + /** * size of the buffer allocated to strbuf */ - size_t _strbufsiz; + size_t _strbufsiz; public: /** * Constructor. The memory for the context structure itself - * must be allocated and maintained by the caller. + * must be allocated and maintained by the caller. */ re_context(errcxdef *errctx); @@ -288,13 +288,13 @@ public: ~re_context(); /** - * Allocate a new state ID + * Allocate a new state ID */ re_state_id alloc_state(); /** * Compile an expression and search for a match within the given string. - * Returns the offset of the match, or -1 if no match was found. + * Returns the offset of the match, or -1 if no match was found. */ int compile_and_search(const char *pattern, size_t patlen, const char *searchstr, size_t searchlen, int *result_len); @@ -302,7 +302,7 @@ public: /** * Compile an expression and check for a match. Returns the length of the match * if we found a match, -1 if we found no match. This is not a search function; - * we merely match the leading substring of the given string to the given pattern. + * we merely match the leading substring of the given string to the given pattern. */ int compile_and_match(const char *pattern, size_t patlen, const char *searchstr, size_t searchlen); diff --git a/engines/glk/tads/tads2/tads2_cmap.cpp b/engines/glk/tads/tads2/tads2_cmap.cpp index cf63c9a763..68945f7336 100644 --- a/engines/glk/tads/tads2/tads2_cmap.cpp +++ b/engines/glk/tads/tads2/tads2_cmap.cpp @@ -29,238 +29,238 @@ namespace TADS2 { /** * Signatures for character map files. The signature is stored at the - * beginning of the file. + * beginning of the file. */ // single-byte character map version 1.0.0 #define CMAP_SIG_S100 "TADS2 charmap S100\n\r\01a" void TADS2::cmap_init_default() { - size_t i; + size_t i; - // initialize the input table - for (i = 0 ; i < sizeof(G_cmap_input)/sizeof(G_cmap_input[0]) ; ++i) - G_cmap_input[i] = (unsigned char)i; + // initialize the input table + for (i = 0 ; i < sizeof(G_cmap_input)/sizeof(G_cmap_input[0]) ; ++i) + G_cmap_input[i] = (unsigned char)i; - // initialize the output table - for (i = 0 ; i < sizeof(G_cmap_output)/sizeof(G_cmap_output[0]) ; ++i) - G_cmap_output[i] = (unsigned char)i; + // initialize the output table + for (i = 0 ; i < sizeof(G_cmap_output)/sizeof(G_cmap_output[0]) ; ++i) + G_cmap_output[i] = (unsigned char)i; - // we have a null ID - memset(G_cmap_id, 0, sizeof(G_cmap_id)); + // we have a null ID + memset(G_cmap_id, 0, sizeof(G_cmap_id)); - // indicate that it's the default - strcpy(G_cmap_ldesc, "(native/no mapping)"); + // indicate that it's the default + strcpy(G_cmap_ldesc, "(native/no mapping)"); - // note that we have no character set loaded - S_cmap_loaded = false; + // note that we have no character set loaded + S_cmap_loaded = false; } int TADS2::cmap_load_internal(const char *filename) { - osfildef *fp; - static char sig1[] = CMAP_SIG_S100; - char buf[256]; - uchar lenbuf[2]; - size_t len; - int sysblk; - - // if there's no mapping file, use the default mapping - if (filename == 0) { - // initialize with the default mapping - cmap_init_default(); - - // return success - return 0; - } - - // open the file - fp = osfoprb(filename, OSFTCMAP); - if (fp == 0) - return 1; - - // check the signature - if (osfrb(fp, buf, sizeof(sig1)) - || memcmp(buf, sig1, sizeof(sig1)) != 0) { - osfcls(fp); - return 2; - } - - // load the ID - G_cmap_id[4] = '\0'; - if (osfrb(fp, G_cmap_id, 4)) { - osfcls(fp); - return 3; - } - - // load the long description - if (osfrb(fp, lenbuf, 2) - || (len = osrp2(lenbuf)) > sizeof(G_cmap_ldesc) - || osfrb(fp, G_cmap_ldesc, len)) { - osfcls(fp); - return 4; - } - - // load the two tables - input, then output - if (osfrb(fp, G_cmap_input, sizeof(G_cmap_input)) - || osfrb(fp, G_cmap_output, sizeof(G_cmap_output))) { - osfcls(fp); - return 5; - } - - // read the next section header - if (osfrb(fp, buf, 4)) { - osfcls(fp); - return 6; - } - - // if it's "SYSI", read the system information string - if (!memcmp(buf, "SYSI", 4)) { - // read the length prefix, then the string - if (osfrb(fp, lenbuf, 2) - || (len = osrp2(lenbuf)) > sizeof(buf) - || osfrb(fp, buf, len)) { - osfcls(fp); - return 7; - } - - // we have a system information block - sysblk = true; - } else { - // there's no system information block - sysblk = false; - } - - /* - * call the OS code, so that it can do any system-dependent - * initialization for the new character mapping - */ - os_advise_load_charmap(G_cmap_id, G_cmap_ldesc, sysblk ? buf : ""); - - // read the next section header - if (sysblk && osfrb(fp, buf, 4)) { - osfcls(fp); - return 8; - } - - // see if we have an entity list - if (!memcmp(buf, "ENTY", 4)) { - // read the entities - for (;;) { - unsigned int cval; - char expansion[CMAP_MAX_ENTITY_EXPANSION]; - - // read the next item's length and character value - if (osfrb(fp, buf, 4)) { - osfcls(fp); - return 9; - } - - // decode the values - len = osrp2(buf); - cval = osrp2(buf+2); - - // if we've reached the zero marker, we're done - if (len == 0 && cval == 0) - break; - - // read the string - if (len > CMAP_MAX_ENTITY_EXPANSION - || osfrb(fp, expansion, len)) { - osfcls(fp); - return 10; - } - - // tell the output code about the expansion - tio_set_html_expansion(cval, expansion, len); - } - } - - /* - * ignore anything else we find - if the file format is updated to - * include extra information in the future, and this old code tries - * to load an updated file, we'll just ignore the new information, - * which should always be placed after the "SYSI" block (if present) - * to ensure compatibility with past versions (such as this code) - */ - // no problems - close the file and return success - osfcls(fp); - return 0; + osfildef *fp; + static char sig1[] = CMAP_SIG_S100; + char buf[256]; + uchar lenbuf[2]; + size_t len; + int sysblk; + + // if there's no mapping file, use the default mapping + if (filename == 0) { + // initialize with the default mapping + cmap_init_default(); + + // return success + return 0; + } + + // open the file + fp = osfoprb(filename, OSFTCMAP); + if (fp == 0) + return 1; + + // check the signature + if (osfrb(fp, buf, sizeof(sig1)) + || memcmp(buf, sig1, sizeof(sig1)) != 0) { + osfcls(fp); + return 2; + } + + // load the ID + G_cmap_id[4] = '\0'; + if (osfrb(fp, G_cmap_id, 4)) { + osfcls(fp); + return 3; + } + + // load the long description + if (osfrb(fp, lenbuf, 2) + || (len = osrp2(lenbuf)) > sizeof(G_cmap_ldesc) + || osfrb(fp, G_cmap_ldesc, len)) { + osfcls(fp); + return 4; + } + + // load the two tables - input, then output + if (osfrb(fp, G_cmap_input, sizeof(G_cmap_input)) + || osfrb(fp, G_cmap_output, sizeof(G_cmap_output))) { + osfcls(fp); + return 5; + } + + // read the next section header + if (osfrb(fp, buf, 4)) { + osfcls(fp); + return 6; + } + + // if it's "SYSI", read the system information string + if (!memcmp(buf, "SYSI", 4)) { + // read the length prefix, then the string + if (osfrb(fp, lenbuf, 2) + || (len = osrp2(lenbuf)) > sizeof(buf) + || osfrb(fp, buf, len)) { + osfcls(fp); + return 7; + } + + // we have a system information block + sysblk = true; + } else { + // there's no system information block + sysblk = false; + } + + /* + * call the OS code, so that it can do any system-dependent + * initialization for the new character mapping + */ + os_advise_load_charmap(G_cmap_id, G_cmap_ldesc, sysblk ? buf : ""); + + // read the next section header + if (sysblk && osfrb(fp, buf, 4)) { + osfcls(fp); + return 8; + } + + // see if we have an entity list + if (!memcmp(buf, "ENTY", 4)) { + // read the entities + for (;;) { + unsigned int cval; + char expansion[CMAP_MAX_ENTITY_EXPANSION]; + + // read the next item's length and character value + if (osfrb(fp, buf, 4)) { + osfcls(fp); + return 9; + } + + // decode the values + len = osrp2(buf); + cval = osrp2(buf+2); + + // if we've reached the zero marker, we're done + if (len == 0 && cval == 0) + break; + + // read the string + if (len > CMAP_MAX_ENTITY_EXPANSION + || osfrb(fp, expansion, len)) { + osfcls(fp); + return 10; + } + + // tell the output code about the expansion + tio_set_html_expansion(cval, expansion, len); + } + } + + /* + * ignore anything else we find - if the file format is updated to + * include extra information in the future, and this old code tries + * to load an updated file, we'll just ignore the new information, + * which should always be placed after the "SYSI" block (if present) + * to ensure compatibility with past versions (such as this code) + */ + // no problems - close the file and return success + osfcls(fp); + return 0; } int TADS2::cmap_load(const char *filename) { - int err; - - // try loading the file - if ((err = cmap_load_internal(filename)) != 0) - return err; - - /* - * note that we've explicitly loaded a character set, if they named - * a character set (if not, this simply establishes the default - * setting, so we haven't explicitly loaded anything) - */ - if (filename != nullptr) - S_cmap_loaded = true; - - // success - return 0; + int err; + + // try loading the file + if ((err = cmap_load_internal(filename)) != 0) + return err; + + /* + * note that we've explicitly loaded a character set, if they named + * a character set (if not, this simply establishes the default + * setting, so we haven't explicitly loaded anything) + */ + if (filename != nullptr) + S_cmap_loaded = true; + + // success + return 0; } void TADS2::cmap_override() { - // apply the default mapping - cmap_init_default(); - - /* - * pretend we have a character map loaded, so that we don't try to - * load another one if the game specifies a character set - */ - S_cmap_loaded = true; + // apply the default mapping + cmap_init_default(); + + /* + * pretend we have a character map loaded, so that we don't try to + * load another one if the game specifies a character set + */ + S_cmap_loaded = true; } void TADS2::cmap_set_game_charset(errcxdef *ec, const char *internal_id, const char *internal_ldesc, const char *argv0) { - char filename[OSFNMAX]; - - /* - * If a character set is already explicitly loaded, ignore the - * game's character set - the player asked us to use a particular - * mapping, so ignore what the game wants. (This will probably - * result in incorrect display of non-ASCII character values, but - * the player is most likely to use this to avoid errors when an - * appropriate mapping file for the game is not available. In this - * case, the player informs us by setting the option that he or she - * knows and accepts that the game will not look exactly right.) - */ - if (S_cmap_loaded) - return; - - /* - * ask the operating system to name the mapping file -- this routine - * will determine, if possible, the current native character set, - * and apply a system-specific naming convention to tell us what - * mapping file we should open - */ - os_gen_charmap_filename(filename, internal_id, argv0); - - // try loading the mapping file - if (cmap_load_internal(filename)) - errsig2(ec, ERR_CHRNOFILE, - ERRTSTR, errstr(ec, filename, strlen(filename)), - ERRTSTR, errstr(ec, internal_ldesc, strlen(internal_ldesc))); - - /** - * We were successful - the game's internal character set is now - * mapped to the current native character set. Even though we - * loaded an ldesc from the mapping file, forget that and store the - * internal ldesc that the game specified. The reason we do this is - * that it's possible that the player will dynamically switch native - * character sets in the future, at which point we'll need to - * re-load the mapping table, which could raise an error if a - * mapping file for the new character set isn't available. So, we - * may need to provide the same explanation later that we needed to - * provide here. Save the game's character set ldesc for that - * eventuality, since it describes exactly what the *game* wanted. - */ - strcpy(G_cmap_ldesc, internal_ldesc); + char filename[OSFNMAX]; + + /* + * If a character set is already explicitly loaded, ignore the + * game's character set - the player asked us to use a particular + * mapping, so ignore what the game wants. (This will probably + * result in incorrect display of non-ASCII character values, but + * the player is most likely to use this to avoid errors when an + * appropriate mapping file for the game is not available. In this + * case, the player informs us by setting the option that he or she + * knows and accepts that the game will not look exactly right.) + */ + if (S_cmap_loaded) + return; + + /* + * ask the operating system to name the mapping file -- this routine + * will determine, if possible, the current native character set, + * and apply a system-specific naming convention to tell us what + * mapping file we should open + */ + os_gen_charmap_filename(filename, internal_id, argv0); + + // try loading the mapping file + if (cmap_load_internal(filename)) + errsig2(ec, ERR_CHRNOFILE, + ERRTSTR, errstr(ec, filename, strlen(filename)), + ERRTSTR, errstr(ec, internal_ldesc, strlen(internal_ldesc))); + + /** + * We were successful - the game's internal character set is now + * mapped to the current native character set. Even though we + * loaded an ldesc from the mapping file, forget that and store the + * internal ldesc that the game specified. The reason we do this is + * that it's possible that the player will dynamically switch native + * character sets in the future, at which point we'll need to + * re-load the mapping table, which could raise an error if a + * mapping file for the new character set isn't available. So, we + * may need to provide the same explanation later that we needed to + * provide here. Save the game's character set ldesc for that + * eventuality, since it describes exactly what the *game* wanted. + */ + strcpy(G_cmap_ldesc, internal_ldesc); } } // End of namespace TADS2 diff --git a/engines/glk/unicode.cpp b/engines/glk/unicode.cpp index 4db49df60b..23bc0e9d2a 100644 --- a/engines/glk/unicode.cpp +++ b/engines/glk/unicode.cpp @@ -34,7 +34,7 @@ size_t strlen_uni(const uint32 *s) { } uint bufferChangeCase(uint32 *buf, uint len, uint numchars, BufferChangeCase destcase, - BufferChangeCond cond, int changerest) { + BufferChangeCond cond, int changerest) { uint ix, jx; uint32 *outbuf; uint32 *newoutbuf; diff --git a/engines/glk/unicode.h b/engines/glk/unicode.h index f4ad96a643..511be2d2dd 100644 --- a/engines/glk/unicode.h +++ b/engines/glk/unicode.h @@ -44,7 +44,7 @@ size_t strlen_uni(const uint32 *s); *converted string should have contained. */ extern uint bufferChangeCase(uint32 *buf, uint len, - uint numchars, BufferChangeCase destcase, BufferChangeCond cond, int changerest); + uint numchars, BufferChangeCase destcase, BufferChangeCond cond, int changerest); } // End of namespace Glk diff --git a/engines/glk/window_pair.cpp b/engines/glk/window_pair.cpp index dfec02bc43..6fdeb93635 100644 --- a/engines/glk/window_pair.cpp +++ b/engines/glk/window_pair.cpp @@ -133,19 +133,19 @@ void PairWindow::redraw() { Window *child = !_backward ? _child1 : _child2; Rect box(child->_bbox.left, child->_yAdj ? child->_bbox.top - child->_yAdj : child->_bbox.top, - child->_bbox.right, child->_bbox.bottom); + child->_bbox.right, child->_bbox.bottom); if (_vertical) { int xBord = _wBorder ? g_conf->_wBorderX : 0; int xPad = (g_conf->_wPaddingX - xBord) / 2; g_vm->_screen->fillRect(Rect(box.right + xPad, box.top, box.right + xPad + xBord, box.bottom), - g_conf->_borderColor); + g_conf->_borderColor); } else { int yBord = _wBorder ? g_conf->_wBorderY : 0; int yPad = (g_conf->_wPaddingY - yBord) / 2; g_vm->_screen->fillRect(Rect(box.left, box.bottom + yPad, box.right, box.bottom + yPad + yBord), - g_conf->_borderColor); + g_conf->_borderColor); } } @@ -205,7 +205,7 @@ void PairWindow::setArrangement(uint method, uint size, Window *keyWin) { } if (keyWin && dynamic_cast<BlankWindow *>(keyWin) - && (method & winmethod_DivisionMask) == winmethod_Fixed) { + && (method & winmethod_DivisionMask) == winmethod_Fixed) { warning("setArrangement: a Blank window cannot have a fixed size"); return; } diff --git a/engines/glk/window_text_buffer.cpp b/engines/glk/window_text_buffer.cpp index a8599c48ce..6069ec8a82 100644 --- a/engines/glk/window_text_buffer.cpp +++ b/engines/glk/window_text_buffer.cpp @@ -306,11 +306,11 @@ void TextBufferWindow::putText(const char *buf, int len, int pos, int oldlen) { if (diff != 0 && pos + oldlen < _numChars) { memmove(_chars + pos + len, - _chars + pos + oldlen, - (_numChars - (pos + oldlen)) * 4); + _chars + pos + oldlen, + (_numChars - (pos + oldlen)) * 4); memmove(_attrs + pos + len, - _attrs + pos + oldlen, - (_numChars - (pos + oldlen)) * sizeof(Attributes)); + _attrs + pos + oldlen, + (_numChars - (pos + oldlen)) * sizeof(Attributes)); } if (len > 0) { for (int i = 0; i < len; i++) { @@ -338,11 +338,11 @@ void TextBufferWindow::putTextUni(const uint32 *buf, int len, int pos, int oldle if (diff != 0 && pos + oldlen < _numChars) { memmove(_chars + pos + len, - _chars + pos + oldlen, - (_numChars - (pos + oldlen)) * 4); + _chars + pos + oldlen, + (_numChars - (pos + oldlen)) * 4); memmove(_attrs + pos + len, - _attrs + pos + oldlen, - (_numChars - (pos + oldlen)) * sizeof(Attributes)); + _attrs + pos + oldlen, + (_numChars - (pos + oldlen)) * sizeof(Attributes)); } if (len > 0) { int i; @@ -442,8 +442,8 @@ void TextBufferWindow::putCharUni(uint32 ch) { } if (g_conf->_spaces && _attr.style != style_Preformatted - && _styles[_attr.style].bg == color - && !_styles[_attr.style].reverse) { + && _styles[_attr.style].bg == color + && !_styles[_attr.style].reverse) { // turn (period space space) into (period space) if (g_conf->_spaces == 1) { if (ch == '.') @@ -480,8 +480,8 @@ void TextBufferWindow::putCharUni(uint32 ch) { // kill spaces at the end for line width calculation linelen = _numChars; while (linelen > 1 && _chars[linelen - 1] == ' ' - && _styles[_attrs[linelen - 1].style].bg == color - && !_styles[_attrs[linelen - 1].style].reverse) + && _styles[_attrs[linelen - 1].style].bg == color + && !_styles[_attrs[linelen - 1].style].reverse) linelen--; if (calcWidth(_chars, _attrs, 0, linelen, -1) >= pw) { @@ -567,8 +567,8 @@ void TextBufferWindow::click(const Point &newPos) { int gs = false; if (_lineRequest || _charRequest - || _lineRequestUni || _charRequestUni - || _moreRequest || _scrollRequest) + || _lineRequestUni || _charRequestUni + || _moreRequest || _scrollRequest) _windows->setFocus(this); if (_hyperRequest) { @@ -822,7 +822,7 @@ void TextBufferWindow::redraw() { // check if part of line is selected if (selBuf) { selrow = g_vm->_selection->getSelection(Rect(x0 / GLI_SUBPIX, y, - x1 / GLI_SUBPIX, y + g_conf->_leading), &sx0, &sx1); + x1 / GLI_SUBPIX, y + g_conf->_leading), &sx0, &sx1); selleft = (sx0 == x0 / GLI_SUBPIX); selright = (sx1 == x1 / GLI_SUBPIX); } else { @@ -842,7 +842,7 @@ void TextBufferWindow::redraw() { // repaint previously selected lines if needed if (ln->_repaint && !Windows::_forceRedraw) _windows->redrawRect(Rect(x0 / GLI_SUBPIX, y, - x1 / GLI_SUBPIX, y + g_conf->_leading)); + x1 / GLI_SUBPIX, y + g_conf->_leading)); // keep selected line dirty and flag for repaint if (!selrow) { @@ -861,8 +861,8 @@ void TextBufferWindow::redraw() { // kill spaces at the end unless they're a different color color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; while (i > 0 && linelen > 1 && ln->_chars[linelen - 1] == ' ' - && _styles[ln->_attrs[linelen - 1].style].bg == color - && !_styles[ln->_attrs[linelen - 1].style].reverse) + && _styles[ln->_attrs[linelen - 1].style].bg == color + && !_styles[ln->_attrs[linelen - 1].style].reverse) linelen --; // kill characters that would overwrite the scroll bar @@ -906,7 +906,7 @@ void TextBufferWindow::redraw() { for (tsc = 0; tsc < linelen; tsc++) { tsw = calcWidth(ln->_chars, ln->_attrs, 0, tsc, spw) / GLI_SUBPIX; if (tsw + tx >= sx0 || - ((tsw + tx + GLI_SUBPIX) >= sx0 && ln->_chars[tsc] != ' ')) { + ((tsw + tx + GLI_SUBPIX) >= sx0 && ln->_chars[tsc] != ' ')) { lsc = tsc; selchar = true; break; @@ -946,14 +946,14 @@ void TextBufferWindow::redraw() { // clear any stored hyperlink coordinates g_vm->_selection->putHyperlink(0, x0 / GLI_SUBPIX, y, - x1 / GLI_SUBPIX, y + g_conf->_leading); + x1 / GLI_SUBPIX, y + g_conf->_leading); /* * fill in background colors */ color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; screen.fillRect(Rect::fromXYWH(x0 / GLI_SUBPIX, y, (x1 - x0) / GLI_SUBPIX, g_conf->_leading), - color); + color); x = x0 + SLOP + ln->_lm; a = 0; @@ -964,13 +964,13 @@ void TextBufferWindow::redraw() { color = ln->_attrs[a].attrBg(_styles); w = screen.stringWidthUni(font, Common::U32String(ln->_chars + a, b - a), spw); screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, w / GLI_SUBPIX, g_conf->_leading), - color); + color); if (link) { screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX + 1, y + g_conf->_baseLine + 1, - w / GLI_SUBPIX + 1, g_conf->_linkStyle), g_conf->_linkColor); + w / GLI_SUBPIX + 1, g_conf->_linkStyle), g_conf->_linkColor); g_vm->_selection->putHyperlink(link, x / GLI_SUBPIX, y, - x / GLI_SUBPIX + w / GLI_SUBPIX, - y + g_conf->_leading); + x / GLI_SUBPIX + w / GLI_SUBPIX, + y + g_conf->_leading); } x += w; a = b; @@ -983,10 +983,10 @@ void TextBufferWindow::redraw() { screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, w / GLI_SUBPIX, g_conf->_leading), color); if (link) { screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX + 1, y + g_conf->_baseLine + 1, - w / GLI_SUBPIX + 1, g_conf->_linkStyle), g_conf->_linkColor); + w / GLI_SUBPIX + 1, g_conf->_linkStyle), g_conf->_linkColor); g_vm->_selection->putHyperlink(link, x / GLI_SUBPIX, y, - x / GLI_SUBPIX + w / GLI_SUBPIX, - y + g_conf->_leading); + x / GLI_SUBPIX + w / GLI_SUBPIX, + y + g_conf->_leading); } x += w; @@ -1015,7 +1015,7 @@ void TextBufferWindow::redraw() { font = ln->_attrs[a].attrFont(_styles); color = link ? g_conf->_linkColor : ln->_attrs[a].attrFg(_styles); x = screen.drawStringUni(Point(x, y + g_conf->_baseLine), - font, color, Common::U32String(ln->_chars + a, b - a), spw); + font, color, Common::U32String(ln->_chars + a, b - a), spw); a = b; } } @@ -1033,7 +1033,7 @@ void TextBufferWindow::redraw() { y = y0 + (_height - 1) * g_conf->_leading; g_vm->_selection->putHyperlink(0, x0 / GLI_SUBPIX, y, - x1 / GLI_SUBPIX, y + g_conf->_leading); + x1 / GLI_SUBPIX, y + g_conf->_leading); color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, x1 / GLI_SUBPIX - x / GLI_SUBPIX, g_conf->_leading), color); @@ -1049,7 +1049,7 @@ void TextBufferWindow::redraw() { color = Windows::_overrideFgSet ? g_conf->_moreColor : _fgColor; screen.drawString(Point(x, y + g_conf->_baseLine), - g_conf->_moreFont, color, g_conf->_morePrompt); + g_conf->_moreFont, color, g_conf->_morePrompt); y1 = y; // don't want pictures overdrawing "[more]" // try to claim the focus @@ -1077,8 +1077,8 @@ void TextBufferWindow::redraw() { hy1 = y + ln->_lPic->h < y1 ? y + ln->_lPic->h : y1; hx0 = x0 / GLI_SUBPIX; hx1 = x0 / GLI_SUBPIX + ln->_lPic->w < x1 / GLI_SUBPIX - ? x0 / GLI_SUBPIX + ln->_lPic->w - : x1 / GLI_SUBPIX; + ? x0 / GLI_SUBPIX + ln->_lPic->w + : x1 / GLI_SUBPIX; g_vm->_selection->putHyperlink(link, hx0, hy0, hx1, hy1); } } @@ -1091,8 +1091,8 @@ void TextBufferWindow::redraw() { hy0 = y > y0 ? y : y0; hy1 = y + ln->_rPic->h < y1 ? y + ln->_rPic->h : y1; hx0 = x1 / GLI_SUBPIX - ln->_rPic->w > x0 / GLI_SUBPIX - ? x1 / GLI_SUBPIX - ln->_rPic->w - : x0 / GLI_SUBPIX; + ? x1 / GLI_SUBPIX - ln->_rPic->w + : x0 / GLI_SUBPIX; hx1 = x1 / GLI_SUBPIX; g_vm->_selection->putHyperlink(link, hx0, hy0, hx1, hy1); } @@ -1133,9 +1133,9 @@ void TextBufferWindow::redraw() { for (i = 0; i < g_conf->_scrollWidth / 2 + 1; i++) { screen.fillRect(Rect::fromXYWH(x0 + g_conf->_scrollWidth / 2 - i, - y0 - g_conf->_scrollWidth / 2 + i, i * 2, 1), g_conf->_scrollFg); + y0 - g_conf->_scrollWidth / 2 + i, i * 2, 1), g_conf->_scrollFg); screen.fillRect(Rect::fromXYWH(x0 + g_conf->_scrollWidth / 2 - i, - y1 + g_conf->_scrollWidth / 2 - i, i * 2, 1), g_conf->_scrollFg); + y1 + g_conf->_scrollWidth / 2 - i, i * 2, 1), g_conf->_scrollFg); } } @@ -1208,8 +1208,8 @@ void TextBufferWindow::acceptReadChar(uint arg) { _scrollPos = 0; if (_scrollPos - || arg == keycode_PageUp - || arg == keycode_MouseWheelUp) { + || arg == keycode_PageUp + || arg == keycode_MouseWheelUp) { acceptScroll(arg); return; } @@ -1502,7 +1502,7 @@ void TextBufferWindow::scrollOneLine(bool forced) { _scrollMax++; if (_scrollMax > _scrollBack - 1 - || _lastSeen > _scrollBack - 1) + || _lastSeen > _scrollBack - 1) scrollResize(); if (_lastSeen >= _height) @@ -1581,7 +1581,7 @@ void TextBufferWindow::scrollResize() { } int TextBufferWindow::calcWidth(uint32 *chars, Attributes *attrs, int startchar, - int numChars, int spw) { + int numChars, int spw) { Screen &screen = *g_vm->_screen; int w = 0; int a, b; @@ -1590,7 +1590,7 @@ int TextBufferWindow::calcWidth(uint32 *chars, Attributes *attrs, int startchar, for (b = startchar; b < numChars; b++) { if (attrs[a] != attrs[b]) { w += screen.stringWidthUni(attrs[a].attrFont(_styles), - Common::U32String(chars + a, b - a), spw); + Common::U32String(chars + a, b - a), spw); a = b; } } diff --git a/engines/glk/window_text_grid.cpp b/engines/glk/window_text_grid.cpp index 7f5b514ec7..b621fec8e7 100644 --- a/engines/glk/window_text_grid.cpp +++ b/engines/glk/window_text_grid.cpp @@ -193,7 +193,7 @@ void TextGridWindow::click(const Point &newPos) { int y = newPos.y - _bbox.top; if (_lineRequest || _charRequest || _lineRequestUni || _charRequestUni - || _moreRequest || _scrollRequest) + || _moreRequest || _scrollRequest) _windows->setFocus(this); if (_mouseRequest) { @@ -603,11 +603,11 @@ void TextGridWindow::redraw() { for (k = a, o = x; k < b; k++, o += g_conf->_cellW) { screen.drawStringUni(Point(o * GLI_SUBPIX, y + g_conf->_baseLine), font, - fgcolor, Common::U32String(&ln->_chars[k], 1), -1); + fgcolor, Common::U32String(&ln->_chars[k], 1), -1); } if (link) { screen.fillRect(Rect::fromXYWH(x, y + g_conf->_baseLine + 1, w, - g_conf->_linkStyle), g_conf->_linkColor); + g_conf->_linkStyle), g_conf->_linkColor); g_vm->_selection->putHyperlink(link, x, y, x + w, y + g_conf->_leading); } @@ -625,11 +625,11 @@ void TextGridWindow::redraw() { for (k = a, o = x; k < b; k++, o += g_conf->_cellW) { screen.drawStringUni(Point(o * GLI_SUBPIX, y + g_conf->_baseLine), font, - fgcolor, Common::U32String(&ln->_chars[k], 1)); + fgcolor, Common::U32String(&ln->_chars[k], 1)); } if (link) { screen.fillRect(Rect::fromXYWH(x, y + g_conf->_baseLine + 1, w, g_conf->_linkStyle), - g_conf->_linkColor); + g_conf->_linkColor); g_vm->_selection->putHyperlink(link, x, y, x + w, y + g_conf->_leading); } } diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp index e689cb9a81..8562e347ee 100644 --- a/engines/glk/windows.cpp +++ b/engines/glk/windows.cpp @@ -75,7 +75,7 @@ Windows::~Windows() { } Window *Windows::windowOpen(Window *splitwin, uint method, uint size, - uint wintype, uint rock) { + uint wintype, uint rock) { Window *newwin, *oldparent; PairWindow *pairWin; uint val; @@ -104,7 +104,7 @@ Window *Windows::windowOpen(Window *splitwin, uint method, uint size, val = (method & winmethod_DirMask); if (val != winmethod_Above && val != winmethod_Below - && val != winmethod_Left && val != winmethod_Right) { + && val != winmethod_Left && val != winmethod_Right) { warning("window_open: invalid method (bad direction)"); return nullptr; } @@ -284,8 +284,8 @@ void Windows::inputGuessFocus() { do { if (altWin - && (altWin->_lineRequest || altWin->_charRequest || - altWin->_lineRequestUni || altWin->_charRequestUni)) + && (altWin->_lineRequest || altWin->_charRequest || + altWin->_lineRequestUni || altWin->_charRequestUni)) break; altWin = iterateTreeOrder(altWin); } while (altWin != _focusWin); @@ -315,8 +315,8 @@ void Windows::inputNextFocus() { do { altWin = iterateTreeOrder(altWin); if (altWin - && (altWin->_lineRequest || altWin->_charRequest || - altWin->_lineRequestUni || altWin->_charRequestUni)) + && (altWin->_lineRequest || altWin->_charRequest || + altWin->_lineRequestUni || altWin->_charRequestUni)) break; } while (altWin != _focusWin); diff --git a/engines/glk/windows.h b/engines/glk/windows.h index ed9b777814..337ad57be4 100644 --- a/engines/glk/windows.h +++ b/engines/glk/windows.h @@ -160,7 +160,7 @@ public: * Open a new window */ Window *windowOpen(Window *splitwin, uint method, uint size, - uint wintype, uint rock); + uint wintype, uint rock); /** * Close an existing window @@ -329,16 +329,16 @@ struct Attributes { */ bool operator==(const Attributes &src) { return fgset == src.fgset && bgset == src.bgset && reverse == src.reverse - && style == src.style && fgcolor == src.fgcolor && bgcolor == src.bgcolor - && hyper == src.hyper; + && style == src.style && fgcolor == src.fgcolor && bgcolor == src.bgcolor + && hyper == src.hyper; } /** * Inequality comparison */ bool operator!=(const Attributes &src) { return fgset != src.fgset || bgset != src.bgset || reverse != src.reverse - || style != src.style || fgcolor != src.fgcolor || bgcolor != src.bgcolor - || hyper != src.hyper; + || style != src.style || fgcolor != src.fgcolor || bgcolor != src.bgcolor + || hyper != src.hyper; } /** |