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

Last change on this file since 589 was 589, checked in by krille_n_, 8 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
RevLine 
[41]1; Project name  :   Assembly Library
2; Description   :   Functions for display output.
3
[376]4;
[491]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 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
[491]18;
[376]19
[41]20; Section containing code
21SECTION .text
22
[376]23
[41]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.
[48]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.
[162]44;
[41]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;--------------------------------------------------------------------
[369]60ALIGN DISPLAY_JUMP_ALIGN
[41]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
[376]80
[41]81    ret
82
83
84;--------------------------------------------------------------------
[44]85; DisplayPrint_SignedWordFromAXWithBaseInBX
[41]86;   Parameters:
87;       AX:     Word to display
[44]88;       BX:     Integer base (binary=2, octal=8, decimal=10, hexadecimal=16)
[41]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;--------------------------------------------------------------------
[134]96%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[369]97ALIGN DISPLAY_JUMP_ALIGN
[44]98DisplayPrint_SignedWordFromAXWithBaseInBX:
99    test    ax, ax
100    jns     SHORT DisplayPrint_WordFromAXWithBaseInBX
[41]101
102    push    ax
103    mov     al, '-'
104    call    DisplayPrint_CharacterFromAL
105    pop     ax
106    neg     ax
[44]107    ; Fall to DisplayPrint_WordFromAXWithBaseInBX
[134]108%endif
[41]109
[376]110
[41]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
[376]122;--------------------------------------------------------------------
[491]123%ifndef MODULE_STRINGS_COMPRESSED
[369]124ALIGN DISPLAY_JUMP_ALIGN
[41]125DisplayPrint_WordFromAXWithBaseInBX:
126    push    cx
127
128    xor     cx, cx
[369]129ALIGN DISPLAY_JUMP_ALIGN
[41]130.DivideLoop:
[580]131    inc     cx                  ; Increment character count
[41]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
[44]137
[580]138ALIGN DISPLAY_JUMP_ALIGN
[532]139PrintAllPushedDigits:           ; Unused entrypoint OK
[44]140.PrintNextDigit:
141    pop     ax                  ; Pop digit
[580]142    cmp     al, 10              ; Convert binary digit in AL to ASCII hex digit ('0'-'9' or 'A'-'F')
143    sbb     al, 69h
144    das
[41]145    call    DisplayPrint_CharacterFromAL
[44]146    loop    .PrintNextDigit
[41]147
148    pop     cx
149    ret
[580]150%endif ; ~MODULE_STRINGS_COMPRESSED
[341]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;--------------------------------------------------------------------
[491]164%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG
[369]165ALIGN DISPLAY_JUMP_ALIGN
[341]166DisplayPrint_QWordFromSSBPwithBaseInBX:
167    push    cx
168
169    mov     cx, bx              ; CX = Integer base
170    xor     bx, bx              ; BX = Character count
[369]171ALIGN DISPLAY_JUMP_ALIGN
[341]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
[580]178    xchg    cx, bx              ; Character count to CX, Integer base to BX
[341]179    jmp     SHORT PrintAllPushedDigits
[491]180%endif
[41]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;--------------------------------------------------------------------
[223]195%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[369]196ALIGN DISPLAY_JUMP_ALIGN
[41]197DisplayPrint_CharacterBufferFromBXSIwithLengthInCX:
[44]198    jcxz    .NothingToPrintSinceZeroLength
199    push    si
[41]200    push    cx
201
[369]202ALIGN DISPLAY_JUMP_ALIGN
[44]203.PrintNextCharacter:
204    mov     ds, bx
205    lodsb
206    LOAD_BDA_SEGMENT_TO ds, dx
207    call    DisplayPrint_CharacterFromAL
208    loop    .PrintNextCharacter
209
[41]210    pop     cx
[44]211    pop     si
212.NothingToPrintSinceZeroLength:
[41]213    ret
[376]214%endif
[41]215
[376]216
[41]217;--------------------------------------------------------------------
[67]218; DisplayPrint_ClearScreenWithCharInALandAttributeInAH
[41]219;   Parameters:
[67]220;       AL:     Character to clear with
221;       AH:     Attribute to clear with
[41]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;--------------------------------------------------------------------
[491]229%ifdef INCLUDE_MENU_LIBRARY
[369]230ALIGN DISPLAY_JUMP_ALIGN
[67]231DisplayPrint_ClearScreenWithCharInALandAttributeInAH:
[41]232    push    di
[67]233    push    cx
234
235    xchg    cx, ax
[41]236    xor     ax, ax
[67]237    call    DisplayCursor_SetCoordinatesFromAX      ; Updates DI
[41]238    call    DisplayPage_GetColumnsToALandRowsToAH
[67]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
[41]244    pop     di
245    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], di
246    ret
[489]247%endif
[491]248
249
[41]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:
[42]258;       DI:     Updated offset to video RAM
[41]259;   Corrupts registers:
260;       AX, DX
261;--------------------------------------------------------------------
[134]262%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[369]263ALIGN DISPLAY_JUMP_ALIGN
[41]264DisplayPrint_ClearAreaWithHeightInAHandWidthInAL:
[42]265    push    si
[41]266    push    cx
267    push    bx
268
[42]269    xchg    bx, ax                          ; Area size to BX
[41]270    call    DisplayCursor_GetSoftwareCoordinatesToAX
[42]271    xchg    si, ax                          ; Software (Y,X) coordinates now in SI
272    xor     cx, cx
[41]273
[369]274ALIGN DISPLAY_JUMP_ALIGN
[42]275.ClearRowLoop:
276    mov     cl, bl                          ; Area width now in CX
[44]277    mov     al, SCREEN_BACKGROUND_CHARACTER
[42]278    call    DisplayPrint_RepeatCharacterFromALwithCountInCX
[41]279
[42]280    xchg    ax, si                          ; Coordinates to AX
281    inc     ah                              ; Increment row
282    mov     si, ax
[41]283    call    DisplayCursor_SetCoordinatesFromAX
[42]284    dec     bh                              ; Decrement rows left
285    jnz     SHORT .ClearRowLoop
[41]286
287    pop     bx
288    pop     cx
[42]289    pop     si
[41]290    ret
[134]291%endif
[42]292
[492]293%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
294    %define EXCLUDE
[532]295    %ifndef MODULE_STRINGS_COMPRESSED
296        %undef EXCLUDE
297    %endif
[589]298    %ifdef MODULE_HOTKEYS OR MODULE_BOOT_MENU
[492]299        %undef EXCLUDE
300    %endif
301%endif
[42]302
[505]303%ifndef EXCLUDE
[42]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:
[181]314;       DX
[42]315;--------------------------------------------------------------------
[369]316ALIGN DISPLAY_JUMP_ALIGN
[42]317DisplayPrint_RepeatCharacterFromALwithCountInCX:
[44]318    jcxz    .NothingToRepeat
319    push    cx
320
[369]321ALIGN DISPLAY_JUMP_ALIGN
[44]322.RepeatCharacter:
[42]323    push    ax
324    call    DisplayPrint_CharacterFromAL
325    pop     ax
[44]326    loop    .RepeatCharacter
327
328    pop     cx
329.NothingToRepeat:
[42]330    ret
[492]331%endif
332%undef EXCLUDE
[223]333
[186]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;--------------------------------------------------------------------
[376]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;;;
[369]350ALIGN DISPLAY_JUMP_ALIGN
[186]351DisplayPrint_NullTerminatedStringFromCSSI:
352    push    bx
353    mov     bx, cs
354    call    DisplayPrint_NullTerminatedStringFromBXSI
355    pop     bx
356    ret
[376]357%endif
[42]358
359
[376]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
[42]365;--------------------------------------------------------------------
[44]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;--------------------------------------------------------------------
[376]375%ifdef MODULE_STRINGS_COMPRESSED
[369]376ALIGN DISPLAY_JUMP_ALIGN
[376]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
[369]383ALIGN DISPLAY_JUMP_ALIGN
[44]384DisplayPrint_Newline:
[52]385    mov     al, LF
386    call    DisplayPrint_CharacterFromAL
[44]387    mov     al, CR
388    ; Fall to DisplayPrint_CharacterFromAL
389
390;--------------------------------------------------------------------
[42]391; DisplayPrint_CharacterFromAL
392;   Parameters:
393;       AL:     Character to display
[567]394;               Zero value is ignored (no character is printed)
[42]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;--------------------------------------------------------------------
[369]402ALIGN DISPLAY_JUMP_ALIGN
[42]403DisplayPrint_CharacterFromAL:
[505]404    test    al, al
[376]405    jz      DisplayPrint_Ret
406
[42]407    mov     ah, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute]
408    jmp     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut]
[223]409
[376]410
[186]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;--------------------------------------------------------------------
[369]422ALIGN DISPLAY_JUMP_ALIGN
[186]423DisplayPrint_NullTerminatedStringFromBXSI:
424    push    si
425    push    cx
426
427    xor     cx, cx
[369]428ALIGN DISPLAY_JUMP_ALIGN
[186]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
[369]438ALIGN DISPLAY_JUMP_ALIGN
[186]439.EndOfString:
440    pop     cx
441    pop     si
[376]442
443DisplayPrint_Ret:               ; random ret to jump to
[186]444    ret
445
Note: See TracBrowser for help on using the repository browser.