working on drive activity

This commit is contained in:
Jorj Bauer 2022-02-02 08:57:06 -05:00
parent 8cd2bc24ab
commit ec691374ea
7 changed files with 54 additions and 26 deletions

View File

@ -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) {

View File

@ -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,

View File

@ -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 {

View File

@ -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<LED_HEIGHT_8875; y++) {
for (int x=0; x<LED_WIDTH_8875; x++) {
// FIXME this isn't working, not sure why
drawPixel(x+LED1_X_8875, y+LED1_Y_8875, 0xFF, 0, 0); ///*drive0 ?*/ 0xFA00/* : 0x0000*/);
}
}
driveIndicator[0] = drive0;
}
if (drive1 != driveIndicator[1]) {
for (int y=0; y<LED_HEIGHT_8875; y++) {
for (int x=0; x<LED_WIDTH_8875; x++) {
drawPixel(x+LED2_X_8875, y+LED2_Y_8875, drive0 ? 0xFA00 : 0x0000);
}
}
driveIndicator[1] = drive1;
}
}
void SDLDisplay::drawImageOfSizeAt(const uint8_t *img,
uint16_t sizex, uint16_t sizey,
uint16_t wherex, uint16_t wherey)
@ -158,17 +184,13 @@ void SDLDisplay::drawPixel(uint16_t x, uint16_t y, uint16_t color)
g = (color & 0x7E0) >> 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);
}
}

View File

@ -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

View File

@ -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<LED_HEIGHT_8875; y++) {
for (int x=0; x<LED_WIDTH_8875; x++) {
drawPixel(x+LED1_X_8875, y+LED1_Y_8875, drive0 ? 0xFA00 : 0x0000);
}
for (int y=0; y<(use8875 ? LED_HEIGHT_8875 : LED_HEIGHT_9341); y++) {
for (int x=0; x<(use8875 ? LED_WIDTH_8875 : LED_WIDTH_9341); x++) {
drawPixel(x+(use8875 ? LED1_X_8875 : LED1_X_9341), y+(use8875 ? LED1_Y_8875 : LED1_Y_9341), drive0 ? 0xFA00 : 0x0000);
}
}
driveIndicator[0] = drive0;
}
if (drive1 != driveIndicator[1]) {
if (use8875) {
for (int y=0; y<LED_HEIGHT_8875; y++) {
for (int x=0; x<LED_WIDTH_8875; x++) {
drawPixel(x+LED2_X_8875, y+LED2_Y_8875, drive1 ? 0xFA00 : 0x0000);
}
for (int y=0; y<(use8875 ? LED_HEIGHT_8875 : LED_HEIGHT_9341); y++) {
for (int x=0; x<(use8875 ? LED_WIDTH_8875 : LED_WIDTH_9341); x++) {
drawPixel(x+(use8875 ? LED2_X_8875 : LED2_X_9341), y+(use8875 ? LED2_Y_8875 : LED2_Y_9341), drive0 ? 0xFA00 : 0x0000);
}
}
// FIXME also 9341
driveIndicator[1] = drive1;
}
}

View File

@ -34,9 +34,7 @@ class TeensyDisplay : public PhysicalDisplay {
virtual void drawPixel(uint16_t x, uint16_t y, uint16_t color);
virtual void drawPixel(uint16_t x, uint16_t y, uint8_t r, uint8_t g, uint8_t b);
bool needsRedraw;
bool driveIndicator[2];
bool driveIndicatorDirty;
private:
const uint8_t *shellImage;