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

Last change on this file since 589 was 589, checked in by Krister Nordvall, 9 years ago

Changes:

  • BIOS: Fixed a purely cosmetic bug from r542 where, in builds containing MODULE_EBIOS, the boot menu would display an incorrect drive size (0.4 kB with MODULE_STRINGS_COMPRESSED or 0.5 kB without) for old drives with no support for LBA.
  • Fixed a bug from r392 where Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent would return the ID in AL instead of AH (if DANGEROUS_DETECTION had been defined).
  • Fixed a bug from r587 in AdvAtaInit.asm that would prevent detection of QDI Vision controllers.
  • Also changed how the QDI Vision IDs are defined (removed the need for shifting) to avoid confusion. This fixed a potential bug from r587 in AdvAtaInit.asm where some IDs were not being shifted.
  • Fixed a bug in PDC20x30.asm from r587 where GetPdcIDtoAX would not return with the IDE base port in DX so DisablePdcProgrammingMode would fail.
  • Made some changes to ModuleDependency.inc and other files so that MODULE_ADVANCED_ATA now requires USE_386. Consequently it is no longer included in the regular AT-builds, only in the 386_8k-build.
  • Moved the UNROLL_SECTORS_IN_CX_TO_xWORDS macros from IDE_8bit.inc to IdeIO.inc which means it's now possible to build a BIOS without MODULE_8BIT_IDE.
  • XTIDECFG: Added a minimum DOS version check (since it needs DOS version 2+) to allow the program to quit gracefully in the unlikely scenario where someone tries to run it under DOS version 1.
  • Made some changes to Drive.asm to improve drive enumeration. The old method using GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE worked well in Windows XP but not in Windows 98 SE (in Windows or in DOS mode). The two problems were; 1) The function call would access the drives which on single floppy drive systems would cause Windows to swap between A: and B: (throwing a blue screen asking the user to insert a disk etc). 2) Only floppy drives and FAT16 drives would be available in the list of drives, no FAT32/optical/network drives.
  • Improved code in IdeControllerMenu.asm so that the default port addresses for all IDE interfaces are now restored when (re-)selecting the (same) type of IDE device.
  • Also made it impossible to select a device type unless the required module is included in the loaded BIOS.
  • The version check done when loading a BIOS now uses the FLASH_SIGNATURE definition from Version.inc. Any changes affecting RomVars now only requires updating that definition. This means that changes to RomVars must be implemented in both the BIOS and XTIDECFG before being committed to the repository.
  • Added a compatibility fix for 3Com 3C503 cards to the ROM checksumming code in Buffers.asm (Buffers_GenerateChecksum).
  • SerDrive: Made some minor changes to file names and paths to improve compatibility with case sensitive environments.
  • BIOSDRVS: Made a minor size optimization which as a side effect also makes it compatible with all DOS versions including DOS version 1.
  • Library: Renamed the WAIT_RETRACE_IF_NECESSARY_THEN macro to CALL_WAIT_FOR_RETRACE_IF_NECESSARY_THEN and made a tail-call-optimized version of it (JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN).
  • A speed optimization to the eRCL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Other minor optimizations and fixes.
File size: 12.6 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 OR MODULE_BOOT_MENU
299 %undef EXCLUDE
300 %endif
301%endif
302
303%ifndef EXCLUDE
304;--------------------------------------------------------------------
305; DisplayPrint_RepeatCharacterFromALwithCountInCX
306; Parameters:
307; AL: Character to display
308; CX: Repeat count
309; DS: BDA segment (zero)
310; ES:DI: Ptr to cursor location in video RAM
311; Returns:
312; DI: Updated offset to video RAM
313; Corrupts registers:
314; DX
315;--------------------------------------------------------------------
316ALIGN DISPLAY_JUMP_ALIGN
317DisplayPrint_RepeatCharacterFromALwithCountInCX:
318 jcxz .NothingToRepeat
319 push cx
320
321ALIGN DISPLAY_JUMP_ALIGN
322.RepeatCharacter:
323 push ax
324 call DisplayPrint_CharacterFromAL
325 pop ax
326 loop .RepeatCharacter
327
328 pop cx
329.NothingToRepeat:
330 ret
331%endif
332%undef EXCLUDE
333
334;--------------------------------------------------------------------
335; DisplayPrint_NullTerminatedStringFromCSSI
336; Parameters:
337; CS:SI: Ptr to NULL terminated string
338; DS: BDA segment (zero)
339; ES:DI: Ptr to cursor location in video RAM
340; Returns:
341; DI: Updated offset to video RAM
342; Corrupts registers:
343; AX, DX
344;--------------------------------------------------------------------
345%ifndef MODULE_STRINGS_COMPRESSED
346;;;
347;;; Take care when using this routine with compressed strings (which is why it is disabled).
348;;; All strings in CSSI should go through the DisplayFormatCompressed code to be decoded.
349;;;
350ALIGN DISPLAY_JUMP_ALIGN
351DisplayPrint_NullTerminatedStringFromCSSI:
352 push bx
353 mov bx, cs
354 call DisplayPrint_NullTerminatedStringFromBXSI
355 pop bx
356 ret
357%endif
358
359
360;;;
361;;; Note that the following routines need to be at the bottom of this file
362;;; to accomodate short jumps from the next file (DisplayFormat/DisplayFormatCompressed)
363;;;
364
365;--------------------------------------------------------------------
366; DisplayPrint_Newline
367; Parameters:
368; DS: BDA segment (zero)
369; ES:DI: Ptr to cursor location in video RAM
370; Returns:
371; DI: Updated offset to video RAM
372; Corrupts registers:
373; AX, DX
374;--------------------------------------------------------------------
375%ifdef MODULE_STRINGS_COMPRESSED
376ALIGN DISPLAY_JUMP_ALIGN
377DisplayPrint_Newline_FormatAdjustBP:
378 inc bp ; we didn't need a parameter after all, readjust BP
379 inc bp
380 ; fall through to DisplayPrint_Newline
381%endif
382
383ALIGN DISPLAY_JUMP_ALIGN
384DisplayPrint_Newline:
385 mov al, LF
386 call DisplayPrint_CharacterFromAL
387 mov al, CR
388 ; Fall to DisplayPrint_CharacterFromAL
389
390;--------------------------------------------------------------------
391; DisplayPrint_CharacterFromAL
392; Parameters:
393; AL: Character to display
394; Zero value is ignored (no character is printed)
395; DS: BDA segment (zero)
396; ES:DI: Ptr to cursor location in video RAM
397; Returns:
398; DI: Updated offset to video RAM
399; Corrupts registers:
400; AX, DX
401;--------------------------------------------------------------------
402ALIGN DISPLAY_JUMP_ALIGN
403DisplayPrint_CharacterFromAL:
404 test al, al
405 jz DisplayPrint_Ret
406
407 mov ah, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute]
408 jmp [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut]
409
410
411;--------------------------------------------------------------------
412; DisplayPrint_NullTerminatedStringFromBXSI
413; Parameters:
414; DS: BDA segment (zero)
415; BX:SI: Ptr to NULL terminated string
416; ES:DI: Ptr to cursor location in video RAM
417; Returns:
418; DI: Updated offset to video RAM
419; Corrupts registers:
420; AX, DX
421;--------------------------------------------------------------------
422ALIGN DISPLAY_JUMP_ALIGN
423DisplayPrint_NullTerminatedStringFromBXSI:
424 push si
425 push cx
426
427 xor cx, cx
428ALIGN DISPLAY_JUMP_ALIGN
429.PrintNextCharacter:
430 mov ds, bx ; String segment to DS
431 lodsb
432 mov ds, cx ; BDA segment to DS
433 test al, al ; NULL?
434 jz SHORT .EndOfString
435 call DisplayPrint_CharacterFromAL
436 jmp SHORT .PrintNextCharacter
437
438ALIGN DISPLAY_JUMP_ALIGN
439.EndOfString:
440 pop cx
441 pop si
442
443DisplayPrint_Ret: ; random ret to jump to
444 ret
445
Note: See TracBrowser for help on using the repository browser.