1 | ; File name : DialogString.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 12.8.2010
|
---|
4 | ; Last update : 18.11.2010
|
---|
5 | ; Author : Tomi Tilli
|
---|
6 | ; Description : Displays word input dialog.
|
---|
7 |
|
---|
8 | ; Section containing code
|
---|
9 | SECTION .text
|
---|
10 |
|
---|
11 | ;--------------------------------------------------------------------
|
---|
12 | ; DialogString_GetStringWithIoInDSSI
|
---|
13 | ; Parameters:
|
---|
14 | ; DS:SI: Ptr to STRING_DIALOG_IO
|
---|
15 | ; SS:BP: Ptr to parent MENU
|
---|
16 | ; Returns:
|
---|
17 | ; Nothing
|
---|
18 | ; Corrupts registers:
|
---|
19 | ; AX, BX, CX, DX, SI, DI
|
---|
20 | ;--------------------------------------------------------------------
|
---|
21 | ALIGN JUMP_ALIGN
|
---|
22 | DialogString_GetStringWithIoInDSSI:
|
---|
23 | mov bx, StringEventHandler
|
---|
24 | mov BYTE [si+STRING_DIALOG_IO.bUserCancellation], TRUE
|
---|
25 | jmp Dialog_DisplayWithDialogInputInDSSIandHandlerInBX
|
---|
26 |
|
---|
27 |
|
---|
28 | ;--------------------------------------------------------------------
|
---|
29 | ; StringEventHandler
|
---|
30 | ; Common parameters for all events:
|
---|
31 | ; BX: Menu event (anything from MENUEVENT struct)
|
---|
32 | ; SS:BP: Ptr to DIALOG
|
---|
33 | ; Common return values for all events:
|
---|
34 | ; CF: Set if event processed
|
---|
35 | ; Cleared if event not processed
|
---|
36 | ; Corrupts registers:
|
---|
37 | ; All
|
---|
38 | ;--------------------------------------------------------------------
|
---|
39 | ALIGN JUMP_ALIGN
|
---|
40 | StringEventHandler:
|
---|
41 | jmp [cs:bx+.rgfnEventHandlers]
|
---|
42 |
|
---|
43 |
|
---|
44 | ALIGN JUMP_ALIGN
|
---|
45 | .InitializeMenuinitFromDSSI:
|
---|
46 | xor ax, ax
|
---|
47 | jmp Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX
|
---|
48 |
|
---|
49 |
|
---|
50 | ALIGN JUMP_ALIGN
|
---|
51 | .IdleProcessing:
|
---|
52 | xor cx, cx ; Item 0 is used as input line
|
---|
53 | call MenuText_AdjustDisplayContextForDrawingItemFromCX
|
---|
54 | call GetStringFromUser
|
---|
55 | call MenuInit_CloseMenuWindow
|
---|
56 | stc
|
---|
57 | ret
|
---|
58 |
|
---|
59 |
|
---|
60 | ALIGN WORD_ALIGN
|
---|
61 | .rgfnEventHandlers:
|
---|
62 | istruc MENUEVENT
|
---|
63 | at MENUEVENT.InitializeMenuinitFromDSSI, dw .InitializeMenuinitFromDSSI
|
---|
64 | at MENUEVENT.ExitMenu, dw Dialog_EventExitMenu
|
---|
65 | at MENUEVENT.IdleProcessing, dw .IdleProcessing
|
---|
66 | at MENUEVENT.ItemHighlightedFromCX, dw Dialog_EventNotHandled
|
---|
67 | at MENUEVENT.ItemSelectedFromCX, dw Dialog_EventNotHandled
|
---|
68 | at MENUEVENT.KeyStrokeInAX, dw Dialog_EventNotHandled
|
---|
69 | at MENUEVENT.RefreshTitle, dw Dialog_EventRefreshTitle
|
---|
70 | at MENUEVENT.RefreshInformation, dw Dialog_EventRefreshInformation
|
---|
71 | at MENUEVENT.RefreshItemFromCX, dw Dialog_EventNotHandled
|
---|
72 | iend
|
---|
73 |
|
---|
74 |
|
---|
75 | ;--------------------------------------------------------------------
|
---|
76 | ; GetStringFromUser
|
---|
77 | ; Parameters
|
---|
78 | ; SS:BP: Ptr to DIALOG
|
---|
79 | ; Returns:
|
---|
80 | ; Nothing (User input stored to STRING_DIALOG_IO)
|
---|
81 | ; Corrupts registers:
|
---|
82 | ; AX, CX, DX, SI, DI
|
---|
83 | ;--------------------------------------------------------------------
|
---|
84 | ALIGN JUMP_ALIGN
|
---|
85 | GetStringFromUser:
|
---|
86 | lds si, [bp+DIALOG.fpDialogIO]
|
---|
87 | mov cx, [si+STRING_DIALOG_IO.wBufferSize]
|
---|
88 | les di, [si+STRING_DIALOG_IO.fpReturnBuffer]
|
---|
89 | call .GetCharacterFilterFunctionToDX
|
---|
90 |
|
---|
91 | call Keyboard_ReadUserInputtedStringToESDIWhilePrinting
|
---|
92 | jz SHORT .UserCancellation
|
---|
93 |
|
---|
94 | mov BYTE [si+STRING_DIALOG_IO.bUserCancellation], FALSE
|
---|
95 | mov [si+STRING_DIALOG_IO.wReturnLength], cx
|
---|
96 | .UserCancellation:
|
---|
97 | ret
|
---|
98 |
|
---|
99 | ;--------------------------------------------------------------------
|
---|
100 | ; .GetCharacterFilterFunctionToDX
|
---|
101 | ; Parameters
|
---|
102 | ; DS:SI: Ptr to STRING_DIALOG_IO
|
---|
103 | ; SS:BP: Ptr to DIALOG
|
---|
104 | ; Returns:
|
---|
105 | ; CS:DX: Ptr to character filter function
|
---|
106 | ; Corrupts registers:
|
---|
107 | ; Nothing
|
---|
108 | ;--------------------------------------------------------------------
|
---|
109 | ALIGN JUMP_ALIGN
|
---|
110 | .GetCharacterFilterFunctionToDX:
|
---|
111 | mov dx, [si+STRING_DIALOG_IO.fnCharFilter]
|
---|
112 | test dx, dx
|
---|
113 | jnz SHORT .ReturnFilterFunctionInDX
|
---|
114 | mov dx, Char_CharIsValid
|
---|
115 | ALIGN JUMP_ALIGN, ret
|
---|
116 | .ReturnFilterFunctionInDX:
|
---|
117 | ret
|
---|