From f3357525ce767cde972ad4ab47a802288772e1a6 Mon Sep 17 00:00:00 2001 From: Christopher Mosher Date: Sun, 27 Jan 2019 01:41:23 -0500 Subject: [PATCH] add annunciator display, rev 0 speaker/cassette out, 3 decimal Hz --- src/addressbus.cpp | 20 +++++++++++------ src/addressbus.h | 52 +++++++++++++++++++++++---------------------- src/apple2.cpp | 2 +- src/screenimage.cpp | 9 ++++++-- src/screenimage.h | 2 ++ 5 files changed, 51 insertions(+), 34 deletions(-) diff --git a/src/addressbus.cpp b/src/addressbus.cpp index 04e197e..f8f73bb 100644 --- a/src/addressbus.cpp +++ b/src/addressbus.cpp @@ -26,8 +26,8 @@ #include "cassetteout.h" #include "slots.h" -AddressBus::AddressBus(Memory& ram, Memory& rom, Keyboard& kbd, VideoMode& vid, Paddles& paddles, PaddleButtonStates& paddleButtonStates, SpeakerClicker& speaker, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Slots& slts): - ram(ram), rom(rom), kbd(kbd), vid(vid), paddles(paddles), paddleButtonStates(paddleButtonStates), speaker(speaker), cassetteIn(cassetteIn), cassetteOut(cassetteOut), slts(slts) +AddressBus::AddressBus(ScreenImage& gui, int revision, Memory& ram, Memory& rom, Keyboard& kbd, VideoMode& vid, Paddles& paddles, PaddleButtonStates& paddleButtonStates, SpeakerClicker& speaker, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Slots& slts): + gui(gui), revision(revision), ram(ram), rom(rom), kbd(kbd), vid(vid), paddles(paddles), paddleButtonStates(paddleButtonStates), speaker(speaker), cassetteIn(cassetteIn), cassetteOut(cassetteOut), slts(slts) { } @@ -50,7 +50,7 @@ unsigned char AddressBus::read(const unsigned short address) { if ((address >> 12) == 0xC) { - // 11007sssxxxxxxxx + // 11007sss,xxxxxxxx const bool seventh = address & 0x0800; const int slot = (address >> 8) & 7; if (seventh) @@ -91,7 +91,7 @@ void AddressBus::write(const unsigned short address, const unsigned char d) { if ((address >> 12) == 0xC) { - // 11007sssxxxxxxxx + // 11007sss,xxxxxxxx const bool seventh = address & 0x0800; const int slot = (address >> 8) & 7; if (!seventh && slot == 0) @@ -137,11 +137,14 @@ unsigned char AddressBus::readSwitch(unsigned short address) } else if (islot == 0x3) { + if (this->revision == 0) { + this->cassetteOut.output(); + } this->speaker.click(); } else if (islot == 0x4) { - // ignore utility strobe + // TODO ? utility strobe } else if (islot == 0x5) { @@ -151,7 +154,12 @@ unsigned char AddressBus::readSwitch(unsigned short address) } else { - // ignore annunciator outputs + // 11000000,01011aaf + // aa = annunciator, 0-3 + // f == on/off + const bool on = iswch & 1; + const int ann = (iswch >> 1) & 3; + this->gui.setAnnunciator(ann, on); } } else if (islot == 0x6) diff --git a/src/addressbus.h b/src/addressbus.h index 6b245cc..80381a0 100644 --- a/src/addressbus.h +++ b/src/addressbus.h @@ -18,6 +18,7 @@ #ifndef ADDRESSBUS_H #define ADDRESSBUS_H +class ScreenImage; class Memory; class Keyboard; class VideoMode; @@ -28,37 +29,38 @@ class CassetteIn; class CassetteOut; class Slots; -class AddressBus -{ -private: - Memory& ram; - Memory& rom; - Keyboard& kbd; - VideoMode& vid; - Paddles& paddles; - PaddleButtonStates& paddleButtonStates; - SpeakerClicker& speaker; +class AddressBus { + private: + ScreenImage& gui; + int revision; + Memory& ram; + Memory& rom; + Keyboard& kbd; + VideoMode& vid; + Paddles& paddles; + PaddleButtonStates& paddleButtonStates; + SpeakerClicker& speaker; CassetteIn& cassetteIn; CassetteOut& cassetteOut; Slots& slts; - unsigned char data; // this emulates the (floating) data bus + unsigned char data; // this emulates the (floating) data bus -public: - AddressBus(Memory& ram, Memory& rom, Keyboard& kbd, VideoMode& vid, Paddles& paddles, PaddleButtonStates& paddleButtonStates, SpeakerClicker& speaker, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Slots& slts); - ~AddressBus(); + public: + AddressBus(ScreenImage& gui, int revision, Memory& ram, Memory& rom, Keyboard& kbd, VideoMode& vid, Paddles& paddles, PaddleButtonStates& paddleButtonStates, SpeakerClicker& speaker, CassetteIn& cassetteIn, CassetteOut& cassetteOut, Slots& slts); + ~AddressBus(); - unsigned char read(const unsigned short address); - void write(const unsigned short address, const unsigned char d); - unsigned char readSwitch(unsigned short address); - void setD7(const bool set); - void writeSwitch(unsigned short address); - enum { MOTHERBOARD_RAM_BAS = 0x00000 } ; - enum { MOTHERBOARD_RAM_LIM = 0x0C000 } ; - enum { MOTHERBOARD_RAM_SIZ = MOTHERBOARD_RAM_LIM-MOTHERBOARD_RAM_BAS }; - enum { MOTHERBOARD_ROM_BAS = 0x0D000 } ; - enum { MOTHERBOARD_ROM_LIM = 0x10000 } ; - enum { MOTHERBOARD_ROM_SIZ = MOTHERBOARD_ROM_LIM-MOTHERBOARD_ROM_BAS } ; + unsigned char read(const unsigned short address); + void write(const unsigned short address, const unsigned char d); + unsigned char readSwitch(unsigned short address); + void setD7(const bool set); + void writeSwitch(unsigned short address); + enum { MOTHERBOARD_RAM_BAS = 0x00000 } ; + enum { MOTHERBOARD_RAM_LIM = 0x0C000 } ; + enum { MOTHERBOARD_RAM_SIZ = MOTHERBOARD_RAM_LIM-MOTHERBOARD_RAM_BAS }; + enum { MOTHERBOARD_ROM_BAS = 0x0D000 } ; + enum { MOTHERBOARD_ROM_LIM = 0x10000 } ; + enum { MOTHERBOARD_ROM_SIZ = MOTHERBOARD_ROM_LIM-MOTHERBOARD_ROM_BAS } ; }; #endif diff --git a/src/apple2.cpp b/src/apple2.cpp index 16ac093..25606a8 100644 --- a/src/apple2.cpp +++ b/src/apple2.cpp @@ -45,7 +45,7 @@ Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates ram(AddressBus::MOTHERBOARD_RAM_SIZ), cassetteIn(gui), cassetteOut(gui), - addressBus(ram,rom,kbd,videoMode,paddles,paddleButtonStates,speaker,cassetteIn,cassetteOut,slts), + addressBus(gui,revision,ram,rom,kbd,videoMode,paddles,paddleButtonStates,speaker,cassetteIn,cassetteOut,slts), picgen(tv,videoMode,this->revision), video(videoMode,addressBus,picgen,textRows), #ifdef USE_EMU diff --git a/src/screenimage.cpp b/src/screenimage.cpp index e503a05..e98e441 100644 --- a/src/screenimage.cpp +++ b/src/screenimage.cpp @@ -107,8 +107,9 @@ void ScreenImage::createScreen() { void ScreenImage::drawLabels() { drawText("EPPLE ][", 0, 141); - drawSlots(); + drawText("ANNUNCIATORS: 0: 1: 2: 3:", 65, 17); drawCassette(); + drawSlots(); drawFnKeys(); } @@ -256,7 +257,7 @@ void ScreenImage::drawChar(const char ch, int row, int col, int color, int bgcol void ScreenImage::displayHz(int hz) { char s[20]; - sprintf(s, "%4.2f MHz ", hz / 1e6); + sprintf(s, "%5.3f MHz ", hz / 1e6); drawText(s, 3, 141); } @@ -435,6 +436,10 @@ void ScreenImage::setTrack(int slot, int drive, int track) { this->slotnames[slot][c - 20] = nibl; } +void ScreenImage::setAnnunciator(int ann, bool on) { + drawChar(' ', 65, 33+4*ann, 0xFFFFFF, on ? 0xFF0000 : 0); +} + void ScreenImage::setIO(int slot, int drive, bool on) { int r(R_SLOT + slot); int c(35 + 32 * drive); diff --git a/src/screenimage.h b/src/screenimage.h index bfd1145..448f577 100644 --- a/src/screenimage.h +++ b/src/screenimage.h @@ -82,6 +82,8 @@ public: void setDiskFile(int slot, int drive, const std::string& filename); + void setAnnunciator(int ann, bool on); + void clearCurrentDrive(int slt, int drv); void setCurrentDrive(int slt, int drv, int track, bool on); void setTrack(int slot, int drive, int track);