1 | ; Project name : Assembly Library |
---|
2 | ; Description : Menu timeouts other time related functions. |
---|
3 | |
---|
4 | ; Section containing code |
---|
5 | SECTION .text |
---|
6 | |
---|
7 | ;-------------------------------------------------------------------- |
---|
8 | ; MenuTime_StartSelectionTimeoutWithTicksInAX |
---|
9 | ; Parameters |
---|
10 | ; AX: Timeout ticks |
---|
11 | ; SS:BP: Ptr to MENU |
---|
12 | ; Returns: |
---|
13 | ; Nothing |
---|
14 | ; Corrupts registers: |
---|
15 | ; AX, BX |
---|
16 | ;-------------------------------------------------------------------- |
---|
17 | ALIGN JUMP_ALIGN |
---|
18 | MenuTime_StartSelectionTimeoutWithTicksInAX: |
---|
19 | push ds |
---|
20 | call PointDSBXtoTimeoutCounter |
---|
21 | call TimerTicks_InitializeTimeoutFromAX |
---|
22 | or BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN |
---|
23 | pop ds |
---|
24 | ret |
---|
25 | |
---|
26 | |
---|
27 | ;-------------------------------------------------------------------- |
---|
28 | ; MenuTime_StopSelectionTimeout |
---|
29 | ; Parameters |
---|
30 | ; SS:BP: Ptr to MENU |
---|
31 | ; Returns: |
---|
32 | ; Nothing |
---|
33 | ; Corrupts registers: |
---|
34 | ; AX, BX, DX, SI, DI |
---|
35 | ;-------------------------------------------------------------------- |
---|
36 | ALIGN JUMP_ALIGN |
---|
37 | MenuTime_StopSelectionTimeout: |
---|
38 | test BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN |
---|
39 | jz SHORT TimeoutAlreadyStopped |
---|
40 | and BYTE [bp+MENU.bFlags], ~FLG_MENU_TIMEOUT_COUNTDOWN |
---|
41 | jmp MenuBorders_RedrawBottomBorderLine |
---|
42 | |
---|
43 | |
---|
44 | ;-------------------------------------------------------------------- |
---|
45 | ; MenuTime_UpdateSelectionTimeout |
---|
46 | ; Parameters |
---|
47 | ; SS:BP: Ptr to MENU |
---|
48 | ; Returns: |
---|
49 | ; CF: Set if timeout |
---|
50 | ; Cleared if time left |
---|
51 | ; Corrupts registers: |
---|
52 | ; AX, BX, SI, DI |
---|
53 | ;-------------------------------------------------------------------- |
---|
54 | ALIGN JUMP_ALIGN |
---|
55 | MenuTime_UpdateSelectionTimeout: |
---|
56 | test BYTE [bp+MENU.bFlags], FLG_MENU_TIMEOUT_COUNTDOWN |
---|
57 | jz SHORT .ReturnSinceTimeoutDisabled |
---|
58 | |
---|
59 | push ds |
---|
60 | call PointDSBXtoTimeoutCounter |
---|
61 | call TimerTicks_GetTimeoutTicksLeftToAXfromDSBX |
---|
62 | pop ds |
---|
63 | jnc SHORT .RedrawSinceNoTimeout |
---|
64 | and BYTE [bp+MENU.bFlags], ~FLG_MENU_TIMEOUT_COUNTDOWN |
---|
65 | stc |
---|
66 | ret |
---|
67 | |
---|
68 | ALIGN JUMP_ALIGN |
---|
69 | .RedrawSinceNoTimeout: |
---|
70 | call MenuBorders_RedrawBottomBorderLine |
---|
71 | clc |
---|
72 | .ReturnSinceTimeoutDisabled: |
---|
73 | TimeoutAlreadyStopped: |
---|
74 | ret |
---|
75 | |
---|
76 | |
---|
77 | ;-------------------------------------------------------------------- |
---|
78 | ; MenuTime_GetTimeoutSecondsLeftToAX |
---|
79 | ; Parameters |
---|
80 | ; SS:BP: Ptr to MENU |
---|
81 | ; Returns: |
---|
82 | ; AX: Seconds until timeout |
---|
83 | ; Corrupts registers: |
---|
84 | ; AX |
---|
85 | ;-------------------------------------------------------------------- |
---|
86 | ALIGN JUMP_ALIGN |
---|
87 | MenuTime_GetTimeoutSecondsLeftToAX: |
---|
88 | push ds |
---|
89 | push dx |
---|
90 | push cx |
---|
91 | push bx |
---|
92 | |
---|
93 | call PointDSBXtoTimeoutCounter |
---|
94 | call TimerTicks_GetTimeoutTicksLeftToAXfromDSBX |
---|
95 | jc SHORT .TimeoutHasOccurredSoMakeSureTicksAreNotBelowZero |
---|
96 | |
---|
97 | xchg dx, ax |
---|
98 | call TimerTicks_GetSecondsToAXfromTicksInDX |
---|
99 | SKIP2B f ; cmp ax, <next instruction> |
---|
100 | .TimeoutHasOccurredSoMakeSureTicksAreNotBelowZero: |
---|
101 | xor ax, ax |
---|
102 | |
---|
103 | pop bx |
---|
104 | pop cx |
---|
105 | pop dx |
---|
106 | pop ds |
---|
107 | ret |
---|
108 | |
---|
109 | |
---|
110 | ;-------------------------------------------------------------------- |
---|
111 | ; PointDSBXtoTimeoutCounter |
---|
112 | ; Parameters |
---|
113 | ; SS:BP: Ptr to MENU |
---|
114 | ; Returns: |
---|
115 | ; DS:BX: Ptr to timeout counter |
---|
116 | ; Corrupts registers: |
---|
117 | ; Nothing |
---|
118 | ;-------------------------------------------------------------------- |
---|
119 | ALIGN JUMP_ALIGN |
---|
120 | PointDSBXtoTimeoutCounter: |
---|
121 | push ss |
---|
122 | pop ds |
---|
123 | lea bx, [bp+MENU.wTimeoutCounter] |
---|
124 | ret |
---|