Wow! The trainer has finally reached part 10! This will also be the first part introduced simultaneously to local BBS's and the INTERNET at the same time! Yes folks, I put up a copy of previous tutorials onto various ftp sites, and awaited the flames saying that the net.gurus already knew this stuff, and why was I wasting disk space! The flames did not appear (well, except for one), and I got some messages saying keep it up, so from now on I will upload all future trainers to ftp sites too (wasp.eng.ufl.edu , cs.uwp.edu etc.). I will also leave a notice in the USENET groups comp.lang.pascal and comp.sys.ibm.pc.demos when a new part is finished (Until enough people say stop )
I can also be reached at my new E-Mail address, smith9@batis.bis.und.ac.za
Well, this tutorial is on Chain-4. When asked to do a trainer on Chain-4, I felt that I would be walking on much travelled ground (I have seen numerous trainers on the subject), but the people who asked me said that they hadn't seen any, so could I do one anyway? Who am I to say no?
The sample program attached isn't that great, but I am sure that all you people out there can immediately see the potential that Chain-4 holds.
If you would like to contact me, or the team, there are many ways you can do it :
1) Write a message to Grant Smith/Denthor/Asphyxia in private mail on the ASPHYXIA BBS.
2) Write to Denthor, EzE or Goth on Connectix.
3) Write to : Grant Smith
P.O.Box 270 Kloof
3640
Natal
South Africa
4) Call me (Grant Smith) at (031) 73 2129 (leave a message if you call during varsity). Call +27-31-73-2129 if you call from outside South Africa. (It's YOUR phone bill ;-))
5) Write to smith9@batis.bis.und.ac.za in E-Mail.
NB : If you are a representative of a company or BBS, and want ASPHYXIA to do you a demo, leave mail to me; we can discuss it.
NNB : If you have done/attempted a demo, SEND IT TO ME! We are feeling quite lonely and want to meet/help out/exchange code with other demo groups. What do you have to lose? Leave a message here and we can work out how to transfer it. We really want to hear from you!
You people out there all have at least 256k vga cards. Most of you have 512k vga cards, and some have 1MB vga cards. But what you see on your screen, as discussed in previous trainers, is 64k of data! What happened to the other 192k??? Chain-4 is a method of using all 256k at one time.
The way this is done is simple. 1 screen = 64k. 64k * 4 = 256k.
Therefore, chain-4 allows you to write to four screens, while displaying one of them. You can then move around these four screens to see the data on them. Think of the Chain-4 screen as a big canvas. The viewport, the bit you see out of, is a smaller rectangle which can be anywhere over the bigger canvas.
The Chain-4 screen, can be any size that adds up to 4 screens.
For example, it can be 4 screens across and one screen down, or one screen across and 4 screens down, or two screens across and two screens down, and any size in between.
In the sample program, the size is a constant. The size * 8 is how many pixels across there are on the chain-4 screen, ie
Size = 40 = 320 pixels across = 1 screen across, 4 screens down Size = 80 = 640 pixels across = 2 screens across, 2 screens down etc.
We need to know the size of the screen for almost all dealings with the Chain-4 screen, for obvious reasons.
If you will remember all the way back to Part 1 of this series, I explained that the memory layout of the MCGA screen is linear. Ie, the top left hand pixel was pixel zero, the one to the right of it was number one, the next one was number two etc. With Chain-4, things are very different.
Chain-4 gets the 4 screens and chains them together (hence the name :)).
Each screen has a different plane value, and must be accessed differently. The reason for this is that a segment of memory is only 64k big, so that we could not fit the entire Chain-4 screen into one segment.
All Chain-4 screens are accessed from $a000, just like in MCGA mode.
What we do is, before we write to the screen, find out what plane we are writing to, set that plane, then plot the pixel. Here is how we find out how far in to plot the pixel and what plane it is on :
Instead of the linear model of MCGA mode, ie :
┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐ │00│01│02│03│04│05│06│07│08│09│10│11│ ...
Each plane of the Chain-4 screen accesses the memory in this way :
Plane 0 : ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐ │00│ │ │ │01│ │ │ │02│ │ │ │ ... Plane 1 : ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐ │ │00│ │ │ │01│ │ │ │02│ │ │ ... Plane 2 : ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐ │ │ │00│ │ │ │01│ │ │ │02│ │ ... Plane 3 : ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐ │ │ │ │00│ │ │ │01│ │ │ │02│ ...
In this way, by choosing the right plane to write to, we can access all of the 256k of memory available to us.
The plane that we write to can easily be found by the simple calculation of x mod 4, and the x coordinate is also found by x div 4 (or shr(x,2)).
We work out our y by multiplying it by the size of our chain-4 screen.
It is possible to write to all four planes at once by setting the correct port values.