0 rem --- **********************************************************
1 rem --- JAMOUT2! Jam out on your Atari with the joystick
2 rem --- sequencer tempo and envelope control in BASIC:           *
3 rem --- Record and Playback added: 800 byte variables!
4 rem --- replay - select    clear memory - reset
5 rem --- **********************************************************
 rem  --- Flashback Version, only allows 1/3 the variable storage
 rem  --- and will overwrite the virtualworld (255 bytes vs 800)
 rem  --- Record and playback your creations on your portable Atari sequencer!
 rem  --- **********************************************************

 rem -------------------------------------------
7 rem ---init section, runs once: -------------
 rem -------------------------------------------

9 g=0:rem command playback counter
  h=1:u=1:t=0
  for x=0 to 254:virtualworld(x)=0:next

 rem --------------------------------------------------
15 rem ---gameloop subroutine, runs every frame:    ---
18 rem ------------------------------------------------

 if g=80 then COLUBK=$40: rem --- Simon's memory full
  
 if p>0 then gosub playback:return

 if SWCHB|%11111110=255 then goto skipreset
 rem 20170529 COLUBK=$70:g=0:p=0:for x=0 to 254:cmdfrms(x)=0:next: rem clear duration
 COLUBK=$70:g=0:p=0:for x=0 to 254:virtualworld(x)=0:next: rem clear duration
 t=0:MUSICINDEX=0
skipreset
 
 if SWCHB|%11111101=255 then goto skipselect
 p=0: s=0:gosub playback:return: rem playback sets p>0
skipselect

80 f=f+1:rem framecounters
90 if r>0 then SUSTAINFORFRAMES=SUSTAINFORFRAMES+1:r=r-1 else r=s
100 if f<7 then return:rem only accept button press every 10th frame
110 f=0:h=h+1

 rem i=1: rem default command to pattern target
 if joy0right=1 and joy0up=1 then gosub save_command:t=230:MUSICINDEX=t:return
 if joy0left=1 and joy0up=1 then gosub save_command:t=245:MUSICINDEX=t:return

 if joy0left=1 and joy0down=1 then gosub save_command:t=200:MUSICINDEX=t:return
 if joy0right=1 and joy0down=1 then gosub save_command:MUSICINDEX=180:t=180:return
 

19 if joy0right=1 then gosub save_command:MUSICINDEX=45:t=45:return
20 if joy0left=1 then gosub save_command:MUSICINDEX=75:t=75;return 
30 if joy0up=1 then gosub save_command:MUSICINDEX=160:t=160:return
40 if joy0down=1 then gosub save_command:MUSICINDEX=65:t=65:return

60 loadplayer0(0):player0x=MUSICINDEX:player0y=MUSICINDEX*2

120 if joy0fire=0 then return

130 s=s+1: rem slide delay (incremental)
140 rem 20170529 bug fix! This bug was in the Supercharger version too: if s=>12 then s=0
 if s=>12 then s=0
 t=MUSICINDEX:gosub save_command
160 r=s
170 i=r*8:loadplayer1(i):COLUP1=200:vwpixel(7,3,bindplayer1)
 rem fall through to save_command, i is not 1!
 return


 
save_command
 rem 20170529 AFP fix, using virualworld if g=255 then return: rem --- Simon's memory full
 if g=80 then return: rem --- Simon's memory full
 rem * j=g-1: rem --- ignore duplicate cmds
 rem * if g>0 and cmdval(j)=MUSICINDEX and command(j)=1 then RETURN
 rem 20170529 AFP fix, using virtual world: valSLIDEDELAY(g)=s
 j=g+80:virtualworld(j)=s
 rem if i=1 then i=MUSICINDEX else i=s
 rem 20170529 afp fix ------------- valMUSICINDEX(g)=MUSICINDEX
 j=g+160:virtualworld(j)=t: rem =MUSICINDEX
 if h=0 then h=1:rem fix short notes
 rem 20170529 AFP fix, using virtualword: cmdfrms(g)=h:g=g+1:h=1
 virtualworld(g)=h:g=g+1:h=1
 rem COLUBK=g
 return
 
playback
 COLUBK=$52
 if p=0 then i=0:r=0:f=10
 if r>0 then SUSTAINFORFRAMES=SUSTAINFORFRAMES+1:r=r-1 else r=s
 if f<7 then f=f+1:return
 f=0
 if i>0 then i=i-1:return

 rem 20170529 i=cmdfrms(p):rem get duration
 i=virtualworld(p):rem get duration

 rem if i=0 then p=0:COLUBK=$02:return else COLUBK=$0E
 rem 20170529 s=valSLIDEDELAY(p):r=s
 j=p+80:s=virtualworld(j):r=s
 rem 20170529 MUSICINDEX=valMUSICINDEX(p)
 j=p+160:MUSICINDEX=virtualworld(j)
61 loadplayer0(0):player0x=MUSICINDEX:player0y=MUSICINDEX*2
171 j=s*8:loadplayer1(j):COLUP1=200:vwpixel(7,3,bindplayer1)

 p=p+1
 if p>79 then p=0:COLUBK=0
 return 
 

201 data cmdfrms 0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0,0,0,0,0,0,0,0,0,0,0,0,0,0
210 data cmdval3 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
215 data 512spacer 0
221 data valSLIDEDELAY 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
222 data cmdfrms1 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
223 data cmdfrms2 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
224 data cmdfrms3 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
500 rem --- gameloop2 subroutine, runs every frame: ---
505 if f<>6 then return
507 rem t=t+1 
510 rem if t=5 then t=0: for x=0 to 9:rowcolors(x)=rowcolors(x)+3:next x 

virtualworld
...x...................................................................xxxx.................
...xx...x.............................................................x..x..................
..xxxx...x.......................................xxxx................xxxx...................
..xXXXXx..x......................................x..x...............x..x....................
..XX.xx.XX.x.....................................xxxx..............x.xx.....................
...XxxxxxXX.........................................xx.xx.........xxxx......................
.x..xxXXXX.x.........................................xxxx...................................
..x..XX....XX...............................................................................
...x...xxxxxx...............................................................................
....x....xxxx...............................................................................
......................xxxxxxxx..............................................................
......................x......x..............................................................
......................xxxxxxxx..............................................................
............................................................................................
............................................................................................
............................................................................................
............................................................................................
............................................................................................
............................................................................................
............................................................................................

sprites
..xxxx..
.xXXXXx.
XX.xx.XX
XxxxxxXX
x.XXXX.x
XX....XX
.xxxxxx.
..xxxx..
40
..xxx...
.xxxx...
..xxx...
..xxx...
..xxx...
.xxxxx..
.xxxxx..
.xxxxx..
48
........
xxxxxxxx
......xx
......xx
xxxxxxxx
xxxx....
xxxx....
xxxxxxxx
56
xxxxxxx.
......x.
......x.
......x.
xxxxxxxx
......xx
......xx
xxxxxxxx
64
xx......
xx......
xx......
xx...xx.
xxxxxxx.
.....xx.
.....xx.
.....xx.
72
........
xxxxxxxx
xx......
xx......
xxxxxxxx
....xxxx
....xxxx
xxxxxxxx
80
........
xxxxxxxx
xx....xx
xx......
xxxxxxxx
xx....xx
xxxx..xx
xxxxxxxx
88
xxxxxxxx
xxxxxxxx
xx...xxx
....xxx.
...xxx..
...xxx..
...xxx..
...xxx..
96
.xxxxxx.
.x....X.
.x....X.
XXxxxxxx
xx....xx
Xxxx..XX
Xxxx..xx
xxxxxxxx
104
xxxxxxxx
x.....xx
x....xxx
xxxxxxxx
......xx
......xx
......xx
......xx
112
xx.xxxxx
xx.xx..x
xx.xx..x
xx.xx..x
xx.xx..x
xx.xxx.x
xxx.xx.x
xxx.xxxx
120
.xx..xx.
xxx.xxx.
.xx..xx.
.xx..xx.
.xx..xx.
.xx..xx.
.xxx.xxx
.xxx.xxx
128
xxxxxxxx
xx.x..xx
xx....xx
xx.xxxxx
xx.xxxxx
xx.xx...
xxx.x...
xxx.xxxx
136
xx.xxxx.
xx....x.
xx....x.
xx....x.
xx.xxxxx
xx.....x
xxx....x
xxx.xxxx

144
xx.xx..x
xx.xx..x
xx.xx..x
xx.xxxxx
xx....xx
xx....xx
xxx...xx
xxx...xx

152
xx.xxxxx
xx.xx...
xx.xx...
xx.xx...
xx.xxxxx
xx....xx
xxx...xx
xxx.xxxx

chiptunes
8, 24, 8, 20, 8
10,24, 10, 20, 8
6, 5, 4, 12, 5
12, 9, 12, 7, 4
8, 24, 8, 20, 8
10,24, 10, 20, 15
8, 24, 8, 20, 8
10,24, 10, 20, 8
0,0,0,0,0

7,27,7,27,8;---45
7,13,7,13,8
7,6,7,6,8
7,27,7,27,14
7,6,7,6,8
0,0,0,0,0

8, 24, 8, 20, 4
10,24, 10, 20, 4
8, 24, 8, 20, 4
10,24, 10, 20, 4
8, 24, 8, 20, 4
10,24, 10, 20, 4
8, 24, 8, 20, 4
10,24, 10, 20, 4
8, 24, 8, 20, 4
10,24, 10, 20, 4
8, 24, 8, 20, 4
10,24, 10, 20, 4
8, 24, 8, 20, 4
10,24, 10, 20, 4
8, 24, 8, 20, 4
10,24, 10, 20, 4
0,0,0,0,0

3,24, 13, 20,4 
2, 24, 13, 20, 6
3,24, 13, 20, 4
2, 24, 3, 20, 6
12,24, 12, 20,4 ; -- 180
12, 20, 12, 24, 8
12,24, 12, 20, 4
0, 0, 0, 0, 0
4,20, 3, 20, 5;-- 200
4,17, 3, 17, 9
4,16, 3, 16, 12
3,12, 3, 12, 3
4,11, 3, 11, 5
0,0,0,0,0

4, 15, 3, 15, 8;--230
10,24, 10, 20, 4
8, 24, 8, 20, 8
7,24, 7, 20, 10;--245
6, 5, 4, 12, 5
12, 9, 12, 7, 4


                                                               