
      X-Mode Frequently Asked Questions - By PC-93 (Phil) Rev 0.1g 29-Dec-93
      ======================================================================

      Foreword
      --------

      Seems like not much has happened as far as files go this week,
      everyone must be taking a rest over the holidays, again, its
      been hard to get on the usual demo sites, Ive been really
      quite impressed with wasp.eng.ufl.edu though, at least you
      can get on there, unfortunately, I have to pay for access, but
      with ftp.uwp.edu and wuarchive.wustl.edu being somewhat full
      I can recommend looking on wasp for most new releases...


      Table of Contents
      -----------------

      1) What is this FAQ and why should I read it??
      2) What IS mode X?
      3) Source code reference list
          a) Information Sources
          b) Books & Other sources
          c) Source Code etc...

      4) Simple Questions and answers (read it ok??)
      5) Further helpful reading  (Not necassarily Mode-X)


      Section 1 - What is this FAQ and why should I read it??
      -------------------------------------------------------

      This FAQ (Frequently asked questions file) is here to provide the
      reader with a brief outline of what Mode-X is and to provide some
      useful references for looking into it further. It is also an
      attemp by me to help cut down the posts on Comp.sys.ibm.pc.demos
      asking for information on Mode-X programming when that very same
      information is posted weekly (or seems like it).

        It is also a chance for the reader to find reference material
      that may take ages searching to do something specific in Xmode.

      If youre really desperate to find something, then maybe its a
      chance to learn how to use archie?? try telnetting to
      archie.doc.ic.ac.uk (or one closer to you), login as archie
      then try typing prog <filename> to search for a particular file
      (and dont forget to note the result!).


      Section 2 - What IS mode-X??
      ----------------------------

      Well, I has been mentioned that perhaps I should make it clear what
      is meant by Mode-X, well, it can really mean two things, the first is
      that it means a mode originally written about by Mike Abrash in Dr Dobbs
      journal (a US programmers magazine), it basically involved tweaking
      (reprogramming) some of the registers on the VGA display adaptor,
      in effect it gave a resolution of 320x240 with 3 pages for graphics,
      and he christened it Mode-X (because there was no bios mode for it).
      After this article it became easier for everyone to write the same
      type of things, using different resolutions, e.g. 320x200x4page etc..
      the problem was, what would one call these modes?? as there are just
      about unlimited combinations, I think it would be better to refer to
      ALL tweaked VGA modes as Mode-X, and as far as I am concerned that
      is what mode-x means......

      Anyway, back to the text:-

      Over to Themie Gouthias for that one..... (original author of Xlib)

      Mode X is a derrivative of the VGA's standard mode 13h
      (320x200 256 color). It is a (family) of undocumented video modes
      that are created by tweaking the VGA's registers. The beauty of mode X
      is that it offers several benefits to the programmer:

      - Multiple graphics pages where mode 13h doesn't allowing for page
        flipping (also known as double buffering) and storage of images
        and data in offscreen video memory

      - A planar video ram organization which although more difficult
        to program, allows the VGA's plane-oriented hardware to be used
        to process pixels in parallel, improving performance by up to
        4 times over mode 13h

      - Loads of other neat tricks associated with having multiple pages
        of video memory to program with, and also smoother animations
        (PC Note that one :) )

      Please note BEFORE you go flooding Themie with email about Xlib
      questions that he has taken a break from supporting it himself
      for a while and has left two other people in charge. (see ref)


      Section 3 - Source Code reference list
      --------------------------------------

      Alright, this is probably THE most important part, in that this
      is where you'll find all the source code and information you'll
      ever need to program proficiently in mode-x, so if you EVER
      post a question about HOW TO PROGRAM MODE-X after reading this
      list and getting the source etc, then YOU WILL BE SHOT AT DAWN :)

      a) Information Sources
      ----------------------
      These sources are good for mode-x stuff..

      Filename : xintro18.zip  Where: wuarchive.wustl.edu in directory
                                     pub/MSDOS_UPLOADS/programming

      Author   : Robert Shmidt (Ztiff Zox??)

      Description:

      XDiscuss (now called Xintro :)) is a really good description of
      How modeX works, how the memory is organised in planar fashion,
      it includes a few graphics pictures to help visualise the memory
      organisation, really a must have to understand the mode.

      ----------------

      Filename : Graphprg.lzh Where: ftp.uwp.edu in pub/msdos/demo/source TBC
      Author   : Michael Abrash (Mode X guru)

      Description:

      This file is a collection of texts and sample source code to loads of
      graphics programming problems, mike was the first person to really
      describe Mode-X in a magazine (Dr Dobbs Journal), in this file he
      goes through a number of interesting routines etc, he also sets up
      a simple 3D polygon filling, lightsourced program called X-Sharp,
      all-in-all this file is A MUST HAVE!
      ---------------------

      Filename : Tweakxxx.zip  Where : same place as xintro above
      Author: Robert Shmidt (again!)

      Description:

      Tweak is a utility that lets you mess around with the registers on
      youre VGA card, which is a real help when trying to come up with
      youre own Xmode, it enables you to test settings on the CRTC regs
      and play with loads of settings.
      ----------------------

      Filename : Unchain.zip Where : TBC
      Author: Colin Buckley  (with correct tabs, honest :) )

      Description:

      Unchain is a utility to help people using turbo debugger to debug
      mode-x programs (because they screw TD's display up usually),
      it allows viewing of the pages in vid ram etc....

      UPDATE: Unchain also works with BC,BP and loads of other products..
      ------------------------


      b) Books & Other Sources
      ------------------------

      Nothing I know of in this category as yet, some non-specific
      graphics books are recommended in a FAQ in rec.games.programmer
      I suggest anyone interested in graphics programming read that
      newsgroup (or at the very least get the FAQ, I think its on
      ftp.uwp.edu - but I'll confirm this)

      NOTE: For those of you without a VGA reference for the registers
            the r.g.p FAQ has loads of them in, so look out for it!!

      Also you can READ comp.sys.ibm.pc.demos for a while, and you
      will usually pick up any info you need to do something that
      you cant get from the files below, only if you have read the
      newsgroup for a while and have not seen what you need posted
      should you post a question, PLEASE DON'T TIE UP THE GROUP
      especially with questions that have been answered over and
      over again....

      c) Source Code
      --------------

      Most of the files in this next section can be found on either
      ftp.uwp.edu, wuarchive.wustl.edu, or nic.funet.fi
      I will put the exact directories where I'm sure about them
      but in general most stuff on wuarchive can be found in the
      /pub/MSDOS_UPLOADS/programming directory. most on ftp.uwp.edu
      in the pub/msdos/programming directory. (I'm not sure about
      nic.funet.fi as I cant use it, the most important thing about
      these places is that you have to explore them, dont just say
      that you cant find something just because it isnt in the root
      directory, EXPLORE, usually things are in the /pub directory
      and most often in msdos (or similar) and programming.....

      Addition: Also you might try looking around on wasp.eng.ufl.edu
                (I forgot that one last time), but I dont use it unless
                someone posts something new there.
      ---------------

      Filename: Xlib06.zip  Where: wuarchive.wustl.edu
      directory: /pub/MSDOS_UPLOADS/programming
      Author: Many contributors, originally by themie gouthias..

      Decription:

      This really is THE source code to get to be able to use Xmode.
      the archive contains mainly C linkable assembler code that
      covers pretty much everything possible with Mode-X, all the
      code is copyright public domain, and is usually pretty fast.
      In the archive there are also demo programs to show what is
      possible and some useful doc's and further references.

      ALSO: Note that there are 2 new re-workings of Xlib in pascal
            called Xlib_tp5.zip and Xlibpas.zip available for pascal
            coders available on the net (ftp etc...)

      NOTE: If you have problems with the unit in Xlibpas not working
            be sure to set the compiler switches {$G+} and {$X+} which
            enable 286 code and extended syntax, then everything
            should run allright.

      ------------

      Filename: stmik020.lzh   Where: TBC (to be confirmed)
      directory: at a guess try ftp.uwp.edu somewhere...
      Author: Future Crew

      Description:

      This archive is FC's release of the screamtracker music interface
      kit (basically a mod player that you can use in youre demo's),
      whats interesting about it is that they have included the whole
      of thier MENTAL SURGERY demo, which has them setting a Mode-X
      variant, and also I believe setting up a VBI int... good to see
      how a well known (who am I kidding) group does things like
      the usualy horizontal stars....  All code in assembler.

      ------------

      Filename: vlafont.zip  Where: TBC (ftp again I think)
      directory: at a guess try ftp.uwp.edu somewhere...
      Author: Draeden (of VLA)

      Description:

      This archive contains all the code and tools to incorporate a
      scrolly mode-X font routine, has sample code (including Y scale)
      and has a good re-working of Mode-X set code from Xlib, all code
      in assembler...

      Note: Generally try to get anything with VLA in the title,
            Draeden has released a load of code, and although he's made
            himself scarce for a while, the rest of VLA can be mailed,
            also he has done IMHO the best ModeX setting code for asm
            programmers...

      ------------

      Filename: mx2_vla.zip Where: TBC

      Author: Draeden (of VLA)

      This is THE best working of Mode-X set code I've seen, really an update
      on the routines found in vlafont.zip, Its really a must have for asm
      programmers (especially tasm users), it provides loads of useful routines
      like mode setting (really flexible) and palette and other stuff like that.

      More stuff about VLA releases next time.


      Section 4 - Simple questions and answers
      ----------------------------------------

      1q) Is it possible to reset mode-x so that the addressing is linear
         like good old 13h but with the 4 pages still??

      1a) No, to the best of available knowledge no its not....

      Note: Just to update this, there has been some discussion carried on
            and it seems that it IS possible on a very few VGA cards, but
            its so rare that it is practically useless, unless someone
            can get it to work on ALL vga cards

      2q) Is it possible to set up my own mode, in some way??

      2a) Yes, but it is quite a tricky process, a utility to help you
          try tweaking the registers for this sort of thing is in
          the file section 3a) Information sources (tweak by Rob shmidt?)

      3q) I have a (insert a crappy vid card name) VGA card, with 4meg memory
          can I still use ModeX?

      3a) Yeah, basically ANY card 100% ibm (tm) VGA compatible can do it..
          and why have you got 4 meg?? :)

      4q) I want to be able to double buffer using a VBL is there one on the
          VGA and how do I use it??

      4a) There isn't a built in VBL on the vga, but you CAN set one up by
          re-synch-ing one of the timers (08h usually), there is an example
          in the newer Xlib (ver 06).

      5q) I want to do a font routine in 320x200x256x4 mode x, and I cant
          get hold of any fonts, the ones Ive got are scanned left to right
          top to bottom, and they make for a hard font routine, is there
          any fonts that I can use in a different format?

      5a) Yes, you can get two utilities for fonts that are perfect for
          mode-x formats, one is in VLAFONT, mentioned elsewhere in the FAQ
          and another is in PCXTOOLS (which is also mentioned elsewhere), if
          you get either one, they hold the font data scanned from top to
          bottom, left to right (i.e. columnwise) which makes drawing them in
          mode-x much faster (dont need to keep setting the plane), also
          this layout lets you do things like move the start of the column
          in a sine wave (for a sin scroller) and other effects..


      Section 4 - Further Helpful reading
      -----------------------------------

      Not much in this section yet, I will expand it over the next few
      months....

      Newsgroups!! pretty simple really, read the graphics newsgroups,
                   rec.games.programmer has some useful info on occasion
                   alt.graphics, comp.graphics (I think), so get a list
                   of newsgroups and take em all!! :) well, a few...

      Note: NEVER just go straight to a newsgroup you've never read before
            and post loads of questions, read it for about a month or so
            this gives you a chance to see what the group is about, and
            also to see if there's a faq posted, usually FAQ's are posted
            at least once a month...

      Reference Books
      ---------------

      EGA/VGA a programmers reference guide by Bradley Dyck Kliewer
      ISBN: 0-07-035099-X

      Description:

      Pretty clear VGA technical reference manual, I prefer it to ferraro's
      (which I will post details on next time), it has all the info you need
      on all the vga's registers, very clearly explained, probably THE best
      vga reference for clarity, although perhaps not as exhaustive on the
      svga than other ref's.

      I'd say that this book is really an essential to all those who havent
      got a VGA reference... (my personal opinion)
      ---------------

      Introduction to Algorithms - by Thomas H Cormen
      ISBN: 0-262-03141-8  published by Mit press and McGraw Hill..

      Description:

      A radically good book, covers pretty much ALL the algorithms needed
      in programming, although the title says introduction, it is not just
      an introductory level text, but covers a wide range of levels, it has
      timings, examples, discussion, and information to a mathematical level.

      IMHO this book is another must have, at least read it once, I think
      that it pays to have this book as a standard reference, really highly
      recommended....
      ---------------

      Also It might be a good idea to get back issues of Dr Dobbs journal
      with the articles Michael Abrash wrote about Mode-X in, as you really
      need the pictures to appreciate his stuff.

      Footnote: Apparently Mike is now working for Microsoft, poor man, what
                a cruel twist of fate, that a man so into getting code to
                run as fast as possible should have to work for them!!

      Other magazine's, especially programmer based ones, PC Techniques have
      had some articles, and also game designer magazine, although these
      seem to have been deleted (they are magazine's on disk), try archie
      for GMD*.* GDM1.ARJ and GDM2.ARJ I know about, but they are a little
      too simple for my taste, may be helpful to newer games programmers.

      -=END OF FAQ=-

      Written 29th December 1993 (yeah I know, but I was bored! by PC (Phil))
      please ask permission before re-printing somewhere else.....
  
