[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 | .SpecialFunction resb 2 |
---|
| 11 | endstruc |
---|
| 12 | |
---|
| 13 | |
---|
[3] | 14 | ;-------------------------------------------------------------------- |
---|
| 15 | ; BootMenuEvent_Handler |
---|
[88] | 16 | ; Common parameters for all events: |
---|
| 17 | ; BX: Menu event (anything from MENUEVENT struct) |
---|
| 18 | ; SS:BP: Menu library handle |
---|
| 19 | ; Common return values for all events: |
---|
| 20 | ; CF: Set if event processed |
---|
| 21 | ; Cleared if event not processed |
---|
[3] | 22 | ; Corrupts registers: |
---|
[88] | 23 | ; All |
---|
[3] | 24 | ;-------------------------------------------------------------------- |
---|
| 25 | ALIGN JUMP_ALIGN |
---|
| 26 | BootMenuEvent_Handler: |
---|
[88] | 27 | cmp bx, MENUEVENT.RefreshItemFromCX ; Above last supported item? |
---|
| 28 | ja SHORT .EventNotHandled |
---|
| 29 | jmp [bx+.rgfnEventSpecificHandlers] |
---|
| 30 | .EventNotHandled: |
---|
| 31 | .IdleProcessing: |
---|
| 32 | clc |
---|
| 33 | ret |
---|
[3] | 34 | |
---|
| 35 | ALIGN WORD_ALIGN |
---|
[88] | 36 | .rgfnEventSpecificHandlers: |
---|
| 37 | dw .InitializeMenuinitFromDSSI |
---|
| 38 | dw .EventCompleted |
---|
| 39 | dw .IdleProcessing |
---|
| 40 | dw .ItemHighlightedFromCX |
---|
| 41 | dw .ItemSelectedFromCX |
---|
| 42 | dw .KeyStrokeInAX |
---|
| 43 | dw BootMenuPrint_TitleStrings |
---|
| 44 | dw .RefreshInformation |
---|
| 45 | dw .RefreshItemFromCX |
---|
[3] | 46 | |
---|
| 47 | |
---|
[88] | 48 | ; Parameters: |
---|
| 49 | ; DS:SI: Ptr to MENUINIT struct to initialize |
---|
| 50 | ; Returns: |
---|
| 51 | ; DS:SI: Ptr to initialized MENUINIT struct |
---|
[3] | 52 | ALIGN JUMP_ALIGN |
---|
[88] | 53 | .InitializeMenuinitFromDSSI: |
---|
| 54 | push ds |
---|
| 55 | call RamVars_GetSegmentToDS |
---|
| 56 | call .GetDefaultMenuitemToDX |
---|
| 57 | call BootMenu_GetMenuitemCountToCX |
---|
| 58 | pop ds |
---|
| 59 | mov [si+MENUINIT.wItems], cx |
---|
| 60 | mov [si+MENUINIT.wHighlightedItem], dx |
---|
| 61 | mov WORD [si+MENUINIT.wTitleAndInfoLines], BOOT_MENU_TITLE_AND_INFO_LINES |
---|
| 62 | mov BYTE [si+MENUINIT.bWidth], BOOT_MENU_WIDTH |
---|
| 63 | call BootMenu_GetHeightToAHwithItemCountInCL |
---|
[92] | 64 | sub ah, MENU_SCREEN_BOTTOM_LINES*2 |
---|
[88] | 65 | mov [si+MENUINIT.bHeight], ah |
---|
| 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 |
---|
| 75 | call BootMenu_ConvertDriveToMenuitem |
---|
| 76 | mov dx, cx |
---|
| 77 | ret |
---|
| 78 | ALIGN JUMP_ALIGN |
---|
| 79 | .DoNotSetDefaultMenuitem: |
---|
| 80 | xor dx, dx ; Whatever appears first on boot menu |
---|
| 81 | ret |
---|
[3] | 82 | |
---|
[88] | 83 | |
---|
| 84 | ; Parameters: |
---|
| 85 | ; CX: Index of new highlighted item |
---|
| 86 | ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED |
---|
[3] | 87 | ALIGN JUMP_ALIGN |
---|
[88] | 88 | .ItemHighlightedFromCX: |
---|
| 89 | push cx |
---|
| 90 | push dx |
---|
[3] | 91 | call RamVars_GetSegmentToDS |
---|
| 92 | call DriveXlate_Reset |
---|
[92] | 93 | call BootMenu_ConvertMenuitemFromCXtoDriveInDX |
---|
[3] | 94 | call DriveXlate_SetDriveToSwap |
---|
[88] | 95 | pop ax ; Update previous item |
---|
| 96 | CALL_MENU_LIBRARY RefreshItemFromAX |
---|
| 97 | pop ax ; Update new item |
---|
| 98 | CALL_MENU_LIBRARY RefreshItemFromAX |
---|
| 99 | CALL_MENU_LIBRARY RefreshInformation |
---|
| 100 | stc |
---|
[3] | 101 | ret |
---|
| 102 | |
---|
| 103 | |
---|
[88] | 104 | ; Parameters: |
---|
| 105 | ; AL: ASCII character for the key |
---|
| 106 | ; AH: Keyboard library scan code for the key |
---|
[3] | 107 | ALIGN JUMP_ALIGN |
---|
[88] | 108 | .KeyStrokeInAX: |
---|
[92] | 109 | cmp ah, ROM_BOOT_HOTKEY_SCANCODE |
---|
| 110 | jne SHORT .CheckDriveHotkeys |
---|
| 111 | int INTV_BOOT_FAILURE ; ROM Boot, never returns |
---|
| 112 | ALIGN JUMP_ALIGN |
---|
| 113 | .CheckDriveHotkeys: |
---|
| 114 | call BootMenu_ConvertAsciiHotkeyFromALtoMenuitemInCX |
---|
[88] | 115 | cmp cx, [bp+MENUINIT.wItems] |
---|
[92] | 116 | jae SHORT .EventCompleted ; Invalid key |
---|
[88] | 117 | xchg ax, cx |
---|
| 118 | CALL_MENU_LIBRARY HighlightItemFromAX |
---|
| 119 | ; Fall to .ItemSelectedFromCX |
---|
[3] | 120 | |
---|
| 121 | |
---|
[88] | 122 | ; Parameters: |
---|
| 123 | ; CX: Index of selected item |
---|
[3] | 124 | ALIGN JUMP_ALIGN |
---|
[88] | 125 | .ItemSelectedFromCX: |
---|
| 126 | CALL_MENU_LIBRARY Close |
---|
| 127 | .EventCompleted: |
---|
| 128 | stc |
---|
[3] | 129 | ret |
---|
| 130 | |
---|
| 131 | |
---|
[88] | 132 | ; Parameters: |
---|
| 133 | ; CX: Index of item to refresh |
---|
| 134 | ; Cursor has been positioned to the beginning of item line |
---|
[3] | 135 | ALIGN JUMP_ALIGN |
---|
[88] | 136 | .RefreshItemFromCX: |
---|
| 137 | mov bx, .rgwItemTypeRefresh |
---|
| 138 | jmp SHORT .RefreshItemOrInformationWithJumpTableInCSBX |
---|
[3] | 139 | |
---|
[88] | 140 | |
---|
| 141 | ; Parameters: |
---|
| 142 | ; CX: Index of highlighted item |
---|
| 143 | ; Cursor has been positioned to the beginning of first line |
---|
[3] | 144 | ALIGN JUMP_ALIGN |
---|
[88] | 145 | .RefreshInformation: |
---|
| 146 | mov bx, .rgwInformationItemTypeRefresh |
---|
| 147 | ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX |
---|
[3] | 148 | |
---|
| 149 | ;-------------------------------------------------------------------- |
---|
[88] | 150 | ; RefreshItemOrInformationWithJumpTableInCSBX |
---|
[3] | 151 | ; Parameters: |
---|
| 152 | ; CX: Index of selected menuitem |
---|
[88] | 153 | ; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table |
---|
[3] | 154 | ; Returns: |
---|
[88] | 155 | ; CF: set since event processed |
---|
[3] | 156 | ;-------------------------------------------------------------------- |
---|
| 157 | ALIGN JUMP_ALIGN |
---|
[88] | 158 | .RefreshItemOrInformationWithJumpTableInCSBX: |
---|
| 159 | cmp cl, NO_ITEM_HIGHLIGHTED |
---|
| 160 | je SHORT .EventCompleted |
---|
| 161 | |
---|
[3] | 162 | call RamVars_GetSegmentToDS |
---|
[92] | 163 | call BootMenu_ConvertMenuitemFromCXtoDriveInDX |
---|
[3] | 164 | test dl, 80h ; Floppy drive? |
---|
[88] | 165 | jz SHORT .DrawFloppyDrive |
---|
| 166 | jmp [cs:bx+ITEM_TYPE_REFRESH.HardDisk] |
---|
[3] | 167 | ALIGN JUMP_ALIGN |
---|
[88] | 168 | .DrawFloppyDrive: |
---|
| 169 | jmp [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive] |
---|
[3] | 170 | |
---|
[88] | 171 | ; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX |
---|
| 172 | ALIGN WORD_ALIGN |
---|
| 173 | .rgwItemTypeRefresh: |
---|
| 174 | istruc ITEM_TYPE_REFRESH |
---|
| 175 | at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitem |
---|
| 176 | at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitem |
---|
| 177 | iend |
---|
| 178 | .rgwInformationItemTypeRefresh: |
---|
| 179 | istruc ITEM_TYPE_REFRESH |
---|
| 180 | at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitemInformation |
---|
| 181 | at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitemInformation |
---|
| 182 | iend |
---|