Skyhigh 21 Coding

From C64 Diskmag Wiki
Jump to: navigation, search
Coding



And now you return to the corner of Dr Shoe, the
all helpful coding guru (shit, I wish instead of just
being a coding guru, I could code like Guru/Reflex!!!)

If you remember last issue, I explained how to code
your first proportional font displayer. I had quite
a lot of very positive reactions, some from guys who
said they had never coded before, and some from
guys who I consider to be BETTER coders than myself
so it was very pleasing for me.

Well, as promised, this time I will unveil the secrets
of that dreaded routine which escaped a lot of
coders for many years (although I heard that
Fuben/Oxyron coded one a few years back, but
never released it until the outfit for The Relax).

Anyway, this subject comes very close to our heart,
as we in Skyhigh presented the first magazine outfit
with a proportional upscroller. So who better to
take you through the basics than the man who
coded it, Raz/Camelot!

Sadly he isn't here, so yet again, you will have to
live with my sad little explanations.

OK, lets begin.

Last issue, if you remember, I actually explained the
secret behind a proportional upscroller. I did that
when I told you the two ways to display a
proportional font on the screen. There were two
methods, one using characters and raster splits,
and one using a bitmap screen (which was what we
used last time). Well, for the proportional upscroller
we need to used the method of chars, and I will
explain this to you again.

OK, we split the screen into 4 equal sections, and
these splits do one thing. They change which data
we are using to define the character set. Not very
clear? Hopefully this diagram will show it a little
better:

*************
* $2000-           *
*            $2800 *
*  ------------  *
* $2800-           *
*            $3000 *         Key:
*  ------------  *         *=edge of the screen
* $3000-           *         - =raster split
*            $3800 *
*  ------------  *
* $3800-           *
*            $4000 *
*************

You probably don't appreciate how long it took me to
draw the fucking diagram...... 8-)

OK, you can see that the screen is split into 4
sections. The numbers show what area of memory the
character set is defined by, and that is what I will
assume from now on.

Anyone with a little bit of a clever mind will have
figured out how this will have worked by now, but
the rest of the world will still need some
explanation.

This example also assumes that you have your
screen located at $0400-$0800. Remember, you
don't need a bitmap screen, just one with normal
chars on.

OK, so here is how it works. You fill the screen with
the data numbered 0-240 in order. So, you get the
following:

$0400=00
$0401  =01
$0402=02

and so on until you reach $04f0.

That will mean $04F0 holds the value $f0, or 240.

Then, if you think, you have 6 rows of characters,
each row of which is 40 characters across, so you
have 240 characters on the top quarter of the
screen.

Then, repeat the process from $04F0 to $05E0,
putting $00 at $04F0 up to $F0 at $05E0. Do this
again for $05E0 to $06D0 and again for $06D0 to
$07C0.

As you will immediately recognise, that is one row
short, which is alright. It is alright, because I have
made a mistake so far. I have said we should start
from $0400. We shouldn't. We should have actually
started from $0428. This figures, as when we scroll
the screen, we will have to move the top borders
in by 1 character to allow smooth entry to the
screen. So, we will never actually see the top line
of the screen, so why put data there if we will
never see it? So, don't put the data there, and
instead start from $0428.

Anyone thinking whilst reading this article would
have noticed that deliberate (ha!) mistake on my
behalf. Just tying to make sure you are still awake,
you see!

Anyway, so now you have a screen with all the data
on it. The next stage is to set up your raster
lines. You want to place them on the pixel line
where the two character sets will change, in
other words, where the data goes back to $00
again. All you need to do is change $D018 to switch
to the next charset, so you will have no probs at
all concerning a messy split, and if you do, a little
bit of timing here and there will work it all out
nicely.

So, you should now have a screen set up which has
absolutely nothing on it, if you run your program.
That is because you will have remembered in
advance to write a small routine blanking all the
data from $2000 to $4000, won't you? There will be
nothing on the screen even though the data is there
because the charset data is currently empty.

OK, now this is where I get into the realms of theory,
as I have never actually done this myself!

The theory behind the upscroller is this.

Display the top pixel line of the WHOLE row of
characters, then scroll it onto the screen using
$D011. YOU MUST ALSO MOVE YOUR 4 RASTER LINES UP
BY 1 PIXEL TO COMPENSATE FOR THIS!!!!!!! That is of
utmost importance. OK, then draw out the next
pixel line of your line of data, then scroll the
line up one pixel using $D011. So, if the whole line
looks like this:

***** *      * *****
*         *      *         *
*         *      *       *
***** *****     *
* *      *   *
* *      * *
***** *      * *****

then so far you will have:

***** *      * *****
*         *      *         *

on the screen.

You then repeat this until the entire line of text
is displayed (all 8 pixel lines of it). So, somewhere on
the screen you have SHZ written.

I say "somewhere on the screen" as I have not told
you yet where you want to place that! Aren't I just
nasty....

OK, you actually want to place that on the BOTTOM
line of your screen, which is at the beginning, 6
lines down into the data held from $3800-$4000. So,
you want to set the position to write this data into
memory as $3800+(5*40) which is (get out your
calculators) $38C8. Remeber it is 5*40 as you are
starting the section at $3800+(0*40), so 5*40 is
the 6th if you add 1 every time, or something like
that, anyway.

OK, so your data is now at the bottom left of the
screen, sitting pretty. But how on earth do you
scroll this?

Well, actually very easily. It is the same as if you
were doing a normal upscroller. Simply pick up all
the from $0428 to $07C0 and place it at $0400 to
$0798. But, the data from $0428 to $0450 does not
go at $0400 to $0428, but instead at $0798 to $07C0
so that is can wrap around.

HOWEVER, when this data is all wrapped around, if
you remember you will have reset $D011. But that
leaves your rasters up shit creek, as you have
the top section $2000 to $2800 with one of its
lines at the bottom of the screen (row 24). So you
need to totally alter it, and move the top one
completely around to the bottom of the screen. The
others may only need moving by one pixel, as I am
not too sure.

The next thing to remember is to blank the data from
$2000 to $2140, as it it now being used for the net
line to come on the screen.

So, you now repeat this rather nasty process, but
place new data at $2000 to $2140.

the big problem is keeping the rasters in check.

The other major thing to remember is that you can't
use the exact routines I gave you last time, as they
worked by displaying a whole character at once,
whereas to maintain a fluid movement, the upscroller
needs the characters to be displayed one pixel
line at a time!

Anyway, that is that for this month. As I write this,
the X96 will open its doors in 62 hours, and I am
still at home in England! Hope to see you there!


Shuze/Afl'70
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox