]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Refactored disk gui information. Show yellow border in OSD if disk is write protected.
authorToni Wilen <twilen@winuae.net>
Sun, 2 Feb 2020 12:56:54 +0000 (14:56 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 2 Feb 2020 12:56:54 +0000 (14:56 +0200)
disk.cpp
include/gui.h
od-win32/lcd.cpp
od-win32/win32gui.cpp
statusline.cpp

index 78dc2d3c26640a113d61e597037a6c4e8351213e..474c4f84baf96663eda9eef9b54901b08799a9fa 100644 (file)
--- a/disk.cpp
+++ b/disk.cpp
@@ -668,11 +668,12 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR
 
 static void reset_drive_gui (int num)
 {
-       gui_data.drive_disabled[num] = 0;
-       gui_data.df[num][0] = 0;
-       gui_data.crc32[num] = 0;
+       struct gui_info_drive *gid = &gui_data.drives[num];
+       gid->drive_disabled = 0;
+       gid->df[0] = 0;
+       gid->crc32 = 0;
        if (currprefs.floppyslots[num].dfxtype < 0)
-               gui_data.drive_disabled[num] = 1;
+               gid->drive_disabled = 1;
 }
 
 static void setamax (void)
@@ -703,6 +704,15 @@ static bool ispcbridgedrive(int num)
        return type == DRV_PC_525_ONLY_40 || type == DRV_PC_35_ONLY_80 || type == DRV_PC_525_40_80;
 }
 
+static bool drive_writeprotected(drive *drv)
+{
+#ifdef CATWEASEL
+       if (drv->catweasel)
+               return 1;
+#endif
+       return currprefs.floppy_read_only || drv->wrprot || drv->forcedwrprot || drv->diskfile == NULL;
+}
+
 static void reset_drive (int num)
 {
        drive *drv = &floppy[num];
@@ -748,25 +758,27 @@ static void update_drive_gui (int num, bool force)
 {
        drive *drv = floppy + num;
        bool writ = dskdmaen == DSKDMA_WRITE && drv->state && !((selected | disabled) & (1 << num));
+       struct gui_info_drive *gid = &gui_data.drives[num];
 
-       if (!force && drv->state == gui_data.drive_motor[num]
-               && drv->cyl == gui_data.drive_track[num]
+       if (!force && drv->state == gid->drive_motor
+               && drv->cyl == gid->drive_track
                && side == gui_data.drive_side
-               && drv->crc32 == gui_data.crc32[num]
-               && writ == gui_data.drive_writing[num]
-               && !_tcscmp (gui_data.df[num], currprefs.floppyslots[num].df))
+               && drv->crc32 == gid->crc32
+               && writ == gid->drive_writing
+               && drive_writeprotected(drv) == gid->floppy_protected
+               && !_tcscmp (gid->df, currprefs.floppyslots[num].df))
                return;
-       _tcscpy (gui_data.df[num], currprefs.floppyslots[num].df);
-       gui_data.crc32[num] = drv->crc32;
-       gui_data.drive_motor[num] = drv->state;
-       gui_data.drive_track[num] = drv->cyl;
+       _tcscpy (gid->df, currprefs.floppyslots[num].df);
+       gid->crc32 = drv->crc32;
+       gid->drive_motor = drv->state;
+       gid->drive_track = drv->cyl;
        if (reserved & (1 << num))
                gui_data.drive_side = reserved_side;
        else
                gui_data.drive_side = side;
-       gui_data.drive_writing[num] = writ;
-       //write_log(_T("%d %d\n"), num, (gui_data.drive_motor[num] ? 1 : 0) | (gui_data.drive_writing[num] ? 2 : 0));
-       gui_led (num + LED_DF0, (gui_data.drive_motor[num] ? 1 : 0) | (gui_data.drive_writing[num] ? 2 : 0), -1);
+       gid->drive_writing = writ;
+       gid->floppy_protected = drive_writeprotected(drv);
+       gui_led (num + LED_DF0, (gid->drive_motor ? 1 : 0) | (gid->drive_writing ? 2 : 0), -1);
 }
 
 static void drive_fill_bigbuf (drive * drv,int);
@@ -1581,16 +1593,6 @@ static int drive_track0 (drive * drv)
        return drv->cyl == 0;
 }
 
-static int drive_writeprotected (drive * drv)
-{
-#ifdef CATWEASEL
-       if (drv->catweasel)
-               return 1;
-#endif
-       //write_log(_T("df%d: %d %d %d %x %s\n"), drv-&floppy[0],currprefs.floppy_read_only, drv->wrprot, drv->forcedwrprot, drv->diskfile, drv->diskfile ? zfile_getname(drv->diskfile) : _T("none"));
-       return currprefs.floppy_read_only || drv->wrprot || drv->forcedwrprot || drv->diskfile == NULL;
-}
-
 static int drive_running (drive * drv)
 {
        return !drv->motoroff;
index ec339635fbc266f58ca29bc057925d65f3db831d..815978a5c35980ffc0c20db35749e3cc38e9db56 100644 (file)
@@ -49,12 +49,18 @@ extern bool no_gui, quit_to_gui;
 #define LED_NET 11
 #define LED_MAX 12
 
+struct gui_info_drive {
+       bool drive_motor;               /* motor on off */
+       uae_u8 drive_track;             /* rw-head track */
+       bool drive_writing;             /* drive is writing */
+       bool drive_disabled;    /* drive is disabled */
+       TCHAR df[256];                  /* inserted image */
+       uae_u32 crc32;                  /* crc32 of image */
+       bool floppy_protected;  /* image is write protected */
+};
+
 struct gui_info
 {
-    bool drive_motor[4];               /* motor on off */
-    uae_u8 drive_track[4];             /* rw-head track */
-    bool drive_writing[4];             /* drive is writing */
-    bool drive_disabled[4];            /* drive is disabled */
     bool powerled;                             /* state of power led */
     uae_u8 powerled_brightness;        /* 0 to 255 */
     uae_s8 drive_side;                 /* floppy side */
@@ -67,8 +73,7 @@ struct gui_info
        int fps_color;
     int sndbuf, sndbuf_status;
        bool sndbuf_avail;
-    TCHAR df[4][256];                  /* inserted image */
-    uae_u32 crc32[4];                  /* crc32 of image */
+       struct gui_info_drive drives[4];
 };
 #define NUM_LEDS (LED_MAX)
 #define VISIBLE_LEDS (LED_MAX - 1)
index 950656bbf0441f94c688be436ecaf8e755fee5bb..b594dc988b05bd3df62e95124d0f316315841626 100644 (file)
@@ -231,8 +231,8 @@ void lcd_update(int led, int on)
        if (led >= 1 && led <= 4) {
                x = 23 + (led - 1) * 40;
                y = 17;
-               track = gui_data.drive_track[led - 1];
-               if (gui_data.drive_disabled[led - 1]) {
+               track = gui_data.drives[led - 1].drive_track;
+               if (gui_data.drives[led - 1].drive_disabled) {
                        track = -1;
                        on = 0;
                }
index 9abcee25aa5dc775056ca77ecf55e1a1e5659ef9..93959b8df722c00fb8edafef1616c273259fbbd0 100644 (file)
@@ -22172,9 +22172,9 @@ void gui_led (int led, int on, int brightness)
        if (D3D_led)
                D3D_led(led, on, brightness);
 #ifdef RETROPLATFORM
-       if (led >= LED_DF0 && led <= LED_DF3 && !gui_data.drive_disabled[led - LED_DF0]) {
-               rp_floppy_track (led - LED_DF0, gui_data.drive_track[led - LED_DF0]);
-               writing = gui_data.drive_writing[led - LED_DF0];
+       if (led >= LED_DF0 && led <= LED_DF3 && !gui_data.drives[led - LED_DF0].drive_disabled) {
+               rp_floppy_track(led - LED_DF0, gui_data.drives[led - LED_DF0].drive_track);
+               writing = gui_data.drives[led - LED_DF0].drive_writing;
        }
        rp_update_leds (led, on, brightness, writing);
 #endif
@@ -22184,11 +22184,11 @@ void gui_led (int led, int on, int brightness)
        if (led >= LED_DF0 && led <= LED_DF3) {
                pos = 7 + (led - LED_DF0);
                ptr = drive_text + pos * LED_STRING_WIDTH;
-               if (gui_data.drive_disabled[led - 1])
+               if (gui_data.drives[led - 1].drive_disabled)
                        _tcscpy (ptr, _T(""));
                else
-                       _stprintf (ptr , _T("%02d"), gui_data.drive_track[led - 1]);
-               p = gui_data.df[led - 1];
+                       _stprintf (ptr , _T("%02d"), gui_data.drives[led - 1].drive_track);
+               p = gui_data.drives[led - 1].df;
                j = _tcslen (p) - 1;
                if (j < 0)
                        j = 0;
@@ -22200,9 +22200,9 @@ void gui_led (int led, int on, int brightness)
                tt = dfx[led - 1];
                tt[0] = 0;
                if (_tcslen (p + j) > 0)
-                       _stprintf (tt, _T("%s [CRC=%08X]"), p + j, gui_data.crc32[led - 1]);
+                       _stprintf (tt, _T("%s [CRC=%08X]"), p + j, gui_data.drives[led - 1].crc32);
                center = 1;
-               if (gui_data.drive_writing[led - 1])
+               if (gui_data.drives[led - 1].drive_writing)
                        writing = 1;
        } else if (led == LED_POWER) {
                pos = 3;
index 93b00bc5bb4d007d53b811685bce888745a8d926..ed0b644fdd7327e365f5e2949a16c4b1f92452d3 100644 (file)
@@ -79,6 +79,18 @@ static void write_tdnumber(uae_u8 *buf, int bpp, int x, int y, int num, uae_u32
        }
 }
 
+static uae_u32 rgbmuldiv(uae_u32 rgb, int mul, int div)
+{
+       uae_u32 out = 0;
+       for (int i = 0; i < 3; i++) {
+               int v = (rgb >> (i * 8)) & 0xff;
+               v *= mul;
+               v /= div;
+               out |= v << (i * 8);
+       }
+       return out;
+}
+
 void draw_status_line_single(int monid, uae_u8 *buf, int bpp, int y, int totalwidth, uae_u32 *rc, uae_u32 *gc, uae_u32 *bc, uae_u32 *alpha)
 {
        struct amigadisplay *ad = &adisplays[monid];
@@ -87,7 +99,6 @@ void draw_status_line_single(int monid, uae_u8 *buf, int bpp, int y, int totalwi
 
        c1 = ledcolor (0x00ffffff, rc, gc, bc, alpha);
        c2 = ledcolor (0x00000000, rc, gc, bc, alpha);
-       cb = ledcolor (TD_BORDER, rc, gc, bc, alpha);
 
        if (td_pos & TD_RIGHT)
                x_start = totalwidth - TD_PADX - VISIBLE_LEDS * TD_WIDTH;
@@ -99,6 +110,7 @@ void draw_status_line_single(int monid, uae_u8 *buf, int bpp, int y, int totalwi
                int x, c, on = 0, am = 2;
                xcolnr on_rgb = 0, on_rgb2 = 0, off_rgb = 0, pen_rgb = 0;
                int half = 0;
+               cb = ledcolor(TD_BORDER, rc, gc, bc, alpha);
 
                if (!(currprefs.leds_on_screen_mask[ad->picasso_on ? 1 : 0] & (1 << led)))
                        continue;
@@ -106,25 +118,30 @@ void draw_status_line_single(int monid, uae_u8 *buf, int bpp, int y, int totalwi
                pen_rgb = c1;
                if (led >= LED_DF0 && led <= LED_DF3) {
                        int pled = led - LED_DF0;
-                       int track = gui_data.drive_track[pled];
+                       struct floppyslot *fs = &currprefs.floppyslots[pled];
+                       struct gui_info_drive *gid = &gui_data.drives[pled];
+                       int track = gid->drive_track;
                        pos = 7 + pled;
                        on_rgb = 0x00cc00;
-                       on_rgb2 = 0x006600;
-                       off_rgb = 0x003300;
-                       if (!gui_data.drive_disabled[pled]) {
+                       if (!gid->drive_disabled) {
                                num1 = -1;
                                num2 = track / 10;
                                num3 = track % 10;
-                               on = gui_data.drive_motor[pled];
-                               if (gui_data.drive_writing[pled]) {
+                               on = gid->drive_motor;
+                               if (gid->drive_writing) {
                                        on_rgb = 0xcc0000;
-                                       on_rgb2 = 0x880000;
                                }
                                half = gui_data.drive_side ? 1 : -1;
-                               if (gui_data.df[pled][0] == 0)
-                                       pen_rgb = ledcolor (0x00aaaaaa, rc, gc, bc, alpha);
+                               if (gid->df[0] == 0) {
+                                       pen_rgb = ledcolor(0x00aaaaaa, rc, gc, bc, alpha);
+                               } else if (gid->floppy_protected) {
+                                       cb = ledcolor(0xff8040, rc, gc, bc, alpha);
+                               }
                        }
                        side = gui_data.drive_side;
+                       on_rgb &= 0xffffff;
+                       off_rgb = rgbmuldiv(on_rgb, 2, 4);
+                       on_rgb2 = rgbmuldiv(on_rgb, 2, 3);
                } else if (led == LED_POWER) {
                        pos = 3;
                        on_rgb = ((gui_data.powerled_brightness * 10 / 16) + 0x33) << 16;
@@ -232,7 +249,7 @@ void draw_status_line_single(int monid, uae_u8 *buf, int bpp, int y, int totalwi
                                on_rgb = 0x0000cc; // "normal" overflow
                        off_rgb = 0x000000;
                        am = 3;
-               } else if (led == LED_MD && gui_data.drive_disabled[3]) {
+               } else if (led == LED_MD && gui_data.drives[3].drive_disabled) {
                        // DF3 reused as internal non-volatile ram led (cd32/cdtv)
                        pos = 7 + 3;
                        if (gui_data.md >= 0) {
@@ -272,7 +289,7 @@ void draw_status_line_single(int monid, uae_u8 *buf, int bpp, int y, int totalwi
                }
                border = 0;
                if (y == 0 || y == TD_TOTAL_HEIGHT - 1) {
-                       c = ledcolor (TD_BORDER, rc, gc, bc, alpha);
+                       c = cb;
                        border = 1;
                }