From 0537e594868000eea13e6f40a512973ef1e87805 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 25 Dec 2023 14:35:24 -0500 Subject: [PATCH] Add RAM. --- Machines/PCCompatible/RTC.hpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Machines/PCCompatible/RTC.hpp b/Machines/PCCompatible/RTC.hpp index a16ca4f74..236939791 100644 --- a/Machines/PCCompatible/RTC.hpp +++ b/Machines/PCCompatible/RTC.hpp @@ -35,6 +35,9 @@ class RTC { switch(selected_) { default: + if(ram_selected()) { + return ram_[ram_address()]; + } return 0xff; case 0x00: return bcd(time_date->tm_sec); // Seconds [0-59] @@ -63,7 +66,8 @@ class RTC { } private: - int selected_; + std::size_t selected_; + std::array ram_{}; uint8_t statusA_ = 0x00; uint8_t statusB_ = 0x02; @@ -71,6 +75,9 @@ class RTC { bool is_decimal() const { return statusB_ & 0x04; } bool is_24hour() const { return statusB_ & 0x02; } + bool ram_selected() const { return selected_ >= 0xe && selected_ < 0xe + ram_.size(); } + std::size_t ram_address() const { return selected_ - 0xe; } + template uint8_t bcd(IntT input) { // If calendar is in binary format, don't convert. @@ -87,7 +94,11 @@ class RTC { void write_register(uint8_t value) { switch(selected_) { - default: break; + default: + if(ram_selected()) { + ram_[ram_address()] = value; + } + break; case 0x0a: statusA_ = value; break; case 0x0b: statusB_ = value; break; }