[net.micro.pc] Noise on Screen

PLOUFF%MIT-MC@sri-unix.UUCP (06/23/83)

From:  Robert L. Plouffe <PLOUFF @ MIT-MC>

In response to Darrell Plank's msg of 2 Jun 83: The method below moves
one byte at a time to video memory. You could move one word at a time,
but this seems to produce a small amount of screen noise.



                        No Noise On The Screen
      Bob Lamb - Planning Research Corporation, McLean Virginia

To eliminate the noise caused by writing to the color/graphics screen
buffer, the writing must be carefully synchronized with the horizontal
retrace interval.

Checking (and, if necessary, waiting for) the display enable bit (bit
0 = 1) of the status byte will reduce, but not totally remove, the
noise from the screen.

To synchronize properly, wait until the display is NOT ready (bit 0 =
0), then disable interrupts, THEN wait until the display is ready (bit
0 = 1).  Now write a byte or word (char and attribute) to the regen
buffer, and enable the interrupts.

My guess is that this method guarantees that you are writing at the
beginning of a horizontal retrace interval.

The following code should make the above method clearer:

	MOV	ES,B800H	;POINT TO VIDEO MEMORY SEGMENT
	MOV	DI,00H		;DESTINATION = TOP OF VIDEO MEMORY
	MOV	SI,OFFSET DATA	;     SOURCE = SOME DATA AREA
	MOV	CX,16D		;TRANSFER 8 WORDS TO VIDEO MEMORY
				; 1 WORD = 2 BYTES = CHAR + ATTRIBUTE
RETRACE:MOV	DX,3DAH 	;STATUS BYTE PORT ADDRESS
UNREADY:IN	AL,DX		;GET STATUS BYTE OF REGEN BUFFER
	TEST	AL,01H		;TEST BIT 0 (0 = NOT READY)
	JNZ	UNREADY 	;WAIT UNTIL BUFFER NOT READY
	CLI			;NEXT PART CAN'T BE INTERRUPTED
READY:	IN	AL,DX		;GET STATUS BYTE OF REGEN BUFFER
	TEST	AL,01H		;TEST BIT 0 (1 = READY)
	JZ	READY		;WAIT UNTIL BUFFER IS READY
	MOVSB			;MOVE ONE WORD TO VIDEO MEMORY
	STI			;NOW INTERRUPTS CAN BE TURNED BACK ON
	LOOP	RETRACE 	;DO FOR ALL 16 BYTES