[41] | 1 | ; Project name : Assembly Library |
---|
| 2 | ; Description : Common functions for many dialogs. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
| 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. |
---|
| 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. |
---|
| 12 | ; |
---|
| 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 |
---|
| 16 | ; GNU General Public License for more details. |
---|
| 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 18 | ; |
---|
| 19 | |
---|
| 20 | |
---|
[41] | 21 | ; Section containing code |
---|
| 22 | SECTION .text |
---|
| 23 | |
---|
| 24 | ;-------------------------------------------------------------------- |
---|
| 25 | ; Dialog_DisplayWithDialogInputInDSSIandHandlerInBX |
---|
| 26 | ; Parameters: |
---|
| 27 | ; BX: Offset to menu event handler |
---|
| 28 | ; DX:AX: Optional user data |
---|
| 29 | ; DS:SI: Ptr to DIALOG_INPUT |
---|
| 30 | ; SS:BP: Ptr to parent MENU |
---|
| 31 | ; Returns: |
---|
| 32 | ; AX: Selected item |
---|
| 33 | ; Corrupts registers: |
---|
| 34 | ; BX, CX, DX, SI, DI |
---|
| 35 | ;-------------------------------------------------------------------- |
---|
| 36 | ALIGN JUMP_ALIGN |
---|
| 37 | Dialog_DisplayWithDialogInputInDSSIandHandlerInBX: |
---|
| 38 | push es |
---|
| 39 | push ds |
---|
| 40 | mov di, bp ; Backup parent MENU |
---|
[50] | 41 | mov cx, DIALOG_size |
---|
| 42 | eENTER_STRUCT cx |
---|
[41] | 43 | |
---|
[46] | 44 | call Memory_ZeroSSBPwithSizeInCX |
---|
[41] | 45 | mov [bp+DIALOG.fpDialogIO], si |
---|
| 46 | mov [bp+DIALOG.fpDialogIO+2], ds |
---|
| 47 | mov [bp+DIALOG.pParentMenu], di |
---|
| 48 | |
---|
| 49 | call MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX |
---|
| 50 | call Dialog_RemoveFromScreenByRedrawingParentMenu |
---|
| 51 | call Keyboard_RemoveAllKeystrokesFromBuffer |
---|
| 52 | |
---|
[52] | 53 | mov ax, [bp+MENUINIT.wHighlightedItem] |
---|
[41] | 54 | eLEAVE_STRUCT DIALOG_size |
---|
| 55 | pop ds |
---|
| 56 | pop es |
---|
| 57 | ret |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | ;-------------------------------------------------------------------- |
---|
| 61 | ; Dialog_EventNotHandled |
---|
| 62 | ; Parameters: |
---|
| 63 | ; BX: Menu event (anything from MENUEVENT struct) |
---|
| 64 | ; SS:BP: Ptr to DIALOG |
---|
| 65 | ; Returns: |
---|
| 66 | ; CF: Cleared since event not processed |
---|
| 67 | ; Corrupts registers: |
---|
| 68 | ; Nothing |
---|
| 69 | ;-------------------------------------------------------------------- |
---|
| 70 | ALIGN JUMP_ALIGN |
---|
| 71 | Dialog_EventNotHandled: |
---|
| 72 | clc |
---|
| 73 | ret |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | ;-------------------------------------------------------------------- |
---|
| 77 | ; Dialog_EventAnyThatClosesDialog |
---|
[58] | 78 | ; Dialog_EventExitMenu |
---|
[41] | 79 | ; Parameters: |
---|
| 80 | ; SS:BP: Ptr to DIALOG |
---|
| 81 | ; Returns: |
---|
| 82 | ; CF: Set since event processed |
---|
| 83 | ; Corrupts registers: |
---|
| 84 | ; Nothing |
---|
| 85 | ;-------------------------------------------------------------------- |
---|
| 86 | ALIGN JUMP_ALIGN |
---|
| 87 | Dialog_EventAnyThatClosesDialog: |
---|
| 88 | call MenuInit_CloseMenuWindow |
---|
[58] | 89 | ALIGN JUMP_ALIGN |
---|
| 90 | Dialog_EventExitMenu: |
---|
[41] | 91 | stc |
---|
| 92 | ret |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | ;-------------------------------------------------------------------- |
---|
[52] | 96 | ; Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX |
---|
[41] | 97 | ; Parameters: |
---|
[52] | 98 | ; AX: Index of highlighted item |
---|
[41] | 99 | ; DS:SI: Ptr to MENUINIT struct to initialize |
---|
| 100 | ; SS:BP: Ptr to DIALOG |
---|
| 101 | ; Returns: |
---|
| 102 | ; DS:SI: Ptr to initialized MENUINIT struct |
---|
| 103 | ; CF: Set since event processed |
---|
| 104 | ;-------------------------------------------------------------------- |
---|
| 105 | ALIGN JUMP_ALIGN |
---|
[52] | 106 | Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX: |
---|
[41] | 107 | les di, [bp+DIALOG.fpDialogIO] |
---|
| 108 | mov WORD [es:di+DIALOG_INPUT.fszItems], g_szSingleItem |
---|
| 109 | mov [es:di+DIALOG_INPUT.fszItems+2], cs |
---|
[52] | 110 | ; Fall to Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX |
---|
[41] | 111 | |
---|
| 112 | ;-------------------------------------------------------------------- |
---|
[52] | 113 | ; Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX |
---|
[41] | 114 | ; Parameters: |
---|
[52] | 115 | ; AX: Index of highlighted item |
---|
[41] | 116 | ; DS:SI: Ptr to MENUINIT struct to initialize |
---|
| 117 | ; SS:BP: Ptr to DIALOG |
---|
| 118 | ; Returns: |
---|
| 119 | ; DS:SI: Ptr to initialized MENUINIT struct |
---|
| 120 | ; CF: Set since event processed |
---|
| 121 | ;-------------------------------------------------------------------- |
---|
| 122 | ALIGN JUMP_ALIGN |
---|
[52] | 123 | Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX: |
---|
| 124 | mov [bp+MENUINIT.wHighlightedItem], ax |
---|
[41] | 125 | les di, [bp+DIALOG.fpDialogIO] |
---|
| 126 | call .GetWidthBasedOnParentMenuToAL |
---|
| 127 | mov [bp+MENUINIT.bWidth], al |
---|
| 128 | |
---|
| 129 | lds si, [es:di+DIALOG_INPUT.fszTitle] |
---|
[52] | 130 | call ItemLineSplitter_GetLinesToAXforStringInDSSI |
---|
[41] | 131 | mov [bp+MENUINIT.bTitleLines], al |
---|
| 132 | |
---|
| 133 | lds si, [es:di+DIALOG_INPUT.fszItems] |
---|
[52] | 134 | call ItemLineSplitter_GetLinesToAXforStringInDSSI |
---|
[41] | 135 | mov [bp+MENUINIT.wItems], ax |
---|
| 136 | |
---|
| 137 | lds si, [es:di+DIALOG_INPUT.fszInfo] |
---|
[52] | 138 | call ItemLineSplitter_GetLinesToAXforStringInDSSI |
---|
[41] | 139 | mov [bp+MENUINIT.bInfoLines], al |
---|
| 140 | |
---|
| 141 | call .GetHeightToAH ; Line counts are required |
---|
| 142 | mov [bp+MENUINIT.bHeight], ah |
---|
| 143 | stc |
---|
| 144 | ret |
---|
| 145 | |
---|
[181] | 146 | |
---|
[41] | 147 | ;-------------------------------------------------------------------- |
---|
| 148 | ; .GetWidthBasedOnParentMenuToAL |
---|
| 149 | ; Parameters: |
---|
| 150 | ; SS:BP: Ptr to DIALOG |
---|
| 151 | ; Returns: |
---|
| 152 | ; AX: Width for dialog |
---|
| 153 | ; Corrupts registers: |
---|
| 154 | ; BX |
---|
| 155 | ;-------------------------------------------------------------------- |
---|
| 156 | ALIGN JUMP_ALIGN |
---|
| 157 | .GetWidthBasedOnParentMenuToAL: |
---|
| 158 | mov bx, [bp+DIALOG.pParentMenu] |
---|
| 159 | mov al, [ss:bx+MENUINIT.bWidth] |
---|
| 160 | sub al, DIALOG_DELTA_WIDTH_FROM_PARENT |
---|
[181] | 161 | cmp al, DIALOG_MAX_WIDTH |
---|
| 162 | jb .ALlessThanDIALOG_MAX_WIDTH |
---|
| 163 | mov al, DIALOG_MAX_WIDTH |
---|
| 164 | ALIGN JUMP_ALIGN, ret |
---|
| 165 | .ALlessThanDIALOG_MAX_WIDTH: |
---|
[41] | 166 | ret |
---|
| 167 | |
---|
[181] | 168 | |
---|
[41] | 169 | ;-------------------------------------------------------------------- |
---|
| 170 | ; .GetHeightToAH |
---|
| 171 | ; Parameters: |
---|
| 172 | ; SS:BP: Ptr to DIALOG |
---|
| 173 | ; Returns: |
---|
| 174 | ; AH: Height for dialog |
---|
| 175 | ; Corrupts registers: |
---|
| 176 | ; AL, BX, DI |
---|
| 177 | ;-------------------------------------------------------------------- |
---|
| 178 | ALIGN JUMP_ALIGN |
---|
| 179 | .GetHeightToAH: |
---|
| 180 | CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH |
---|
| 181 | xchg bx, ax |
---|
| 182 | mov ah, [bp+MENUINIT.bTitleLines] |
---|
| 183 | add ah, [bp+MENUINIT.wItems] |
---|
| 184 | add ah, [bp+MENUINIT.bInfoLines] |
---|
| 185 | add ah, BYTE MENU_VERTICAL_BORDER_LINES |
---|
[181] | 186 | cmp ah, bh |
---|
| 187 | jb .AHlessThanBH |
---|
| 188 | xchg bx, ax |
---|
| 189 | ALIGN JUMP_ALIGN |
---|
| 190 | .AHlessThanBH: |
---|
| 191 | cmp ah, DIALOG_MAX_HEIGHT |
---|
| 192 | jb .AHlessThanDIALOG_MAX_HEIGHT |
---|
| 193 | mov ah, DIALOG_MAX_HEIGHT |
---|
| 194 | ALIGN JUMP_ALIGN, ret |
---|
| 195 | .AHlessThanDIALOG_MAX_HEIGHT: |
---|
[41] | 196 | ret |
---|
| 197 | |
---|
| 198 | |
---|
| 199 | ;-------------------------------------------------------------------- |
---|
| 200 | ; Dialog_EventRefreshTitle |
---|
| 201 | ; Dialog_EventRefreshInformation |
---|
| 202 | ; Parameters: |
---|
| 203 | ; SS:BP: Ptr to DIALOG |
---|
| 204 | ; Returns: |
---|
| 205 | ; CF: Set since event processed |
---|
| 206 | ;-------------------------------------------------------------------- |
---|
| 207 | ALIGN JUMP_ALIGN |
---|
| 208 | Dialog_EventRefreshTitle: |
---|
| 209 | lds si, [bp+DIALOG.fpDialogIO] |
---|
[52] | 210 | lds si, [si+DIALOG_INPUT.fszTitle] |
---|
| 211 | jmp SHORT PrintTitleOrInfoLine |
---|
[41] | 212 | |
---|
| 213 | ALIGN JUMP_ALIGN |
---|
| 214 | Dialog_EventRefreshInformation: |
---|
| 215 | lds si, [bp+DIALOG.fpDialogIO] |
---|
[52] | 216 | lds si, [si+DIALOG_INPUT.fszInfo] |
---|
| 217 | ; Fall to PrintTitleOrInfoLine |
---|
[41] | 218 | |
---|
| 219 | ALIGN JUMP_ALIGN |
---|
[52] | 220 | PrintTitleOrInfoLine: |
---|
| 221 | mov bx, ds |
---|
| 222 | CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI |
---|
[41] | 223 | stc |
---|
| 224 | ret |
---|
| 225 | |
---|
| 226 | |
---|
| 227 | ;-------------------------------------------------------------------- |
---|
| 228 | ; Dialog_EventRefreshItemFromCX |
---|
| 229 | ; Parameters: |
---|
| 230 | ; CX: Item to refresh |
---|
| 231 | ; SS:BP: Ptr to DIALOG |
---|
| 232 | ; Returns: |
---|
| 233 | ; CF: Set since event processed |
---|
| 234 | ;-------------------------------------------------------------------- |
---|
| 235 | ALIGN JUMP_ALIGN |
---|
| 236 | Dialog_EventRefreshItemFromCX: |
---|
| 237 | lds si, [bp+DIALOG.fpDialogIO] |
---|
[52] | 238 | lds si, [si+DIALOG_INPUT.fszItems] |
---|
| 239 | call ItemLineSplitter_GetLineToDSSIandLengthToCXfromStringInDSSIwithIndexInCX |
---|
| 240 | jnc SHORT .LineNotFound |
---|
| 241 | |
---|
| 242 | mov bx, ds |
---|
| 243 | CALL_DISPLAY_LIBRARY PrintCharBufferFromBXSIwithLengthInCX |
---|
| 244 | .LineNotFound: |
---|
[41] | 245 | stc |
---|
| 246 | ret |
---|
| 247 | |
---|
| 248 | |
---|
| 249 | ;-------------------------------------------------------------------- |
---|
| 250 | ; Dialog_RemoveFromScreenByRedrawingParentMenu |
---|
| 251 | ; Parameters: |
---|
| 252 | ; SS:BP: Ptr to DIALOG |
---|
| 253 | ; Returns: |
---|
| 254 | ; Nothing |
---|
| 255 | ; Corrupts: |
---|
| 256 | ; AX, BX, CX, DX, SI, DI |
---|
| 257 | ;-------------------------------------------------------------------- |
---|
| 258 | ALIGN JUMP_ALIGN |
---|
| 259 | Dialog_RemoveFromScreenByRedrawingParentMenu: |
---|
| 260 | mov si, [bp+DIALOG.pParentMenu] ; SS:SI points to parent MENU |
---|
| 261 | call .GetParentTitleBorderCoordinatesToDX |
---|
| 262 | call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX |
---|
| 263 | cmp ah, dh ; Dialog taller than parent? |
---|
[162] | 264 | jnb SHORT .RedrawWholeParentWindow |
---|
| 265 | ; Fall to .RedrawDialogAreaAndWholeParentWindow |
---|
[41] | 266 | |
---|
| 267 | ;-------------------------------------------------------------------- |
---|
| 268 | ; .RedrawDialogAreaAndWholeParentWindow |
---|
| 269 | ; .RedrawWholeParentWindow |
---|
| 270 | ; Parameters: |
---|
| 271 | ; SS:SI: Ptr to parent MENU |
---|
| 272 | ; SS:BP: Ptr to DIALOG |
---|
| 273 | ; Returns: |
---|
| 274 | ; Nothing |
---|
| 275 | ; Corrupts: |
---|
| 276 | ; AX, BX, CX, DX, SI, DI |
---|
| 277 | ;-------------------------------------------------------------------- |
---|
| 278 | .RedrawDialogAreaAndWholeParentWindow: |
---|
[48] | 279 | push si |
---|
| 280 | call MenuBorders_AdjustDisplayContextForDrawingBorders |
---|
| 281 | pop si |
---|
[44] | 282 | mov al, SCREEN_BACKGROUND_ATTRIBUTE |
---|
[41] | 283 | CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL |
---|
| 284 | mov ax, [bp+MENUINIT.wWidthAndHeight] |
---|
| 285 | CALL_DISPLAY_LIBRARY ClearAreaWithHeightInAHandWidthInAL |
---|
| 286 | ; Fall to .RedrawWholeParentWindow |
---|
| 287 | |
---|
| 288 | ALIGN JUMP_ALIGN |
---|
| 289 | .RedrawWholeParentWindow: |
---|
| 290 | push bp |
---|
| 291 | mov bp, si |
---|
| 292 | call MenuInit_RefreshMenuWindow |
---|
| 293 | pop bp |
---|
| 294 | ret |
---|
[162] | 295 | |
---|
| 296 | ;-------------------------------------------------------------------- |
---|
| 297 | ; .GetParentTitleBorderCoordinatesToDX |
---|
| 298 | ; Parameters: |
---|
| 299 | ; SS:SI: Ptr to parent MENU |
---|
| 300 | ; SS:BP: Ptr to DIALOG |
---|
| 301 | ; Returns: |
---|
| 302 | ; DL: Parent border column (X) |
---|
| 303 | ; DH: Parent border row (Y) |
---|
| 304 | ; Corrupts: |
---|
| 305 | ; AX |
---|
| 306 | ;-------------------------------------------------------------------- |
---|
| 307 | ALIGN JUMP_ALIGN |
---|
| 308 | .GetParentTitleBorderCoordinatesToDX: |
---|
| 309 | xchg si, bp |
---|
| 310 | call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX |
---|
| 311 | xchg bp, si |
---|
| 312 | xchg dx, ax |
---|
| 313 | ret |
---|