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

Last change on this file since 47 was 47, checked in by aitotat, 14 years ago

Assembly Library:
CGA snow prevention now works when copying strings on formatted printing.

File size: 5.5 KB
RevLine 
[41]1; File name     :   MenuTime.asm
2; Project name  :   Assembly Library
3; Created date  :   25.7.2010
[47]4; Last update   :   4.10.2010
[41]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    push    ds
59
[45]60    call    MenuTime_DrawWithoutUpdating
61    jnc     SHORT .TimeoutDisabled
62    call    PointDSBXtoTimeoutCounter
63    call    TimerTicks_SetCarryIfTimeoutFromDSBX
[41]64
65ALIGN JUMP_ALIGN
[45]66.TimeoutDisabled:
[41]67    pop     ds
68    ret
69
70;--------------------------------------------------------------------
71; MenuTime_DrawWithoutUpdating
72;   Parameters
73;       SS:BP:  Ptr to MENU
74;   Returns:
[45]75;       CF:     Set if timeout enabled
76;               Cleared if timeout disabled
[41]77;   Corrupts registers:
78;       AX, BX, CX, DX, SI, DI
79;--------------------------------------------------------------------
80ALIGN JUMP_ALIGN
81MenuTime_DrawWithoutUpdating:
82    cmp     WORD [bp+MENUINIT.wTimeoutTicks], BYTE 0
[45]83    je      SHORT .ReturnSinceTimeoutDisabled   ; Clear CF
[41]84
85    push    ds
[45]86    call    GetSecondsLeftUntilTimeoutToAXandCounterToDSBX
[41]87    call    DrawTimeoutInAXoverMenuBorders
88    pop     ds
[45]89    stc
90ALIGN JUMP_ALIGN, ret
[41]91.ReturnSinceTimeoutDisabled:
92    ret
93
94
95;--------------------------------------------------------------------
[45]96; GetSecondsLeftUntilTimeoutToAXandCounterToDSBX
[41]97;   Parameters
98;       SS:BP:  Ptr to MENU
99;   Returns:
[45]100;       AX:     Seconds until timeout
[41]101;       DS:BX:  Ptr to timeout counter
102;   Corrupts registers:
[45]103;       AX, CX, DX
[41]104;--------------------------------------------------------------------
105ALIGN JUMP_ALIGN
[45]106GetSecondsLeftUntilTimeoutToAXandCounterToDSBX:
107    call    PointDSBXtoTimeoutCounter
108    call    TimerTicks_GetElapsedToAXfromDSBX
109    neg     ax          ; Negate since DS:BX points to end time
110    MAX_S   ax, 0       ; Set to zero if overflow
111    xchg    dx, ax
112    jmp     TimerTicks_GetSecondsToAXfromTicksInDX
[41]113
114
115;--------------------------------------------------------------------
[45]116; PointDSBXtoTimeoutCounter
[41]117;   Parameters
118;       SS:BP:  Ptr to MENU
119;   Returns:
120;       DS:BX:  Ptr to timeout counter
121;   Corrupts registers:
[45]122;       Nothing
[41]123;--------------------------------------------------------------------
124ALIGN JUMP_ALIGN
[45]125PointDSBXtoTimeoutCounter:
126    push    ss
127    pop     ds
128    lea     bx, [bp+MENU.wTimeoutCounter]
129    ret
[41]130
131
132;--------------------------------------------------------------------
133; DrawTimeoutInAXoverMenuBorders
134;   Parameters
135;       AX:     Seconds to draw
136;       SS:BP:  Ptr to MENU
137;   Returns:
138;       Nothing
139;   Corrupts registers:
[44]140;       AX, CX, DX, SI, DI
[41]141;--------------------------------------------------------------------
142ALIGN JUMP_ALIGN
143DrawTimeoutInAXoverMenuBorders:
[44]144    xchg    cx, ax
[41]145    call    MenuBorders_AdjustDisplayContextForDrawingBorders
146    call    MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
147    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
148    ; Fall to .PrintTimeoutStringWithSecondsInDX
149
150;--------------------------------------------------------------------
151; .PrintTimeoutStringWithSecondsInDX
152;   Parameters
[44]153;       CX:     Seconds to print
[41]154;       SS:BP:  Ptr to MENU
155;   Returns:
156;       Nothing
157;   Corrupts registers:
158;       AX, DX, SI, DI
159;--------------------------------------------------------------------
160;ALIGN JUMP_ALIGN
161.PrintTimeoutStringWithSecondsInDX:
162    push    bp
163
164    mov     bp, sp
[44]165    call    .GetTimeoutAttributeToAXfromSecondsInCX
[41]166    mov     si, .szSelectionTimeout
167    push    ax          ; Push attribute
[44]168    push    cx          ; Push seconds
[41]169    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
170    pop     bp
171
[45]172    ; Draw right border with normal border color
[41]173    mov     al, DOUBLE_RIGHT_HORIZONTAL_TO_SINGLE_VERTICAL
174    jmp     MenuBorders_PrintSingleBorderCharacterFromAL
175.szSelectionTimeout:
176    db      DOUBLE_BOTTOM_LEFT_CORNER
177    db      DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL
[47]178    db      "%AAutoselection in %2u s",NULL
[41]179
180;--------------------------------------------------------------------
[44]181; .GetTimeoutAttributeToAXfromSecondsInCX
[41]182;   Parameters
[44]183;       CX:     Seconds to print
[41]184;   Returns:
185;       AX:     Attribute byte for seconds
[44]186;       CX:     Seconds to print
[41]187;   Corrupts registers:
188;       SI, DI
189;--------------------------------------------------------------------
190ALIGN JUMP_ALIGN
[44]191.GetTimeoutAttributeToAXfromSecondsInCX:
[41]192    mov     si, ATTRIBUTE_CHARS.cNormalTimeout
[44]193    cmp     cx, BYTE 3
[41]194    ja      SHORT .GetAttributeToAX
195    add     si, BYTE ATTRIBUTE_CHARS.cHurryTimeout - ATTRIBUTE_CHARS.cNormalTimeout
196ALIGN JUMP_ALIGN
197.GetAttributeToAX:
198    jmp     MenuAttribute_GetToAXfromTypeInSI
Note: See TracBrowser for help on using the repository browser.