Index: trunk/bootcode/airboot.asm
===================================================================
--- trunk/bootcode/airboot.asm	(revision 77)
+++ trunk/bootcode/airboot.asm	(revision 78)
@@ -120,5 +120,5 @@
 BIOS_AUXPARMS_DEFAULT   EQU     (AUX_INIT_PARMS SHL 8) OR BIOS_COM_PORT
 
-; Default byte value for BIOS_BootDisk variabls
+; Default byte value for BIOS_BootDisk variable
 BIOS_BOOTDISK_DEFAULT   EQU     80h
 
Index: trunk/bootcode/regular/driveio.asm
===================================================================
--- trunk/bootcode/regular/driveio.asm	(revision 77)
+++ trunk/bootcode/regular/driveio.asm	(revision 78)
@@ -39,6 +39,7 @@
         mov     es, ax
         mov     bx, offset Configuration
-        mov     dx, 0080h                     ; First harddrive, Sector 55...
-        mov     cx, 0037h
+        xor     dh, dh
+        mov     dl, [BIOS_BootDisk]           ; Disk we booted from
+        mov     cx, 0037h                     ; Sector 55 (CHS)
         mov     ax, 0201h                     ; Function 02, read 1 sector...
         int     13h
@@ -86,6 +87,7 @@
         ; ES == CS
         mov     bx, offset Configuration
-        mov     dx, 0080h                     ; First harddrive, Sector 55...
-        mov     cx, 0037h
+        xor     dh, dh
+        mov     dl, [BIOS_BootDisk]           ; Disk we booted from
+        mov     cx, 0037h                     ; Sector 55 (CHS)
 
         ; Changed from 5 to calculated value
@@ -173,5 +175,5 @@
         mov     di, offset LBASwitchTable
         mov     dh, [TotalHarddiscs]
-        mov     dl, 80h
+        mov     dl, 80h        ; First disk to process
     DIOILUT_DriveLoop:
         push    dx
@@ -197,7 +199,7 @@
         mov     bptr ds:[di], ah  ; Save that value
         inc     di                ; Go to next BYTE
-        inc     dl
-        dec     dh
-        jnz     DIOILUT_DriveLoop
+        inc     dl                ; Next disk
+        dec     dh                ; Decrease disks to process
+        jnz     DIOILUT_DriveLoop ; Next disk if DH != 0
         ret
 DriveIO_InitLBASwitchTable  EndP
@@ -800,6 +802,6 @@
         ; checking the AiR-BOOT MBR.
         ;
-        cmp     dl,80h
-        ja      DriveIO_ProtectMBR_is_not_bootdisk
+        cmp     dl, [BIOS_BootDisk]
+        jne     DriveIO_ProtectMBR_is_not_bootdisk
 
         ;
Index: trunk/bootcode/regular/other.asm
===================================================================
--- trunk/bootcode/regular/other.asm	(revision 77)
+++ trunk/bootcode/regular/other.asm	(revision 78)
@@ -166,7 +166,24 @@
         call    MBR_TeletypeNL
 
+        ;
+        ; Write MBR back to disk to sync MBR variables.
+        ; Otherwise subsequent MBR loads will differ from the RAM stored one,
+        ; which is used by MBR protection to validate parts of the MBR.
+        ;
+        xor     bx, bx
+        mov     cx, 1
+        xor     dh, dh
+        mov     dl, [BIOS_BootDisk]
+        mov     al, 1
+        mov     ah, 03h
+        int     13h
+
+
+        ; Start with disk at index 0
         xor     cx,cx
+
     PRECRAP_Main_next_disk:
 
+        ; Get next disk and convert to BIOS disk-number
         mov     dl,cl
         or      dl,80h
@@ -431,5 +448,5 @@
         mov     ah, 41h
         mov     bx, 55AAh
-        mov     dl, 80h
+        mov     dl, [BIOS_BootDisk]     ; We check using the boot-disk
         int     13h
         cmp     bx, 0AA55h
Index: trunk/bootcode/regular/partmain.asm
===================================================================
--- trunk/bootcode/regular/partmain.asm	(revision 77)
+++ trunk/bootcode/regular/partmain.asm	(revision 78)
@@ -1318,12 +1318,13 @@
         ; --- HIDE COMPLETED ---
         ; So something got hidden and we have to remark a primary partition,
-        ;  if we are booting something non-primary from 1st hdd.
-        cmp     bptr [si+LocIPT_Drive], 80h
-        ja      PSP_HideAdjustPrimaryMark  ; When booting any hdd, but 1st
+        ;  if we are booting something non-primary from the boot-disk.
+        mov     al, [BIOS_BootDisk]
+        cmp     bptr [si+LocIPT_Drive], al
+        jne     PSP_HideAdjustPrimaryMark  ; When booting any hdd, but boot-disk
         mov     ax, wptr [si+LocIPT_AbsolutePartTable]
         mov     bx, wptr [si+LocIPT_AbsolutePartTable+2]
         or      ax, ax
         jnz     PSP_HideAdjustPrimaryMark  ; or booting non-primary partition
-        or      bx, bx                     ;  on 1st harddrive.
+        or      bx, bx                     ;  on boot-disk.
         jz      PSP_NoHideAdjustPrimaryMark
 
@@ -1333,9 +1334,18 @@
         xor     bx, bx
         mov     cx, 0001h                  ; Cylinder 0, Sector 1
-        mov     dx, 0080h                  ; First HD, Head 0
-                                                                     ; Load MBR
+        xor     dh, dh                     ; Head 0
+        mov     dl, [BIOS_BootDisk]        ; Boot Disk
+
+        ; This uses the boot-disk and alters 'CurPartition_Location'.
+        ; CHECKME: How does 81h being the boot-disk influences this ?
         call    DriveIO_LoadPartition      ; Load Primary Partition Table
+
+        ; This would only be needed for very old BIOSses
         call    PART_MarkFirstGoodPrimary
-        call    DriveIO_SavePartition       ; Saves the Partition-Table
+
+        ; CHECKME: Disabled writing back MBR with modified boot flags
+        ; This is a safety measure now that booting AirBoot from other disks
+        ; than 80h can occur.
+        ;~ call    DriveIO_SavePartition       ; Saves the Partition-Table
 
 
Index: trunk/bootcode/regular/partscan.asm
===================================================================
--- trunk/bootcode/regular/partscan.asm	(revision 77)
+++ trunk/bootcode/regular/partscan.asm	(revision 78)
@@ -305,5 +305,5 @@
         ; Clearing the boot-flags on other disks would prevent booting them
         ; from the BIOS. (TRAC ticket #6)
-        cmp     dl, 080h                            ; See if this is boot-disk
+        cmp     dl, [BIOS_BootDisk]                 ; See if this is boot-disk
         jne     PSSP_Skip_Clear_BootFlag            ; Nope, skip clear flag
         and     byte ptr [si+LocBRPT_Flags], 7Fh    ; Reset the Active-Flag
@@ -313,9 +313,10 @@
         jb      PSSP_ScanLoop
         ; If we are on first HDD and in primary partition table -> mark primary
-        cmp     bptr [CurPartition_Location+4], 80h ; Drive
+        mov     al, [BIOS_BootDisk]
+        cmp     bptr [CurPartition_Location+4], al  ; Drive
         jne     PSSP_NoMarkPrimary
         cmp     wptr [CurPartition_Location+0], 0
         jne     PSSP_NoMarkPrimary
-        cmp     wptr [CurPartition_Location+2], 0 ; Absolute Location
+        cmp     wptr [CurPartition_Location+2], 0   ; Absolute Location
         jne     PSSP_NoMarkPrimary
         call    PART_MarkFirstGoodPrimary
