From 282d0f1ebb19adbb034c74dfaee32fc943cd0209 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 5 Nov 2020 18:17:21 -0500 Subject: [PATCH] For debugging, adds a dump of anything in the [presumably] text buffer. Nothing is there. --- Machines/Apple/AppleIIgs/AppleIIgs.cpp | 1 + Machines/Apple/AppleIIgs/Video.cpp | 23 +++++++++++++++++++++++ Machines/Apple/AppleIIgs/Video.hpp | 2 ++ 3 files changed, 26 insertions(+) diff --git a/Machines/Apple/AppleIIgs/AppleIIgs.cpp b/Machines/Apple/AppleIIgs/AppleIIgs.cpp index 1f84209d3..218330c6c 100644 --- a/Machines/Apple/AppleIIgs/AppleIIgs.cpp +++ b/Machines/Apple/AppleIIgs/AppleIIgs.cpp @@ -84,6 +84,7 @@ class ConcreteMachine: ram_.resize(ram_size * 1024); memory_.set_storage(ram_, rom_); + video_.set_internal_ram(&ram_[ram_.size() - 128*1024]); // TODO: enable once machine is otherwise sane. // Memory::Fuzz(ram_); diff --git a/Machines/Apple/AppleIIgs/Video.cpp b/Machines/Apple/AppleIIgs/Video.cpp index bd47bae9f..7b2b4639e 100644 --- a/Machines/Apple/AppleIIgs/Video.cpp +++ b/Machines/Apple/AppleIIgs/Video.cpp @@ -22,12 +22,35 @@ VideoBase::VideoBase() : VideoSwitches(Cycles(2), [] (Cycles) {}) { } +void VideoBase::set_internal_ram(const uint8_t *ram) { + ram_ = ram; +} + void VideoBase::did_set_annunciator_3(bool) {} void VideoBase::did_set_alternative_character_set(bool) {} void VideoBase::run_for(Cycles cycles) { // TODO: everything else! + const auto old = cycles_into_frame_; cycles_into_frame_ = (cycles_into_frame_ + cycles.as()) % (CyclesPerLine * Lines); + + // DEBUGGING HACK!! + // Scan the output buffer, assuming this is 40-column text mode, and print anything found. + if(cycles_into_frame_ < old) { + for(int line = 0; line < 192; line += 8) { + const uint16_t address = get_row_address(line); + + bool did_print_line = false; + for(int column = 0; column < 40; column++) { + const char c = char(ram_[address + column]); + if(c > 0) { + printf("%c", c); + did_print_line = true; + } + } + if(did_print_line) printf("\n"); + } + } } bool VideoBase::get_is_vertical_blank() { diff --git a/Machines/Apple/AppleIIgs/Video.hpp b/Machines/Apple/AppleIIgs/Video.hpp index a85f75085..1e6038377 100644 --- a/Machines/Apple/AppleIIgs/Video.hpp +++ b/Machines/Apple/AppleIIgs/Video.hpp @@ -19,6 +19,7 @@ namespace Video { class VideoBase: public Apple::II::VideoSwitches { public: VideoBase(); + void set_internal_ram(const uint8_t *); void run_for(Cycles); bool get_is_vertical_blank(); @@ -41,6 +42,7 @@ class VideoBase: public Apple::II::VideoSwitches { void set_interrupts(uint8_t); int cycles_into_frame_ = 0; + const uint8_t *ram_ = nullptr; }; class Video: public VideoBase {