source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/Dialog/DialogString.asm@ 372

Last change on this file since 372 was 58, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:

  • Exiting menu with ESC can now be canceled.
File size: 3.5 KB
RevLine 
[41]1; File name : DialogString.asm
2; Project name : Assembly Library
3; Created date : 12.8.2010
[58]4; Last update : 18.11.2010
[41]5; Author : Tomi Tilli
6; Description : Displays word input dialog.
7
8; Section containing code
9SECTION .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;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
22DialogString_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;--------------------------------------------------------------------
39ALIGN JUMP_ALIGN
40StringEventHandler:
41 jmp [cs:bx+.rgfnEventHandlers]
42
43
44ALIGN JUMP_ALIGN
[52]45.InitializeMenuinitFromDSSI:
46 xor ax, ax
47 jmp Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX
48
49
50ALIGN JUMP_ALIGN
[41]51.IdleProcessing:
[52]52 xor cx, cx ; Item 0 is used as input line
53 call MenuText_AdjustDisplayContextForDrawingItemFromCX
[41]54 call GetStringFromUser
55 call MenuInit_CloseMenuWindow
56 stc
57 ret
58
59
60ALIGN WORD_ALIGN
61.rgfnEventHandlers:
62istruc MENUEVENT
[52]63 at MENUEVENT.InitializeMenuinitFromDSSI, dw .InitializeMenuinitFromDSSI
[58]64 at MENUEVENT.ExitMenu, dw Dialog_EventExitMenu
[41]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
72iend
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;--------------------------------------------------------------------
84ALIGN JUMP_ALIGN
85GetStringFromUser:
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;--------------------------------------------------------------------
109ALIGN 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
115ALIGN JUMP_ALIGN, ret
116.ReturnFilterFunctionInDX:
117 ret
Note: See TracBrowser for help on using the repository browser.