From 0526ac2ee21c5c45c3bb98becdf6856871953d2b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 5 Sep 2018 11:36:40 -0400 Subject: [PATCH] Slightly increases const correctness. The converters from source data to output pixels do not modify the source data. It's a shame there's no `restrict` in C++. --- Machines/AppleII/Video.cpp | 12 ++++++------ Machines/AppleII/Video.hpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Machines/AppleII/Video.cpp b/Machines/AppleII/Video.cpp index 4fe943ab8..7435f3c1f 100644 --- a/Machines/AppleII/Video.cpp +++ b/Machines/AppleII/Video.cpp @@ -160,7 +160,7 @@ void VideoBase::set_character_rom(const std::vector &character_rom) { } } -void VideoBase::output_text(uint8_t *target, uint8_t *source, size_t length, size_t pixel_row) const { +void VideoBase::output_text(uint8_t *target, const uint8_t *const source, size_t length, size_t pixel_row) const { for(size_t c = 0; c < length; ++c) { const int character = source[c] & character_zones[source[c] >> 6].address_mask; const uint8_t xor_mask = character_zones[source[c] >> 6].xor_mask; @@ -180,7 +180,7 @@ void VideoBase::output_text(uint8_t *target, uint8_t *source, size_t length, siz } } -void VideoBase::output_double_text(uint8_t *target, uint8_t *source, uint8_t *auxiliary_source, size_t length, size_t pixel_row) const { +void VideoBase::output_double_text(uint8_t *target, const uint8_t *const source, const uint8_t *const auxiliary_source, size_t length, size_t pixel_row) const { for(size_t c = 0; c < length; ++c) { const std::size_t character_addresses[2] = { static_cast( @@ -220,7 +220,7 @@ void VideoBase::output_double_text(uint8_t *target, uint8_t *source, uint8_t *au } } -void VideoBase::output_low_resolution(uint8_t *target, uint8_t *source, size_t length, int column, int row) const { +void VideoBase::output_low_resolution(uint8_t *target, const uint8_t *const source, size_t length, int column, int row) const { const int row_shift = row&4; for(size_t c = 0; c < length; ++c) { // Low-resolution graphics mode shifts the colour code on a loop, but has to account for whether this @@ -242,7 +242,7 @@ void VideoBase::output_low_resolution(uint8_t *target, uint8_t *source, size_t l } } -void VideoBase::output_double_low_resolution(uint8_t *target, uint8_t *source, uint8_t *auxiliary_source, size_t length, int column, int row) const { +void VideoBase::output_double_low_resolution(uint8_t *target, const uint8_t *const source, const uint8_t *const auxiliary_source, size_t length, int column, int row) const { const int row_shift = row&4; for(size_t c = 0; c < length; ++c) { if((column + static_cast(c))&1) { @@ -272,7 +272,7 @@ void VideoBase::output_double_low_resolution(uint8_t *target, uint8_t *source, u } } -void VideoBase::output_high_resolution(uint8_t *target, uint8_t *source, size_t length) const { +void VideoBase::output_high_resolution(uint8_t *target, const uint8_t *const source, size_t length) const { for(size_t c = 0; c < length; ++c) { // High resolution graphics shift out LSB to MSB, optionally with a delay of half a pixel. // If there is a delay, the previous output level is held to bridge the gap. @@ -299,7 +299,7 @@ void VideoBase::output_high_resolution(uint8_t *target, uint8_t *source, size_t } } -void VideoBase::output_double_high_resolution(uint8_t *target, uint8_t *source, uint8_t *auxiliary_source, size_t length) const { +void VideoBase::output_double_high_resolution(uint8_t *target, const uint8_t *const source, const uint8_t *const auxiliary_source, size_t length) const { for(size_t c = 0; c < length; ++c) { target[0] = auxiliary_source[c] & 0x01; target[1] = auxiliary_source[c] & 0x02; diff --git a/Machines/AppleII/Video.hpp b/Machines/AppleII/Video.hpp index d7db1bf4f..a992b61a6 100644 --- a/Machines/AppleII/Video.hpp +++ b/Machines/AppleII/Video.hpp @@ -209,32 +209,32 @@ class VideoBase { /*! Outputs 40-column text to @c target, using @c length bytes from @c source. */ - void output_text(uint8_t *target, uint8_t *source, size_t length, size_t pixel_row) const; + void output_text(uint8_t *target, const uint8_t *source, size_t length, size_t pixel_row) const; /*! Outputs 80-column text to @c target, drawing @c length columns from @c source and @c auxiliary_source. */ - void output_double_text(uint8_t *target, uint8_t *source, uint8_t *auxiliary_source, size_t length, size_t pixel_row) const; + void output_double_text(uint8_t *target, const uint8_t *source, const uint8_t *auxiliary_source, size_t length, size_t pixel_row) const; /*! Outputs 40-column low-resolution graphics to @c target, drawing @c length columns from @c source. */ - void output_low_resolution(uint8_t *target, uint8_t *source, size_t length, int column, int row) const; + void output_low_resolution(uint8_t *target, const uint8_t *source, size_t length, int column, int row) const; /*! Outputs 80-column low-resolution graphics to @c target, drawing @c length columns from @c source and @c auxiliary_source. */ - void output_double_low_resolution(uint8_t *target, uint8_t *source, uint8_t *auxiliary_source, size_t length, int column, int row) const; + void output_double_low_resolution(uint8_t *target, const uint8_t *source, const uint8_t *auxiliary_source, size_t length, int column, int row) const; /*! Outputs 40-column high-resolution graphics to @c target, drawing @c length columns from @c source. */ - void output_high_resolution(uint8_t *target, uint8_t *source, size_t length) const; + void output_high_resolution(uint8_t *target, const uint8_t *source, size_t length) const; /*! Outputs 80-column double-high-resolution graphics to @c target, drawing @c length columns from @c source. */ - void output_double_high_resolution(uint8_t *target, uint8_t *source, uint8_t *auxiliary_source, size_t length) const; + void output_double_high_resolution(uint8_t *target, const uint8_t *source, const uint8_t *auxiliary_source, size_t length) const; // Maintain a ClockDeferrer for delayed mode switches. ClockDeferrer deferrer_;