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