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

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