[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:
|
---|
[127] | 26 | cmp bx, BYTE MENUEVENT.RefreshItemFromCX ; Above last supported item?
|
---|
[88] | 27 | ja SHORT .EventNotHandled
|
---|
[127] | 28 | jmp [cs:bx+.rgfnEventSpecificHandlers]
|
---|
[88] | 29 | .EventNotHandled:
|
---|
| 30 | clc
|
---|
| 31 | ret
|
---|
[3] | 32 |
|
---|
| 33 | ALIGN WORD_ALIGN
|
---|
[88] | 34 | .rgfnEventSpecificHandlers:
|
---|
[124] | 35 | dw .InitializeMenuinitFromDSSI ; MENUEVENT.InitializeMenuinitFromDSSI
|
---|
| 36 | dw .EventCompleted ; MENUEVENT.ExitMenu
|
---|
| 37 | dw .EventNotHandled ; MENUEVENT.IdleProcessing
|
---|
| 38 | dw .ItemHighlightedFromCX ; MENUEVENT.ItemHighlightedFromCX
|
---|
| 39 | dw .ItemSelectedFromCX ; MENUEVENT.ItemSelectedFromCX
|
---|
| 40 | dw .KeyStrokeInAX ; MENUEVENT.KeyStrokeInAX
|
---|
| 41 | dw BootMenuPrint_TitleStrings ; MENUEVENT.RefreshTitle
|
---|
| 42 | dw .RefreshInformation ; MENUEVENT.RefreshInformation
|
---|
| 43 | dw .RefreshItemFromCX ; MENUEVENT.RefreshItemFromCX
|
---|
[3] | 44 |
|
---|
| 45 |
|
---|
[88] | 46 | ; Parameters:
|
---|
| 47 | ; DS:SI: Ptr to MENUINIT struct to initialize
|
---|
| 48 | ; Returns:
|
---|
| 49 | ; DS:SI: Ptr to initialized MENUINIT struct
|
---|
[3] | 50 | ALIGN JUMP_ALIGN
|
---|
[88] | 51 | .InitializeMenuinitFromDSSI:
|
---|
| 52 | push ds
|
---|
| 53 | call RamVars_GetSegmentToDS
|
---|
| 54 | call .GetDefaultMenuitemToDX
|
---|
[124] | 55 | call BootMenu_GetMenuitemCountToAX
|
---|
[88] | 56 | pop ds
|
---|
[124] | 57 | mov [si+MENUINIT.wItems], ax
|
---|
[88] | 58 | mov [si+MENUINIT.wHighlightedItem], dx
|
---|
| 59 | mov WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES
|
---|
| 60 | mov BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH
|
---|
[124] | 61 | call BootMenu_GetHeightToAHwithItemCountInAL
|
---|
[88] | 62 | mov [si+MENUINIT.bHeight], ah
|
---|
[135] | 63 | mov al, TICKS_PER_SECOND
|
---|
| 64 | mul BYTE [cs:ROMVARS.bBootDelay]
|
---|
| 65 | CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX
|
---|
[88] | 66 | stc
|
---|
[3] | 67 | ret
|
---|
| 68 |
|
---|
[88] | 69 | ALIGN JUMP_ALIGN
|
---|
| 70 | .GetDefaultMenuitemToDX:
|
---|
| 71 | mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive
|
---|
| 72 | call BootMenu_IsDriveInSystem
|
---|
| 73 | jnc SHORT .DoNotSetDefaultMenuitem
|
---|
| 74 | call DriveXlate_SetDriveToSwap
|
---|
[124] | 75 | jmp BootMenu_GetMenuitemToDXforDriveInDL
|
---|
[88] | 76 | ALIGN JUMP_ALIGN
|
---|
| 77 | .DoNotSetDefaultMenuitem:
|
---|
| 78 | xor dx, dx ; Whatever appears first on boot menu
|
---|
| 79 | ret
|
---|
[3] | 80 |
|
---|
[88] | 81 |
|
---|
| 82 | ; Parameters:
|
---|
| 83 | ; CX: Index of new highlighted item
|
---|
| 84 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
|
---|
[3] | 85 | ALIGN JUMP_ALIGN
|
---|
[88] | 86 | .ItemHighlightedFromCX:
|
---|
| 87 | push cx
|
---|
| 88 | push dx
|
---|
[3] | 89 | call RamVars_GetSegmentToDS
|
---|
| 90 | call DriveXlate_Reset
|
---|
[130] | 91 | call BootMenu_GetDriveToDXforMenuitemInCX
|
---|
[3] | 92 | call DriveXlate_SetDriveToSwap
|
---|
[88] | 93 | pop ax ; Update previous item
|
---|
| 94 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
| 95 | pop ax ; Update new item
|
---|
| 96 | CALL_MENU_LIBRARY RefreshItemFromAX
|
---|
| 97 | CALL_MENU_LIBRARY RefreshInformation
|
---|
| 98 | stc
|
---|
[3] | 99 | ret
|
---|
| 100 |
|
---|
| 101 |
|
---|
[88] | 102 | ; Parameters:
|
---|
| 103 | ; AL: ASCII character for the key
|
---|
| 104 | ; AH: Keyboard library scan code for the key
|
---|
[3] | 105 | ALIGN JUMP_ALIGN
|
---|
[88] | 106 | .KeyStrokeInAX:
|
---|
[92] | 107 | cmp ah, ROM_BOOT_HOTKEY_SCANCODE
|
---|
| 108 | jne SHORT .CheckDriveHotkeys
|
---|
[95] | 109 | jmp Int19hMenu_RomBoot
|
---|
[92] | 110 | ALIGN JUMP_ALIGN
|
---|
| 111 | .CheckDriveHotkeys:
|
---|
[130] | 112 | call BootMenu_GetMenuitemToAXforAsciiHotkeyInAL
|
---|
| 113 | cmp ax, [bp+MENUINIT.wItems]
|
---|
[92] | 114 | jae SHORT .EventCompleted ; Invalid key
|
---|
[88] | 115 | CALL_MENU_LIBRARY HighlightItemFromAX
|
---|
| 116 | ; Fall to .ItemSelectedFromCX
|
---|
[3] | 117 |
|
---|
| 118 |
|
---|
[88] | 119 | ; Parameters:
|
---|
| 120 | ; CX: Index of selected item
|
---|
[3] | 121 | ALIGN JUMP_ALIGN
|
---|
[88] | 122 | .ItemSelectedFromCX:
|
---|
| 123 | CALL_MENU_LIBRARY Close
|
---|
| 124 | .EventCompleted:
|
---|
| 125 | stc
|
---|
[3] | 126 | ret
|
---|
| 127 |
|
---|
| 128 |
|
---|
[88] | 129 | ; Parameters:
|
---|
| 130 | ; CX: Index of item to refresh
|
---|
| 131 | ; Cursor has been positioned to the beginning of item line
|
---|
[3] | 132 | ALIGN JUMP_ALIGN
|
---|
[88] | 133 | .RefreshItemFromCX:
|
---|
| 134 | mov bx, .rgwItemTypeRefresh
|
---|
| 135 | jmp SHORT .RefreshItemOrInformationWithJumpTableInCSBX
|
---|
[3] | 136 |
|
---|
[88] | 137 |
|
---|
| 138 | ; Parameters:
|
---|
| 139 | ; CX: Index of highlighted item
|
---|
| 140 | ; Cursor has been positioned to the beginning of first line
|
---|
[3] | 141 | ALIGN JUMP_ALIGN
|
---|
[88] | 142 | .RefreshInformation:
|
---|
| 143 | mov bx, .rgwInformationItemTypeRefresh
|
---|
| 144 | ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX
|
---|
[3] | 145 |
|
---|
| 146 | ;--------------------------------------------------------------------
|
---|
[88] | 147 | ; RefreshItemOrInformationWithJumpTableInCSBX
|
---|
[3] | 148 | ; Parameters:
|
---|
| 149 | ; CX: Index of selected menuitem
|
---|
[88] | 150 | ; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table
|
---|
[3] | 151 | ; Returns:
|
---|
[88] | 152 | ; CF: set since event processed
|
---|
[3] | 153 | ;--------------------------------------------------------------------
|
---|
[88] | 154 | .RefreshItemOrInformationWithJumpTableInCSBX:
|
---|
| 155 | cmp cl, NO_ITEM_HIGHLIGHTED
|
---|
| 156 | je SHORT .EventCompleted
|
---|
| 157 |
|
---|
[3] | 158 | call RamVars_GetSegmentToDS
|
---|
[130] | 159 | call BootMenu_GetDriveToDXforMenuitemInCX
|
---|
[128] | 160 | test dl, dl ; Floppy drive?
|
---|
| 161 | jns SHORT .DrawFloppyDrive
|
---|
[88] | 162 | jmp [cs:bx+ITEM_TYPE_REFRESH.HardDisk]
|
---|
[3] | 163 | ALIGN JUMP_ALIGN
|
---|
[88] | 164 | .DrawFloppyDrive:
|
---|
| 165 | jmp [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive]
|
---|
[3] | 166 |
|
---|
[88] | 167 | ; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX
|
---|
| 168 | ALIGN WORD_ALIGN
|
---|
| 169 | .rgwItemTypeRefresh:
|
---|
| 170 | istruc ITEM_TYPE_REFRESH
|
---|
| 171 | at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitem
|
---|
| 172 | at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitem
|
---|
| 173 | iend
|
---|
| 174 | .rgwInformationItemTypeRefresh:
|
---|
| 175 | istruc ITEM_TYPE_REFRESH
|
---|
| 176 | at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitemInformation
|
---|
| 177 | at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitemInformation
|
---|
| 178 | iend
|
---|