source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/MenuTime.asm@ 42

Last change on this file since 42 was 41, checked in by Tomi Tilli, 14 years ago

Initial commit for Assembly Library.

File size: 5.6 KB
Line 
1; File name : MenuTime.asm
2; Project name : Assembly Library
3; Created date : 25.7.2010
4; Last update : 13.8.2010
5; Author : Tomi Tilli
6; Description : Menu timeouts other time related functions.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; MenuTime_SetSelectionTimeoutValueFromAX
13; Parameters
14; AX: Selection timeout in system timer ticks
15; SS:BP: Ptr to MENU
16; Returns:
17; Nothing
18; Corrupts registers:
19; Nothing
20;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
22MenuTime_SetSelectionTimeoutValueFromAX:
23 mov [bp+MENUINIT.wTimeoutTicks], ax
24 ret
25
26
27;--------------------------------------------------------------------
28; MenuTime_RestartSelectionTimeout
29; Parameters
30; SS:BP: Ptr to MENU
31; Returns:
32; Nothing
33; Corrupts registers:
34; AX, BX
35;--------------------------------------------------------------------
36ALIGN JUMP_ALIGN
37MenuTime_RestartSelectionTimeout:
38 push ds
39 call PointDSBXtoTimeoutCounter
40 mov ax, [bp+MENUINIT.wTimeoutTicks]
41 call TimerTicks_InitializeTimeoutFromAX ; End time to [DS:BX]
42 pop ds
43 ret
44
45
46;--------------------------------------------------------------------
47; MenuTime_UpdateSelectionTimeout
48; Parameters
49; SS:BP: Ptr to MENU
50; Returns:
51; CF: Set if timeout
52; Cleared if time left
53; Corrupts registers:
54; AX, BX, CX, DX, SI, DI
55;--------------------------------------------------------------------
56ALIGN JUMP_ALIGN
57MenuTime_UpdateSelectionTimeout:
58 cmp WORD [bp+MENUINIT.wTimeoutTicks], BYTE 0
59 je SHORT .ReturnSinceTimeoutDisabled ; CF cleared
60 push ds
61
62 call GetSecondsUntilTimeoutToAXandPtrToTimeoutCounterToDSBX
63 cmp al, [bp+MENU.bLastSecondPrinted]
64 je SHORT .SetCFifTimeoutAndReturn
65 mov [bp+MENU.bLastSecondPrinted], al
66 call DrawTimeoutInAXoverMenuBorders
67
68ALIGN JUMP_ALIGN
69.SetCFifTimeoutAndReturn:
70 call TimerTicks_SetCarryIfTimeoutFromDSBX
71 pop ds
72.ReturnSinceTimeoutDisabled:
73 ret
74
75
76;--------------------------------------------------------------------
77; MenuTime_DrawWithoutUpdating
78; Parameters
79; SS:BP: Ptr to MENU
80; Returns:
81; Nothing
82; Corrupts registers:
83; AX, BX, CX, DX, SI, DI
84;--------------------------------------------------------------------
85ALIGN JUMP_ALIGN
86MenuTime_DrawWithoutUpdating:
87 cmp WORD [bp+MENUINIT.wTimeoutTicks], BYTE 0
88 je SHORT .ReturnSinceTimeoutDisabled
89
90 push ds
91 call GetSecondsUntilTimeoutToAXandPtrToTimeoutCounterToDSBX
92 call DrawTimeoutInAXoverMenuBorders
93 pop ds
94.ReturnSinceTimeoutDisabled:
95 ret
96
97
98;--------------------------------------------------------------------
99; PointDSBXtoTimeoutCounter
100; Parameters
101; SS:BP: Ptr to MENU
102; Returns:
103; DS:BX: Ptr to timeout counter
104; Corrupts registers:
105; Nothing
106;--------------------------------------------------------------------
107ALIGN JUMP_ALIGN
108PointDSBXtoTimeoutCounter:
109 push ss
110 pop ds
111 lea bx, [bp+MENU.wTimeoutCounter]
112 ret
113
114
115;--------------------------------------------------------------------
116; GetSecondsUntilTimeoutToAXandPtrToTimeoutCounterToDSBX
117; Parameters
118; SS:BP: Ptr to MENU
119; Returns:
120; AX: Seconds until timeout
121; DS:BX: Ptr to timeout counter
122; Corrupts registers:
123; AX, CX, DX
124;--------------------------------------------------------------------
125ALIGN JUMP_ALIGN
126GetSecondsUntilTimeoutToAXandPtrToTimeoutCounterToDSBX:
127 call PointDSBXtoTimeoutCounter
128 call TimerTicks_GetElapsedToAXfromDSBX
129 neg ax ; Negate since DS:BX points to end time
130 MAX_S ax, 0 ; Set to zero if overflow
131 xchg dx, ax
132 jmp TimerTicks_GetSecondsToAXfromTicksInDX
133
134
135;--------------------------------------------------------------------
136; DrawTimeoutInAXoverMenuBorders
137; Parameters
138; AX: Seconds to draw
139; SS:BP: Ptr to MENU
140; Returns:
141; Nothing
142; Corrupts registers:
143; AX, DX, SI, DI
144;--------------------------------------------------------------------
145ALIGN JUMP_ALIGN
146DrawTimeoutInAXoverMenuBorders:
147 xchg dx, ax
148 call MenuBorders_AdjustDisplayContextForDrawingBorders
149 call MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
150 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
151 ; Fall to .PrintTimeoutStringWithSecondsInDX
152
153;--------------------------------------------------------------------
154; .PrintTimeoutStringWithSecondsInDX
155; Parameters
156; DX: Seconds to print
157; SS:BP: Ptr to MENU
158; Returns:
159; Nothing
160; Corrupts registers:
161; AX, DX, SI, DI
162;--------------------------------------------------------------------
163;ALIGN JUMP_ALIGN
164.PrintTimeoutStringWithSecondsInDX:
165 push bp
166
167 mov bp, sp
168 call .GetTimeoutAttributeToAXfromSecondsInDX
169 mov si, .szSelectionTimeout
170 push ax ; Push attribute
171 push dx ; Push seconds
172 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
173 pop bp
174
175 mov al, DOUBLE_RIGHT_HORIZONTAL_TO_SINGLE_VERTICAL
176 jmp MenuBorders_PrintSingleBorderCharacterFromAL
177.szSelectionTimeout:
178 db DOUBLE_BOTTOM_LEFT_CORNER
179 db DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL
180 db "%AAutoselection in %2ds",NULL
181
182;--------------------------------------------------------------------
183; .GetTimeoutAttributeToAXfromSecondsInDX
184; Parameters
185; DX: Seconds to print
186; Returns:
187; AX: Attribute byte for seconds
188; DX: Seconds to print
189; Corrupts registers:
190; SI, DI
191;--------------------------------------------------------------------
192ALIGN JUMP_ALIGN
193.GetTimeoutAttributeToAXfromSecondsInDX:
194 mov si, ATTRIBUTE_CHARS.cNormalTimeout
195 cmp dx, BYTE 3
196 ja SHORT .GetAttributeToAX
197 add si, BYTE ATTRIBUTE_CHARS.cHurryTimeout - ATTRIBUTE_CHARS.cNormalTimeout
198ALIGN JUMP_ALIGN
199.GetAttributeToAX:
200 jmp MenuAttribute_GetToAXfromTypeInSI
Note: See TracBrowser for help on using the repository browser.