Classic Computer Magazine Archive COMPUTE! ISSUE 71 / APRIL 1986 / PAGE 87

Smooth-Scrolling
Billboards
For IBM

Paul W. Carlson

Do you want to leave a message on your computer screen that's sure to be noticed? Or would you like to create an eye-catching display in a shop window that effectively communicates your message to the public? The programs presented here let you easily produce smooth-scrolling billboards on the 40- or 80-column screen of your IBM PC (with color/graphics adapter and BASICA) or PCjr (with Cartridge BASIC).


To be really effective, a billboard program must smoothly scroll its message across the screen. Programs that jerk the letters across the screen are very hard on the eyes. The speed necessary for smooth scrolling can be achieved only by avoiding the routines in the BIOS (Basic Input/Output System) and writing directly to video memory. However, this can cause a problem when text is used in graphics modes-writing directly to video memory disrupts the character generator. As a result, small flickering lines appear on the screen (for more details, see COMPUTE! Books' Mapping the IBM PC and PCjr, pages 193-198).
    This problem can be solved by writing to video memory only during the time when the monitor's raster beam is in vertical retrace, while the display is idle. On some IBM-compatible computers (the Compaq, for example), the problem can be avoided by writing to an inactive page of video memory and then making it the active page. The programs following this article make use of both methods.
    With some computer and graphics card combinations, a few flickering lines remain at the very top of the screen when running the 80-column billboard program. These could have been eliminated, but only at the expense of speed and smoothness. About 300 characters can be written to video memory during the vertical retrace period, and 640 characters (eight lines of 80) need to be written for each screen update. Therefore, to eliminate the flickering lines entirely, we'd have to wait for three vertical retrace periods. These lines are less objectionable than the loss of smoothness caused by waiting for an extra retrace period.

Creating Billboards
Program 1 is for creating billboards on the 40-column screen, and Program 2 is for the 80-column screen. Both programs are extremely easy to use. After typing RUN, simply enter any text string at the prompt. If you want your message to contain a comma, enclose the entire text string in double quotes. When you press ENTER, the message enlarges and begins scrolling. It can be stopped at any time by pressing the Q key.
    The programs can be customized to suit your taste. The character that forms the large letters can be changed from a solid block to another character by changing the DATA statement identified in the listing. For example, to change the solid block to a smiling face, change the DB to 02 in line 300. You can also modify the scrolling speed by changing the two bytes identified in the listing (the second byte has 256 times the effect of the first byte).

How It Works
The techniques used here can be applied to any program that must update a text screen very rapidly, so a brief description of the steps involved may be useful.
1. Set up a buffer in memory equal in size to the block of characters to be written to the screen (8 X 80 for the 80-column billboard).
2. For each input character, access the character PEL map in ROM at FFA6:OE. By columns, depending on whether or not a bit is set, put the code for a solid block or a space into the rightmost column of the buffer array.
3. When a column is complete, scroll the whole buffer one column to the left.
4. Wait for the beginning of a vertical retrace period, then copy the buffer to the inactive screen.
5. Make the inactive screen the active screen.
6. Do the next column in step 2.

For instruction's on entering these listings, please refer to "COMPUTE!'s Guide to Typing In Programs" In this issue of COMPUTE!.

Program 1: 40-Column Billboards

EN 10 ' Forty Column Scrolling
      Billboard
JO 20 '
LJ 30 ' Press the 'IQ" key to qu
      it.
JA 40 '
DI 50 DEF SEG:CLEAR,&H3FFO:N=&H4
      60A
DL 60 FOR J=0 TO 249:READ A$
BB 70 POKE N+J,VAL("&H"+A$):NEXT
FA 80 KEY OFF:CLS:SCREEN 0:WIDTH
       80
GL 90 INPUT"Text string";T$:T$=T
      $+"  "
FF 100 N=&H4000:K=LEN(T$):FOR J=
       1 TO K
LP 110 POKE N,ASC(MID$(T$,J,1)):
       N=N+1
OA 120 NEXT:POKE N,0:CLS:WIDTH 4
       0
JL 130 LOCATE,,0:N=&H460A:CALL N
CC 140 WIDTH 80:CLS:KEY ON-END
E6 150 DATA 06,8B,EC,8C,DB,8E,C0
       ,B9
EN 160 DATA 80,02,8D,3E,08,41,1E
       ,B8
KK 170 DATA 00,88,BE,D8,BE,30,02
       ,F3
BB 180 DATA A4,1F,B8,A6,FF,8E,C0
       ,8D
GG 190 DATA 36,00,40,BA,IC,46,80
       ,FB
JK 200 DATA 00,74,F4,B7,00,D1,E3
       ,DS
KI 210 DATA E3,D1,E3,83,C3,0E,B9
       ,08
FK 220 DATA 00,33,FF,26,BA,07,88
       ,85
GJ 230 DATA 00,41,47,43,E2,F5,56
       ,06
DK 240 DATA B9,09,00,51,33,FF,B9
       ,08
FI 250 DATA 00,BB,4E,00,DO,A5,00
       ,41
NK 260 DATA 72,04,BO,20,EB,02,BO
DF 270 ' The following value is
       the
JF 280 ' ASCII code of character
        that
HE 290 ' forms the large text.
HP 300 DATA DB
JH 310 DATA 88,87,08,41,83,C3,50
       ,47
ON 320 DATA E2,EA,EB,02,EB,B5,8C
       ,DB
CF 330 DATA 8E,C3,FC,BB,08,00,8D
       ,36
EK 340 DATA 0A,41,8D,3E,08,41,B9
       ,4E
FC 350 DATA 00,F3,A4,46,46,47,47
       ,48
NF 360 DATA 75,F4,AO,08,46,34,01
       ,A2
HT 370 DATA 08,46,B4,05,50,A8,01
       ,73
GO 380 DATA 05,BB,00,BB,EB,03,B8
       ,80
GE 390 DATA BB,BE,C0,B9,A0,00,BF
       ,30
HK 400 DATA 02,BD,36,08,41,BA,DA
       ,03
OK 410 DATA EC,A8,08,75,FB,EC,AB
       ,08
GC 420 DATA 74,FB,F3,A5,EB,04,EB
       ,88
JE 430 DATA EB,AA,B9,AO,00,BA,DA
       ,03
OA 440 DATA EC,AB,08,75,FB,EC,AB
       ,08
IJ 450 DATA 74,FB,F3,A5,5B,CD,10
       ,B9
FF 460 ' The following two value
       s are the
FJ 470 ' time delay constant in
       the order
KH 480 ' least sig. byte, most s
       ig. byte.
CP 490 DATA 01,00
AG 500 DATA E2,FE,59,E2,DF,07,5E
       ,B4
AG 510 DATA 06,B2,FF,CD,21,3C,71
       ,74
NN 520 DATA 06,3C,51,74,02,EB,CF
       ,88
FP 530 DATA E5,07,BB,00,05,CD,10
       ,CB

Program 2: 80-Column Billboards

KF 10 ' Eighty Column Scrolling
       Billboard
JO 20 '
LJ 30 ' Press the "Q" key to qu
      it.
JA 40 '
DI 50 DEF SEG:CLEAR,&H3FF0:N=&H4
      60A
HC 60 FOR J=0 TO 250-READ A$
BE 70 POKE N+J,VAL("&H"+A$):NEXT
FA 80 KEY OFF:CLS:SCREEN 0:WIDTH
      80
GL 90 INPUT"Text string";T$:T$=T
      $+"  "
FF 100 N=&H4000:K=LEN(T$):FOR J=
       1 TO K
LP 110 POKE N,ASC(MID$(T$,J,1)):
       N-N+1
HD 120 NEXT:POKE N,0:CLS
JL 130 LOCATE,,0:N=&H460A:CALL N
CC 140 WIDTH 80:CLS:KEY ON:END
EG 150 DATA 06,BB,EC,BC,DB,BE,C0
       ,B9
BH 160 DATA 00,05,BD,3E,08,41,1E
       ,B8
CP 170 DATA 00,BB,BE,DB,BE,60,04
       ,F3
BB 180 DATA A4,1F,BB,A6,FF,8E,C0
       ,8D
GG 190 DATA 36,00,40,8A,1C,46,80
       ,FB
JK 200 DATA 00,74,F4,B7,00,D1,E3
       ,D1
KI 210 DATA E3,D1,E3,83,C3,0E,B9
       ,08
FK 220 DATA 00,33,FF,26,8A,07,88
       ,85
BJ 230 DATA 00,41,47,43,E2,F5,56
       ,06
DK 240 DATA B9,09,00,51,33,FF,B9
       ,08
KI 250 DATA 00,BB,9E,00,D0,A5,00
       ,41
MK 260 DATA 72,04,B0,20,EB,02,B0
OF 270 ' The following value is
       the
JF 280 ' ASCII code of character
        that
HE 290 ' forms the large text.
HP 300 DATA DB
ON 310 DATA 88,87,08,41,81,C3,A0
       ,00
JO 320 DATA 47,E2,E9,EB,02,EB,B4
       ,BC
BE 330 DATA DB,8E,C3,FC,B8,08,00
       ,BD
NE 340 DATA 36,0A,41,81),3E,08,41
       ,B9
CP 350 DATA 9E,00,F3,A4,46,46,47
       ,47
PJ 360 DATA 48,75,F4,A0,08,46,34
       ,01
JD 370 DATA A2,08,46,B4,05,50,AB
       ,01
GK 380 DATA 75,05,B8,00,BB,EB,03
       ,B8
NH 390 DATA 00,B9,BE,C0,B9,40,01
       ,BF
N6 400 DATA 60,04,8D,36,08,41,BA
       ,DA
OF 410 DATA 03,EC,AB,08,75,FB,EC
       ,AB
KO 420 DATA 08,74,FB,F3,A5,EB,04
       ,EB
HC 430 DATA BA,EB,AA,B9,40,01,BA
       ,DA
EL 440 DATA 03,EC,A8,08,75,FB,EC
       ,AB
FI 450 DATA 0B,74,FB,F3,A5,58,CD
       ,10
AF 460 DATA B9
FM 470 ' The following two value
       s are the
FL 480 ' time delay constant in
       the order
LJ 490 ' least sig. byte, most s
       ig. byte.
BO 500 DATA 01,00
BI 510 DATA E2,FE,59,E2,DF,07,5E
       ,B4
BI 520 DATA 06,B2,FF,CD,21,3C,71
       ,74
MP 530 DATA 06,3C,51,74,02,EB,CF
       ,8B
FB 540 DATA E5,07,BB,00,05,CD,10
       ,CB