source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/MenuLoop.asm@ 373

Last change on this file since 373 was 369, checked in by gregli@…, 13 years ago

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

File size: 5.0 KB
RevLine 
[41]1; Project name : Assembly Library
2; Description : Menu loop for waiting keystrokes.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; MenuLoop_Enter
9; Parameters
10; SS:BP: Ptr to MENU
11; Returns:
12; Nothing
13; Corrupts registers:
14; AX, BX, CX, DX, SI, DI
15;--------------------------------------------------------------------
[369]16ALIGN MENU_JUMP_ALIGN
[41]17MenuLoop_Enter:
[58]18 call KeystrokeProcessing
19 call TimeoutProcessing
[189]20%ifdef MENUEVENT_IDLEPROCESSING_ENABLE
[105]21 call MenuEvent_IdleProcessing ; User idle processing
[189]22%endif
[41]23 test BYTE [bp+MENU.bFlags], FLG_MENU_EXIT
24 jz SHORT MenuLoop_Enter
[58]25 ret
[41]26
27
28;--------------------------------------------------------------------
[105]29; KeystrokeProcessing
[58]30; TimeoutProcessing
[41]31; Parameters
32; SS:BP: Ptr to MENU
33; Returns:
34; Nothing
35; Corrupts registers:
[58]36; All, except SS:BP
[41]37;--------------------------------------------------------------------
[369]38ALIGN MENU_JUMP_ALIGN
[105]39KeystrokeProcessing:
40 call Keyboard_GetKeystrokeToAX
41 jnz SHORT ProcessKeystrokeFromAX
42NoKeystrokeToProcess:
43 ret
[41]44
[369]45ALIGN MENU_JUMP_ALIGN
[58]46TimeoutProcessing:
47 call MenuTime_UpdateSelectionTimeout
[105]48 jnc NoKeystrokeToProcess
[178]49 mov al, CR ; Fake ENTER to select item
[105]50 ; Fall to ProcessKeystrokeFromAX
[41]51
[58]52
[41]53;--------------------------------------------------------------------
54; ProcessKeystrokeFromAX
55; Parameters
56; AL: ASCII character
57; AH: BIOS scan code
58; SS:BP: Ptr to MENU
59; Returns:
[133]60; Nothing
[41]61; Corrupts registers:
62; AX, BX, CX, DX, SI, DI
63;--------------------------------------------------------------------
[369]64ALIGN MENU_JUMP_ALIGN
[41]65ProcessKeystrokeFromAX:
[60]66 xchg cx, ax
67 call MenuTime_StopSelectionTimeout
68 xchg ax, cx
69 call .ProcessMenuSystemKeystrokeFromAX
[105]70 jc SHORT NoKeystrokeToProcess
[41]71 jmp MenuEvent_KeyStrokeInAX
72
73;--------------------------------------------------------------------
[60]74; .ProcessMenuSystemKeystrokeFromAX
[41]75; Parameters
76; AL: ASCII character
77; AH: BIOS scan code
78; SS:BP: Ptr to MENU
79; Returns:
80; CF: Set if keystroke processed
81; Cleared if keystroke not processed
82; AL: ASCII character (if CF cleared)
83; AH: BIOS scan code (if CF cleared)
84; Corrupts registers:
85; BX, CX, DX, SI, DI
86;--------------------------------------------------------------------
[369]87ALIGN MENU_JUMP_ALIGN
[60]88.ProcessMenuSystemKeystrokeFromAX:
[178]89 cmp al, ESC
[41]90 je SHORT .LeaveMenuWithoutSelectingItem
[178]91 cmp al, CR
[41]92 je SHORT .SelectItem
93
94 test BYTE [bp+MENU.bFlags], FLG_MENU_USER_HANDLES_SCROLLING
95 jz SHORT MenuLoop_ProcessScrollingKeysFromAX
[133]96 ret ; Return with CF cleared since keystroke not processed
[41]97
[369]98ALIGN MENU_JUMP_ALIGN
[41]99.LeaveMenuWithoutSelectingItem:
[58]100 call MenuEvent_ExitMenu
101 jnc SHORT .CancelMenuExit
[41]102 call MenuInit_CloseMenuWindow
[52]103 mov WORD [bp+MENUINIT.wHighlightedItem], NO_ITEM_HIGHLIGHTED
[58]104.CancelMenuExit:
[41]105 stc
106 ret
107
[369]108ALIGN MENU_JUMP_ALIGN
[41]109.SelectItem:
[52]110 mov cx, [bp+MENUINIT.wHighlightedItem]
[41]111 call MenuEvent_ItemSelectedFromCX
112 stc
113 ret
114
115
116;--------------------------------------------------------------------
117; MenuLoop_ProcessScrollingKeysFromAX
118; Parameters
119; AL: ASCII character
120; AH: BIOS scan code
121; SS:BP: Ptr to MENU
122; Returns:
123; CF: Set if keystroke processed
124; Cleared if keystroke not processed
125; AL: ASCII character (if CF cleared)
126; AH: BIOS scan code (if CF cleared)
127; Corrupts registers:
128; BX, CX, DX, SI, DI
129;--------------------------------------------------------------------
[369]130ALIGN MENU_JUMP_ALIGN
[41]131MenuLoop_ProcessScrollingKeysFromAX:
[178]132 xchg ah, al
133 cmp al, MENU_KEY_PGUP
[41]134 je SHORT .ChangeToPreviousPage
[178]135 cmp al, MENU_KEY_PGDN
[41]136 je SHORT .ChangeToNextPage
[178]137 cmp al, MENU_KEY_HOME
[41]138 je SHORT .SelectFirstItem
[178]139 cmp al, MENU_KEY_END
[41]140 je SHORT .SelectLastItem
141
[178]142 cmp al, MENU_KEY_UP
[41]143 je SHORT .DecrementSelectedItem
[178]144 cmp al, MENU_KEY_DOWN
[41]145 je SHORT .IncrementSelectedItem
146 clc ; Clear CF since keystroke not processed
[178]147 xchg ah, al
[41]148 ret
149
[369]150ALIGN MENU_JUMP_ALIGN
[41]151.ChangeToPreviousPage:
152 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
153 xchg ax, cx
154 neg ax
[52]155 mov cx, [bp+MENUINIT.wHighlightedItem]
[41]156 add cx, ax
157 jge SHORT .MoveHighlightedItemByAX ; No rotation for PgUp
158 ; Fall to .SelectFirstItem
[369]159ALIGN MENU_JUMP_ALIGN
[41]160.SelectFirstItem:
[52]161 mov ax, [bp+MENUINIT.wHighlightedItem]
[41]162 neg ax
163 jmp SHORT .MoveHighlightedItemByAX
164
[369]165ALIGN MENU_JUMP_ALIGN
[41]166.ChangeToNextPage:
167 call MenuScrollbars_GetMaxVisibleItemsOnPageToCX
168 xchg ax, cx
[52]169 mov cx, [bp+MENUINIT.wHighlightedItem]
[41]170 add cx, ax
171 cmp cx, [bp+MENUINIT.wItems]
172 jb SHORT .MoveHighlightedItemByAX ; No rotation for PgDn
173 ; Fall to .SelectLastItem
[369]174ALIGN MENU_JUMP_ALIGN
[41]175.SelectLastItem:
[178]176 stc
[41]177 mov ax, [bp+MENUINIT.wItems]
[178]178 sbb ax, [bp+MENUINIT.wHighlightedItem]
[41]179 jmp SHORT .MoveHighlightedItemByAX
180
[369]181ALIGN MENU_JUMP_ALIGN
[41]182.DecrementSelectedItem:
183 mov ax, -1
[178]184 SKIP2B cx ; mov cx, <next instruction>
[41]185.IncrementSelectedItem:
[178]186 mov al, 1 ; AH is already 0
[369]187ALIGN MENU_JUMP_ALIGN
[41]188.MoveHighlightedItemByAX:
189 call MenuScrollbars_MoveHighlightedItemByAX
190 stc
191 ret
Note: See TracBrowser for help on using the repository browser.