Board index » delphi » Four ways scrolling on VGA / SVGA

Four ways scrolling on VGA / SVGA

I have a big problem, how can i scroll Sideways and Down/Up???
In text mode this is easy, but how can I do this on VGA or SVGA???

Please send a E-mail to: Henrik Stokseth on this E-Mail address:

s...@sn.no

Thanks for any information that will help me...
-----------------------------------------------------------------------

 

Re:Four ways scrolling on VGA / SVGA


Quote
Frode Stokseth wrote:

> I have a big problem, how can i scroll Sideways and Down/Up???
> In text mode this is easy, but how can I do this on VGA or SVGA???

> Please send a E-mail to: Henrik Stokseth on this E-Mail address:

> s...@sn.no

> Thanks for any information that will help me...
> -----------------------------------------------------------------------

The best and fastest way of doing this in VGA is probably by using
modeX. If you don't know how, go to http://x2ftp.oulu.fi/pub/msdos/programming
and look for something like xlib*.* or modex*.*. You can also read
"Asphyxia's vga trainers", which will explain modeX very good.

I don't have the address at the moment, but go to a searchrobot and write "asphyxia" and
you'll soon find it. E-mail me otherwise.

// Tobias

Re:Four ways scrolling on VGA / SVGA


Quote
> I have a big problem, how can i scroll Sideways and Down/Up???
> In text mode this is easy, but how can I do this on VGA or SVGA???

> Please send a E-mail to: Henrik Stokseth on this E-Mail address:

> s...@sn.no

I dont; know any trick built into pascal for doing this, but the basic
algorithm is to store the location for everything as an offset from some
anchor (which should be the the thing you are scrolling around). THen
draw everythign realtive to that anchor. This way when the anchor moves
evrythign scrolls.
Don't forget to clip off screen objects though!
Amir

P.s. modeX is just a low-res graphics mode with built in page flipping,
there is nothing in it that will make  scrolling any easier than any
other graphics mode.

Re:Four ways scrolling on VGA / SVGA


In article <4uahl5$...@cocoa.brown.edu>,
Amir Lopatin  <Amir_Lopa...@Brown.EDU> wrote:

Quote
>P.s. modeX is just a low-res graphics mode with built in page flipping,
>there is nothing in it that will make  scrolling any easier than any
>other graphics mode.

You are *so* wrong.

Mode X (and its variant, Mode Y) is the slang term given by Michael
Abrash to the two most common unchained 256-color VGA video modes
used in demos.  "Unchained" comes from the method of "unchaining"
the video memory in order to access it all--normal mode 13 (320x200x256
colors) is "chained".  Mode X is 320x240 and Mode Y is 320x200.

Unchaining the video memory has a slight disadvantage:  The memory
organization is different, and is harder to program for (it is
organized in "planes of bytes", which is harder to work with than
the standard linear format of normal mode 13).  However, the
advantages are numerous; when you unchain video memory, you get:

        - More video modes on a standard VGA, from 320x240 (square
        aspect ratio) to 360x480 (high res with 256 colors on any
        monitor) and others

        - The ability to pan across all of video memory, as if it
        were a big virtual page

        - Horizontal split screen, with the lower half not affected
        by the panning of the upper half

        - 2 or more video pages (by "panning" to an area of video
        memory one screen length down)

        - The ability to write up to four pixels at once with just
        one write (great for polygon filling)

In the "old days" of IBM PC demos, Mode X programming was the only
way to get any speed out of the slow ISA bus and slow video cards
of the time.  Nowadays, normal mode 13 is making a comeback because
of two things:

        - Texture mapping, "Phong" shading, and other modern effects
        are faster to do in normal mode 13 than in Mode X

        - Local-bus video cards (VLB and PCI) can move video memory
        much faster than before, and are becoming quite common.

When you unchain, you are given access to all 256k of VGA RAM.
Unfortunately, only 64k is addressable by A000:0-A000:FFFF.

The VGA then utilizes the plane method of color selection. Due to
some weird hardware "features", instead of one bit in each plane
controlling each pixel's color, one byte in one plane controls the
color of a pixel.

This is arranged according to the following formula:
if Mode13h_offset = y*320 + x,
then ModeX_offset=Mode13h_offset / 4,
and ModeX_plane=Mode13h_offset % 4.

So, (0,0) would be at plane 0, offset 0.
(1,0) would be at plane 1, offset 0.
(2,0) would be at plane 2, offset 0.
(3,0) would be at plane 3, offset 0.
(4,0) would be at plane 0, offset 1.
(5,0) would be at plane 1, offset 1.
(6,0) would be at plane 2, offset 1.
(7,0) would be at plane 3, offset 1.
(8,0) would be at plane 0, offset 2.
(0,1) would be at plane 0, offset 80.

Pascal and C libraries for programming ModeX are at
ftp://x2ftp.oulu.fi/pub/msdos/programming under all the "xlib"
directories.  

      X-Mode Frequently Asked Questions - By Zoombapup (Phil)  12-Sept-94
      ======================================================================

      Foreword
      --------

      Hmm, whats new this time??

      Well, I am off the net for a coupla weeks, which is kinda hard :)
      dont forget x2ftp.oulu.fi is now a good programmers site, if a
      little slow sometimes, in /pub/msdos/programming you can find
      all sorts.

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

      1) What is this FAQ and why should I read it??
      2) What IS mode X?
      3) How do you set mode-x?  (asm source)
      4) Source code reference list
          a) Information Sources
          b) Books & Other sources
          c) Source Code etc...
      5) Simple Questions and answers (read it ok??)
      6) 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, It 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 - How to set up mode x
      --------------------------------

        Here's  the code needed to set up a tweaked 320*200*256-mode.
        It  was  in  a  text  file  by  some  unknown finnish author,
        It was translated by Saint/EMF (thanks Jani).

---------------------------------------------------------------
1. Set the BIOS mode 13h, which is the standard 256-color mode.

        mov     ax, 0013h
        int     10h

2. Put the CHAIN4-mode of Sequencer off

        mov     dx, 03C4h
        mov     ax, 0604h
        out     dx, ax

3. Clear the video memory (setting mode 13h clears only every fourth byte
                           from each plane)

        mov     ax, 0F02h
        out     dx, ax
        mov     dx, 0A000h
        mov     es, dx
        xor     di, di
        xor     ax, ax
        mov     cx, 8000h
        rep     stosw

Note: Parts 4 and 5 may need switching round, i.e. do part 5 first, then
part 4... but it works anyway....

4. Turn off the CRTC's LONG-mode

        mov     dx, 03D4h
        mov     ax, 0014h
        out     dx, ax

5. Turn on the CRTC's BYTE-mode

        mov     ax, 0E317h
        out     dx, ax

   And now you are in tweaked mode!
   If you want also double the vertical resolution to 320*400*256,
   add this:

        mov     ax, 4009h
        out     dx, ax
---------------------------------------------------------------

        The last out is needed if you want to double the Y-resolution
        to 400 lines,  so that  each scanline  has its  own  line  in
        memory.  The bits 0-4 in  the  CTRC register 09h  define  the
        number of  times  to display  the scanline minus one.  To get
        back to  200-line mode,  out 4109h there,  or if  you  want a
        100-line  mode,  out 4309h.  The same thing can be applied to
        the Mode X to get 480- or 120-line modes.

      Many Thanks to jani for this, I've only just decided to include
      it in the faq (I had it for months, but I didnt want to confuse
      beginners by supplying source like this, but WTH) -- Phil.

      Section 4 - 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: simtel archives... usually
      Directory : I forgot to write it... should be /VGA will be confirmed.
      Author   : Robert Shmidt (Ztiff Zox??)

      Simtel Stuff can be gotten from oak.oakland.edu

      Description:

      XDiscuss (now called Xintro :)) is a really good description of
      How modeX works, how the memory is
...

read more »

Other Threads