[41] | 1 | ; Project name : Assembly Library
|
---|
| 2 | ; Description : Menu loop for waiting keystrokes.
|
---|
| 3 |
|
---|
[376] | 4 | ;
|
---|
[526] | 5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
[376] | 7 | ;
|
---|
| 8 | ; This program is free software; you can redistribute it and/or modify
|
---|
| 9 | ; it under the terms of the GNU General Public License as published by
|
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
| 11 | ; (at your option) any later version.
|
---|
[526] | 12 | ;
|
---|
[376] | 13 | ; This program is distributed in the hope that it will be useful,
|
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
[526] | 16 | ; GNU General Public License for more details.
|
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
| 18 | ;
|
---|
| 19 |
|
---|
[526] | 20 |
|
---|
[41] | 21 | ; Section containing code
|
---|
| 22 | SECTION .text
|
---|
| 23 |
|
---|
| 24 | ;--------------------------------------------------------------------
|
---|
| 25 | ; MenuLoop_Enter
|
---|
| 26 | ; Parameters
|
---|
| 27 | ; SS:BP: Ptr to MENU
|
---|
| 28 | ; Returns:
|
---|
| 29 | ; Nothing
|
---|
| 30 | ; Corrupts registers:
|
---|
| 31 | ; AX, BX, CX, DX, SI, DI
|
---|
| 32 | ;--------------------------------------------------------------------
|
---|
[369] | 33 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 34 | MenuLoop_Enter:
|
---|
[58] | 35 | call KeystrokeProcessing
|
---|
| 36 | call TimeoutProcessing
|
---|
[189] | 37 | %ifdef MENUEVENT_IDLEPROCESSING_ENABLE
|
---|
[105] | 38 | call MenuEvent_IdleProcessing ; User idle processing
|
---|
[189] | 39 | %endif
|
---|
[41] | 40 | test BYTE [bp+MENU.bFlags], FLG_MENU_EXIT
|
---|
| 41 | jz SHORT MenuLoop_Enter
|
---|
[58] | 42 | ret
|
---|
[41] | 43 |
|
---|
| 44 |
|
---|
| 45 | ;--------------------------------------------------------------------
|
---|
[105] | 46 | ; KeystrokeProcessing
|
---|
[58] | 47 | ; TimeoutProcessing
|
---|
[41] | 48 | ; Parameters
|
---|
| 49 | ; SS:BP: Ptr to MENU
|
---|
| 50 | ; Returns:
|
---|
| 51 | ; Nothing
|
---|
| 52 | ; Corrupts registers:
|
---|
[58] | 53 | ; All, except SS:BP
|
---|
[41] | 54 | ;--------------------------------------------------------------------
|
---|
[369] | 55 | ALIGN MENU_JUMP_ALIGN
|
---|
[105] | 56 | KeystrokeProcessing:
|
---|
| 57 | call Keyboard_GetKeystrokeToAX
|
---|
| 58 | jnz SHORT ProcessKeystrokeFromAX
|
---|
| 59 | NoKeystrokeToProcess:
|
---|
| 60 | ret
|
---|
[41] | 61 |
|
---|
[369] | 62 | ALIGN MENU_JUMP_ALIGN
|
---|
[58] | 63 | TimeoutProcessing:
|
---|
| 64 | call MenuTime_UpdateSelectionTimeout
|
---|
[105] | 65 | jnc NoKeystrokeToProcess
|
---|
[178] | 66 | mov al, CR ; Fake ENTER to select item
|
---|
[105] | 67 | ; Fall to ProcessKeystrokeFromAX
|
---|
[41] | 68 |
|
---|
[58] | 69 |
|
---|
[41] | 70 | ;--------------------------------------------------------------------
|
---|
| 71 | ; ProcessKeystrokeFromAX
|
---|
| 72 | ; Parameters
|
---|
| 73 | ; AL: ASCII character
|
---|
| 74 | ; AH: BIOS scan code
|
---|
| 75 | ; SS:BP: Ptr to MENU
|
---|
| 76 | ; Returns:
|
---|
[133] | 77 | ; Nothing
|
---|
[41] | 78 | ; Corrupts registers:
|
---|
| 79 | ; AX, BX, CX, DX, SI, DI
|
---|
| 80 | ;--------------------------------------------------------------------
|
---|
[369] | 81 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 82 | ProcessKeystrokeFromAX:
|
---|
[60] | 83 | xchg cx, ax
|
---|
| 84 | call MenuTime_StopSelectionTimeout
|
---|
| 85 | xchg ax, cx
|
---|
| 86 | call .ProcessMenuSystemKeystrokeFromAX
|
---|
[105] | 87 | jc SHORT NoKeystrokeToProcess
|
---|
[41] | 88 | jmp MenuEvent_KeyStrokeInAX
|
---|
[526] | 89 |
|
---|
[41] | 90 | ;--------------------------------------------------------------------
|
---|
[60] | 91 | ; .ProcessMenuSystemKeystrokeFromAX
|
---|
[41] | 92 | ; Parameters
|
---|
| 93 | ; AL: ASCII character
|
---|
| 94 | ; AH: BIOS scan code
|
---|
| 95 | ; SS:BP: Ptr to MENU
|
---|
| 96 | ; Returns:
|
---|
| 97 | ; CF: Set if keystroke processed
|
---|
| 98 | ; Cleared if keystroke not processed
|
---|
| 99 | ; AL: ASCII character (if CF cleared)
|
---|
| 100 | ; AH: BIOS scan code (if CF cleared)
|
---|
| 101 | ; Corrupts registers:
|
---|
| 102 | ; BX, CX, DX, SI, DI
|
---|
| 103 | ;--------------------------------------------------------------------
|
---|
[369] | 104 | ALIGN MENU_JUMP_ALIGN
|
---|
[60] | 105 | .ProcessMenuSystemKeystrokeFromAX:
|
---|
[492] | 106 | %ifndef MENU_NO_ESC
|
---|
[178] | 107 | cmp al, ESC
|
---|
[589] | 108 | jne SHORT .NotEscape
|
---|
[41] | 109 |
|
---|
[589] | 110 | ; Leave menu without selecting item
|
---|
[58] | 111 | call MenuEvent_ExitMenu
|
---|
| 112 | jnc SHORT .CancelMenuExit
|
---|
[41] | 113 | call MenuInit_CloseMenuWindow
|
---|
[52] | 114 | mov WORD [bp+MENUINIT.wHighlightedItem], NO_ITEM_HIGHLIGHTED
|
---|
[58] | 115 | .CancelMenuExit:
|
---|
[41] | 116 | stc
|
---|
| 117 | ret
|
---|
[492] | 118 | %endif
|
---|
[526] | 119 |
|
---|
[369] | 120 | ALIGN MENU_JUMP_ALIGN
|
---|
[589] | 121 | .NotEscape:
|
---|
| 122 | cmp al, CR
|
---|
| 123 | jne SHORT .NotCarriageReturn
|
---|
| 124 |
|
---|
| 125 | ; Select item
|
---|
[52] | 126 | mov cx, [bp+MENUINIT.wHighlightedItem]
|
---|
[41] | 127 | call MenuEvent_ItemSelectedFromCX
|
---|
| 128 | stc
|
---|
[589] | 129 | .Return:
|
---|
[41] | 130 | ret
|
---|
| 131 |
|
---|
[589] | 132 | ALIGN MENU_JUMP_ALIGN
|
---|
| 133 | .NotCarriageReturn:
|
---|
| 134 | test BYTE [bp+MENU.bFlags], FLG_MENU_USER_HANDLES_SCROLLING
|
---|
| 135 | jnz SHORT .Return ; With CF cleared since keystroke not processed
|
---|
| 136 | ; Fall to MenuLoop_ProcessScrollingKeysFromAX
|
---|
[41] | 137 |
|
---|
[589] | 138 |
|
---|
[41] | 139 | ;--------------------------------------------------------------------
|
---|
| 140 | ; MenuLoop_ProcessScrollingKeysFromAX
|
---|
| 141 | ; Parameters
|
---|
| 142 | ; AL: ASCII character
|
---|
| 143 | ; AH: BIOS scan code
|
---|
| 144 | ; SS:BP: Ptr to MENU
|
---|
| 145 | ; Returns:
|
---|
| 146 | ; CF: Set if keystroke processed
|
---|
| 147 | ; Cleared if keystroke not processed
|
---|
| 148 | ; AL: ASCII character (if CF cleared)
|
---|
| 149 | ; AH: BIOS scan code (if CF cleared)
|
---|
| 150 | ; Corrupts registers:
|
---|
| 151 | ; BX, CX, DX, SI, DI
|
---|
| 152 | ;--------------------------------------------------------------------
|
---|
[369] | 153 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 154 | MenuLoop_ProcessScrollingKeysFromAX:
|
---|
[178] | 155 | xchg ah, al
|
---|
| 156 | cmp al, MENU_KEY_PGUP
|
---|
[41] | 157 | je SHORT .ChangeToPreviousPage
|
---|
[178] | 158 | cmp al, MENU_KEY_PGDN
|
---|
[41] | 159 | je SHORT .ChangeToNextPage
|
---|
[178] | 160 | cmp al, MENU_KEY_HOME
|
---|
[41] | 161 | je SHORT .SelectFirstItem
|
---|
[178] | 162 | cmp al, MENU_KEY_END
|
---|
[41] | 163 | je SHORT .SelectLastItem
|
---|
| 164 |
|
---|
[178] | 165 | cmp al, MENU_KEY_UP
|
---|
[41] | 166 | je SHORT .DecrementSelectedItem
|
---|
[178] | 167 | cmp al, MENU_KEY_DOWN
|
---|
[41] | 168 | je SHORT .IncrementSelectedItem
|
---|
| 169 | clc ; Clear CF since keystroke not processed
|
---|
[178] | 170 | xchg ah, al
|
---|
[41] | 171 | ret
|
---|
| 172 |
|
---|
[369] | 173 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 174 | .ChangeToPreviousPage:
|
---|
| 175 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
[589] | 176 | neg cx
|
---|
| 177 | mov ax, cx
|
---|
| 178 | add cx, [bp+MENUINIT.wHighlightedItem]
|
---|
[41] | 179 | jge SHORT .MoveHighlightedItemByAX ; No rotation for PgUp
|
---|
| 180 | ; Fall to .SelectFirstItem
|
---|
[369] | 181 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 182 | .SelectFirstItem:
|
---|
[52] | 183 | mov ax, [bp+MENUINIT.wHighlightedItem]
|
---|
[41] | 184 | neg ax
|
---|
| 185 | jmp SHORT .MoveHighlightedItemByAX
|
---|
| 186 |
|
---|
[369] | 187 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 188 | .ChangeToNextPage:
|
---|
| 189 | call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
|
---|
[589] | 190 | mov ax, cx
|
---|
| 191 | add cx, [bp+MENUINIT.wHighlightedItem]
|
---|
[41] | 192 | cmp cx, [bp+MENUINIT.wItems]
|
---|
| 193 | jb SHORT .MoveHighlightedItemByAX ; No rotation for PgDn
|
---|
| 194 | ; Fall to .SelectLastItem
|
---|
[369] | 195 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 196 | .SelectLastItem:
|
---|
[178] | 197 | stc
|
---|
[41] | 198 | mov ax, [bp+MENUINIT.wItems]
|
---|
[178] | 199 | sbb ax, [bp+MENUINIT.wHighlightedItem]
|
---|
[41] | 200 | jmp SHORT .MoveHighlightedItemByAX
|
---|
| 201 |
|
---|
[369] | 202 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 203 | .DecrementSelectedItem:
|
---|
[581] | 204 | mov al, -1
|
---|
| 205 | SKIP2B cx
|
---|
[41] | 206 | .IncrementSelectedItem:
|
---|
[581] | 207 | mov al, 1
|
---|
| 208 | cbw
|
---|
[369] | 209 | ALIGN MENU_JUMP_ALIGN
|
---|
[41] | 210 | .MoveHighlightedItemByAX:
|
---|
| 211 | call MenuScrollbars_MoveHighlightedItemByAX
|
---|
| 212 | stc
|
---|
| 213 | ret
|
---|