1 | ; File name : DialogWord.asm |
---|
2 | ; Project name : Assembly Library |
---|
3 | ; Created date : 10.8.2010 |
---|
4 | ; Last update : 12.10.2010 |
---|
5 | ; Author : Tomi Tilli |
---|
6 | ; Description : Displays word input dialog. |
---|
7 | |
---|
8 | ; Section containing code |
---|
9 | SECTION .text |
---|
10 | |
---|
11 | ;-------------------------------------------------------------------- |
---|
12 | ; DialogWord_GetWordWithIoInDSSI |
---|
13 | ; Parameters: |
---|
14 | ; DS:SI: Ptr to WORD_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 | DialogWord_GetWordWithIoInDSSI: |
---|
23 | mov bx, WordEventHandler |
---|
24 | mov BYTE [si+WORD_DIALOG_IO.bUserCancellation], TRUE |
---|
25 | jmp Dialog_DisplayWithDialogInputInDSSIandHandlerInBX |
---|
26 | |
---|
27 | |
---|
28 | ;-------------------------------------------------------------------- |
---|
29 | ; WordEventHandler |
---|
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 | WordEventHandler: |
---|
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 GetWordFromUser |
---|
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_EventNotHandled |
---|
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 | ; GetWordFromUser |
---|
77 | ; Parameters |
---|
78 | ; SS:BP: Ptr to DIALOG |
---|
79 | ; Returns: |
---|
80 | ; Nothing (User input stored to WORD_DIALOG_IO) |
---|
81 | ; Corrupts registers: |
---|
82 | ; AX, BX, DX, SI, DI |
---|
83 | ;-------------------------------------------------------------------- |
---|
84 | ALIGN JUMP_ALIGN |
---|
85 | GetWordFromUser: |
---|
86 | lds si, [bp+DIALOG.fpDialogIO] |
---|
87 | eMOVZX bx, BYTE [si+WORD_DIALOG_IO.bNumericBase] |
---|
88 | ALIGN JUMP_ALIGN |
---|
89 | .GetUserInputIntilValidOrCancelled: |
---|
90 | call Keyboard_ReadUserInputtedWordWhilePrinting |
---|
91 | jz SHORT .UserCancellation |
---|
92 | |
---|
93 | cmp ax, [si+WORD_DIALOG_IO.wMin] |
---|
94 | jb SHORT .InputtedWordNotInRange |
---|
95 | cmp ax, [si+WORD_DIALOG_IO.wMax] |
---|
96 | ja SHORT .InputtedWordNotInRange |
---|
97 | |
---|
98 | mov [si+WORD_DIALOG_IO.bUserCancellation], bh ; Zero = FALSE |
---|
99 | mov [si+WORD_DIALOG_IO.wReturnWord], ax |
---|
100 | .UserCancellation: |
---|
101 | ret |
---|
102 | |
---|
103 | .InputtedWordNotInRange: |
---|
104 | call Keyboard_PlayBellForUnwantedKeystroke |
---|
105 | call .ClearInputtedWordFromDialog |
---|
106 | jmp SHORT .GetUserInputIntilValidOrCancelled |
---|
107 | |
---|
108 | ;-------------------------------------------------------------------- |
---|
109 | ; .ClearInputtedWordFromDialog |
---|
110 | ; Parameters |
---|
111 | ; SS:BP: Ptr to DIALOG |
---|
112 | ; Returns: |
---|
113 | ; Nothing |
---|
114 | ; Corrupts registers: |
---|
115 | ; AX, CX, DX, DI |
---|
116 | ;-------------------------------------------------------------------- |
---|
117 | ALIGN JUMP_ALIGN |
---|
118 | .ClearInputtedWordFromDialog: |
---|
119 | CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX |
---|
120 | xchg dx, ax |
---|
121 | |
---|
122 | mov al, ' ' |
---|
123 | mov cx, 5 |
---|
124 | CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX |
---|
125 | |
---|
126 | xchg ax, dx |
---|
127 | CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX |
---|
128 | ret |
---|