--- title: "Surround" type: "article" slug: "surround" url: "http://localhost/article/surround/" markdown_url: "http://localhost/article/surround.md" published_at: "2020-10-27T17:09:18+00:00" modified_at: "2026-06-21T23:36:58+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "You will probably recognize Surround as soon as you RUN it. It is a version of a fairly standard routine in which you are required to surround your adversary before he can surround you. Both players are in continuous motion and are not allowed to cross their tracks or those of their opponent, or to…" category: - name: "Timex Sinclair User" slug: "timex-sinclair-user" taxonomy: "category" url: "http://localhost/category/periodicals/timex-sinclair-user/" post_tag: - name: "1983" slug: "year-1983" taxonomy: "post_tag" url: "http://localhost/tag/year-1983/" - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "Full Text" slug: "fulltext" taxonomy: "post_tag" url: "http://localhost/tag/fulltext/" - name: "TS 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" - name: "Type-in program" slug: "type-in-program" taxonomy: "post_tag" url: "http://localhost/tag/type-in-program/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" indiv: - name: "J Winchester" slug: "j-winchester" taxonomy: "indiv" url: "http://localhost/indiv/j-winchester/" publication: "Timex Sinclair User" publication_r: id: 10278 title: "Timex Sinclair User" type: "periodical" url: "http://localhost/periodical/timex-sinclair-user/" authors: "J Winchester" volume: "1" issue: "2" issues_articles: - id: 26867 title: "Timex Sinclair User n2" type: "issue" url: "http://localhost/issue/timex-sinclair-user-n2/" pages: "37" pubdate: "July 1983" download: "http://localhost/wp-content/uploads/2023/04/Surround.P.zip" archive_link: false volumeissue: "v1n2" article_media: - id: 57245 title: "Surround" type: "computer_media" url: "http://localhost/computer_media/surround/" --- # Surround You will probably recognize Surround as soon as you RUN it. It is a version of a fairly standard routine in which you are required to surround your adversary before he can surround you. Both players are in continuous motion and are not allowed to cross their tracks or those of their opponent, or to hit the boundary or the score display. What will surprise you is the way in which the T/S1000/ZX81 can recognize two keys when pressed simultaneously. That is not possible using INKEY$ and is achieved by utilizing address 16421. This contains a number which changes as groups of keys are pressed. Lines 185 to 260 translate the number into a series of possible moves. Black uses keys 1-5 to move up, Z-V to move down, Q-T for right and A-G for left. Grey uses the keys 6-0 for up, Y-P for right, B-M for down, and H-ENTER for left. After a crash the other player scores one; the winner is the first to reach 15, The routine enabling two players to participate can obviously be used in many graphics games. (T/S1000/ZX81 16K) ## Source Code: Surround ``` 1 REM SURROUND 2 REM BLACK 1-5 UP,Z-V DOWN,Q-T RIGHT,AG LEFT. 3 REM GREY 6-0 UP,Y-P RIGHT,B-M DOWN; H-ENTER LEFT. 5 LET SX=0 6 LET SB=0 7 LET O=PEEK 16396+256*PEEK 16397 10 POKE 16418,0 20 PRINT AT 0,0;"++++++++++++++++++++++++++++++++" 30 FOR P=1 TO 22 40 PRINT "+ +" 50 NEXT P 60 PRINT ;"++++++++++++++++++++++++++++++++" 70 PRINT AT 2,2;STR$ SX;AT 2,28;STR$ SB 80 LET X=12 90 LET Y=3 100 LET B=12 110 LET C=28 120 LET X1=0 130 LET Y1=1 140 LET B1=0 145 LET C1=-1 150 IF PEEK (O+1+Y+33*X)<>0 THEN GOTO 400 160 IF PEEK (O+1+C+33*B)<>0 THEN GOTO 300 170 PRINT AT X,Y;CHR$ (128);AT B,C;CHR$ (136) 180 LET A=PEEK 16421 185 IF A=238 OR A=222 OR A=190 OR A=254 OR A=126 THEN LET X1=1 190 IF A=247 OR A=231 OR A=215 OR A=183 OR A=119 THEN LET X1=-1 200 IF X1<>0 THEN LET Y1=0 210 IF A=235 OR A=251 OR A=219 OR A=187 OR A=125 THEN LET Y1=1 215 IF A=237 OR A=221 OR A=253 OR A=189 OR A=125 THEN LET Y1=-1 220 IF Y1<>0 THEN LET X1=0 230 IF A=231 OR A=239 OR A=235 OR A=237 OR A=238 THEN LET B1=-1 235 IF A=119 OR A=123 OR A=125 OR A=126 OR A=127 THEN LET B1=1 240 IF B1<>0 THEN LET C1=0 245 IF A=215 OR A=219 OR A=223 OR A=221 OR A=222 THEN LET C1=1 250 IF A=183 OR A=187 OR A=189 OR A=191 OR A=190 THEN LET C1=-1 260 IF C1<>0 THEN LET B1=0 270 LET X=X+X1 280 LET Y=Y+Y1 290 LET B=B+B1 295 GOTO 150 300 LET SX=SX+1 310 IF SX<15 THEN GOTO 7 320 STOP 400 LET SB=SB+1 410 IF SB<15 THEN GOTO 7 500 SAVE "1013%5" 600 RUN ```