source: xtideuniversalbios/trunk/Assembly_Library/Inc/CgaSnow.inc@ 127

Last change on this file since 127 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: 1.9 KB
RevLine 
[48]1; File name : CgaSnow.inc
2; Project name : AssemblyLibrary
3; Created date : 8.10.2010
[52]4; Last update : 11.10.2010
[48]5; Author : Tomi Tilli
6; Description : Macros for preventing CGA snow.
7%ifndef CGASNOW_INC
8%define CGASNOW_INC
9
10;--------------------------------------------------------------------
11; WAIT_RETRACE_IF_NECESSARY_THEN
12; Parameters:
13; %1: Instruction that accessed CGA memory
14; AL: Character to output
15; AH: Attribute to output (stosw only)
16; DS: BDA segment (zero)
17; ES:SI: Ptr to video memory where to read from (if %1 reads)
18; ES:DI: Ptr to video memory where to output (if %1 writes)
19; Returns:
20; SI, DI: Updated according to instruction
21; Corrupts registers:
22; AX, DX
23;--------------------------------------------------------------------
24%macro WAIT_RETRACE_IF_NECESSARY_THEN 1
25%ifdef ELIMINATE_CGA_SNOW
26 %ifidn %1, stosb
[49]27 call CgaSnow_Stosb
[48]28 %elifidn %1, stosw
[49]29 call CgaSnow_Stosw
[48]30 %elifidn %1, rep movsb
[49]31 call CgaSnow_RepMovsb
[48]32 %else
33 %error "Invalid instruction passed to WAIT_RETRACE_IF_NECESSARY_THEN"
34 %endif
35%else ; No CGA snow prevention
36 %ifidn %1, rep movsb
37 eSEG_STR rep, es, movsb
38 %else
39 %1 ; Single instruction
40 %endif
41%endif
42%endmacro
43
44
45;--------------------------------------------------------------------
46; WAIT_UNTIL_SAFE_CGA_WRITE
47; Parameters:
48; DX: CGA Status Register Address (3DAh)
49; Returns:
50; Nothing
51; Corrupts registers:
52; AL
53;--------------------------------------------------------------------
54%macro WAIT_UNTIL_SAFE_CGA_WRITE 0
55%%WaitUntilNotInRetrace:
56 in al, dx
57 shr al, 1 ; 1 = Bit 0: A 1 indicates that regen-buffer memory access can be
58 ; made without interfering with the display. (H or V retrace)
59 jc SHORT %%WaitUntilNotInRetrace
60%%WaitUntilNextRetraceStarts:
61 in al, dx
62 shr al, 1
63 jnc SHORT %%WaitUntilNextRetraceStarts
64%endmacro
65
66
67%endif ; CGASNOW_INC
Note: See TracBrowser for help on using the repository browser.