[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 |
---|
[137] | 63 | mov ax, [cs:ROMVARS.wBootTimeout] |
---|
[135] | 64 | CALL_MENU_LIBRARY StartSelectionTimeoutWithTicksInAX |
---|
[88] | 65 | stc |
---|
[3] | 66 | ret |
---|
| 67 | |
---|
[88] | 68 | ALIGN JUMP_ALIGN |
---|
| 69 | .GetDefaultMenuitemToDX: |
---|
| 70 | mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive |
---|
| 71 | call BootMenu_IsDriveInSystem |
---|
| 72 | jnc SHORT .DoNotSetDefaultMenuitem |
---|
| 73 | call DriveXlate_SetDriveToSwap |
---|
[124] | 74 | jmp BootMenu_GetMenuitemToDXforDriveInDL |
---|
[88] | 75 | ALIGN JUMP_ALIGN |
---|
| 76 | .DoNotSetDefaultMenuitem: |
---|
| 77 | xor dx, dx ; Whatever appears first on boot menu |
---|
| 78 | ret |
---|
[3] | 79 | |
---|
[88] | 80 | |
---|
| 81 | ; Parameters: |
---|
| 82 | ; CX: Index of new highlighted item |
---|
| 83 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED |
---|
[3] | 84 | ALIGN JUMP_ALIGN |
---|
[88] | 85 | .ItemHighlightedFromCX: |
---|
| 86 | push cx |
---|
| 87 | push dx |
---|
[3] | 88 | call RamVars_GetSegmentToDS |
---|
| 89 | call DriveXlate_Reset |
---|
[130] | 90 | call BootMenu_GetDriveToDXforMenuitemInCX |
---|
[3] | 91 | call DriveXlate_SetDriveToSwap |
---|
[88] | 92 | pop ax ; Update previous item |
---|
| 93 | CALL_MENU_LIBRARY RefreshItemFromAX |
---|
| 94 | pop ax ; Update new item |
---|
| 95 | CALL_MENU_LIBRARY RefreshItemFromAX |
---|
| 96 | CALL_MENU_LIBRARY RefreshInformation |
---|
| 97 | stc |
---|
[3] | 98 | ret |
---|
| 99 | |
---|
| 100 | |
---|
[88] | 101 | ; Parameters: |
---|
| 102 | ; AL: ASCII character for the key |
---|
| 103 | ; AH: Keyboard library scan code for the key |
---|
[3] | 104 | ALIGN JUMP_ALIGN |
---|
[88] | 105 | .KeyStrokeInAX: |
---|
[92] | 106 | cmp ah, ROM_BOOT_HOTKEY_SCANCODE |
---|
| 107 | jne SHORT .CheckDriveHotkeys |
---|
[95] | 108 | jmp Int19hMenu_RomBoot |
---|
[92] | 109 | ALIGN JUMP_ALIGN |
---|
| 110 | .CheckDriveHotkeys: |
---|
[130] | 111 | call BootMenu_GetMenuitemToAXforAsciiHotkeyInAL |
---|
| 112 | cmp ax, [bp+MENUINIT.wItems] |
---|
[92] | 113 | jae SHORT .EventCompleted ; Invalid key |
---|
[88] | 114 | CALL_MENU_LIBRARY HighlightItemFromAX |
---|
| 115 | ; Fall to .ItemSelectedFromCX |
---|
[3] | 116 | |
---|
| 117 | |
---|
[88] | 118 | ; Parameters: |
---|
| 119 | ; CX: Index of selected item |
---|
[3] | 120 | ALIGN JUMP_ALIGN |
---|
[88] | 121 | .ItemSelectedFromCX: |
---|
| 122 | CALL_MENU_LIBRARY Close |
---|
| 123 | .EventCompleted: |
---|
| 124 | stc |
---|
[3] | 125 | ret |
---|
| 126 | |
---|
| 127 | |
---|
[88] | 128 | ; Parameters: |
---|
| 129 | ; CX: Index of item to refresh |
---|
| 130 | ; Cursor has been positioned to the beginning of item line |
---|
[3] | 131 | ALIGN JUMP_ALIGN |
---|
[88] | 132 | .RefreshItemFromCX: |
---|
| 133 | mov bx, .rgwItemTypeRefresh |
---|
| 134 | jmp SHORT .RefreshItemOrInformationWithJumpTableInCSBX |
---|
[3] | 135 | |
---|
[88] | 136 | |
---|
| 137 | ; Parameters: |
---|
| 138 | ; CX: Index of highlighted item |
---|
| 139 | ; Cursor has been positioned to the beginning of first line |
---|
[3] | 140 | ALIGN JUMP_ALIGN |
---|
[88] | 141 | .RefreshInformation: |
---|
| 142 | mov bx, .rgwInformationItemTypeRefresh |
---|
| 143 | ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX |
---|
[3] | 144 | |
---|
| 145 | ;-------------------------------------------------------------------- |
---|
[88] | 146 | ; RefreshItemOrInformationWithJumpTableInCSBX |
---|
[3] | 147 | ; Parameters: |
---|
| 148 | ; CX: Index of selected menuitem |
---|
[88] | 149 | ; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table |
---|
[3] | 150 | ; Returns: |
---|
[88] | 151 | ; CF: set since event processed |
---|
[3] | 152 | ;-------------------------------------------------------------------- |
---|
[88] | 153 | .RefreshItemOrInformationWithJumpTableInCSBX: |
---|
| 154 | cmp cl, NO_ITEM_HIGHLIGHTED |
---|
| 155 | je SHORT .EventCompleted |
---|
| 156 | |
---|
[3] | 157 | call RamVars_GetSegmentToDS |
---|
[130] | 158 | call BootMenu_GetDriveToDXforMenuitemInCX |
---|
[128] | 159 | test dl, dl ; Floppy drive? |
---|
| 160 | jns SHORT .DrawFloppyDrive |
---|
[88] | 161 | jmp [cs:bx+ITEM_TYPE_REFRESH.HardDisk] |
---|
[3] | 162 | ALIGN JUMP_ALIGN |
---|
[88] | 163 | .DrawFloppyDrive: |
---|
| 164 | jmp [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive] |
---|
[3] | 165 | |
---|
[88] | 166 | ; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX |
---|
| 167 | ALIGN WORD_ALIGN |
---|
| 168 | .rgwItemTypeRefresh: |
---|
| 169 | istruc ITEM_TYPE_REFRESH |
---|
| 170 | at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitem |
---|
| 171 | at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitem |
---|
| 172 | iend |
---|
| 173 | .rgwInformationItemTypeRefresh: |
---|
| 174 | istruc ITEM_TYPE_REFRESH |
---|
| 175 | at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitemInformation |
---|
| 176 | at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitemInformation |
---|
| 177 | iend |
---|