mirror of
https://github.com/TomHarte/CLK.git
synced 2026-04-20 10:17:05 +00:00
Merge pull request #1704 from TomHarte/UndefinedBehaviourRedux
Resolve minor instances of undefined behaviour.
This commit is contained in:
@@ -284,10 +284,10 @@ private:
|
||||
sprite.image[2] = colour;
|
||||
sprite.x -= sprite.early_clock();
|
||||
|
||||
const AddressT graphic_location = base->sprite_generator_table_address_ & bits<11>(AddressT((name << 3) | sprite.row));
|
||||
const AddressT graphic_location =
|
||||
base->sprite_generator_table_address_ & bits<11>(AddressT((name << 3) | sprite.row));
|
||||
sprite.image[0] = base->ram_[graphic_location];
|
||||
sprite.image[1] = base->ram_[graphic_location+16]; // TODO: occasional out-of-bounds accesses here. Check
|
||||
// uninitialised Master System.
|
||||
sprite.image[1] = base->ram_[graphic_location | 16];
|
||||
|
||||
if constexpr (SpriteBuffer::test_is_filling) {
|
||||
if(slot == ((mode == SpriteMode::Mode2) ? 7 : 3)) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "SAA5050.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
namespace {
|
||||
@@ -151,7 +152,7 @@ enum ControlCode: uint8_t {
|
||||
using namespace Mullard;
|
||||
|
||||
void SAA5050Serialiser::begin_frame(const bool is_odd) {
|
||||
line_ = -2;
|
||||
line_ = next_line_ = 0;
|
||||
row_ = 0;
|
||||
odd_frame_ = is_odd;
|
||||
|
||||
@@ -162,7 +163,7 @@ void SAA5050Serialiser::begin_frame(const bool is_odd) {
|
||||
}
|
||||
|
||||
void SAA5050Serialiser::begin_line() {
|
||||
line_ += 2;
|
||||
line_ = next_line_;
|
||||
if(line_ == 20) {
|
||||
line_ = 0;
|
||||
++row_;
|
||||
@@ -172,6 +173,7 @@ void SAA5050Serialiser::begin_line() {
|
||||
}
|
||||
row_has_double_height_ = false;
|
||||
}
|
||||
next_line_ = line_ + 2;
|
||||
|
||||
output_.reset();
|
||||
has_output_ = false;
|
||||
@@ -265,6 +267,8 @@ void SAA5050Serialiser::add(const Numeric::SizedInt<7> c) {
|
||||
}
|
||||
|
||||
void SAA5050Serialiser::load_pixels(const uint8_t c) {
|
||||
assert(line_ >= 0 && line_ < 20);
|
||||
|
||||
if(flash_ && ((frame_counter_&31) > 23)) { // Complete guess on the blink period here.
|
||||
output_.reset();
|
||||
return;
|
||||
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
Output output_;
|
||||
bool has_output_ = false;
|
||||
|
||||
int row_, line_;
|
||||
int row_, line_, next_line_;
|
||||
bool odd_frame_;
|
||||
|
||||
bool flash_ = false;
|
||||
|
||||
@@ -236,7 +236,7 @@ private:
|
||||
count += 8;
|
||||
|
||||
// Output pixel row prematurely if storage is exhausted.
|
||||
if(output_state == OutputState::Pixels && pixel_pointer == pixels + DefaultAllocationSize) {
|
||||
if(output_state == OutputState::Pixels && pixels && pixel_pointer == pixels + DefaultAllocationSize) {
|
||||
flush_pixels();
|
||||
count = 0;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ private:
|
||||
count += 9;
|
||||
|
||||
// Output pixel row prematurely if storage is exhausted.
|
||||
if(output_state == OutputState::Pixels && pixel_pointer == pixels + DefaultAllocationSize) {
|
||||
if(output_state == OutputState::Pixels && pixels && pixel_pointer == pixels + DefaultAllocationSize) {
|
||||
crt.output_data(count);
|
||||
count = 0;
|
||||
|
||||
|
||||
@@ -365,8 +365,6 @@ BufferingScanTarget::OutputArea BufferingScanTarget::get_output_area() {
|
||||
}
|
||||
|
||||
void BufferingScanTarget::complete_output_area(const OutputArea &area) {
|
||||
// TODO: check that this is the expected next area if in DEBUG mode.
|
||||
|
||||
PointerSet new_read_pointers;
|
||||
new_read_pointers.line = uint16_t(area.end.line);
|
||||
new_read_pointers.scan = uint16_t(area.end.scan);
|
||||
|
||||
Reference in New Issue
Block a user