source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Libraries/menu/menucrsr.asm@ 86

Last change on this file since 86 was 86, checked in by krille_n_@…, 14 years ago

Size optimizations in various files in the XTIDE BIOS.
Also added a new include file for generic macros (macros.inc).

File size: 7.2 KB
Line 
1; Project name : Menu library
2; Description : ASM library to menu system.
3; Contains menu cursor functions.
4
5;--------------- Equates -----------------------------
6
7W_OFF_CRSR_STR EQU 0102h ; User string cursor offset
8
9
10;-------------- Private global variables -------------
11; Section containing initialized data
12;SECTION .data
13
14
15;-------------- Public functions ---------------------
16; Section containing code
17SECTION .text
18
19;--------------------------------------------------------------------
20; Returns X and Y coordinates for menu top left corner.
21; This function is used for calculating initial coordinates when
22; initializing menu for first time.
23; Parameters:
24; SS:BP: Ptr to MENUVARS
25; Returns:
26; DL: X coordinate for centered menu
27; DH: Y coordinate for centered menu
28; Corrupts registers:
29; AX, BX
30;--------------------------------------------------------------------
31ALIGN JUMP_ALIGN
32MenuCrsr_GetCenter:
33 mov ah, 0Fh ; Get Current Video Mode
34 int 10h
35 mov dl, ah ; Copy column count to DL
36 sub dl, [bp+MENUVARS.bWidth] ; Subtract menu width from columns
37 shr dl, 1 ; Divide by 2 for start X
38 mov dh, CNT_SCRN_ROW ; Load row count
39 sub dh, [bp+MENUVARS.bHeight] ; Subtract menu height from rows
40 shr dh, 1 ; Divide by 2 for start y
41 ret
42
43
44;--------------------------------------------------------------------
45; Sets cursor to start of menu string.
46; MenuCrsr_Point1stItem Sets cursor to first menuitem string
47; MenuCrsr_PointInfo Sets cursor to info string
48; MenuCrsr_PointTitle Sets cursor to title string
49; Parameters:
50; SS:BP: Ptr to MENUVARS
51; Returns:
52; Nothing
53; Corrupts registers:
54; AX, BX, CX, DX
55;--------------------------------------------------------------------
56ALIGN JUMP_ALIGN
57MenuCrsr_Point1stItem:
58 xor dx, dx ; Zero DX
59 call MenuCrsr_PointItemBrdr ; Point to item border (left)
60 mov cx, W_OFF_CRSR_STR & 0FFh ; Offset to user string (move X only)
61 jmp MenuCrsr_Move ; Move cursor
62ALIGN JUMP_ALIGN
63MenuCrsr_PointInfo:
64 xor dx, dx ; Zero DX
65 call MenuCrsr_PointNfoBrdr ; Point to Info border (top left)
66 mov cx, W_OFF_CRSR_STR ; Movement from border to user str
67 jmp MenuCrsr_Move ; Move cursor
68ALIGN JUMP_ALIGN
69MenuCrsr_PointTitle:
70 xor dx, dx ; Zero DX
71 call MenuCrsr_PointTitleBrdr ; Point to Title border (top left)
72 mov cx, W_OFF_CRSR_STR ; Movement from border to user str
73 jmp MenuCrsr_Move ; Move cursor
74
75
76;--------------------------------------------------------------------
77; Sets cursor to start of wanted menuitem string.
78;
79; MenuCrsr_PointNthItem
80; Parameters:
81; CX: Menuitem index where to set cursor
82; SS:BP: Ptr to MENUVARS
83; Returns:
84; Nothing
85; Corrupts registers:
86; AX, BX, DX
87;--------------------------------------------------------------------
88ALIGN JUMP_ALIGN
89MenuCrsr_PointNthItem:
90 push cx
91 push cx
92 call MenuCrsr_Point1stItem ; Point to topmost menuitem
93 pop cx
94 sub cx, [bp+MENUVARS.wItemTop] ; Number of newlines needed
95 jcxz .Return
96ALIGN JUMP_ALIGN
97.NewLineLoop:
98 call MenuDraw_NewlineStr
99 loop .NewLineLoop
100ALIGN JUMP_ALIGN
101.Return:
102 pop cx
103 ret
104
105
106;--------------------------------------------------------------------
107; Sets cursor to start of menu border.
108; MenuCrsr_PointBelowBrdr Sets cursor to below menu bottom border
109; MenuCrsr_PointNfoBrdr Sets cursor to top left corner of info borders
110; MenuCrsr_PointItemBrdr Sets cursor to first menuitem left border
111; MenuCrsr_PointTitleBrdr Sets cursor to top left corner of title borders
112; Parameters:
113; DX: 0
114; SS:BP: Ptr to MENUVARS
115; Returns:
116; Nothing
117; Corrupts registers:
118; AX, BX, DX
119;--------------------------------------------------------------------
120ALIGN JUMP_ALIGN
121MenuCrsr_PointBelowBrdr:
122 mov dh, [bp+MENUVARS.bInfoH] ; Load info height without borders
123 test dh, dh ; Info displayed?
124 jz .BottomOnly ; If not, continue
125 inc dh ; Increment Y for top border
126ALIGN JUMP_ALIGN
127.BottomOnly:
128 inc dh ; Increment Y for bottom border
129ALIGN JUMP_ALIGN
130MenuCrsr_PointNfoBrdr:
131 add dh, [bp+MENUVARS.bVisCnt] ; Load max number of visible menuitems
132ALIGN JUMP_ALIGN
133MenuCrsr_PointItemBrdr:
134 inc dh ; Add title top border
135 mov al, [bp+MENUVARS.bTitleH] ; Load title height
136 add dh, al ; Add title height to DH
137 test al, al ; Title visible?
138 jz MenuCrsr_PointTitleBrdr ; If not, jump to set cursor
139 inc dh ; Title bottom border
140ALIGN JUMP_ALIGN
141MenuCrsr_PointTitleBrdr:
142 add dx, [bp+MENUVARS.wInitCrsr] ; Add initial cursor position
143 ; Fall to MenuCrsr_SetCursor
144
145
146;--------------------------------------------------------------------
147; Sets cursor position in DX.
148; Parameters:
149; DL: Cursor X coordinate
150; DH: Cursor Y coordinate
151; Returns:
152; Nothing
153; Corrupts registers:
154; AX, BX
155;--------------------------------------------------------------------
156ALIGN JUMP_ALIGN
157MenuCrsr_SetCursor:
158 mov ah, 02h ; Set Cursor Position and Size
159 SKIP2B bx ; mov bx, <next instruction>
160 ; Fall through to MenuCrsr_GetCursor
161
162
163;--------------------------------------------------------------------
164; Return cursor position in DX.
165; Parameters:
166; Nothing
167; Returns:
168; CL: Cursor start scan line
169; CH: Cursor end scan line
170; DL: Cursor X coordinate
171; DH: Cursor Y coordinate
172; Corrupts registers:
173; AX, BX
174;--------------------------------------------------------------------
175;ALIGN JUMP_ALIGN
176MenuCrsr_GetCursor:
177 mov ah, 03h ; Get Cursor Position and Size
178 xor bx, bx ; Zero page
179 int 10h
180 ret
181
182
183;--------------------------------------------------------------------
184; Moves cursor from current location.
185; Parameters:
186; CL: Cursor X coordinate movement (can be negative)
187; CH: Cursor Y coordinate movement (can be negative)
188; Returns:
189; Nothing
190; Corrupts registers:
191; AX, BX, DX
192;--------------------------------------------------------------------
193ALIGN JUMP_ALIGN
194MenuCrsr_Move:
195 push cx
196 call MenuCrsr_GetCursor ; Get cursor position to DX
197 pop cx
198 add dl, cl ; Move X
199 add dh, ch ; Move Y
200 jmp MenuCrsr_SetCursor
201
202
203;--------------------------------------------------------------------
204; Shows cursor that has been hidden.
205; Parameters:
206; Nothing
207; Returns:
208; Nothing
209; Corrupts registers:
210; AX, CX
211;--------------------------------------------------------------------
212ALIGN JUMP_ALIGN
213MenuCrsr_Show:
214 mov cx, 0607h ; Two line cursor near or at the bottom of cell
215 jmp MenuCrsr_SetShape
216
217
218;--------------------------------------------------------------------
219; Hides cursor.
220; Parameters:
221; Nothing
222; Returns:
223; Nothing
224; Corrupts registers:
225; AX, CX
226;--------------------------------------------------------------------
227ALIGN JUMP_ALIGN
228MenuCrsr_Hide:
229 mov cx, 2000h
230 ; Fall to MenuCrsr_SetShape
231
232;--------------------------------------------------------------------
233; Sets cursor shape.
234; Parameters:
235; CL: Cursor start scan line
236; CH: Cursor end scan line
237; Returns:
238; Nothing
239; Corrupts registers:
240; AX
241;--------------------------------------------------------------------
242ALIGN JUMP_ALIGN
243MenuCrsr_SetShape:
244 mov ax, 0103h ; Set Text-Mode Cursor Shape
245 ; AL=assumed video mode to prevent lock ups on some BIOSes
246 int 10h
247 ret
Note: See TracBrowser for help on using the repository browser.