Personal Computer News


Right, Left And Diagonal Scrolling

 
Published in Personal Computer News #099

Right, left and diagonal scroll is possible with Steve Scovell's machine code listing.

Side Scroll

Right, left and diagonal scroll is possible with Steve Scovell's machine code listing

The Amstrad Basic lacks a scroll command - but it's possible to scroll left, right and diagonally as well as the usual up and down with a bit of machine code. By using a CALL address command the routines can be easily accessed by any Basic programmer.

The machine code in the listing here is a package of three types of routine written with the games programmer in mind.

  1. Scroll, left, right, up, down. There is already a firmware routine for up and down scrolling but it always blanks out the new line with an ink. The routine here does not.
  2. Blank out. With the current paper ink the left edge, right edge, top and bottom lines.
  3. Fill box. These boxes are one, two or three characters high and are printed at the left or right edge of the screen, with the current pen ink.

Each type of routine is modified easily with a few pokes.

The up, down, left and right routine is separate for ease of use. Although one routine could perform all four movements, you might want to change scroll direction in a program, which would involve several pokes.

How They Work

The Scroll routine first calls the firmware routine &BC0B.GET OFFSET. This loads the HL register pair with the address of the first byte of screen memory, HL can now be incremented or decremented and when &BC05 SRC SET OFFSET. is called, the screen can be made to scroll, with 80 bytes per screen line up in all modes, an increase of 80 on starting offset. The screen scrolls up one chracter line (eight screen lines) and by increasing HL by two, the screen scrolls left. Decrementing HL has the opposite effect. The OS is kept informed of the offset at all times so even after several scrolls, a locate x,y:print chrs is always executed at the correct screen address. Each scroll rotine takes 12 bytes.

The routines are set up for use in mode 1. For use in mode 0 or 2 consult Table 2 and poke these addresses before running these routines.

To use them you must first type in the Basic loader and run the routine. There is then a simple data check and even with a DATA OK message save the loader to tape before calling a routine.

First, try CALL 20000: the screen should scroll left by one space. To get a taste of the speed of these routines try 10 call 20000/20 for f=1 to 20:next/30 goto 10 and run it. Save the code to tape statement at the end of the Loader program.

How To Use The Routines

CALL 20000 scroll left
CALL 20012 scroll right
CALL 20024 scroll up
CALL 20036 scroll down
CALL 20048 blank left
CALL 20066 blank right
CALL 20084 blank top
CALL 20102 blank bottom
CALL 20120 box 1 left
CALL 20138 box 1 right
CALL 20156 box 2 right
CALL 20174 box 2 left
CALL 20192 box 3 right
CALL 20210 box 3 left
 
POKE 20004 scroll count left
POKE 20016 scroll count right
POKE 20028 scroll count up
POKE 20040 scroll count down
Table 1

In Use

For your own games you try omitting the blank out routine so that whatever exits left appears at the right of the screen but one line up or one line down in mode 1. If that's not what you want, it can be corrected with a scroll up or down. You can also have diagonal scroll by poking the scroll count addresses with 82, i.e. if you poke the scroll left, scroll count with 82, and when you call left scroll you will have a right to left diagonal scroll.

The scroll count address can be poked with any number between 1 and 255 and each number has a different effect. If you wish to use the routines in mode 0 or 2 first poke the addresses given in Table 2. For smooth scrolling in these modes, the scroll counts should be poked with 4 in mode 0 and 1 in mode 2. However, experimenting with different numbers and ocmbinations of scroll can result in some very interesting programs.

POKE Mode 1 Mode 2
20073 19 79
20075 19 79
20093 19 79
20111 19 79
20145 19 79
20147 19 79
20163 19 79
20165 19 79
20199 19 79
20201 19 79
Table 2

Steve Scovell