1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-26 09:29:45 +00:00

Adds flashing, randomises initial RAM contents.

This commit is contained in:
Thomas Harte 2021-03-18 23:07:51 -04:00
parent 622a8abf7f
commit 020a04006e
2 changed files with 15 additions and 1 deletions

View File

@ -89,6 +89,12 @@ template <VideoTiming timing> class Video {
const int cycles_this_line = std::min(cycles_remaining, timings.cycles_per_line - offset);
const int end_offset = offset + cycles_this_line;
if(!line && !offset) {
++flash_counter_;
flash_mask_ = uint8_t(flash_counter_ >> 4);
flash_counter_ &= 31;
}
if(line < 3) {
// Output sync line.
crt_.output_sync(cycles_this_line);
@ -127,9 +133,11 @@ template <VideoTiming timing> class Video {
const int start_column = offset >> 3;
const int end_column = (offset + pixel_duration) >> 3;
for(int column = start_column; column < end_column; column++) {
const uint8_t pixels = memory_[pixel_address_];
const uint8_t attributes = memory_[attribute_address_];
constexpr uint8_t masks[] = {0, 0xff};
const uint8_t pixels = memory_[pixel_address_] ^ masks[flash_mask_ & (attributes >> 7)];
const uint8_t colours[2] = {
palette[((attributes & 0x40) >> 3) | (attributes & 0x07)],
palette[(attributes & 0x78) >> 3],
@ -255,6 +263,9 @@ template <VideoTiming timing> class Video {
int attribute_address_ = 0;
int pixel_address_ = 0;
uint8_t flash_mask_ = 0;
int flash_counter_ = 0;
#define RGB(r, g, b) (r << 4) | (g << 2) | b
static constexpr uint8_t palette[] = {
RGB(0, 0, 0), RGB(0, 0, 2), RGB(2, 0, 0), RGB(2, 0, 2),

View File

@ -26,6 +26,8 @@
#include "../../../Analyser/Static/ZXSpectrum/Target.hpp"
#include "../../Utility/MemoryFuzzer.hpp"
#include "../../../ClockReceiver/JustInTime.hpp"
#include <array>
@ -60,6 +62,7 @@ template<Model model> class ConcreteMachine:
// Set up initial memory map.
update_memory_map();
Memory::Fuzz(ram_);
// TODO: insert media.
(void)target;