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

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

Changes to Assembly Library:
Completely rewritten line splitting (slower but no need to modify string).
Some changes to string processing functions.
Saved few bytes from CGA detection.

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