From 1a2b18f93b569ebf1abbc83d14b7d4dfea97c9e2 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 12 Jun 2016 17:27:57 -0400 Subject: [PATCH] Steps towards CPU mapping; diagnostic. --- Components/6560/6560.cpp | 50 +++++----------------------------------- Components/6560/6560.hpp | 1 + 2 files changed, 7 insertions(+), 44 deletions(-) diff --git a/Components/6560/6560.cpp b/Components/6560/6560.cpp index e63bf47e2..b454e8227 100644 --- a/Components/6560/6560.cpp +++ b/Components/6560/6560.cpp @@ -48,49 +48,11 @@ MOS6560::MOS6560() : _vertical_counter(0) { _crt->set_composite_sampling_function( - "float angles[16] = float[](" - "0.0," // black - "0.0," // white - "1.963495408493621," // red - "5.105088062083414," // cyan - "0.785398163397448," // purple - "3.926990816987241," // green - "0.0," // blue - "3.141592653589793," // yellow - - "2.356194490192345," // orange - "2.748893571891069," // light yellow - "1.963495408493621," // light red - "5.105088062083414," // light cyan - "0.785398163397448," // light purple - "3.926990816987241," // light green - "0.0," // light blue - "3.141592653589793" // light yellow - ");" - "float brightnesses[16] = float[](" - "0.0 / 255.0," - "255.0 / 255.0," - "79.6875 / 255.0," - "159.375 / 255.0," - "95.625 / 255.0," - "127.5 / 255.0," - "63.75 / 255.0," - "191.25 / 255.0," - - "95.625 / 255.0," - "63.75 / 255.0," - "127.5 / 255.0," - "189.375 / 255.0," - "135.625 / 255.0," - "191.25 / 255.0," - "119.53125 / 255.0," - "159.375 / 255.0" - ");" "float composite_sample(usampler2D texID, vec2 coordinate, vec2 iCoordinate, float phase, float amplitude)" "{" "uint c = texture(texID, coordinate).r;" - "float y = brightnesses[c];" - "float phaseOffset = angles[c];" + "float y = float(c >> 4) / 4.0;" + "float phaseOffset = float(c & 15u) / 16.0;" // "float chroma = step(3.141592654, mod(phase + phaseOffset, 6.283185308)) * 2.0 - 1.0;" "float chroma = cos(phase + phaseOffset);" @@ -129,7 +91,7 @@ void MOS6560::set_register(int address, uint8_t value) break; case 0xe: - _auxiliary_colour = value >> 4; + _auxiliary_colour = _colours[value >> 4]; // TODO: sound amplitude break; @@ -140,8 +102,8 @@ void MOS6560::set_register(int address, uint8_t value) _cycles_in_state = 0; } _invertedCells = !!((value >> 3)&1); - _borderColour = value & 0x07; - _backgroundColour = value >> 4; + _borderColour = _colours[value & 0x07]; + _backgroundColour = _colours[value >> 4]; break; // TODO: audio, primarily @@ -290,7 +252,7 @@ void MOS6560::set_graphics_value(uint8_t value, uint8_t colour_value) if(pixel_pointer) { - uint8_t cell_colour = _character_colour & 0x7; + uint8_t cell_colour = _colours[_character_colour & 0x7]; if(!(_character_colour&0x8)) { pixel_pointer[0] = ((_character_value >> 7)&1) ? cell_colour : _backgroundColour; diff --git a/Components/6560/6560.hpp b/Components/6560/6560.hpp index be8f856df..9b5134bd9 100644 --- a/Components/6560/6560.hpp +++ b/Components/6560/6560.hpp @@ -49,6 +49,7 @@ class MOS6560 { uint8_t *pixel_pointer; uint8_t _registers[16]; + uint8_t _colours[16]; void output_border(unsigned int number_of_cycles); };