source: xtideuniversalbios/trunk/Assembly_Library/Src/Display/DisplayPrint.asm @ 567

Last change on this file since 567 was 567, checked in by krille_n_@…, 10 years ago

Changes:

  • Renamed MODULE_FEATURE_SETS to MODULE_POWER_MANAGEMENT.
  • Renamed MODULE_VERY_LATE_INITIALIZATION to MODULE_VERY_LATE_INIT and removed it from the official builds.
  • Removed the code that skips detection of slave drives on XT-CF controllers since slave drives can be used with Lo-tech ISA CompactFlash boards.
  • Added autodetection of the SVC ADP50L controller to XTIDECFG.
  • The autodetection of XT-CF controllers now requires MODULE_8BIT_IDE_ADVANCED in the loaded BIOS.
  • Fixed a bug in XTIDECFG from r502 where the "Base (cmd block) address" menu option would be displayed when a serial device was selected as the IDE controller.
  • XTIDECFG would display the "Enable interrupt" menu option for the XTIDE r1 but not for the XTIDE r2. It's now displayed for both controller types.
  • Disabled the "Internal Write Cache" menu option in the Master/Slave Drive menus for serial device type drives.
  • Optimizations and other fixes.
File size: 12.7 KB
Line 
1; Project name  :   Assembly Library
2; Description   :   Functions for display output.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
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.
12;
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
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing code
21SECTION .text
22
23
24;--------------------------------------------------------------------
25; Supports following formatting types:
26;   %a      Specifies attribute for next character
27;   %A      Specifies attribute for remaining string (or until next %A)
28;   %d      Prints signed 16-bit decimal integer
29;   %u      Prints unsigned 16-bit decimal integer
30;   %x      Prints 16-bit hexadecimal integer
31;   %s      Prints string (from CS segment)
32;   %S      Prints string (far pointer)
33;   %c      Prints character
34;   %t      Prints character number of times (character needs to be pushed first, then repeat times)
35;   %%      Prints '%' character (no parameter pushed)
36;
37;   Any placeholder can be set to minimum length by specifying
38;   minimum number of characters. For example %8d would append spaces
39;   after integer so that at least 8 characters would be printed.
40;
41;   When placing '-' after number, then spaces will be used for prepending.
42;   For example %8-d would prepend integer with spaces so that at least
43;   8 characters would be printed.
44;
45; DisplayPrint_FormattedNullTerminatedStringFromCSSI
46;   Parameters:
47;       BP:     SP before pushing parameters
48;       DS:     BDA segment (zero)
49;       CS:SI:  Pointer to string to format
50;       ES:DI:  Ptr to cursor location in video RAM
51;       Stack:  Parameters for formatting placeholders.
52;               Parameter for first placeholder must be pushed first.
53;               Low word must pushed first for placeholders requiring
54;               32-bit parameters (two words).
55;   Returns:
56;       DI:     Updated offset to video RAM
57;   Corrupts registers:
58;       AX, DX
59;--------------------------------------------------------------------
60ALIGN DISPLAY_JUMP_ALIGN
61DisplayPrint_FormattedNullTerminatedStringFromCSSI:
62    push    bp
63    push    si
64    push    cx
65    push    bx
66    push    WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute]
67
68    dec     bp                  ; Point BP to...
69    dec     bp                  ; ...first stack parameter
70    call    DisplayFormat_ParseCharacters
71
72    ; Pop original character attribute
73    pop     ax
74    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], al
75
76    pop     bx
77    pop     cx
78    pop     si
79    pop     bp
80
81    ret
82
83
84;--------------------------------------------------------------------
85; DisplayPrint_SignedWordFromAXWithBaseInBX
86;   Parameters:
87;       AX:     Word to display
88;       BX:     Integer base (binary=2, octal=8, decimal=10, hexadecimal=16)
89;       DS:     BDA segment (zero)
90;       ES:DI:  Ptr to cursor location in video RAM
91;   Returns:
92;       DI:     Updated offset to video RAM
93;   Corrupts registers:
94;       AX, DX
95;--------------------------------------------------------------------
96%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
97ALIGN DISPLAY_JUMP_ALIGN
98DisplayPrint_SignedWordFromAXWithBaseInBX:
99    test    ax, ax
100    jns     SHORT DisplayPrint_WordFromAXWithBaseInBX
101
102    push    ax
103    mov     al, '-'
104    call    DisplayPrint_CharacterFromAL
105    pop     ax
106    neg     ax
107    ; Fall to DisplayPrint_WordFromAXWithBaseInBX
108%endif
109
110
111;--------------------------------------------------------------------
112; DisplayPrint_WordFromAXWithBaseInBX
113;   Parameters:
114;       AX:     Word to display
115;       BX:     Integer base (binary=2, octal=8, decimal=10, hexadecimal=16)
116;       DS:     BDA segment (zero)
117;       ES:DI:  Ptr to cursor location in video RAM
118;   Returns:
119;       DI:     Updated offset to video RAM
120;   Corrupts registers:
121;       AX, DX
122;--------------------------------------------------------------------
123%ifndef MODULE_STRINGS_COMPRESSED
124ALIGN DISPLAY_JUMP_ALIGN
125DisplayPrint_WordFromAXWithBaseInBX:
126    push    cx
127    push    bx
128
129    xor     cx, cx
130ALIGN DISPLAY_JUMP_ALIGN
131.DivideLoop:
132    xor     dx, dx              ; DX:AX now holds the integer
133    div     bx                  ; Divide DX:AX by base
134    push    dx                  ; Push remainder
135    inc     cx                  ; Increment character count
136    test    ax, ax              ; All divided?
137    jnz     SHORT .DivideLoop   ;  If not, loop
138
139PrintAllPushedDigits:           ; Unused entrypoint OK
140    mov     bx, g_rgcDigitToCharacter
141ALIGN DISPLAY_JUMP_ALIGN
142.PrintNextDigit:
143    pop     ax                  ; Pop digit
144    cs xlatb
145    call    DisplayPrint_CharacterFromAL
146    loop    .PrintNextDigit
147
148    pop     bx
149    pop     cx
150    ret
151
152g_rgcDigitToCharacter:  db  "0123456789ABCDEF"
153
154%endif ; MODULE_STRINGS_COMPRESSED
155
156;--------------------------------------------------------------------
157; DisplayPrint_QWordFromSSBPwithBaseInBX
158;   Parameters:
159;       SS:BP:  QWord to display
160;       BX:     Integer base (binary=2, octal=8, decimal=10, hexadecimal=16)
161;       DS:     BDA segment (zero)
162;       ES:DI:  Ptr to cursor location in video RAM
163;   Returns:
164;       DI:     Updated offset to video RAM
165;   Corrupts registers:
166;       AX, DX, [SS:BP]
167;--------------------------------------------------------------------
168%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
169ALIGN DISPLAY_JUMP_ALIGN
170DisplayPrint_QWordFromSSBPwithBaseInBX:
171    push    cx
172    push    bx
173
174    mov     cx, bx              ; CX = Integer base
175    xor     bx, bx              ; BX = Character count
176ALIGN DISPLAY_JUMP_ALIGN
177.DivideLoop:
178    call    Math_DivQWatSSBPbyCX; Divide by base
179    push    dx                  ; Push remainder
180    inc     bx                  ; Increment character count
181    cmp     WORD [bp], BYTE 0   ; All divided?
182    jne     SHORT .DivideLoop   ;  If not, loop
183    mov     cx, bx              ; Character count to CX
184    jmp     SHORT PrintAllPushedDigits
185%endif
186
187
188;--------------------------------------------------------------------
189; DisplayPrint_CharacterBufferFromBXSIwithLengthInCX
190;   Parameters:
191;       CX:     Buffer length (characters)
192;       BX:SI:  Ptr to NULL terminated string
193;       DS:     BDA segment (zero)
194;       ES:DI:  Ptr to cursor location in video RAM
195;   Returns:
196;       DI:     Updated offset to video RAM
197;   Corrupts registers:
198;       AX, DX
199;--------------------------------------------------------------------
200%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
201ALIGN DISPLAY_JUMP_ALIGN
202DisplayPrint_CharacterBufferFromBXSIwithLengthInCX:
203    jcxz    .NothingToPrintSinceZeroLength
204    push    si
205    push    cx
206
207ALIGN DISPLAY_JUMP_ALIGN
208.PrintNextCharacter:
209    mov     ds, bx
210    lodsb
211    LOAD_BDA_SEGMENT_TO ds, dx
212    call    DisplayPrint_CharacterFromAL
213    loop    .PrintNextCharacter
214
215    pop     cx
216    pop     si
217.NothingToPrintSinceZeroLength:
218    ret
219%endif
220
221
222;--------------------------------------------------------------------
223; DisplayPrint_ClearScreenWithCharInALandAttributeInAH
224;   Parameters:
225;       AL:     Character to clear with
226;       AH:     Attribute to clear with
227;       DS:     BDA segment (zero)
228;       ES:DI:  Ptr to cursor location in video RAM
229;   Returns:
230;       Nothing
231;   Corrupts registers:
232;       AX, DX
233;--------------------------------------------------------------------
234%ifdef INCLUDE_MENU_LIBRARY
235ALIGN DISPLAY_JUMP_ALIGN
236DisplayPrint_ClearScreenWithCharInALandAttributeInAH:
237    push    di
238    push    cx
239
240    xchg    cx, ax
241    xor     ax, ax
242    call    DisplayCursor_SetCoordinatesFromAX      ; Updates DI
243    call    DisplayPage_GetColumnsToALandRowsToAH
244    mul     ah      ; AX = AL*AH = Characters on screen
245    xchg    cx, ax  ; AX = Char+Attr, CX = WORDs to store
246    rep stosw
247
248    pop     cx
249    pop     di
250    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], di
251    ret
252%endif
253
254
255;--------------------------------------------------------------------
256; DisplayPrint_ClearAreaWithHeightInAHandWidthInAL
257;   Parameters:
258;       AH:     Area height
259;       AL:     Area width
260;       DS:     BDA segment (zero)
261;       ES:DI:  Ptr to cursor location in video RAM
262;   Returns:
263;       DI:     Updated offset to video RAM
264;   Corrupts registers:
265;       AX, DX
266;--------------------------------------------------------------------
267%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
268ALIGN DISPLAY_JUMP_ALIGN
269DisplayPrint_ClearAreaWithHeightInAHandWidthInAL:
270    push    si
271    push    cx
272    push    bx
273
274    xchg    bx, ax                          ; Area size to BX
275    call    DisplayCursor_GetSoftwareCoordinatesToAX
276    xchg    si, ax                          ; Software (Y,X) coordinates now in SI
277    xor     cx, cx
278
279ALIGN DISPLAY_JUMP_ALIGN
280.ClearRowLoop:
281    mov     cl, bl                          ; Area width now in CX
282    mov     al, SCREEN_BACKGROUND_CHARACTER
283    call    DisplayPrint_RepeatCharacterFromALwithCountInCX
284
285    xchg    ax, si                          ; Coordinates to AX
286    inc     ah                              ; Increment row
287    mov     si, ax
288    call    DisplayCursor_SetCoordinatesFromAX
289    dec     bh                              ; Decrement rows left
290    jnz     SHORT .ClearRowLoop
291
292    pop     bx
293    pop     cx
294    pop     si
295    ret
296%endif
297
298%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
299    %define EXCLUDE
300    %ifndef MODULE_STRINGS_COMPRESSED
301        %undef EXCLUDE
302    %endif
303    %ifdef MODULE_HOTKEYS
304        %undef EXCLUDE
305    %endif
306    %ifdef MODULE_BOOT_MENU
307        %undef EXCLUDE
308    %endif
309%endif
310
311%ifndef EXCLUDE
312;--------------------------------------------------------------------
313; DisplayPrint_RepeatCharacterFromALwithCountInCX
314;   Parameters:
315;       AL:     Character to display
316;       CX:     Repeat count
317;       DS:     BDA segment (zero)
318;       ES:DI:  Ptr to cursor location in video RAM
319;   Returns:
320;       DI:     Updated offset to video RAM
321;   Corrupts registers:
322;       DX
323;--------------------------------------------------------------------
324ALIGN DISPLAY_JUMP_ALIGN
325DisplayPrint_RepeatCharacterFromALwithCountInCX:
326    jcxz    .NothingToRepeat
327    push    cx
328
329ALIGN DISPLAY_JUMP_ALIGN
330.RepeatCharacter:
331    push    ax
332    call    DisplayPrint_CharacterFromAL
333    pop     ax
334    loop    .RepeatCharacter
335
336    pop     cx
337.NothingToRepeat:
338    ret
339%endif
340%undef EXCLUDE
341
342;--------------------------------------------------------------------
343; DisplayPrint_NullTerminatedStringFromCSSI
344;   Parameters:
345;       CS:SI:  Ptr to NULL terminated string
346;       DS:     BDA segment (zero)
347;       ES:DI:  Ptr to cursor location in video RAM
348;   Returns:
349;       DI:     Updated offset to video RAM
350;   Corrupts registers:
351;       AX, DX
352;--------------------------------------------------------------------
353%ifndef MODULE_STRINGS_COMPRESSED
354;;;
355;;; Take care when using this routine with compressed strings (which is why it is disabled).
356;;; All strings in CSSI should go through the DisplayFormatCompressed code to be decoded.
357;;;
358ALIGN DISPLAY_JUMP_ALIGN
359DisplayPrint_NullTerminatedStringFromCSSI:
360    push    bx
361    mov     bx, cs
362    call    DisplayPrint_NullTerminatedStringFromBXSI
363    pop     bx
364    ret
365%endif
366
367
368;;;
369;;; Note that the following routines need to be at the bottom of this file
370;;; to accomodate short jumps from the next file (DisplayFormat/DisplayFormatCompressed)
371;;;
372
373;--------------------------------------------------------------------
374; DisplayPrint_Newline
375;   Parameters:
376;       DS:     BDA segment (zero)
377;       ES:DI:  Ptr to cursor location in video RAM
378;   Returns:
379;       DI:     Updated offset to video RAM
380;   Corrupts registers:
381;       AX, DX
382;--------------------------------------------------------------------
383%ifdef MODULE_STRINGS_COMPRESSED
384ALIGN DISPLAY_JUMP_ALIGN
385DisplayPrint_Newline_FormatAdjustBP:
386    inc     bp                  ; we didn't need a parameter after all, readjust BP
387    inc     bp
388    ; fall through to DisplayPrint_Newline
389%endif
390
391ALIGN DISPLAY_JUMP_ALIGN
392DisplayPrint_Newline:
393    mov     al, LF
394    call    DisplayPrint_CharacterFromAL
395    mov     al, CR
396    ; Fall to DisplayPrint_CharacterFromAL
397
398;--------------------------------------------------------------------
399; DisplayPrint_CharacterFromAL
400;   Parameters:
401;       AL:     Character to display
402;               Zero value is ignored (no character is printed)
403;       DS:     BDA segment (zero)
404;       ES:DI:  Ptr to cursor location in video RAM
405;   Returns:
406;       DI:     Updated offset to video RAM
407;   Corrupts registers:
408;       AX, DX
409;--------------------------------------------------------------------
410ALIGN DISPLAY_JUMP_ALIGN
411DisplayPrint_CharacterFromAL:
412    test    al, al
413    jz      DisplayPrint_Ret
414
415    mov     ah, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute]
416    jmp     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut]
417
418
419;--------------------------------------------------------------------
420; DisplayPrint_NullTerminatedStringFromBXSI
421;   Parameters:
422;       DS:     BDA segment (zero)
423;       BX:SI:  Ptr to NULL terminated string
424;       ES:DI:  Ptr to cursor location in video RAM
425;   Returns:
426;       DI:     Updated offset to video RAM
427;   Corrupts registers:
428;       AX, DX
429;--------------------------------------------------------------------
430ALIGN DISPLAY_JUMP_ALIGN
431DisplayPrint_NullTerminatedStringFromBXSI:
432    push    si
433    push    cx
434
435    xor     cx, cx
436ALIGN DISPLAY_JUMP_ALIGN
437.PrintNextCharacter:
438    mov     ds, bx              ; String segment to DS
439    lodsb
440    mov     ds, cx              ; BDA segment to DS
441    test    al, al              ; NULL?
442    jz      SHORT .EndOfString
443    call    DisplayPrint_CharacterFromAL
444    jmp     SHORT .PrintNextCharacter
445
446ALIGN DISPLAY_JUMP_ALIGN
447.EndOfString:
448    pop     cx
449    pop     si
450
451DisplayPrint_Ret:               ; random ret to jump to
452    ret
453
Note: See TracBrowser for help on using the repository browser.