Changeset 88 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm
- Timestamp:
- Jan 27, 2011, 8:14:13 AM (14 years ago)
- google:author:
- aitotat
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm
r28 r88 1 ; File name : BootMenuEvent.asm 2 ; Project name : IDE BIOS 3 ; Created date : 26.3.2010 4 ; Last update : 1.4.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Boot Menu event handler for menu library callbacks. 7 3 … … 9 5 SECTION .text 10 6 7 struc ITEM_TYPE_REFRESH 8 .HardDisk resb 2 9 .FloppyDrive resb 2 10 .SpecialFunction resb 2 11 endstruc 12 13 11 14 ;-------------------------------------------------------------------- 12 ; Boot Menu event handler.13 ;14 15 ; BootMenuEvent_Handler 15 ; Parameters: 16 ; BX: Callback event 17 ; CX: Menuitem index (usually index of selected Menuitem) 18 ; DX: Event parameter (event specific) 19 ; SS:BP: Ptr to MENUVARS 20 ; Returns: 21 ; AH: Event specific or unused. Set to 0 if unused. 22 ; AL: 1=Event processed 23 ; 0=Event not processed (default action if any) 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 24 22 ; Corrupts registers: 25 ; BX, CX, DX23 ; All 26 24 ;-------------------------------------------------------------------- 27 25 ALIGN JUMP_ALIGN 28 26 BootMenuEvent_Handler: 29 push es 30 push ds 31 push di 32 push si 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 33 34 34 xor ax, ax ; Event not processed35 cmp bx, BYTE EVNT_MNU_GETDEF ; Event in jump table?36 ja SHORT .Return37 shl bx, 138 call [cs:bx+.rgwEventJmp]39 .Return:40 pop si41 pop di42 pop ds43 pop es44 ret45 35 ALIGN WORD_ALIGN 46 .rgwEventJmp: 47 dw BootMenuEvent_Exit ; 0, EVNT_MNU_EXIT (Menu will quit) 48 dw BootMenuEvent_EventItemSelectionChanged ; 1, EVNT_MMU_SELCHG (Menuitem selection changed (with arrows)) 49 dw BootMenuEvent_EventItemSelected ; 2, EVNT_MNU_SELSET (Menuitem selected (with Enter)) 50 dw BootMenuEvent_EventKeyPressed ; 3, EVNT_MNU_KEY (Keyboard key pressed) 51 dw BootMenuEvent_EventMenuDraw ; 4, EVNT_MNU_UPD (Menu needs to be updated) 52 dw BootMenuEvent_EventGetDefaultMenuitem ; 5, EVNT_MNU_GETDEF (Request menuitem to be selected by default) 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 53 46 54 47 55 ;-------------------------------------------------------------------- 56 ; Boot Menu event handler. 57 ; Handles Menu Exit notification (EVNT_MNU_EXIT). 58 ; 59 ; BootMenuEvent_Exit 60 ; Parameters: 61 ; SS:BP: Ptr to MENUVARS 62 ; Returns: 63 ; AH: 1 to cancel exit 64 ; 0 to allow menu exit 65 ; AL: 1 = Event processed 66 ; Corrupts registers: 67 ; Nothing 68 ;-------------------------------------------------------------------- 48 ; Parameters: 49 ; DS:SI: Ptr to MENUINIT struct to initialize 50 ; Returns: 51 ; DS:SI: Ptr to initialized MENUINIT struct 69 52 ALIGN JUMP_ALIGN 70 BootMenuEvent_Exit: 71 mov ax, 1 ; Event handled 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 64 mov [si+MENUINIT.bHeight], ah 65 stc 72 66 ret 73 67 74 75 ;--------------------------------------------------------------------76 ; Boot Menu event handler.77 ; Handles Menuitem Selection Changed notification (EVNT_MMU_SELCHG).78 ;79 ; BootMenuEvent_EventItemSelectionChanged80 ; Parameters:81 ; CX: Index of selected Menuitem82 ; SS:BP: Ptr to MENUVARS83 ; Returns:84 ; AX: 1 = Event processed85 ; Corrupts registers:86 ; BX, CX, DX, DI87 ;--------------------------------------------------------------------88 68 ALIGN JUMP_ALIGN 89 BootMenuEvent_EventItemSelectionChanged: 90 call RamVars_GetSegmentToDS 91 call DriveXlate_Reset 92 call BootMenu_ConvertMenuitemToDriveOrFunction 93 jc SHORT BootMenuEvent_UpdateAllMenuitems ; Selection changed to a function 94 call DriveXlate_SetDriveToSwap 95 ; Fall to BootMenuEvent_UpdateAllMenuitems 96 97 ;-------------------------------------------------------------------- 98 ; Redraws all menuitems. 99 ; 100 ; BootMenuEvent_UpdateAllMenuitems 101 ; Parameters: 102 ; SS:BP: Ptr to MENUVARS 103 ; Returns: 104 ; AX: 1 = Event processed 105 ; Corrupts registers: 106 ; BX, CX, DX 107 ;-------------------------------------------------------------------- 108 ALIGN JUMP_ALIGN 109 BootMenuEvent_UpdateAllMenuitems: 110 mov cx, -1 ; Update all items 111 mov dl, MFL_UPD_ITEM | MFL_UPD_NFO | MFL_UPD_NOCLEAR 112 call Menu_Invalidate 113 mov ax, 1 ; Event handled 114 ret 115 116 117 ;-------------------------------------------------------------------- 118 ; Boot Menu event handler. 119 ; Handles Menuitem Selected notification (EVNT_MNU_SELSET). 120 ; 121 ; BootMenuEvent_EventItemSelected 122 ; Parameters: 123 ; CX: Index of selected Menuitem 124 ; SS:BP: Ptr to MENUVARS 125 ; Returns: 126 ; AX: 1 = Event processed 127 ; Corrupts registers: 128 ; BX, CX, DX 129 ;-------------------------------------------------------------------- 130 ALIGN JUMP_ALIGN 131 BootMenuEvent_EventItemSelected: 132 call Menu_Exit ; Exit from menu 133 mov ax, 1 ; Event handled 134 ret 135 136 137 ;-------------------------------------------------------------------- 138 ; Boot Menu event handler. 139 ; Handles Key pressed notification (EVNT_MNU_KEY). 140 ; 141 ; BootMenuEvent_EventKeyPressed 142 ; Parameters: 143 ; CX: Index of currently selected Menuitem 144 ; DL: ASCII character 145 ; DH: BIOS Scan Code 146 ; SS:BP: Ptr to MENUVARS 147 ; Returns: 148 ; AX: 1 = Event processed 149 ; Corrupts registers: 150 ; BX, CX, DX, DS 151 ;-------------------------------------------------------------------- 152 ALIGN JUMP_ALIGN 153 BootMenuEvent_EventKeyPressed: 154 mov al, dl ; Copy ASCII char to AL 155 sub al, 'a'-'A' ; To upper case character 156 cmp al, 'A' ; First possible drive letter? 157 jb SHORT .Return ; If below, return 158 cmp al, 'Z' ; Last possible drive letter? 159 ja SHORT .Return ; If above, return 160 LOAD_BDA_SEGMENT_TO ds, dx 161 mov [BOOTVARS.bMenuHotkey], al 162 jmp SHORT BootMenuEvent_EventItemSelected 163 .Return: 164 mov ax, 1 165 ret 166 167 168 ;-------------------------------------------------------------------- 169 ; Boot Menu event handler. 170 ; Handles Menu Update notification (EVNT_MNU_UPD). 171 ; 172 ; BootMenuEvent_EventMenuDraw 173 ; Parameters: 174 ; CX: Index of Menuitem to update (if MFL_UPD_ITEM set) 175 ; DL: Update flag (only one): 176 ; MFL_UPD_TITLE Update Menu Title string(s) 177 ; MFL_UPD_NFO Update Menu Info string(s) 178 ; MFL_UPD_ITEM Update Menuitem string 179 ; SS:BP: Ptr to MENUVARS 180 ; Returns: 181 ; AX: Was event processed 182 ; Corrupts registers: 183 ; BX, CX, DX, SI, DI, DS 184 ;-------------------------------------------------------------------- 185 ALIGN JUMP_ALIGN 186 BootMenuEvent_EventMenuDraw: 187 test dl, MFL_UPD_ITEM ; Need to update Menuitem? 188 jnz SHORT BootMenuEvent_DrawMenuitem 189 test dl, MFL_UPD_NFO ; Need to update Info String(s)? 190 jnz SHORT BootMenuEvent_DrawInfo 191 test dl, MFL_UPD_TITLE ; Need to update Title String(s)? 192 jnz SHORT BootMenuEvent_DrawTitle 193 xor ax, ax 194 ret 195 196 ;-------------------------------------------------------------------- 197 ; Draws Menuitem string. Cursor is set to a menuitem location. 198 ; 199 ; BootMenuEvent_DrawMenuitem 200 ; Parameters: 201 ; CX: Index of Menuitem to draw 202 ; SS:BP: Ptr to MENUVARS 203 ; Returns: 204 ; AX: Was event processed 205 ; Corrupts registers: 206 ; BX, CX, DX, SI, DI, DS, ES 207 ;-------------------------------------------------------------------- 208 ALIGN JUMP_ALIGN 209 BootMenuEvent_DrawMenuitem: 210 call RamVars_GetSegmentToDS 211 call BootMenu_ConvertMenuitemToDriveOrFunction 212 jc SHORT .DrawFunctionItem 213 call BootMenuPrint_TranslatedDriveNumber 214 test dl, 80h ; Floppy drive? 215 jz SHORT .DrawFloppyDriveItem 216 jmp BootMenuPrint_HardDiskMenuitem 217 ALIGN JUMP_ALIGN 218 .DrawFunctionItem: 219 jmp BootMenuPrint_FunctionMenuitem 220 ALIGN JUMP_ALIGN 221 .DrawFloppyDriveItem: 222 jmp BootMenuPrint_FloppyMenuitem 223 224 ;-------------------------------------------------------------------- 225 ; Draws information strings. Cursor is set to a first information line. 226 ; 227 ; BootMenuEvent_DrawInfo 228 ; Parameters: 229 ; CX: Index of selected menuitem 230 ; SS:BP: Ptr to MENUVARS 231 ; Returns: 232 ; AX: Was event processed 233 ; Corrupts registers: 234 ; BX, CX, DX, SI, DI, DS, ES 235 ;-------------------------------------------------------------------- 236 ALIGN JUMP_ALIGN 237 BootMenuEvent_DrawInfo: 238 call RamVars_GetSegmentToDS 239 call BootMenu_ConvertMenuitemToDriveOrFunction 240 jc SHORT .DrawFunctionInfo 241 test dl, 80h ; Floppy drive? 242 jz SHORT .DrawFloppyDriveInfo 243 jmp BootMenuPrint_HardDiskMenuitemInformation 244 ALIGN JUMP_ALIGN 245 .DrawFunctionInfo: 246 jmp BootMenuPrint_FunctionMenuitemInformation 247 ALIGN JUMP_ALIGN 248 .DrawFloppyDriveInfo: 249 jmp BootMenuPrint_FloppyMenuitemInformation 250 251 ;-------------------------------------------------------------------- 252 ; Draws title strings. Cursor is set to a first title line. 253 ; 254 ; BootMenuEvent_DrawTitle 255 ; Parameters: 256 ; SS:BP: Ptr to MENUVARS 257 ; Returns: 258 ; AX: Was event processed 259 ; Corrupts registers: 260 ; CX, DX, SI 261 ;-------------------------------------------------------------------- 262 ALIGN JUMP_ALIGN 263 BootMenuEvent_DrawTitle: 264 jmp BootMenuPrint_TitleStrings 265 266 267 ;-------------------------------------------------------------------- 268 ; Boot Menu event handler. 269 ; Handles Get Default Menuitem notification (EVNT_MNU_GETDEF). 270 ; 271 ; BootMenuEvent_EventGetDefaultMenuitem 272 ; Parameters: 273 ; SS:BP: Ptr to MENUVARS 274 ; Returns: 275 ; AX: Was event processed 276 ; CX: Index of menuitem to set selected 277 ; Corrupts registers: 278 ; BX, CX, DX, DI, DS 279 ;-------------------------------------------------------------------- 280 ALIGN JUMP_ALIGN 281 BootMenuEvent_EventGetDefaultMenuitem: 282 call RamVars_GetSegmentToDS 69 .GetDefaultMenuitemToDX: 283 70 mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive 284 71 call BootMenu_IsDriveInSystem … … 286 73 call DriveXlate_SetDriveToSwap 287 74 call BootMenu_ConvertDriveToMenuitem 288 mov ax, 175 mov dx, cx 289 76 ret 290 77 ALIGN JUMP_ALIGN 291 78 .DoNotSetDefaultMenuitem: 292 xor ax, ax79 xor dx, dx ; Whatever appears first on boot menu 293 80 ret 81 82 83 ; Parameters: 84 ; CX: Index of new highlighted item 85 ; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED 86 ALIGN JUMP_ALIGN 87 .ItemHighlightedFromCX: 88 push cx 89 push dx 90 call RamVars_GetSegmentToDS 91 call DriveXlate_Reset 92 call BootMenu_ConvertMenuitemToDriveOrFunction 93 jc SHORT .UpdatePreviousAndNewMenuitem ; Selection changed to a function 94 call DriveXlate_SetDriveToSwap 95 96 .UpdatePreviousAndNewMenuitem: 97 pop ax ; Update previous item 98 CALL_MENU_LIBRARY RefreshItemFromAX 99 pop ax ; Update new item 100 CALL_MENU_LIBRARY RefreshItemFromAX 101 CALL_MENU_LIBRARY RefreshInformation 102 stc 103 ret 104 105 106 ; Parameters: 107 ; AL: ASCII character for the key 108 ; AH: Keyboard library scan code for the key 109 ALIGN JUMP_ALIGN 110 .KeyStrokeInAX: 111 xor ah, ah ; ASCII drive letter now in AX 112 call BootMenu_ConvertHotkeyToMenuitem 113 cmp cx, [bp+MENUINIT.wItems] 114 jae SHORT .EventNotHandled ; Invalid key 115 xchg ax, cx 116 CALL_MENU_LIBRARY HighlightItemFromAX 117 ; Fall to .ItemSelectedFromCX 118 119 120 ; Parameters: 121 ; CX: Index of selected item 122 ALIGN JUMP_ALIGN 123 .ItemSelectedFromCX: 124 CALL_MENU_LIBRARY Close 125 .EventCompleted: 126 stc 127 ret 128 129 130 ; Parameters: 131 ; CX: Index of item to refresh 132 ; Cursor has been positioned to the beginning of item line 133 ALIGN JUMP_ALIGN 134 .RefreshItemFromCX: 135 mov bx, .rgwItemTypeRefresh 136 jmp SHORT .RefreshItemOrInformationWithJumpTableInCSBX 137 138 139 ; Parameters: 140 ; CX: Index of highlighted item 141 ; Cursor has been positioned to the beginning of first line 142 ALIGN JUMP_ALIGN 143 .RefreshInformation: 144 mov bx, .rgwInformationItemTypeRefresh 145 ; Fall to .RefreshItemOrInformationWithJumpTableInCSBX 146 147 ;-------------------------------------------------------------------- 148 ; RefreshItemOrInformationWithJumpTableInCSBX 149 ; Parameters: 150 ; CX: Index of selected menuitem 151 ; CS:BX: Ptr to ITEM_TYPE_REFRESH jump table 152 ; Returns: 153 ; CF: set since event processed 154 ;-------------------------------------------------------------------- 155 ALIGN JUMP_ALIGN 156 .RefreshItemOrInformationWithJumpTableInCSBX: 157 cmp cl, NO_ITEM_HIGHLIGHTED 158 je SHORT .EventCompleted 159 160 call RamVars_GetSegmentToDS 161 call BootMenu_ConvertMenuitemToDriveOrFunction 162 jc SHORT .DrawFunction 163 test dl, 80h ; Floppy drive? 164 jz SHORT .DrawFloppyDrive 165 jmp [cs:bx+ITEM_TYPE_REFRESH.HardDisk] 166 ALIGN JUMP_ALIGN 167 .DrawFunction: 168 jmp [cs:bx+ITEM_TYPE_REFRESH.SpecialFunction] 169 ALIGN JUMP_ALIGN 170 .DrawFloppyDrive: 171 jmp [cs:bx+ITEM_TYPE_REFRESH.FloppyDrive] 172 173 ; Jump tables for .RefreshItemOrInformationWithJumpTableInCSBX 174 ALIGN WORD_ALIGN 175 .rgwItemTypeRefresh: 176 istruc ITEM_TYPE_REFRESH 177 at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitem 178 at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitem 179 at ITEM_TYPE_REFRESH.SpecialFunction, dw BootMenuPrint_FunctionMenuitem 180 iend 181 .rgwInformationItemTypeRefresh: 182 istruc ITEM_TYPE_REFRESH 183 at ITEM_TYPE_REFRESH.HardDisk, dw BootMenuPrint_HardDiskMenuitemInformation 184 at ITEM_TYPE_REFRESH.FloppyDrive, dw BootMenuPrint_FloppyMenuitemInformation 185 at ITEM_TYPE_REFRESH.SpecialFunction, dw BootMenuPrint_ClearInformationArea 186 iend
Note:
See TracChangeset
for help on using the changeset viewer.