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

Last change on this file since 374 was 369, checked in by gregli@…, 13 years ago

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

File size: 3.4 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for preventing CGA snow.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; CgaSnow_IsCgaPresent
9; Parameters:
10; DS: BDA segment (zero)
11; Returns:
12; CF: Set if CGA detected
13; Cleared if CGA not detected
14; Corrupts registers:
15; AX
16;--------------------------------------------------------------------
17ALIGN DISPLAY_JUMP_ALIGN
18CgaSnow_IsCgaPresent:
19 cmp WORD [BDA.wVidPort], CGA_STATUS_REGISTER - OFFSET_TO_CGA_STATUS_REGISTER
20 jne SHORT .CgaNotFound
21
22 ; All standard CGA modes use 25 rows but only EGA and later store it to BDA.
23 cmp BYTE [BDA.bVidRows], 25
24 jge SHORT .CgaNotFound
25 stc
26 ret
27ALIGN DISPLAY_JUMP_ALIGN
28.CgaNotFound:
29 clc
30 ret
31
32
33; CGA snow prevention must be kept optional to avoid unnecessary
34; overhead when building programs meant for non-CGA systems.
35%ifdef ELIMINATE_CGA_SNOW
36
37;--------------------------------------------------------------------
38; CgaSnow_Stosb
39; CgaSnow_Stosw
40; Parameters:
41; AL: Character to output
42; AH: Attribute to output (CgaSnow_StoswWithoutCgaSnow only)
43; DS: BDA segment (zero)
44; ES:DI: Ptr to video memory where to output
45; Returns:
46; DI: Incremented for next character
47; Corrupts registers:
48; AX, DX
49;--------------------------------------------------------------------
50ALIGN DISPLAY_JUMP_ALIGN
51CgaSnow_Stosb:
52 call LoadCgaStatusRegisterAddressToDXifCgaPresent
53 jz SHORT .StosbWithoutWaitSinceUnknownPort
54
55 mov ah, al
56 cli ; Interrupt request would mess up timing
57 WAIT_UNTIL_SAFE_CGA_WRITE
58 mov al, ah
59.StosbWithoutWaitSinceUnknownPort:
60 stosb
61 sti
62 ret
63
64ALIGN DISPLAY_JUMP_ALIGN
65CgaSnow_Stosw:
66 push bx
67 call LoadCgaStatusRegisterAddressToDXifCgaPresent
68 jz SHORT .StoswWithoutWaitSinceUnknownPort
69
70 xchg bx, ax
71 cli ; Interrupt request would mess up timing
72 WAIT_UNTIL_SAFE_CGA_WRITE
73 xchg ax, bx
74.StoswWithoutWaitSinceUnknownPort:
75 stosw
76 sti
77 pop bx
78 ret
79
80
81;--------------------------------------------------------------------
82; CgaSnow_RepMovsb
83; Parameters:
84; CX: Number of characters to copy
85; DS: BDA segment (zero)
86; ES:SI: Ptr to video memory where to read from
87; ES:DI: Ptr to video memory where to write to
88; Returns:
89; SI, DI: Updated for next character
90; Corrupts registers:
91; AX, CX, DX
92;--------------------------------------------------------------------
93ALIGN DISPLAY_JUMP_ALIGN
94CgaSnow_RepMovsb:
95 call LoadCgaStatusRegisterAddressToDXifCgaPresent
96 jz SHORT .RepMovsbWithoutWaitSinceUnknownPort
97
98.MovsbNextByte:
99 cli ; Interrupt request would mess up timing
100 WAIT_UNTIL_SAFE_CGA_WRITE
101 es movsb
102 sti
103 loop .MovsbNextByte
104 ret
105.RepMovsbWithoutWaitSinceUnknownPort:
106 eSEG_STR rep, es, movsb
107 ret
108
109
110;--------------------------------------------------------------------
111; LoadCgaStatusRegisterAddressToDXifCgaPresent
112; Parameters:
113; DS: BDA segment (zero)
114; Returns:
115; DX: CGA Status Register Address
116; ZF: Set if CGA not present
117; Cleared if CGA present
118; Corrupts registers:
119; Nothing
120;--------------------------------------------------------------------
121ALIGN DISPLAY_JUMP_ALIGN
122LoadCgaStatusRegisterAddressToDXifCgaPresent:
123 test BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_CGA
124 jz SHORT .NoCgaDetected
125 mov dx, CGA_STATUS_REGISTER
126ALIGN DISPLAY_JUMP_ALIGN, ret
127.NoCgaDetected:
128 ret
129
130
131%endif ; ELIMINATE_CGA_SNOW
Note: See TracBrowser for help on using the repository browser.