1 | ; File name : MenuInit.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 13.7.2010
|
---|
4 | ; Last update : 5.10.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
|
---|
30 | call Memory_ZeroSSBPwithSizeInCX
|
---|
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 | ; MenuInit_GetHighlightedItemToAX
|
---|
117 | ; Parameters
|
---|
118 | ; SS:BP: Ptr to MENU
|
---|
119 | ; Returns:
|
---|
120 | ; AX: Index of highlighted item or NO_ITEM_HIGHLIGHTED
|
---|
121 | ; Corrupts registers:
|
---|
122 | ; Nothing
|
---|
123 | ;--------------------------------------------------------------------
|
---|
124 | ALIGN JUMP_ALIGN
|
---|
125 | MenuInit_GetHighlightedItemToAX:
|
---|
126 | mov ax, [bp+MENU.wHighlightedItem]
|
---|
127 | ret
|
---|
128 |
|
---|
129 |
|
---|
130 | ;--------------------------------------------------------------------
|
---|
131 | ; MenuInit_SetTitleHeightFromAL
|
---|
132 | ; MenuInit_SetInformationHeightFromAL
|
---|
133 | ; MenuInit_SetTotalItemsFromAX
|
---|
134 | ; Parameters
|
---|
135 | ; AX/AL: Parameter
|
---|
136 | ; SS:BP: Ptr to MENU
|
---|
137 | ; Returns:
|
---|
138 | ; Nothing
|
---|
139 | ; Corrupts registers:
|
---|
140 | ; Nothing
|
---|
141 | ;--------------------------------------------------------------------
|
---|
142 | ALIGN JUMP_ALIGN
|
---|
143 | MenuInit_SetTitleHeightFromAL:
|
---|
144 | mov [bp+MENUINIT.bTitleLines], al
|
---|
145 | ret
|
---|
146 |
|
---|
147 | ALIGN JUMP_ALIGN
|
---|
148 | MenuInit_SetInformationHeightFromAL:
|
---|
149 | mov [bp+MENUINIT.bInfoLines], al
|
---|
150 | ret
|
---|
151 |
|
---|
152 | ALIGN JUMP_ALIGN
|
---|
153 | MenuInit_SetTotalItemsFromAX:
|
---|
154 | mov [bp+MENUINIT.wItems], ax
|
---|
155 | ret
|
---|
156 |
|
---|
157 |
|
---|
158 | ;--------------------------------------------------------------------
|
---|
159 | ; MenuInit_SetUserDataFromDSSI
|
---|
160 | ; MenuInit_GetUserDataToDSSI
|
---|
161 | ; Parameters
|
---|
162 | ; DS:SI: User data (MenuInit_SetUserDataFromDSSI)
|
---|
163 | ; SS:BP: Ptr to MENU
|
---|
164 | ; Returns:
|
---|
165 | ; DS:SI: User data (MenuInit_GetUserDataToDSSI)
|
---|
166 | ; Corrupts registers:
|
---|
167 | ; Nothing
|
---|
168 | ;--------------------------------------------------------------------
|
---|
169 | ALIGN JUMP_ALIGN
|
---|
170 | MenuInit_SetUserDataFromDSSI:
|
---|
171 | mov [bp+MENU.dwUserData], si
|
---|
172 | mov [bp+MENU.dwUserData+2], ds
|
---|
173 | ret
|
---|
174 |
|
---|
175 | ALIGN JUMP_ALIGN
|
---|
176 | MenuInit_GetUserDataToDSSI:
|
---|
177 | lds si, [bp+MENU.dwUserData]
|
---|
178 | ret
|
---|