[88] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Boot Menu event handler for menu library callbacks. |
---|
| 3 | |
---|
| 4 | ; Section containing code |
---|
| 5 | SECTION .text |
---|
| 6 | |
---|
[88] | 7 | struc ITEM_TYPE_REFRESH |
---|
| 8 | .HardDisk resb 2 |
---|
| 9 | .FloppyDrive resb 2 |
---|
| 10 | endstruc |
---|
| 11 | |
---|
| 12 | |
---|
[3] | 13 | ;-------------------------------------------------------------------- |
---|
| 14 | ; BootMenuEvent_Handler |
---|
[88] | 15 | ; Common parameters for all events: |
---|
| 16 | ; BX: Menu event (anything from MENUEVENT struct) |
---|
| 17 | ; SS:BP: Menu library handle |
---|
| 18 | ; Common return values for all events: |
---|
| 19 | ; CF: Set if event processed |
---|
| 20 | ; Cleared if event not processed |
---|
[3] | 21 | ; Corrupts registers: |
---|
[88] | 22 | ; All |
---|
[3] | 23 | ;-------------------------------------------------------------------- |
---|
| 24 | ALIGN JUMP_ALIGN |
---|
| 25 | BootMenuEvent_Handler: |
---|
[183] | 26 | |
---|
| 27 | %ifdef MENUEVENT_INLINE_OFFSETS |
---|
| 28 | |
---|
| 29 | add bx, BootMenuEvent_Handler |
---|
| 30 | jmp bx |
---|
| 31 | |
---|
| 32 | %else |
---|
| 33 | |
---|
[127] | 34 | cmp bx, BYTE MENUEVENT.RefreshItemFromCX ; Above last supported item? |
---|
[88] | 35 | ja SHORT .EventNotHandled |
---|
[127] | 36 | jmp [cs:bx+.rgfnEventSpecificHandlers] |
---|
[183] | 37 | |
---|
| 38 | %endif |
---|
| 39 | |
---|
[88] | 40 | .EventNotHandled: |
---|
| 41 | clc |
---|
| 42 | ret |
---|
[3] | 43 | |
---|
[183] | 44 | %ifdef MENUEVENT_INLINE_OFFSETS |
---|
| 45 | |
---|
| 46 | MENUEVENT_InitializeMenuinitFromDSSI equ (BootMenuEvent_Handler.InitializeMenuinitFromDSSI - BootMenuEvent_Handler) |
---|
| 47 | MENUEVENT_ExitMenu equ (BootMenuEvent_Handler.EventCompleted - BootMenuEvent_Handler) |
---|
| 48 | MENUEVENT_IdleProcessing equ (BootMenuEvent_Handler.EventNotHandled - BootMenuEvent_Handler) |
---|
| 49 | MENUEVENT_ItemHighlightedFromCX equ (BootMenuEvent_Handler.ItemHighlightedFromCX - BootMenuEvent_Handler) |
---|
| 50 | MENUEVENT_ItemSelectedFromCX equ (BootMenuEvent_Handler.ItemSelectedFromCX - BootMenuEvent_Handler) |
---|
| 51 | MENUEVENT_KeyStrokeInAX equ (BootMenuEvent_Handler.KeyStrokeInAX - BootMenuEvent_Handler) |
---|
| 52 | MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - BootMenuEvent_Handler) |
---|
| 53 | MENUEVENT_RefreshInformation equ (BootMenuEvent_Handler.RefreshInformation - BootMenuEvent_Handler) |
---|
| 54 | MENUEVENT_RefreshItemFromCX equ (BootMenuEvent_Handler.RefreshItemFromCX - BootMenuEvent_Handler) |
---|
| 55 | |
---|
| 56 | %else |
---|
| 57 | |
---|
[3] | 58 | ALIGN WORD_ALIGN |
---|
[88] | 59 | .rgfnEventSpecificHandlers: |
---|
[124] | 60 | dw .InitializeMenuinitFromDSSI ; MENUEVENT.InitializeMenuinitFromDSSI |
---|
| 61 | dw .EventCompleted ; MENUEVENT.ExitMenu |
---|
| 62 | dw .EventNotHandled ; MENUEVENT.IdleProcessing |
---|
| 63 | dw .ItemHighlightedFromCX ; MENUEVENT.ItemHighlightedFromCX |
---|
| 64 | dw .ItemSelectedFromCX ; MENUEVENT.ItemSelectedFromCX |
---|
| 65 | dw .KeyStrokeInAX ; MENUEVENT.KeyStrokeInAX |
---|
| 66 | dw BootMenuPrint_TitleStrings ; MENUEVENT.RefreshTitle |
---|
| 67 | dw .RefreshInformation ; MENUEVENT.RefreshInformation |
---|
| 68 | dw .RefreshItemFromCX ; MENUEVENT.RefreshItemFromCX |
---|
[183] | 69 | |
---|
| 70 | %endif |
---|
[3] | 71 | |
---|
| 72 | |
---|
[88] | 73 | ; Parameters: |
---|
| 74 | ; DS:SI: Ptr to MENUINIT struct to initialize |
---|
| 75 | ; Returns: |
---|
| 76 | ; DS:SI: Ptr to initialized MENUINIT struct |
---|
[3] | 77 | ALIGN JUMP_ALIGN |
---|
[88] | 78 | .InitializeMenuinitFromDSSI: |
---|
| 79 | push ds |
---|
| 80 | call RamVars_GetSegmentToDS |
---|
| 81 | call .GetDefaultMenuitemToDX |
---|
[124] | 82 | call BootMenu_GetMenuitemCountToAX |
---|
[88] | 83 | pop ds |
---|
[124] | 84 | mov [si+MENUINIT.wItems], ax |
---|
[88] | 85 | mov [si+MENUINIT.wHighlightedItem], dx |
---|
| 86 | mov WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES |
---|
| 87 | mov BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH |
---|
[124] | 88 | call BootMenu_GetHeightToAHwithItemCountInAL |
---|
[88] | 89 | mov [si+MENUINIT.bHeight], ah |
---|
[137] | 90 | mov ax, [cs:ROMVARS.wBootTimeout] |
---|
[135] | 91 | CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX |
---|
[88] | 92 | stc |
---|
[3] | 93 | ret |
---|
| 94 | |
---|
[88] | 95 | ALIGN JUMP_ALIGN |
---|
| 96 | .GetDefaultMenuitemToDX: |
---|
| 97 | mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive |
---|
| 98 | call BootMenu_IsDriveInSystem |
---|
| 99 | jnc SHORT .DoNotSetDefaultMenuitem |
---|
| 100 | call DriveXlate_SetDriveToSwap |
---|
[124] | 101 | jmp BootMenu_GetMenuitemToDXforDriveInDL |
---|
[88] | 102 | ALIGN JUMP_ALIGN |
---|
| 103 | .DoNotSetDefaultMenuitem: |
---|
| 104 | xor dx, dx ; Whatever appears first on boot menu |
---|
| 105 | ret |
---|
[3] | 106 | |
---|
[88] | 107 | |
---|
| 108 | ; Parameters: |
---|
| 109 | ; CX: Index of new highlighted item |
---|
| 110 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED |
---|
[3] | 111 | ALIGN JUMP_ALIGN |
---|
[88] | 112 | .ItemHighlightedFromCX: |
---|
| 113 | push cx |
---|
[3] | 114 | call RamVars_GetSegmentToDS |
---|
| 115 | call DriveXlate_Reset |
---|
[130] | 116 | call BootMenu_GetDriveToDXforMenuitemInCX |
---|
[3] | 117 | call DriveXlate_SetDriveToSwap |
---|
[140] | 118 | |
---|
| 119 | xor ax, ax ; Update first floppy drive (for translated drive number) |
---|
[88] | 120 | CALL_MENU_LIBRARY RefreshItemFromAX |
---|
[140] | 121 | mov dl, 80h |
---|
| 122 | call BootMenu_GetMenuitemToDXforDriveInDL |
---|
| 123 | xchg ax, dx ; Update first hard disk (for translated drive number) |
---|
[88] | 124 | CALL_MENU_LIBRARY RefreshItemFromAX |
---|
[140] | 125 | pop ax ; Update new item (for translated drive number) |
---|
| 126 | CALL_MENU_LIBRARY RefreshItemFromAX |
---|
[88] | 127 | CALL_MENU_LIBRARY RefreshInformation |
---|
| 128 | stc |
---|
[3] | 129 | ret |
---|
| 130 | |
---|
| 131 | |
---|
[88] | 132 | ; Parameters: |
---|
| 133 | ; AL: ASCII character for the key |
---|
| 134 | ; AH: Keyboard library scan code for the key |
---|
[3] | 135 | ALIGN JUMP_ALIGN |
---|
[88] | 136 | .KeyStrokeInAX: |
---|
[92] | 137 | cmp ah, ROM_BOOT_HOTKEY_SCANCODE |
---|
| 138 | jne SHORT .CheckDriveHotkeys |
---|
[95] | 139 | jmp Int19hMenu_RomBoot |
---|
[92] | 140 | ALIGN JUMP_ALIGN |
---|
| 141 | .CheckDriveHotkeys: |
---|
[130] | 142 | call BootMenu_GetMenuitemToAXforAsciiHotkeyInAL |
---|
| 143 | cmp ax, [bp+MENUINIT.wItems] |
---|
[92] | 144 | jae SHORT .EventCompleted ; Invalid key |
---|
[88] | 145 | CALL_MENU_LIBRARY HighlightItemFromAX |
---|
| 146 | ; Fall to .ItemSelectedFromCX |
---|
[3] | 147 | |
---|
| 148 | |
---|
[88] | 149 | ; Parameters: |
---|
| 150 | ; CX: Index of selected item |
---|
[3] | 151 | ALIGN JUMP_ALIGN |
---|
[88] | 152 | .ItemSelectedFromCX: |
---|
| 153 | CALL_MENU_LIBRARY Close |
---|
| 154 | .EventCompleted: |
---|
| 155 | stc |
---|
[3] | 156 | ret |
---|
| 157 | |
---|
| 158 | |
---|
[88] | 159 | ; Parameters: |
---|
| 160 | ; CX: Index of item to refresh |
---|
| 161 | ; Cursor has been positioned to the beginning of item line |
---|
[3] | 162 | ALIGN JUMP_ALIGN |
---|
[88] | 163 | .RefreshItemFromCX: |
---|
| 164 | mov bx, .rgwItemTypeRefresh |
---|
| 165 | jmp SHORT .RefreshItemOrInformationWithJumpTableInCSBX |
---|
[3] | 166 | |
---|
[88] | 167 | |
---|
| 168 | ; Parameters: |
---|
| 169 | ; CX: Index of highlighted item |
---|
| 170 | ; Cursor has been positioned to the beginning of first line |
---|
[3] | 171 | ALIGN JUMP_ALIGN |
---|
[88] | 172 | .RefreshInformation: |
---|
| 173 | mov bx, .rgwInformationItemTypeRefresh |
---|
| 174 | ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX |
---|
[3] | 175 | |
---|
| 176 | ;-------------------------------------------------------------------- |
---|
[88] | 177 | ; RefreshItemOrInformationWithJumpTableInCSBX |
---|
[3] | 178 | ; Parameters: |
---|
| 179 | ; CX: Index of selected menuitem |
---|
[88] | 180 | ; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table |
---|
[3] | 181 | ; Returns: |
---|
[88] | 182 | ; CF: set since event processed |
---|
[3] | 183 | ;-------------------------------------------------------------------- |
---|
[88] | 184 | .RefreshItemOrInformationWithJumpTableInCSBX: |
---|
| 185 | cmp cl, NO_ITEM_HIGHLIGHTED |
---|
| 186 | je SHORT .EventCompleted |
---|
| 187 | |
---|
[3] | 188 | call RamVars_GetSegmentToDS |
---|
[130] | 189 | call BootMenu_GetDriveToDXforMenuitemInCX |
---|
[128] | 190 | test dl, dl ; Floppy drive? |
---|
| 191 | jns SHORT .DrawFloppyDrive |
---|
[88] | 192 | jmp [cs:bx+ITEM_TYPE_REFRESH.HardDisk] |
---|
[3] | 193 | ALIGN JUMP_ALIGN |
---|
[88] | 194 | .DrawFloppyDrive: |
---|
| 195 | jmp [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive] |
---|
[3] | 196 | |
---|
[88] | 197 | ; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX |
---|
| 198 | ALIGN WORD_ALIGN |
---|
| 199 | .rgwItemTypeRefresh: |
---|
| 200 | istruc ITEM_TYPE_REFRESH |
---|
| 201 | at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitem |
---|
| 202 | at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitem |
---|
| 203 | iend |
---|
| 204 | .rgwInformationItemTypeRefresh: |
---|
| 205 | istruc ITEM_TYPE_REFRESH |
---|
| 206 | at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitemInformation |
---|
| 207 | at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitemInformation |
---|
| 208 | iend |
---|