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

Last change on this file since 50 was 50, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:
Removed Memory_ExchangeSSBPwithESDI since it obviously corrupted stack.
CGA detection is now only done once when initializing Display Context.
Moved File Library defines to File.inc.

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