From 348c42bdeaa5a146c40ccabea11f7a62918268db Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 18 Jan 2023 22:23:19 -0500 Subject: [PATCH] Start trying to bluff my way through extended status. --- Components/9918/Implementation/9918.cpp | 30 +++++++++++++++++++-- Components/9918/Implementation/9918Base.hpp | 19 ++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Components/9918/Implementation/9918.cpp b/Components/9918/Implementation/9918.cpp index 9d4d8841c..d99995c8e 100644 --- a/Components/9918/Implementation/9918.cpp +++ b/Components/9918/Implementation/9918.cpp @@ -649,6 +649,12 @@ void Base::write_register(uint8_t value) { } break; + case 15: + if constexpr (is_yamaha_vdp(personality)) { + Storage::selected_status_ = this->low_write_ & 0xf; + } + break; + default: LOG("Unknown TMS write: " << int(this->low_write_) << " to " << int(value)); break; @@ -699,6 +705,26 @@ uint8_t Base::read_vram() { template uint8_t Base::read_register() { + if constexpr (is_yamaha_vdp(personality)) { + switch(Storage::selected_status_) { + case 0: break; + + case 2: + // b7 = transfer ready flag (i.e. VDP ready for next transfer) + // b6 = 1 during vblank + // b5 = 1 during hblank + // b4 = set if colour detected during search command + // b1 = display field odd/even + // b0 = command ongoing + return + queued_access_ == MemoryAccess::None ? 0x80 : 0x00 | + 0x40 | + 0x20; + + break; + } + } + // Gets the status register. const uint8_t result = this->status_; this->status_ &= ~(StatusInterrupt | StatusSpriteOverflow | StatusSpriteCollision); @@ -868,8 +894,8 @@ void TMS9918::latch_horizontal_counter() { template class TI::TMS::TMS9918; template class TI::TMS::TMS9918; -template class TI::TMS::TMS9918; +//template class TI::TMS::TMS9918; template class TI::TMS::TMS9918; template class TI::TMS::TMS9918; template class TI::TMS::TMS9918; -template class TI::TMS::TMS9918; +//template class TI::TMS::TMS9918; diff --git a/Components/9918/Implementation/9918Base.hpp b/Components/9918/Implementation/9918Base.hpp index 06deb5b0d..204c8cb03 100644 --- a/Components/9918/Implementation/9918Base.hpp +++ b/Components/9918/Implementation/9918Base.hpp @@ -118,7 +118,24 @@ constexpr uint8_t StatusSpriteOverflow = 0x40; constexpr int StatusSpriteCollisionShift = 5; constexpr uint8_t StatusSpriteCollision = 0x20; -template struct Base { +/// A container for personality-specific storage; see specific instances below. +template struct Storage { +}; + +template <> struct Storage { +}; + +// Yamaha-specific storage. +template struct Storage> { + int selected_status_ = 0; +}; + +// Master System-specific storage. +template struct Storage> { + // TODO: relocate contents of master_system_ struct; +}; + +template struct Base: public Storage { Base(); static constexpr int output_lag = 11; // i.e. pixel output will occur 11 cycles