Changeset 48 in xtideuniversalbios for trunk/Assembly_Library/Src/Display


Ignore:
Timestamp:
Oct 8, 2010, 3:44:05 PM (14 years ago)
Author:
Tomi Tilli
google:author:
aitotat
Message:

Changes to Assembly Library:
Added functions to clear Menu Title and Information areas.
Implemented automatic line change when writing Menu Title and Information areas.
CGA snow related functions have been moved to CgaSnow.asm.
Keyboard input functions no longer produce beep for backspace.

Location:
trunk/Assembly_Library/Src/Display
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Src/Display/DisplayCharOut.asm

    r47 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   26.6.2010
    4 ; Last update   :   4.10.2010
     4; Last update   :   8.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for outputting characters to video memory.
     
    1111; Section containing code
    1212SECTION .text
    13 
    14 ;--------------------------------------------------------------------
    15 ; WAIT_RETRACE_IF_NECESSARY_THEN
    16 ;   Parameters:
    17 ;       AL:     Character to output
    18 ;       AH:     Attribute to output (stosw only)
    19 ;       DS:     BDA segment (zero)
    20 ;       ES:DI:  Ptr to video memory where to output
    21 ;   Returns:
    22 ;       DI:     Incremented for next character
    23 ;   Corrupts registers:
    24 ;       AX, DX
    25 ;--------------------------------------------------------------------
    26 %macro WAIT_RETRACE_IF_NECESSARY_THEN 1
    27 %ifdef ELIMINATE_CGA_SNOW
    28     %ifidn %1, stosb
    29         call    StosbWithoutCgaSnow
    30     %else
    31         call    StoswWithoutCgaSnow
    32     %endif
    33 %else
    34     %1          ; STOSB or STOSW
    35 %endif
    36 %endmacro
    37 
    3813
    3914;--------------------------------------------------------------------
     
    155130.BufferFull:
    156131    ret
    157 
    158 
    159 ; STOSB and STOSW replacement functions to prevent CGA snow. These will slow
    160 ; drawing a lot so use them only if it is necessary to eliminate CGA snow.
    161 %ifdef ELIMINATE_CGA_SNOW
    162 
    163 OFFSET_TO_CGA_STATUS_REGISTER   EQU     6       ; Base port 3D4h + 6 = 3DAh
    164 CGA_STATUS_REGISTER             EQU     3DAh
    165 
    166 ;--------------------------------------------------------------------
    167 ; WAIT_UNTIL_SAFE_CGA_WRITE
    168 ;   Parameters:
    169 ;       DX:     CGA Status Register Address (3DAh)
    170 ;   Returns:
    171 ;       Nothing
    172 ;   Corrupts registers:
    173 ;       AL
    174 ;--------------------------------------------------------------------
    175 %macro WAIT_UNTIL_SAFE_CGA_WRITE 0
    176 %%WaitUntilNotInRetrace:
    177     in      al, dx
    178     shr     al, 1   ; 1 = Bit 0: A 1 indicates that regen-buffer memory access can be
    179                     ; made without interfering with the display. (H or V retrace)
    180     jc      SHORT %%WaitUntilNotInRetrace
    181 %%WaitUntilNextRetraceStarts:
    182     in      al, dx
    183     shr     al, 1
    184     jnc     SHORT %%WaitUntilNextRetraceStarts
    185 %endmacro
    186 
    187 ;--------------------------------------------------------------------
    188 ; StosbWithoutCgaSnow
    189 ; StoswWithoutCgaSnow
    190 ;   Parameters:
    191 ;       AL:     Character to output
    192 ;       AH:     Attribute to output (StoswWithoutCgaSnow only)
    193 ;       DS:     BDA segment (zero)
    194 ;       ES:DI:  Ptr to video memory where to output
    195 ;   Returns:
    196 ;       DI:     Incremented for next character
    197 ;   Corrupts registers:
    198 ;       AX, DX
    199 ;--------------------------------------------------------------------
    200 ALIGN JUMP_ALIGN
    201 StosbWithoutCgaSnow:
    202     call    DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
    203     jne     SHORT .StosbWithoutWaitSinceUnknownPort
    204 
    205     mov     ah, al
    206     cli             ; Interrupt request would mess up timing
    207     WAIT_UNTIL_SAFE_CGA_WRITE
    208     mov     al, ah
    209 .StosbWithoutWaitSinceUnknownPort:
    210     stosb
    211     sti
    212     ret
    213 
    214 ALIGN JUMP_ALIGN
    215 StoswWithoutCgaSnow:
    216     push    bx
    217     call    DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
    218     jne     SHORT .StoswWithoutWaitSinceUnknownPort
    219 
    220     xchg    bx, ax
    221     cli             ; Interrupt request would mess up timing
    222     WAIT_UNTIL_SAFE_CGA_WRITE
    223     xchg    ax, bx
    224 .StoswWithoutWaitSinceUnknownPort:
    225     stosw
    226     pop     bx
    227     sti
    228     ret
    229 
    230 
    231 ;--------------------------------------------------------------------
    232 ; DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
    233 ;   Parameters:
    234 ;       DS:     BDA segment (zero)
    235 ;   Returns:
    236 ;       DX:     CGA Status Register Address
    237 ;       ZF:     Set if CGA Base Port found in BDA
    238 ;   Corrupts registers:
    239 ;       Nothing
    240 ;--------------------------------------------------------------------
    241 ALIGN JUMP_ALIGN
    242 DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA:
    243     mov     dx, [BDA.wVidPort]
    244     add     dl, OFFSET_TO_CGA_STATUS_REGISTER
    245     cmp     dx, CGA_STATUS_REGISTER
    246     ret
    247 
    248 %endif ; ELIMINATE_CGA_SNOW
  • trunk/Assembly_Library/Src/Display/DisplayContext.asm

    r45 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   25.6.2010
    4 ; Last update   :   28.9.2010
     4; Last update   :   5.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for managing display context.
     
    102102
    103103;--------------------------------------------------------------------
     104; DisplayContext_PrepareOffScreenBufferInESBXtoESDI
     105;   Parameters:
     106;       BX:AX:  Ptr to off screen buffer
     107;   Returns:
     108;       Nothing
     109;   Corrupts registers:
     110;       AX
     111;--------------------------------------------------------------------
     112ALIGN JUMP_ALIGN
     113DisplayContext_PrepareOffScreenBufferInESBXtoESDI:
     114    push    ds
     115
     116    LOAD_BDA_SEGMENT_TO ds, di
     117    xchg    ax, bx
     118    mov     bx, es
     119    call    DisplayContext_SetCharacterPointerFromBXAX  ; ES:DI now has the pointer
     120
     121    mov     bl, ATTRIBUTES_NOT_USED
     122    mov     ax, BUFFER_OUTPUT_WITH_CHAR_ONLY
     123    call    DisplayContext_SetCharOutputFunctionFromAXwithAttribFlagInBL
     124
     125    mov     bx, di
     126    pop     ds
     127    ret
     128
     129
     130;--------------------------------------------------------------------
    104131; DisplayContext_SynchronizeToHardware
    105132;   Parameters:
     
    123150;       DS:     BDA segment (zero)
    124151;   Returns:
    125 ;       ES:DI:  Pointer that was in DX:AX
     152;       ES:DI:  Pointer that was in BX:AX
    126153;   Corrupts registers:
    127154;       AX
  • trunk/Assembly_Library/Src/Display/DisplayFormat.asm

    r47 r48  
    22; Project name  :   Assembly Library
    33; Created date  :   29.6.2010
    4 ; Last update   :   4.10.2010
     4; Last update   :   8.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for displaying formatted strings.
     
    220220    dec     di                  ; DI = Offset where to move last byte formatted
    221221    xchg    bx, ax              ; BX = BYTEs to prepend
    222     call    .ReverseMoveCXbytesFromESSItoESDI
     222    call    .ReverseCopyCXbytesFromESSItoESDI
    223223    xchg    ax, bx
    224224    call    .ReversePrintAXspacesStartingFromESDI
     
    231231
    232232;--------------------------------------------------------------------
    233 ; .ReverseMoveCXbytesFromESSItoESDI
    234 ;   Parameters:
    235 ;       CX:     Number of bytes to move
    236 ;       DS:     BDA segment (zero)
    237 ;       ES:SI:  Ptr to source in video RAM
    238 ;       ES:DI:  Ptr to destination in video RAM
    239 ;   Returns:
    240 ;       DI:     Offset to character preceeding string just moved
     233; .ReverseCopyCXbytesFromESSItoESDI
     234;   Parameters:
     235;       CX:     Number of bytes to copy
     236;       DS:     BDA segment (zero)
     237;       ES:SI:  Ptr to old location
     238;       ES:DI:  Ptr to new location
     239;   Returns:
     240;       DI:     Updated to before last character copied
    241241;   Corrupts registers:
    242242;       AX, CX, DX, SI
    243243;--------------------------------------------------------------------
    244244ALIGN JUMP_ALIGN
    245 .ReverseMoveCXbytesFromESSItoESDI:
    246 %ifdef ELIMINATE_CGA_SNOW
    247     call    DisplayCharOut_LoadAndVerifyStatusRegisterFromBDA
    248     je      SHORT .WaitUntilReadyToMoveNextByte
    249 %endif
    250 
     245.ReverseCopyCXbytesFromESSItoESDI:
     246    test    BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_ATTRIBUTES
     247    jz      SHORT .CopyWithoutDisplayProcessing
     248
     249    WAIT_RETRACE_IF_NECESSARY_THEN rep movsb
     250    dec     di                  ; Point to preceeding character instead of attribute
     251    ret
     252ALIGN JUMP_ALIGN
     253.CopyWithoutDisplayProcessing:
    251254    eSEG_STR rep, es, movsb
    252 
    253 %ifdef ELIMINATE_CGA_SNOW
    254     jmp     SHORT .AlignDIforFirstPreceedingSpace
    255 .WaitUntilReadyToMoveNextByte:
    256     cli             ; Interrupt request would mess up timing
    257     WAIT_UNTIL_SAFE_CGA_WRITE
    258 .MovsbWithoutWaitSinceUnknownPort:
    259     eSEG    es
    260     movsb
    261     sti
    262     loop    .WaitUntilReadyToMoveNextByte
    263 %endif
    264     ; Fall to .AlignDIforFirstPreceedingSpace
    265 
    266 ;--------------------------------------------------------------------
    267 ; .AlignDIforFirstPreceedingSpace
    268 ;   Parameters:
    269 ;       DS:     BDA segment (zero)
    270 ;       ES:DI:  Byte offset before last byte moved
    271 ;   Returns:
    272 ;       DI:     Offset to space preceeding moved string
    273 ;   Corrupts registers:
    274 ;       AX
    275 ;--------------------------------------------------------------------
    276 ALIGN JUMP_ALIGN
    277 .AlignDIforFirstPreceedingSpace:
    278     mov     al, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags]
    279     and     ax, BYTE FLG_CONTEXT_ATTRIBUTES
    280     not     ax
    281     and     di, ax
    282255    ret
    283256
  • trunk/Assembly_Library/Src/Display/DisplayPrint.asm

    r44 r48  
    2525;   minimum number of characters. For example %8d would append spaces
    2626;   after integer so that at least 8 characters would be printed.
     27;
     28;   When placing '-' after number, then spaces will be used for prepending.
     29;   For example %8-d would prepend integer with spaces so that at least
     30;   8 characters would be printed.
    2731;
    2832; DisplayPrint_FormattedNullTerminatedStringFromCSSI
Note: See TracChangeset for help on using the changeset viewer.