Survive - a Mode 7 game

reminisce about bbc micro & electron games like chuckie egg, repton, elite & exile

Related forum: adventures


User avatar
MartinB
Posts: 4566
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Survive - a Mode 7 game

Postby MartinB » Sun Apr 05, 2015 4:54 pm

I actually posted this on STH back in about 2008 I think but there are new people to bore with it now... :wink:

It's a simple Mode 7 game I wrote as a lunchtime project back in 1987 and for a laugh, I sent it to Micro User who published it in the August 87 issue and paid me £60 for the privilege :shock:. It's a bit like the snake stay-alive games but here there is a computer opponent also looking for space (the original also supported two human players) and my motivation was a challenge from a work colleague of the time regarding my being able to write an algorithm that would on average beat a human player.

On topic, the game just uses the Mode 7 block graphic and full line colour codes and it is basically a straight screen memory ($7C00 - $7FFF) peeker and poker, largely written in Basic but with the computer opponent algorithm written in assembler for speed. Might be useful for someone wanting to write a Mode 7 game to take apart and see how a very crude game can be written. <Shift><Break> to run.

Image

survive.zip
(3.36 KiB) Downloaded 56 times
Attachments
survive.JPG
(15.56 KiB) Not downloaded yet

User avatar
aerworuld
Posts: 1689
Joined: Tue Sep 25, 2012 8:40 pm
Location: Basingstoke, Hampshire
Contact:

Re: Mode 7 Teletext Graphics font

Postby aerworuld » Mon Apr 06, 2015 9:57 am

MartinB wrote: (the original also supported two human players)


this is great fun, Martin!

Is the two-player version still available?

Stuart :-)

User avatar
MartinB
Posts: 4566
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Re: Mode 7 Teletext Graphics font

Postby MartinB » Mon Apr 06, 2015 4:50 pm

Yes Stuart, I do have the original (or you could type it in from TMU August 87 :shock: :wink: ) but unless you're planning on using it on a real Beeb, I think I'll need to change the keys. (The two-player layout isn't good for a PC.)

galax
Posts: 103
Joined: Mon Jul 21, 2014 3:58 pm

.

Postby galax » Mon Apr 06, 2015 11:43 pm

.
Last edited by galax on Thu Jun 04, 2015 4:41 am, edited 1 time in total.

User avatar
aerworuld
Posts: 1689
Joined: Tue Sep 25, 2012 8:40 pm
Location: Basingstoke, Hampshire
Contact:

Re: Survive - a Mode 7 game

Postby aerworuld » Tue Apr 07, 2015 5:52 am

me being me :shock: i thought i would see if Survive! would run on my Elk with the Jafa Mode 7 sim on.

Survive!_1.jpg
Welcome screen


The game loads fine and the game itself begins, you hear all the noises but the screen refresh on simulated Mode 7 is too slow and you are dead before the screen updates. Still at least you do eventually get to see your pretty patterns :lol:

Survive!_2.jpg
oops.


I tried it on the Elk in Normal, 64k and Turbo but it says no thankyou :roll:

Still, I will keep playing it in the emulator; this is a goodun!

Stuart :-)

User avatar
MartinB
Posts: 4566
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Re: Survive - a Mode 7 game

Postby MartinB » Tue Apr 07, 2015 7:07 am

Thanks Dave for the admin service, much appreciated.... =D> 8)

galax wrote:Survive's collision detection is interesting- not sure if it's intentional but the two players can actually cross streams if they both occupy the same location at the same time (should be a draw?), or if one crosses just in front of the other. Also one player can follow the other, one character behind, without a collision being detected!

Yep, it's intentional! When I wrote Survive, I based it loosely on an arcade game which was essentially the same (no idea of the name now) and in that version, the trails were allowed to cross if they were coincident. You were also able to travel immediately behind your opponent but again, only if the two players were perfectly offset in trail by one player position. Therefore, I initially embodied that same behaviour in Survive and amongst my local testers of the time, it was deemed a good feature, there to be tactically exploited if you were skilful enough.

I sent it to TMU with the write-up and when I spoke to them on the phone, they said they loved the game (the two-player version in particular was allegedly stopping any work from getting done :shock:) and they too liked the crossing feature - indeed, it is explicitly pointed out in the game description.....
Survive TMU August 87.JPG


Stuart - I wouldn't have expected much joy from the Elk Mode 7 sim I'm afraid, I think this is one game that would require a significant re-write in another mode before it could be Elk-friendly :(

I'll get the two-player version up later but before I do, what do people think would be two good sets of keys for a PC? (From a two-people, four-hands ergonomics perspective?)

These were the Beeb originals but they don't really work for a PC....

Survive two-player version keys.png

User avatar
aerworuld
Posts: 1689
Joined: Tue Sep 25, 2012 8:40 pm
Location: Basingstoke, Hampshire
Contact:

Re: Survive - a Mode 7 game

Postby aerworuld » Tue Apr 07, 2015 8:27 am

how about:

Selection_002.png
(10.96 KiB) Not downloaded yet


Stuart ;-)

ps: had to take a screenshot of the keys to make them look right on my screen lol

galax
Posts: 103
Joined: Mon Jul 21, 2014 3:58 pm

.

Postby galax » Tue Apr 07, 2015 8:33 am

.
Last edited by galax on Thu Jun 04, 2015 4:41 am, edited 1 time in total.

User avatar
MartinB
Posts: 4566
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Re: Survive - a Mode 7 game

Postby MartinB » Tue Apr 07, 2015 10:27 pm

Here's an ssd and listing of the originally published game which has the choice of one or two-players and also has 5 skill levels. I'm not sure why I changed to 3 skill levels when I first posted the one-player-only game on here, maybe I just thought that 5 weren't necessary... :-k

Anyway, regarding suitable key-sets for two players, these aren't really any use for a PC but should be fine on a real Beeb. Rather than me messing about, if anyone fancies figuring out some good keys for two human players under PC emulation, the key scans are in lines 580-690 and the corresponding intro screen depictions of the keys are in lines 1100-1120. Feel free to publish a version with revised keys 8)

keys.png


survive original.zip
(2.08 KiB) Downloaded 40 times


Code: Select all

   10 REM Survive
   20 REM By Martin Barr
   30 REM(c) The Micro User 1987
   40 ONERRORGOTO 1480
   50 MODE7
   60 PROC_ass
   70 PROC_oneortwo
   80 VDU23;&200A;0;0;0;
   90 sc1%=0:sc2%=0:d=RND(-TIME)
  100 REPEAT
  110 PROC_init
  120 FORd=0TO2000:NEXT
  130 REPEAT
  140 SOUND&11,-1,140,1
  150 M%=M%+1
  160 TIME=0
  170 IFcomp% PROC_compdir2:IFd2%<>lastd2% prevd2%=lastd2%
  180 lastd1%=d1%:lastd2%=d2%
  190 REPEAT
  200 PROC_dir1
  210 IF NOT comp% PROC_dir2
  220 UNTIL TIME>DL%
  230 IF d1%=-lastd1% THEN d1%=lastd1%
  240 IF d2%=-lastd2% THEN d2%=lastd2%
  250 PROC_hit1
  260 PROC_hit2
  270 PROC_mov1
  280 PROC_mov2
  290 UNTIL hit1% OR hit2%
  300 SOUND0,-10,85,2
  310 IFhit1% winner$="Player O Wins !"ELSE winner$="Player X Wins !"
  320 IF(hit1% AND hit2%) winner$=" It's a Draw ! "
  330 tb=?&7C00-16:IF tb<135 tf=tb+1 ELSE tf=129
  340 bb=?&7FC0-16:IF bb<135 bf=bb+1 ELSE bf=129
  350 PRINTTAB(0,0)CHR$(tb)CHR$(157)CHR$(tf)SPC(10)winner$;SPC(12)
  360 sc1%=sc1%+ABS(hit2%)
  370 sc2%=sc2%+ABS(hit1%)
  380 PRINTTAB(0,24)CHR$(bb)CHR$(157)CHR$(bf)SPC(3)"Player X = ";sc1%;SPC(3)"Player O = ";sc2%;SPC(39-POS);:?&7FE7=32
  390 REPEAT UNTIL INKEY-99
  400 UNTIL FALSE
  410 END
  420 DEFPROC_init
  430 CLS:pc=0
  440 FORd=&7C00 TO &7FC0 STEP 40
  450 REPEAT:nc=RND(7)+144:UNTIL nc<>pc
  460 pc=nc:?d=nc:NEXT
  470 FORd=&7C01 TO &7C27:?d=&FF:NEXT
  480 FORd=&7C01 TO &7FC0 STEP40:?d=&FF:NEXT
  490 FORd=&7FC1 TO &7FFF:?d=&FF:NEXT
  500 FORd=&7C27 TO &7FFF STEP40:?d=&FF:NEXT
  510 p1%=&7C00+(40*RND(22)+1)+RND(16)+1
  520 p2%=&7C00+(40*RND(22)+1)+RND(16)+22
  530 d1%=1:lastd1%=1:hit1%=FALSE:hit2%=FALSE
  540 d2%=-1:lastd2%=-1:prevd2%=-1:FF%=&FF
  550 X%=ASC"X":O%=ASC"O":?p1%=X%:?p2%=O%
  560 testm%=0:testp%=0:M%=0
  570 ENDPROC
  580 DEFPROC_dir1
  590 IFINKEY-82THENd1%=-40
  600 IFINKEY-98THENd1%=40
  610 IFINKEY-2THENd1%=1
  620 IFINKEY-65THENd1%=-1
  630 ENDPROC
  640 DEFPROC_dir2
  650 IFINKEY-41THENd2%=-40
  660 IFINKEY-89THENd2%=40
  670 IFINKEY-104THENd2%=1
  680 IFINKEY-103THENd2%=-1
  690 ENDPROC
  700 DEFPROC_hit1
  710 IF?(p1%+d1%)=FF% THENhit1%=TRUE
  720 ENDPROC
  730 DEFPROC_hit2
  740 IF?(p2%+d2%)=FF% THENhit2%=TRUE
  750 ENDPROC
  760 DEFPROC_mov1
  770 ?p1%=FF%:p1%=p1%+d1%:?p1%=X%
  780 ENDPROC
  790 DEFPROC_mov2
  800 ?p2%=FF%:p2%=p2%+d2%:?p2%=O%
  810 ENDPROC
  820 DEFPROC_compdir2
  830 IF?(p2%+d2%)=FF% THEN PROC_crash:ENDPROC
  840 IF?(p2%+d2%+d2%)=FF% AND M%>40 THEN PROC_change:ENDPROC
  850 IFM%>50 ENDPROC
  860 IFlastd1%<>d1%PROC_change:ENDPROC
  870 ENDPROC
  880 DEFPROC_change
  890 PROC_space
  900 IFtestp%=testm% THEN ENDPROC
  910 IFtestp%>testm% THENd2%=DX% ELSEd2%=-DX%
  920 ENDPROC
  930 DEFPROC_crash
  940 PROC_space
  950 IFtestp%=1 THENd2%=-DX%:ENDPROC
  960 IFtestm%=1 THENd2%=DX%:ENDPROC
  970 IF(testp%=2)AND(testm%=2) THENd2%=prevd2%:ENDPROC
  980 IFtestp%=testm% THENd2%=DX%:ENDPROC
  990 IFtestp%>testm% THENd2%=DX% ELSEd2%=-DX%
  995 ENDPROC
 1000 DEFPROC_space
 1010 ?&70=p2% MOD 256:?&71=p2% DIV 256
 1020 ?&72=ABS(d2%)
 1030 CALL spm%
 1040 testp%=?&73:testm%=?&74:DX%=?&76
 1050 ENDPROC
 1060 DEFPROC_oneortwo
 1070 CLS
 1080 FORd=0TO1:PRINTCHR$157CHR$131TAB(11,0+d)CHR$141CHR$129"* Survive! *":NEXT
 1090 PRINT""
 1100 PRINTSPC(10)"S"SPC(17)"£"
 1110 PRINTSPC(4)"CLOC"CHR$136" x"CHR$137" CTRL"SPC(8)"<"CHR$136" o"CHR$137">"
 1120 PRINTSPC(10)"Z"SPC(17)"]"
 1130 PRINTTAB(8,17)CHR$130"One or Two Players ? ";
 1140 REPEAT UNTIL INKEY-49 OR INKEY -50
 1150 IFINKEY-49 comp%=TRUE ELSE comp%=FALSE
 1160 IFcomp% PRINT"1" ELSE PRINT"2"
 1170 PROC_skill
 1180 ENDPROC
 1190 DEFPROC_ass
 1200 DIM spm% 200
 1210 FORd=0TO2 STEP 2
 1220 P%=spm%
 1230 [OPTd
 1240 LDA&70:STA&77:LDA&71:STA&78
 1250 LDY#0:STY&73:STY&74
 1260 LDX#40:LDA&72:CMP#1:BEQ a:LDX#1
 1270 .a STX&76:.LOOP1 LDA&76:CLC:ADC&77
 1280 STA&77:BCC b:INC&78:.b INC&73
 1290 LDA(&77),Y:CMP#&FF:BNE LOOP1
 1300 LDA&70:STA&77:LDA&71:STA&78
 1310 .LOOP2 LDA&77:SEC:SBC&76:STA&77
 1320 BCS c:DEC&78:.c INC&74:LDA(&77),Y
 1330 CMP#&FF:BNE LOOP2
 1340 RTS
 1350 ]
 1360 NEXT
 1370 ENDPROC
 1380 DEFPROC_skill
 1390 PRINTTAB(8)CHR$130"Skill Level  (1-5) ? ";
 1400 a$="12345!#$%"+CHR$(34)
 1410 REPEAT
 1420 *FX15,0
 1430 sk$=GET$
 1440 UNTIL INSTR(a$,sk$)
 1450 sk$=CHR$(ASC(sk$)OR&10)
 1460 DL%=3*(5-VAL(sk$))
 1470 ENDPROC
 1480 IF ERR=17 THEN RUN
 1490 MODE 6:REPORT:PRINT" at line "ERL
 1500 END
>

RobC
Posts: 1858
Joined: Sat Sep 01, 2007 9:41 pm

Re: Survive - a Mode 7 game

Postby RobC » Thu Apr 09, 2015 7:31 pm

This takes me back - I still have the original magazine that it appeared in and remember typing it in :D

Pretty sure I bought the magazine at a motorway service station on the way to Alton Towers!

User avatar
roland
Posts: 2836
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Survive - a Mode 7 game

Postby roland » Fri Apr 10, 2015 3:44 pm

Can somebody convert it to an Atom with Godil and BBC Basic? Probably only the screen poking has to be changed... Then it will be the first Atom BBC Basic game AFAIK 8)
256K + 6502 Inside
MAN WOMAN :shock:

User avatar
MartinB
Posts: 4566
Joined: Mon Mar 31, 2008 9:04 pm
Location: Obscurity

Re: Survive - a Mode 7 game

Postby MartinB » Fri Apr 10, 2015 10:39 pm

RobC wrote:This takes me back - I still have the original magazine that it appeared in and remember typing it in :D
I find that somehow quite surreal - nearly 30 years down the line to encounter someone who actually typed in and played the game at the time :shock: =D> 8)

Roland wrote:Can somebody convert it to an Atom with Godil and BBC Basic?
I think that should be easy for someone who knows the Atom, I don't even have one I'm afraid but it would be an honour for Survive to take the accolade you alluded to... :D

Survive uses the Beeb Mode 7 (Teletext) screen but there are only a few assumptions therein...

  • 1000 directly addressable screen cells arranged as 40 columns x 25 lines.
  • A complete line of 24 character cells can be set to one solid colour (specifically any 'on' or non-black pixels within each cell in the screen line) by poking a set-colour value into the first cell of that 25 cell line.
  • A screen cell whose contents are 0 (zero) will be black.
  • Poking a value of $FF (255) into a given screen cell address sets every pixel in that cell giving a full block character. (Adjacent blocks have no vertical or horizontal gaps.)
  • The two player characters can be displayed by poking a symbol value (here Ascii 'x' and Ascii 'o') into a cell and can be erased by simply over-poking a trail block character (here $FF as per the borders.)

The Beeb Mode 7 screen layout and addresses look like this....

Survive Mode 7 screen memory.jpg


The only absolute screen address references in the Survive code occur in the initialisation procedure, DEFPROC_init, program lines 420-570. Here, the border is drawn by poking $FF into the rectangle of cells that constitute the play area boundary (shown in green above) and at the start of each screen row, the 25 cells (shown in pink above) are poked with a random Teletext set-colour value ensuring no that adjacent row colour repeats. The only other absolute address reference is used to give each player (p1% and p2%) a random start position within the central playing area inside the border. Thereafter, there are no other absolute references, all the dynamic play being determined either by offsets (-1, +1, -40, +40) or by peeking for zero (blank cells) and $FF for the border or the player trails.

Some Teletext print codes are used on the intro screen (e.g. Double Height) but this is just trivia and the cursor is turned off with a VDU23 statement in line 80.

The assembler code is dynamically allocated with a DIM spm% 200.

So, an absolute breeze then.... \:D/ :-D :wink:


Return to “software: classic games”

Who is online

Users browsing this forum: No registered users and 4 guests