[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 |
|
---|
| 7 | ;--------------------------------------------------------------------
|
---|
| 8 | ; BootMenuEvent_Handler
|
---|
[88] | 9 | ; Common parameters for all events:
|
---|
| 10 | ; BX: Menu event (anything from MENUEVENT struct)
|
---|
| 11 | ; SS:BP: Menu library handle
|
---|
| 12 | ; Common return values for all events:
|
---|
| 13 | ; CF: Set if event processed
|
---|
| 14 | ; Cleared if event not processed
|
---|
[3] | 15 | ; Corrupts registers:
|
---|
[88] | 16 | ; All
|
---|
[3] | 17 | ;--------------------------------------------------------------------
|
---|
| 18 | ALIGN JUMP_ALIGN
|
---|
| 19 | BootMenuEvent_Handler:
|
---|
[202] | 20 |
|
---|
[183] | 21 | %ifdef MENUEVENT_INLINE_OFFSETS
|
---|
[202] | 22 |
|
---|
[183] | 23 | add bx, BootMenuEvent_Handler
|
---|
| 24 | jmp bx
|
---|
[3] | 25 |
|
---|
[183] | 26 | MENUEVENT_InitializeMenuinitFromDSSI equ (BootMenuEvent_Handler.InitializeMenuinitFromDSSI - BootMenuEvent_Handler)
|
---|
| 27 | MENUEVENT_ExitMenu equ (BootMenuEvent_Handler.EventCompleted - BootMenuEvent_Handler)
|
---|
| 28 | MENUEVENT_ItemHighlightedFromCX equ (BootMenuEvent_Handler.ItemHighlightedFromCX - BootMenuEvent_Handler)
|
---|
| 29 | MENUEVENT_ItemSelectedFromCX equ (BootMenuEvent_Handler.ItemSelectedFromCX - BootMenuEvent_Handler)
|
---|
| 30 | MENUEVENT_KeyStrokeInAX equ (BootMenuEvent_Handler.KeyStrokeInAX - BootMenuEvent_Handler)
|
---|
| 31 | MENUEVENT_RefreshTitle equ (BootMenuPrint_TitleStrings - BootMenuEvent_Handler)
|
---|
| 32 | MENUEVENT_RefreshInformation equ (BootMenuEvent_Handler.RefreshInformation - BootMenuEvent_Handler)
|
---|
| 33 | MENUEVENT_RefreshItemFromCX equ (BootMenuEvent_Handler.RefreshItemFromCX - BootMenuEvent_Handler)
|
---|
[202] | 34 | ;
|
---|
| 35 | ; Note that there is no entry for MENUEVENT_IdleProcessing. If MENUEVENT_IDLEPROCESSING_ENABLE is not %defined,
|
---|
[189] | 36 | ; then the entry point will not be called (saving memory on this end and at the CALL point).
|
---|
| 37 | ;
|
---|
[202] | 38 |
|
---|
[183] | 39 | %else
|
---|
[202] | 40 |
|
---|
[189] | 41 | cmp bx, BYTE MENUEVENT.RefreshItemFromCX ; Above last supported item?
|
---|
| 42 | ja SHORT .EventNotHandled
|
---|
| 43 | jmp [cs:bx+.rgfnEventSpecificHandlers]
|
---|
| 44 |
|
---|
| 45 | .EventNotHandled:
|
---|
| 46 | clc
|
---|
| 47 | ret
|
---|
[202] | 48 |
|
---|
[3] | 49 | ALIGN WORD_ALIGN
|
---|
[88] | 50 | .rgfnEventSpecificHandlers:
|
---|
[124] | 51 | dw .InitializeMenuinitFromDSSI ; MENUEVENT.InitializeMenuinitFromDSSI
|
---|
| 52 | dw .EventCompleted ; MENUEVENT.ExitMenu
|
---|
| 53 | dw .EventNotHandled ; MENUEVENT.IdleProcessing
|
---|
| 54 | dw .ItemHighlightedFromCX ; MENUEVENT.ItemHighlightedFromCX
|
---|
| 55 | dw .ItemSelectedFromCX ; MENUEVENT.ItemSelectedFromCX
|
---|
| 56 | dw .KeyStrokeInAX ; MENUEVENT.KeyStrokeInAX
|
---|
| 57 | dw BootMenuPrint_TitleStrings ; MENUEVENT.RefreshTitle
|
---|
| 58 | dw .RefreshInformation ; MENUEVENT.RefreshInformation
|
---|
| 59 | dw .RefreshItemFromCX ; MENUEVENT.RefreshItemFromCX
|
---|
[202] | 60 |
|
---|
[183] | 61 | %endif
|
---|
[3] | 62 |
|
---|
| 63 |
|
---|
[88] | 64 | ; Parameters:
|
---|
| 65 | ; DS:SI: Ptr to MENUINIT struct to initialize
|
---|
| 66 | ; Returns:
|
---|
| 67 | ; DS:SI: Ptr to initialized MENUINIT struct
|
---|
[3] | 68 | ALIGN JUMP_ALIGN
|
---|
[88] | 69 | .InitializeMenuinitFromDSSI:
|
---|
| 70 | push ds
|
---|
| 71 | call RamVars_GetSegmentToDS
|
---|
| 72 | call .GetDefaultMenuitemToDX
|
---|
[124] | 73 | call BootMenu_GetMenuitemCountToAX
|
---|
[88] | 74 | pop ds
|
---|
[124] | 75 | mov [si+MENUINIT.wItems], ax
|
---|
[88] | 76 | mov [si+MENUINIT.wHighlightedItem], dx
|
---|
| 77 | mov WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
|
---|
| 78 | mov BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH
|
---|
[124] | 79 | call BootMenu_GetHeightToAHwithItemCountInAL
|
---|
[88] | 80 | mov [si+MENUINIT.bHeight], ah
|
---|
[137] | 81 | mov ax, [cs:ROMVARS.wBootTimeout]
|
---|
[135] | 82 | CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
|
---|
[88] | 83 | stc
|
---|
[3] | 84 | ret
|
---|
| 85 |
|
---|
[88] | 86 | ALIGN JUMP_ALIGN
|
---|
| 87 | .GetDefaultMenuitemToDX:
|
---|
| 88 | mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive
|
---|
| 89 | call BootMenu_IsDriveInSystem
|
---|
| 90 | jnc SHORT .DoNotSetDefaultMenuitem
|
---|
| 91 | call DriveXlate_SetDriveToSwap
|
---|
[124] | 92 | jmp BootMenu_GetMenuitemToDXforDriveInDL
|
---|
[88] | 93 | ALIGN JUMP_ALIGN
|
---|
| 94 | .DoNotSetDefaultMenuitem:
|
---|
| 95 | xor dx, dx ; Whatever appears first on boot menu
|
---|
| 96 | ret
|
---|
[3] | 97 |
|
---|
[88] | 98 |
|
---|
| 99 | ; Parameters:
|
---|
| 100 | ; CX: Index of new highlighted item
|
---|
| 101 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
|
---|
[3] | 102 | ALIGN JUMP_ALIGN
|
---|
[88] | 103 | .ItemHighlightedFromCX:
|
---|
| 104 | push cx
|
---|
[3] | 105 | call RamVars_GetSegmentToDS
|
---|
| 106 | call DriveXlate_Reset
|
---|
[130] | 107 | call BootMenu_GetDriveToDXforMenuitemInCX
|
---|
[3] | 108 | call DriveXlate_SetDriveToSwap
|
---|
[140] | 109 |
|
---|
| 110 | xor ax, ax ; Update first floppy drive (for translated drive number)
|
---|
[88] | 111 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
[140] | 112 | mov dl, 80h
|
---|
| 113 | call BootMenu_GetMenuitemToDXforDriveInDL
|
---|
| 114 | xchg ax, dx ; Update first hard disk (for translated drive number)
|
---|
[88] | 115 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
[140] | 116 | pop ax ; Update new item (for translated drive number)
|
---|
| 117 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
[88] | 118 | CALL_MENU_LIBRARY RefreshInformation
|
---|
| 119 | stc
|
---|
[3] | 120 | ret
|
---|
| 121 |
|
---|
| 122 |
|
---|
[88] | 123 | ; Parameters:
|
---|
| 124 | ; AL: ASCII character for the key
|
---|
| 125 | ; AH: Keyboard library scan code for the key
|
---|
[3] | 126 | ALIGN JUMP_ALIGN
|
---|
[88] | 127 | .KeyStrokeInAX:
|
---|
[92] | 128 | cmp ah, ROM_BOOT_HOTKEY_SCANCODE
|
---|
| 129 | jne SHORT .CheckDriveHotkeys
|
---|
[212] | 130 | ;; NOTE: carry flag will be clear after compare above that resulted in zero
|
---|
| 131 | jmp Int19hMenu_JumpToBootSector_or_RomBoot
|
---|
[92] | 132 | ALIGN JUMP_ALIGN
|
---|
| 133 | .CheckDriveHotkeys:
|
---|
[130] | 134 | call BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
|
---|
| 135 | cmp ax, [bp+MENUINIT.wItems]
|
---|
[92] | 136 | jae SHORT .EventCompleted ; Invalid key
|
---|
[88] | 137 | CALL_MENU_LIBRARY HighlightItemFromAX
|
---|
| 138 | ; Fall to .ItemSelectedFromCX
|
---|
[3] | 139 |
|
---|
| 140 |
|
---|
[88] | 141 | ; Parameters:
|
---|
| 142 | ; CX: Index of selected item
|
---|
[3] | 143 | ALIGN JUMP_ALIGN
|
---|
[88] | 144 | .ItemSelectedFromCX:
|
---|
| 145 | CALL_MENU_LIBRARY Close
|
---|
| 146 | .EventCompleted:
|
---|
| 147 | stc
|
---|
[3] | 148 | ret
|
---|
| 149 |
|
---|
| 150 |
|
---|
[88] | 151 | ; Parameters:
|
---|
| 152 | ; CX: Index of item to refresh
|
---|
| 153 | ; Cursor has been positioned to the beginning of item line
|
---|
[3] | 154 | ALIGN JUMP_ALIGN
|
---|
[88] | 155 | .RefreshItemFromCX:
|
---|
[202] | 156 | xor bl, bl ; will result in SF being clear in .RefreshItemOrInformation...
|
---|
[190] | 157 | SKIP2B dx ; dx corrupted below by BootMenu_GetDriveToDXforMenuitemInCX
|
---|
[189] | 158 | ; Fall to .RefreshInformation
|
---|
[202] | 159 |
|
---|
[88] | 160 | ; Parameters:
|
---|
| 161 | ; CX: Index of highlighted item
|
---|
| 162 | ; Cursor has been positioned to the beginning of first line
|
---|
[190] | 163 | ; NO ALIGN - in the shadow of SKIP2B
|
---|
[88] | 164 | .RefreshInformation:
|
---|
[190] | 165 | mov bl,040h ; will result in SF being set in .RefreshItemOrInformation...
|
---|
[88] | 166 | ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
|
---|
[3] | 167 |
|
---|
| 168 | ;--------------------------------------------------------------------
|
---|
[88] | 169 | ; RefreshItemOrInformationWithJumpTableInCSBX
|
---|
[3] | 170 | ; Parameters:
|
---|
| 171 | ; CX: Index of selected menuitem
|
---|
[88] | 172 | ; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table
|
---|
[3] | 173 | ; Returns:
|
---|
[88] | 174 | ; CF: set since event processed
|
---|
[3] | 175 | ;--------------------------------------------------------------------
|
---|
[88] | 176 | .RefreshItemOrInformationWithJumpTableInCSBX:
|
---|
| 177 | cmp cl, NO_ITEM_HIGHLIGHTED
|
---|
| 178 | je SHORT .EventCompleted
|
---|
| 179 |
|
---|
[3] | 180 | call RamVars_GetSegmentToDS
|
---|
[130] | 181 | call BootMenu_GetDriveToDXforMenuitemInCX
|
---|
[190] | 182 | or bl,dl ; or drive number with bit from .RefreshItemFromCX or .RefreshInformation
|
---|
| 183 | shl bl,1 ; drive letter high order bit to CF, Item/Information bit to SF
|
---|
[189] | 184 | jc SHORT BootMenuPrint_HardDiskMenuitem
|
---|
[194] | 185 | ; fall through to BootMenuEvent_FallThroughToFloppyMenuitem
|
---|
[202] | 186 |
|
---|
| 187 | ;;;
|
---|
[189] | 188 | ;;; Fall-through (to BootMenuPrint_FloppyMenuitem)
|
---|
| 189 | ;;; (checked at assembler time with the code after BootMenuPrint_FloppyMenuitem)
|
---|
| 190 | ;;;
|
---|
[3] | 191 | ALIGN JUMP_ALIGN
|
---|
[202] | 192 | BootMenuEvent_FallThroughToFloppyMenuitem:
|
---|
[194] | 193 | ; fall through to BootMenuPrint_FloppyMenuitem
|
---|