source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm @ 92

Last change on this file since 92 was 92, checked in by aitotat, 13 years ago

Changes to XTIDE Universal BIOS:

  • Removed ROM Boot from boot menu and created a hotkey for it.
File size: 6.0 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Displays Boot Menu.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Displays Boot Menu and returns Drive or Function number.
9;
10; BootMenu_DisplayAndReturnSelection
11;   Parameters:
12;       DS:     RAMVARS segment
13;   Returns:
14;       DX:     Untranslated drive number to be used for booting (if CF cleared)
15;               Function number (if CF set)
16;       CF:     Cleared if drive selected
17;               Set if function selected
18;   Corrupts registers:
19;       All General Purpose Registers
20;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
22BootMenu_DisplayAndReturnSelection:
23    call    DriveXlate_Reset
24    call    BootMenuPrint_TheBottomOfScreen
25    call    BootMenu_Enter          ; Get selected menuitem index to CX
26    call    BootMenuPrint_ClearScreen
27    cmp     cx, BYTE NO_ITEM_SELECTED
28    je      SHORT BootMenu_DisplayAndReturnSelection
29    jmp     SHORT BootMenu_ConvertMenuitemFromCXtoDriveInDX
30
31
32;--------------------------------------------------------------------
33; Enters Boot Menu or submenu.
34;
35; BootMenu_Enter
36;   Parameters:
37;       Nothing
38;   Returns:
39;       CX:     Index of selected item or NO_ITEM_SELECTED
40;   Corrupts registers:
41;       BX, DI
42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44BootMenu_Enter:
45    mov     bx, BootMenuEvent_Handler
46    CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
47    xchg    cx, ax
48    ret
49
50
51;--------------------------------------------------------------------
52; Returns number of menuitems in Boot Menu.
53;
54; BootMenu_GetMenuitemCountToCX
55;   Parameters:
56;       DS:     RAMVARS segment
57;   Returns:
58;       CX:     Number of boot menu items
59;   Corrupts registers:
60;       AX
61;--------------------------------------------------------------------
62ALIGN JUMP_ALIGN
63BootMenu_GetMenuitemCountToCX:
64    call    RamVars_GetHardDiskCountFromBDAtoCX
65    xchg    ax, cx
66    call    FloppyDrive_GetCount
67    add     ax, cx
68    ret
69
70
71;--------------------------------------------------------------------
72; BootMenu_GetHeightToALwithItemCountInCL
73;   Parameters:
74;       CL:     Number of menuitems
75;   Returns:
76;       AH:     Boot menu height
77;   Corrupts registers:
78;       AL, CL, DI
79;--------------------------------------------------------------------
80ALIGN JUMP_ALIGN
81BootMenu_GetHeightToAHwithItemCountInCL:
82    add     cl, BOOT_MENU_HEIGHT_WITHOUT_ITEMS
83    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
84    MIN_U   ah, cl
85    ret
86
87
88;--------------------------------------------------------------------
89; BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX
90;   Parameters:
91;       AL:     ASCII hotkey starting from upper case 'A'
92;   Returns:
93;       CX:     Menuitem index
94;   Corrupts registers:
95;       AX
96;--------------------------------------------------------------------
97ALIGN JUMP_ALIGN
98BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX:
99    call    BootMenu_GetLetterForFirstHardDiskToCL
100    cmp     al, cl                      ; Letter is for Hard Disk?
101    jae     SHORT .StartFromHardDiskLetter
102    sub     al, 'A'                     ; Letter to Floppy Drive menuitem
103    xchg    ax, cx                      ; Menuitem index to CX
104    ret
105ALIGN JUMP_ALIGN
106.StartFromHardDiskLetter:
107    sub     al, cl                      ; Hard Disk index
108    call    FloppyDrive_GetCount
109    add     cx, ax                      ; Menuitem index
110    ret
111
112;--------------------------------------------------------------------
113; Returns letter for first hard disk. Usually it will be 'c' but it
114; can be higher if more than two floppy drives are found.
115;
116; BootMenu_GetLetterForFirstHardDiskToCL
117;   Parameters:
118;       Nothing
119;   Returns:
120;       CL:     Upper case letter for first hard disk
121;   Corrupts registers:
122;       CH
123;--------------------------------------------------------------------
124ALIGN JUMP_ALIGN
125BootMenu_GetLetterForFirstHardDiskToCL:
126    call    FloppyDrive_GetCount
127    add     cl, 'A'
128    MAX_U   cl, 'C'
129    ret
130
131
132;--------------------------------------------------------------------
133; BootMenu_ConvertMenuitemFromCXtoDriveInDX
134;   Parameters:
135;       CX:     Index of menuitem selected from Boot Menu
136;       DS:     RAMVARS segment
137;   Returns:
138;       DX:     Drive number to be used for booting
139;   Corrupts registers:
140;       CX
141;--------------------------------------------------------------------
142ALIGN JUMP_ALIGN
143BootMenu_ConvertMenuitemFromCXtoDriveInDX:
144    mov     dx, cx                  ; Copy menuitem index to DX
145    call    FloppyDrive_GetCount
146    cmp     dx, cx                  ; Floppy drive?
147    jb      SHORT .ReturnFloppyDriveInDX
148    sub     dx, cx                  ; Remove floppy drives from index
149    or      dl, 80h
150.ReturnFloppyDriveInDX:
151    ret
152
153
154;--------------------------------------------------------------------
155; Converts Floppy or Hard Disk Drive number to menuitem index.
156; This function does not check does the drive really exists.
157;
158; BootMenu_ConvertDriveToMenuitem
159;   Parameters:
160;       DL:     Drive number
161;   Returns:
162;       CX:     Menuitem index (assuming drive is available)
163;   Corrupts registers:
164;       AX
165;--------------------------------------------------------------------
166ALIGN JUMP_ALIGN
167BootMenu_ConvertDriveToMenuitem:
168    test    dl, 80h                 ; Floppy drive?
169    jz      SHORT .ReturnFloppyMenuitem
170    call    FloppyDrive_GetCount
171    mov     ax, 7Fh                 ; Load mask to clear floppy bit
172    and     ax, dx                  ; AX = Hard Disk index
173    add     cx, ax                  ; Add hard disk index to floppy drive count
174    ret
175ALIGN JUMP_ALIGN
176.ReturnFloppyMenuitem:
177    eMOVZX  cx, dl                  ; Drive number and item index are equal
178    ret
179
180
181;--------------------------------------------------------------------
182; Checks is drive number valid for this system.
183;
184; BootMenu_IsDriveInSystem
185;   Parameters:
186;       DL:     Drive number
187;       DS:     RAMVARS segment
188;   Returns:
189;       CF:     Set if drive number is valid
190;               Clear if drive is not present in system
191;   Corrupts registers:
192;       AX, CX
193;--------------------------------------------------------------------
194ALIGN JUMP_ALIGN
195BootMenu_IsDriveInSystem:
196    test    dl, 80h                             ; Floppy drive?
197    jz      SHORT .IsFloppyDriveIsInSystem
198    call    RamVars_GetHardDiskCountFromBDAtoCX ; Hard Disk count to CX
199    or      cl, 80h                             ; Set Hard Disk bit to CX
200    jmp     SHORT .CompareDriveNumberToDriveCount
201.IsFloppyDriveIsInSystem:
202    call    FloppyDrive_GetCount                ; Floppy Drive count to CX
203.CompareDriveNumberToDriveCount:
204    cmp     dl, cl
205    ret
Note: See TracBrowser for help on using the repository browser.