home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TUT10NEW.ZIP / TUT10.TXT < prev   
Text File  |  1995-02-02  |  16KB  |  382 lines

  1.                    ╒═══════════════════════════════╕
  2.                    │         W E L C O M E         │
  3.                    │  To the VGA Trainer Program   │ │
  4.                    │              By               │ │
  5.                    │      DENTHOR of ASPHYXIA      │ │ │
  6.                    │      (updated by Snowman)     │ │ │
  7.                    ╘═══════════════════════════════╛ │ │
  8.                      ────────────────────────────────┘ │
  9.                        ────────────────────────────────┘
  10.  
  11.                            --==[ PART 10 ]==--
  12.  
  13. Note: This is Snowman here.  This is tutorial 10, and 10 is a pretty
  14. important number.  For normal humans, this is first number greater
  15. than 0 that needs two characters to represent it.  (of course for us
  16. REAL programmers, its 16, but you can't expect your parents to
  17. understand that sort of thing).
  18.  
  19. Anyway, I have decided to take a different approach to the converting
  20. of these tutorials.  Denthor and I have built up a friendly line of
  21. communication.  As such, I am going to start putting in my two cents
  22. wherever I feel like it (pointing out as many of Denthor's errors as
  23. I possibly can, be they real or imagined).  Unless Denthor decides to
  24. turn around and re-edit all of these tutorials, there is no way that
  25. that he can respond to anything I have to say, so its a win-win
  26. situation.  muhahahaaa!
  27.  
  28. I just checked and there has been about 210k of source code converted
  29. from Pascal to C++.  210k!  Do you know what all of that typing can
  30. do to someone?  Have you any idea how many times I've stayed up until
  31. 5 in the morning working on one of these things?  Well, I'm sick of
  32. just letting Denthor have all the glory.  That's right.  As of
  33. tutorial part 10, I am now the "deviant convertor", and will do my
  34. best to make this series as 'interesting' as I possibly can.
  35.  
  36.   -Christopher (Snowman) G. Mann / HORNET  r3cgm@dax.cc.uakron.edu
  37.  
  38. [BTW: Anything in brackets has been added by Snowman]
  39. <BTW: Anything in those <> thingies is made-up Denthor stuff>
  40.  
  41. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  42. ■ Introduction
  43.  
  44. Wow! The trainer has finally reached part 10! This will also be the
  45. first part introduced simultaneously to local BBS's and the INTERNET at
  46. the same time! Yes folks, I put up a copy of previous tutorials onto
  47. various ftp sites, and awaited the flames saying that the net.gurus
  48. already knew this stuff, and why was I wasting disk space! The flames
  49. did not appear (well, except for one), and I got some messages saying
  50. keep it up, so from now on I will upload all future trainers to ftp
  51. sites too (wasp.eng.ufl.edu , cs.uwp.edu etc.). I will also leave a
  52. notice in the USENET groups comp.lang.pascal and comp.sys.ibm.pc.demos
  53. when a new part is finished (Until enough people say stop ;-))
  54.  
  55. I can also be reached at my new E-Mail address,
  56.                  smith9@batis.bis.und.ac.za
  57.  
  58. Well, this tutorial is on Chain-4. When asked to do a trainer on
  59. Chain-4, I felt that I would be walking on much travelled ground (I have
  60. seen numerous trainers on the subject), but the people who asked me said
  61. that they hadn't seen any, so could I do one anyway? Who am I to say no?
  62.  
  63. [I happen to know personally that Denthor didn't get any mail asking him
  64. to do a Chain-4 tutor.  He's just trying to show off.]
  65.  
  66. The sample program attached isn't that great, but I am sure that all you
  67. people out there can immediately see the potential that Chain-4 holds.
  68.  
  69. [As far as the code goes, I must ask: // where are these? ]
  70.  
  71. If you would like to contact me, or the team, there are many ways you
  72. can do it : 1) Write a message to Grant Smith/Denthor/Asphyxia in private mail
  73.                   on the ASPHYXIA BBS.
  74.             2) Write to Denthor, EzE or Goth on Connectix.
  75.             3) Write to :  Grant Smith
  76.                            P.O.Box 270 Kloof
  77.                            3640
  78.                            Natal
  79.                            South Africa
  80.             4) Call me (Grant Smith) at (031) 73 2129 (leave a message if you
  81.                   call during varsity). Call +27-31-73-2129 if you call
  82.                   from outside South Africa. (It's YOUR phone bill ;-))
  83.             5) Write to smith9@batis.bis.und.ac.za in E-Mail.
  84.  
  85. NB : If you are a representative of a company or BBS, and want ASPHYXIA
  86.        to do you a demo, leave mail to me; we can discuss it.
  87. NNB : If you have done/attempted a demo, SEND IT TO ME! We are feeling
  88.         quite lonely and want to meet/help out/exchange code with other demo
  89.         groups. What do you have to lose? Leave a message here and we can work
  90.         out how to transfer it. We really want to hear from you!
  91.  
  92.  
  93.  
  94. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  95. ■ What is Chain-4?
  96.  
  97. You people out there all have at least 256k vga cards. Most of you have
  98. 512k vga cards, and some have 1MB vga cards. But what you see on your
  99. screen, as discussed in previous trainers, is 64k of data! What happened
  100. to the other 192k??? Chain-4 is a method of using all 256k at one time.
  101.  
  102. [But is it difficult to use the other 192k?]
  103.  
  104. Heck no, its simple!  1 screen = 64k. 64k * 4 = 256k. Therefore, chain-4
  105. allows you to write to four screens, while displaying one of them. You can
  106. then move around these four screens to see the data on them. Think of the
  107. Chain-4 screen as a big canvas. The viewport, the bit you see out of, is a
  108. smaller rectangle which can be anywhere over the bigger canvas.
  109.  
  110.      +----------------------------+ Chain-4 screen
  111.      |          +--+              |
  112.      |          |  | <- Viewport  |
  113.      |          +--+              |
  114.      |                            |
  115.      +----------------------------+
  116.  
  117. [But Denthor, if I can see 1/4th of the screen at one time, isn't your
  118. diagram a little out of scale?]
  119.  
  120. <Well... I guess so, but that's not the point.  I'm just trying to show
  121. everyone how they should _think_ about a chain 4 screen.>
  122.  
  123. [But how can they understand if you give them faulty diagrams?]
  124.  
  125. <Oh, shut up already!>
  126.  
  127. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  128. ■ The size of the chain-4 screen
  129.  
  130. The Chain-4 screen, can be any size that adds up to 4 screens.
  131.  
  132. For example, it can be 4 screens across and one screen down, or one
  133. screen across and 4 screens down, or two screens across and two screens
  134. down, and any size in between.
  135.  
  136. [Er... Denthor, you already listed the 3 possible combinations of
  137. a chain-4 layout: 4 across and 1 down, 4 down and 1 across, and 2
  138. across AND down.  Are you saying we could have something like 1.5
  139. screens across and 2.5 down?  I mean, come on!, you're confusing me.]
  140.  
  141. <Actually, I just added that "any size in between" to confuse the
  142. reader.  My evil plan has worked!  muhaaha...>
  143.  
  144. In the sample program, the size is a constant. The size * 8 is how many
  145. pixels across there are on the chain-4 screen, ie
  146.    Size = 40   = 320 pixels across = 1 screen across, 4 screens down
  147.    Size = 80   = 640 pixels across = 2 screens across, 2 screens down
  148. etc.
  149.  
  150. We need to know the size of the screen for almost all dealings with the
  151. Chain-4 screen, for obvious reasons.
  152.  
  153.  
  154. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  155. ■ Layout of the chain-4 screen, and accessing it
  156.  
  157. If you will remember all the way back to Part 1 of this series, I
  158. explained that the memory layout of the MCGA screen is linear. Ie, the
  159. top left hand pixel was pixel zero, the one to the right of it was
  160. number one, the next one was number two etc. With Chain-4, things are
  161. very different.
  162.  
  163. [Hey, shouldn't you also have said something like "After you get to
  164. the right of the screen and go back to the left (next line) the computer
  165. thinks of that as pixel 321 and not line 2, pixel 1"?]
  166.  
  167. <Well, I just _assumed_ that if you got this far in the series, you'd
  168. understand the basic layout of video memory!>
  169.  
  170. [Jeesh, it was just a question, don't overreact.]
  171.  
  172. <What am I supposed to do, just happily explain code while you are
  173. constantly making up all of these things that I'm saying?  Besides, all
  174. of these comments are detracting from the reader's understanding of
  175. the code.>
  176.  
  177. [Denthor, you forget.  You no longer have any power in here.  This is
  178. MY domain now.  Just think of me as the Borg.]
  179.  
  180. Chain-4 gets the 4 screens and chains them together (hence the name :)).
  181. Each screen has a different plane value, and must be accessed
  182. differently. The reason for this is that a segment of memory is only 64k
  183. big, so that we could not fit the entire Chain-4 screen into one
  184. segment.
  185.  
  186. All Chain-4 screens are accessed from $a000, just like in MCGA mode.
  187. What we do is, before we write to the screen, find out what plane we are
  188. writing to, set that plane, then plot the pixel. Here is how we find out
  189. how far in to plot the pixel and what plane it is on :
  190.  
  191.  Instead of the linear model of MCGA mode, ie :
  192.         ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
  193.         │00│01│02│03│04│05│06│07│08│09│10│11│ ...
  194.  
  195.  Each plane of the Chain-4 screen accesses the memory in this way :
  196.  
  197.        Plane 0 :
  198.         ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
  199.         │00│  │  │  │01│  │  │  │02│  │  │  │ ...
  200.  
  201.        Plane 1 :
  202.         ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
  203.         │  │00│  │  │  │01│  │  │  │02│  │  │ ...
  204.  
  205.        Plane 2 :
  206.         ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
  207.         │  │  │00│  │  │  │01│  │  │  │02│  │ ...
  208.  
  209.        Plane 3 :
  210.         ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
  211.         │  │  │  │00│  │  │  │01│  │  │  │02│ ...
  212.  
  213. In this way, by choosing the right plane to write to, we can access all
  214. of the 256k of memory available to us. The plane that we write to can
  215. easily be found by the simple calculation of  x mod 4, and the x
  216. coordinate is also found by  x div 4. We work out our y by multiplying
  217. it by the size of our chain-4 screen.
  218.  
  219. [Could you be a little MORE cryptic?  I had to read this last paragraph
  220. three times before I got what you were saying.]
  221.  
  222. <Hey, I already know this stuff.  Why should I make it clear for the
  223. reader? ... oh wait a minute, this is a tutorial!  My mistake, won't
  224. happen again.>
  225.  
  226. NOTE : It is possible to write to all four planes at once by setting the
  227.        correct port values.
  228.  
  229. [Any chance you could share this knowledge with the reader?]
  230.  
  231. <No can do, its an Asphyxia secret.>
  232.  
  233. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  234. ■ Uses of Chain-4
  235.  
  236. The uses of Chain-4 are many. One could write data to one screen, then
  237. flip to it (the move_to command is almost instantaneous). This means
  238. that 64k of memory does not need to be set aside for a virtual screen,
  239. you are using the vga cards memory instead!
  240.  
  241. Scrolling is much easier to code for in Chain-4 mode.
  242.  
  243. [Scrollers are for lamers.]
  244.  
  245. <I don't mean text scrollers you idiot!  I mean for other things, like
  246. moving around a picture on the screen, etc.>
  247.  
  248. [Hey, watch your attitude with me or I'll put bugs in the pascal source
  249. and say you did it.]
  250.  
  251. <You wouldn't!>
  252.  
  253. [I would.]
  254.  
  255. <OK, I'm sorry.>
  256.  
  257. <[shaking hands]>
  258.  
  259. It is possible to "tweak" the mode into other resolutions. In our demo,
  260. our vectors were in 320x240 mode, and our dot vectors were in 320x400
  261. mode.
  262.  
  263. The main disadvantage of chain-4 as I see it is the plane swapping,
  264. which can be slow. With a bit of clever coding however, these can be
  265. kept down to a minimum.
  266.  
  267. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  268. ■ The sample programs
  269.  
  270. The first sample program is GFX.PAS. This is a until in which I have
  271. placed most of our routines from previous tuts. All the procedures and
  272. variables you can see under the INTERFACE section can be used in any
  273. program with GFX in the USES clause. In other words, I could do this :
  274.  
  275. USES GFX,crt;
  276.  
  277. BEGIN
  278.   Setupvirtual;
  279.   cls (vaddr,0);
  280.   Shutdown;
  281. END.
  282.  
  283. [Its about time you started putting these functions in an external
  284. file.  Hell, I did it back in tut7.  Do you know how much redundant
  285. code you made the pascal'ers go through?]
  286.  
  287. <Well, call it a quirk of mine, but I _really_ like to cut and paste.>
  288.  
  289. [er...]
  290.  
  291. This program would compile perfectly. What I suggest you do is this :
  292. Rename the file to a name that suites you (eg your group name), change
  293. the first line of the unit to that name, then add all useful procedures
  294. etc. to the unit. Make it grow :-).
  295.  
  296. The second file is the sample program (note the USES GFX,crt; up near
  297. the top!). The program is easy to understand and is documented.
  298.  
  299. [hahaha.... "documented"?  I've seen business cards with more
  300. documentation than your programs.]
  301.  
  302. <Hey, without these programs to convert, you wouldn't have _anything_
  303. useful to contribute!>
  304.  
  305. [Now that was just mean!  I make one comment about your documentation
  306. and you make fun of me like that.  Can't we all just get along?]
  307.  
  308. <I'm sorry Snowman.  Sometimes my temper just gets away from me.>
  309.  
  310. <[shaking hands]>
  311.  
  312. The bit that I want to draw your attention to is the constant, BIT. Because
  313. I am distributing this file to many places in text form, not binary form, I
  314. could not just add a .CEL file with the program. So what I did was write
  315. some text in one color then saved it as a .CEL . I then wrote a ten line
  316. program that did the following : Moving from left to right, it counted how
  317. many pixels were of color zero, then saved the byte value to an array. When
  318. it came across color one, is counted for how long that went on then saved
  319. the byte value and saved it to an array and so on. When it was finished, I
  320. converted the array into a text file in the CONST format. Not too cunning,
  321. but I thought I had better explain it ;-)
  322.  
  323. [Actually, that was a pretty good idea.]
  324.  
  325. <Thank you.>
  326.  
  327. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  328. ■ In closing
  329.  
  330. There are other documents and sample programs available on Chain-4 and
  331. it's like : Try XLIB for one...
  332.  
  333. Finally! Some BBS's have joined my BBS list! (Okay, only two new ones,
  334. but it's a start ;-)) All you international BBS's! If you will regularly
  335. download the tuts from an FTP site, give me your names!
  336.  
  337. I own a car. The car's name is Bob. A few days ago, Bob was in an
  338. accident, and now has major damage to his front. Knowing insurance, I
  339. probably won't get much, probably nothing (the other guy wasn't insured,
  340. and I am only 18 :( ). I will probably have to find work in order to pay
  341. for my repairs. The point to this meandering is this : I am upset, so if
  342. you think you are getting a quote, you can just forget it.
  343.  
  344. Oh, well. Life goes on!
  345.  
  346. [Your car's name is Bob?  Do you name your silverware too?]
  347.  
  348. <Hey, a car has feelings just like anyone else.  Don't make fun of Bob,
  349. he's very sensitive.>
  350.  
  351. [Won't happen again.]
  352.  
  353. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  354.  
  355. [This is Snowman...]
  356.  
  357. <...and this is Denthor...>
  358.  
  359. [<...and WE, ARE, OUTTA HERE! >]
  360.  
  361. These fine BBS's carry the ASPHYXIA DEMO TRAINER SERIES : (alphabetical)
  362.  
  363. ╔══════════════════════════╦════════════════╦═════╦═══╦════╦════╗
  364. ║BBS Name                  ║Telephone No.   ║Open ║Msg║File║Past║
  365. ╠══════════════════════════╬════════════════╬═════╬═══╬════╬════╣
  366. ║ASPHYXIA BBS #1           ║(031) 765-5312  ║ALL  ║ * ║ *  ║ *  ║
  367. ║ASPHYXIA BBS #2           ║(031) 765-6293  ║ALL  ║ * ║ *  ║ *  ║
  368. ║Connectix BBS             ║(031) 266-9992  ║ALL  ║   ║ *  ║ *  ║
  369. ║POP!                      ║(012) 661-1257  ║ALL  ║   ║ *  ║ *  ║
  370. ║Pure Surf BBS             ║(031) 561-5943  ║A/H  ║   ║ *  ║ *  ║
  371. ╚══════════════════════════╩════════════════╩═════╩═══╩════╩════╝
  372.  
  373. For international users : If you live outside the Republic of South
  374. Africa, do the following : Dial +27, dont dial the first 0, but dial
  375. the rest of the number. Eg, for the ASPHYXIA BBS : +27-31-765-5312
  376.  
  377. Open = Open at all times or only A/H
  378. Msg  = Available in message base
  379. File = Available in file base
  380. Past = Previous Parts available
  381.  
  382.