🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: rec.games.programmer
Article #4

Re: unfeatured vga mode..

#4
From: Cyberman
Date: Tue, 27 Oct 1992 02:35
251 lines
7472 bytes
   Cyberman was espousing about 'Re: unfeatured vga mode..',
   on [10-25-92  22:43] to All!

 Cy> It's not an unfeatured mode it is called a TWEAKED mode it
 Cy> can be also 360x200 (or 400 or 350 or 480). It is better to
 Cy> use 360x200 instead. Basically you set it 320x200x256 mode
 Cy> then change the clock to 28mhz.  Then you must modify a
 Cy> number of other registers.

    I seem to have neglected the article it's a modified version
    of the aforementioned article.

--------------------------------------------------------------------------------
From Hoke@cup.portal.com Mon Oct 30 09:52:08 1989
From: Hoke@cup.portal.com (Hoke S Johnson)
Newsgroups: comp.graphics
Subject: VGA 360x480x256 mode usage code examples
Date: 30 Oct 89 06:48:05 GMT
Organization: The Portal System (TM)

/*
Since I received a large number of requests for code examples on how
to set and use the 360x480x256 color mode on the VGA card I am posting
some Turbo Pascal Code routines and code fragments that demonstrate
the use of this mode.  I have also included a 320x400x256 color mode
set as well which is very similar to the 360x480x256 color mode.  This
code has been tried on the Compaq VGA card and on the Orchid Designer
VGA card and it works on both.  I cannot guarantee the suitability of
this code for any particular VGA card but believe that it will work
fine for all register level compatible VGA cards.  Have fun and enjoy.


The following VGA 360x480x256 mode set procedure was converted from assembly
language code which appeared in the Sept/Oct 1989 Programmer's Journal
Volume 7.5 in an article by Michael Abrash,  who received the 360x480x256
mode set code from John Bridges who has placed them in the public domain.
The conversion from assembly language to Turbo Pascal Version 5.0 was
done by Hoke Johnson.

*/

/* the aforementioned code was modified to work in Turbo C */

#include <dos.h>
#define VGAPage 0xA000          /* VGA video RAM segment address */


/* Procedure to set standard VGA card into 360x480x256 color mode */
void VGA360x480()
{
	char         Inbyte;

	_AX = 0x0013;
	geninterrupt(0x10);		/* Let the bios set up into 320x200x256 mode first */

	outportb(0x3c4, 0x04);
	outportb(0x3c5, 0x06);		/* Disable chain 4 */


/* Clear out the display memory, this did not appear in the Journal article */

	outportb(0x3c4, 0x02);
	outportb(0x3c5, 0x0F);

	memset(MK_FP(VGAPage,0), 0, 65535);

	/* The following Sync reset was included in the Programmer's Journal
	article, but I had to disable it since it causes all of my PCs to hang
	when I include it */

#if 0
	outportb($3c4,  $00);
	outportb($3c5,  $01);
#endif
	/* Sync reset */
	outportb(0x3c2, 0xE7);		/* Use the 28mHz clock */

	outportb(0x3d4, 0x11);
	Inbyte = inportb(0x3d5) & 0x7f;
	outportb(0x3d4, 0x11);
	outportb(0x3d5, Inbyte);	/* Enable the writing of CRTC Registers */

/* Write the CRTC Registers */

	outportb(0x3d4, 0x00);
	outportb(0x3d5, 0x6b);

	outportb(0x3d4, 0x01);
	outportb(0x3d5, 0x59);

	outportb(0x3d4, 0x02);
	outportb(0x3d5, 0x5a);

	outportb(0x3d4, 0x03);
	outportb(0x3d5, 0x8e);

	outportb(0x3d4, 0x04);
	outportb(0x3d5, 0x5e);

	outportb(0x3d4, 0x05);
	outportb(0x3d5, 0x8a);

	outportb(0x3d4, 0x06);
	outportb(0x3d5, 0x0d);

	outportb(0x3d4, 0x07);
	outportb(0x3d5, 0x3e);

	outportb(0x3d4, 0x09);
	outportb(0x3d5, 0x40);

	outportb(0x3d4, 0x10);
	outportb(0x3d5, 0xea);

	outportb(0x3d4, 0x12);
	outportb(0x3d5, 0xdf);

	outportb(0x3d4, 0x13);
	outportb(0x3d5, 0x2d);

	outportb(0x3d4, 0x14);
	outportb(0x3d5, 0x00);

	outportb(0x3d4, 0x15);
	outportb(0x3d5, 0xe7);

	outportb(0x3d4, 0x16);
	outportb(0x3d5, 0x06);

	outportb(0x3d4, 0x17);
	outportb(0x3d5, 0xe3);

	outportb(0x3d4, 0x11);
	outportb(0x3d5, 0xac);
}

/*

The following code fragment shows how to write an arbitrary scanline
of pixels on the screen in 360x480x256 VGA mode.  The Linenumbers are
numbered from 0 to 479 starting from the upper left.  A byte array
(Scanline) contains the pixels to be displayed.

I,J,K,L are Words or Integers
BT is a Byte

I := Linenumber * 90;  {The start of each graphic scan line is 360/4 or 90
                        memory addresses after the previous scan line.
                        Each scan line occupies 90 bytes of address space
                        and since there are four memory planes there are
                        90 X 4 bytes of memory (360) for each scan line.

                        If the upper left pixel is pixel number 0,  and
                        the lower right pixel is pixel number
                        360x480-1, an arbitrary pixel is accessed by
                        finding the VGA memory address which is the
                        pixel number shifted right 2 places relative
                        to the start of VGA memory and the memory
                        plane number is the 2 LSBs of the pixel
                        number}


  For J := 0 to DispWidth - 1 do
    Begin
      L := I + j div 4;               {Calculate VGA memory address offset}
      k := j mod 4;                   {Set K = 2 LSBs of pixel number}
      BT := $01 shl k;                {Set BT = memory plane mask code}
      Port[$3c4] := $02;              {Index Timing Sequencer register 2}
      Port[$3c5] := BT;               {Write memory plane select mask}
      Mem[VGAPage:L] := ScanLine[j];  {Write pixel}
    End;

The following routine sets the standard VGA into 320x400x256 mode, which
is very similar to the 360x480x256 mode.  Writing to the screen in
320x400x256 is the same as 360x480x256 mode, the only difference is
the address span of each scan line which is 80 rather than 90.

*/


void VGA320x400()
{
	char         Inbyte;

	_AX = 0x0013;
	geninterrupt(0x10);

	outportb(0x3c4, 0x04);
	outportb(0x3c5, 0x06);		/* Disable chain 4 */

	outportb(0x3c4, 0x02);
	outportb(0x3c5, 0x0F);

	memset(MK_FP(VGAPage,0), 0, 65535);

	outportb(0x3c2, 0xE3);		/* Set the 25mHz clock */

	outportb(0x3d4, 0x11);
	Inbyte = inportb(0x3d5) & 0x7f;
	outportb(0x3d4, 0x11);
	outportb(0x3d5, Inbyte);	/* Enable the writing of CRTC Registers */

	outportb(0x3d4, 0x09);
	outportb(0x3d5, 0x40);

	outportb(0x3d4, 0x14);
	outportb(0x3d5, 0x00);

	outportb(0x3d4, 0x17);
	outportb(0x3d5, 0xe3);
}

void
testpat(int x,int y)
{
	int i,j;
	int k;
	char far *cp;

	outportb(0x3c4, 2);
	for (j = 0; j < y; j++) {
		k = j * (x >> 2);
		for (i = 0; i < x; i++) {
			outportb(0x3c5, 1 << (i & 3));
			cp = MK_FP(VGAPage,k + (i >> 2));
			*cp = (i + j);
		}
	}
}


main()
{
	VGA320x400();
	testpat(320,400);
	getch();
	VGA360x480();
	testpat(360,480);
	getch();
	_AX = 0x0003;
	geninterrupt(0x10);
}
--------------------------------------------------------------------------------

                Stephen Cyberman@Toz.Buffalo.NY.US
             Mangled on Mon  10-26-1992  at 13:04:34

... It's a header file AND the only documentation!
--- Blue Wave/QWK v2.10
                
Technical Details
Message-ID: <gate.5P80sB1w165w@toz.buffalo.ny.us>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!ub!toz!cyberman

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!zaphod.mps.ohio-state.edu!ub!toz!cyberman
From: cyberman@toz.buffalo.ny.us (Cyberman)
Newsgroups: rec.games.programmer
Subject: Re: unfeatured vga mode..
Message-ID: <gate.5P80sB1w165w@toz.buffalo.ny.us>
Date: 27 Oct 92 02:35:39 GMT
Lines: 251
X-Maildoor: WaflineMail 1.00r