source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/Dialog/DialogProgress.asm@ 628

Last change on this file since 628 was 625, checked in by Krister Nordvall, 17 months ago

Changes:

  • Added a configuration option to let the BIOS store RamVars to an UMB when Full operating mode is enabled. This is primarily for XT class machines with RAM in the UMA (which apparently is a common thing these days).
  • Added two new builds specifically for IBM PS/2 machines. This is for support of the new McIDE adapter from the guys at zzxio.com. Note that the additional hardware specific code (under the USE_PS2 define) is for the PS/2 machines themselves and not for the McIDE adapters, so any controller in an IBM PS/2 machine can be used with the USE_PS2 define.
  • Moved pColorTheme out of the range of ROMVARS being copied over when doing "Load old settings from EEPROM" in XTIDECFG. This fixed a serious bug from r592 where loading a BIOS from file and then loading the old settings from ROM would corrupt 7 bytes of code somewhere in the loaded BIOS.
  • Optimizations (speed and size) to the library. Browsing the menus in XTIDECFG should now feel a little less sluggish.
  • Hopefully fixed a problem with the PostCommitHook script where it sometimes wouldn't find the CommitInProgress file. I say hopefully because testing this is a nightmare.
File size: 8.9 KB
RevLine 
[41]1; Project name : Assembly Library
2; Description : Displays progress bar dialog and starts progress task.
3
[376]4;
[491]5; XTIDE Universal BIOS and Associated Tools
[625]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2023 by XTIDE Universal BIOS Team.
[376]7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
[491]12;
[376]13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[491]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
[491]20
[41]21; Section containing code
22SECTION .text
23
24;--------------------------------------------------------------------
25; DialogProgress_GetStringWithIoInDSSI
26; Parameters:
27; DS:SI: Ptr to PROGRESS_DIALOG_IO
28; SS:BP: Ptr to parent MENU
29; Returns:
30; Nothing
31; Corrupts registers:
[596]32; AX, BX, CX, DX, DI
[41]33;--------------------------------------------------------------------
34ALIGN JUMP_ALIGN
35DialogProgress_StartProgressTaskWithIoInDSSIandParamInDXAX:
36 mov bx, ProgressEventHandler
37 jmp Dialog_DisplayWithDialogInputInDSSIandHandlerInBX
38
39
40;--------------------------------------------------------------------
41; DialogProgress_SetProgressValueFromAX
42; Parameters
43; AX: Progress bar value to set
44; SS:BP: Ptr to DIALOG
45; Returns:
46; Nothing
47; Corrupts registers:
[48]48; AX, BX, CX, DX, SI, DI
[41]49;--------------------------------------------------------------------
50ALIGN JUMP_ALIGN
51DialogProgress_SetProgressValueFromAX:
52 push ds
53
54 lds si, [bp+DIALOG.fpDialogIO]
55 mov bx, [si+PROGRESS_DIALOG_IO.wMaxProgressValue]
[181]56 cmp ax, bx
57 jb SHORT .AXlessThanBX
58 mov ax, bx
59 jmp SHORT .UpdateProgressBar
60ALIGN JUMP_ALIGN
61.AXlessThanBX:
[41]62 mov bx, ax
63 sub bx, [si+PROGRESS_DIALOG_IO.wCurrentProgressValue]
64 cmp bx, [si+PROGRESS_DIALOG_IO.wProgressPerCharacter]
65 jb SHORT .ReturnWithoutUpdate
66.UpdateProgressBar:
67 mov [si+PROGRESS_DIALOG_IO.wCurrentProgressValue], ax
68 xor ax, ax
69 call MenuText_RefreshItemFromAX
70 call MenuText_RefreshInformation
71ALIGN JUMP_ALIGN
72.ReturnWithoutUpdate:
73 pop ds
74 ret
75
76
77;--------------------------------------------------------------------
78; ProgressEventHandler
79; Common parameters for all events:
80; BX: Menu event (anything from MENUEVENT struct)
81; SS:BP: Ptr to DIALOG
82; Common return values for all events:
83; CF: Set if event processed
84; Cleared if event not processed
85; Corrupts registers:
86; All
87;--------------------------------------------------------------------
88ALIGN JUMP_ALIGN
89ProgressEventHandler:
90 jmp [cs:bx+.rgfnEventHandlers]
91
92
93ALIGN JUMP_ALIGN
94.IdleProcessing:
95 call MenuInit_GetUserDataToDSSI
96 les di, [bp+DIALOG.fpDialogIO]
[64]97 push bp
[41]98 call [es:di+PROGRESS_DIALOG_IO.fnTaskWithParamInDSSI]
[64]99 pop bp
[41]100 call MenuInit_CloseMenuWindow
101 stc
102 ret
103
104
105ALIGN JUMP_ALIGN
106.RefreshItemFromCX:
107 lds si, [bp+DIALOG.fpDialogIO]
108 call DrawProgressBarFromDialogIoInDSSI
109 stc
110 ret
111
112
113ALIGN JUMP_ALIGN
114.RefreshInformation:
115 lds si, [bp+DIALOG.fpDialogIO]
116 call TimerTicks_ReadFromBdaToAX
117 sub ax, [si+PROGRESS_DIALOG_IO.wStartTimeTicks]
118 xchg dx, ax
119 call DrawTimeElapsedFromDX
120 call DrawTimeLeftFromProgressDialogIoInDSSIwithTimeElapsedInDX
121 stc
122 ret
123
124
125ALIGN WORD_ALIGN
126.rgfnEventHandlers:
127istruc MENUEVENT
128 at MENUEVENT.InitializeMenuinitFromDSSI, dw .InitializeMenuinitFromDSSI
[58]129 at MENUEVENT.ExitMenu, dw Dialog_EventExitMenu
[41]130 at MENUEVENT.IdleProcessing, dw .IdleProcessing
131 at MENUEVENT.ItemHighlightedFromCX, dw Dialog_EventNotHandled
132 at MENUEVENT.ItemSelectedFromCX, dw Dialog_EventNotHandled
133 at MENUEVENT.KeyStrokeInAX, dw Dialog_EventNotHandled
134 at MENUEVENT.RefreshTitle, dw Dialog_EventRefreshTitle
135 at MENUEVENT.RefreshInformation, dw .RefreshInformation
136 at MENUEVENT.RefreshItemFromCX, dw .RefreshItemFromCX
137iend
138
139
[625]140ALIGN JUMP_ALIGN
141.InitializeMenuinitFromDSSI:
142 mov ax, NO_ITEM_HIGHLIGHTED
143 call Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX
144 lds si, [bp+DIALOG.fpDialogIO]
145 call TimerTicks_ReadFromBdaToAX
146 mov [si+PROGRESS_DIALOG_IO.wStartTimeTicks], ax
147
148 ; 0 = 65536 but it needs to be adjusted to 65535 to prevent division by zero
149 cmp WORD [si+PROGRESS_DIALOG_IO.wMaxProgressValue], BYTE 0
150 jne SHORT CalculateProgressNeededBeforeUpdatingCharacter
151 dec WORD [si+PROGRESS_DIALOG_IO.wMaxProgressValue]
152 ; Fall to CalculateProgressNeededBeforeUpdatingCharacter
153
[41]154;--------------------------------------------------------------------
155; CalculateProgressNeededBeforeUpdatingCharacter
156; Parameters:
157; DS:SI: Ptr to PROGRESS_DIALOG_IO
158; SS:BP: Ptr to DIALOG
159; Returns:
160; CF: Set since event handled
161; Corrupts:
162; AX, BX, DX, SI, DS
163;--------------------------------------------------------------------
164CalculateProgressNeededBeforeUpdatingCharacter:
165 call MenuLocation_GetMaxTextLineLengthToAX
166 call GetProgressLengthToBXfromProgressDialogIoInDSSI
167 xchg ax, bx
168 xor dx, dx
169 div bx
170 mov [si+PROGRESS_DIALOG_IO.wProgressPerCharacter], ax
171 stc
172 ret
173
174
175;--------------------------------------------------------------------
176; DrawProgressBarFromDialogIoInDSSI
177; Parameters:
178; DS:SI: Ptr to PROGRESS_DIALOG_IO
179; SS:BP: Ptr to DIALOG
180; Returns:
181; Nothing
182; Corrupts:
183; AX, BX, CX, DX, DI
184;--------------------------------------------------------------------
185ALIGN JUMP_ALIGN
186DrawProgressBarFromDialogIoInDSSI:
[181]187 ; Get full chars to CX and empty chars to DX
[41]188 call MenuLocation_GetMaxTextLineLengthToAX
189 mov cx, ax
190 mul WORD [si+PROGRESS_DIALOG_IO.wCurrentProgressValue]
191 call GetProgressLengthToBXfromProgressDialogIoInDSSI
192 div bx
193 xchg cx, ax ; AX = Text line length, CX = Number of full chars
194 sub ax, cx
195 xchg dx, ax ; DX = Number of empty chars
196
[181]197 mov al, PROGRESS_COMPLETE_CHARACTER
198 call .RepeatProgressCharacterCXtimesFromAL
199
200 mov cx, dx
201 mov al, PROGRESS_INCOMPLETE_CHARACTER
202 ; Fall to .RepeatProgressCharacterCXtimesFromAL
203
[69]204;--------------------------------------------------------------------
205; .RepeatProgressCharacterCXtimesFromAL
206; Parameters:
207; AL: Progress bar character to repeat
208; CX: Number of times to repeat the progress character
209; Returns:
210; Nothing
211; Corrupts:
212; AX, CX, DI
213;--------------------------------------------------------------------
214ALIGN JUMP_ALIGN
215.RepeatProgressCharacterCXtimesFromAL:
[505]216 JMP_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
[41]217
[69]218
[41]219;--------------------------------------------------------------------
220; GetProgressLengthToBXfromProgressDialogIoInDSSI
221; Parameters:
222; DS:SI: Ptr to PROGRESS_DIALOG_IO
223; Returns:
224; BX: Progress length
225; Corrupts:
226; Nothing
227;--------------------------------------------------------------------
228ALIGN JUMP_ALIGN
229GetProgressLengthToBXfromProgressDialogIoInDSSI:
230 mov bx, [si+PROGRESS_DIALOG_IO.wMaxProgressValue]
231 sub bx, [si+PROGRESS_DIALOG_IO.wMinProgressValue]
232 ret
233
[181]234
[41]235;--------------------------------------------------------------------
236; DrawTimeElapsedFromDX
237; Parameters:
238; DX: Ticks elapsed
239; Returns:
240; Nothing
241; Corrupts:
242; AX, BX, CX, DI
243;--------------------------------------------------------------------
244ALIGN JUMP_ALIGN
245DrawTimeElapsedFromDX:
246 push si
247 push dx
248
249 mov si, g_szTimeElapsed
250 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
251 call FormatTicksFromDX
252
253 pop dx
254 pop si
255 ret
256
257
258;--------------------------------------------------------------------
259; DrawTimeLeftFromProgressDialogIoInDSSIwithTimeElapsedInDX
260; Parameters:
261; DX: Ticks elapsed
262; DS:SI: Ptr to PROGRESS_DIALOG_IO
263; Returns:
264; Nothing
265; Corrupts:
266; AX, BX, CX, DX, SI, DI
267;--------------------------------------------------------------------
268ALIGN JUMP_ALIGN
269DrawTimeLeftFromProgressDialogIoInDSSIwithTimeElapsedInDX:
270 push si
271 mov si, g_szTimeLeft
272 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
273 pop si
274
275 mov cx, [si+PROGRESS_DIALOG_IO.wCurrentProgressValue]
276 mov ax, [si+PROGRESS_DIALOG_IO.wMaxProgressValue]
277 sub ax, cx
278 mul dx ; Progress left * elapsed time
279
280 sub cx, [si+PROGRESS_DIALOG_IO.wMinProgressValue]
[181]281 jz SHORT .PreventDivisionByZero
[41]282 div cx ; AX = Estimated ticks left
283 xchg dx, ax
[491]284 SKIP2B ax
[41]285.PreventDivisionByZero:
286 xor dx, dx
287 ; Fall to FormatTicksFromDX
288
289
290;--------------------------------------------------------------------
291; FormatTicksFromDX
292; Parameters:
293; DX: Ticks to format
294; Returns:
295; Nothing
296; Corrupts:
297; AX, CX, DX, SI, DI
298;--------------------------------------------------------------------
299ALIGN JUMP_ALIGN
300FormatTicksFromDX:
301 push bp
302
303 mov bp, sp
304 mov si, g_szTimeFormat
[491]305 call TimerTicks_GetMinutesToAXandRemainderTicksToDXfromTicksInDX
[41]306 push ax
307 call TimerTicks_GetSecondsToAXfromTicksInDX
308 push ax
309 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
310
311 pop bp
312 ret
Note: See TracBrowser for help on using the repository browser.