1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-27 18:55:48 +00:00

Start trying to bluff my way through extended status.

This commit is contained in:
Thomas Harte 2023-01-18 22:23:19 -05:00
parent e450e53c4e
commit 348c42bdea
2 changed files with 46 additions and 3 deletions

View File

@ -649,6 +649,12 @@ void Base<personality>::write_register(uint8_t value) {
}
break;
case 15:
if constexpr (is_yamaha_vdp(personality)) {
Storage<personality>::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<personality>::read_vram() {
template <Personality personality>
uint8_t Base<personality>::read_register() {
if constexpr (is_yamaha_vdp(personality)) {
switch(Storage<personality>::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<personality>::latch_horizontal_counter() {
template class TI::TMS::TMS9918<Personality::TMS9918A>;
template class TI::TMS::TMS9918<Personality::V9938>;
template class TI::TMS::TMS9918<Personality::V9958>;
//template class TI::TMS::TMS9918<Personality::V9958>;
template class TI::TMS::TMS9918<Personality::SMSVDP>;
template class TI::TMS::TMS9918<Personality::SMS2VDP>;
template class TI::TMS::TMS9918<Personality::GGVDP>;
template class TI::TMS::TMS9918<Personality::MDVDP>;
//template class TI::TMS::TMS9918<Personality::MDVDP>;

View File

@ -118,7 +118,24 @@ constexpr uint8_t StatusSpriteOverflow = 0x40;
constexpr int StatusSpriteCollisionShift = 5;
constexpr uint8_t StatusSpriteCollision = 0x20;
template <Personality personality> struct Base {
/// A container for personality-specific storage; see specific instances below.
template <Personality personality, typename Enable = void> struct Storage {
};
template <> struct Storage<Personality::TMS9918A> {
};
// Yamaha-specific storage.
template <Personality personality> struct Storage<personality, std::enable_if_t<is_yamaha_vdp(personality)>> {
int selected_status_ = 0;
};
// Master System-specific storage.
template <Personality personality> struct Storage<personality, std::enable_if_t<is_sega_vdp(personality)>> {
// TODO: relocate contents of master_system_ struct;
};
template <Personality personality> struct Base: public Storage<personality> {
Base();
static constexpr int output_lag = 11; // i.e. pixel output will occur 11 cycles