[net.micro.pc] Help with Video Retrace Code

vlv@drux1.UUCP (Vaughn Vernon) (08/02/85)

Does anyone know the assembler code to do a check on the horizontal
retrace flag for the mono and color display on the PC to prevent
fuzz?

The code I really need is pretty simple I would suppose.  I would do
all the tricky stuff in 'C' (ie: set characters, attributes and the
offset into either the mono or color diplay for the line to be displayed)

I would like to be able to call an ASM routine like so:

	screen = (color ? 0xb8000:0xb0000);	/* paragraph 0 offset */
	for(row = 0; row < 25; row++)
		disp_row(buff[row], (screen + (row * 160));

I have reasons for doing one row at a time.

The routine would first check for a horizontal retrace and then blow
(movsb ?) the buff of char,attr,char,attr ... (160 bytes) to the
address that I passed.

I wish I could write such a beast!  Can someone help?  I can probably
do the data move my self if I can just get the retrace code.

					Thanks in advance,

					Vaughn Vernon
					AT&T ISL
					Denver, CO
					ihnp4!drutx!drux1!vlv

dmt@mtgzz.UUCP (d.m.tutelman) (08/04/85)

> Does anyone know the assembler code to do a check on the horizontal
> retrace flag for the mono and color display on the PC to prevent
> fuzz?
> 
Actually, you could even do it in C, though the code examples I have
are assembler.  The important thing to know is that the status
register of the 6845 display chip includes a bit (bit 1) for horizontal
retrace status. (The 6845 is used in both the mono and color boards.)

The code that follows is adapted from the Micromint MPX-16 BIOS, but is very
similar to the BIOS code published in the IBM PC Tech Ref:

	mov	dx,video_base	; 3B4H or 3D4H
	add	dx,6		; status register
waitlow:in	al,dx		; get the status reg
	test	al,1		; horizontal retrace bit on?
	jnz	waitlow
	cli			; don't want to be interrupted here
waithi:	in	al,dx		; now wait till it goes on again
	test	al,1
	jz	waithi
;NOW you can write for a period equal to the retrace interval.

			Dave Tutelman
			Physical - AT&T Information Systems
				   Holmdel, NJ 07733
			Logical  - ...ihnp4!mtuxo!mtgzz!dmt
			Audible  - (201)-834-2895