From 2a7fc86b15fc985b6c127a776b597f154653e52c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 20:44:35 -0400 Subject: [PATCH 01/21] Enabled stricter warnings. --- .../Mac/Clock Signal.xcodeproj/project.pbxproj | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index fe0f78dc4..2925ec984 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -2901,10 +2901,19 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CLANG_WARN_ASSIGN_ENUM = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; CODE_SIGN_ENTITLEMENTS = "Clock Signal/Clock Signal.entitlements"; COMBINE_HIDPI_IMAGES = YES; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; INFOPLIST_FILE = "Clock Signal/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "TH.Clock-Signal"; @@ -2920,10 +2929,19 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; + CLANG_WARN_ASSIGN_ENUM = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; CODE_SIGN_ENTITLEMENTS = "Clock Signal/Clock Signal.entitlements"; COMBINE_HIDPI_IMAGES = YES; + GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; + GCC_WARN_ABOUT_MISSING_NEWLINE = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; + GCC_WARN_SHADOW = YES; + GCC_WARN_SIGN_COMPARE = YES; INFOPLIST_FILE = "Clock Signal/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "TH.Clock-Signal"; From 2471ef805bdf3f1d6691f6624b124c5b1a62ba5b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 20:45:49 -0400 Subject: [PATCH 02/21] Fixed signed/unsigned comparison and potential negative table reference. --- Machines/ZX8081/Typer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Machines/ZX8081/Typer.cpp b/Machines/ZX8081/Typer.cpp index 7bc08fa32..f5a38f33c 100644 --- a/Machines/ZX8081/Typer.cpp +++ b/Machines/ZX8081/Typer.cpp @@ -148,9 +148,10 @@ uint16_t *ZX8081::Machine::sequence_for_character(Utility::Typer *typer, char ch #undef SHIFT #undef X - if(character > sizeof(zx81_key_sequences) / sizeof(*zx81_key_sequences)) return nullptr; + size_t ucharacter = (size_t)character; + if(ucharacter > sizeof(zx81_key_sequences) / sizeof(*zx81_key_sequences)) return nullptr; KeyTable *table = is_zx81_ ? &zx81_key_sequences : &zx80_key_sequences; - if((*table)[character][0] == NotMapped) return nullptr; - return (uint16_t *)(*table)[character]; + if((*table)[ucharacter][0] == NotMapped) return nullptr; + return (uint16_t *)(*table)[ucharacter]; } From 5b4c5b0cbf5c9f1949178e0951c9f2b89ddc77af Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 20:46:08 -0400 Subject: [PATCH 03/21] Avoided having two different variables named next_output_run. --- Outputs/CRT/CRT.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Outputs/CRT/CRT.cpp b/Outputs/CRT/CRT.cpp index e612dab5e..6b5c4ec80 100644 --- a/Outputs/CRT/CRT.cpp +++ b/Outputs/CRT/CRT.cpp @@ -102,10 +102,10 @@ Flywheel::SyncEvent CRT::get_next_horizontal_sync_event(bool hsync_is_requested, return horizontal_flywheel_->get_next_event_in_period(hsync_is_requested, cycles_to_run_for, cycles_advanced); } -#define output_x1() (*(uint16_t *)&next_run[OutputVertexOffsetOfHorizontal + 0]) -#define output_x2() (*(uint16_t *)&next_run[OutputVertexOffsetOfHorizontal + 2]) -#define output_position_y() (*(uint16_t *)&next_run[OutputVertexOffsetOfVertical + 0]) -#define output_tex_y() (*(uint16_t *)&next_run[OutputVertexOffsetOfVertical + 2]) +#define output_x1() (*(uint16_t *)&next_output_run[OutputVertexOffsetOfHorizontal + 0]) +#define output_x2() (*(uint16_t *)&next_output_run[OutputVertexOffsetOfHorizontal + 2]) +#define output_position_y() (*(uint16_t *)&next_output_run[OutputVertexOffsetOfVertical + 0]) +#define output_tex_y() (*(uint16_t *)&next_output_run[OutputVertexOffsetOfVertical + 2]) #define source_input_position_x1() (*(uint16_t *)&next_run[SourceVertexOffsetOfInputStart + 0]) #define source_input_position_y() (*(uint16_t *)&next_run[SourceVertexOffsetOfInputStart + 2]) @@ -192,8 +192,8 @@ void CRT::advance_cycles(unsigned int number_of_cycles, bool hsync_requested, bo const uint16_t output_y = openGL_output_builder_.get_composite_output_y(); // Construct the output run - uint8_t *next_run = openGL_output_builder_.array_builder.get_output_storage(OutputVertexSize); - if(next_run) { + uint8_t *next_output_run = openGL_output_builder_.array_builder.get_output_storage(OutputVertexSize); + if(next_output_run) { output_x1() = output_run_.x1; output_position_y() = output_run_.y; output_tex_y() = output_y; From 2d8e7e9f8b40d798c65e75b25cd47078cb138400 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 20:46:25 -0400 Subject: [PATCH 04/21] Removed reference to a parameter long-since dead. --- Storage/Tape/Formats/TapePRG.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Storage/Tape/Formats/TapePRG.hpp b/Storage/Tape/Formats/TapePRG.hpp index c2be2dc9a..a8de13790 100644 --- a/Storage/Tape/Formats/TapePRG.hpp +++ b/Storage/Tape/Formats/TapePRG.hpp @@ -25,7 +25,6 @@ class PRG: public Tape, public Storage::FileHolder { Constructs a @c T64 containing content from the file with name @c file_name, of type @c type. @param file_name The name of the file to load. - @param type The type of data the file should contain. @throws ErrorBadFormat if this file could not be opened and recognised as the specified type. */ PRG(const char *file_name); From 807e1d36d5b03766cbcf1645684755bd853fbd3c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 20:57:48 -0400 Subject: [PATCH 05/21] Resolved signedness mismatch. --- StaticAnalyser/Acorn/Tape.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/StaticAnalyser/Acorn/Tape.cpp b/StaticAnalyser/Acorn/Tape.cpp index 358b643ea..68d67f737 100644 --- a/StaticAnalyser/Acorn/Tape.cpp +++ b/StaticAnalyser/Acorn/Tape.cpp @@ -38,7 +38,7 @@ static std::unique_ptr GetNextChunk(const std::shared_ptris_at_end() && name_ptr < sizeof(name)) { name[name_ptr] = (char)parser.get_next_byte(tape); if(!name[name_ptr]) break; @@ -80,7 +80,7 @@ static std::unique_ptr GetNextChunk(const std::shared_ptr GetNextFile(std::deque &chunks) { +static std::unique_ptr GetNextFile(std::deque &chunks) { // find next chunk with a block number of 0 while(chunks.size() && chunks.front().block_number) { chunks.pop_front(); From 163c0f1b445f027ba208b0c29ad24e407c726482 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 20:58:17 -0400 Subject: [PATCH 06/21] Ensured `offset` means exactly one thing. --- Storage/Disk/DigitalPhaseLockedLoop.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Storage/Disk/DigitalPhaseLockedLoop.cpp b/Storage/Disk/DigitalPhaseLockedLoop.cpp index d29410e8d..0548eeb68 100644 --- a/Storage/Disk/DigitalPhaseLockedLoop.cpp +++ b/Storage/Disk/DigitalPhaseLockedLoop.cpp @@ -47,8 +47,8 @@ void DigitalPhaseLockedLoop::add_pulse() { } } -void DigitalPhaseLockedLoop::post_phase_offset(int phase, int offset) { - offset_history_[offset_history_pointer_] = offset; +void DigitalPhaseLockedLoop::post_phase_offset(int new_phase, int new_offset) { + offset_history_[offset_history_pointer_] = new_offset; offset_history_pointer_ = (offset_history_pointer_ + 1) % offset_history_.size(); // use an unweighted average of the stored offsets to compute current window size, @@ -65,7 +65,7 @@ void DigitalPhaseLockedLoop::post_phase_offset(int phase, int offset) { window_length_ = total_spacing / total_divisor; } - int error = phase - (window_length_ >> 1); + int error = new_phase - (window_length_ >> 1); // use a simple spring mechanism as a lowpass filter for phase phase_ -= (error + 1) >> 1; From ef03c84b21ab0f528313a44dd274dd93db58216f Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 20:58:55 -0400 Subject: [PATCH 07/21] More definitively removed the old sample-offset blending approach to filtering. --- .../CRT/Internals/Shaders/IntermediateShader.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp index 4103230a5..894e4f293 100644 --- a/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp +++ b/Outputs/CRT/Internals/Shaders/IntermediateShader.cpp @@ -331,7 +331,7 @@ void IntermediateShader::set_filter_coefficients(float sampling_rate, float cuto GLfloat offsets[5]; unsigned int taps = 11; // unsigned int taps = 21; - while(1) { +// while(1) { float coefficients[21]; SignalProcessing::FIRFilter luminance_filter(taps, sampling_rate, 0.0f, cutoff_frequency, SignalProcessing::FIRFilter::DefaultAttenuation); luminance_filter.get_coefficients(coefficients); @@ -341,12 +341,12 @@ void IntermediateShader::set_filter_coefficients(float sampling_rate, float cuto memset(weights, 0, sizeof(float)*12); memset(offsets, 0, sizeof(float)*5); - int halfSize = (taps >> 1); - for(int c = 0; c < taps; c++) { - if(c < 5) offsets[c] = (halfSize - c); + unsigned int half_size = (taps >> 1); + for(unsigned int c = 0; c < taps; c++) { + if(c < 5) offsets[c] = (half_size - c); weights[c] = coefficients[c]; } - break; +// break; // int halfSize = (taps >> 1); // while(c < halfSize && sample < 5) { @@ -368,8 +368,8 @@ void IntermediateShader::set_filter_coefficients(float sampling_rate, float cuto // } // break; // } - taps -= 2; - } +// taps -= 2; +// } set_uniform("weights", 4, 3, weights); set_uniform("offsets", 1, 5, offsets); From 3f609e17b3d1e9e686a59f776deee498bdb48e95 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:18:51 -0400 Subject: [PATCH 08/21] Factored out the table-lookup approach to being a typer, and adjusted so as definitely to limit myself to positive offset table lookups. --- Machines/Commodore/Vic-20/Typer.cpp | 10 ++++------ Machines/Commodore/Vic-20/Vic20.hpp | 2 -- Machines/Electron/Electron.hpp | 2 -- Machines/Electron/Typer.cpp | 12 +++++------- Machines/Oric/Oric.hpp | 2 -- Machines/Oric/Typer.cpp | 10 ++++------ Machines/Typer.cpp | 7 +++++++ Machines/Typer.hpp | 4 ++++ Machines/ZX8081/Typer.cpp | 19 ++++++++----------- Machines/ZX8081/ZX8081.hpp | 2 -- 10 files changed, 32 insertions(+), 38 deletions(-) diff --git a/Machines/Commodore/Vic-20/Typer.cpp b/Machines/Commodore/Vic-20/Typer.cpp index ef6a4f98e..982651742 100644 --- a/Machines/Commodore/Vic-20/Typer.cpp +++ b/Machines/Commodore/Vic-20/Typer.cpp @@ -9,10 +9,10 @@ #include "Vic20.hpp" uint16_t *Commodore::Vic20::Machine::sequence_for_character(Utility::Typer *typer, char character) { -#define KEYS(...) {__VA_ARGS__, TerminateSequence} -#define SHIFT(...) {KeyLShift, __VA_ARGS__, TerminateSequence} +#define KEYS(...) {__VA_ARGS__, EndSequence} +#define SHIFT(...) {KeyLShift, __VA_ARGS__, EndSequence} #define X {NotMapped} - static Key key_sequences[][3] = { + static KeySequence key_sequences[] = { /* NUL */ X, /* SOH */ X, /* STX */ X, /* ETX */ X, /* EOT */ X, /* ENQ */ X, @@ -80,7 +80,5 @@ uint16_t *Commodore::Vic20::Machine::sequence_for_character(Utility::Typer *type #undef SHIFT #undef X - if(character > sizeof(key_sequences) / sizeof(*key_sequences)) return nullptr; - if(key_sequences[character][0] == NotMapped) return nullptr; - return (uint16_t *)key_sequences[character]; + return table_lookup_sequence_for_character(key_sequences, sizeof(key_sequences), character); } diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index 86b4c88ca..e70c845cd 100644 --- a/Machines/Commodore/Vic-20/Vic20.hpp +++ b/Machines/Commodore/Vic-20/Vic20.hpp @@ -63,8 +63,6 @@ enum Key: uint16_t { KeyI = key(1, 0x10), KeyP = key(1, 0x20), KeyAsterisk = key(1, 0x40), KeyReturn = key(1, 0x80), Key1 = key(0, 0x01), Key3 = key(0, 0x02), Key5 = key(0, 0x04), Key7 = key(0, 0x08), Key9 = key(0, 0x10), KeyPlus = key(0, 0x20), KeyGBP = key(0, 0x40), KeyDelete = key(0, 0x80), - - TerminateSequence = 0xffff, NotMapped = 0xfffe }; enum JoystickInput { diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index 8bcbea878..f24462a51 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -57,8 +57,6 @@ enum Key: uint16_t { KeyShift = 0x00d0 | 0x08, KeyControl = 0x00d0 | 0x04, KeyFunc = 0x00d0 | 0x02, KeyEscape = 0x00d0 | 0x01, KeyBreak = 0xfffd, - - TerminateSequence = 0xffff, NotMapped = 0xfffe, }; /*! diff --git a/Machines/Electron/Typer.cpp b/Machines/Electron/Typer.cpp index 2f431eec1..d0fcd1bab 100644 --- a/Machines/Electron/Typer.cpp +++ b/Machines/Electron/Typer.cpp @@ -17,11 +17,11 @@ int Electron::Machine::get_typer_frequency() { } uint16_t *Electron::Machine::sequence_for_character(Utility::Typer *typer, char character) { -#define KEYS(...) {__VA_ARGS__, TerminateSequence} -#define SHIFT(...) {KeyShift, __VA_ARGS__, TerminateSequence} -#define CTRL(...) {KeyControl, __VA_ARGS__, TerminateSequence} +#define KEYS(...) {__VA_ARGS__, EndSequence} +#define SHIFT(...) {KeyShift, __VA_ARGS__, EndSequence} +#define CTRL(...) {KeyControl, __VA_ARGS__, EndSequence} #define X {NotMapped} - static Key key_sequences[][3] = { + static KeySequence key_sequences[] = { /* NUL */ X, /* SOH */ X, /* STX */ X, /* ETX */ X, /* EOT */ X, /* ENQ */ X, @@ -91,7 +91,5 @@ uint16_t *Electron::Machine::sequence_for_character(Utility::Typer *typer, char #undef SHIFT #undef X - if(character > sizeof(key_sequences) / sizeof(*key_sequences)) return nullptr; - if(key_sequences[character][0] == NotMapped) return nullptr; - return (uint16_t *)key_sequences[character]; + return table_lookup_sequence_for_character(key_sequences, sizeof(key_sequences), character); } diff --git a/Machines/Oric/Oric.hpp b/Machines/Oric/Oric.hpp index cef8d56ac..43766d710 100644 --- a/Machines/Oric/Oric.hpp +++ b/Machines/Oric/Oric.hpp @@ -48,8 +48,6 @@ enum Key: uint16_t { KeyForwardSlash = 0x0700 | 0x08, Key0 = 0x0700 | 0x04, KeyL = 0x0700 | 0x02, Key8 = 0x0700 | 0x01, KeyNMI = 0xfffd, - - TerminateSequence = 0xffff, NotMapped = 0xfffe }; enum ROM { diff --git a/Machines/Oric/Typer.cpp b/Machines/Oric/Typer.cpp index dd66a972c..117665769 100644 --- a/Machines/Oric/Typer.cpp +++ b/Machines/Oric/Typer.cpp @@ -1,10 +1,10 @@ #include "Oric.hpp" uint16_t *Oric::Machine::sequence_for_character(Utility::Typer *typer, char character) { -#define KEYS(...) {__VA_ARGS__, TerminateSequence} -#define SHIFT(...) {KeyLeftShift, __VA_ARGS__, TerminateSequence} +#define KEYS(...) {__VA_ARGS__, EndSequence} +#define SHIFT(...) {KeyLeftShift, __VA_ARGS__, EndSequence} #define X {NotMapped} - static Key key_sequences[][3] = { + static KeySequence key_sequences[] = { /* NUL */ X, /* SOH */ X, /* STX */ X, /* ETX */ X, /* EOT */ X, /* ENQ */ X, @@ -73,7 +73,5 @@ uint16_t *Oric::Machine::sequence_for_character(Utility::Typer *typer, char char #undef SHIFT #undef X - if(character > sizeof(key_sequences) / sizeof(*key_sequences)) return nullptr; - if(key_sequences[character][0] == NotMapped) return nullptr; - return (uint16_t *)key_sequences[character]; + return table_lookup_sequence_for_character(key_sequences, sizeof(key_sequences), character); } diff --git a/Machines/Typer.cpp b/Machines/Typer.cpp index 241dc3810..3238476a4 100644 --- a/Machines/Typer.cpp +++ b/Machines/Typer.cpp @@ -77,3 +77,10 @@ bool Typer::Delegate::typer_set_next_character(Utility::Typer *typer, char chara uint16_t *Typer::Delegate::sequence_for_character(Typer *typer, char character) { return nullptr; } + +uint16_t *Typer::Delegate::table_lookup_sequence_for_character(KeySequence *sequences, size_t length, char character) { + size_t ucharacter = (size_t)((unsigned char)character); + if(ucharacter > (length / sizeof(KeySequence))) return nullptr; + if(sequences[ucharacter][0] == NotMapped) return nullptr; + return sequences[ucharacter]; +} diff --git a/Machines/Typer.hpp b/Machines/Typer.hpp index dc089d4c4..2ed013e09 100644 --- a/Machines/Typer.hpp +++ b/Machines/Typer.hpp @@ -23,7 +23,11 @@ class Typer { virtual uint16_t *sequence_for_character(Typer *typer, char character); + typedef uint16_t KeySequence[16]; + uint16_t *table_lookup_sequence_for_character(KeySequence *sequences, size_t length, char character); + const uint16_t EndSequence = 0xffff; + const uint16_t NotMapped = 0xfffe; }; Typer(const char *string, int delay, int frequency, Delegate *delegate); diff --git a/Machines/ZX8081/Typer.cpp b/Machines/ZX8081/Typer.cpp index f5a38f33c..089392678 100644 --- a/Machines/ZX8081/Typer.cpp +++ b/Machines/ZX8081/Typer.cpp @@ -9,11 +9,10 @@ #include "ZX8081.hpp" uint16_t *ZX8081::Machine::sequence_for_character(Utility::Typer *typer, char character) { -#define KEYS(...) {__VA_ARGS__, TerminateSequence} -#define SHIFT(...) {KeyShift, __VA_ARGS__, TerminateSequence} +#define KEYS(...) {__VA_ARGS__, EndSequence} +#define SHIFT(...) {KeyShift, __VA_ARGS__, EndSequence} #define X {NotMapped} - typedef Key KeyTable[126][3]; - KeyTable zx81_key_sequences = { + static KeySequence zx81_key_sequences[] = { /* NUL */ X, /* SOH */ X, /* STX */ X, /* ETX */ X, /* EOT */ X, /* ENQ */ X, @@ -79,7 +78,7 @@ uint16_t *ZX8081::Machine::sequence_for_character(Utility::Typer *typer, char ch /* | */ X, /* } */ X, }; - KeyTable zx80_key_sequences = { + static KeySequence zx80_key_sequences[] = { /* NUL */ X, /* SOH */ X, /* STX */ X, /* ETX */ X, /* EOT */ X, /* ENQ */ X, @@ -148,10 +147,8 @@ uint16_t *ZX8081::Machine::sequence_for_character(Utility::Typer *typer, char ch #undef SHIFT #undef X - size_t ucharacter = (size_t)character; - if(ucharacter > sizeof(zx81_key_sequences) / sizeof(*zx81_key_sequences)) return nullptr; - - KeyTable *table = is_zx81_ ? &zx81_key_sequences : &zx80_key_sequences; - if((*table)[ucharacter][0] == NotMapped) return nullptr; - return (uint16_t *)(*table)[ucharacter]; + if(is_zx81_) + return table_lookup_sequence_for_character(zx81_key_sequences, sizeof(zx81_key_sequences), character); + else + return table_lookup_sequence_for_character(zx80_key_sequences, sizeof(zx80_key_sequences), character); } diff --git a/Machines/ZX8081/ZX8081.hpp b/Machines/ZX8081/ZX8081.hpp index 4b6bf9dda..c2f36a6ff 100644 --- a/Machines/ZX8081/ZX8081.hpp +++ b/Machines/ZX8081/ZX8081.hpp @@ -37,8 +37,6 @@ enum Key: uint16_t { KeyP = 0x0500 | 0x01, KeyO = 0x0500 | 0x02, KeyI = 0x0500 | 0x04, KeyU = 0x0500 | 0x08, KeyY = 0x0500 | 0x10, KeyEnter = 0x0600 | 0x01, KeyL = 0x0600 | 0x02, KeyK = 0x0600 | 0x04, KeyJ = 0x0600 | 0x08, KeyH = 0x0600 | 0x10, KeySpace = 0x0700 | 0x01, KeyDot = 0x0700 | 0x02, KeyM = 0x0700 | 0x04, KeyN = 0x0700 | 0x08, KeyB = 0x0700 | 0x10, - - TerminateSequence = 0xffff, NotMapped = 0xfffe }; class Machine: From 9b72c445a74e94bbfe8fc8043fd6d54b8aa854b4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:19:46 -0400 Subject: [PATCH 09/21] Fixed indexing type. --- Processors/Z80/Z80.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Processors/Z80/Z80.hpp b/Processors/Z80/Z80.hpp index 1bd3c7577..7d260855a 100644 --- a/Processors/Z80/Z80.hpp +++ b/Processors/Z80/Z80.hpp @@ -426,7 +426,7 @@ template class Processor { size_t destination = 0; for(size_t c = 0; c < 256; c++) { target.instructions[c] = &target.all_operations[destination]; - for(int t = 0; t < lengths[c];) { + for(size_t t = 0; t < lengths[c];) { // Skip zero-length bus cycles. if(table[c][t].type == MicroOp::BusOperation && table[c][t].machine_cycle.length == 0) { t++; From aaa60dab121f67ab499a789cb226ffe804fed80f Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:21:01 -0400 Subject: [PATCH 10/21] Fixed signedness of index. --- Components/AY38910/AY38910.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Components/AY38910/AY38910.cpp b/Components/AY38910/AY38910.cpp index 35d528d0e..22769b805 100644 --- a/Components/AY38910/AY38910.cpp +++ b/Components/AY38910/AY38910.cpp @@ -76,7 +76,7 @@ void AY38910::set_clock_rate(double clock_rate) { } void AY38910::get_samples(unsigned int number_of_samples, int16_t *target) { - int c = 0; + unsigned int c = 0; while((master_divider_&7) && c < number_of_samples) { target[c] = output_volume_; master_divider_++; From 53f0e1896bedc94fb0960d03080ed28f68878147 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:21:23 -0400 Subject: [PATCH 11/21] Made delay_time_ unsigned for safe comparison. --- Components/1770/1770.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Components/1770/1770.hpp b/Components/1770/1770.hpp index 27170dc51..285552be7 100644 --- a/Components/1770/1770.hpp +++ b/Components/1770/1770.hpp @@ -123,7 +123,7 @@ class WD1770: public Storage::Disk::Controller { void posit_event(Event type); int interesting_event_mask_; int resume_point_; - int delay_time_; + unsigned int delay_time_; // Output int last_bit_; From 64865b3f417fc6f425d1bb166a5d23e7c8972102 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:23:34 -0400 Subject: [PATCH 12/21] Signedness fixes. --- Components/1770/1770.cpp | 2 +- Storage/Tape/Formats/TZX.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Components/1770/1770.cpp b/Components/1770/1770.cpp index 383a2eb41..6e2011f45 100644 --- a/Components/1770/1770.cpp +++ b/Components/1770/1770.cpp @@ -403,7 +403,7 @@ void WD1770::posit_event(Event new_event_type) { goto verify; } step(step_direction_ ? 1 : -1); - int time_to_wait; + unsigned int time_to_wait; switch(command_ & 3) { default: case 0: time_to_wait = 6; break; diff --git a/Storage/Tape/Formats/TZX.cpp b/Storage/Tape/Formats/TZX.cpp index 37b0cb169..6814b8bcd 100644 --- a/Storage/Tape/Formats/TZX.cpp +++ b/Storage/Tape/Formats/TZX.cpp @@ -126,7 +126,7 @@ void TZX::get_generalised_segment(uint32_t output_symbols, uint8_t max_pulses_pe base <<= 1; bits++; } - for(int c = 0; c < output_symbols; c++) { + for(size_t c = 0; c < output_symbols; c++) { uint8_t symbol_value; int count; if(is_data) { From 6d5807ec4b24acf548f548073a448521a0b8abed Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:24:28 -0400 Subject: [PATCH 13/21] Fixed sign and ensured that the `DataFromString` implementation is of the thing declared in the header. --- Storage/Data/ZX8081.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Storage/Data/ZX8081.cpp b/Storage/Data/ZX8081.cpp index d706dfc4b..ada6f2e6d 100644 --- a/Storage/Data/ZX8081.cpp +++ b/Storage/Data/ZX8081.cpp @@ -51,7 +51,7 @@ static std::shared_ptr ZX81FileFromData(const std::vector &data) // Look for a file name. size_t data_pointer = 0; std::vector name_data; - int c = 11; + size_t c = 11; while(c < data.size() && c--) { name_data.push_back(data[data_pointer] & 0x3f); if(data[data_pointer] & 0x80) break; @@ -121,7 +121,7 @@ std::wstring Storage::Data::ZX8081::StringFromData(const std::vector &d return string; } -std::vector DataFromString(const std::wstring &string, bool is_zx81) { +std::vector Storage::Data::ZX8081::DataFromString(const std::wstring &string, bool is_zx81) { std::vector data; // TODO From 2b5d0877a872e07f2c545c47445f3490eea31c80 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:27:50 -0400 Subject: [PATCH 14/21] Adjusted parameter name to match documentation. I think it's a carry-over from before I was passing the whole event along. --- OSBindings/Mac/Clock Signal/Views/CSOpenGLView.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.h b/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.h index 34d08584e..3e18f5371 100644 --- a/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.h +++ b/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.h @@ -43,7 +43,7 @@ @c CSOpenGLViewResponderDelegate methods and as -[CSOpenGLViewDelegate openGLView:didUpdateToTime:]. @param event The @c NSEvent describing the flagsChanged. */ -- (void)flagsChanged:(nonnull NSEvent *)newModifiers; +- (void)flagsChanged:(nonnull NSEvent *)event; @end From 449c33ee8bbde7de84da1e671f0adf7762c51256 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:28:04 -0400 Subject: [PATCH 15/21] Signedness fixes. --- Outputs/CRT/Internals/CRTOpenGL.cpp | 2 +- Outputs/Speaker.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Outputs/CRT/Internals/CRTOpenGL.cpp b/Outputs/CRT/Internals/CRTOpenGL.cpp index 0b5c3f275..81a2d7a55 100644 --- a/Outputs/CRT/Internals/CRTOpenGL.cpp +++ b/Outputs/CRT/Internals/CRTOpenGL.cpp @@ -102,7 +102,7 @@ void OpenGLOutputBuilder::draw_frame(unsigned int output_width, unsigned int out } // make sure there's a target to draw to - if(!framebuffer_ || framebuffer_->get_height() != output_height || framebuffer_->get_width() != output_width) { + if(!framebuffer_ || (unsigned int)framebuffer_->get_height() != output_height || (unsigned int)framebuffer_->get_width() != output_width) { std::unique_ptr new_framebuffer(new OpenGL::TextureTarget((GLsizei)output_width, (GLsizei)output_height, pixel_accumulation_texture_unit, GL_LINEAR)); if(framebuffer_) { new_framebuffer->bind_framebuffer(); diff --git a/Outputs/Speaker.hpp b/Outputs/Speaker.hpp index 4fd2b0fd8..72e0970fb 100644 --- a/Outputs/Speaker.hpp +++ b/Outputs/Speaker.hpp @@ -104,8 +104,8 @@ class Speaker { std::vector buffer_in_progress_; float high_frequency_cut_off_; - int buffer_in_progress_pointer_; - int number_of_taps_, requested_number_of_taps_; + size_t buffer_in_progress_pointer_; + size_t number_of_taps_, requested_number_of_taps_; bool coefficients_are_dirty_; Delegate *delegate_; From 37459a3ebc45eeda4fe57ef0b3b48e9ebf5f9dbf Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:51:18 -0400 Subject: [PATCH 16/21] Fixed parameter shadowing. --- Machines/Atari2600/TIA.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Machines/Atari2600/TIA.hpp b/Machines/Atari2600/TIA.hpp index d8dd31c5a..73438c9a5 100644 --- a/Machines/Atari2600/TIA.hpp +++ b/Machines/Atari2600/TIA.hpp @@ -229,14 +229,14 @@ class TIA { } queue_[4]; int queue_read_pointer_, queue_write_pointer_; - inline void output_pixels(uint8_t *const target, const int count, const uint8_t collision_identity, int pixel_position, int adder, int reverse_mask) { - if(pixel_position == 32 || !graphic[graphic_index]) return; + inline void output_pixels(uint8_t *const target, const int count, const uint8_t collision_identity, int output_pixel_position, int output_adder, int output_reverse_mask) { + if(output_pixel_position == 32 || !graphic[graphic_index]) return; int output_cursor = 0; - while(pixel_position < 32 && output_cursor < count) { - int shift = (pixel_position >> 2) ^ reverse_mask; + while(output_pixel_position < 32 && output_cursor < count) { + int shift = (output_pixel_position >> 2) ^ output_reverse_mask; target[output_cursor] |= ((graphic[graphic_index] >> shift)&1) * collision_identity; output_cursor++; - pixel_position += adder; + output_pixel_position += output_adder; } } From dddb30477bf25c41b803f14f89dc699690d38f68 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:52:08 -0400 Subject: [PATCH 17/21] Used a different inner-loop variable, for clarity. --- Machines/Electron/Video.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Machines/Electron/Video.cpp b/Machines/Electron/Video.cpp index 4e901aa95..08eaf4550 100644 --- a/Machines/Electron/Video.cpp +++ b/Machines/Electron/Video.cpp @@ -425,9 +425,9 @@ void VideoOutput::setup_screen_map() { screen_map_.emplace_back(DrawAction::Blank, cycles_per_line >> 1); screen_map_.emplace_back(DrawAction::Sync, (cycles_per_line * 5) >> 1); } - for(int c = 0; c < first_graphics_line - 3; c++) emplace_blank_line(); - for(int c = 0; c < 256; c++) emplace_pixel_line(); - for(int c = 256 + first_graphics_line; c < 312; c++) emplace_blank_line(); + for(int l = 0; l < first_graphics_line - 3; l++) emplace_blank_line(); + for(int l = 0; l < 256; l++) emplace_pixel_line(); + for(int l = 256 + first_graphics_line; l < 312; l++) emplace_blank_line(); if(c&1) emplace_blank_line(); } } From be750ee4275e9ac485add3123af1d7d08a9b5671 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:52:37 -0400 Subject: [PATCH 18/21] Eliminated all dangling implicit signedness conversions. --- Outputs/CRT/CRT.cpp | 6 +++--- Outputs/CRT/CRT.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Outputs/CRT/CRT.cpp b/Outputs/CRT/CRT.cpp index 6b5c4ec80..387c28f8d 100644 --- a/Outputs/CRT/CRT.cpp +++ b/Outputs/CRT/CRT.cpp @@ -38,7 +38,7 @@ void CRT::set_new_timing(unsigned int cycles_per_line, unsigned int height_of_di unsigned int multiplied_cycles_per_line = cycles_per_line * time_multiplier_; // generate timing values implied by the given arguments - sync_capacitor_charge_threshold_ = ((int)(syncCapacityLineChargeThreshold * cycles_per_line) * 3) / 4; + sync_capacitor_charge_threshold_ = ((unsigned int)(syncCapacityLineChargeThreshold * cycles_per_line) * 3) / 4; // create the two flywheels horizontal_flywheel_.reset(new Flywheel(multiplied_cycles_per_line, (millisecondsHorizontalRetraceTime * multiplied_cycles_per_line) >> 6, multiplied_cycles_per_line >> 6)); @@ -364,8 +364,8 @@ Outputs::CRT::Rect CRT::get_rect_for_area(int first_line_after_sync, int number_ unsigned int horizontal_retrace_period = horizontal_period - horizontal_scan_period; // make sure that the requested range is visible - if(first_cycle_after_sync < horizontal_retrace_period) first_cycle_after_sync = (int)horizontal_retrace_period; - if(first_cycle_after_sync + number_of_cycles > horizontal_scan_period) number_of_cycles = (int)(horizontal_scan_period - (unsigned)first_cycle_after_sync); + if((unsigned int)first_cycle_after_sync < horizontal_retrace_period) first_cycle_after_sync = (int)horizontal_retrace_period; + if((unsigned int)(first_cycle_after_sync + number_of_cycles) > horizontal_scan_period) number_of_cycles = (int)(horizontal_scan_period - (unsigned)first_cycle_after_sync); float start_x = (float)((unsigned)first_cycle_after_sync - horizontal_retrace_period) / (float)horizontal_scan_period; float width = (float)number_of_cycles / (float)horizontal_scan_period; diff --git a/Outputs/CRT/CRT.hpp b/Outputs/CRT/CRT.hpp index 49f6bb206..f8267a570 100644 --- a/Outputs/CRT/CRT.hpp +++ b/Outputs/CRT/CRT.hpp @@ -43,7 +43,7 @@ class CRT { // elements of sync separation bool is_receiving_sync_; // true if the CRT is currently receiving sync (i.e. this is for edge triggering of horizontal sync) int sync_capacitor_charge_level_; // this charges up during times of sync and depletes otherwise; needs to hit a required threshold to trigger a vertical sync - int sync_capacitor_charge_threshold_; // this charges up during times of sync and depletes otherwise; needs to hit a required threshold to trigger a vertical sync + unsigned int sync_capacitor_charge_threshold_; // this charges up during times of sync and depletes otherwise; needs to hit a required threshold to trigger a vertical sync unsigned int sync_period_; struct Scan { From 1d01acce0658ef17376876bee529ac440afa4a09 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:53:05 -0400 Subject: [PATCH 19/21] Fixed differing types of loop variables and targets. --- Storage/Disk/Encodings/MFM.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Storage/Disk/Encodings/MFM.cpp b/Storage/Disk/Encodings/MFM.cpp index 04f419362..33c69e0b3 100644 --- a/Storage/Disk/Encodings/MFM.cpp +++ b/Storage/Disk/Encodings/MFM.cpp @@ -141,12 +141,12 @@ template std::shared_ptr shifter.add_index_address_mark(); // add the post-index mark - for(int c = 0; c < post_index_address_mark_bytes; c++) shifter.add_byte(post_index_address_mark_value); + for(size_t c = 0; c < post_index_address_mark_bytes; c++) shifter.add_byte(post_index_address_mark_value); // add sectors for(const Sector §or : sectors) { // gap - for(int c = 0; c < pre_address_mark_bytes; c++) shifter.add_byte(0x00); + for(size_t c = 0; c < pre_address_mark_bytes; c++) shifter.add_byte(0x00); // sector header shifter.add_ID_address_mark(); @@ -158,8 +158,8 @@ template std::shared_ptr shifter.add_crc(); // gap - for(int c = 0; c < post_address_mark_bytes; c++) shifter.add_byte(0x4e); - for(int c = 0; c < pre_data_mark_bytes; c++) shifter.add_byte(0x00); + for(size_t c = 0; c < post_address_mark_bytes; c++) shifter.add_byte(0x4e); + for(size_t c = 0; c < pre_data_mark_bytes; c++) shifter.add_byte(0x00); // data shifter.add_data_address_mark(); @@ -170,8 +170,8 @@ template std::shared_ptr shifter.add_crc(); // gap - for(int c = 0; c < post_data_bytes; c++) shifter.add_byte(0x00); - for(int c = 0; c < inter_sector_gap; c++) shifter.add_byte(0x4e); + for(size_t c = 0; c < post_data_bytes; c++) shifter.add_byte(0x00); + for(size_t c = 0; c < inter_sector_gap; c++) shifter.add_byte(0x4e); } while(segment.data.size() < expected_track_bytes) shifter.add_byte(0x00); From 45ec5f8eab2da6b4fff602cc66644808658f18b5 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:53:27 -0400 Subject: [PATCH 20/21] Eliminated implicit sign conversion. --- Storage/Disk/Formats/AcornADF.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Storage/Disk/Formats/AcornADF.cpp b/Storage/Disk/Formats/AcornADF.cpp index d5ed9d113..779bc29c0 100644 --- a/Storage/Disk/Formats/AcornADF.cpp +++ b/Storage/Disk/Formats/AcornADF.cpp @@ -64,7 +64,7 @@ std::shared_ptr AcornADF::get_uncached_track_at_position(unsigned int hea fseek(file_, file_offset, SEEK_SET); std::vector sectors; - for(int sector = 0; sector < sectors_per_track; sector++) { + for(unsigned int sector = 0; sector < sectors_per_track; sector++) { Storage::Encodings::MFM::Sector new_sector; new_sector.track = (uint8_t)position; new_sector.side = (uint8_t)head; From 92d1dd9a4ac53801c347c26c1d622a9b203047df Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 21 Jul 2017 21:54:05 -0400 Subject: [PATCH 21/21] Attempts to eliminate all remaining type variations. --- Outputs/Speaker.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Outputs/Speaker.hpp b/Outputs/Speaker.hpp index 72e0970fb..4827218d7 100644 --- a/Outputs/Speaker.hpp +++ b/Outputs/Speaker.hpp @@ -59,7 +59,7 @@ class Speaker { } void set_output_quality(int number_of_taps) { - requested_number_of_taps_ = number_of_taps; + requested_number_of_taps_ = (size_t)number_of_taps; set_needs_updated_filter_coefficients(); } @@ -171,7 +171,7 @@ template class Filter: public Speaker { // if the output rate is less than the input rate, use the filter if(input_cycles_per_second_ > output_cycles_per_second_ || (input_cycles_per_second_ == output_cycles_per_second_ && high_frequency_cut_off_ >= 0.0)) { while(cycles_remaining) { - unsigned int cycles_to_read = (unsigned int)std::min((int)cycles_remaining, number_of_taps_ - input_buffer_depth_); + unsigned int cycles_to_read = (unsigned int)std::min((size_t)cycles_remaining, number_of_taps_ - input_buffer_depth_); static_cast(this)->get_samples(cycles_to_read, &input_buffer_[(size_t)input_buffer_depth_]); cycles_remaining -= cycles_to_read; input_buffer_depth_ += cycles_to_read; @@ -216,14 +216,14 @@ template class Filter: public Speaker { std::unique_ptr filter_; std::vector input_buffer_; - int input_buffer_depth_; + size_t input_buffer_depth_; void update_filter_coefficients() { // make a guess at a good number of taps if this hasn't been provided explicitly if(requested_number_of_taps_) { number_of_taps_ = requested_number_of_taps_; } else { - number_of_taps_ = (int)ceilf((input_cycles_per_second_ + output_cycles_per_second_) / output_cycles_per_second_); + number_of_taps_ = (size_t)ceilf((input_cycles_per_second_ + output_cycles_per_second_) / output_cycles_per_second_); number_of_taps_ *= 2; number_of_taps_ |= 1; } @@ -235,9 +235,9 @@ template class Filter: public Speaker { float high_pass_frequency; if(high_frequency_cut_off_ > 0.0) { - high_pass_frequency = std::min((float)output_cycles_per_second_ / 2.0f, high_frequency_cut_off_); + high_pass_frequency = std::min(output_cycles_per_second_ / 2.0f, high_frequency_cut_off_); } else { - high_pass_frequency = (float)output_cycles_per_second_ / 2.0f; + high_pass_frequency = output_cycles_per_second_ / 2.0f; } filter_.reset(new SignalProcessing::FIRFilter((unsigned int)number_of_taps_, (float)input_cycles_per_second_, 0.0, high_pass_frequency, SignalProcessing::FIRFilter::DefaultAttenuation));