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

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

Changes:

  • XTIDECFG: Fixed a bug from r459 where the menu option for selection of default boot drive would be missing if the BIOS had been built without MODULE_HOTKEYS. The menu option is now visible if either or both of MODULE_HOTKEYS and MODULE_BOOT_MENU is available.
  • BIOS: Disabled ATA-ID validation by adding a new define (NO_ATAID_VALIDATION) and making it the default for all builds since at least two WD Caviar drive models are incompatible with it.
  • Fixed the "No Fixed Disk Present in FDISK"-bug introduced in r551 which means the Tiny build now works without including MODULE_DRIVEXLATE.
  • Fixed a bug from r528 where pressing hotkey F6 would not initiate detection of serial drives.
  • Fixed a bug from r186 in DisplayFormatCompressed.asm where the boot menu would print the IRQ in hexadecimal format when it should be in decimal format.
  • Optimizations and 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
128 xor cx, cx
129ALIGN DISPLAY_JUMP_ALIGN
130.DivideLoop:
131 inc cx ; Increment character count
132 xor dx, dx ; DX:AX now holds the integer
133 div bx ; Divide DX:AX by base
134 push dx ; Push remainder
135 test ax, ax ; All divided?
136 jnz SHORT .DivideLoop ; If not, loop
137
138ALIGN DISPLAY_JUMP_ALIGN
139PrintAllPushedDigits: ; Unused entrypoint OK
140.PrintNextDigit:
141 pop ax ; Pop digit
142 cmp al, 10 ; Convert binary digit in AL to ASCII hex digit ('0'-'9' or 'A'-'F')
143 sbb al, 69h
144 das
145 call DisplayPrint_CharacterFromAL
146 loop .PrintNextDigit
147
148 pop cx
149 ret
150%endif ; ~MODULE_STRINGS_COMPRESSED
151
152;--------------------------------------------------------------------
153; DisplayPrint_QWordFromSSBPwithBaseInBX
154; Parameters:
155; SS:BP: QWord to display
156; BX: Integer base (binary=2, octal=8, decimal=10, hexadecimal=16)
157; DS: BDA segment (zero)
158; ES:DI: Ptr to cursor location in video RAM
159; Returns:
160; DI: Updated offset to video RAM
161; Corrupts registers:
162; AX, DX, [SS:BP]
163;--------------------------------------------------------------------
164%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
165ALIGN DISPLAY_JUMP_ALIGN
166DisplayPrint_QWordFromSSBPwithBaseInBX:
167 push cx
168
169 mov cx, bx ; CX = Integer base
170 xor bx, bx ; BX = Character count
171ALIGN DISPLAY_JUMP_ALIGN
172.DivideLoop:
173 call Math_DivQWatSSBPbyCX; Divide by base
174 push dx ; Push remainder
175 inc bx ; Increment character count
176 cmp WORD [bp], BYTE 0 ; All divided?
177 jne SHORT .DivideLoop ; If not, loop
178 xchg cx, bx ; Character count to CX, Integer base to BX
179 jmp SHORT PrintAllPushedDigits
180%endif
181
182
183;--------------------------------------------------------------------
184; DisplayPrint_CharacterBufferFromBXSIwithLengthInCX
185; Parameters:
186; CX: Buffer length (characters)
187; BX:SI: Ptr to NULL terminated string
188; DS: BDA segment (zero)
189; ES:DI: Ptr to cursor location in video RAM
190; Returns:
191; DI: Updated offset to video RAM
192; Corrupts registers:
193; AX, DX
194;--------------------------------------------------------------------
195%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
196ALIGN DISPLAY_JUMP_ALIGN
197DisplayPrint_CharacterBufferFromBXSIwithLengthInCX:
198 jcxz .NothingToPrintSinceZeroLength
199 push si
200 push cx
201
202ALIGN DISPLAY_JUMP_ALIGN
203.PrintNextCharacter:
204 mov ds, bx
205 lodsb
206 LOAD_BDA_SEGMENT_TO ds, dx
207 call DisplayPrint_CharacterFromAL
208 loop .PrintNextCharacter
209
210 pop cx
211 pop si
212.NothingToPrintSinceZeroLength:
213 ret
214%endif
215
216
217;--------------------------------------------------------------------
218; DisplayPrint_ClearScreenWithCharInALandAttributeInAH
219; Parameters:
220; AL: Character to clear with
221; AH: Attribute to clear with
222; DS: BDA segment (zero)
223; ES:DI: Ptr to cursor location in video RAM
224; Returns:
225; Nothing
226; Corrupts registers:
227; AX, DX
228;--------------------------------------------------------------------
229%ifdef INCLUDE_MENU_LIBRARY
230ALIGN DISPLAY_JUMP_ALIGN
231DisplayPrint_ClearScreenWithCharInALandAttributeInAH:
232 push di
233 push cx
234
235 xchg cx, ax
236 xor ax, ax
237 call DisplayCursor_SetCoordinatesFromAX ; Updates DI
238 call DisplayPage_GetColumnsToALandRowsToAH
239 mul ah ; AX = AL*AH = Characters on screen
240 xchg cx, ax ; AX = Char+Attr, CX = WORDs to store
241 rep stosw
242
243 pop cx
244 pop di
245 mov [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], di
246 ret
247%endif
248
249
250;--------------------------------------------------------------------
251; DisplayPrint_ClearAreaWithHeightInAHandWidthInAL
252; Parameters:
253; AH: Area height
254; AL: Area width
255; DS: BDA segment (zero)
256; ES:DI: Ptr to cursor location in video RAM
257; Returns:
258; DI: Updated offset to video RAM
259; Corrupts registers:
260; AX, DX
261;--------------------------------------------------------------------
262%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
263ALIGN DISPLAY_JUMP_ALIGN
264DisplayPrint_ClearAreaWithHeightInAHandWidthInAL:
265 push si
266 push cx
267 push bx
268
269 xchg bx, ax ; Area size to BX
270 call DisplayCursor_GetSoftwareCoordinatesToAX
271 xchg si, ax ; Software (Y,X) coordinates now in SI
272 xor cx, cx
273
274ALIGN DISPLAY_JUMP_ALIGN
275.ClearRowLoop:
276 mov cl, bl ; Area width now in CX
277 mov al, SCREEN_BACKGROUND_CHARACTER
278 call DisplayPrint_RepeatCharacterFromALwithCountInCX
279
280 xchg ax, si ; Coordinates to AX
281 inc ah ; Increment row
282 mov si, ax
283 call DisplayCursor_SetCoordinatesFromAX
284 dec bh ; Decrement rows left
285 jnz SHORT .ClearRowLoop
286
287 pop bx
288 pop cx
289 pop si
290 ret
291%endif
292
293%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
294 %define EXCLUDE
295 %ifndef MODULE_STRINGS_COMPRESSED
296 %undef EXCLUDE
297 %endif
298 %ifdef MODULE_HOTKEYS
299 %undef EXCLUDE
300 %endif
301 %ifdef MODULE_BOOT_MENU
302 %undef EXCLUDE
303 %endif
304%endif
305
306%ifndef EXCLUDE
307;--------------------------------------------------------------------
308; DisplayPrint_RepeatCharacterFromALwithCountInCX
309; Parameters:
310; AL: Character to display
311; CX: Repeat count
312; DS: BDA segment (zero)
313; ES:DI: Ptr to cursor location in video RAM
314; Returns:
315; DI: Updated offset to video RAM
316; Corrupts registers:
317; DX
318;--------------------------------------------------------------------
319ALIGN DISPLAY_JUMP_ALIGN
320DisplayPrint_RepeatCharacterFromALwithCountInCX:
321 jcxz .NothingToRepeat
322 push cx
323
324ALIGN DISPLAY_JUMP_ALIGN
325.RepeatCharacter:
326 push ax
327 call DisplayPrint_CharacterFromAL
328 pop ax
329 loop .RepeatCharacter
330
331 pop cx
332.NothingToRepeat:
333 ret
334%endif
335%undef EXCLUDE
336
337;--------------------------------------------------------------------
338; DisplayPrint_NullTerminatedStringFromCSSI
339; Parameters:
340; CS:SI: Ptr to NULL terminated string
341; DS: BDA segment (zero)
342; ES:DI: Ptr to cursor location in video RAM
343; Returns:
344; DI: Updated offset to video RAM
345; Corrupts registers:
346; AX, DX
347;--------------------------------------------------------------------
348%ifndef MODULE_STRINGS_COMPRESSED
349;;;
350;;; Take care when using this routine with compressed strings (which is why it is disabled).
351;;; All strings in CSSI should go through the DisplayFormatCompressed code to be decoded.
352;;;
353ALIGN DISPLAY_JUMP_ALIGN
354DisplayPrint_NullTerminatedStringFromCSSI:
355 push bx
356 mov bx, cs
357 call DisplayPrint_NullTerminatedStringFromBXSI
358 pop bx
359 ret
360%endif
361
362
363;;;
364;;; Note that the following routines need to be at the bottom of this file
365;;; to accomodate short jumps from the next file (DisplayFormat/DisplayFormatCompressed)
366;;;
367
368;--------------------------------------------------------------------
369; DisplayPrint_Newline
370; Parameters:
371; DS: BDA segment (zero)
372; ES:DI: Ptr to cursor location in video RAM
373; Returns:
374; DI: Updated offset to video RAM
375; Corrupts registers:
376; AX, DX
377;--------------------------------------------------------------------
378%ifdef MODULE_STRINGS_COMPRESSED
379ALIGN DISPLAY_JUMP_ALIGN
380DisplayPrint_Newline_FormatAdjustBP:
381 inc bp ; we didn't need a parameter after all, readjust BP
382 inc bp
383 ; fall through to DisplayPrint_Newline
384%endif
385
386ALIGN DISPLAY_JUMP_ALIGN
387DisplayPrint_Newline:
388 mov al, LF
389 call DisplayPrint_CharacterFromAL
390 mov al, CR
391 ; Fall to DisplayPrint_CharacterFromAL
392
393;--------------------------------------------------------------------
394; DisplayPrint_CharacterFromAL
395; Parameters:
396; AL: Character to display
397; Zero value is ignored (no character is printed)
398; DS: BDA segment (zero)
399; ES:DI: Ptr to cursor location in video RAM
400; Returns:
401; DI: Updated offset to video RAM
402; Corrupts registers:
403; AX, DX
404;--------------------------------------------------------------------
405ALIGN DISPLAY_JUMP_ALIGN
406DisplayPrint_CharacterFromAL:
407 test al, al
408 jz DisplayPrint_Ret
409
410 mov ah, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute]
411 jmp [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut]
412
413
414;--------------------------------------------------------------------
415; DisplayPrint_NullTerminatedStringFromBXSI
416; Parameters:
417; DS: BDA segment (zero)
418; BX:SI: Ptr to NULL terminated string
419; ES:DI: Ptr to cursor location in video RAM
420; Returns:
421; DI: Updated offset to video RAM
422; Corrupts registers:
423; AX, DX
424;--------------------------------------------------------------------
425ALIGN DISPLAY_JUMP_ALIGN
426DisplayPrint_NullTerminatedStringFromBXSI:
427 push si
428 push cx
429
430 xor cx, cx
431ALIGN DISPLAY_JUMP_ALIGN
432.PrintNextCharacter:
433 mov ds, bx ; String segment to DS
434 lodsb
435 mov ds, cx ; BDA segment to DS
436 test al, al ; NULL?
437 jz SHORT .EndOfString
438 call DisplayPrint_CharacterFromAL
439 jmp SHORT .PrintNextCharacter
440
441ALIGN DISPLAY_JUMP_ALIGN
442.EndOfString:
443 pop cx
444 pop si
445
446DisplayPrint_Ret: ; random ret to jump to
447 ret
448
Note: See TracBrowser for help on using the repository browser.