Changeset 44 in xtideuniversalbios for trunk


Ignore:
Timestamp:
Sep 27, 2010, 7:23:36 PM (14 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Spaces can now be generated before format specifier when printing formatted string.
Background character and attribute can now be easily specified before compiling.

Location:
trunk/Assembly_Library
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Inc/Display.inc

    r41 r44  
    22; Project name  :   AssemblyLibrary
    33; Created date  :   25.6.2010
    4 ; Last update   :   15.9.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Defines for display library.
     
    3737    .PushDisplayContext:
    3838    .PopDisplayContext:
    39     .InitializeDisplayContext                   resb    2
    40 
    41     .SetCharacterPointerFromBXAX                resb    2
    42     .SetCharacterOutputFunctionFromAX           resb    2
    43     .SetCharacterOutputParameterFromAX          resb    2
    44     .SetCharacterAttributeFromAL                resb    2
    45     .SetCursorShapeFromAX                       resb    2
    46     .SetCursorCoordinatesFromAX                 resb    2
    47     .SetNewPageFromAL                           resb    2
    48     .SynchronizeDisplayContextToHardware        resb    2
    49 
    50     .GetCharacterPointerToBXAX                  resb    2
    51     .GetSoftwareCoordinatesToAX                 resb    2
    52     .GetColumnsToALandRowsToAH                  resb    2
    53 
    54     .FormatNullTerminatedStringFromCSSI         resb    2
    55     .PrintSignedDecimalIntegerFromAX            resb    2
    56     .PrintWordFromAXwithBaseInBX                resb    2
    57     .PrintCharBufferFromBXSIwithLengthInCX      resb    2
    58     .PrintNullTerminatedStringFromBXSI          resb    2
    59     .PrintNullTerminatedStringFromCSSI          resb    2
    60     .PrintRepeatedCharacterFromALwithCountInCX  resb    2
    61     .PrintCharacterFromAL                       resb    2
    62     .PrintNewlineCharacters                     resb    2
    63     .ClearAreaWithHeightInAHandWidthInAL        resb    2
    64     .ClearScreen                                resb    2
     39    .InitializeDisplayContext                       resb    2
     40
     41    .SetCharacterPointerFromBXAX                    resb    2
     42    .SetCharOutputFunctionFromAXwithAttribFlagInDL  resb    2
     43    .SetCharacterOutputParameterFromAX              resb    2
     44    .SetCharacterAttributeFromAL                    resb    2
     45    .SetCursorShapeFromAX                           resb    2
     46    .SetCursorCoordinatesFromAX                     resb    2
     47    .SetNewPageFromAL                               resb    2
     48    .SynchronizeDisplayContextToHardware            resb    2
     49
     50    .GetCharacterPointerToBXAX                      resb    2
     51    .GetSoftwareCoordinatesToAX                     resb    2
     52    .GetColumnsToALandRowsToAH                      resb    2
     53
     54    .FormatNullTerminatedStringFromCSSI             resb    2
     55    .PrintSignedWordFromAXWithBaseInBX              resb    2
     56    .PrintWordFromAXwithBaseInBX                    resb    2
     57    .PrintCharBufferFromBXSIwithLengthInCX          resb    2
     58    .PrintNullTerminatedStringFromBXSI              resb    2
     59    .PrintNullTerminatedStringFromCSSI              resb    2
     60    .PrintRepeatedCharacterFromALwithCountInCX      resb    2
     61    .PrintCharacterFromAL                           resb    2
     62    .PrintNewlineCharacters                         resb    2
     63    .ClearAreaWithHeightInAHandWidthInAL            resb    2
     64    .ClearScreen                                    resb    2
    6565endstruc
    6666
    67 ; Character output functions for DISPLAY_LIB.SetCharacterOutputFunctionFromAX
     67; Attribute flags for DISPLAY_LIB.SetCharacterOutputFunctionFromAXwithAttributeFlagInDL
     68ATTRIBUTES_NOT_USED                         EQU     0
     69ATTRIBUTES_ARE_USED                         EQU     FLG_CONTEXT_ATTRIBUTES
     70
     71; Character output functions for DISPLAY_LIB.SetCharacterOutputFunctionFromAXwithAttributeFlagInDL
    6872TELETYPE_OUTPUT_WITH_ATTRIBUTE              EQU     DisplayCharOut_TeletypeOutputWithAttribute
    6973TELETYPE_OUTPUT_WITHOUT_ATTRIBUTE           EQU     DisplayCharOut_TeletypeOutput
     
    98102    .wCursorShape       resb    2   ; Current cursor shape
    99103    .bAttribute         resb    1   ; Selected character attribute
    100                         resb    1
     104    .bFlags             resb    1   ; Display context flags
    101105endstruc
     106
     107; Display context flags
     108FLG_CONTEXT_ATTRIBUTES      EQU     (1<<0)  ; Character output function uses attributes
    102109
    103110
     
    203210ANGLE_QUOTE_LEFT                            EQU     174
    204211ANGLE_QUOTE_RIGHT                           EQU     175
    205 
     212BLOCK_MOSTLY_BACKGROUND                     EQU     176
     213BLOCK_EVEN_BACKGROUND_AND_FOREGROUND        EQU     177
     214BLOCK_MOSTLY_FOREGROUND                     EQU     178
     215BLOCK_FULL_FOREGROUND                       EQU     219
     216
     217
     218; Background character for clearing screen
     219%ifndef SCREEN_BACKGROUND_CHARACTER
     220    %define SCREEN_BACKGROUND_CHARACTER     BLOCK_MOSTLY_BACKGROUND
     221%endif
     222%ifndef SCREEN_BACKGROUND_ATTRIBUTE
     223    %define SCREEN_BACKGROUND_ATTRIBUTE     MONO_NORMAL
     224%endif
    206225
    207226%endif ; DISPLAY_INC
  • trunk/Assembly_Library/Inc/Menu.inc

    r41 r44  
    125125MENU_TEXT_COLUMN_OFFSET             EQU     2
    126126
    127 SCROLL_TRACK_CHARACTER              EQU     176
    128 SCROLL_THUMB_CHARACTER              EQU     219
     127SCROLL_TRACK_CHARACTER              EQU     BLOCK_EVEN_BACKGROUND_AND_FOREGROUND
     128SCROLL_THUMB_CHARACTER              EQU     BLOCK_FULL_FOREGROUND
    129129
    130130NO_ITEM_SELECTED                    EQU     -1
  • trunk/Assembly_Library/Src/Display/Display.asm

    r41 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   2.7.2010
    4 ; Last update   :   13.8.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Display Library functions for CALL_DISPLAY_LIBRARY macro
     
    6565.rgfnDisplayLibraryFunctions:
    6666istruc DISPLAY_LIB
    67     at  DISPLAY_LIB.InitializeDisplayContext,                   dw  DisplayContext_Initialize
     67    at  DISPLAY_LIB.InitializeDisplayContext,                       dw  DisplayContext_Initialize
    6868
    69     at  DISPLAY_LIB.SetCharacterPointerFromBXAX,                dw  DisplayContext_SetCharacterPointerFromBXAX
    70     at  DISPLAY_LIB.SetCharacterOutputFunctionFromAX,           dw  DisplayContext_SetCharacterOutputFunctionFromAX
    71     at  DISPLAY_LIB.SetCharacterOutputParameterFromAX,          dw  DisplayContext_SetCharacterOutputParameterFromAX
    72     at  DISPLAY_LIB.SetCharacterAttributeFromAL,                dw  DisplayContext_SetCharacterAttributeFromAL
    73     at  DISPLAY_LIB.SetCursorShapeFromAX,                       dw  DisplayCursor_SetShapeFromAX
    74     at  DISPLAY_LIB.SetCursorCoordinatesFromAX,                 dw  DisplayCursor_SetCoordinatesFromAX
    75     at  DISPLAY_LIB.SetNewPageFromAL,                           dw  DisplayPage_SetFromAL
    76     at  DISPLAY_LIB.SynchronizeDisplayContextToHardware,        dw  DisplayContext_SynchronizeToHardware
     69    at  DISPLAY_LIB.SetCharacterPointerFromBXAX,                    dw  DisplayContext_SetCharacterPointerFromBXAX
     70    at  DISPLAY_LIB.SetCharOutputFunctionFromAXwithAttribFlagInDL,  dw  DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInDL
     71    at  DISPLAY_LIB.SetCharacterOutputParameterFromAX,              dw  DisplayContext_SetCharacterOutputParameterFromAX
     72    at  DISPLAY_LIB.SetCharacterAttributeFromAL,                    dw  DisplayContext_SetCharacterAttributeFromAL
     73    at  DISPLAY_LIB.SetCursorShapeFromAX,                           dw  DisplayCursor_SetShapeFromAX
     74    at  DISPLAY_LIB.SetCursorCoordinatesFromAX,                     dw  DisplayCursor_SetCoordinatesFromAX
     75    at  DISPLAY_LIB.SetNewPageFromAL,                               dw  DisplayPage_SetFromAL
     76    at  DISPLAY_LIB.SynchronizeDisplayContextToHardware,            dw  DisplayContext_SynchronizeToHardware
    7777
    78     at  DISPLAY_LIB.GetCharacterPointerToBXAX,                  dw  DisplayContext_GetCharacterPointerToBXAX
    79     at  DISPLAY_LIB.GetSoftwareCoordinatesToAX,                 dw  DisplayCursor_GetSoftwareCoordinatesToAX
    80     at  DISPLAY_LIB.GetColumnsToALandRowsToAH,                  dw  DisplayPage_GetColumnsToALandRowsToAH
     78    at  DISPLAY_LIB.GetCharacterPointerToBXAX,                      dw  DisplayContext_GetCharacterPointerToBXAX
     79    at  DISPLAY_LIB.GetSoftwareCoordinatesToAX,                     dw  DisplayCursor_GetSoftwareCoordinatesToAX
     80    at  DISPLAY_LIB.GetColumnsToALandRowsToAH,                      dw  DisplayPage_GetColumnsToALandRowsToAH
    8181
    82     at  DISPLAY_LIB.FormatNullTerminatedStringFromCSSI,         dw  .FormatNullTerminatedStringFromCSSI
    83     at  DISPLAY_LIB.PrintSignedDecimalIntegerFromAX,            dw  DisplayPrint_SignedDecimalIntegerFromAX
    84     at  DISPLAY_LIB.PrintWordFromAXwithBaseInBX,                dw  DisplayPrint_WordFromAXWithBaseInBX
    85     at  DISPLAY_LIB.PrintCharBufferFromBXSIwithLengthInCX,      dw  DisplayPrint_CharacterBufferFromBXSIwithLengthInCX
    86     at  DISPLAY_LIB.PrintNullTerminatedStringFromBXSI,          dw  DisplayPrint_NullTerminatedStringFromBXSI
    87     at  DISPLAY_LIB.PrintNullTerminatedStringFromCSSI,          dw  DisplayPrint_NullTerminatedStringFromCSSI
    88     at  DISPLAY_LIB.PrintRepeatedCharacterFromALwithCountInCX,  dw  DisplayPrint_RepeatCharacterFromALwithCountInCX
    89     at  DISPLAY_LIB.PrintCharacterFromAL,                       dw  DisplayPrint_CharacterFromAL
    90     at  DISPLAY_LIB.PrintNewlineCharacters,                     dw  DisplayPrint_Newline
    91     at  DISPLAY_LIB.ClearAreaWithHeightInAHandWidthInAL,        dw  DisplayPrint_ClearAreaWithHeightInAHandWidthInAL
    92     at  DISPLAY_LIB.ClearScreen,                                dw  DisplayPrint_ClearScreen
     82    at  DISPLAY_LIB.FormatNullTerminatedStringFromCSSI,             dw  .FormatNullTerminatedStringFromCSSI
     83    at  DISPLAY_LIB.PrintSignedWordFromAXWithBaseInBX,              dw  DisplayPrint_SignedWordFromAXWithBaseInBX
     84    at  DISPLAY_LIB.PrintWordFromAXwithBaseInBX,                    dw  DisplayPrint_WordFromAXWithBaseInBX
     85    at  DISPLAY_LIB.PrintCharBufferFromBXSIwithLengthInCX,          dw  DisplayPrint_CharacterBufferFromBXSIwithLengthInCX
     86    at  DISPLAY_LIB.PrintNullTerminatedStringFromBXSI,              dw  DisplayPrint_NullTerminatedStringFromBXSI
     87    at  DISPLAY_LIB.PrintNullTerminatedStringFromCSSI,              dw  DisplayPrint_NullTerminatedStringFromCSSI
     88    at  DISPLAY_LIB.PrintRepeatedCharacterFromALwithCountInCX,      dw  DisplayPrint_RepeatCharacterFromALwithCountInCX
     89    at  DISPLAY_LIB.PrintCharacterFromAL,                           dw  DisplayPrint_CharacterFromAL
     90    at  DISPLAY_LIB.PrintNewlineCharacters,                         dw  DisplayPrint_Newline
     91    at  DISPLAY_LIB.ClearAreaWithHeightInAHandWidthInAL,            dw  DisplayPrint_ClearAreaWithHeightInAHandWidthInAL
     92    at  DISPLAY_LIB.ClearScreen,                                    dw  DisplayPrint_ClearScreen
    9393iend
  • trunk/Assembly_Library/Src/Display/DisplayCharOut.asm

    r42 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   26.6.2010
    4 ; Last update   :   18.9.2010
     4; Last update   :   22.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for outputting characters to video memory.
     
    180180                    ; made without interfering with the display. (H or V retrace)
    181181    jc      SHORT %%WaitUntilNotInRetrace
    182     sti
    183     nop             ; Should have time to serve IRQ here
    184     cli
    185182%%WaitUntilNextRetraceStarts:
    186183    in      al, dx
  • trunk/Assembly_Library/Src/Display/DisplayContext.asm

    r41 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   25.6.2010
    4 ; Last update   :   13.8.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for managing display context.
     
    2323    mov     WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], DEFAULT_CHARACTER_OUTPUT
    2424    mov     WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCursorShape], CURSOR_NORMAL
    25     mov     BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], MONO_NORMAL
     25    mov     BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], SCREEN_BACKGROUND_ATTRIBUTE
     26    mov     BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_ATTRIBUTES
    2627
    2728    xor     ax, ax
     
    152153
    153154;--------------------------------------------------------------------
    154 ; DisplayContext_SetCharacterOutputFunctionFromAX
     155; DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInDL
    155156;   Parameters:
    156157;       AX:     Offset to character output function
    157 ;       DS:     BDA segment (zero)
    158 ;   Returns:
    159 ;       Nothing
    160 ;   Corrupts registers:
    161 ;       Nothing
    162 ;--------------------------------------------------------------------
    163 ALIGN JUMP_ALIGN
    164 DisplayContext_SetCharacterOutputFunctionFromAX:
     158;       DL:     Attribute Flag
     159;       DS:     BDA segment (zero)
     160;   Returns:
     161;       Nothing
     162;   Corrupts registers:
     163;       Nothing
     164;--------------------------------------------------------------------
     165ALIGN JUMP_ALIGN
     166DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInDL:
    165167    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut], ax
     168    and     BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], ~FLG_CONTEXT_ATTRIBUTES
     169    mov     al, dl
     170    and     al, FLG_CONTEXT_ATTRIBUTES
     171    or      [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], al
    166172    ret
    167173
     
    211217    mov     dx, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam]
    212218    ret
     219
     220
     221;--------------------------------------------------------------------
     222; DisplayContext_GetCharacterOffsetToAXfromByteOffsetInAX
     223;   Parameters:
     224;       AX:     Offset in bytes from some character to another
     225;       DS:     BDA segment (zero)
     226;   Returns:
     227;       AX:     Offset in characters from some character to another
     228;   Corrupts registers:
     229;       Nothing
     230;--------------------------------------------------------------------   
     231ALIGN JUMP_ALIGN
     232DisplayContext_GetCharacterOffsetToAXfromByteOffsetInAX:
     233    test    BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_ATTRIBUTES
     234    jz      SHORT ReturnOffsetInAX
     235    sar     ax, 1       ; BYTE count to WORD count
     236    ret
     237
     238;--------------------------------------------------------------------
     239; DisplayContext_GetByteOffsetToAXfromCharacterOffsetInAX
     240;   Parameters:
     241;       AX:     Offset in characters from some character to another
     242;       DS:     BDA segment (zero)
     243;   Returns:
     244;       AX:     Offset in bytes from some character to another
     245;   Corrupts registers:
     246;       Nothing
     247;--------------------------------------------------------------------   
     248ALIGN JUMP_ALIGN
     249DisplayContext_GetByteOffsetToAXfromCharacterOffsetInAX:
     250    test    BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_ATTRIBUTES
     251    jz      SHORT ReturnOffsetInAX
     252    sal     ax, 1       ; WORD count to BYTE count
     253ALIGN JUMP_ALIGN, ret
     254ReturnOffsetInAX:
     255    ret
  • trunk/Assembly_Library/Src/Display/DisplayFormat.asm

    r41 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   29.6.2010
    4 ; Last update   :   10.8.2010
     4; Last update   :   26.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for displaying formatted strings.
     
    1313;   Parameters:
    1414;       DS:     BDA segment (zero)
     15;       SS:BP:  Pointer to first format parameter (-=2 updates to next parameter)
     16;       CS:SI:  Pointer to string to format
     17;       ES:DI:  Ptr to cursor location in video RAM
     18;   Returns:
     19;       CS:SI:  Ptr to end of format string (ptr to one past NULL)
     20;       DI:     Updated offset to video RAM
     21;   Corrupts registers:
     22;       AX, BX, CX, DX, BP
     23;--------------------------------------------------------------------
     24ALIGN JUMP_ALIGN
     25DisplayFormat_ParseCharacters:
     26    call    ReadCharacterAndTestForNull
     27    jz      SHORT .QuitCharacterParsing
     28
     29    ePUSH_T cx, DisplayFormat_ParseCharacters   ; Return address
     30    xor     cx, cx                              ; Initial placeholder size
     31    cmp     al, '%'                             ; Format specifier?
     32    je      SHORT ParseFormatSpecifier
     33    jmp     DisplayPrint_CharacterFromAL
     34
     35ALIGN JUMP_ALIGN
     36.QuitCharacterParsing:
     37    ret
     38
     39
     40;--------------------------------------------------------------------
     41; ParseFormatSpecifier
     42;   Parameters:
     43;       CX:     Placeholder size
     44;       DS:     BDA segment (zero)
    1545;       SS:BP:  Pointer to first format parameter (-=2 for next parameter)
    1646;       CS:SI:  Pointer to string to format
    1747;       ES:DI:  Ptr to cursor location in video RAM
    1848;   Returns:
     49;       SI:     Updated to first unparsed character
    1950;       DI:     Updated offset to video RAM
    20 ;   Corrupts registers:
    21 ;       AX, BX, CX, DX, SI, BP
    22 ;--------------------------------------------------------------------
    23 ALIGN JUMP_ALIGN
    24 DisplayFormat_ParseCharacters:
    25     call    .ReadCharacterAndTestForNull
    26     jz      SHORT .Return
    27     xor     cx, cx                          ; Zero CX for parsing number parameter
    28     cmp     al, '%'
    29     je      SHORT .FormatParameterEncountered
    30     call    DisplayPrint_CharacterFromAL    ; Control or printable character
    31     jmp     SHORT DisplayFormat_ParseCharacters
    32 ALIGN JUMP_ALIGN
    33 .Return:
    34     ret
    35 
    36 ;--------------------------------------------------------------------
    37 ; .ReadCharacterAndTestForNull
    38 ;   Parameters:
    39 ;       CS:SI:  Pointer next character from string
    40 ;   Returns:
    41 ;       AL:     Character from string
    42 ;       SI:     Incremented to next character
    43 ;       ZF:     Set if NULL, cleared if valid character
    44 ;   Corrupts registers:
    45 ;       Nothing
    46 ;--------------------------------------------------------------------
    47 ALIGN JUMP_ALIGN
    48 .ReadCharacterAndTestForNull:
    49     eSEG    cs
    50     lodsb                                   ; Load from CS:SI to AL
    51     test    al, al                          ; NULL to end string?
    52     ret
    53 
    54 
    55 ;--------------------------------------------------------------------
    56 ; .FormatParameterEncountered
    57 ;   Parameters:
    58 ;       CX:     Zero or previous number parameter
    59 ;       DS:     BDA segment (zero)
    60 ;       SS:BP:  Pointer to next format parameter
    61 ;       CS:SI:  Pointer to next format string character
    62 ;       ES:DI:  Ptr to cursor location in video RAM
    63 ;   Returns:
    64 ;       SI:     Incremented to next character
    65 ;       BP:     Offset to next format parameter
    66 ;       Eventually jumps to DisplayFormat_ParseCharacters
     51;       BP:     Updated to next format parameter
    6752;   Corrupts registers:
    6853;       AX, BX, CX, DX
    6954;--------------------------------------------------------------------
    7055ALIGN JUMP_ALIGN
    71 .FormatParameterEncountered:
    72     call    .ReadCharacterAndTestForNull
    73     jz      SHORT .Return
     56ParseFormatSpecifier:
     57    call    ReadCharacterAndTestForNull
    7458    call    Char_IsDecimalDigitInAL
    75     jnc     SHORT .FormatWithCorrectFormatFunction
    76     ; Fall to .ParseNumberParameterToCX
    77 
    78 ;--------------------------------------------------------------------
    79 ; .ParseNumberParameterToCX
    80 ;   Parameters:
    81 ;       AL:     Number digit from format string
    82 ;       CX:     Zero or previous number parameter
    83 ;   Returns:
    84 ;       CX:     Updated number parameter
    85 ;       Jumps to .FormatParameterEncountered
     59    jc      SHORT .ParsePlaceholderSizeDigitFromALtoCX
     60    call    GetFormatSpecifierParserToAX
     61    call    ax              ; Parser function
     62    dec     bp
     63    dec     bp              ; SS:BP now points to next parameter
     64    test    cx, cx
     65    jnz     SHORT PrependOrAppendSpaces
     66    ret
     67
     68;--------------------------------------------------------------------
     69; .ParsePlaceholderSizeDigitFromALtoCX
     70;   Parameters:
     71;       AL:     Digit character from format string
     72;       CX:     Current placeholder size
     73;       DS:     BDA segment (zero)
     74;   Returns:
     75;       CX:     Current placeholder size
     76;       Jumps back to ParseFormatSpecifier
    8677;   Corrupts registers:
    8778;       AX
    8879;--------------------------------------------------------------------
    89 .ParseNumberParameterToCX:
     80ALIGN JUMP_ALIGN
     81.ParsePlaceholderSizeDigitFromALtoCX:
     82    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], di
    9083    sub     al, '0'             ; Digit '0'...'9' to integer 0...9
    9184    mov     ah, cl              ; Previous number parameter to AH
    9285    aad                         ; AL += (AH * 10)
    9386    mov     cl, al              ; Updated number parameter now in CX
    94     jmp     SHORT .FormatParameterEncountered
    95 
    96 ;--------------------------------------------------------------------
    97 ; .FormatWithCorrectFormatFunction
    98 ;   Parameters:
    99 ;       AL:     Format placeholder character (non digit character after '%')
    100 ;       CX:     Number parameter (zero if no number parameter present)
    101 ;       DS:     BDA segment (zero)
    102 ;       SS:BP:  Pointer to format parameter
    103 ;       CS:SI:  Pointer to next format string character
    104 ;       ES:DI:  Ptr to cursor location in video RAM
    105 ;   Returns:
    106 ;       Eventually jumps to DisplayFormat_ParseCharacters
     87    jmp     SHORT ParseFormatSpecifier
     88
     89
     90;--------------------------------------------------------------------
     91; ReadCharacterAndTestForNull
     92;   Parameters:
     93;       CS:SI:  Pointer next character from string
     94;   Returns:
     95;       AL:     Character from string
     96;       SI:     Incremented to next character
     97;       ZF:     Set if NULL, cleared if valid character
     98;   Corrupts registers:
     99;       Nothing
     100;--------------------------------------------------------------------
     101ALIGN JUMP_ALIGN
     102ReadCharacterAndTestForNull:
     103    eSEG    cs
     104    lodsb                                   ; Load from CS:SI to AL
     105    test    al, al                          ; NULL to end string?
     106    ret
     107
     108
     109;--------------------------------------------------------------------
     110; GetFormatSpecifierParserToAX
     111;   Parameters:
     112;       AL:     Format specifier character
     113;   Returns:
     114;       AX:     Offset to parser function
     115;   Corrupts registers:
     116;       AX, BX
     117;--------------------------------------------------------------------
     118ALIGN JUMP_ALIGN
     119GetFormatSpecifierParserToAX:
     120    mov     bx, .rgcFormatCharToLookupIndex
     121ALIGN JUMP_ALIGN
     122.CheckForNextSpecifierParser:
     123    cmp     al, [cs:bx]
     124    je      SHORT .ConvertIndexToFunctionOffset
     125    inc     bx
     126    cmp     bx, .rgcFormatCharToLookupIndexEnd
     127    jb      SHORT .CheckForNextSpecifierParser
     128    mov     ax, c_FormatCharacter
     129    ret
     130ALIGN JUMP_ALIGN
     131.ConvertIndexToFunctionOffset:
     132    sub     bx, .rgcFormatCharToLookupIndex
     133    shl     bx, 1               ; Shift for WORD lookup
     134    mov     ax, [cs:bx+.rgfnFormatSpecifierParser]
     135    ret
     136
     137.rgcFormatCharToLookupIndex:
     138    db      "aAduxsSct-+%"
     139.rgcFormatCharToLookupIndexEnd:
     140ALIGN WORD_ALIGN
     141.rgfnFormatSpecifierParser:
     142    dw      a_FormatAttributeForNextCharacter
     143    dw      A_FormatAttributeForRemainingString
     144    dw      d_FormatSignedDecimalWord
     145    dw      u_FormatUnsignedDecimalWord
     146    dw      x_FormatHexadecimalWord
     147    dw      s_FormatStringFromSegmentCS
     148    dw      S_FormatStringFromFarPointer
     149    dw      c_FormatCharacter
     150    dw      t_FormatRepeatCharacter
     151    dw      PrepareToPrependParameterWithSpaces
     152    dw      PrepareToAppendSpacesAfterParameter
     153    dw      percent_FormatPercent
     154
     155
     156;--------------------------------------------------------------------
     157; PrependOrAppendSpaces
     158;   Parameters:
     159;       CX:     Minimum length for format specifier in characters
     160;       DS:     BDA segment (zero)
     161;       ES:DI:  Ptr to cursor location in video RAM
     162;   Returns:
     163;       Nothing
    107164;   Corrupts registers:
    108165;       AX, BX, CX, DX
    109166;--------------------------------------------------------------------
    110167ALIGN JUMP_ALIGN
    111 .FormatWithCorrectFormatFunction:
    112     xor     bx, bx                              ; Zero lookup index
    113 ALIGN JUMP_ALIGN
    114 .PlaceholderComparisonLoop:
    115     cmp     al, [cs:bx+.rgcFormatCharToLookupIndex]
    116     je      SHORT .JumpToFormatPlaceholder
    117     inc     bx
    118     cmp     bl, .EndOFrgcFormatCharToLookupIndex - .rgcFormatCharToLookupIndex
    119     jb      SHORT .PlaceholderComparisonLoop    ; Loop
    120     call    DisplayPrint_CharacterFromAL        ; Display unsupported format character
    121     ; Fall to .UpdateSpacesToAppendAfterPrintingSingleCharacter
    122 
    123 ;--------------------------------------------------------------------
    124 ; .UpdateSpacesToAppendAfterPrintingSingleCharacter
    125 ; .UpdateSpacesToAppend
    126 ;   Parameters:
    127 ;       BX:     Number of characters printed (.UpdateSpacesToAppend only)
    128 ;       CX:     Number parameter (zero if no number parameter present)
    129 ;       DS:     BDA segment (zero)
    130 ;       SS:BP:  Pointer to format parameter
    131 ;       CS:SI:  Pointer to next format string character
    132 ;       ES:DI:  Ptr to cursor location in video RAM
    133 ;   Returns:
    134 ;       CX:     Number of spaces to append
    135 ;       Jumps to .PrepareToFormatNextParameter
     168PrependOrAppendSpaces:
     169    mov     ax, di
     170    sub     ax, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition]
     171    test    cx, cx
     172    js      SHORT .PrependWithSpaces
     173    ; Fall to .AppendSpaces
     174
     175;--------------------------------------------------------------------
     176; .AppendSpaces
     177;   Parameters:
     178;       AX:     Number of format parameter BYTEs printed
     179;       CX:     Minimum length for format specifier in characters
     180;       DS:     BDA segment (zero)
     181;       ES:DI:  Ptr to cursor location in video RAM
     182;   Returns:
     183;       Nothing
     184;   Corrupts registers:
     185;       AX, CX, DX
     186;--------------------------------------------------------------------
     187.AppendSpaces:
     188    call    DisplayContext_GetCharacterOffsetToAXfromByteOffsetInAX
     189    sub     cx, ax
     190    jle     SHORT .NothingToAppendOrPrepend
     191    mov     al, ' '
     192    jmp     DisplayPrint_RepeatCharacterFromALwithCountInCX
     193
     194;--------------------------------------------------------------------
     195; .PrependWithSpaces
     196;   Parameters:
     197;       AX:     Number of format parameter BYTEs printed
     198;       CX:     Negative minimum length for format specifier in characters
     199;       DS:     BDA segment (zero)
     200;       ES:DI:  Ptr to cursor location in video RAM
     201;   Returns:
     202;       Nothing
    136203;   Corrupts registers:
    137204;       AX, BX, CX, DX
    138205;--------------------------------------------------------------------
    139206ALIGN JUMP_ALIGN
    140 .UpdateSpacesToAppendAfterPrintingSingleCharacter:
    141     mov     bx, 1
    142 ALIGN JUMP_ALIGN
    143 .UpdateSpacesToAppend:
    144     jcxz    .PrepareToFormatNextParameter
    145     sub     cx, bx              ; Number of spaces to append
    146     jle     SHORT .PrepareToFormatNextParameter
     207.PrependWithSpaces:
     208    xchg    ax, cx
     209    neg     ax
     210    call    DisplayContext_GetByteOffsetToAXfromCharacterOffsetInAX
     211    sub     ax, cx              ; AX = BYTEs to prepend, CX = BYTEs to move
     212    jle     SHORT .NothingToAppendOrPrepend
     213
     214    mov     bx, di
     215    add     bx, ax              ; BX = DI after prepending
     216
     217    push    si
     218    dec     di                  ; DI = Offset to last byte formatted
     219    mov     si, di
     220    add     di, ax              ; DI = Offset to new location for last byte
     221    std
     222    eSEG_STR rep, es, movsb
     223
     224    mov     dl, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags]
     225    and     dx, BYTE FLG_CONTEXT_ATTRIBUTES
     226    not     dx
     227    and     di, dx              ; WORD alignment when using attributes
     228
     229    call    DisplayContext_GetCharacterOffsetToAXfromByteOffsetInAX
     230    xchg    cx, ax              ; CX = Spaces to prepend
    147231    mov     al, ' '
    148232    call    DisplayPrint_RepeatCharacterFromALwithCountInCX
    149     ; Fall to .PrepareToFormatNextParameter
    150 
    151 ;--------------------------------------------------------------------
    152 ; .PrepareToFormatNextParameter
    153 ;   Parameters:
    154 ;       DS:     BDA segment (zero)
    155 ;       SS:BP:  Pointer to format parameter
    156 ;       CS:SI:  Pointer to next format string character
    157 ;       ES:DI:  Ptr to cursor location in video RAM
    158 ;   Returns:
    159 ;       BP:     Adjusted to point next stack parameter
    160 ;       Jumps to DisplayFormat_ParseCharacters
    161 ;   Corrupts registers:
    162 ;       Nothing
    163 ;--------------------------------------------------------------------
    164 ALIGN JUMP_ALIGN
    165 .PrepareToFormatNextParameter:
    166     dec     bp
    167     dec     bp
    168     jmp     SHORT DisplayFormat_ParseCharacters
    169 
    170 
    171 ;--------------------------------------------------------------------
    172 ; .JumpToFormatPlaceholder
    173 ;   Parameters:
    174 ;       BX:     Lookup index for format function
    175 ;       CX:     Number parameter (zero if no number parameter present)
    176 ;       DS:     BDA segment (zero)
    177 ;       SS:BP:  Pointer to next format parameter
    178 ;       CS:SI:  Pointer to next format string character
    179 ;       ES:DI:  Ptr to cursor location in video RAM
    180 ;   Returns:
    181 ;       Eventually jumps to DisplayFormat_ParseCharacters
     233    cld                         ; Restore DF
     234
     235    mov     di, bx
     236    pop     si
     237.NothingToAppendOrPrepend:
     238    ret
     239
     240
     241;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     242; Formatting functions
     243;   Parameters:
     244;       DS:     BDA segment (zero)
     245;       SS:BP:  Pointer to next format parameter (-=2 updates to next parameter)
     246;       ES:DI:  Ptr to cursor location in video RAM
     247;   Returns:
     248;       SS:BP:  Points to last WORD parameter used
    182249;   Corrupts registers:
    183250;       AX, BX, DX
    184 ;--------------------------------------------------------------------
    185 ALIGN JUMP_ALIGN
    186 .JumpToFormatPlaceholder:
    187     shl     bx, 1                   ; Shift for WORD lookup
    188     jmp     [cs:bx+.rgfnFormatParameter]
    189 
    190 ALIGN JUMP_ALIGN
    191 .a_FormatAttributeForNextCharacter:
     251;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
     252ALIGN JUMP_ALIGN
     253a_FormatAttributeForNextCharacter:
    192254    mov     bl, [bp]
    193255    xchg    bl, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute]
    194     call    .ReadCharacterAndTestForNull
    195     jz      SHORT .Return
    196     call    DisplayPrint_CharacterFromAL
     256    push    bx
     257    push    cx
     258    push    di
     259    call    DisplayFormat_ParseCharacters   ; Recursive call
     260    pop     WORD [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition]
     261    pop     cx
     262    pop     bx
    197263    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], bl
    198     jmp     SHORT .UpdateSpacesToAppendAfterPrintingSingleCharacter
    199 
    200 ALIGN JUMP_ALIGN
    201 .A_FormatAttributeForRemainingString:
     264    ret
     265
     266ALIGN JUMP_ALIGN
     267A_FormatAttributeForRemainingString:
    202268    mov     al, [bp]
    203269    mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute], al
    204     jmp     SHORT .PrepareToFormatNextParameter
    205 
    206 ALIGN JUMP_ALIGN
    207 .d_FormatSignedDecimalWord:
    208     mov     ax, [bp]
    209     call    DisplayPrint_SignedDecimalIntegerFromAX
    210     jmp     SHORT .UpdateSpacesToAppend
    211 
    212 ALIGN JUMP_ALIGN
    213 .u_FormatUnsignedDecimalWord:
     270    ret
     271
     272ALIGN JUMP_ALIGN
     273d_FormatSignedDecimalWord:
    214274    mov     ax, [bp]
    215275    mov     bx, 10
    216     call    DisplayPrint_WordFromAXWithBaseInBX
    217     jmp     SHORT .UpdateSpacesToAppend
    218 
    219 ALIGN JUMP_ALIGN
    220 .x_FormatHexadecimalWord:
     276    jmp     DisplayPrint_SignedWordFromAXWithBaseInBX
     277
     278ALIGN JUMP_ALIGN
     279u_FormatUnsignedDecimalWord:
     280    mov     ax, [bp]
     281    mov     bx, 10
     282    jmp     DisplayPrint_WordFromAXWithBaseInBX
     283
     284ALIGN JUMP_ALIGN
     285x_FormatHexadecimalWord:
    221286    mov     ax, [bp]
    222287    mov     bx, 16
    223288    call    DisplayPrint_WordFromAXWithBaseInBX
    224     inc     bx                  ; Increment character count for 'h'
    225289    mov     al, 'h'
    226     call    DisplayPrint_CharacterFromAL
    227     jmp     SHORT .UpdateSpacesToAppend
    228 
    229 ALIGN JUMP_ALIGN
    230 .s_FormatStringFromSegmentCS:
     290    jmp     DisplayPrint_CharacterFromAL
     291
     292ALIGN JUMP_ALIGN
     293s_FormatStringFromSegmentCS:
    231294    xchg    si, [bp]
    232295    call    DisplayPrint_NullTerminatedStringFromCSSI
    233     mov     si, [bp]            ; Restore SI
    234     jmp     SHORT .UpdateSpacesToAppend
    235 
    236 ALIGN JUMP_ALIGN
    237 .S_FormatStringFromFarPointer:
     296    mov     si, [bp]
     297    ret
     298
     299ALIGN JUMP_ALIGN
     300S_FormatStringFromFarPointer:
     301    mov     bx, [bp-2]
    238302    xchg    si, [bp]
    239     mov     bx, [bp-2]
    240303    call    DisplayPrint_NullTerminatedStringFromBXSI
    241     mov     si, [bp]            ; Restore SI
    242     jmp     SHORT .UpdateSpacesToAppendWithDWordParameter
    243 
    244 ALIGN JUMP_ALIGN
    245 .c_FormatCharacter:
     304    mov     si, [bp]
     305    dec     bp
     306    dec     bp
     307    ret
     308
     309ALIGN JUMP_ALIGN
     310c_FormatCharacter:
    246311    mov     al, [bp]
    247     jmp     SHORT .FormatSingleCharacterFromAL
    248 
    249 ALIGN JUMP_ALIGN
    250 .t_FormatRepeatCharacter:
     312    jmp     DisplayPrint_CharacterFromAL
     313
     314ALIGN JUMP_ALIGN
     315t_FormatRepeatCharacter:
     316    push    cx
    251317    mov     cx, [bp-2]
    252     mov     bx, cx
    253318    mov     al, [bp]
    254319    call    DisplayPrint_RepeatCharacterFromALwithCountInCX
    255     jmp     SHORT .UpdateSpacesToAppendWithDWordParameter
    256 
    257 ALIGN JUMP_ALIGN
    258 .percent_FormatPercent:
     320    pop     cx
     321    dec     bp
     322    dec     bp
     323    ret
     324
     325ALIGN JUMP_ALIGN
     326percent_FormatPercent:
    259327    mov     al, '%'
    260     inc     bp                  ; Adjust here since...
    261     inc     bp                  ; ...no parameter on stack
    262     ; Fall to .FormatSingleCharacterFromAL
    263 
    264 ALIGN JUMP_ALIGN
    265 .FormatSingleCharacterFromAL:
    266     call    DisplayPrint_CharacterFromAL
    267     jmp     .UpdateSpacesToAppendAfterPrintingSingleCharacter
    268 
    269 ALIGN JUMP_ALIGN
    270 .UpdateSpacesToAppendWithDWordParameter:
    271     dec     bp
    272     dec     bp
    273     jmp     .UpdateSpacesToAppend
    274 
    275 
    276 ; Table for converting format character to jump table index
    277 .rgcFormatCharToLookupIndex:
    278     db      "aAduxsSct%"
    279 .EndOFrgcFormatCharToLookupIndex:
    280 
    281 ; Jump table
    282 ALIGN WORD_ALIGN
    283 .rgfnFormatParameter:
    284     dw      .a_FormatAttributeForNextCharacter
    285     dw      .A_FormatAttributeForRemainingString
    286     dw      .d_FormatSignedDecimalWord
    287     dw      .u_FormatUnsignedDecimalWord
    288     dw      .x_FormatHexadecimalWord
    289     dw      .s_FormatStringFromSegmentCS
    290     dw      .S_FormatStringFromFarPointer
    291     dw      .c_FormatCharacter
    292     dw      .t_FormatRepeatCharacter
    293     dw      .percent_FormatPercent
     328    jmp     DisplayPrint_CharacterFromAL
     329
     330ALIGN JUMP_ALIGN
     331PrepareToPrependParameterWithSpaces:
     332    neg     cx
     333    ; Fall to PrepareToAppendSpacesAfterParameter
     334
     335ALIGN JUMP_ALIGN
     336PrepareToAppendSpacesAfterParameter:
     337    add     sp, BYTE 2              ; Remove return offset
     338    jmp     ParseFormatSpecifier
  • trunk/Assembly_Library/Src/Display/DisplayPrint.asm

    r42 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   26.6.2010
    4 ; Last update   :   18.9.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for display output.
     
    6565
    6666;--------------------------------------------------------------------
    67 ; DisplayPrint_SignedDecimalIntegerFromAX
     67; DisplayPrint_SignedWordFromAXWithBaseInBX
    6868;   Parameters:
    6969;       AX:     Word to display
    70 ;       DS:     BDA segment (zero)
    71 ;       ES:DI:  Ptr to cursor location in video RAM
    72 ;   Returns:
    73 ;       BX:     Number of characters printed
    74 ;       DI:     Updated offset to video RAM
    75 ;   Corrupts registers:
    76 ;       AX, DX
    77 ;--------------------------------------------------------------------
    78 ALIGN JUMP_ALIGN
    79 DisplayPrint_SignedDecimalIntegerFromAX:
    80     mov     bx, 10
    81     test    ah, 1<<7            ; Sign bit set?
    82     jz      SHORT DisplayPrint_WordFromAXWithBaseInBX
     70;       BX:     Integer base (binary=2, octal=8, decimal=10, hexadecimal=16)
     71;       DS:     BDA segment (zero)
     72;       ES:DI:  Ptr to cursor location in video RAM
     73;   Returns:
     74;       DI:     Updated offset to video RAM
     75;   Corrupts registers:
     76;       AX, DX
     77;--------------------------------------------------------------------
     78ALIGN JUMP_ALIGN
     79DisplayPrint_SignedWordFromAXWithBaseInBX:
     80    test    ax, ax
     81    jns     SHORT DisplayPrint_WordFromAXWithBaseInBX
    8382
    8483    push    ax
     
    8786    pop     ax
    8887    neg     ax
    89     call    DisplayPrint_WordFromAXWithBaseInBX
    90     inc     bx                  ; Increment character count for '-'
    91     ret
    92 
     88    ; Fall to DisplayPrint_WordFromAXWithBaseInBX
    9389
    9490;--------------------------------------------------------------------
     
    10096;       ES:DI:  Ptr to cursor location in video RAM
    10197;   Returns:
    102 ;       BX:     Number of characters printed
    10398;       DI:     Updated offset to video RAM
    10499;   Corrupts registers:
     
    108103DisplayPrint_WordFromAXWithBaseInBX:
    109104    push    cx
     105    push    bx
    110106
    111107    xor     cx, cx
     
    118114    test    ax, ax              ; All divided?
    119115    jnz     SHORT .DivideLoop   ;  If not, loop
    120     mov     dx, cx              ; Character count to DX
    121 ALIGN JUMP_ALIGN
    122 .PrintLoop:
    123     pop     bx                  ; Pop digit
    124     mov     al, [cs:bx+.rgcDigitToCharacter]
    125     call    DisplayPrint_CharacterFromAL
    126     loop    .PrintLoop
    127     mov     bx, dx              ; Return characters printed
    128 
     116
     117    mov     bx, .rgcDigitToCharacter
     118ALIGN JUMP_ALIGN
     119.PrintNextDigit:
     120    pop     ax                  ; Pop digit
     121    eSEG    cs
     122    xlatb
     123    call    DisplayPrint_CharacterFromAL
     124    loop    .PrintNextDigit
     125
     126    pop     bx
    129127    pop     cx
    130128    ret
     
    140138;       ES:DI:  Ptr to cursor location in video RAM
    141139;   Returns:
    142 ;       BX:     Number of characters printed
    143140;       DI:     Updated offset to video RAM
    144141;   Corrupts registers:
     
    147144ALIGN JUMP_ALIGN
    148145DisplayPrint_CharacterBufferFromBXSIwithLengthInCX:
    149     push    cx
    150 
    151     mov     es, bx                  ; Buffer now in ES:SI
    152     xor     bx, bx                  ; Zero character counter
    153     jcxz    .BufferPrinted
    154 ALIGN JUMP_ALIGN
    155 .CharacterOutputLoop:
    156     mov     al, [es:bx+si]
    157     inc     bx
    158     call    LoadDisplaySegmentAndPrintCharacterFromAL
    159     loop    .CharacterOutputLoop
    160 .BufferPrinted:
    161     mov     es, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2]
    162     pop     cx
     146    jcxz    .NothingToPrintSinceZeroLength
     147    push    si
     148    push    cx
     149
     150ALIGN JUMP_ALIGN
     151.PrintNextCharacter:
     152    mov     ds, bx
     153    lodsb
     154    LOAD_BDA_SEGMENT_TO ds, dx
     155    call    DisplayPrint_CharacterFromAL
     156    loop    .PrintNextCharacter
     157
     158    LOAD_BDA_SEGMENT_TO ds, dx
     159    pop     cx
     160    pop     si
     161.NothingToPrintSinceZeroLength:
    163162    ret
    164163
     
    171170;       ES:DI:  Ptr to cursor location in video RAM
    172171;   Returns:
    173 ;       BX:     Number of characters printed
    174172;       DI:     Updated offset to video RAM
    175173;   Corrupts registers:
     
    178176ALIGN JUMP_ALIGN
    179177DisplayPrint_NullTerminatedStringFromCSSI:
     178    push    bx
    180179    mov     bx, cs
    181     ; Fall to DisplayPrint_NullTerminatedStringFromBXSI
     180    call    DisplayPrint_NullTerminatedStringFromBXSI
     181    pop     bx
     182    ret
     183
    182184
    183185;--------------------------------------------------------------------
     
    188190;       ES:DI:  Ptr to cursor location in video RAM
    189191;   Returns:
    190 ;       BX:     Number of characters printed
    191192;       DI:     Updated offset to video RAM
    192193;   Corrupts registers:
     
    195196ALIGN JUMP_ALIGN
    196197DisplayPrint_NullTerminatedStringFromBXSI:
    197     mov     es, bx                  ; String now in ES:SI
    198     xor     bx, bx                  ; Zero character counter
    199 ALIGN JUMP_ALIGN
    200 .CharacterOutputLoop:
    201     mov     al, [es:bx+si]
    202     test    al, al
    203     jz      SHORT .AllCharacterPrinted
    204     inc     bx
    205 
    206     call    LoadDisplaySegmentAndPrintCharacterFromAL
    207     jmp     SHORT .CharacterOutputLoop
    208 ALIGN JUMP_ALIGN
    209 .AllCharacterPrinted:
    210     mov     es, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2]
    211     ret
    212 
    213 ;--------------------------------------------------------------------
    214 ; LoadDisplaySegmentAndPrintCharacterFromAL
    215 ;   Parameters:
    216 ;       AL:     Character to print
    217 ;       DI:     Offset to cursor location in video RAM
    218 ;       DS:     BDA segment (zero)
    219 ;   Returns:
    220 ;       DI:     Updated offset to video RAM
    221 ;   Corrupts registers:
    222 ;       AX, DX
    223 ;--------------------------------------------------------------------
    224 ALIGN JUMP_ALIGN
    225 LoadDisplaySegmentAndPrintCharacterFromAL:
    226     push    es
    227     mov     es, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition+2]
    228     call    DisplayPrint_CharacterFromAL
    229     pop     es
    230     ret
    231 
    232 
    233 ;--------------------------------------------------------------------
    234 ; DisplayPrint_Newline
    235 ;   Parameters:
    236 ;       DS:     BDA segment (zero)
    237 ;       ES:DI:  Ptr to cursor location in video RAM
    238 ;   Returns:
    239 ;       DI:     Updated offset to video RAM
    240 ;   Corrupts registers:
    241 ;       AX, DX
    242 ;--------------------------------------------------------------------
    243 ALIGN JUMP_ALIGN
    244 DisplayPrint_Newline:
    245     mov     al, CR
    246     call    DisplayPrint_CharacterFromAL
    247     mov     al, LF
    248     jmp     SHORT DisplayPrint_CharacterFromAL
     198    push    si
     199    push    cx
     200
     201    xor     cx, cx
     202ALIGN JUMP_ALIGN
     203.PrintNextCharacter:
     204    mov     ds, bx              ; String segment to DS
     205    lodsb
     206    mov     ds, cx              ; BDA segment to DS
     207    test    al, al              ; NULL?
     208    jz      SHORT .EndOfString
     209    call    DisplayPrint_CharacterFromAL
     210    jmp     SHORT .PrintNextCharacter
     211
     212ALIGN JUMP_ALIGN
     213.EndOfString:
     214    pop     cx
     215    pop     si
     216    ret
    249217
    250218
     
    297265.ClearRowLoop:
    298266    mov     cl, bl                          ; Area width now in CX
    299     mov     al, ' '                         ; Clear with space
     267    mov     al, SCREEN_BACKGROUND_CHARACTER
    300268    call    DisplayPrint_RepeatCharacterFromALwithCountInCX
    301269
     
    327295ALIGN JUMP_ALIGN
    328296DisplayPrint_RepeatCharacterFromALwithCountInCX:
     297    jcxz    .NothingToRepeat
     298    push    cx
     299
     300ALIGN JUMP_ALIGN
     301.RepeatCharacter:
    329302    push    ax
    330303    call    DisplayPrint_CharacterFromAL
    331304    pop     ax
    332     loop    DisplayPrint_RepeatCharacterFromALwithCountInCX
    333     ret
     305    loop    .RepeatCharacter
     306
     307    pop     cx
     308.NothingToRepeat:
     309    ret
     310
     311
     312;--------------------------------------------------------------------
     313; DisplayPrint_Newline
     314;   Parameters:
     315;       DS:     BDA segment (zero)
     316;       ES:DI:  Ptr to cursor location in video RAM
     317;   Returns:
     318;       DI:     Updated offset to video RAM
     319;   Corrupts registers:
     320;       AX, DX
     321;--------------------------------------------------------------------
     322ALIGN JUMP_ALIGN
     323DisplayPrint_Newline:
     324    mov     al, CR
     325    call    DisplayPrint_CharacterFromAL
     326    mov     al, LF
     327    ; Fall to DisplayPrint_CharacterFromAL
    334328
    335329
  • trunk/Assembly_Library/Src/LibraryTests.asm

    r41 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   27.6.2010
    4 ; Last update   :   15.9.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Tests for Assembly Library.
     
    254254    mov     ax, si
    255255    CALL_DISPLAY_LIBRARY SetCharacterPointerFromBXAX
     256    mov     dl, ATTRIBUTES_NOT_USED
    256257    mov     ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
    257     CALL_DISPLAY_LIBRARY SetCharacterOutputFunctionFromAX
     258    CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInDL
    258259    lea     ax, [si+STRING_BUFFER_SIZE]
    259260    CALL_DISPLAY_LIBRARY SetCharacterOutputParameterFromAX
     
    408409    call    PrintHorizontalRuler
    409410    call    PrintVerticalRuler
     411   
     412    mov     al, COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)
     413    CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
    410414
    411415    mov     ax, CURSOR_XY(0, 1)
    412416    CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
    413     mov     al, COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)
    414     CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
    415417    call    PrintFormattedStrings
    416418
     
    494496    ret
    495497.szIntegers:
    496     db  "Integers -32768, -1, 0, 1, 65535:          %A|%6d|%6d|%6d|%6d|%6u|",LF,CR,NULL
     498    db  "Integers -32768, -1, 0, 1, 65535:          %A|%6-d|%6-d|%6-d|%6-d|%6-u|",LF,CR,NULL
    497499
    498500.PrintHexadecimals:
     
    508510    ret
    509511.szHexadecimals:
    510     db  "Hexadecimals CACAh, FFFFh, 0, 5A5Ah, A5A5h:%A|%6x|%6x|%6x|%6x|%6x|",LF,CR,NULL
     512    db  "Hexadecimals CACAh, FFFFh, 0, 5A5Ah, A5A5h:%A|%6-x|%6-x|%6-x|%6-x|%6-x|",LF,CR,NULL
    511513
    512514.PrintCharacters:
  • trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm

    r41 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   6.8.2010
    4 ; Last update   :   16.9.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Common functions for many dialogs.
     
    291291ALIGN JUMP_ALIGN
    292292.RedrawDialogAreaAndWholeParentWindow:
    293     mov     al, MONO_NORMAL
     293    mov     al, SCREEN_BACKGROUND_ATTRIBUTE
    294294    CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
    295295    call    MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
  • trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm

    r41 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   6.9.2010
    4 ; Last update   :   16.9.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Displays file dialog.
     
    148148;       Nothing
    149149;   Corrupts registers:
    150 ;       AX, CX, SI, DI, DS, ES
     150;       AX, CX, DX, SI, DI, DS, ES
    151151;--------------------------------------------------------------------
    152152ALIGN JUMP_ALIGN
     
    171171;       Nothing
    172172;   Corrupts registers:
    173 ;       AX, CX, DI
     173;       AX, CX, DX, DI
    174174;--------------------------------------------------------------------
    175175;ALIGN JUMP_ALIGN
     
    225225;       DI:     Updated for next file
    226226;   Corrupts registers:
    227 ;       AX, BX, CX
     227;       AX, BX, CX, DX
    228228;--------------------------------------------------------------------
    229229ALIGN JUMP_ALIGN
     
    241241;       DI:     Updated for next file
    242242;   Corrupts registers:
    243 ;       AX, BX, CX
     243;       AX, BX, CX, DX
    244244;--------------------------------------------------------------------
    245245;ALIGN JUMP_ALIGN
     
    253253    xchg    ax, cx
    254254    CALL_DISPLAY_LIBRARY SetCharacterPointerFromBXAX
     255    mov     dl, ATTRIBUTES_NOT_USED
    255256    mov     ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
    256     CALL_DISPLAY_LIBRARY SetCharacterOutputFunctionFromAX
     257    CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInDL
    257258
    258259    call    .FormatFileOrDirectoryToBufferFromDTAinDSSI
  • trunk/Assembly_Library/Src/Menu/Dialog/StringsForDialogs.asm

    r41 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   14.9.2010
    4 ; Last update   :   16.9.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Strings used by dialogs.
     
    99g_szTimeElapsed:        db  "Time elapsed  :",NULL
    1010g_szTimeLeft:           db  "Estimated left:",NULL
    11 g_szTimeFormat:         db  " %2u min %2u sec",LF,CR,NULL
     11g_szTimeFormat:         db  " %2-u min %2-u sec",LF,CR,NULL
    1212
    1313; Strings for File Dialog
     
    2323
    2424g_szFileFormat:
    25     db      "%14S  %4u %c%cB",LF,NULL
     25    db      "%14S  %4-u %c%cB",LF,NULL
    2626g_szDirectoryFormat:
    2727    db      "[%12S]  %s-DIR",LF,NULL
  • trunk/Assembly_Library/Src/Menu/MenuBorders.asm

    r41 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   14.7.2010
    4 ; Last update   :   7.9.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for drawing menu borders.
     
    4545;       Nothing
    4646;   Corrupts registers:
    47 ;       AX, SI, DI
     47;       AX, DX, SI, DI
    4848;--------------------------------------------------------------------
    4949ALIGN JUMP_ALIGN
    5050MenuBorders_AdjustDisplayContextForDrawingBorders:
     51    mov     dl, ATTRIBUTES_ARE_USED
    5152    mov     ax, MenuCharOut_MenuBorderTeletypeOutputWithAttribute
    52     CALL_DISPLAY_LIBRARY SetCharacterOutputFunctionFromAX
     53    CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInDL
    5354
    5455    mov     ax, bp
     
    268269    call    MenuAttribute_SetToDisplayContextFromTypeInSI
    269270
     271    push    dx
     272    mov     dl, ATTRIBUTES_ARE_USED
    270273    mov     ax, FAST_OUTPUT_WITH_ATTRIBUTE_ONLY
    271     CALL_DISPLAY_LIBRARY SetCharacterOutputFunctionFromAX
     274    CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInDL
     275    pop     dx
    272276
    273277    call    PrintMultipleBorderCharactersFromAL ; AL does not matter
  • trunk/Assembly_Library/Src/Menu/MenuText.asm

    r41 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   21.7.2010
    4 ; Last update   :   11.8.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for drawing menu texts by the user.
     
    218218;       Nothing
    219219;   Corrupts registers:
    220 ;       AX, SI, DI
     220;       AX, DX, SI, DI
    221221;--------------------------------------------------------------------
    222222ALIGN JUMP_ALIGN
    223223AdjustDisplayContextForDrawingTexts:
     224    mov     dl, ATTRIBUTES_ARE_USED
    224225    mov     ax, MenuCharOut_MenuTextTeletypeOutputWithAttribute
    225     CALL_DISPLAY_LIBRARY SetCharacterOutputFunctionFromAX
     226    CALL_DISPLAY_LIBRARY SetCharOutputFunctionFromAXwithAttribFlagInDL
    226227
    227228    mov     ax, bp
  • trunk/Assembly_Library/Src/Menu/MenuTime.asm

    r41 r44  
    22; Project name  :   Assembly Library
    33; Created date  :   25.7.2010
    4 ; Last update   :   13.8.2010
     4; Last update   :   27.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Menu timeouts other time related functions.
     
    141141;       Nothing
    142142;   Corrupts registers:
    143 ;       AX, DX, SI, DI
     143;       AX, CX, DX, SI, DI
    144144;--------------------------------------------------------------------
    145145ALIGN JUMP_ALIGN
    146146DrawTimeoutInAXoverMenuBorders:
    147     xchg    dx, ax
     147    xchg    cx, ax
    148148    call    MenuBorders_AdjustDisplayContextForDrawingBorders
    149149    call    MenuLocation_GetBottomBordersTopLeftCoordinatesToAX
     
    154154; .PrintTimeoutStringWithSecondsInDX
    155155;   Parameters
    156 ;       DX:     Seconds to print
     156;       CX:     Seconds to print
    157157;       SS:BP:  Ptr to MENU
    158158;   Returns:
     
    166166
    167167    mov     bp, sp
    168     call    .GetTimeoutAttributeToAXfromSecondsInDX
     168    call    .GetTimeoutAttributeToAXfromSecondsInCX
    169169    mov     si, .szSelectionTimeout
    170170    push    ax          ; Push attribute
    171     push    dx          ; Push seconds
     171    push    cx          ; Push seconds
    172172    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
    173173    pop     bp
     
    178178    db      DOUBLE_BOTTOM_LEFT_CORNER
    179179    db      DOUBLE_LEFT_HORIZONTAL_TO_SINGLE_VERTICAL
    180     db      "%AAutoselection in %2ds",NULL
    181 
    182 ;--------------------------------------------------------------------
    183 ; .GetTimeoutAttributeToAXfromSecondsInDX
    184 ;   Parameters
    185 ;       DX:     Seconds to print
     180    db      "%AAutoselection in %2-ds",NULL
     181
     182;--------------------------------------------------------------------
     183; .GetTimeoutAttributeToAXfromSecondsInCX
     184;   Parameters
     185;       CX:     Seconds to print
    186186;   Returns:
    187187;       AX:     Attribute byte for seconds
    188 ;       DX:     Seconds to print
     188;       CX:     Seconds to print
    189189;   Corrupts registers:
    190190;       SI, DI
    191191;--------------------------------------------------------------------
    192192ALIGN JUMP_ALIGN
    193 .GetTimeoutAttributeToAXfromSecondsInDX:
     193.GetTimeoutAttributeToAXfromSecondsInCX:
    194194    mov     si, ATTRIBUTE_CHARS.cNormalTimeout
    195     cmp     dx, BYTE 3
     195    cmp     cx, BYTE 3
    196196    ja      SHORT .GetAttributeToAX
    197197    add     si, BYTE ATTRIBUTE_CHARS.cHurryTimeout - ATTRIBUTE_CHARS.cNormalTimeout
Note: See TracChangeset for help on using the changeset viewer.