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

Last change on this file since 183 was 162, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

  • Size optimizations, mostly by excluding code from the BIOS.
  • Cleaned the source a bit, fixed spelling and grammar mistakes.
File size: 3.4 KB
RevLine 
[48]1; Project name : Assembly Library
2; Description : Functions for preventing CGA snow.
3
4; Section containing code
5SECTION .text
6
[50]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 JUMP_ALIGN
18CgaSnow_IsCgaPresent:
19 cmp WORD [BDA.wVidPort], CGA_STATUS_REGISTER - OFFSET_TO_CGA_STATUS_REGISTER
20 jne SHORT .CgaNotFound
[52]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
[50]25 stc
26 ret
27ALIGN JUMP_ALIGN
28.CgaNotFound:
29 clc
30 ret
[48]31
[50]32
[162]33; CGA snow prevention must be kept optional to avoid unnecessary
34; overhead when building programs meant for non-CGA systems.
[48]35%ifdef ELIMINATE_CGA_SNOW
36
37;--------------------------------------------------------------------
[49]38; CgaSnow_Stosb
39; CgaSnow_Stosw
[48]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 JUMP_ALIGN
[49]51CgaSnow_Stosb:
[50]52 call LoadCgaStatusRegisterAddressToDXifCgaPresent
53 jz SHORT .StosbWithoutWaitSinceUnknownPort
[48]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 JUMP_ALIGN
[49]65CgaSnow_Stosw:
[48]66 push bx
[50]67 call LoadCgaStatusRegisterAddressToDXifCgaPresent
68 jz SHORT .StoswWithoutWaitSinceUnknownPort
[48]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
[162]76 sti
[48]77 pop bx
78 ret
79
80
81;--------------------------------------------------------------------
[49]82; CgaSnow_RepMovsb
[48]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 JUMP_ALIGN
[49]94CgaSnow_RepMovsb:
[50]95 call LoadCgaStatusRegisterAddressToDXifCgaPresent
96 jz SHORT .RepMovsbWithoutWaitSinceUnknownPort
[48]97
98.MovsbNextByte:
99 cli ; Interrupt request would mess up timing
100 WAIT_UNTIL_SAFE_CGA_WRITE
101 eSEG es
102 movsb
103 sti
104 loop .MovsbNextByte
105 ret
106.RepMovsbWithoutWaitSinceUnknownPort:
107 eSEG_STR rep, es, movsb
108 ret
109
110
111;--------------------------------------------------------------------
[50]112; LoadCgaStatusRegisterAddressToDXifCgaPresent
[48]113; Parameters:
114; DS: BDA segment (zero)
115; Returns:
116; DX: CGA Status Register Address
[50]117; ZF: Set if CGA not present
118; Cleared if CGA present
[48]119; Corrupts registers:
120; Nothing
121;--------------------------------------------------------------------
122ALIGN JUMP_ALIGN
[50]123LoadCgaStatusRegisterAddressToDXifCgaPresent:
124 test BYTE [VIDEO_BDA.displayContext+DISPLAY_CONTEXT.bFlags], FLG_CONTEXT_CGA
125 jz SHORT .NoCgaDetected
126 mov dx, CGA_STATUS_REGISTER
127ALIGN JUMP_ALIGN, ret
128.NoCgaDetected:
[48]129 ret
130
131
132%endif ; ELIMINATE_CGA_SNOW
Note: See TracBrowser for help on using the repository browser.