1 | ; File name : MenuTime.asm
|
---|
2 | ; Project name : Assembly Library
|
---|
3 | ; Created date : 25.7.2010
|
---|
4 | ; Last update : 27.9.2010
|
---|
5 | ; Author : Tomi Tilli
|
---|
6 | ; Description : Menu timeouts other time related functions.
|
---|
7 |
|
---|
8 | ; Section containing code
|
---|
9 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
21 | ALIGN JUMP_ALIGN
|
---|
22 | MenuTime_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 | ;--------------------------------------------------------------------
|
---|
36 | ALIGN JUMP_ALIGN
|
---|
37 | MenuTime_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 | ;--------------------------------------------------------------------
|
---|
56 | ALIGN JUMP_ALIGN
|
---|
57 | MenuTime_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 |
|
---|
68 | ALIGN 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 | ;--------------------------------------------------------------------
|
---|
85 | ALIGN JUMP_ALIGN
|
---|
86 | MenuTime_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 | ;--------------------------------------------------------------------
|
---|
107 | ALIGN JUMP_ALIGN
|
---|
108 | PointDSBXtoTimeoutCounter:
|
---|
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 | ;--------------------------------------------------------------------
|
---|
125 | ALIGN JUMP_ALIGN
|
---|
126 | GetSecondsUntilTimeoutToAXandPtrToTimeoutCounterToDSBX:
|
---|
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, CX, DX, SI, DI
|
---|
144 | ;--------------------------------------------------------------------
|
---|
145 | ALIGN JUMP_ALIGN
|
---|
146 | DrawTimeoutInAXoverMenuBorders:
|
---|
147 | xchg cx, 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 | ; CX: 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 .GetTimeoutAttributeToAXfromSecondsInCX
|
---|
169 | mov si, .szSelectionTimeout
|
---|
170 | push ax ; Push attribute
|
---|
171 | push cx ; 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 %2-ds",NULL
|
---|
181 |
|
---|
182 | ;--------------------------------------------------------------------
|
---|
183 | ; .GetTimeoutAttributeToAXfromSecondsInCX
|
---|
184 | ; Parameters
|
---|
185 | ; CX: Seconds to print
|
---|
186 | ; Returns:
|
---|
187 | ; AX: Attribute byte for seconds
|
---|
188 | ; CX: Seconds to print
|
---|
189 | ; Corrupts registers:
|
---|
190 | ; SI, DI
|
---|
191 | ;--------------------------------------------------------------------
|
---|
192 | ALIGN JUMP_ALIGN
|
---|
193 | .GetTimeoutAttributeToAXfromSecondsInCX:
|
---|
194 | mov si, ATTRIBUTE_CHARS.cNormalTimeout
|
---|
195 | cmp cx, BYTE 3
|
---|
196 | ja SHORT .GetAttributeToAX
|
---|
197 | add si, BYTE ATTRIBUTE_CHARS.cHurryTimeout - ATTRIBUTE_CHARS.cNormalTimeout
|
---|
198 | ALIGN JUMP_ALIGN
|
---|
199 | .GetAttributeToAX:
|
---|
200 | jmp MenuAttribute_GetToAXfromTypeInSI
|
---|