1 | ; File name : DialogString.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 12.8.2010
|
---|
4 | ; Last update : 7.9.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 | .IdleProcessing:
|
---|
46 | xor ax, ax ; Item 0 is used as input line
|
---|
47 | call MenuText_AdjustDisplayContextForDrawingItemFromAX
|
---|
48 | call GetStringFromUser
|
---|
49 | call MenuInit_CloseMenuWindow
|
---|
50 | stc
|
---|
51 | ret
|
---|
52 |
|
---|
53 |
|
---|
54 | ALIGN WORD_ALIGN
|
---|
55 | .rgfnEventHandlers:
|
---|
56 | istruc MENUEVENT
|
---|
57 | at MENUEVENT.InitializeMenuinitFromDSSI, dw Dialog_EventInitializeMenuinitFromDSSIforSingleItem
|
---|
58 | at MENUEVENT.ExitMenu, dw Dialog_EventNotHandled
|
---|
59 | at MENUEVENT.IdleProcessing, dw .IdleProcessing
|
---|
60 | at MENUEVENT.ItemHighlightedFromCX, dw Dialog_EventNotHandled
|
---|
61 | at MENUEVENT.ItemSelectedFromCX, dw Dialog_EventNotHandled
|
---|
62 | at MENUEVENT.KeyStrokeInAX, dw Dialog_EventNotHandled
|
---|
63 | at MENUEVENT.RefreshTitle, dw Dialog_EventRefreshTitle
|
---|
64 | at MENUEVENT.RefreshInformation, dw Dialog_EventRefreshInformation
|
---|
65 | at MENUEVENT.RefreshItemFromCX, dw Dialog_EventNotHandled
|
---|
66 | iend
|
---|
67 |
|
---|
68 |
|
---|
69 | ;--------------------------------------------------------------------
|
---|
70 | ; GetStringFromUser
|
---|
71 | ; Parameters
|
---|
72 | ; SS:BP: Ptr to DIALOG
|
---|
73 | ; Returns:
|
---|
74 | ; Nothing (User input stored to STRING_DIALOG_IO)
|
---|
75 | ; Corrupts registers:
|
---|
76 | ; AX, CX, DX, SI, DI
|
---|
77 | ;--------------------------------------------------------------------
|
---|
78 | ALIGN JUMP_ALIGN
|
---|
79 | GetStringFromUser:
|
---|
80 | lds si, [bp+DIALOG.fpDialogIO]
|
---|
81 | mov cx, [si+STRING_DIALOG_IO.wBufferSize]
|
---|
82 | les di, [si+STRING_DIALOG_IO.fpReturnBuffer]
|
---|
83 | call .GetCharacterFilterFunctionToDX
|
---|
84 |
|
---|
85 | call Keyboard_ReadUserInputtedStringToESDIWhilePrinting
|
---|
86 | jz SHORT .UserCancellation
|
---|
87 |
|
---|
88 | mov BYTE [si+STRING_DIALOG_IO.bUserCancellation], FALSE
|
---|
89 | mov [si+STRING_DIALOG_IO.wReturnLength], cx
|
---|
90 | .UserCancellation:
|
---|
91 | ret
|
---|
92 |
|
---|
93 | ;--------------------------------------------------------------------
|
---|
94 | ; .GetCharacterFilterFunctionToDX
|
---|
95 | ; Parameters
|
---|
96 | ; DS:SI: Ptr to STRING_DIALOG_IO
|
---|
97 | ; SS:BP: Ptr to DIALOG
|
---|
98 | ; Returns:
|
---|
99 | ; CS:DX: Ptr to character filter function
|
---|
100 | ; Corrupts registers:
|
---|
101 | ; Nothing
|
---|
102 | ;--------------------------------------------------------------------
|
---|
103 | ALIGN JUMP_ALIGN
|
---|
104 | .GetCharacterFilterFunctionToDX:
|
---|
105 | mov dx, [si+STRING_DIALOG_IO.fnCharFilter]
|
---|
106 | test dx, dx
|
---|
107 | jnz SHORT .ReturnFilterFunctionInDX
|
---|
108 | mov dx, Char_CharIsValid
|
---|
109 | ALIGN JUMP_ALIGN, ret
|
---|
110 | .ReturnFilterFunctionInDX:
|
---|
111 | ret
|
---|