From 632b37ececed194a66cf77039a0f296af46fea7a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 29 Jul 2018 10:41:12 -0400 Subject: [PATCH] Attempts an implementation of auxiliary memory. --- Machines/AppleII/AppleII.cpp | 56 ++++++++++++++++++++++++++++++++---- Machines/AppleII/Video.cpp | 2 +- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/Machines/AppleII/AppleII.cpp b/Machines/AppleII/AppleII.cpp index ef6769162..5e5d5b8b2 100644 --- a/Machines/AppleII/AppleII.cpp +++ b/Machines/AppleII/AppleII.cpp @@ -209,6 +209,31 @@ template class ConcreteMachine: // MARK - The IIe's auxiliary RAM controls. bool alternative_zero_page_ = false; + bool read_auxiliary_memory_ = false; + bool write_auxiliary_memory_ = false; + void set_main_paging() { + for(int target = 0x02; target < 0xc0; ++target) { + write_pages_[target] = write_auxiliary_memory_ ? &aux_ram_[target << 8] : &ram_[target << 8]; + read_pages_[target] = read_auxiliary_memory_ ? &aux_ram_[target << 8] : &ram_[target << 8]; + } + + if(video_->get_80_store()) { + int start_page, end_page; + if(video_->get_text()) { + start_page = 0x4; + end_page = 0x8; + } else { + start_page = 0x10; + end_page = 0x20; + } + + bool use_aux_ram = video_->get_page2(); + for(int target = start_page; target < end_page; ++target) { + write_pages_[target] = use_aux_ram ? &aux_ram_[target << 8] : &ram_[target << 8]; + read_pages_[target] = use_aux_ram ? &aux_ram_[target << 8] : &ram_[target << 8]; + } + } + } // MARK - typing std::unique_ptr string_serialiser_; @@ -310,7 +335,7 @@ template class ConcreteMachine: break; case Target::Model::IIe: rom_size += 3840; - rom_names.push_back("apple2e.rom"); + rom_names.push_back("apple2eu.rom"); break; } const auto roms = rom_fetcher("AppleII", rom_names); @@ -501,7 +526,7 @@ template class ConcreteMachine: // Read-only switches. switch(address) { default: -// printf("Unknown read from %04x\n", address); + printf("Unknown (?) read from %04x\n", address); break; case 0xc000: @@ -540,6 +565,10 @@ template class ConcreteMachine: } break; // The IIe-only state reads follow... + case 0xc011: if(is_iie) *value = (*value & 0x7f) | language_card_.bank1 ? 0x80 : 0x00; break; + case 0xc012: if(is_iie) *value = (*value & 0x7f) | language_card_.read ? 0x80 : 0x00; break; + case 0xc013: if(is_iie) *value = (*value & 0x7f) | read_auxiliary_memory_ ? 0x80 : 0x00; break; + case 0xc014: if(is_iie) *value = (*value & 0x7f) | write_auxiliary_memory_ ? 0x80 : 0x00; break; case 0xc015: if(is_iie) *value = (*value & 0x7f) | internal_CX_rom_ ? 0x80 : 0x00; break; case 0xc016: if(is_iie) *value = (*value & 0x7f) | alternative_zero_page_ ? 0x80 : 0x00; break; case 0xc017: if(is_iie) *value = (*value & 0x7f) | slot_C3_rom_ ? 0x80 : 0x00; break; @@ -555,10 +584,21 @@ template class ConcreteMachine: } else { // Write-only switches. All IIe as currently implemented. if(is_iie) { -// printf("w %04x\n", address); + if(address >= 0xc000 && address < 0xc100) printf("w %04x\n", address); switch(address) { default: -// printf("Unknown write to %04x\n", address); + printf("Unknown (?) write to %04x\n", address); + break; + + case 0xc002: + case 0xc003: + read_auxiliary_memory_ = !!(address&1); + set_main_paging(); + break; + case 0xc004: + case 0xc005: + write_auxiliary_memory_ = !!(address&1); + set_main_paging(); break; case 0xc006: @@ -621,8 +661,12 @@ template class ConcreteMachine: case 0xc051: update_video(); video_->set_text(true); break; case 0xc052: update_video(); video_->set_mixed(false); break; case 0xc053: update_video(); video_->set_mixed(true); break; - case 0xc054: update_video(); video_->set_page2(false); break; - case 0xc055: update_video(); video_->set_page2(true); break; + case 0xc054: + case 0xc055: + update_video(); + video_->set_page2(!!(address&1)); + set_main_paging(); + break; case 0xc056: update_video(); video_->set_high_resolution(false); break; case 0xc057: update_video(); video_->set_high_resolution(true); break; diff --git a/Machines/AppleII/Video.cpp b/Machines/AppleII/Video.cpp index e5dde24e2..65c44ee20 100644 --- a/Machines/AppleII/Video.cpp +++ b/Machines/AppleII/Video.cpp @@ -59,7 +59,7 @@ bool VideoBase::get_80_store() { } void VideoBase::set_page2(bool page2) { - page2_ = page2;; + page2_ = page2; } bool VideoBase::get_page2() {