From 38325741dedc6148c6aa331065cb599ea804e3fd Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 10 Dec 2024 21:28:46 -0500 Subject: [PATCH] Forward address information to a video stub. --- Machines/Commodore/Plus4/Plus4.cpp | 14 +++- Machines/Commodore/Plus4/Video.hpp | 81 +++++++++++++++++++ .../Clock Signal.xcodeproj/project.pbxproj | 2 + 3 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 Machines/Commodore/Plus4/Video.hpp diff --git a/Machines/Commodore/Plus4/Plus4.cpp b/Machines/Commodore/Plus4/Plus4.cpp index 77aa25ef7..e638a3806 100644 --- a/Machines/Commodore/Plus4/Plus4.cpp +++ b/Machines/Commodore/Plus4/Plus4.cpp @@ -8,10 +8,10 @@ #include "Plus4.hpp" +#include "Video.hpp" + #include "../../MachineTypes.hpp" - #include "../../../Processors/6502/6502.hpp" - #include "../../../Analyser/Static/Commodore/Target.hpp" using namespace Commodore::Plus4; @@ -207,6 +207,15 @@ public: case 0xff04: timers_.write<4>(*value); break; case 0xff05: timers_.write<5>(*value); break; + case 0xff06: video_.write<0xff06>(*value); break; + case 0xff07: video_.write<0xff07>(*value); break; + case 0xff0c: video_.write<0xff0c>(*value); break; + case 0xff0d: video_.write<0xff0d>(*value); break; + case 0xff12: video_.write<0xff12>(*value); break; + case 0xff14: video_.write<0xff14>(*value); break; + case 0xff1a: video_.write<0xff1a>(*value); break; + case 0xff1b: video_.write<0xff1b>(*value); break; + default: printf("TODO: TED write at %04x\n", address); } @@ -241,6 +250,7 @@ private: Cycles timers_subcycles_; Timers timers_; + Video video_; }; } diff --git a/Machines/Commodore/Plus4/Video.hpp b/Machines/Commodore/Plus4/Video.hpp new file mode 100644 index 000000000..86b9f1f6f --- /dev/null +++ b/Machines/Commodore/Plus4/Video.hpp @@ -0,0 +1,81 @@ +// +// Video.hpp +// Clock Signal +// +// Created by Thomas Harte on 10/12/2024. +// Copyright © 2024 Thomas Harte. All rights reserved. +// + +#pragma once + +namespace Commodore::Plus4 { + +struct Video { +public: + template + void write(const uint8_t value) { + const auto load_high10 = [&](uint16_t &target) { + target = uint16_t( + (target & 0x00ff) | ((value & 0x3) << 8) + ); + }; + const auto load_low8 = [&](uint16_t &target) { + target = uint16_t( + (target & 0xff00) | value + ); + }; + + + switch(address) { + case 0xff06: + extended_colour_mode_ = value & 0x40; + bitmap_mode_ = value & 0x20; + display_enable_ = value & 0x10; + rows_25_ = value & 8; + y_scroll_ = value & 7; + break; + + case 0xff07: + characters_256_ = value & 0x80; + is_ntsc_ = value & 0x40; + ted_off_ = value & 0x20; + multicolour_mode_ = value & 0x10; + columns_40_ = value & 8; + x_scroll_ = value & 7; + break; + + case 0xff12: + character_generator_address_ = uint16_t((value & 0xfc) << 8); + break; + case 0xff14: + screen_memory_address_ = uint16_t((value & 0xf8) << 8); + break; + + case 0xff0c: load_high10(cursor_address_); break; + case 0xff0d: load_low8(cursor_address_); break; + case 0xff1a: load_high10(character_row_address_); break; + case 0xff1b: load_low8(character_row_address_); break; + } + } + +private: + bool extended_colour_mode_ = false; + bool bitmap_mode_ = false; + bool display_enable_ = false; + bool rows_25_ = false; + int y_scroll_ = 0; + + bool characters_256_ = false; + bool is_ntsc_ = false; + bool ted_off_ = false; + bool multicolour_mode_ = false; + bool columns_40_ = false; + int x_scroll_ = 0; + + uint16_t cursor_address_ = 0; + uint16_t character_row_address_ = 0; + uint16_t character_generator_address_ = 0; + uint16_t screen_memory_address_ = 0; +}; + +} diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 5fd7733d7..f723807c1 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -1296,6 +1296,7 @@ 42EB812C2B47008D00429AF4 /* MemoryMap.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryMap.cpp; sourceTree = ""; }; 4B018B88211930DE002A3937 /* 65C02_extended_opcodes_test.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = 65C02_extended_opcodes_test.bin; path = "Klaus Dormann/65C02_extended_opcodes_test.bin"; sourceTree = ""; }; 4B01A6871F22F0DB001FD6E3 /* Z80MemptrTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Z80MemptrTests.swift; sourceTree = ""; }; + 4B03291F2D0923E300C51EB5 /* Video.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Video.hpp; sourceTree = ""; }; 4B0333AD2094081A0050B93D /* AppleDSK.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AppleDSK.cpp; sourceTree = ""; }; 4B0333AE2094081A0050B93D /* AppleDSK.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AppleDSK.hpp; sourceTree = ""; }; 4B046DC31CFE651500E9E45E /* ScanProducer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ScanProducer.hpp; sourceTree = ""; }; @@ -3393,6 +3394,7 @@ children = ( 4B596EAF2D037E8800FBF4B1 /* Plus4.hpp */, 4B596EB02D037E8800FBF4B1 /* Plus4.cpp */, + 4B03291F2D0923E300C51EB5 /* Video.hpp */, ); path = Plus4; sourceTree = "";