#include "appleui.h" #include "vm.h" #include "images.h" // for the image abstraction constants #include "globals.h" AppleUI::AppleUI() { redrawFrame = true; redrawDriveLatches = true; redrawDriveActivity = true; driveInserted[0] = driveInserted[1] = 0; driveActivity[0] = driveActivity[1] = 0; } AppleUI::~AppleUI() { } void AppleUI::drawStaticUIElement(uint8_t element) { // Only one static UI element right now... if (element != UIeOverlay) return; redrawFrame = true; } void AppleUI::drawOnOffUIElement(uint8_t element, bool state) { if (element == UIeDisk1_state || element == UIeDisk2_state) { driveInserted[element-UIeDisk1_state] = state; redrawDriveLatches = true; } else if (element == UIeDisk1_activity || element == UIeDisk2_activity) { driveActivity[element-UIeDisk1_activity] = state; redrawDriveActivity = true; } } void AppleUI::drawPercentageUIElement(uint8_t element, uint8_t percent) { // only 1 element of this type if (element != UIePowerPercentage) { return; } drawBatteryStatus(percent); } void AppleUI::drawBatteryStatus(uint8_t percent) { return; // *** FIXME: image and positioning not updated for new aspect ratio uint16_t xoff = 301; uint16_t yoff = 222; // the area around the apple is 12 wide; it's exactly 11 high the // color is 210/202/159 static uint8_t *img = NULL; static uint16_t h,w; if (!img) { if (!getImageInfoAndData(IMG_APPLEBATTERY, &w, &h, &img)) { return; } } float watermark = ((float)percent / 100.0) * h; for (int y=0; y watermark) { // black... bgr = bgg = bgb = 0; } uint16_t w = w; for (int x=0; x> 3); g_display->drawPixel(x+xoff, y+yoff, color16); } } } void AppleUI::blit() { if (redrawFrame) { redrawFrame = false; g_display->drawUIImage(IMG_SHELL); } if (redrawDriveLatches) { 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) { redrawDriveActivity = false; g_display->drawDriveActivity(driveActivity[0], driveActivity[1]); } }