The Computer Tutor: Floating Screen Memory Map, Part 2

Author(s): Gene G. Buza
Publication: Synchro-Sette
Pub Details: Synchro-Sette v2 n7 (Volume 2, Issue 7)
Date: August 1983
Pages: 7-8
the Computer Tutor heading - FLOATING SCREEN MEMORY MAP - Part 2 - with cartoon of a professor pointing at a computer in a waste basket
the Computer Tutor heading – FLOATING SCREEN MEMORY MAP – Part 2 – with cartoon of a professor pointing at a computer in a waste basket

Greetings Class! I’m surprised to see so many of you here. Isn’t this heat something? We’ll try to keep today’s lesson short.

Perhaps you experimented with the effects demonstrated in the last session. To review that lesson, we can recall that the versions of the ZX/TS computers with at least 16K of RAM memory have the capability to directly correlate what is happening on the screen with what is happening in certain portions of the computer’s random access memory locations.

This is, of course, true with most computers – but, unlike most other computers, the RAM area that holds the screen information is not stationary or in the same place all the time. The location of this RAM area is in direct proportion to the size of the program residing in memory at that time.

Hence-forth, we say that the map or screen co-ordinate positions, float.

We have seen how we could take advantage of this knowledge by writing a routine that would copy the contents of the screen directly to the printer – INCLUDING THE BOTTOM TWO LINES.

In today’s lesson, I would like to demonstrate moving graphics in the form of a game where the keyboard directly correlates the contents of the screen.

In the past, you may have seen games written in BASIC where the user fires a projectile at a moving object. While the projectile is in flight, the object stops and waits for the projectile to hit it or go by. Many people have asked me, “why not make the game more difficult and have the object and projectile move at the same time?”.

Routines can easily be written to make this happen. Does anyone know why it usually isn’t done? Yes, the gentleman in the rear has his hand up?

He says that it is because the two objects are moving at right angles to each other and any routine would have difficulty correlating their positions to tell when a “hit” occurs.

As usual, the answer is totally incorrect!

The real reason is that the double movement slows down the movement process where the flight simulation takes a longer period of time. By POKEing and PEEKing the screen, this process can be speeded up somewhat. Enter the following program:

  10 LET S=0
20 GOSUB 5000
30 LET I=743
40 LET A=0
50 LET G=0
1000 REM LEFT TO RIGHT
1005 FOR N=398 TO 427
1010 LET A$=INKEY$
1020 IF A$<>"" THEN LET A=1
1030 GOSUB 6000
1035 POKE XX+N-1,0
1040 POKE XX+N,128
1060 NEXT N
1070 LET G=G+1
1080 IF G>10 THEN GOTO 8000
1090 PRINT AT 1,20;"PASSES = ";G
;" "
1100 REM RIGHT TO LEFT
1110 FOR N=427 TO 398 STEP -1
1120 LET A$=INKEY$
1130 IF A$<>"" THEN LET A=1
1140 GOSUB 6000
1145 POKE XX+N+1,0
1150 POKE XX+N,128
1170 NEXT N
1180 LET G=G+1
1190 IF G>10 THEN GOTO 8000
1200 PRINT AT 1,20;"PASSES = ";G
;" "
1210 GOTO 1000
5000 REM FIND SCREEN LOCATION
5010 LET XX=PEEK 16396+256*PEEK
16397
5020 RETURN
6000 REM SHOOTER ROUTINE
6010 IF A=0 THEN RETURN
6020 IF PEEK (XX+I)=128 THEN GOT
O 7000
6030 POKE XX+I,136
6040 POKE XX+I+33,0
6060 LET I=I-33
6070 IF I>50 THEN RETURN
6080 LET A=0
6090 POKE XX+33+I,0
6100 LET I=743
6110 LET G=G+1
6120 RETURN
7000 REM BLOWUP ROUTINE
7001 PAUSE 10
7005 FOR N=1 TO 10
7010 POKE XX+I-34,128
7020 POKE XX+I-33,0
7030 POKE XX+I-32,128
7040 POKE XX+I+1,0
7050 POKE XX+I+34,128
7060 POKE XX+I+33,0
7070 POKE XX+I+32,128
7080 POKE XX+I-1,0
7090 POKE XX+I-34,0
7100 POKE XX+I-33,128
7110 POKE XX+I-32,0
7120 POKE XX+I+1,128
7130 POKE XX+I+34,0
7140 POKE XX+I+33,128
7150 POKE XX+I+32,0
7160 NEXT N
7170 CLS
7180 LET S=S+1
7190 LET I=743
7200 LET A=0
7210 LET G=G+1
7220 IF G>10 THEN GOTO 8000
7230 GOTO 1000
8000 REM SCORE DISPLAY
8005 PRINT AT 1,0;"SCORE = ";S*1
0
8010 PAUSE 40000
8020 CLS
8030 RUN
9998 SAVE "XXX"
9999 RUN

The trick to getting the most speed is to have the least amount of program lines in the FOR/NEXT loops while the INKEY$ is in effect. The program has all of it’s routines categorized with REMarks. The “XX” variable from the 5000 routine determines the screen’s location.

The 1000 and 1100 routines provide the movement of the object by POKEing the screen location with the code 128 and POKEing the location where the object appeared previously with a 0 which erases the old object. Therefore, the illusion of movement is achieved.

By following the logic of the program, you will notice that although all of the moving graphics are POKEd to the screen, in line 6020, the single PEEK in the program occurs where if the next location that the projectile is about to enter has a “128” (the character code for the moving graphic block) in it, the program will branch to the 7000 routine which provides the “blow-up” graphics.

The “shooter” routine starting with line 6000 works pretty much the same way as the 1000/1100 routines work except to provide vertical movement rather than horizontal.

I’m going to let you out early today but I do want you to consider this homework assignment!

Write a routine that would allow only a certain portion of the screen to be copied to the printer. This routine should allow the user to set the co-ordinates of what portion of the screen is to be copied.

Class dismissed!

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.