1 | ; File name : MenuInit.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 13.7.2010
|
---|
4 | ; Last update : 12.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+MENUINIT.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 |
|
---|
59 | mov ax, CURSOR_HIDDEN
|
---|
60 | CALL_DISPLAY_LIBRARY SetCursorShapeFromAX
|
---|
61 | call MenuEvent_InitializeMenuinit ; User initialization
|
---|
62 | call MenuTime_RestartSelectionTimeout
|
---|
63 | call MenuInit_RefreshMenuWindow
|
---|
64 | jmp MenuLoop_Enter
|
---|
65 |
|
---|
66 |
|
---|
67 | ;--------------------------------------------------------------------
|
---|
68 | ; MenuInit_RefreshMenuWindow
|
---|
69 | ; Parameters
|
---|
70 | ; SS:BP: Ptr to MENU
|
---|
71 | ; Returns:
|
---|
72 | ; Nothing
|
---|
73 | ; Corrupts registers:
|
---|
74 | ; AX, BX, CX, DX, SI, DI
|
---|
75 | ;--------------------------------------------------------------------
|
---|
76 | ALIGN JUMP_ALIGN
|
---|
77 | MenuInit_RefreshMenuWindow:
|
---|
78 | call MenuBorders_RefreshAll ; Draw borders
|
---|
79 | call MenuText_RefreshTitle ; Draw title strings
|
---|
80 | call MenuText_RefreshAllItems ; Draw item strings
|
---|
81 | jmp MenuText_RefreshInformation ; Draw information strings
|
---|
82 |
|
---|
83 |
|
---|
84 | ;--------------------------------------------------------------------
|
---|
85 | ; MenuInit_CloseMenuWindow
|
---|
86 | ; Parameters
|
---|
87 | ; SS:BP: Ptr to MENU
|
---|
88 | ; Returns:
|
---|
89 | ; Nothing
|
---|
90 | ; Corrupts registers:
|
---|
91 | ; Nothing
|
---|
92 | ;--------------------------------------------------------------------
|
---|
93 | ALIGN JUMP_ALIGN
|
---|
94 | MenuInit_CloseMenuWindow:
|
---|
95 | or BYTE [bp+MENU.bFlags], FLG_MENU_EXIT
|
---|
96 | ret
|
---|
97 |
|
---|
98 |
|
---|
99 | ;--------------------------------------------------------------------
|
---|
100 | ; MenuInit_HighlightItemFromAX
|
---|
101 | ; Parameters
|
---|
102 | ; AX: Item to highlight
|
---|
103 | ; SS:BP: Ptr to MENU
|
---|
104 | ; Returns:
|
---|
105 | ; Nothing
|
---|
106 | ; Corrupts registers:
|
---|
107 | ; AX, BX, CX, DX, SI, DI
|
---|
108 | ;--------------------------------------------------------------------
|
---|
109 | ALIGN JUMP_ALIGN
|
---|
110 | MenuInit_HighlightItemFromAX:
|
---|
111 | sub ax, [bp+MENUINIT.wHighlightedItem]
|
---|
112 | jmp MenuScrollbars_MoveHighlightedItemByAX
|
---|
113 |
|
---|
114 | ;--------------------------------------------------------------------
|
---|
115 | ; MenuInit_GetHighlightedItemToAX
|
---|
116 | ; Parameters
|
---|
117 | ; SS:BP: Ptr to MENU
|
---|
118 | ; Returns:
|
---|
119 | ; AX: Index of highlighted item or NO_ITEM_HIGHLIGHTED
|
---|
120 | ; Corrupts registers:
|
---|
121 | ; Nothing
|
---|
122 | ;--------------------------------------------------------------------
|
---|
123 | ALIGN JUMP_ALIGN
|
---|
124 | MenuInit_GetHighlightedItemToAX:
|
---|
125 | mov ax, [bp+MENUINIT.wHighlightedItem]
|
---|
126 | ret
|
---|
127 |
|
---|
128 |
|
---|
129 | ;--------------------------------------------------------------------
|
---|
130 | ; MenuInit_SetTitleHeightFromAL
|
---|
131 | ; MenuInit_SetInformationHeightFromAL
|
---|
132 | ; MenuInit_SetTotalItemsFromAX
|
---|
133 | ; Parameters
|
---|
134 | ; AX/AL: Parameter
|
---|
135 | ; SS:BP: Ptr to MENU
|
---|
136 | ; Returns:
|
---|
137 | ; Nothing
|
---|
138 | ; Corrupts registers:
|
---|
139 | ; Nothing
|
---|
140 | ;--------------------------------------------------------------------
|
---|
141 | ALIGN JUMP_ALIGN
|
---|
142 | MenuInit_SetTitleHeightFromAL:
|
---|
143 | mov [bp+MENUINIT.bTitleLines], al
|
---|
144 | ret
|
---|
145 |
|
---|
146 | ALIGN JUMP_ALIGN
|
---|
147 | MenuInit_SetInformationHeightFromAL:
|
---|
148 | mov [bp+MENUINIT.bInfoLines], al
|
---|
149 | ret
|
---|
150 |
|
---|
151 | ALIGN JUMP_ALIGN
|
---|
152 | MenuInit_SetTotalItemsFromAX:
|
---|
153 | mov [bp+MENUINIT.wItems], ax
|
---|
154 | ret
|
---|
155 |
|
---|
156 |
|
---|
157 | ;--------------------------------------------------------------------
|
---|
158 | ; MenuInit_SetUserDataFromDSSI
|
---|
159 | ; MenuInit_GetUserDataToDSSI
|
---|
160 | ; Parameters
|
---|
161 | ; DS:SI: User data (MenuInit_SetUserDataFromDSSI)
|
---|
162 | ; SS:BP: Ptr to MENU
|
---|
163 | ; Returns:
|
---|
164 | ; DS:SI: User data (MenuInit_GetUserDataToDSSI)
|
---|
165 | ; Corrupts registers:
|
---|
166 | ; Nothing
|
---|
167 | ;--------------------------------------------------------------------
|
---|
168 | ALIGN JUMP_ALIGN
|
---|
169 | MenuInit_SetUserDataFromDSSI:
|
---|
170 | mov [bp+MENU.dwUserData], si
|
---|
171 | mov [bp+MENU.dwUserData+2], ds
|
---|
172 | ret
|
---|
173 |
|
---|
174 | ALIGN JUMP_ALIGN
|
---|
175 | MenuInit_GetUserDataToDSSI:
|
---|
176 | lds si, [bp+MENU.dwUserData]
|
---|
177 | ret
|
---|