2 ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͸
\r
4 ³ To the VGA Trainer Program ³ ³
\r
6 ³ DENTHOR of ASPHYXIA ³ ³ ³
\r
7 ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ; ³ ³
\r
8 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³
\r
9 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
\r
17 Hello! This is Denthor here with the 5 part of the ASPHYXIA VGA Trainer
\r
18 Series : The Scrolling Saga. I have had many requests for information on
\r
19 scrolling, so I decided to make it this weeks topic. Note that I do make
\r
20 reference to my recently released program TEXTER5, which should be available
\r
21 from wherever you get this message. (Note to Sysops : If you put the trainer
\r
22 series up on your boards, please add WORMIE.ZIP and TEXTER5.ZIP as they
\r
23 both suppliment this series)
\r
25 By the way, sorry for the delay in the appearance of this part. Tests,
\r
26 projects and a few wild days of sin at the Wild Coast all conspired
\r
27 against the prompt appearance of this part. Also note I need more input as
\r
28 to what I should do future parts on, so leave me mail.
\r
30 If you would like to contact me, or the team, there are many ways you
\r
31 can do it : 1) Write a message to Grant Smith in private mail here on
\r
33 2) Write a message here in the Programming conference here
\r
34 on the Mailbox (Preferred if you have a general
\r
35 programming query or problem others would benefit from)
\r
36 3) Write to ASPHYXIA on the ASPHYXIA BBS.
\r
37 4) Write to Denthor, Eze or Livewire on Connectix.
\r
38 5) Write to : Grant Smith
\r
42 6) Call me (Grant Smith) at 73 2129 (leave a message if you
\r
43 call during varsity)
\r
45 NB : If you are a representative of a company or BBS, and want ASPHYXIA
\r
46 to do you a demo, leave mail to me; we can discuss it.
\r
47 NNB : If you have done/attempted a demo, SEND IT TO ME! We are feeling
\r
48 quite lonely and want to meet/help out/exchange code with other demo
\r
49 groups. What do you have to lose? Leave a message here and we can work
\r
50 out how to transfer it. We really want to hear from you!
\r
53 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
54 þ What is scrolling?
\r
56 If you have ever seen a demo, you have probably seen some form of scrolling.
\r
57 Our SILKYDEMO has quite a nice example of scrolling. What it is is a long
\r
58 row of text moving across your screen, usually from right to left, eg :
\r
67 etc. etc. See the program attatched for an example of scrolling.
\r
69 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
70 þ What do we scroll?
\r
72 Usually, letters. Most groups put greetings and information in their
\r
73 'scrollies', as they are termed. You can also scroll and entire screen
\r
74 using the scrolling technique. Scrolling your text is a hell of a lot
\r
75 less boring then just having it appear on your screen. Unfortunately,
\r
76 'scrollies' have been used so many times in demos they are wearing a
\r
77 bit thin, so usually they are accompanied by a cool picture or some nice
\r
78 routine happening at the same time (In our SILKYDEMO we had a moving
\r
79 checkerboard and colour bars going at the same time).
\r
81 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
82 þ How do we scroll from side to side?
\r
84 The theory behind scrolling is quite easy. Let us imagine that we are
\r
85 scrolling a 16x16 font grabbed by TEXTER (;-)) across the top of the
\r
86 screen (ie. 320 pixels) As we know, the VGA screen starts at zero at the
\r
87 top left hand part of the screen, then counts up to the right to 319, then
\r
88 goes back to the left hand side one pixel down at 320. (See Tut 1) This means
\r
89 that a 16*320 scroller takes up the space 0 to 5119 on the screen. In ascii
\r
90 this looks like this :
\r
97 Simple enough. Now what we do is we put down the first Y-line of the first
\r
98 character onto the very right hand side of the screen , like so :
\r
100 For loop1:=1 to 16 do
\r
101 Putpixel (319,loop1-1,font['A',1,loop1],vga);
\r
103 This will draw some stuff on the very right hand side. Your screen should now
\r
111 Next, we move each line one to the left, ie :
\r
113 For loop1:=0 to 15 do
\r
114 Move (mem[VGA:loop1*320+1],mem[VGA:loop1*320],320);
\r
116 This scrolls the screen from right to left, which is the easiest to read.
\r
117 To scroll the screen from left to right, swap the +1 onto the other side
\r
118 of the command. Also, to increase the size of the portion scrolled, increase
\r
119 the 15 to however many lines from the top you wish to scroll-1.
\r
121 After this move, your screen will look like this :
\r
126 (4800) . X . (5119)
\r
131 What you then do is draw in the next line on the right hand side, move it,
\r
132 draw the next line, move it etc. etc. Tah-Dah! You have a scrolly! Fairly
\r
135 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
136 þ How do we scroll up or down?
\r
138 To scroll up or down is also fairly simple. This can be used for 'movie
\r
139 credit' endings (I once wrote a little game with a desert scrolling down
\r
140 with you being a little robot on the bottom of the screen). The theory is
\r
141 this : Draw the top line (or bottom line) then move the entire screen :
\r
143 Move (mem[vga:0],mem[vga:320],63680);
\r
144 { 64000 - 320 = 63680 }
\r
146 For scrolling down, or :
\r
148 Move (mem[vga:320],mem[vga:0],63680);
\r
150 For scrolling up. You then draw the next line and repeat.
\r
152 Because of the simplicity of coding in a scrolly, most demos have one. It
\r
153 is usually best to have something extra happening on the screen so that
\r
154 the viewer doesn't get too bored, even, as I say, if it is only a really nice
\r
157 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
160 The University of Natal, Durban, Science Dept., now has 10 new 486's!
\r
161 This is a great boon, as now I can program nice routines during frees
\r
162 (even though I am a Commerce Student (Shhhhh) ;-) ). I can now use those
\r
163 previously wasted hours that I spent socialising and making friends
\r
166 I suggest you get a copy of TEXTER, for coding demos with fonts, or in fact
\r
167 almost any graphics application, it is an amazing help, and we have used it
\r
168 for *ALL* our demos. (P.S. We have written many demos, but many have been
\r
169 written for companies and have not been released for the general public)
\r
170 NOTE : For TEXTER's test program TEST.PAS, add {$X+} {$R-} if you have range
\r
171 checking on (I code with it off.)
\r
173 [ "I'm from the Computer Inspection Agency, sir,
\r
174 I'm here to check your computer. Here is
\r
175 my identification."
\r
176 "Certainly. Have a look, I'm clean. I don't have
\r
177 any pirated software."
\r
178 The C-man pushes past him and sits in front of the
\r
179 computer. He notes the fact that the computer
\r
180 is currently off with a look of disdain. He
\r
181 makes a note on his clipboard. He boots up.
\r
182 "What is this?" he asks, pointing at the screen.
\r
183 "It's MasterMenu" stutters the man. "I wrote it
\r
185 "Do you know what the penalty is for using junk
\r
186 like this on a private machine?" The C-man smiles.
\r
187 "This is a two-month sentance in itself!"
\r
188 "I'm sorry sir! It won't happen again!"
\r
189 "I know. I'll make sure of that." He smiles again.
\r
190 The C-man runs through the hard drive, checking for
\r
191 illeagal software, bad programs and anti-government
\r
192 propaganda. He notes with satisfaction that he has
\r
193 enough to put this weenie away for ten years, not that
\r
194 it mattered. He usually could just make something up.
\r
195 He comes to the last entry on the aphebetised menu tree.
\r
196 His hands jerk away from the keyboard. Then, tentatively,
\r
197 he types in the three letters of doom. He looks at the
\r
198 man, who is backing away with wide eyes and his hands
\r
199 outstretched in front of him, as if to ward off a blow.
\r
200 The C-man smiles, his lips a thin, hard line.
\r
210 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
\r
222 Letter = Array[1..xsize,1..ysize] of Byte;
\r
223 Letters = Array[' '..']'] of Letter;
\r
225 VAR Font : ^Letters;
\r
227 {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
\r
228 Procedure SetMCGA; { This procedure gets you into 320x200x256 mode. }
\r
237 {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
\r
238 Procedure SetText; { This procedure returns you to text mode. }
\r
246 {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
\r
247 procedure WaitRetrace; assembler;
\r
248 { This waits until you are in a Verticle Retrace }
\r
264 {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
\r
265 Procedure Pal(ColorNo : Byte; R,G,B : Byte);
\r
266 { This sets the Red, Green and Blue values of a certain color }
\r
268 Port[$3c8] := ColorNo;
\r
275 {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
\r
276 Procedure PutPixel (X,Y : Integer; Col : Byte; Where : Word);
\r
277 { This puts a pixel at X,Y using color col, on VGA or the Virtual Screen}
\r
279 Mem [Where:X+(Y*320)]:=col;
\r
282 {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
\r
283 procedure LoadPal (FileName : string);
\r
284 { This loads the Pallette file and puts it on screen }
\r
285 type DACType = array [0..255] of record
\r
289 Fil : file of DACType;
\r
292 assign (Fil, FileName);
\r
296 for I := 0 to 255 do Pal(I,Dac[I].R,Dac[I].G,Dac[I].B);
\r
299 {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
\r
300 function Exist(FileName: string): Boolean;
\r
301 { Checks to see if filename exits or not }
\r
305 Assign(f, FileName);
\r
309 Exist := (IOResult = 0) and
\r
314 {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
\r
316 { This loads the font and the pallette }
\r
319 loop2,loop3:integer;
\r
321 getmem (font,sizeof (font^));
\r
322 If exist ('softrock.fnt') then BEGIN
\r
323 Assign (f,'softrock.fnt');
\r
325 blockread (f,font^,sizeof (font^));
\r
327 Writeln ('SoftRock.FNT from TEXTER5 found in current directory. Using.');
\r
330 Writeln ('SoftRock.FNT from TEXTER5 not found in current directory.');
\r
331 For loop1:=' ' to ']' do
\r
332 For loop2:=1 to 16 do
\r
333 for loop3:=1 to 16 do
\r
334 font^[loop1,loop2,loop3]:=loop2;
\r
336 If exist ('pallette.col') then
\r
337 Writeln ('Pallette.COL from TEXTER5 found in current directory. Using.')
\r
339 Writeln ('Pallette.COL from TEXTER5 not found in current directory.');
\r
342 Write ('Hit any key to continue ...');
\r
345 If exist ('pallette.col') then loadpal ('pallette.col');
\r
349 {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ}
\r
350 Procedure ScrollMsg (Msg : String);
\r
351 { This scrolls the string in MSG across the screen }
\r
352 Var Loop1,loop2,loop3 : Integer;
\r
354 For loop1:=1 to length (msg) do BEGIN
\r
355 For loop2:=1 to xsize do BEGIN
\r
357 { This bit scrolls the screen by one then puts in the new row of
\r
361 For Loop3 := 100 to 99+ysize do
\r
362 move (mem[vga:1+(loop3*320)],mem[vga:(loop3*320)],319);
\r
363 for loop3:=100 to 99+ysize do
\r
364 putpixel (319,loop3,font^[msg[loop1],loop2,loop3-99],vga);
\r
365 { Change the -99 above to the minimum of loop3-1, which you
\r
366 will change in order to move the position of the scrolly }
\r
369 {This next bit scrolls by one pixel after each letter so that there
\r
370 are gaps between the letters }
\r
373 For Loop3 := 100 to 99+ysize do
\r
374 move (mem[vga:1+(loop3*320)],mem[vga:(loop3*320)],319);
\r
375 for loop3:=100 to 99+ysize do
\r
376 putpixel (319,loop3,0,vga);
\r
383 Writeln ('This program will give you an example of a scrolly. If the file');
\r
384 Writeln ('SOFTROCK.FNT is in the current directory, this program will scroll');
\r
385 Writeln ('letters, otherwise it will only scroll bars. It also searches for');
\r
386 Writeln ('PALLETTE.COL, which it uses for it''s pallette. Both SOFTROCK.FNT');
\r
387 Writeln ('and PALLETTE.COL come with TEXTER5.ZIP, at a BBS near you.');
\r
389 Writeln ('You will note that you can change what the scrolly says merely by');
\r
390 Writeln ('changing the string in the program.');
\r
394 ScrollMsg ('ASPHYXIA RULZ!!! ');
\r
397 freemem (font, sizeof (font^));
\r
398 Writeln ('All done. This concludes the fifth sample program in the ASPHYXIA');
\r
399 Writeln ('Training series. You may reach DENTHOR under the name of GRANT');
\r
400 Writeln ('SMITH on the MailBox BBS, or leave a message to ASPHYXIA on the');
\r
401 Writeln ('ASPHYXIA BBS. Get the numbers from Roblist, or write to :');
\r
402 Writeln (' Grant Smith');
\r
403 Writeln (' P.O. Box 270');
\r
404 Writeln (' Kloof');
\r
406 Writeln ('I hope to hear from you soon!');
\r
408 Write ('Hit any key to exit ...');
\r