#####################################
# 2020 Reset64 4kb                  #
# Craptastic Game Compo 2020        #
#                                   #
# A Day In The Life Of A Teleporter #
# (BASIC 10Liner version)           #
#                                   #
# (c) 2020 by Roman Werner @romwer  #
# email: roman.werner@gmail.com     #
#                                   # 
# Original game (see disclaimer)    # 
# (c) 2020 by Christian Gleinser    #
#####################################

Disclaimer
==========
This BASIC 10Liner is a free adaption of Christian Gleinser's original game with the same title "A Day In The Life Of A Teleporter".
All credits for the idea and concept must go to him. Christian's Website: https://www.drwuro.com / E-Mail: email@drwuro.com


Task and Goal
=============
YOU are the teleporter. When the guy enters the portal, your job is to guide him through the teleportation vortex (which humans can't see).

How does teleportation work? It's quite easy to explain.
There is an invisible teleportation vortex, which carries the subject "X" to its destination.
Whenever a person enters the portal, your job is to recreate the vortex path using your joystick in port 2.
The vortex path is displayed on the screen for you to memorize while the person walks towards the teleporter.
Once he enters, the path disappears and you have to follow the segments of the path with your joystick (left/right/up/down).
If you press the wrong direction, the teleportation process fails, resulting in the death of the person. So make sure you do a good job!

There are 10 screens to master. Have fun!


Control:
========
Joystick:
- Use the stick to move the subject along the invisble vortex path.
- Press fire after a fail attempt to restart


Game Requirements:
==================
- C64/C128* with BASIC 2.0 runtime environment (or compatible)
- 1 Player

*Also playable on Windows/MacOS/iOS/Android (C64 Emulator required)


Starting in VICE: C64 emulator (http://vice-emu.sourceforge.net/):
==================================================================
Start the emulator and then drag and drop the "telepor10.prg" into the VICE window.
-or-
Load the program with the command: load "telepor10.prg",8
Then start the program with:       run


Telepor10 BASIC program code:
=============================
0restore:b=160:f=15:g=0:v=53265:fori=0tol:reada:next:print"{light blue}{clear}{dark gray}"l+1"{down*3}":poke210,208:print"0023{left}";
1d=0:a(0)=-1:a(1)=-40:a(2)=1:a(3)=40:pokev,91:o=1355+360*(land1):x=o:pokeo,f:r=rnd(-a)
2fori=1to9+l:d=d+2-(rnd(1)*3)and3:forj=1to5:y=x:x=x+a(d):u=peek(x):pokex,b:onggosub6:next:next
3pokex,f:d=0:u=32:q=127:fori=1to8:pokeo+u+i,96:pokex+39+i,96:next:fori=-7to0:n=o+i:poken-1,u
4u=peek(n):poken,24:forj=1tob:next:next:onggoto:t=19-z*2:gosub5:print"0{left}";:x=2:gosub6:w=16:g=1:goto1
5s=54272:pokes+6,b:pokes+24,f:forj=0to9:pokes+1,rnd(1)*b:pokes+4,17:waitv,128:next:pokes+4,w:return
6c=56320:ifj=1andp<>a(d)thenpokex,u:pokey+p,b:print"3{home}{light blue}"tab(t)f$(z):z=z+1:waitc,w,w:onzgoto,:run
7b=24:ifj>4andi<9+lthenk=peek(c):on-(k=q)goto7:p=(kand1)*40-(kand2)*20+sgn(kand4)-sgn(kand8)
8pokex,u:ifg+i+j=f+ltheno=x+7:l=l+1:ifl>9thenprint"{home}"tab(f)"{pink}well done!":pokex+1,b:waitc,w,w:run
9f$(1)="lst try":f$(2)="you failed":return:data905,370,879,533,234,744,837,84,102,550


Telepor10 BASIC program code (PUR-80 version using command abbreviations):
==========================================================================
0reS:b=160:f=15:g=0:v=53265:fOi=0tol:rEa:nE:?"{light blue}{clear}{dark gray}"l+1"{down*3}":pO210,208:?"0023{left}";
1d=0:a(0)=-1:a(1)=-40:a(2)=1:a(3)=40:pOv,91:o=1355+360*(laN1):x=o:pOo,f:r=rN(-a)
2fOi=1to9+l:d=d+2-(rN(1)*3)aN3:fOj=1to5:y=x:x=x+a(d):u=pE(x):pOx,b:onggoS6:nE:nE
3pOx,f:d=0:u=32:q=127:fOi=1to8:pOo+u+i,96:pOx+39+i,96:nE:fOi=-7to0:n=o+i:pOn-1,u
4u=pE(n):pOn,24:fOj=1tob:nE:nE:onggO:t=19-z*2:goS5:?"0{left}";:x=2:goS6:w=16:g=1:gO1
5s=54272:pOs+6,b:pOs+24,f:fOj=0to9:pOs+1,rN(1)*b:pOs+4,17:wAv,128:nE:pOs+4,w:reT
6c=56320:ifj=1aNp<>a(d)tHpOx,u:pOy+p,b:?"3{home}{light blue}"tAt)f$(z):z=z+1:wAc,w,w:onzgO,:rU
7b=24:ifj>4aNi<9+ltHk=pE(c):on-(k=q)gO7:p=(kaN1)*40-(kaN2)*20+sG(kaN4)-sG(kaN8)
8pOx,u:ifg+i+j=f+ltHo=x+7:l=l+1:ifl>9tH?"{home}"tAf)"{pink}well done!":pOx+1,b:wAc,w,w:rU
9f$(1)="lst try":f$(2)="you failed":reT:dA905,370,879,533,234,744,837,84,102,550


Tip: Copy/paste the program-Code into CBM prg Studio (http://www.ajordison.co.uk/).
There you can see the commands in nice color highlighting and you can directly execute the game in an emulator of your choice.


Telepor10 Tenliner explained (000=row 0/100=row 1/...):
======================================================
000 restore: rem reset data pointer before next level
001 b=160: rem rem costant for inverse space (representing teleporter vortex beam)
002 f=15: rem constant value for 15
003 g=0: rem 'go'-flag. A value of 1 will call player player control subroutine in line 020 (onggosub060)
004 v=53265: rem contstant for vic status control register
005 fori=0tol:reada:next: rem read data (randomizer seed numbers) up to current level
006 print"{light blue}{clear}{dark gray}"l+1"{down*3}": rem places cursor at beginning of line 4 which means the lo-byte offset for print will be at 160
007 poke210,208: rem setting hi-byte offset for print to 53248 (+160=53408) - yes we are gonna print into VIC-addresses :)
008 print"0023{left}";: rem set VIC-II color registers inclusive ECM colors (at mirror addresses 53408/09/10/11)

010 d=0
011 a(0)=-1:a(1)=-40:a(2)=1:a(3)=40
012 pokev,91: rem set ECM-mode (4x64 character blocks with individual background-colors)
013 o=1355+360*(land1): rem screen address starting point for left teleportal
014 x=o: rem copy as start address to build way to the right teleportal
015 pokeo,f: rem display the character O on screen for left teleportal
016 r=rnd(-a): rem initialize randomizer with level seed

020 fori=1to9+l: rem start with 9 segments and add more when in higher levels
021 d=d+2-(rnd(1)*3)and3: rem set next direction but not opposite from where we came from
022 forj=1to5: rem print 5 elements per segment
023 y=x: rem safe position in vortex beam before player was pressing the wrong direction
024 x=x+a(d): rem add direction offset to current position
025 u=peek(x): rem safe character underneath players 'X' position
026 pokex,b: rem first loop displays beam character, second loop the players 'X'
027 onggosub060: rem call player control subroutine second loop only (when g=1)
028 next:next

030 pokex,f: rem display the character O on screen for right teleportal
031 d=0:u=32:q=127: rem reset initial direction / us space as initial restore char / q = constant for joy2-iddle value
032 fori=1to8: rem for eight elements...
033 pokeo+u+i,96:  rem display left  platform with red inversed space (32+64=96)
034 pokex+39+i,96: rem display right platform with red inversed space (32+64=96)
035 next
036 fori=-7to0: rem lets walk the subject eight steps to the teleportal
037 n=o+i
038 poken-1,u: rem restore safed character from last offset

040 u=peek(n): rem safe character from this screen offset
041 poken,24: rem display 'X' at next position
042 forj=1tob: rem wait a short moment between next step
043 next:next
044 onggoto: rem reaching this point after second loop then go to next level
045 t=19-z*2: rem prepare tab position for "failed" message
046 gosub050: rem play sound effect when entering portal
047 print"0{left}";: rem set ECM background color3 to black (=hide vortex beam)
048 x=2: rem a safe address to do avoid an unwanted poke to screen (line 8)
049 gosub060:w=16:g=1:goto010: rem wait for first direction / w=constant for 16, most used for joystick button waiting / g=1 sets flag to enable loop with player control

050 s=54272: rem sid base address
051 pokes+6,b: rem set sustain/release value for portal sound effect
052 pokes+24,f: rem set volume to 15
053 forj=0to9: rem for 10 times
054 pokes+1,rnd(1)*b: rem set random frequencies (person types in destination)
055 pokes+4,17: rem set waveform and turn gate on (starts attack/decay)
056 waitv,128: rem wait for vertical blank (waste a tiny little bit of time)
057 next
058 pokes+4,w: rem turn gate off (starts sustain/release)
059 return

060 c=56320: rem joystick control port 2
061 ifj=1andp<>a(d)thenpokex,u:pokey+p,b:print"3{home}{light blue}"tab(t)f$(z):z=z+1:waitc,w,w:onzgoto,:run
063 rem check on first step of segment if direction was wrong. If wrong, then...
064 rem show incorrect move, activate vortex beam and display fail message
065 rem add one to failure counter z
066 rem wait for joystick button
067 rem restart level as long as z is being captured by the goto, otherwise restart game 

070 b=24: rem change character from inverse space to 'x'
071 ifj>4andi<9+lthenk=peek(c):on-(k=q)goto070:p=(kand1)*40-(kand2)*20+sgn(kand4)-sgn(kand8)
072 rem when at the beginning of a segment position get direction from joystick port 2

080 pokex,u: rem print 'X' character
081 ifg+i+j=f+ltheno=x+7:l=l+1:ifl>9thenprint"{home}"tab(f)"{pink}well done!":pokex+1,b:waitc,w,w:run
082 rem if subject reached end of vortex beam then go to next level. At level 10 show success.

090 f$(1)="lst try": rem fail text when one life is left
091 f$(2)="you failed": rem fail text with no lives left
092 return
093 data905,370,879,533,234,744,837,84,102,550: rem level seeds for randomizer

2020 rem basic 10liner / (c) roman werner @romwer roman.werner@gmail.com


Trivia
======
The reason for making this BASIC 10liner was, that some members on forum64.de felt the original game being too fast and asked for a BASIC version (as a joke).
Christian Gleinser then suggested that maybe I would think about making a BASIC 10liner out of it (as a joke). Well, I happily accepted the challenge :).

