From: niemann@rubdv15.ETDV.ruhr-uni-bochum.de
Guillaume,

  Yup, you can run that darn diamond S3 chipset...in spite of the
whacky Diamond people (...fight the power!... :).  I am running linux
on a 486DX50 with 8 Meg RAM, Diamond Stealth 24 VLB (S3 805 chipset)
with 1 Meg of memory, and a MAG MX15F monitor (it is capable of some
sort of auto-syncing).  I am using a 3-button serial mouse.

bcr> Guillaume reported this file works as is with his Diamond Stealth
bcr> Hicolor...

Here is what I am doing:

  First be sure you have swap file or partition setup.  I actually
tried for quite a while to get X working BEFORE I setup a swap file.
If you can run mono mode, which you should no matter what, then you
probably have your swap working.

  My server is  XS3-0.4.4, installed in /usr/X386/bin  AND
with a symbolic link to X.  That is I performed a
    ln -s XS3-0.4.4 X    .
A listing on my /usr/X386/bin gives the following for X* 

lrwxrwxrwx   1 root     root            9 May 26 19:41 X -> XS3-0.4.4*
-rwsr-xr-x   1 root     wheel      914436 Feb 11 19:42 X386*
-rwsr-xr-x   1 root     wheel      914436 Feb 11 19:42 X386mono*
-rwxr-xr-x   1 root     root         9220 Apr 10 23:46 XConsole*
-rwsr-xr-x   1 root     root       840708 May 26 19:40 XS3-0.4.4*

Notice the modes, these are setup as servers. It might be that this is
an older XS3, I have not checked recently.

   The routine I use to program my third clock on the S3 805 chipset
is `s3'.  It is available in the tar file  stealth-fix.tar  either on
sunsite.unc.edu  or tsx-11.mit.edu  or your own local favorite linux
site, I bet.  I tried the `freq' available in diamond.tar, but I did
not have any luck with it.  That was also when I was pretty inexperienced;
I might be able to get it to work now.  I suggest trying the s3 program
at first.

   Below, in the script I use to launch X-windows, I show the options
I use.  The README for s3 is also helpful, though brief.

   Below I include my very short do_x script and my Xconfig file.
=====================below is do_x which I keep in /usr/bin===========
/usr/local/s3/s3 5 9
startx 2> /xerr.log ; sync ; sync

   Some comments about my Xconfig: You will certainly want to check
the type of mouse you are using.  Also, notice that I define both the
left and right ALT keys as META keys for emacs.  Most of the file is
commented out, it is useful to see what other options people have
used.  Also, I only have two color modes defined 640x480 and 1024x768.
Use CTL-ALT-+ (on the keypad) to switch from one to the other.
I routinely run in 1024x768 without trouble (a little eye strain...I want
one of those 19 inch monitors :).

   With all this in place, you should log on as root and do a do_x and
you should get an okay looking 640x480 mode.  If the screen is blurred,
and fuzzy, try doing a couple CTL-ALT-+ to cycle the modes.  My monitor
is capable of some sort of auto-syncing and changing modes seems to 
encourage this.  If not, try a different frequency...which might mean using
a different program from s3 (the readme only mentions two options for it,
though probably there are more).

  Well, I was pretty long-winded.  Let me know how it goes.  Also, I
recommend installing xv-3.00 and viewing some cute gif files.  It
really shows off the color X-windows.  Also, for your modem check out
seyon.  And for a X-window server from a machine a work or school to 
pop up windows on your home machine check out term.  Hope some of this helps.  
              Bonne chance, bill e.g.

   Now for my Xconfig:

---> Cut here <--- : Xconfig
# $Header: /home/x_cvs/mit/server/ddx/x386/Xconfig.cpp,v 1.8 1993/01/24 03:47:46 dawes Exp $
# $XConsortium: Xconfig,v 1.2 91/08/26 14:34:55 gildea Exp $
#
# Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of Thomas Roell not be used in
# advertising or publicity pertaining to distribution of the software without
# specific, written prior permission.  Thomas Roell makes no representations
# about the suitability of this software for any purpose.  It is provided
# "as is" without express or implied warranty.
#
# THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
# EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
# Author:  Thomas Roell, roell@informatik.tu-muenchen.de
#
# Extensive modifications by the XFree86 Core Team

#
# ** Refer to the X386 man page for details about the format of this file **
# ** The X386 man page is installed as /usr/X386/man/man1/X386.1x **
#

#
# some nice paths, to avoid conflicts with other X-servers
#
RGBPath		"/usr/X386/lib/X11/rgb"

#
# Multiple FontPath entries are allowed (which are concatenated together),
# as well as specifying multiple comma-separated entries in one FontPath
# command (or a combination of both methods)
#
FontPath	"/usr/X386/lib/X11/fonts/misc/"
FontPath	"/usr/X386/lib/X11/fonts/Type1/"
FontPath	"/usr/X386/lib/X11/fonts/Speedo/"
FontPath	"/usr/X386/lib/X11/fonts/75dpi/"
# FontPath	"/usr/X386/lib/X11/fonts/100dpi/"

#
# Uncomment this to cause a core dump at the spot where a signal is 
# received.  This may leave the console in an unusable state, but may
# provide a better stack trace in the core dump to aid in debugging
#
 NoTrapSignals

#
# Keyboard and various keyboard-related parameters
#
Keyboard
  AutoRepeat 500 5
  ServerNumLock
#  Xleds      1 2 3
#  DontZap
#
# To set the LeftAlt to Meta, RightAlt key to ModeShift, 
# RightCtl key to Compose, and ScrollLock key to ModeLock:
# 
  LeftAlt     Meta
  RightAlt    ModeShift
  RightCtl    Compose
  ScrollLock  ModeLock

#
# Mouse definition and related parameters
#
BusMouse	"/dev/bmousems"
#Microsoft	"/dev/ttyS1"
  BaudRate	1200
  Emulate3Buttons

#
# The graphics drivers
#

vga256
  Virtual	1024 768
  ViewPort      0 0
  Modes 	"1024x768" "640x480"
  Clocks	25 28 80

ModeDB
# OFFICIAL VESA Monitor timings + IBM Standards - TRY THESE FIRST
# Contributor:          Thomas Roell [roell@sgcs.com]
# Last Edit Date:       3/29/92
#
# name        clock   horizontal timing     vertical timing      flags
"640x480"     25     640 672 768 800 480 490 492 509
"1024x768"    80     1024 1064 1088 1344      768  770  781  798
---> Cut here <--- : Makefile
# Makefile for modify

CC=		cc
CFLAGS=		-O6 -Wall -Wstrict-prototypes
OBJ=		stealth.o

all: $(OBJ)
	$(CC) $(CFLAGS) -s -o stealth $(OBJ)

stealth.o: stealth.c
	$(CC) $(CFLAGS) -c stealth.c

clean:
	rm -f *.o core stealth
---> Cut here <--- : stealth.c
/*
   stealth - this program modifies the file setup.S in your
   linux/boot subdirectory. The old file is saved as setup.S~.

   (C) 1993 Christoph Niemann

   This program was derived from another, more complex program
   i have written some time ago. Because of this it surely contains
   a lot of silly things.

   Do what you like with this program, but don't remove this message :-)

   Send comments to: niemann@rubdv15.etdv.ruhr-uni-bochum.de
*/



#include <stdio.h>
#include <string.h>

#define SETUP	 "/boot/setup.S"
#define LINUX	 "/linux"
#define BAK	 "~"
#define FALSE	 0
#define TRUE	 1
#define MAX_NUMBER 4
#define MAX_STRING 255
#define MAKE_TYPE 1

/* This IS the patch... */
char inserts[MAX_NUMBER][MAX_STRING] = { "je\tnovga",
	"\tmov\tax,#0x4f02\n\tmov\tbx,#0x205\n\tint\t0x10\n\tmov\tax,#0x4f02\n\tmov\tbx,#0x03\n\tint\t0x10\n",
	"je\tnovga",
	"\tmov\tax,#0x4f02\n\tmov\tbx,#0x203\n\tint\t0x10\n\tmov\tax,#0x4f02\n\tmov\tbx,#0x03\n\tint\t0x10\n"
	 };

void help( char *PName )
{
  puts("This program modifies linux's setup.S file to allow programming");
  puts("the 3rd oscillator of DIAMOND video cards. It currently supports");
  puts("all cards that are VESA-compatible, as the DIAMOND STEALTH series");
  puts("You can give two parameters: The directory of your linux sources");
  puts("and the video-mode you prefer.");
  puts("Possible values for the video-mode: 800 for 800x600 and 1024 for");
  puts("1024x768");
  printf("Usage: %s [linux-basedir] [ 800 | 1024 ]\n", PName);
  printf("Default: %s /linux 1024\n", PName);
  exit(-1);
}

char *read_line( char* string )
{
  char   *start;
  char   new[MAX_STRING];
  char	 *c;
  start = string;
  new[0] = '\0';
  while ( *start == ' ' || *start == '\t' ) start++;
  strcpy( new, start );
  c = &new[0];
  while (*c != '\0')
    if (*c == '!' ) *c = '\0'; else c++;
  if (new[strlen(new) - 1] == '\n') 
    new[strlen(new) - 1] = '\0';
  return &new[0];
}

void main( int argc, char *argv[] )
{
  char setup_name[MAX_STRING];
  char setup_name_bak[MAX_STRING];
  char string[MAX_STRING];
  char *new;
  FILE *setup_file = NULL;
  FILE *setup_file_new = NULL;
  int  patched = FALSE;
  int  number = 0;
  int  i;
  int  flag = 0;

  if (argc > 3) help( argv[0] );

  if (strcmp(argv[1], "?") == 0 || strcmp(argv[1], "-?") == 0)
    help(argv[0]);
  else
    printf("Type %s ? for help\n", argv[0]);

  strcpy(setup_name, LINUX );

  for (i = 1; i < argc; i++)
  {
    if (strcmp(argv[i], "1024") == 0)
      number = 0;
    else if (strcmp(argv[i], "800") == 0)
      number = 2;
    else if (flag == 0)
      strcpy(setup_name, argv[i]);
    else
      help(argv[0]);
  }

  strcat(setup_name, SETUP );

  printf("Patching %s to enable %s videomode\n",
	setup_name, number ? "800x600" : "1024*768");

  strcpy(setup_name_bak, setup_name);
  strcat(setup_name_bak, BAK);

  if ( rename(setup_name, setup_name_bak) < 0 )
  {
    perror("Rename: ");
    exit(-1);
  }

  if (!(setup_file = fopen(setup_name_bak, "r"))) 
  {
    perror("Cannot make backups");
    exit(-1);
  }

  if (!(setup_file_new = fopen(setup_name, "w"))) 
  {
    perror("Cannot create the new files");
    exit(-1);
  }

  flag = 0;

  while (!feof(setup_file))
  {
    fgets(string, MAX_STRING, setup_file);
    if ( patched )
    {
      patched = FALSE;
      if ( strncmp( string, inserts[number + 1],
		strcspn(inserts[number + 1], "\n") + 1 ) == 0 )
      {
	printf("The patch is already applied.\n");
	fclose(setup_file_new);
	fclose(setup_file);
	rename(setup_name_bak, setup_name);
	exit(-1);
      }
    }
    fputs( string, setup_file_new );
    new = read_line(string);
    if ( flag == 0 && strlen(new) >= strlen(inserts[number]) &&
         strncmp(inserts[number], new, strlen(inserts[number])) == 0)
    {
      fputs(inserts[number + 1], setup_file_new);
      flag = 1;
      patched = TRUE;
    }
  } /* setup.S processed */

  if (flag == 0)
    puts("Sorry, patch could not be applied.\n"
	"This program should work with linux <= 0.99-10");
  fclose(setup_file);
  fclose(setup_file_new);
}


