From 3be1ce457b59b0dce62753858d820126a36491f4 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 5 Jun 2016 14:05:31 -0400 Subject: [PATCH] Made some attempt at discerning fields. --- Components/6560/6560.cpp | 41 +++++++++++++++++++++++++++++++++++++--- Components/6560/6560.hpp | 5 +++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/Components/6560/6560.cpp b/Components/6560/6560.cpp index f1fa17ce4..be4b4de5f 100644 --- a/Components/6560/6560.cpp +++ b/Components/6560/6560.cpp @@ -11,7 +11,7 @@ using namespace MOS; MOS6560::MOS6560() : - _crt(new Outputs::CRT::CRT(65, 1, Outputs::CRT::DisplayType::NTSC60, 1)) + _crt(new Outputs::CRT::CRT(65 * 4, 4, Outputs::CRT::DisplayType::NTSC60, 1)) { _crt->set_rgb_sampling_function( "vec3 rgb_sample(usampler2D sampler, vec2 coordinate, vec2 icoordinate)" @@ -22,12 +22,47 @@ MOS6560::MOS6560() : void MOS6560::set_register(int address, uint8_t value) { - printf("%02x -> %d\n", value, address); + switch(address) + { + case 0x0: + _interlaced = !!(value&0x80); + _first_column_location = value & 0x7f; + break; + + case 0x1: + _first_row_location = value; + break; + + case 0x2: + _number_of_columns = value & 0x7f; + _video_matrix_start_address = (uint16_t)((_video_matrix_start_address & 0x3c00) | ((value & 0x80) << 2)); + break; + + case 0x3: + _number_of_rows = (value >> 1)&0x3f; + _wide_characters = !!(value&0x01); + break; + + case 0x5: + _character_cell_start_address = (uint16_t)((value & 0x0f) << 10); + _video_matrix_start_address = (uint16_t)((_video_matrix_start_address & 0x0400) | ((value & 0xf0) << 5)); + break; + + case 0xf: + // TODO: colours + break; + + default: + break; + } + + printf("%02x: %02x\n", address, value); + printf("%04x %04x [%d by %d from %d, %d]\n", _character_cell_start_address, _video_matrix_start_address, _number_of_columns, _number_of_rows, _first_column_location, _first_row_location); } uint16_t MOS6560::get_address() { - return 0; + return 0x1c; } void MOS6560::set_graphics_value(uint8_t value) diff --git a/Components/6560/6560.hpp b/Components/6560/6560.hpp index 027e69bfd..eedbf80f9 100644 --- a/Components/6560/6560.hpp +++ b/Components/6560/6560.hpp @@ -25,6 +25,11 @@ class MOS6560 { private: std::unique_ptr _crt; + + bool _interlaced, _wide_characters; + uint8_t _first_column_location, _first_row_location; + uint8_t _number_of_columns, _number_of_rows; + uint16_t _character_cell_start_address, _video_matrix_start_address; }; }