diff --git a/main.tal b/main.tal index 6e033af..4bf5feb 100644 --- a/main.tal +++ b/main.tal @@ -22,7 +22,11 @@ ( constants ) %PTN_WIDTH { #0003 } ( pattern width. a short ) %PTN_LEN { #0010 } ( pattern length. a short ) +%SONG_WIDTH { #0004 } ( song width. a short ) +%SONG_LEN { #00ff } ( song length. a short ) +%TIMELINE_DISP_WIDTH { #0018 } ( width on the display of the timeline ) +%PATTERN_DISP_WIDTH { #0040 } ( width on the display of a pattern ) ( devices ) |00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ] @@ -73,12 +77,12 @@ ( for the sake of testing, play pattern 0-3 on ch 0-3 ) #00 .Channel0/pattern-index STZ .Channel0/pattern-index LDZ .Channel0/pattern-addr ;alloc-load-pattern JSR2 -#01 .Channel1/pattern-index STZ +( #01 .Channel1/pattern-index STZ .Channel1/pattern-index LDZ .Channel1/pattern-addr ;alloc-load-pattern JSR2 #02 .Channel2/pattern-index STZ .Channel2/pattern-index LDZ .Channel2/pattern-addr ;alloc-load-pattern JSR2 #03 .Channel3/pattern-index STZ -.Channel3/pattern-index LDZ .Channel3/pattern-addr ;alloc-load-pattern JSR2 +.Channel3/pattern-index LDZ .Channel3/pattern-addr ;alloc-load-pattern JSR2 ) ( init editor to pattern 0 ) #00 .Edit/pattern-index STZ @@ -341,10 +345,6 @@ RTN ( draw-pattern-line draws a single line in a pattern ) @draw-pattern-line ( addr ) - .Draw/row LDZ ;draw-byte JSR2 ( draw the row number ) - ;line .Screen/addr DEO2 - #21 .Screen/color DEO - .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 ( move right a sprite ) #00 .Draw/col STZ &loop #00 .Draw/col LDZ NEQ ,&else JCN ( if it's not the note value, draw a byte ) @@ -364,15 +364,30 @@ RTN @draw-pattern ( addr ) #00 .Draw/row STZ &loop - .Draw/pattern-y LDZ2 .Screen/x DEO2 + .Screen/x DEI2 STH2 +( .Draw/pattern-y LDZ2 .Screen/x DEO2 ) DUP2 ;draw-pattern-line JSR2 .Screen/y DEI2 #0008 ADD2 .Screen/y DEO2 ( add spacing between rows ) + STHr2 .Screen/x DEO2 ( reset X ) PTN_WIDTH ADD2 ( get the next byte in the pattern ) #01 .Draw/row LDZ ADD .Draw/row STZ .Draw/row LDZ PTN_LEN LOB NEQ ,&loop JCN POP2 ( remove final address from stack ) RTN +@draw-timeline ( draws numeric timeline to the side of patterns ) + #00 .Draw/row STZ + &loop + .Screen/x DEI2 STH2 + .Draw/row LDZ ;draw-byte JSR2 ( draw the row number ) + ;line .Screen/addr DEO2 + #21 .Screen/color DEO + .Screen/y DEI2 #0008 ADD2 .Screen/y DEO2 ( add spacing between rows ) + STHr2 .Screen/x DEO2 ( reset X ) + #01 .Draw/row LDZ ADD .Draw/row STZ + .Draw/row LDZ PTN_LEN LOB NEQ ,&loop JCN +RTN + @draw-playhead ( clear previous playhead ) .Draw/playhead-y LDZ2 .Screen/y DEO2 @@ -400,10 +415,15 @@ RTN ;draw-playhead JSR2 #0000 .Screen/x DEO2 #0000 .Screen/y DEO2 - .Edit/pattern-index LDZ ;draw-byte JSR2 .Draw/pattern-x LDZ2 .Screen/x DEO2 .Draw/pattern-y LDZ2 .Screen/y DEO2 - .Edit/pattern-addr LDZ2 ;draw-pattern JSR2 + ;draw-timeline JSR2 + .Draw/pattern-x LDZ2 TIMELINE_DISP_WIDTH ADD2 .Screen/x DEO2 ( draw pattern after timeline ) + .Draw/pattern-y LDZ2 .Screen/y DEO2 + .Channel0/pattern-addr LDZ2 ;draw-pattern JSR2 + .Draw/pattern-y LDZ2 .Screen/y DEO2 + .Draw/pattern-x LDZ2 PATTERN_DISP_WIDTH TIMELINE_DISP_WIDTH .Draw/pattern-hspacing LDZ2 ADD2 ADD2 ADD2 .Screen/x DEO2 + .Channel0/pattern-addr LDZ2 ;draw-pattern JSR2 ;draw-free-mem JSR2 RTN @@ -420,6 +440,7 @@ RTN POPr RTN +( @on-step ( whenever a pattern step should be played ) PTN_LEN .Playback/position LDZ2 NEQ2 ,&continue JCN ( if we're at the end of the pattern, reset the counter ) @@ -437,6 +458,19 @@ RTN #0001 .Playback/position LDZ2 ADD2 .Playback/position STZ2 ;draw-playhead JSR2 ( update the playhead position ) RTN +) + +@on-step + PTN_LEN .Playback/position LDZ2 NEQ2 ,&continue JCN + ( PATTERN SWITCHING CODE GOES HERE ) + .Channel0/pattern-index LDZ #01 ADD DUP .Channel0/pattern-index STZ + .Channel0 ;alloc-load-pattern JSR2 + #0000 .Playback/position STZ2 + &continue + .Playback/position LDZ2 PTN_WIDTH MUL2 .Channel0/pattern-addr LDZ2 ADD2 + .Audio0 ;play-line JSR2 + #0001 .Playback/position LDZ2 ADD2 .Playback/position STZ2 +RTN @draw-cursor ( -- ) @@ -527,6 +561,7 @@ BRK an ff in the note column of the pattern will kill the existing note without starting a new one (this is the tracker "box" note) ) @data ( start of data ) +@song $3fc ( $ff * 4, 256 lines on 4 channels ) @pattern_table :ptn0 :ptn1 :ptn2 :ptn3 ( pattern table. Contains the addresses of patterns ) @pattern_pointer :pointer-start ( pattern pointer. Points to where the next pattern will be written in memory ) @ptn0