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

Last change on this file since 569 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 4.3 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-2013 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;--------------------------------------------------------------------
109%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
110 %ifdef MODULE_STRINGS_COMPRESSED
111 %define EXCLUDE
112 %endif
113 %ifdef MODULE_BOOT_MENU
114 %undef EXCLUDE
115 %endif
116%endif
117
118%ifndef EXCLUDE
119ALIGN DISPLAY_JUMP_ALIGN
120CgaSnow_RepMovsb:
121 call LoadCgaStatusRegisterAddressToDXifCgaPresent
122 jz SHORT .RepMovsbWithoutWaitSinceUnknownPort
123
124.MovsbNextByte:
125 cli ; Interrupt request would mess up timing
126 WAIT_UNTIL_SAFE_CGA_WRITE
127 es movsb
128 sti
129 loop .MovsbNextByte
130 ret
131.RepMovsbWithoutWaitSinceUnknownPort:
132 eSEG_STR rep, es, movsb
133 ret
134%endif
135%undef EXCLUDE
136
137
138;--------------------------------------------------------------------
139; LoadCgaStatusRegisterAddressToDXifCgaPresent
140; Parameters:
141; DS: BDA segment (zero)
142; Returns:
143; DX: CGA Status Register Address
144; ZF: Set if CGA not present
145; Cleared if CGA present
146; Corrupts registers:
147; Nothing
148;--------------------------------------------------------------------
149ALIGN DISPLAY_JUMP_ALIGN
150LoadCgaStatusRegisterAddressToDXifCgaPresent:
151 test BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_CGA
152 jz SHORT .NoCgaDetected
153 mov dx, CGA_STATUS_REGISTER
154ALIGN DISPLAY_JUMP_ALIGN, ret
155.NoCgaDetected:
156 ret
157
158
159%endif ; ELIMINATE_CGA_SNOW
Note: See TracBrowser for help on using the repository browser.