Changeset 52 in xtideuniversalbios for trunk/Assembly_Library/Src/Menu/MenuCharOut.asm


Ignore:
Timestamp:
Oct 12, 2010, 6:51:07 PM (14 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to Assembly Library:
Completely rewritten line splitting (slower but no need to modify string).
Some changes to string processing functions.
Saved few bytes from CGA detection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Src/Menu/MenuCharOut.asm

    r51 r52  
    22; Project name  :   Assembly Library
    33; Created date  :   15.7.2010
    4 ; Last update   :   10.10.2010
     4; Last update   :   12.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Character out function for printing withing menu window.
     
    1010
    1111;--------------------------------------------------------------------
    12 ; MenuCharOut_MenuBorderTeletypeOutputWithAttribute
     12; MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange
     13; MenuCharOut_MenuTeletypeOutput
    1314;   Parameters:
    1415;       AL:     Character to output
     
    1617;       DS:     BDA segment (zero)
    1718;       ES:DI:  Ptr to video memory where to output
     19;       [DISPLAY_CONTEXT.wCharOutParam]:
     20;               Low byte  = First column offset (after CR)
     21;               High byte = Last column offset (when using automatic line change)
    1822;   Returns:
    1923;       DI:     Incremented for next character
     
    2226;--------------------------------------------------------------------
    2327ALIGN JUMP_ALIGN
    24 MenuCharOut_MenuBorderTeletypeOutputWithAttribute:
    25     cmp     al, CR                  ; Carriage return?
    26     je      SHORT .PrintCRandAdjustColumnToMenuBorders
    27     jmp     DisplayCharOut_TeletypeOutputWithAttribute
    28 
    29 ALIGN JUMP_ALIGN
    30 .PrintCRandAdjustColumnToMenuBorders:
    31     call    DisplayCharOut_BiosTeletypeOutput
    32     xor     ax, ax                  ; No offset, cursor to start of border
    33     jmp     SHORT SetCursorToNextMenuLine
    34 
    35 
    36 ;--------------------------------------------------------------------
    37 ; MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange
    38 ; MenuCharOut_MenuTextTeletypeOutputWithAttribute
    39 ;   Parameters:
    40 ;       AL:     Character to output
    41 ;       AH:     Attribute to output
    42 ;       DS:     BDA segment (zero)
    43 ;       ES:DI:  Ptr to video memory where to output
    44 ;   Returns:
    45 ;       DI:     Incremented for next character
    46 ;   Corrupts registers:
    47 ;       AX, DX
    48 ;--------------------------------------------------------------------
    49 ALIGN JUMP_ALIGN
    50 MenuCharOut_MenuTextTeletypeOutputWithAttributeAndAutomaticLineChange:
    51     push    di
    52     push    ax
    53     mov     al, DOUBLE_VERTICAL
    54     add     di, BYTE MENU_TEXT_COLUMN_OFFSET    ; Border char comes after space
    55     WAIT_RETRACE_IF_NECESSARY_THEN scasb
    56     pop     ax
    57     pop     di
    58     je      SHORT MovePartialWordToNewTextLineAndPrintCharacterFromAX
     28MenuCharOut_MenuTeletypeOutputWithAutomaticLineChange:
     29    call    CharOutLineSplitter_IsCursorAtTheEndOfTextLine
     30    jnc     SHORT MenuCharOut_MenuTeletypeOutput
     31    cmp     al, ' '
     32    jb      SHORT ReturnSinceNoNeedToStartLineWithControlCharacter
     33    call    CharOutLineSplitter_MovePartialWordToNewTextLine
    5934    ; Fall to MenuCharOut_MenuTextTeletypeOutputWithAttribute
    6035
    6136ALIGN JUMP_ALIGN
    62 MenuCharOut_MenuTextTeletypeOutputWithAttribute:
    63     cmp     al, CR                      ; Carriage return?
    64     je      SHORT PrintCRfromALandAdjustColumnToMenuText
     37MenuCharOut_MenuTeletypeOutput:
     38    cmp     al, CR
     39    je      SHORT PrintCRandAdjustOffsetForStartOfLine
    6540    jmp     DisplayCharOut_TeletypeOutputWithAttribute
    6641
    6742
    6843;--------------------------------------------------------------------
    69 ; MovePartialWordToNewTextLineAndPrintCharacterFromAX
    70 ;   Parameters:
    71 ;       AL:     Character to output
    72 ;       AH:     Attribute to output
    73 ;       DS:     BDA segment (zero)
    74 ;       ES:DI:  Ptr to end of text line in video memory
    75 ;   Returns:
    76 ;       DI:     Incremented for next character
    77 ;   Corrupts registers:
    78 ;       AX, DX
    79 ;--------------------------------------------------------------------
    80 ALIGN JUMP_ALIGN
    81 MovePartialWordToNewTextLineAndPrintCharacterFromAX:
    82     cmp     al, ' '     ; Space or any control character
    83     jb      SHORT .MoveCursorInDItoBeginningOfNextLine
    84     push    si
    85     push    cx
    86     push    ax
    87 
    88     call    .GetOffsetToPartialWordToSIandSizeToCX
    89     call    .MoveCursorInDItoBeginningOfNextLine
    90     jcxz    .NothingToMove
    91     call    .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
    92 .NothingToMove:
    93     pop     ax
    94     pop     cx
    95     pop     si
    96     jmp     DisplayCharOut_TeletypeOutputWithAttribute
    97 
    98 ;--------------------------------------------------------------------
    99 ; .GetOffsetToPartialWordToSIandSizeToCX
    100 ;   Parameters:
    101 ;       ES:DI:  Ptr to space before border character
    102 ;   Returns:
    103 ;       CX:     Number of bytes that needs to be moved
    104 ;       ES:SI:  Ptr to beginning of partial word that needs to be moved to new line
    105 ;   Corrupts registers:
    106 ;       Nothing
    107 ;--------------------------------------------------------------------
    108 ALIGN JUMP_ALIGN
    109 .GetOffsetToPartialWordToSIandSizeToCX:
    110     xor     cx, cx
    111     mov     si, di
    112 ALIGN JUMP_ALIGN
    113 .ScanNextCharacter:     ; Space will always be found since one comes after border
    114     dec     si
    115     dec     si
    116     cmp     BYTE [es:si], ' '
    117     je      SHORT .PartialWordFound
    118     inc     cx
    119     jmp     SHORT .ScanNextCharacter
    120 ALIGN JUMP_ALIGN
    121 .PartialWordFound:
    122     inc     si
    123     inc     si          ; SI now points one past space
    124     shl     cx, 1       ; Characters to bytes
    125     ret
    126 
    127 ;--------------------------------------------------------------------
    128 ; .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX
    129 ;   Parameters:
    130 ;       CX:     Number of bytes in partial word
    131 ;       DS:     BDA segment (zero)
    132 ;       ES:SI:  Ptr to partial word on previous line
    133 ;       ES:DI:  Ptr to new empty line
    134 ;   Returns:
    135 ;       ES:DI:  Ptr where to store next character
    136 ;   Corrupts registers:
    137 ;       AX, CX, DX, SI
    138 ;--------------------------------------------------------------------
    139 ALIGN JUMP_ALIGN
    140 .MovePartialWordFromPreviousLineInESSItoNewLineInESDIwithSizeInCX:
    141     push    si
    142     push    cx
    143     WAIT_RETRACE_IF_NECESSARY_THEN rep movsb
    144     pop     cx
    145     pop     si
    146     xchg    di, si
    147     shr     cx, 1       ; Bytes to characters
    148     mov     al, ' '
    149     call    DisplayPrint_RepeatCharacterFromALwithCountInCX
    150     mov     di, si
    151     ret
    152 
    153 ;--------------------------------------------------------------------
    154 ; .MoveCursorInDItoBeginningOfNextLine
     44; MenuCharOut_PrintLFCRandAdjustOffsetForStartOfLine
     45; PrintCRandAdjustOffsetForStartOfLine
    15546;   Parameters:
    15647;       DS:     BDA segment (zero)
    15748;       ES:DI:  Ptr to cursor location
     49;       [DISPLAY_CONTEXT.wCharOutParam]:
     50;               Low byte  = First column offset (after CR)
     51;               High byte = Last column offset (when using automatic line change)
    15852;   Returns:
    15953;       ES:DI:  Ptr to beginning of new line
     
    16256;--------------------------------------------------------------------
    16357ALIGN JUMP_ALIGN
    164 .MoveCursorInDItoBeginningOfNextLine:
     58MenuCharOut_PrintLFCRandAdjustOffsetForStartOfLine:
    16559    mov     al, LF
    16660    call    DisplayCharOut_BiosTeletypeOutput
     61    ; Fall to PrintCRandAdjustOffsetForStartOfLine
     62
     63ALIGN JUMP_ALIGN
     64PrintCRandAdjustOffsetForStartOfLine:
    16765    mov     al, CR
    168     ; Fall to PrintCRfromALandAdjustColumnToMenuText
    169 
    170 
    171 ;--------------------------------------------------------------------
    172 ; PrintCRfromALandAdjustColumnToMenuText
    173 ;   Parameters:
    174 ;       AL:     Character to output (CR)
    175 ;       DS:     BDA segment (zero)
    176 ;       ES:DI:  Ptr to video memory where to output
    177 ;   Returns:
    178 ;       DI:     Incremented for next text line
    179 ;   Corrupts registers:
    180 ;       AX, DX
    181 ;--------------------------------------------------------------------
    182 ALIGN JUMP_ALIGN
    183 PrintCRfromALandAdjustColumnToMenuText:
    18466    call    DisplayCharOut_BiosTeletypeOutput
    185     mov     al, MENU_TEXT_COLUMN_OFFSET ; Offset to start of text
    186     ; Fall to SetCursorToNextMenuLine
    187 
    188 ;--------------------------------------------------------------------
    189 ; SetCursorToNextMenuLine
    190 ;   Parameters:
    191 ;       AL:     Column offset from start of borders
    192 ;       DS:     BDA segment (zero)
    193 ;       ES:DI:  Ptr to video memory where to output
    194 ;   Returns:
    195 ;       DI:     Adjusted for next line
    196 ;   Corrupts registers:
    197 ;       AX, DX
    198 ;--------------------------------------------------------------------
    199 ALIGN JUMP_ALIGN
    200 SetCursorToNextMenuLine:
    201     push    bp
    202 
    203     mov     bp, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam]
    204     call    .AddCoordinatesForNewBorderLineToAX
    205     call    DisplayCursor_SetCoordinatesFromAX  ; Updates DI
    206 
    207     pop     bp
     67    eMOVZX  ax, BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.wCharOutParam]
     68    add     di, ax
     69ReturnSinceNoNeedToStartLineWithControlCharacter:
    20870    ret
    209 
    210 ;--------------------------------------------------------------------
    211 ; .AddCoordinatesForNewBorderLineToAX
    212 ;   Parameters:
    213 ;       AL:     Column offset from start of borders
    214 ;       DS:     BDA segment (zero)
    215 ;       SS:BP:  Ptr to MENU
    216 ;   Returns:
    217 ;       AX:     Coordinates for new line
    218 ;   Corrupts registers:
    219 ;       DX
    220 ;--------------------------------------------------------------------
    221 ALIGN JUMP_ALIGN
    222 .AddCoordinatesForNewBorderLineToAX:
    223     call    MenuLocation_AddTitleBordersTopLeftCoordinatesToAX
    224     push    ax
    225     call    DisplayCursor_GetSoftwareCoordinatesToAX
    226     pop     dx
    227     mov     al, dl                  ; Adjust column to borders
    228     ret
Note: See TracChangeset for help on using the changeset viewer.