Index: trunk/src/VBox/Devices/PC/BIOS/logo.c
===================================================================
--- trunk/src/VBox/Devices/PC/BIOS/logo.c	(revision 2880)
+++ trunk/src/VBox/Devices/PC/BIOS/logo.c	(revision 2913)
@@ -446,5 +446,5 @@
 /**
  * Fade in and check for keystroke.
- * @returns    BIOS scan code if available, 0 if not.
+ * @returns   1 if F12 was pressed, 0 if not.
  */
 Bit8u fade_in(palette_seg, palette_size)
@@ -454,5 +454,5 @@
     RGBPAL *palette;
     Bit16u i, j;
-    Bit8u  scode, scan_code = 0;
+    Bit8u  scode;
 
     // Fade in
@@ -482,14 +482,14 @@
         }
         scode = wait(16 / WAIT_MS, 0);
-        if (scode)
-            scan_code = scode;
+        if (scode == F12_SCAN_CODE)
+            return 1;
     }
 
-    return scan_code;
+    return 0; // F12 not pressed
 }
 
 /**
  * Fade out and check for keystroke.
- * @returns    BIOS scan code if available, 0 if not.
+ * @returns    1 if F12 was pressed, 0 if not.
  */
 Bit8u fade_out(palette_seg, palette_size)
@@ -499,5 +499,5 @@
     RGBPAL *palette;
     Bit16u i, j;
-    Bit8u  scode, scan_code = 0;
+    Bit8u  scode;
 
     // Fade out
@@ -527,9 +527,9 @@
         }
         scode = wait(16 / WAIT_MS, 0);
-        if (scode)
-            scan_code = scode;
+        if (scode == F12_SCAN_CODE)
+            return 1;
     }
 
-    return scan_code;
+    return 0; // F12 not pressed
 }
 
@@ -583,5 +583,5 @@
     Bit16u      address;
 
-    Bit8u       scode, scan_code = 0;
+    Bit8u       scode, f12_pressed = 0;
     Bit8u c;
 
@@ -977,20 +977,21 @@
         if (is_fade_in)
         {
-            scode = fade_in(pal_seg, palette_size);
-            if (scode && scan_code != F12_SCAN_CODE)
-                scan_code = scode;
+            if (fade_in(pal_seg, palette_size))
+                f12_pressed = 1;
         }
 
         // Wait (interval in milliseconds)
-        scode = wait(logo_time / WAIT_MS, 0);
-        if (scode && scan_code != F12_SCAN_CODE)
-            scan_code = scode;
-
-        // Fade out
-        if (is_fade_out)
-        {
-            scode = fade_out(pal_seg, palette_size);
-            if (scode && scan_code != F12_SCAN_CODE)
-                scan_code = scode;
+        if (!f12_pressed)
+        {
+            scode = wait(logo_time / WAIT_MS, 0);
+            if (scode == F12_SCAN_CODE)
+                f12_pressed = 1;
+        }
+
+        // Fade out (only if F12 was not pressed)
+        if (is_fade_out && !f12_pressed)
+        {
+            if (fade_out(pal_seg, palette_size))
+                f12_pressed = 1;
         }
     }
@@ -1038,13 +1039,15 @@
 
             // if the user has pressed F12 don't wait here
-            if ( scan_code != F12_SCAN_CODE )
+            if (!f12_pressed)
             {
                 // Wait for timeout or keystroke
-                scan_code = wait(F12_WAIT_TIME, 1);
+                scode = wait(F12_WAIT_TIME, 1);
+                if (scode == F12_SCAN_CODE)
+                    f12_pressed = 1;
             }
         }
 
         // If F12 pressed, show boot menu
-        if (scan_code == F12_SCAN_CODE)
+        if (f12_pressed)
         {
             // Hide cursor, clear screen and move cursor to starting position
@@ -1075,23 +1078,32 @@
 
             // Show menu
-            printf("\n");
-            printf("VirtualBox temporary boot device selection\n");
-            printf("\n");
-            printf(" 1) Floppy\n");
-            printf(" 2) Hard Disk\n");
-            printf(" 3) CD-ROM\n");
-            printf(" 4) LAN\n\n");
-            printf(" 0) Continue booting\n");
+            printf("\n"
+                   "VirtualBox temporary boot device selection\n"
+                   "\n"
+                   " 1) Floppy\n"
+                   " 2) Hard Disk\n"
+                   " 3) CD-ROM\n"
+                   " 4) LAN\n"
+                   "\n"
+                   " 0) Continue booting\n");
 
             // Wait for keystroke
-            do
+            for (;;)
             {
-                scan_code = wait(WAIT_HZ, 1);
-            } while (scan_code == 0);
-
-            // Change first boot device code to selected one
-            if (scan_code > 0x02 && scan_code <= 0x05)
-            {
-                write_byte(ebda_seg,&EbdaData->uForceBootDrive, scan_code-1);
+                do
+                {
+                    scode = wait(WAIT_HZ, 1);
+                } while (scode == 0);
+
+                // Change first boot device code to selected one
+                if (scode > 0x02 && scode <= 0x05)
+                {
+                    write_byte(ebda_seg,&EbdaData->uForceBootDrive, scode-1);
+                    break;
+                }
+
+                // '0' ... continue
+                if (scode == 0x0b)
+                    break;
             }
 
