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

Last change on this file since 376 was 376, checked in by gregli@…, 12 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 4.4 KB
Line 
1; File name     :   DialogWord.asm
2; Project name  :   Assembly Library
3; Created date  :   10.8.2010
4; Last update   :   18.11.2010
5; Author        :   Tomi Tilli
6; Description   :   Displays word input dialog.
7
8;
9; XTIDE Universal BIOS and Associated Tools 
10; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
11;
12; This program is free software; you can redistribute it and/or modify
13; it under the terms of the GNU General Public License as published by
14; the Free Software Foundation; either version 2 of the License, or
15; (at your option) any later version.
16; 
17; This program is distributed in the hope that it will be useful,
18; but WITHOUT ANY WARRANTY; without even the implied warranty of
19; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20; GNU General Public License for more details.     
21; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22;
23       
24
25; Section containing code
26SECTION .text
27
28;--------------------------------------------------------------------
29; DialogWord_GetWordWithIoInDSSI
30;   Parameters:
31;       DS:SI:  Ptr to WORD_DIALOG_IO
32;       SS:BP:  Ptr to parent MENU
33;   Returns:
34;       Nothing
35;   Corrupts registers:
36;       AX, BX, CX, DX, SI, DI
37;--------------------------------------------------------------------
38ALIGN JUMP_ALIGN
39DialogWord_GetWordWithIoInDSSI:
40    mov     bx, WordEventHandler
41    mov     BYTE [si+WORD_DIALOG_IO.bUserCancellation], TRUE
42    jmp     Dialog_DisplayWithDialogInputInDSSIandHandlerInBX
43
44
45;--------------------------------------------------------------------
46; WordEventHandler
47;   Common parameters for all events:
48;       BX:         Menu event (anything from MENUEVENT struct)
49;       SS:BP:      Ptr to DIALOG
50;   Common return values for all events:
51;       CF:         Set if event processed
52;                   Cleared if event not processed
53;   Corrupts registers:
54;       All
55;--------------------------------------------------------------------
56ALIGN JUMP_ALIGN
57WordEventHandler:
58    jmp     [cs:bx+.rgfnEventHandlers]
59
60
61ALIGN JUMP_ALIGN
62.InitializeMenuinitFromDSSI:
63    xor     ax, ax
64    jmp     Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX
65
66
67ALIGN JUMP_ALIGN
68.IdleProcessing:
69    xor     cx, cx                      ; Item 0 is used as input line
70    call    MenuText_AdjustDisplayContextForDrawingItemFromCX
71    call    GetWordFromUser
72    call    MenuInit_CloseMenuWindow
73    stc
74    ret
75
76
77ALIGN WORD_ALIGN
78.rgfnEventHandlers:
79istruc MENUEVENT
80    at  MENUEVENT.InitializeMenuinitFromDSSI,   dw  .InitializeMenuinitFromDSSI
81    at  MENUEVENT.ExitMenu,                     dw  Dialog_EventExitMenu
82    at  MENUEVENT.IdleProcessing,               dw  .IdleProcessing
83    at  MENUEVENT.ItemHighlightedFromCX,        dw  Dialog_EventNotHandled
84    at  MENUEVENT.ItemSelectedFromCX,           dw  Dialog_EventNotHandled
85    at  MENUEVENT.KeyStrokeInAX,                dw  Dialog_EventNotHandled
86    at  MENUEVENT.RefreshTitle,                 dw  Dialog_EventRefreshTitle
87    at  MENUEVENT.RefreshInformation,           dw  Dialog_EventRefreshInformation
88    at  MENUEVENT.RefreshItemFromCX,            dw  Dialog_EventNotHandled
89iend
90
91
92;--------------------------------------------------------------------
93; GetWordFromUser
94;   Parameters
95;       SS:BP:  Ptr to DIALOG
96;   Returns:
97;       Nothing (User input stored to WORD_DIALOG_IO)
98;   Corrupts registers:
99;       AX, BX, DX, SI, DI
100;--------------------------------------------------------------------
101ALIGN JUMP_ALIGN
102GetWordFromUser:
103    lds     si, [bp+DIALOG.fpDialogIO]
104    eMOVZX  bx, [si+WORD_DIALOG_IO.bNumericBase]
105ALIGN JUMP_ALIGN
106.GetUserInputIntilValidOrCancelled:
107    call    Keyboard_ReadUserInputtedWordWhilePrinting
108    jz      SHORT .UserCancellation
109
110    cmp     ax, [si+WORD_DIALOG_IO.wMin]
111    jb      SHORT .InputtedWordNotInRange
112    cmp     ax, [si+WORD_DIALOG_IO.wMax]
113    ja      SHORT .InputtedWordNotInRange
114
115    mov     [si+WORD_DIALOG_IO.bUserCancellation], bh   ; Zero = FALSE
116    mov     [si+WORD_DIALOG_IO.wReturnWord], ax
117.UserCancellation:
118    ret
119
120.InputtedWordNotInRange:
121    call    Keyboard_PlayBellForUnwantedKeystroke
122    call    .ClearInputtedWordFromDialog
123    jmp     SHORT .GetUserInputIntilValidOrCancelled
124
125;--------------------------------------------------------------------
126; .ClearInputtedWordFromDialog
127;   Parameters
128;       SS:BP:  Ptr to DIALOG
129;   Returns:
130;       Nothing
131;   Corrupts registers:
132;       AX, CX, DX, DI
133;--------------------------------------------------------------------
134ALIGN JUMP_ALIGN
135.ClearInputtedWordFromDialog:
136    CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
137    xchg    dx, ax
138
139    mov     al, ' '
140    mov     cx, 5
141    CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
142
143    xchg    ax, dx
144    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
145    ret
Note: See TracBrowser for help on using the repository browser.