I'm writing an adventure game and would like to mix text with graphics. Is there any way I can divide the screen to leave four lines at the bottom for text?
Peter Goldstein
You didn't mention which computer you're writing your game on, but we'll assume it's the Commodore 64. The Apple, Atari, IBM, and TI have this capability built into BASIC and require no special programming.
On the 64, the best way to divide the screen into two (or more) parts is to use a programming technique called a raster interrupt. Raster interrupts take advantage of the sequential nature of a video image. The image is painted on the screen by a cathode-ray beam which always begins at the top-left corner and sweeps across the screen left to right. When the beam reaches the right edge of the screen, it's turned off for a split second and returned to the left side of the screen. Then the beam is dropped down one line and the process is repeated. When it finally reaches the bottom-right corner of the screen, it's switched off again and returned to the starting position at the upper-left corner. The entire cycle repeats 60 times a second.
On the Commodore 64, you can determine which horizontal line the beam is currently scanning by reading the raster register at location $D012 (53266). With this information in hand, you can write a program to interrupt the process so you can insert a few lines of text or change screen colors.
However, this takes some advanced programming. The raster interrupt can't be accessed directly from BASIC, because BASIC must be turned off to insert a vector to your interrupt routine.
Here's a demonstration program which loads a machine language routine into memory and allows you to change screen colors and split the screen. To use this routine in your own programs, simply change lines 20 through 50 to define the variables to suit your needs.
10 GOSUB130 :rem 117
20 INPUT"SELECT TOP SCREEN COLOR: ";A :rem 222
30 INPUT"SELECT BOTTOM SCREEN COLOR: ";B
:rem 194
40 PRINT"WHAT ROW FOR SCREEN DIVISION?"
:rem 172
50 INPUTC:IFC<1ORC>23THENPRINT"VALID RANG
E IS 0-23{2 SPACES}RE-ENTER":GOTO40
:rem 140
60 SYS49152 :rem 106
70 POKE829,A:REM SET TOP SCREEN COLOR :rem 226
80 POKE830,B:REM SET BOTTOM SCREEN COLOR
:rem 190
90 POKE831,21: REM TOP SCREEN UPPERCASE/G
RAPHICS :rem 188
100 POKE832,23:REM BOTTOM SCREEN LOWER CA
SE :rem 70
110 POKE828,50+C*8:REM SET DIVIDING POINT
:rem 166
120 STOP :rem 217
130 CK=0:FORI=49152TO49247:READA:CK=CK+A:
POKEI,A:NEXT:IFCK=10244THENRETURN :rem 180
140 PRINT"{RVS}ERROR IN DATA STATEMENTS":
STOP :rem 59
150 DATA120,169,127,141,13,220 :rem 231
160 DATA169,1,141,26,208,173 :rem 145
170 DATA60,3,141,18,208,169 :rem 96
180 DATA27,141,17,208,169,34 :rem 151
190 DATA141,20,3,169,192,141 :rem 141
200 DATA21,3,88,96,173,18 :rem 1
210 DATA208,205,60,3,208,28 :rem 87
220 DATA169,0,141,18,208,173 :rem 142
230 DATA64,3,141,24,208,173 :rem 89
240 DATA62,3,141,33,208,169 :rem 93
250 DATA1,141,25,208,104,168 :rem 137
260 DATA104,170,104,64,173,60 :rem 187
270 DATA3,141,18,208,173,61 :rem 93
280 DATA3,,141,33,208,173,63 :rem 93
290 DATA3,141,24,208,169,1 :rem 43
300 DATA141,25,208,76,49,234 :rem 147
For a thorough discussion on using raster interrupts, see "Split Screens" and "Son of Split Screens" by Jim Butterfield in COMPUTE!'s First Book of Commodore 64.