[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
DenTut12-Pas
                   ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸
                   ³         W E L C O M E         ³
                   ³  To the VGA Trainer Program   ³ ³
                   ³              By               ³ ³
                   ³      DENTHOR of ASPHYXIA      ³ ³ ³
                   ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ; ³ ³
                     ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³
                       ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
                           --==[ PART 12 ]==--



  • Introduction
Hello!

Well, a lot has happened since the last trainer, which is the reason for the amazingly long delay. First, the elections. These were quite easy actually, I went and watched a move (Demolition Man) (Election day special, all movies R2, which is about 50 US cents), then went and voted after most voters had gone home, so no long lines . Soon after were exams. These did not go too well, and I am not looking forward to the results. Finally, I got measles and pneumonia at the same time and was sent off to hospital for a few days. All in all, not events which are conducive to coding! This has meant that the trainer has been delayed, and ASPHYXIA was not able to enter into the local democompo, Dexterity '94, which we were hoping to do well in. Oh well, onward and upward!

This trainer is on full screen scrolling in Chain-4, by request. This is actually very easy to do (and smooth), and holds a lot of potential, as I am sure you can immediately imagine.


  • What is full screen scrolling?
I seem to recall doing this in a previous tut, but here goes again! Full screen scrolling is when the entire screen moves in a particular direction, with the new picture scrolling on to the screen. Um. Think of movie credits. The screen, filled with text, is scrolled off the top of the screen while the new text is scrolled on from the bottom. This is full screen scrolling.

Full screen scrolling is not limited to movie credits. Games like Raptor have you flying over a scrolling landscape while you are down the bad guys. In this tutorial we will be doing vertical scrolling, but the code can very easily be altered for horizontal scrolling too.

Remember that we will be using Chain-4 to do our scrolling, so you may want to brush up on tut 10 in which that was covered. I will assume a brief knowledge of how chain-4 works for this tutorial.


  • The theory
The theory behind full screen scrolling in Chain-4 is acually very simple.

Picture if you will, a screen that is two monitors high. Chain-4 actually has four, but for this we only need two. Now, for this screen that is two monitors high, we can only see one monitors worth. Here it is in ASCII
    +-------------+  Screen two monitors high
    |             |
    |             |
    |             |
    |             |
    |+-----------+|
    ||           ||
    ||           ||<- This is the bit we can see, one monitors worth
    ||           ||
    |+-----------+|
    +-------------+
We can move the bit we can see up or down the enlarged screen. So, for example, if the screen two monitors high had a picture on it, we could move the bit we see up and down to try glimpse the entire picture. Think of it in this way : The screen is a large painting, but we can only see though a small magnifing glass. We can move this magnifing glass around the painting, but can never see the painting all at once.

This actually works in our favour. Anything done outside the bit we are looking through cannot be seen, so we can do our work without changing our screen.

On to scrolling. The method we will use this time is as follows :
1) Draw the next line to be seen just above and just below the part we
   can see.
      +------------+ The enlarged screen
      |            |
      |            |
      |111111111111|  The new part of the picture
      |+----------+|
      ||          || The bit we can see
      |+----------+|
      |111111111111|  The new part of the picture
      +------------+
2) Move the view up one pixel so that the new part of the picture is
   visible at the top of the screen.
3) Repeat Steps 1) and 2) until the whole screen is filled. Our screen
   will look as follows :
     +---------------+
     |+-------------+|
     ||3333333333333||
     ||2222222222222|| Viewscreen
     ||1111111111111||
     |+-------------+|
     |333333333333333|
     |222222222222222|
     |111111111111111|
     +---------------+
Check this picture with steps 1) and 2), you will see that this is
correct.
4) Set our viewport to the bottom of the enlarged screen.
     +---------------+
     |333333333333333|
     |222222222222222|
     |111111111111111|
     |+-------------+|
     ||3333333333333||
     ||2222222222222|| New position of viewscreen
     ||1111111111111||
     |+-------------+|
     +---------------+
As you can see, the bit we will be looking at is exactly the same as
before, we are now just at the bottom of the larger screen instead of
the top!
5) Jump back to 1). The entire sequence can begin again, and we can have
   infinate scrolling in the upward direction. Clever huh?



  • Our code
In the sample code, we have 21 different icons. What we do is decide what the next row of icons is going to consist of. We then draw the next line of pixels above and below the viewscreen according to what icons we are displaying. We then scroll up one pixel and begin again. When we have completed a row of icons, we randomly select a new row and begin again. Our icons are 16x16, so exactly 20 fit across a 320 pixel screen.

When we hit the top of our enlarged screen, we flip down to the bottom which looks exactly the same as the screen we have left. In this manner we have obtained smooth, infinate full screen scrolling!


  • Extra bits
As you will see from the code, it would be the work of but a few minutes to extend our landscape across the two unused screens, thereby allowing limited horizontal movement along with our vertical movement. In fact, the entire routine could easily be made to be a horizontal scrolling routine.

A map of sorts could be generated, with one byte equalling one terrain type. In this manner, the terrain scrolled over could be set, as in a flying game (Flying Shark, Raptor etc). The terrain could also easily be replaced with letters for our movie-style credits.

Free direction scrolling, ie scrolling in all directions, is a very different matter, with very different methods to get it to work. Perhaps this will be discussed in a later trainer. But for now, work with this, know it, understand it, and think up many great things to do with it! How about a full screen text scrolly? A game? Go wild!


  • In closing
Well, I hope you enjoyed this, the latest trainer. The sample program is a little short, but that is because the concept is so simple. Attached is a file, PICCS.DAT, which contains the terrain and letters for the sample program. They were .CEL's, which I loaded into the des^ variable, which I then dumped to disk, for easy access later. The .CEL's were drawn on short notice, but still produces some nice terrain.

I have recieved a few requests for future trainers, and most of them are for effects, so I guess that is what will be done from now on. A surprising number have told me not to do a sound trainer and stick with graphics stuff, with only a few asking for sound stuff, so I will hold off on that until there is more of a demand.

I am still open to suggestions for future trainers, and of course suggestions for improving the series. Leave me mail!

Hmm. A quote? Okay, let me think ....
        [    The little devil sat atop the alpine slopes, frolicking in the
           snow.  He threw a snowball at a nearby squirrel, which
           missed. The resulting avalance buried two villages and a ski
           resort.
             The little devil was scared. Avalances were bad for
           business. The locals would form team spirit, be nice to
           each other and work together and free those trapped beneath
           the snow, which created even more goodwill. The man
           downstairs didn't like goodwill. He didn't like it at
           all.
             In the blink of an eye the devil was in his penthouse
           apartment, dressed in his usual suit. He picked up the phone.
           Dialing was for mortals.
             "Hello, Micros..."
             "This is Mister Crowley", interrupted the devil.
             There were sounds of thumping on the other side of the
           phone, then there was a new voice. "Hello, Bill here, we
           haven't heard from you in a while, Mister Crowley." The fear
           of the man on the other end was almost tangible. The devil
           smiled.
             "Hello Bill. Something has come up."
             "No!" The man on the other side almost shouted with       .
           "Not Win..."
             "Yes, Bill. It is time."
             "Havn't I paid enough for my sins? Just that one night..."
           The man was almost sobbing.
             "You are touching me, Bill. But nevertheless, it is time."
             "No." The man sounded beaten, alone.
             "Yes. Bill, it is time for a new update."
                                                                       ]
                                                      - Grant Smith
                                                          14:23
                                                            23-7-94
See you next time! - Denthor

last edited (June 22, 2004) by Relman, Number of views: 1783, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.