Changeset 42 in xtideuniversalbios for trunk/Assembly_Library


Ignore:
Timestamp:
Sep 18, 2010, 6:04:31 PM (14 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Display Library no more produces CGA snow.

Location:
trunk/Assembly_Library
Files:
4 edited

Legend:

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

    r41 r42  
    22; Project name  :   Assembly Library
    33; Created date  :   26.6.2010
    4 ; Last update   :   13.8.2010
     4; Last update   :   18.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for outputting characters to video memory.
     
    1313
    1414;--------------------------------------------------------------------
     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
     38
     39;--------------------------------------------------------------------
    1540; DisplayCharOut_TeletypeOutputWithAttribute
    1641; DisplayCharOut_TeletypeOutput
     
    2954    cmp     al, ' '                         ; Printable character?
    3055    jb      SHORT DisplayCharOut_BiosTeletypeOutput
    31     stosw
     56    WAIT_RETRACE_IF_NECESSARY_THEN stosw
    3257    ret
    3358
     
    85110;       AL:     Character to output
    86111;       AH:     Attribute to output
    87 ;       ES:DI:  Ptr to video memory where to output
    88 ;   Returns:
    89 ;       DI:     Incremented for next character
    90 ;   Corrupts registers:
    91 ;       AX
     112;       DS:     BDA segment (zero)
     113;       ES:DI:  Ptr to video memory where to output
     114;   Returns:
     115;       DI:     Incremented for next character
     116;   Corrupts registers:
     117;       AX, DX
    92118;--------------------------------------------------------------------
    93119ALIGN JUMP_ALIGN
     
    95121    xchg    al, ah              ; Swap character and attribute
    96122    inc     di                  ; Skip character
    97     stosb
     123    WAIT_RETRACE_IF_NECESSARY_THEN stosb
    98124    ret
    99125
    100126ALIGN JUMP_ALIGN
    101127DisplayCharOut_Character:
    102     stosb
     128    WAIT_RETRACE_IF_NECESSARY_THEN stosb
    103129    inc     di                  ; Skip attribute
    104130    ret
     
    106132ALIGN JUMP_ALIGN
    107133DisplayCharOut_CharacterWithAttribute:
    108     stosw
     134    WAIT_RETRACE_IF_NECESSARY_THEN stosw
    109135    ret
    110136
     
    129155.BufferFull:
    130156    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
     163OFFSET_TO_CGA_STATUS_REGISTER   EQU     6       ; Base port 3D4h + 6 = 3DAh
     164CGA_STATUS_REGISTER             EQU     3DAh
     165
     166;--------------------------------------------------------------------
     167; WAIT_UNTIL_SAFE_CGA_WRITE
     168;   Parameters:
     169;       DX:     CGA Status Register Address (3DAh)
     170;   Returns:
     171;       Interrupts disabled
     172;   Corrupts registers:
     173;       AL
     174;--------------------------------------------------------------------
     175%macro WAIT_UNTIL_SAFE_CGA_WRITE 0
     176    cli             ; Interrupt request would mess up timing
     177%%WaitUntilNotInRetrace:
     178    in      al, dx
     179    shr     al, 1   ; 1 = Bit 0: A 1 indicates that regen-buffer memory access can be
     180                    ; made without interfering with the display. (H or V retrace)
     181    jc      SHORT %%WaitUntilNotInRetrace
     182    sti
     183    nop             ; Should have time to serve IRQ here
     184    cli
     185%%WaitUntilNextRetraceStarts:
     186    in      al, dx
     187    shr     al, 1
     188    jnc     SHORT %%WaitUntilNextRetraceStarts
     189%endmacro
     190
     191;--------------------------------------------------------------------
     192; StosbWithoutCgaSnow
     193; StoswWithoutCgaSnow
     194;   Parameters:
     195;       AL:     Character to output
     196;       AH:     Attribute to output (StoswWithoutCgaSnow only)
     197;       DS:     BDA segment (zero)
     198;       ES:DI:  Ptr to video memory where to output
     199;   Returns:
     200;       DI:     Incremented for next character
     201;   Corrupts registers:
     202;       AX, DX
     203;--------------------------------------------------------------------
     204ALIGN JUMP_ALIGN
     205StosbWithoutCgaSnow:
     206    call    LoadAndVerifyStatusRegisterFromBDA
     207    jne     SHORT .StosbWithoutWaitSinceUnknownPort
     208
     209    mov     ah, al
     210    WAIT_UNTIL_SAFE_CGA_WRITE
     211    mov     al, ah
     212    stosb
     213    sti
     214    ret
     215ALIGN JUMP_ALIGN
     216.StosbWithoutWaitSinceUnknownPort:
     217    stosb
     218    ret
     219
     220ALIGN JUMP_ALIGN
     221StoswWithoutCgaSnow:
     222    call    LoadAndVerifyStatusRegisterFromBDA
     223    jne     SHORT .StoswWithoutWaitSinceUnknownPort
     224
     225    push    bx
     226    xchg    bx, ax
     227    WAIT_UNTIL_SAFE_CGA_WRITE
     228    xchg    ax, bx
     229    stosw
     230    pop     bx
     231    sti
     232    ret
     233ALIGN JUMP_ALIGN
     234.StoswWithoutWaitSinceUnknownPort:
     235    stosw
     236    ret
     237
     238;--------------------------------------------------------------------
     239; LoadAndVerifyStatusRegisterFromBDA
     240;   Parameters:
     241;       DS:     BDA segment (zero)
     242;   Returns:
     243;       DX:     CGA Status Register Address
     244;       ZF:     Set if CGA Base Port found in BDA
     245;   Corrupts registers:
     246;       Nothing
     247;--------------------------------------------------------------------
     248ALIGN JUMP_ALIGN
     249LoadAndVerifyStatusRegisterFromBDA:
     250    mov     dx, [BDA.wVidPort]
     251    add     dl, OFFSET_TO_CGA_STATUS_REGISTER
     252    cmp     dx, CGA_STATUS_REGISTER
     253    ret
     254
     255%endif ; ELIMINATE_CGA_SNOW
  • trunk/Assembly_Library/Src/Display/DisplayPrint.asm

    r41 r42  
    22; Project name  :   Assembly Library
    33; Created date  :   26.6.2010
    4 ; Last update   :   10.8.2010
     4; Last update   :   18.9.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for display output.
     
    250250
    251251;--------------------------------------------------------------------
    252 ; DisplayPrint_RepeatCharacterFromALwithCountInCX
    253 ;   Parameters:
    254 ;       AL:     Character to display
    255 ;       CX:     Repeat count
    256 ;       DS:     BDA segment (zero)
    257 ;       ES:DI:  Ptr to cursor location in video RAM
    258 ;   Returns:
    259 ;       DI:     Updated offset to video RAM
    260 ;   Corrupts registers:
    261 ;       AX, DX
    262 ;--------------------------------------------------------------------
    263 ALIGN JUMP_ALIGN
    264 DisplayPrint_RepeatCharacterFromALwithCountInCX:
    265     push    ax
    266     call    DisplayPrint_CharacterFromAL
    267     pop     ax
    268     loop    DisplayPrint_RepeatCharacterFromALwithCountInCX
    269     ret
    270 
    271 
    272 ;--------------------------------------------------------------------
    273 ; DisplayPrint_CharacterFromAL
    274 ;   Parameters:
    275 ;       AL:     Character to display
    276 ;       DS:     BDA segment (zero)
    277 ;       ES:DI:  Ptr to cursor location in video RAM
    278 ;   Returns:
    279 ;       DI:     Updated offset to video RAM
    280 ;   Corrupts registers:
    281 ;       AX, DX
    282 ;--------------------------------------------------------------------
    283 ALIGN JUMP_ALIGN
    284 DisplayPrint_CharacterFromAL:
    285     mov     ah, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute]
    286     jmp     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut]
    287 
    288 
    289 ;--------------------------------------------------------------------
    290252; DisplayPrint_ClearScreen
    291253;   Parameters:
     
    317279;       ES:DI:  Ptr to cursor location in video RAM
    318280;   Returns:
    319 ;       Nothing
     281;       DI:     Updated offset to video RAM
    320282;   Corrupts registers:
    321283;       AX, DX
     
    323285ALIGN JUMP_ALIGN
    324286DisplayPrint_ClearAreaWithHeightInAHandWidthInAL:
     287    push    si
    325288    push    cx
    326289    push    bx
    327     push    di
    328 
    329     xchg    bx, ax                          ; Move parameters to BX
     290
     291    xchg    bx, ax                          ; Area size to BX
    330292    call    DisplayCursor_GetSoftwareCoordinatesToAX
    331     xchg    dx, ax                          ; Coordinates now in DX
    332     xor     cx, cx                          ; Zero CX
    333 
    334 ALIGN JUMP_ALIGN
    335 .ClearRowFromArea:
     293    xchg    si, ax                          ; Software (Y,X) coordinates now in SI
     294    xor     cx, cx
     295
     296ALIGN JUMP_ALIGN
     297.ClearRowLoop:
     298    mov     cl, bl                          ; Area width now in CX
    336299    mov     al, ' '                         ; Clear with space
    337     mov     ah, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute]
    338     mov     cl, bl                          ; Area width = WORDs to clear
    339     rep stosw
    340     dec     bh
    341     jz      SHORT .AreaCleared
    342 
    343     inc     dh                              ; Increment row
    344     push    dx
    345     xchg    ax, dx
     300    call    DisplayPrint_RepeatCharacterFromALwithCountInCX
     301
     302    xchg    ax, si                          ; Coordinates to AX
     303    inc     ah                              ; Increment row
     304    mov     si, ax
    346305    call    DisplayCursor_SetCoordinatesFromAX
    347     pop     dx
    348     jmp     SHORT .ClearRowFromArea
    349 
    350 ALIGN JUMP_ALIGN
    351 .AreaCleared:
    352     pop     di
    353     mov     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fpCursorPosition], di
     306    dec     bh                              ; Decrement rows left
     307    jnz     SHORT .ClearRowLoop
     308
    354309    pop     bx
    355310    pop     cx
    356     ret
     311    pop     si
     312    ret
     313
     314
     315;--------------------------------------------------------------------
     316; DisplayPrint_RepeatCharacterFromALwithCountInCX
     317;   Parameters:
     318;       AL:     Character to display
     319;       CX:     Repeat count
     320;       DS:     BDA segment (zero)
     321;       ES:DI:  Ptr to cursor location in video RAM
     322;   Returns:
     323;       DI:     Updated offset to video RAM
     324;   Corrupts registers:
     325;       AX, DX
     326;--------------------------------------------------------------------
     327ALIGN JUMP_ALIGN
     328DisplayPrint_RepeatCharacterFromALwithCountInCX:
     329    push    ax
     330    call    DisplayPrint_CharacterFromAL
     331    pop     ax
     332    loop    DisplayPrint_RepeatCharacterFromALwithCountInCX
     333    ret
     334
     335
     336;--------------------------------------------------------------------
     337; DisplayPrint_CharacterFromAL
     338;   Parameters:
     339;       AL:     Character to display
     340;       DS:     BDA segment (zero)
     341;       ES:DI:  Ptr to cursor location in video RAM
     342;   Returns:
     343;       DI:     Updated offset to video RAM
     344;   Corrupts registers:
     345;       AX, DX
     346;--------------------------------------------------------------------
     347ALIGN JUMP_ALIGN
     348DisplayPrint_CharacterFromAL:
     349    mov     ah, [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bAttribute]
     350    jmp     [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.fnCharOut]
  • trunk/Assembly_Library/Src/Time/Delay.asm

    r41 r42  
    7676    push    dx
    7777
     78    sti                         ; Make sure that interrupts are enabled
    7879    xchg    dx, ax
    7980    call    TimerTicks_ReadFromBdaToAX
    8081    add     dx, ax              ; DX = end time
    81     sti                         ; Make sure that interrupts are enabled
    8282.WaitLoop:
    8383    call    TimerTicks_ReadFromBdaToAX
  • trunk/Assembly_Library/makefile

    r41 r42  
    5050# Assembler preprocessor defines.                               #
    5151#################################################################
    52 DEFINES =
     52DEFINES = ELIMINATE_CGA_SNOW
    5353DEFINES_XT =
    5454DEFINES_XTPLUS = USE_186
Note: See TracChangeset for help on using the changeset viewer.