mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Various undefined behaviour fixes.
Primarily around uninitialised variables, but also with an attempted use of a negative pointer.
This commit is contained in:
parent
3f4d90d775
commit
0c2dd62328
@ -156,18 +156,8 @@ class AYDeferrer {
|
|||||||
class CRTCBusHandler {
|
class CRTCBusHandler {
|
||||||
public:
|
public:
|
||||||
CRTCBusHandler(uint8_t *ram, InterruptTimer &interrupt_timer) :
|
CRTCBusHandler(uint8_t *ram, InterruptTimer &interrupt_timer) :
|
||||||
cycles_(0),
|
|
||||||
was_enabled_(false),
|
|
||||||
was_sync_(false),
|
|
||||||
pixel_data_(nullptr),
|
|
||||||
pixel_pointer_(nullptr),
|
|
||||||
was_hsync_(false),
|
|
||||||
ram_(ram),
|
ram_(ram),
|
||||||
interrupt_timer_(interrupt_timer),
|
interrupt_timer_(interrupt_timer) {
|
||||||
pixel_divider_(1),
|
|
||||||
mode_(2),
|
|
||||||
next_mode_(2),
|
|
||||||
cycles_into_hsync_(0) {
|
|
||||||
establish_palette_hits();
|
establish_palette_hits();
|
||||||
build_mode_table();
|
build_mode_table();
|
||||||
}
|
}
|
||||||
@ -501,19 +491,19 @@ class CRTCBusHandler {
|
|||||||
return mapping[colour];
|
return mapping[colour];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int cycles_;
|
unsigned int cycles_ = 0;
|
||||||
|
|
||||||
bool was_enabled_, was_sync_, was_hsync_, was_vsync_;
|
bool was_enabled_ = false, was_sync_ = false, was_hsync_ = false, was_vsync_ = false;
|
||||||
int cycles_into_hsync_;
|
int cycles_into_hsync_ = 0;
|
||||||
|
|
||||||
std::shared_ptr<Outputs::CRT::CRT> crt_;
|
std::shared_ptr<Outputs::CRT::CRT> crt_;
|
||||||
uint8_t *pixel_data_, *pixel_pointer_;
|
uint8_t *pixel_data_ = nullptr, *pixel_pointer_ = nullptr;
|
||||||
|
|
||||||
uint8_t *ram_;
|
uint8_t *ram_ = nullptr;
|
||||||
|
|
||||||
int next_mode_, mode_;
|
int next_mode_ = 2, mode_ = 2;
|
||||||
|
|
||||||
unsigned int pixel_divider_;
|
unsigned int pixel_divider_ = 1;
|
||||||
uint16_t mode0_output_[256];
|
uint16_t mode0_output_[256];
|
||||||
uint32_t mode1_output_[256];
|
uint32_t mode1_output_[256];
|
||||||
uint64_t mode2_output_[256];
|
uint64_t mode2_output_[256];
|
||||||
@ -523,9 +513,9 @@ class CRTCBusHandler {
|
|||||||
std::vector<uint8_t> mode1_palette_hits_[4];
|
std::vector<uint8_t> mode1_palette_hits_[4];
|
||||||
std::vector<uint8_t> mode3_palette_hits_[4];
|
std::vector<uint8_t> mode3_palette_hits_[4];
|
||||||
|
|
||||||
int pen_;
|
int pen_ = 0;
|
||||||
uint8_t palette_[16];
|
uint8_t palette_[16];
|
||||||
uint8_t border_;
|
uint8_t border_ = 0;
|
||||||
|
|
||||||
InterruptTimer &interrupt_timer_;
|
InterruptTimer &interrupt_timer_;
|
||||||
};
|
};
|
||||||
|
@ -67,9 +67,7 @@ ArrayBuilder::Submission ArrayBuilder::submit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayBuilder::Buffer::Buffer(size_t size, std::function<void(bool is_input, uint8_t *, size_t)> submission_function) :
|
ArrayBuilder::Buffer::Buffer(size_t size, std::function<void(bool is_input, uint8_t *, size_t)> submission_function) :
|
||||||
is_full(false),
|
submission_function_(submission_function) {
|
||||||
submission_function_(submission_function),
|
|
||||||
allocated_data(0), flushed_data(0), submitted_data(0) {
|
|
||||||
if(!submission_function_) {
|
if(!submission_function_) {
|
||||||
glGenBuffers(1, &buffer);
|
glGenBuffers(1, &buffer);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||||
|
@ -82,17 +82,17 @@ class ArrayBuilder {
|
|||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool is_full;
|
bool is_full = false;
|
||||||
GLuint buffer;
|
GLuint buffer = 0;
|
||||||
std::function<void(bool is_input, uint8_t *, size_t)> submission_function_;
|
std::function<void(bool is_input, uint8_t *, size_t)> submission_function_;
|
||||||
std::vector<uint8_t> data;
|
std::vector<uint8_t> data;
|
||||||
size_t allocated_data;
|
size_t allocated_data = 0;
|
||||||
size_t flushed_data;
|
size_t flushed_data = 0;
|
||||||
size_t submitted_data;
|
size_t submitted_data = 0;
|
||||||
} output_, input_;
|
} output_, input_;
|
||||||
uint8_t *get_storage(size_t size, Buffer &buffer);
|
uint8_t *get_storage(size_t size, Buffer &buffer);
|
||||||
|
|
||||||
bool is_full_;
|
bool is_full_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,13 +99,13 @@ void TextureBuilder::reduce_previous_allocation_to(size_t actual_length) {
|
|||||||
// against rounding errors when this run is drawn.
|
// against rounding errors when this run is drawn.
|
||||||
// TODO: allow somebody else to specify the rule for generating a left-padding value and
|
// TODO: allow somebody else to specify the rule for generating a left-padding value and
|
||||||
// a right-padding value.
|
// a right-padding value.
|
||||||
uint8_t *start_pointer = pointer_to_location(write_area_.x, write_area_.y);
|
uint8_t *start_pointer = pointer_to_location(write_area_.x, write_area_.y) - bytes_per_pixel_;
|
||||||
memcpy( &start_pointer[-bytes_per_pixel_],
|
memcpy( start_pointer,
|
||||||
start_pointer,
|
&start_pointer[bytes_per_pixel_],
|
||||||
bytes_per_pixel_);
|
bytes_per_pixel_);
|
||||||
|
|
||||||
memcpy( &start_pointer[actual_length * bytes_per_pixel_],
|
memcpy( &start_pointer[(actual_length + 1) * bytes_per_pixel_],
|
||||||
&start_pointer[(actual_length - 1) * bytes_per_pixel_],
|
&start_pointer[actual_length * bytes_per_pixel_],
|
||||||
bytes_per_pixel_);
|
bytes_per_pixel_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user