home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1984 May
/
1984-05.d64
/
supersprite
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
7KB
|
207 lines
10 rema:
20 :
21 rem list of variables
22 rem sp sprite page
23 rem v base of video chip
24 rem c base of colour ram
25 rem sd base of sound chip
26 rem s base of screen
27 rem hs byte to save high score
28 rem ch kernal print routine (chrout)
29 rem ar image of accumulator register
30 rem bs best score yet at runtime
31 rem zs old screen base and char set
32 rem zc old background colour
33 rem ze old border colour
34 rem zr old value of repeat flag
35 rem zl old print colour
36 rem gl turn number in game loop
37 rem i and j for-next indices
38 rem u, u2 and u$ workhorses
39 rem t1-t9 constants in game loop
40 rem b$ game screen building block
41 rem t$ 16 space indent
42 rem w either v or v+1 (sprite pos.)
43 rem ps part-score (one turn)
44 rem ts total score so far
45 rem fq quit flag, set by pressing *
46 :
47 rem subroutines
48 rem 1000 one turn of the game
49 rem 2000 print game screen
50 rem 3000 exit (or play again)
51 rem 4000 build sprite
52 rem 5000 instructions data strings
53 rem 6000 print instructions
54 rem 7000 fly sprite ahead of instr.
55 rem 8000 wait to resume game
56 :
100 rem seed random number generator, disable character set shifts
110 u=rnd(-ti):poke657,128
120 rem save old environment, build new one, build sprite, print instructions
130 sp=13:v=53248
140 poke2041,peek(v+24):pokev+24,22
150 poke2042,peek(v+32):pokev+32,7
160 poke2043,peek(v+33):pokev+33,7
170 poke2044,peek(646):poke646,0
180 poke2045,peek(650):poke650,128
190 print"[147]":gosub4000
200 gosub6000:print"[147]":pokev+24,20
210 deffnsc(u)=int(u+u*gl/10)
220 fori=1to16:t$=t$+"":nexti
230 b$=""+chr$(13)+"":fori=0to39:b$=b$+" ":nexti
240 v=53248:c=55296:s=1024:sd=54272
250 hs=peek(43)+peek(44)*256+5
260 t1=135:t2=255:t3=230:t4=133
270 t5=5:t6=9:t7=.992:t8=42:t9=32
280 bs=peek(hs):ch=65508:ar=780
290 rem initialize cursors, print game screen
300 e(1)=1269:e(2)=1475:e(3)=1682:e(4)=1888
310 pokev+21,0:gosub2000
320 rem make space for score on screen, set sound chip, clear keyboard buffer
330 fori=1080to1100:pokei,32:next
340 pokesd+4,16:pokesd+11,16:pokesd+18,16
350 pokesd+6,240:pokesd+13,240:pokesd+20,240
360 pokesd+24,15
370 geta$:ifa$<>""then370
380 :
390 rem begin 20-turn game loop,set part score to zero
400 forgl=1to20:ps=0
410 rem position sprite, unexpand it, zero the collision detect register
420 pokev,23:pokev+1,49
430 pokev+23,0:pokev+31,0
440 rem print score info, turn on sound
450 print""t$"turn:"gl" score:"ts
460 print""t$"best yet:"peek(hs)-1
470 pokesd+4,17:pokesd+11,17:pokesd+18,17
480 rem turn on sprite, take 1 turn, goto 570 if game aborted (fq set)
490 pokev+21,1:gosub1000:iffq=1then550
500 rem scroll sprite off screen if no collision, otherwise screech to a halt
510 ifpeek(v+1)>t3thenfori=peek(v+1)to250:pokev+1,i:nexti:goto550
520 pokesd+4,129:pokesd+11,33:pokesd+18,33
530 for i=72to20step-2:pokesd+1,i:pokesd+8,i-3:pokesd+15,i-2:nexti
540 rem turn off sound. jump to exit if fq set
550 pokesd+4,16:pokesd+11,16:pokesd+18,16
560 pokesd+1,0:pokesd+8,0:pokesd+15,0
570 iffq=1thenfq=0:gl=20:next:pokev+21,0:goto670
580 rem calculate part score from sprite y position, modify, add to total score
590 ps=fnsc(int((peek(v+1)-71)/40))
600 ts=ts+int((ps^1.4+ps)/2)
610 pokev+21,0:pokev+16,0
620 nextgl
630 rem update high score record, zero sound chip, go to exit (3000)
640 ifpeek(hs)<ts+1thenpokehs,ts+1
650 fori=0to24:poke sd+i,0:nexti
660 fori=1to500:nexti
670 gosub3000:clr:goto210
680 :
970 rem subroutine--one turn of the game
980 :
990 rem decide which sprite position register to alter (w) and by how much (u)
1000 u2=rnd(1):w=v+int(u2*2):u=gl/7+2
1010 rem y-expand sprite if expression true
1020 ifu2>t7andpeek(v+1)<t1thenpokev+23,1
1030 rem set msb of sprite x-position if necessary
1040 ifpeek(w)+u>t2thenpokev+16,1:pokev,peek(v)+u-t2:goto1070
1050 rem update sprite position. exit if collision detected or 4th gap crossed
1060 pokew,peek(w)+u
1070 if(peek(v+31)and1)orpeek(v+1)>t3thenreturn
1080 rem change frequencies according to sprite y position and random number u2
1090 u=232-peek(v+1):pokesd+1,u*2/3:pokesd+8,u+3*u2:pokesd+15,u+3
1100 rem poll keyboard. exit on *; pause on ' '; goto1000 if not a function key
1110 sysch:u=peek(ar):ifu=t8thents=0:fq=1:return :rem exit
1120 ifu=t9thengosub8000:rem take 5
1130 ifu<t4then1000:rem input<f1
1140 rem move line right if key not shifted (1120), left if shifted (1140)
1150 u=u-132:ifu<t5then1180:rem input f1-f4
1160 ifu<t6then1200:rem input f5-f8
1170 goto1000:rem input>f8
1180 e(u)=e(u)+(e(u)=1100+200*u-(u>2)):pokee(u),223:pokee(u)-1,160
1190 poke e(u)+4+(u>2),32:pokee(u)+5+(u>2),95:e(u)=e(u)+1:goto1000
1200 u=u-4:e(u)=e(u)-(e(u)=1064+200*(u)):pokee(u)+3+(u>2),95
1210 pokee(u)+4+(u>2),160:pokee(u)-1,32:pokee(u)-2,223:e(u)=e(u)-1:goto1000
1970 rem subroutine--print game screen
1980 :
1990 rem line colours set in line 2000. last colour is for printed messages
2000 print"[147][156]"b$""b$"[154]"b$"[150]"b$"[144]"
2010 fori=1to4:pokee(i)-1,223:pokee(i)+3-(i<3),95:forj=e(i)toe(i)+2-(i<3)
2020 pokej,32:nextj,i:return
2030 :
2980 rem subroutine--exit or re-entry
2990 :
3000 print"[147]"t$"your score:"ts
3010 print""t$"best yet:";peek(hs)-1
3020 print"play again (y/n)?
3030 [161]a$:[139]a$[178]""[167]3030
3040 [139]a$[178]"y"[167][142]
3050 [139]a$[178]"n"[167]3070
3060 [137]3030
3070 [139] [168](bs[179][194](hs))[167]3100
3080 [153]:[153]" congratulations, you broke the record.
3090 print:print" be sure to save the program.
3100 [153]:[153]" see you around.
3110 print""
3120 rem restore previous environment
3130 pokev+24,peek(2041):pokev+32,peek(2042):pokev+33,peek(2043)
3140 poke646,peek(2044):poke650,peek(2045):poke657,0
3150 end
3160 :
3980 rem subroutine--build sprite at page 13 (locations 832-895 in tape buffer)
3990 :
4000 for i=0to41:readu:poke(64*sp)+i,u:next
4010 fori=42to63:poke(64*sp)+i,0:next
4020 poke2040,sp:pokev+23,1:pokev+29,1:pokev+39,0:return
4030 return
4040 data 248,0,0,62,0,0,7,128,0,1,224
4050 data 0,0,120,0,0,62,0,0,15,112
4060 data 0,7,248,0,7,248,0,6,120,0
4070 data 6,12,0,6,6,0,3,6,0,1,128
4080 :
4980 rem data for instructions page
4990 :
5000 data"[217]our objective is to maneuver the
5010 [131]"horizontal lines so that (NULL)uper(NULL)prite
5020 data"may fly safely through the gaps.
5030 [131]"(NULL)he four lines are controlled by the
5040 data"four function keys on your right.
5050 [131]"
5060 data"[208]ressing one of these keys will cause
5070 [131]"the corresponding line to slide right.
5080 data"[212]he same key shifted will cause its
5090 [131]"line to slide left. (NULL)ress the space
5100 data"bar to pause, '*' to abort.
5110 [131]"
5120 data"[193] game consists of 20 turns. [208]oints are
5130 [131]"awarded for every gap safely traversed.
5140 data"[212]he payoffs increase with the number of
5150 [131]"gaps traversed on a turn, and with the
5160 data"number of turns taken. [211]uper[211]prite's
5170 [131]"flight speed and natural waywardness
5180 data"also increase as the game progresses."
5190 data"
5200 [131]"(NULL)he maximum score is 253. chr$ood luck.
5210 data"
5220 [131]" (NULL)(NULL)val(NULL)(NULL)close(NULL)(NULL)atnlenvalclosepeekatn(NULL)close(NULL)(NULL) (NULL)(NULL)atn(NULL)(NULL)closechr$atn(NULL)val.
5230 :
5980 rem subroutine--print instructions
5990 :
6000 pokev,23:pokev+1,49:pokev+21,1
6010 gosub7000:gosub7000
6020 forw=1to23:readu$:printu$:gosub7000:nextw
6030 pokev+21,0:pokev,23:pokev+1,49:pokev+23,0:pokev+29,0
6040 geta$:ifa$<>chr$(32)then 6040
6050 return
6060 :
6980 rem subroutine--fly sprite down 1 print line (ahead of instructions)
6990 :
7000 fori=1to8:pokev,peek(v)+1
7010 pokev+1,peek(v+1)+1:next
7020 pokev,peek(v)+1:return
7030 :
7980 rem subroutine--answer the phone
7990 :
8000 poke sd+24,0
8010 sysch:ifpeek(ar)<>32then8010
8020 poke sd+24,15
8030 return