source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/Dialog/DialogWord.asm @ 41

Last change on this file since 41 was 41, checked in by aitotat, 14 years ago

Initial commit for Assembly Library.

File size: 3.6 KB
Line 
1; File name     :   DialogWord.asm
2; Project name  :   Assembly Library
3; Created date  :   10.8.2010
4; Last update   :   7.9.2010
5; Author        :   Tomi Tilli
6; Description   :   Displays word input dialog.
7
8; Section containing code
9SECTION .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;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
22DialogWord_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;--------------------------------------------------------------------
39ALIGN JUMP_ALIGN
40WordEventHandler:
41    jmp     [cs:bx+.rgfnEventHandlers]
42
43
44ALIGN JUMP_ALIGN
45.IdleProcessing:
46    xor     ax, ax                      ; Item 0 is used as input line
47    call    MenuText_AdjustDisplayContextForDrawingItemFromAX
48    call    GetWordFromUser
49    call    MenuInit_CloseMenuWindow
50    stc
51    ret
52
53
54ALIGN WORD_ALIGN
55.rgfnEventHandlers:
56istruc 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
66iend
67
68
69;--------------------------------------------------------------------
70; GetWordFromUser
71;   Parameters
72;       SS:BP:  Ptr to DIALOG
73;   Returns:
74;       Nothing (User input stored to WORD_DIALOG_IO)
75;   Corrupts registers:
76;       AX, BX, DX, SI, DI
77;--------------------------------------------------------------------
78ALIGN JUMP_ALIGN
79GetWordFromUser:
80    lds     si, [bp+DIALOG.fpDialogIO]
81    eMOVZX  bx, BYTE [si+WORD_DIALOG_IO.bNumericBase]
82ALIGN JUMP_ALIGN
83.GetUserInputIntilValidOrCancelled:
84    call    Keyboard_ReadUserInputtedWordWhilePrinting
85    jz      SHORT .UserCancellation
86
87    cmp     ax, [si+WORD_DIALOG_IO.wMin]
88    jb      SHORT .InputtedWordNotInRange
89    cmp     ax, [si+WORD_DIALOG_IO.wMax]
90    ja      SHORT .InputtedWordNotInRange
91
92    mov     [si+WORD_DIALOG_IO.bUserCancellation], bh   ; Zero = FALSE
93    mov     [si+WORD_DIALOG_IO.wReturnWord], ax
94.UserCancellation:
95    ret
96
97.InputtedWordNotInRange:
98    call    Keyboard_PlayBellForUnwantedKeystroke
99    call    .ClearInputtedWordFromDialog
100    jmp     SHORT .GetUserInputIntilValidOrCancelled
101
102;--------------------------------------------------------------------
103; .ClearInputtedWordFromDialog
104;   Parameters
105;       SS:BP:  Ptr to DIALOG
106;   Returns:
107;       Nothing
108;   Corrupts registers:
109;       AX, CX, DX, DI
110;--------------------------------------------------------------------
111ALIGN JUMP_ALIGN
112.ClearInputtedWordFromDialog:
113    CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
114    xchg    dx, ax
115
116    mov     al, ' '
117    mov     cx, 5
118    CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
119
120    xchg    ax, dx
121    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
122    ret
Note: See TracBrowser for help on using the repository browser.