Scroll Routines Demo

By Richard Dimond

Originally published in EUG #29

Since I found that I had the game Thrust on Play It Again Sam which I had successfully transferred to disk, I thought that I would try to get the routines that Mark Bellis was wanting. However, all my efforts to try to break out of the program to get the coding were foiled by getting the opening screen each time. The only way out then was to press BREAK and lose the program.

I then thought that I would try to make my own routines and this EUG includes a demonstration of these routines. I wanted to use the Thrust screen and tried to get it using Snapshot but I could not get this to work so I have made up a rather crude screen with some BASIC routines to show how they work. When run, press 1, 2 or 3 to choose the scroll and afterwards, SPACE re-runs the program or Q to quit.

While these do not give as smooth or as quick a scroll as in Thrust, I hope that they may form a basis for someone to enjoy experimenting with them. If anyone has any problems, I shall be glad to help and, if I can improve them myself later, I will send them in.

Here is some explanation of how I developed_these_and_how they work for those interested in experimenting with them.

I realised that it needed something like:

      LDA &6482 :STA &6480 :LDA &648A :STA &6488 : ....
      LDA &6484 :STA &6482 :LDA &648C :STA &648A : ....
      LDA &6486 :STA &6484 : ....
      LDA &65C0 :STA &6486 : ....
      LDA &65C2 :STA &65C0 : ....

I made up the BASIC program U.SCR-B to do this. This worked, provided that the odd bytes of each character were zero but it was very slow. After coding this, it ran much quicker and smoother but was not as quick as the Thrust routine.

To speed it up I have made it scroll four bytes at a time rather than two, and also had to include all four bytes though this does not give as smooth a scroll.

To do this I have used the routine:

      .loop3 LDA(a),Y : STA(b),Y
where a and b are zero page addresses pointing to screen addresses with a initially = b+4.

The addresses are then increased by 8 for the next character and repeated 40 times to complete the line. This has then scrolled lower half of the characters into the top half.

Next the upper half of the characters in the next line must be scrolled into the lower half of the line above. To do this, a must be set to the address of the start of the next line and the initial value of b increased by 4. This is done by subtracting from their values at the end of the line at suba.

A similar subtraction is then made at the end of this line at subb to bring the values back to a = b+4 for scrolling the lower half of this line.

The value in register X is compared to alternate between the two subs.

The scrolling then continues until the comparison of a+1 at chk in line 480. When this is equal, the comparison in line 500 is made and if not equal, the scrolling continues half a line each time until this is equal.

The coding can easily be altered to cover a different area of the screen by altering four values:

  b...can be the value of the start of any line. i.e. &5800 plus any multiple of &140
a...must initially be equal to b+4
The comparison value in line 480 can be any value greater than the high byte of the addresses up to &7F
The address in line 500 should equal b

Having got this scrolling working well, I found that Thrust also had routines for scrolling down and left so I tried modifying the program to do these scrollings as well.

To scroll down is very similar, except that the initial values of a and b must point to the last line and the comparison in line 400 to the upper limit. The address in line 420 must also be the last non-zero byte of the screen.

The left scroll is rather different. The bits of the screen have to be shifted left four times each time. This is done with the routine in loop3, lines 240-290.

The two bytes to be shifted each time needed to stored in temp, shifted and loaded back each time. Also the characters are shifted in columns rather than lines. To do this, I saved the addresses of the top of the column in aa and bb and increased these by 8 after each column had been shifted.

The routine is stopped at line 430 as before but the address can be any suitable non-zero point in mid-screen.

Richard Dimond, EUG #29