[41] | 1 | ; Project name : Assembly Library |
---|
| 2 | ; Description : Functions for initializing menu system. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
[505] | 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
[526] | 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. |
---|
[505] | 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 |
---|
[505] | 16 | ; GNU General Public License for more details. |
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 18 | ; |
---|
| 19 | |
---|
[505] | 20 | |
---|
[41] | 21 | ; Section containing code |
---|
| 22 | SECTION .text |
---|
| 23 | |
---|
| 24 | ;-------------------------------------------------------------------- |
---|
| 25 | ; MenuEvent_InitializeMenuinit |
---|
| 26 | ; Parameters |
---|
| 27 | ; SS:BP: Ptr to MENU |
---|
| 28 | ; Returns: |
---|
| 29 | ; DS:SI: Ptr to MENU with MENUINIT initialized from user handler |
---|
| 30 | ; CF: Set if event processed |
---|
| 31 | ; Cleared if event not processed |
---|
| 32 | ; Corrupts registers: |
---|
| 33 | ; AX, BX, DX |
---|
| 34 | ;-------------------------------------------------------------------- |
---|
[369] | 35 | ALIGN MENU_JUMP_ALIGN |
---|
[41] | 36 | MenuEvent_InitializeMenuinit: |
---|
| 37 | push ss |
---|
| 38 | pop ds |
---|
| 39 | mov si, bp |
---|
[183] | 40 | mov bl, MENUEVENT_InitializeMenuinitFromDSSI |
---|
[41] | 41 | jmp SHORT MenuEvent_SendFromBX |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | ;-------------------------------------------------------------------- |
---|
| 45 | ; MenuEvent_ExitMenu |
---|
| 46 | ; Parameters |
---|
| 47 | ; SS:BP: Ptr to MENU |
---|
| 48 | ; Returns: |
---|
[58] | 49 | ; CF: Set to exit from menu |
---|
| 50 | ; Cleared to cancel exit |
---|
[41] | 51 | ; Corrupts registers: |
---|
| 52 | ; AX, BX, DX |
---|
| 53 | ;-------------------------------------------------------------------- |
---|
[492] | 54 | %ifndef MENU_NO_ESC |
---|
[369] | 55 | ALIGN MENU_JUMP_ALIGN |
---|
[41] | 56 | MenuEvent_ExitMenu: |
---|
[183] | 57 | mov bl, MENUEVENT_ExitMenu |
---|
[41] | 58 | jmp SHORT MenuEvent_SendFromBX |
---|
[492] | 59 | %endif |
---|
[41] | 60 | |
---|
[505] | 61 | |
---|
[189] | 62 | %ifdef MENUEVENT_IDLEPROCESSING_ENABLE |
---|
[41] | 63 | ;-------------------------------------------------------------------- |
---|
| 64 | ; MenuEvent_IdleProcessing |
---|
| 65 | ; Parameters |
---|
| 66 | ; SS:BP: Ptr to MENU |
---|
| 67 | ; Returns: |
---|
| 68 | ; CF: Set if event processed |
---|
| 69 | ; Cleared if event not processed |
---|
| 70 | ; Corrupts registers: |
---|
| 71 | ; AX, BX, DX |
---|
| 72 | ;-------------------------------------------------------------------- |
---|
[369] | 73 | ALIGN MENU_JUMP_ALIGN |
---|
[41] | 74 | MenuEvent_IdleProcessing: |
---|
[183] | 75 | mov bl, MENUEVENT_IdleProcessing |
---|
[41] | 76 | jmp SHORT MenuEvent_SendFromBX |
---|
[189] | 77 | %endif |
---|
[41] | 78 | |
---|
| 79 | ;-------------------------------------------------------------------- |
---|
| 80 | ; MenuEvent_RefreshTitle |
---|
| 81 | ; MenuEvent_RefreshInformation |
---|
| 82 | ; Parameters |
---|
[48] | 83 | ; SS:BP: Ptr to MENU |
---|
[41] | 84 | ; Cursor will be positioned to beginning of window |
---|
| 85 | ; Returns: |
---|
| 86 | ; CF: Set if event processed |
---|
| 87 | ; Cleared if event not processed |
---|
| 88 | ; Corrupts registers: |
---|
[48] | 89 | ; AX, CX, BX, DX |
---|
[41] | 90 | ;-------------------------------------------------------------------- |
---|
[369] | 91 | ALIGN MENU_JUMP_ALIGN |
---|
[41] | 92 | MenuEvent_RefreshTitle: |
---|
[183] | 93 | mov bl, MENUEVENT_RefreshTitle |
---|
[133] | 94 | SKIP2B cx ; mov cx, <next instruction> |
---|
[48] | 95 | |
---|
[41] | 96 | MenuEvent_RefreshInformation: |
---|
[183] | 97 | mov bl, MENUEVENT_RefreshInformation |
---|
[52] | 98 | mov cx, [bp+MENUINIT.wHighlightedItem] |
---|
[41] | 99 | jmp SHORT MenuEvent_SendFromBX |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | ;-------------------------------------------------------------------- |
---|
| 103 | ; MenuEvent_RefreshItemFromCX |
---|
| 104 | ; Parameters |
---|
| 105 | ; CX: Index of item to refresh |
---|
[48] | 106 | ; SS:BP: Ptr to MENU |
---|
[41] | 107 | ; Cursor has been positioned to the beginning of item line |
---|
| 108 | ; Returns: |
---|
| 109 | ; CF: Set if event processed |
---|
| 110 | ; Cleared if event not processed |
---|
| 111 | ; Corrupts registers: |
---|
| 112 | ; AX, BX, DX |
---|
| 113 | ;-------------------------------------------------------------------- |
---|
[369] | 114 | ALIGN MENU_JUMP_ALIGN |
---|
[41] | 115 | MenuEvent_RefreshItemFromCX: |
---|
[183] | 116 | mov bl, MENUEVENT_RefreshItemFromCX |
---|
[41] | 117 | jmp SHORT MenuEvent_SendFromBX |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | ;-------------------------------------------------------------------- |
---|
| 121 | ; MenuEvent_HighlightItemFromCX |
---|
| 122 | ; Parameters |
---|
| 123 | ; CX: Index of item to highlight |
---|
[48] | 124 | ; SS:BP: Ptr to MENU |
---|
[41] | 125 | ; Returns: |
---|
| 126 | ; Nothing |
---|
| 127 | ; Corrupts registers: |
---|
| 128 | ; AX, BX, DX, SI, DI |
---|
| 129 | ;-------------------------------------------------------------------- |
---|
[369] | 130 | ALIGN MENU_JUMP_ALIGN |
---|
[41] | 131 | MenuEvent_HighlightItemFromCX: |
---|
| 132 | mov dx, cx |
---|
[52] | 133 | xchg dx, [bp+MENUINIT.wHighlightedItem] |
---|
[41] | 134 | push dx |
---|
| 135 | |
---|
[183] | 136 | mov bl, MENUEVENT_ItemHighlightedFromCX |
---|
[41] | 137 | call MenuEvent_SendFromBX |
---|
| 138 | |
---|
| 139 | pop ax |
---|
| 140 | call MenuText_RefreshItemFromAX |
---|
[52] | 141 | mov ax, [bp+MENUINIT.wHighlightedItem] |
---|
[41] | 142 | jmp MenuText_RefreshItemFromAX |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | ;-------------------------------------------------------------------- |
---|
| 146 | ; MenuEvent_KeyStrokeInAX |
---|
| 147 | ; Parameters |
---|
| 148 | ; AL: ASCII character for the key |
---|
| 149 | ; AH: Keyboard library scan code for the key |
---|
[48] | 150 | ; SS:BP: Ptr to MENU |
---|
[41] | 151 | ; Returns: |
---|
| 152 | ; CF: Set if event processed |
---|
| 153 | ; Cleared if event not processed |
---|
| 154 | ; Corrupts registers: |
---|
| 155 | ; AX, BX, DX |
---|
| 156 | ;-------------------------------------------------------------------- |
---|
[505] | 157 | %ifdef MENUEVENT_KeyStrokeInAX |
---|
[369] | 158 | ALIGN MENU_JUMP_ALIGN |
---|
[41] | 159 | MenuEvent_KeyStrokeInAX: |
---|
[183] | 160 | mov bl, MENUEVENT_KeyStrokeInAX |
---|
[133] | 161 | SKIP2B dx ; mov dx, <next instruction> |
---|
[492] | 162 | %endif |
---|
[41] | 163 | |
---|
| 164 | ;-------------------------------------------------------------------- |
---|
| 165 | ; MenuEvent_ItemSelectedFromCX |
---|
| 166 | ; Parameters |
---|
| 167 | ; CX: Index of selected item |
---|
[48] | 168 | ; SS:BP: Ptr to MENU |
---|
[41] | 169 | ; Returns: |
---|
| 170 | ; CF: Set if event processed |
---|
| 171 | ; Cleared if event not processed |
---|
| 172 | ; Corrupts registers: |
---|
| 173 | ; AX, BX, DX |
---|
| 174 | ;-------------------------------------------------------------------- |
---|
| 175 | MenuEvent_ItemSelectedFromCX: |
---|
[183] | 176 | mov bl, MENUEVENT_ItemSelectedFromCX |
---|
[133] | 177 | ; Fall to MenuEvent_SendFromBX |
---|
[41] | 178 | |
---|
| 179 | |
---|
| 180 | ;-------------------------------------------------------------------- |
---|
| 181 | ; MenuEvent_SendFromBX |
---|
| 182 | ; Parameters |
---|
[133] | 183 | ; BL: Menu event to send |
---|
[41] | 184 | ; SS:BP: Ptr to MENU |
---|
| 185 | ; Other registers: Event specific parameters |
---|
| 186 | ; Returns: |
---|
| 187 | ; AX, DX: Event specific return values |
---|
| 188 | ; CF: Set if event processed |
---|
| 189 | ; Cleared if event not processed |
---|
| 190 | ; Corrupts registers: |
---|
| 191 | ; BX |
---|
| 192 | ;-------------------------------------------------------------------- |
---|
[369] | 193 | ALIGN MENU_JUMP_ALIGN |
---|
[41] | 194 | MenuEvent_SendFromBX: |
---|
| 195 | push es |
---|
| 196 | push ds |
---|
| 197 | push di |
---|
| 198 | push si |
---|
| 199 | push cx |
---|
[133] | 200 | xor bh, bh |
---|
[41] | 201 | call [bp+MENU.fnEventHandler] |
---|
| 202 | pop cx |
---|
| 203 | pop si |
---|
| 204 | pop di |
---|
| 205 | pop ds |
---|
| 206 | pop es |
---|
| 207 | ret |
---|