[392] | 1 | ; Project name : XTIDE Universal BIOS |
---|
| 2 | ; Description : Boot Menu event handler for menu library callbacks. |
---|
| 3 | |
---|
| 4 | ; |
---|
| 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. |
---|
| 7 | ; |
---|
| 8 | ; This program is free software; you can redistribute it and/or modify |
---|
| 9 | ; it under the terms of the GNU General Public License as published by |
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ; (at your option) any later version. |
---|
| 12 | ; |
---|
| 13 | ; This program is distributed in the hope that it will be useful, |
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | ; GNU General Public License for more details. |
---|
| 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 18 | ; |
---|
| 19 | |
---|
| 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
| 23 | ;-------------------------------------------------------------------- |
---|
| 24 | ; GetMenuitemToDXforDriveInDL |
---|
| 25 | ; Parameters: |
---|
| 26 | ; DL: Drive number |
---|
| 27 | ; Returns: |
---|
| 28 | ; DX: Menuitem index (assuming drive is available) |
---|
| 29 | ; Corrupts registers: |
---|
| 30 | ; AX |
---|
| 31 | ;-------------------------------------------------------------------- |
---|
| 32 | GetMenuitemToDXforDriveInDL: |
---|
| 33 | xor dh, dh ; Drive number now in DX |
---|
| 34 | test dl, dl |
---|
| 35 | jns SHORT .ReturnItemIndexInDX ; Return if floppy drive (HD bit not set) |
---|
| 36 | call FloppyDrive_GetCountToAX |
---|
| 37 | and dl, ~80h ; Clear HD bit |
---|
| 38 | add dx, ax |
---|
| 39 | .ReturnItemIndexInDX: |
---|
| 40 | ret |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | ;-------------------------------------------------------------------- |
---|
| 44 | ; BootMenuEvent_Handler |
---|
| 45 | ; Common parameters for all events: |
---|
| 46 | ; BX: Menu event (anything from MENUEVENT struct) |
---|
| 47 | ; SS:BP: Menu library handle |
---|
| 48 | ; Common return values for all events: |
---|
| 49 | ; CF: Set if event processed |
---|
| 50 | ; Cleared if event not processed |
---|
| 51 | ; Corrupts registers: |
---|
| 52 | ; All |
---|
| 53 | ;-------------------------------------------------------------------- |
---|
| 54 | BootMenuEvent_Handler: |
---|
| 55 | LOAD_BDA_SEGMENT_TO es, di |
---|
| 56 | call RamVars_GetSegmentToDS |
---|
| 57 | |
---|
| 58 | %ifdef MENUEVENT_INLINE_OFFSETS |
---|
| 59 | |
---|
| 60 | add bx, FirstEvent |
---|
| 61 | jmp bx |
---|
| 62 | |
---|
[489] | 63 | .EventNotHandled: |
---|
| 64 | .DoNotSetDefaultMenuitem: |
---|
[392] | 65 | xor dx, dx ; Clear CF (and menuitem index for DoNotSetDefaultMenuitem) |
---|
| 66 | ret |
---|
| 67 | |
---|
| 68 | MENUEVENT_InitializeMenuinitFromDSSI equ (EventInitializeMenuinitFromSSBP - FirstEvent) |
---|
| 69 | MENUEVENT_ExitMenu equ (BootMenuEvent_Completed - FirstEvent) |
---|
| 70 | MENUEVENT_ItemHighlightedFromCX equ (EventItemHighlightedFromCX - FirstEvent) |
---|
| 71 | MENUEVENT_ItemSelectedFromCX equ (EventItemSelectedFromCX - FirstEvent) |
---|
| 72 | MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - FirstEvent) |
---|
| 73 | MENUEVENT_RefreshInformation equ (BootMenuPrint_RefreshInformation - FirstEvent) |
---|
| 74 | MENUEVENT_RefreshItemFromCX equ (BootMenuPrint_RefreshItem - FirstEvent) |
---|
| 75 | ; |
---|
| 76 | ; Note that there is no entry for MENUEVENT_IdleProcessing. If MENUEVENT_IDLEPROCESSING_ENABLE is not %defined, |
---|
| 77 | ; then the entry point will not be called (saving memory on this end and at the CALL point). |
---|
| 78 | ; |
---|
| 79 | |
---|
| 80 | %else |
---|
| 81 | |
---|
| 82 | cmp bx, BYTE MENUEVENT.RefreshItemFromCX ; Above last supported item? |
---|
[489] | 83 | ja SHORT .EventNotHandled |
---|
[392] | 84 | jmp [cs:bx+rgfnEventSpecificHandlers] |
---|
| 85 | |
---|
[489] | 86 | .EventNotHandled: |
---|
| 87 | .DoNotSetDefaultMenuitem: |
---|
[392] | 88 | xor dx, dx ; Clear CF (and menuitem index for DoNotSetDefaultMenuitem) |
---|
| 89 | ret |
---|
| 90 | |
---|
| 91 | rgfnEventSpecificHandlers: |
---|
| 92 | dw EventInitializeMenuinitFromSSBP ; MENUEVENT.InitializeMenuinitFromDSSI |
---|
| 93 | dw EventCompleted ; MENUEVENT.ExitMenu |
---|
| 94 | dw EventNotHandled ; MENUEVENT.IdleProcessing |
---|
| 95 | dw EventItemHighlightedFromCX ; MENUEVENT.ItemHighlightedFromCX |
---|
| 96 | dw EventItemSelectedFromCX ; MENUEVENT.ItemSelectedFromCX |
---|
| 97 | dw EventKeyStrokeInAX ; MENUEVENT.KeyStrokeInAX |
---|
| 98 | dw BootMenuPrint_TitleStrings ; MENUEVENT.RefreshTitle |
---|
| 99 | dw BootMenuPrint_RefreshInformation ; MENUEVENT.RefreshInformation |
---|
| 100 | dw BootMenuPrint_RefreshItem ; MENUEVENT.RefreshItemFromCX |
---|
| 101 | |
---|
| 102 | %endif |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | ;-------------------------------------------------------------------- |
---|
| 106 | ; EventInitializeMenuinitFromSSBP |
---|
| 107 | ; Parameters |
---|
| 108 | ; DS: Ptr to RAMVARS |
---|
| 109 | ; ES: Ptr to BDA (zero) |
---|
| 110 | ; SS:BP: Ptr to MENUINIT struct to initialize |
---|
| 111 | ; Returns: |
---|
| 112 | ; CF: Set if event processed |
---|
| 113 | ; Cleared if event not processed |
---|
| 114 | ; Corrupts registers: |
---|
| 115 | ; Does not matter |
---|
| 116 | ;-------------------------------------------------------------------- |
---|
| 117 | FirstEvent: |
---|
| 118 | EventInitializeMenuinitFromSSBP: |
---|
| 119 | ; Store default Menuitem (=default drive to boot from) |
---|
[492] | 120 | xor dx, dx |
---|
[392] | 121 | mov [bp+MENUINIT.wHighlightedItem], dx |
---|
| 122 | |
---|
| 123 | ; Store number of Menuitems |
---|
| 124 | call RamVars_GetHardDiskCountFromBDAtoAX |
---|
| 125 | xchg ax, cx |
---|
| 126 | call FloppyDrive_GetCountToAX |
---|
| 127 | add ax, cx |
---|
[492] | 128 | inc ax ; extra entry for ROM Boot item |
---|
[392] | 129 | mov [bp+MENUINIT.wItems], ax |
---|
[492] | 130 | |
---|
[392] | 131 | ; Store menu size |
---|
| 132 | mov WORD [bp+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES |
---|
| 133 | mov BYTE [bp+MENUINIT.bWidth], BOOT_MENU_WIDTH |
---|
| 134 | add al, BOOT_MENU_HEIGHT_WITHOUT_ITEMS |
---|
| 135 | xchg cx, ax |
---|
| 136 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH |
---|
| 137 | MIN_U ah, cl |
---|
| 138 | mov [bp+MENUINIT.bHeight], ah |
---|
| 139 | |
---|
| 140 | ; Store selection timeout |
---|
| 141 | mov ax, [cs:ROMVARS.wBootTimeout] |
---|
| 142 | CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX |
---|
| 143 | stc |
---|
| 144 | ret |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | ;-------------------------------------------------------------------- |
---|
| 148 | ; EventItemHighlightedFromCX |
---|
| 149 | ; Parameters |
---|
| 150 | ; CX: Index of new highlighted item |
---|
| 151 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED |
---|
| 152 | ; DS: Ptr to RAMVARS |
---|
| 153 | ; ES: Ptr to BDA (zero) |
---|
| 154 | ; SS:BP: Menu library handle |
---|
| 155 | ; Returns: |
---|
| 156 | ; CF: Set if event processed |
---|
| 157 | ; Cleared if event not processed |
---|
| 158 | ; Corrupts registers: |
---|
| 159 | ; Does not matter |
---|
| 160 | ;-------------------------------------------------------------------- |
---|
| 161 | EventItemHighlightedFromCX: |
---|
| 162 | push cx |
---|
[492] | 163 | call DriveXlate_Reset |
---|
[392] | 164 | call BootMenu_GetDriveToDXforMenuitemInCX |
---|
[492] | 165 | jnc .noDriveSwap |
---|
[392] | 166 | call DriveXlate_SetDriveToSwap |
---|
[492] | 167 | .noDriveSwap: |
---|
| 168 | |
---|
[392] | 169 | ; Redraw changes in drive numbers |
---|
| 170 | xor ax, ax ; Update first floppy drive (for translated drive number) |
---|
| 171 | CALL_MENU_LIBRARY RefreshItemFromAX |
---|
| 172 | mov dl, 80h |
---|
| 173 | call GetMenuitemToDXforDriveInDL |
---|
| 174 | xchg ax, dx ; Update first hard disk (for translated drive number) |
---|
| 175 | CALL_MENU_LIBRARY RefreshItemFromAX |
---|
| 176 | pop ax ; Update new item (for translated drive number) |
---|
| 177 | CALL_MENU_LIBRARY RefreshItemFromAX |
---|
| 178 | CALL_MENU_LIBRARY RefreshInformation |
---|
| 179 | stc |
---|
| 180 | ret |
---|
| 181 | |
---|
[492] | 182 | |
---|
[392] | 183 | ;-------------------------------------------------------------------- |
---|
[395] | 184 | ; EventItemSelectedFromCX |
---|
[392] | 185 | ; Parameters |
---|
[395] | 186 | ; CX: Index of selected item |
---|
[392] | 187 | ; DS: Ptr to RAMVARS |
---|
| 188 | ; ES: Ptr to BDA (zero) |
---|
| 189 | ; SS:BP: Menu library handle |
---|
| 190 | ; Returns: |
---|
| 191 | ; CF: Set if event processed |
---|
| 192 | ; Cleared if event not processed |
---|
| 193 | ; Corrupts registers: |
---|
| 194 | ; Does not matter |
---|
| 195 | ;-------------------------------------------------------------------- |
---|
[395] | 196 | EventItemSelectedFromCX: |
---|
[392] | 197 | ; Fall to CloseBootMenu |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | ;-------------------------------------------------------------------- |
---|
| 201 | ; CloseBootMenu |
---|
| 202 | ; Parameters |
---|
| 203 | ; DS: RAMVARS segment |
---|
| 204 | ; ES: BDA segment (zero) |
---|
| 205 | ; Returns: |
---|
| 206 | ; Nothing |
---|
| 207 | ; Corrupts registers: |
---|
| 208 | ; Does not matter |
---|
| 209 | ;-------------------------------------------------------------------- |
---|
| 210 | CloseBootMenu: |
---|
| 211 | call DriveXlate_Reset |
---|
| 212 | CALL_MENU_LIBRARY Close |
---|
| 213 | ; Fall to BootMenuEvent_Completed |
---|
| 214 | |
---|
[492] | 215 | |
---|
[392] | 216 | ;-------------------------------------------------------------------- |
---|
| 217 | ; BootMenuEvent_Completed |
---|
| 218 | ; Parameters |
---|
| 219 | ; Nothing |
---|
| 220 | ; Returns: |
---|
| 221 | ; CF: Set to exit from menu |
---|
| 222 | ; Corrupts registers: |
---|
| 223 | ; Nothing |
---|
| 224 | ;-------------------------------------------------------------------- |
---|
| 225 | BootMenuEvent_Completed: |
---|
| 226 | stc |
---|
| 227 | ret |
---|