From ec691374eaea530e5b1f555fb501b777c69b6a99 Mon Sep 17 00:00:00 2001 From: Jorj Bauer Date: Wed, 2 Feb 2022 08:57:06 -0500 Subject: [PATCH] working on drive activity --- apple/appleui.cpp | 1 + image-8875-drivelatches.h | 8 ++++---- images.h | 7 +++++++ sdl/sdl-display.cpp | 36 +++++++++++++++++++++++++++++------- sdl/sdl-display.h | 4 ++++ teensy/teensy-display.cpp | 22 +++++++++------------- teensy/teensy-display.h | 2 -- 7 files changed, 54 insertions(+), 26 deletions(-) diff --git a/apple/appleui.cpp b/apple/appleui.cpp index e2f495f..b9bd593 100644 --- a/apple/appleui.cpp +++ b/apple/appleui.cpp @@ -117,6 +117,7 @@ void AppleUI::blit() redrawDriveLatches = false; g_display->drawUIImage(driveInserted[0] ? IMG_D1CLOSED : IMG_D1OPEN); g_display->drawUIImage(driveInserted[1] ? IMG_D2CLOSED : IMG_D2OPEN); + redrawDriveActivity = true; // these overlap } if (redrawDriveActivity) { diff --git a/image-8875-drivelatches.h b/image-8875-drivelatches.h index a4357fb..757a6fd 100644 --- a/image-8875-drivelatches.h +++ b/image-8875-drivelatches.h @@ -1,4 +1,4 @@ -const static uint8_t image_d1_open[] PROGMEM = { +const static uint8_t image_d1_closed[] PROGMEM = { 0xCE,0x37, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, @@ -87,7 +87,7 @@ const static uint8_t image_d1_open[] PROGMEM = { 0x58,0xA2, 0xCD,0xD5, }; -const static uint8_t image_d1_closed[] PROGMEM = { +const static uint8_t image_d1_open[] PROGMEM = { 0xCE,0x37, 0x31,0x23, 0x10,0x81, 0x18,0x81, 0x20,0xC1, 0x29,0x02, 0x28,0xE2, 0x28,0xC2, 0x31,0x01, 0x29,0x01, 0x20,0xC1, 0x28,0xE1, 0x31,0x42, 0x28,0xC1, 0x20,0xA0, 0x31,0x22, 0x31,0x01, 0x28,0xE1, 0x31,0x02, 0x30,0xE1, 0x20,0xA0, 0x20,0xA0, 0x20,0xA0, 0x28,0xC1, @@ -176,7 +176,7 @@ const static uint8_t image_d1_closed[] PROGMEM = { 0x58,0xA2, 0xCD,0xD5, }; -const static uint8_t image_d2_open[] PROGMEM = { +const static uint8_t image_d2_closed[] PROGMEM = { 0xCE,0x37, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, 0x20,0xC1, @@ -265,7 +265,7 @@ const static uint8_t image_d2_open[] PROGMEM = { 0x58,0xA2, 0xCD,0xD5, }; -const static uint8_t image_d2_closed[] PROGMEM = { +const static uint8_t image_d2_open[] PROGMEM = { 0xCE,0x37, 0x31,0x23, 0x10,0x81, 0x18,0x81, 0x20,0xC1, 0x29,0x02, 0x28,0xE2, 0x28,0xC2, 0x31,0x01, 0x29,0x01, 0x20,0xC1, 0x28,0xE1, 0x31,0x42, 0x28,0xC1, 0x20,0xA0, 0x31,0x22, 0x31,0x01, 0x28,0xE1, 0x31,0x02, 0x30,0xE1, 0x20,0xA0, 0x20,0xA0, 0x20,0xA0, 0x28,0xC1, diff --git a/images.h b/images.h index 6a94d01..26d5454 100644 --- a/images.h +++ b/images.h @@ -20,6 +20,13 @@ #define LED1_Y_8875 68 #define LED2_Y_8875 117 +#define LED_HEIGHT_9341 1 +#define LED_WIDTH_9341 6 +#define LED1_X_9341 125 +#define LED2_X_9341 (125+135) +#define LED1_Y_9341 213 +#define LED2_Y_9341 213 + // These are the ABSTRACTED constants that AppleUI uses to tell the // display what it wants redrawn via drawUIImage(uint8_t imageIdx) enum { diff --git a/sdl/sdl-display.cpp b/sdl/sdl-display.cpp index f67f670..375fe8f 100644 --- a/sdl/sdl-display.cpp +++ b/sdl/sdl-display.cpp @@ -44,6 +44,8 @@ SDLDisplay::SDLDisplay() { memset(videoBuffer, 0, sizeof(videoBuffer)); + driveIndicator[0] = driveIndicator[1] = false; + shellImage = NULL; d1OpenImage = d1ClosedImage = d2OpenImage = d2ClosedImage = NULL; appleImage = NULL; @@ -111,6 +113,30 @@ void SDLDisplay::drawUIImage(uint8_t imageIdx) } } +void SDLDisplay::drawDriveActivity(bool drive0, bool drive1) +{ + if (drive0 != driveIndicator[0]) { + printf("change d0\n"); + for (int y=0; y> 3, b = (color & 0x1F) << 3; - for (int yoff=0; yoff<2; yoff++) { - putpixel(renderer, x, (y*2)+yoff, r, g, b); - } + putpixel(renderer, x, y, r, g, b); } void SDLDisplay::drawPixel(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b) { - for (int yoff=0; yoff<2; yoff++) { - if (x < SDL_WIDTH && y < SDL_HEIGHT) { - putpixel(renderer, x, (y*2)+yoff, r, g, b); - } + if (x < SDL_WIDTH && y < SDL_HEIGHT) { + putpixel(renderer, x, y, r, g, b); } } diff --git a/sdl/sdl-display.h b/sdl/sdl-display.h index c7786f6..19050ae 100644 --- a/sdl/sdl-display.h +++ b/sdl/sdl-display.h @@ -21,6 +21,8 @@ class SDLDisplay : public PhysicalDisplay { virtual void flush(); virtual void drawUIImage(uint8_t imageIdx); + virtual void drawDriveActivity(bool drive0, bool drive1); + virtual void drawImageOfSizeAt(const uint8_t *img, uint16_t sizex, uint16_t sizey, uint16_t wherex, uint16_t wherey); virtual void drawPixel(uint16_t x, uint16_t y, uint16_t color); @@ -52,6 +54,8 @@ class SDLDisplay : public PhysicalDisplay { uint8_t *d2ClosedImage; uint8_t *appleImage; uint16_t appleImageWidth, appleImageHeight; + + bool driveIndicator[2]; }; #endif diff --git a/teensy/teensy-display.cpp b/teensy/teensy-display.cpp index ad39ce7..867d1f6 100644 --- a/teensy/teensy-display.cpp +++ b/teensy/teensy-display.cpp @@ -46,7 +46,6 @@ const uint16_t loresPixelColors[16] = { 0x0000, // 0 black TeensyDisplay::TeensyDisplay() { driveIndicator[0] = driveIndicator[1] = false; - driveIndicatorDirty = true; shellImage = NULL; d1OpenImage = d1ClosedImage = d2OpenImage = d2ClosedImage = NULL; @@ -158,27 +157,24 @@ void TeensyDisplay::drawUIImage(uint8_t imageIdx) void TeensyDisplay::drawDriveActivity(bool drive0, bool drive1) { - // FIXME port constants for 9341 + // FIXME this could be much more efficient; it's doing a lot of checking use8875 in the middle of a loop + if (drive0 != driveIndicator[0]) { - if (use8875) { - for (int y=0; y