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