source: xtideuniversalbios/trunk/Assembly_Library/Src/Display/CgaSnow.asm @ 48

Last change on this file since 48 was 48, checked in by aitotat, 14 years ago

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.

File size: 3.7 KB
Line 
1; File name     :   CgaSnow.asm
2; Project name  :   Assembly Library
3; Created date  :   8.10.2010
4; Last update   :   8.10.2010
5; Author        :   Tomi Tilli
6; Description   :   Functions for preventing CGA snow.
7
8; Section containing code
9SECTION .text
10
11
12; CGA snow preventing must be kept optional so unnecerrasy overhead
13; can be prevented when building program ment for non-CGA systems.
14%ifdef ELIMINATE_CGA_SNOW
15
16;--------------------------------------------------------------------
17; CgaSnow_StosbWithoutCgaSnow
18; CgaSnow_StoswWithoutCgaSnow
19;   Parameters:
20;       AL:     Character to output
21;       AH:     Attribute to output (CgaSnow_StoswWithoutCgaSnow only)
22;       DS:     BDA segment (zero)
23;       ES:DI:  Ptr to video memory where to output
24;   Returns:
25;       DI:     Incremented for next character
26;   Corrupts registers:
27;       AX, DX
28;--------------------------------------------------------------------
29ALIGN JUMP_ALIGN
30CgaSnow_StosbWithoutCgaSnow:
31    call    LoadAndVerifyStatusRegisterFromBDA
32    jne     SHORT .StosbWithoutWaitSinceUnknownPort
33
34    mov     ah, al
35    cli             ; Interrupt request would mess up timing
36    WAIT_UNTIL_SAFE_CGA_WRITE
37    mov     al, ah
38.StosbWithoutWaitSinceUnknownPort:
39    stosb
40    sti
41    ret
42
43ALIGN JUMP_ALIGN
44CgaSnow_StoswWithoutCgaSnow:
45    push    bx
46    call    LoadAndVerifyStatusRegisterFromBDA
47    jne     SHORT .StoswWithoutWaitSinceUnknownPort
48
49    xchg    bx, ax
50    cli             ; Interrupt request would mess up timing
51    WAIT_UNTIL_SAFE_CGA_WRITE
52    xchg    ax, bx
53.StoswWithoutWaitSinceUnknownPort:
54    stosw
55    pop     bx
56    sti
57    ret
58
59
60;--------------------------------------------------------------------
61; CgaSnow_ScasbWithoutCgaSnow
62;   Parameters:
63;       AL:     Byte for comparison
64;       DS:     BDA segment (zero)
65;       ES:DI:  Ptr to video memory where to output
66;   Returns:
67;       DI:     Incremented for next character
68;   Corrupts registers:
69;       AX, DX
70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72CgaSnow_ScasbWithoutCgaSnow:
73    call    LoadAndVerifyStatusRegisterFromBDA
74    jne     SHORT .ScasbWithoutWaitSinceUnknownPort
75
76    mov     ah, al
77    cli             ; Interrupt request would mess up timing
78    WAIT_UNTIL_SAFE_CGA_WRITE
79.ScasbWithoutWaitSinceUnknownPort:
80    mov     al, ah
81    scasb
82    sti
83    ret
84
85
86;--------------------------------------------------------------------
87; CgaSnow_RepMovsbWithoutCgaSnow
88;   Parameters:
89;       CX:     Number of characters to copy
90;       DS:     BDA segment (zero)
91;       ES:SI:  Ptr to video memory where to read from
92;       ES:DI:  Ptr to video memory where to write to
93;   Returns:
94;       SI, DI: Updated for next character
95;   Corrupts registers:
96;       AX, CX, DX
97;--------------------------------------------------------------------
98ALIGN JUMP_ALIGN
99CgaSnow_RepMovsbWithoutCgaSnow:
100    call    LoadAndVerifyStatusRegisterFromBDA
101    jne     SHORT .RepMovsbWithoutWaitSinceUnknownPort
102
103.MovsbNextByte:
104    cli             ; Interrupt request would mess up timing
105    WAIT_UNTIL_SAFE_CGA_WRITE
106    eSEG    es
107    movsb
108    sti
109    loop    .MovsbNextByte
110    ret
111.RepMovsbWithoutWaitSinceUnknownPort:
112    eSEG_STR rep, es, movsb
113    ret
114
115
116;--------------------------------------------------------------------
117; LoadAndVerifyStatusRegisterFromBDA
118;   Parameters:
119;       DS:     BDA segment (zero)
120;   Returns:
121;       DX:     CGA Status Register Address
122;       ZF:     Set if CGA Base Port found in BDA
123;   Corrupts registers:
124;       Nothing
125;--------------------------------------------------------------------
126ALIGN JUMP_ALIGN
127LoadAndVerifyStatusRegisterFromBDA:
128    mov     dx, [BDA.wVidPort]
129    add     dl, OFFSET_TO_CGA_STATUS_REGISTER
130    cmp     dx, CGA_STATUS_REGISTER
131    je      SHORT .CheckIfEgaOrLater
132    ret
133
134ALIGN JUMP_ALIGN
135.CheckIfEgaOrLater:
136    push    ax
137    call    DisplayPage_GetColumnsToALandRowsToAH
138    cmp     ah, [BDA.bVidRows]      ; Video rows stored only by EGA and later
139    lahf
140    xor     ah, 1<<6                ; Invert ZF
141    sahf
142    pop     ax
143    ret
144
145
146%endif ; ELIMINATE_CGA_SNOW
Note: See TracBrowser for help on using the repository browser.