1 | ; File name : MenuInit.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 13.7.2010
|
---|
4 | ; Last update : 16.9.2010
|
---|
5 | ; Author : Tomi Tilli
|
---|
6 | ; Description : Functions for initializing menu system.
|
---|
7 |
|
---|
8 | ; Section containing code
|
---|
9 | SECTION .text
|
---|
10 |
|
---|
11 | ;--------------------------------------------------------------------
|
---|
12 | ; MenuInit_DisplayMenuWithHandlerInBXandUserDataInDXAX
|
---|
13 | ; Parameters
|
---|
14 | ; DX:AX: User specified data
|
---|
15 | ; BX: Menu event handler
|
---|
16 | ; Returns:
|
---|
17 | ; AX: Index of selected item or NO_ITEM_SELECTED
|
---|
18 | ; Corrupts registers:
|
---|
19 | ; All except segments
|
---|
20 | ;--------------------------------------------------------------------
|
---|
21 | ALIGN JUMP_ALIGN
|
---|
22 | MenuInit_DisplayMenuWithHandlerInBXandUserDataInDXAX:
|
---|
23 | push es
|
---|
24 | push ds
|
---|
25 | LOAD_BDA_SEGMENT_TO ds, cx
|
---|
26 | push WORD [BDA.wVidCurShape]
|
---|
27 | eENTER_STRUCT MENU_size
|
---|
28 |
|
---|
29 | mov cx, MENU_size / 2
|
---|
30 | call Memory_ZeroSSBPbyWordsInCX
|
---|
31 | call MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX
|
---|
32 | mov ax, [bp+MENU.wHighlightedItem]
|
---|
33 |
|
---|
34 | eLEAVE_STRUCT MENU_size
|
---|
35 | pop ax
|
---|
36 | CALL_DISPLAY_LIBRARY SetCursorShapeFromAX
|
---|
37 | pop ds
|
---|
38 | pop es
|
---|
39 | ret
|
---|
40 |
|
---|
41 |
|
---|
42 | ;--------------------------------------------------------------------
|
---|
43 | ; MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX
|
---|
44 | ; Parameters
|
---|
45 | ; DX:AX: User specified data
|
---|
46 | ; BX: Menu event handler
|
---|
47 | ; SS:BP: Ptr to MENU
|
---|
48 | ; Returns:
|
---|
49 | ; Nothing
|
---|
50 | ; Corrupts registers:
|
---|
51 | ; All, except SS:BP
|
---|
52 | ;--------------------------------------------------------------------
|
---|
53 | ALIGN JUMP_ALIGN
|
---|
54 | MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX:
|
---|
55 | mov [bp+MENU.fnEventHandler], bx
|
---|
56 | mov [bp+MENU.dwUserData], ax
|
---|
57 | mov [bp+MENU.dwUserData+2], dx
|
---|
58 | mov WORD [bp+MENU.wHighlightedItem], NO_ITEM_HIGHLIGHTED
|
---|
59 |
|
---|
60 | mov ax, CURSOR_HIDDEN
|
---|
61 | CALL_DISPLAY_LIBRARY SetCursorShapeFromAX
|
---|
62 | call MenuEvent_InitializeMenuinit ; User initialization
|
---|
63 | call MenuTime_RestartSelectionTimeout
|
---|
64 | call MenuInit_RefreshMenuWindow
|
---|
65 | jmp MenuLoop_Enter
|
---|
66 |
|
---|
67 |
|
---|
68 | ;--------------------------------------------------------------------
|
---|
69 | ; MenuInit_RefreshMenuWindow
|
---|
70 | ; Parameters
|
---|
71 | ; SS:BP: Ptr to MENU
|
---|
72 | ; Returns:
|
---|
73 | ; Nothing
|
---|
74 | ; Corrupts registers:
|
---|
75 | ; AX, BX, CX, DX, SI, DI
|
---|
76 | ;--------------------------------------------------------------------
|
---|
77 | ALIGN JUMP_ALIGN
|
---|
78 | MenuInit_RefreshMenuWindow:
|
---|
79 | call MenuBorders_RefreshAll ; Draw borders
|
---|
80 | call MenuText_RefreshTitle ; Draw title strings
|
---|
81 | call MenuText_RefreshAllItems ; Draw item strings
|
---|
82 | jmp MenuText_RefreshInformation ; Draw information strings
|
---|
83 |
|
---|
84 |
|
---|
85 | ;--------------------------------------------------------------------
|
---|
86 | ; MenuInit_CloseMenuWindow
|
---|
87 | ; Parameters
|
---|
88 | ; SS:BP: Ptr to MENU
|
---|
89 | ; Returns:
|
---|
90 | ; Nothing
|
---|
91 | ; Corrupts registers:
|
---|
92 | ; Nothing
|
---|
93 | ;--------------------------------------------------------------------
|
---|
94 | ALIGN JUMP_ALIGN
|
---|
95 | MenuInit_CloseMenuWindow:
|
---|
96 | or BYTE [bp+MENU.bFlags], FLG_MENU_EXIT
|
---|
97 | ret
|
---|
98 |
|
---|
99 |
|
---|
100 | ;--------------------------------------------------------------------
|
---|
101 | ; MenuInit_HighlightItemFromAX
|
---|
102 | ; Parameters
|
---|
103 | ; AX: Item to highlight
|
---|
104 | ; SS:BP: Ptr to MENU
|
---|
105 | ; Returns:
|
---|
106 | ; Nothing
|
---|
107 | ; Corrupts registers:
|
---|
108 | ; AX, BX, CX, DX, SI, DI
|
---|
109 | ;--------------------------------------------------------------------
|
---|
110 | ALIGN JUMP_ALIGN
|
---|
111 | MenuInit_HighlightItemFromAX:
|
---|
112 | sub ax, [bp+MENU.wHighlightedItem]
|
---|
113 | jmp MenuScrollbars_MoveHighlightedItemByAX
|
---|
114 |
|
---|
115 |
|
---|
116 | ;--------------------------------------------------------------------
|
---|
117 | ; MenuInit_SetTitleHeightFromAL
|
---|
118 | ; MenuInit_SetInformationHeightFromAL
|
---|
119 | ; MenuInit_SetTotalItemsFromAX
|
---|
120 | ; Parameters
|
---|
121 | ; AX/AL: Parameter
|
---|
122 | ; SS:BP: Ptr to MENU
|
---|
123 | ; Returns:
|
---|
124 | ; Nothing
|
---|
125 | ; Corrupts registers:
|
---|
126 | ; Nothing
|
---|
127 | ;--------------------------------------------------------------------
|
---|
128 | ALIGN JUMP_ALIGN
|
---|
129 | MenuInit_SetTitleHeightFromAL:
|
---|
130 | mov [bp+MENUINIT.bTitleLines], al
|
---|
131 | ret
|
---|
132 |
|
---|
133 | ALIGN JUMP_ALIGN
|
---|
134 | MenuInit_SetInformationHeightFromAL:
|
---|
135 | mov [bp+MENUINIT.bInfoLines], al
|
---|
136 | ret
|
---|
137 |
|
---|
138 | ALIGN JUMP_ALIGN
|
---|
139 | MenuInit_SetTotalItemsFromAX:
|
---|
140 | mov [bp+MENUINIT.wItems], ax
|
---|
141 | ret
|
---|
142 |
|
---|
143 |
|
---|
144 | ;--------------------------------------------------------------------
|
---|
145 | ; MenuInit_SetUserDataFromDSSI
|
---|
146 | ; MenuInit_GetUserDataToDSSI
|
---|
147 | ; Parameters
|
---|
148 | ; DS:SI: User data (MenuInit_SetUserDataFromDSSI)
|
---|
149 | ; SS:BP: Ptr to MENU
|
---|
150 | ; Returns:
|
---|
151 | ; DS:SI: User data (MenuInit_GetUserDataToDSSI)
|
---|
152 | ; Corrupts registers:
|
---|
153 | ; Nothing
|
---|
154 | ;--------------------------------------------------------------------
|
---|
155 | ALIGN JUMP_ALIGN
|
---|
156 | MenuInit_SetUserDataFromDSSI:
|
---|
157 | mov [bp+MENU.dwUserData], si
|
---|
158 | mov [bp+MENU.dwUserData+2], ds
|
---|
159 | ret
|
---|
160 |
|
---|
161 | ALIGN JUMP_ALIGN
|
---|
162 | MenuInit_GetUserDataToDSSI:
|
---|
163 | lds si, [bp+MENU.dwUserData]
|
---|
164 | ret
|
---|