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

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

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 4.1 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for preventing CGA snow.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; CgaSnow_IsCgaPresent
25; Parameters:
26; DS: BDA segment (zero)
27; Returns:
28; CF: Set if CGA detected
29; Cleared if CGA not detected
30; Corrupts registers:
31; AX
32;--------------------------------------------------------------------
33ALIGN DISPLAY_JUMP_ALIGN
34CgaSnow_IsCgaPresent:
35 cmp WORD [BDA.wVidPort], CGA_STATUS_REGISTER - OFFSET_TO_CGA_STATUS_REGISTER
36 jne SHORT .CgaNotFound
37
38 ; All standard CGA modes use 25 rows but only EGA and later store it to BDA.
39 cmp BYTE [BDA.bVidRows], 25
40 jge SHORT .CgaNotFound
41 stc
42 ret
43ALIGN DISPLAY_JUMP_ALIGN
44.CgaNotFound:
45 clc
46 ret
47
48
49; CGA snow prevention must be kept optional to avoid unnecessary
50; overhead when building programs meant for non-CGA systems.
51%ifdef ELIMINATE_CGA_SNOW
52
53;--------------------------------------------------------------------
54; CgaSnow_Stosb
55; CgaSnow_Stosw
56; Parameters:
57; AL: Character to output
58; AH: Attribute to output (CgaSnow_StoswWithoutCgaSnow only)
59; DS: BDA segment (zero)
60; ES:DI: Ptr to video memory where to output
61; Returns:
62; DI: Incremented for next character
63; Corrupts registers:
64; AX, DX
65;--------------------------------------------------------------------
66ALIGN DISPLAY_JUMP_ALIGN
67CgaSnow_Stosb:
68 call LoadCgaStatusRegisterAddressToDXifCgaPresent
69 jz SHORT .StosbWithoutWaitSinceUnknownPort
70
71 mov ah, al
72 cli ; Interrupt request would mess up timing
73 WAIT_UNTIL_SAFE_CGA_WRITE
74 mov al, ah
75.StosbWithoutWaitSinceUnknownPort:
76 stosb
77 sti
78 ret
79
80ALIGN DISPLAY_JUMP_ALIGN
81CgaSnow_Stosw:
82 push bx
83 call LoadCgaStatusRegisterAddressToDXifCgaPresent
84 jz SHORT .StoswWithoutWaitSinceUnknownPort
85
86 xchg bx, ax
87 cli ; Interrupt request would mess up timing
88 WAIT_UNTIL_SAFE_CGA_WRITE
89 xchg ax, bx
90.StoswWithoutWaitSinceUnknownPort:
91 stosw
92 sti
93 pop bx
94 ret
95
96
97;--------------------------------------------------------------------
98; CgaSnow_RepMovsb
99; Parameters:
100; CX: Number of characters to copy
101; DS: BDA segment (zero)
102; ES:SI: Ptr to video memory where to read from
103; ES:DI: Ptr to video memory where to write to
104; Returns:
105; SI, DI: Updated for next character
106; Corrupts registers:
107; AX, CX, DX
108;--------------------------------------------------------------------
109ALIGN DISPLAY_JUMP_ALIGN
110CgaSnow_RepMovsb:
111 call LoadCgaStatusRegisterAddressToDXifCgaPresent
112 jz SHORT .RepMovsbWithoutWaitSinceUnknownPort
113
114.MovsbNextByte:
115 cli ; Interrupt request would mess up timing
116 WAIT_UNTIL_SAFE_CGA_WRITE
117 es movsb
118 sti
119 loop .MovsbNextByte
120 ret
121.RepMovsbWithoutWaitSinceUnknownPort:
122 eSEG_STR rep, es, movsb
123 ret
124
125
126;--------------------------------------------------------------------
127; LoadCgaStatusRegisterAddressToDXifCgaPresent
128; Parameters:
129; DS: BDA segment (zero)
130; Returns:
131; DX: CGA Status Register Address
132; ZF: Set if CGA not present
133; Cleared if CGA present
134; Corrupts registers:
135; Nothing
136;--------------------------------------------------------------------
137ALIGN DISPLAY_JUMP_ALIGN
138LoadCgaStatusRegisterAddressToDXifCgaPresent:
139 test BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_CGA
140 jz SHORT .NoCgaDetected
141 mov dx, CGA_STATUS_REGISTER
142ALIGN DISPLAY_JUMP_ALIGN, ret
143.NoCgaDetected:
144 ret
145
146
147%endif ; ELIMINATE_CGA_SNOW
Note: See TracBrowser for help on using the repository browser.