Vicious Tracker

Basic and Machine Language

Moderator: Moderators

User avatar
R'zo
Vic 20 Nerd
Posts: 514
Joined: Fri Jan 16, 2015 11:48 pm

Vicious Tracker

Post by R'zo »

Current status: Beta release (testers wanted)
Program: Vicous Tracker
Requirements: Vic 20 with at least 16k memory expansion. 24k and 32k versions are also available.
Description: music tracker.

The main goal was to create a tracker for the Vic that can easily export song files and irq from basic to disk file for easy use with basic program.
Designed primarily for biginners to have an easy way to produce music irqs to accompany their basic programs.

Secondary goal is to provide well organized, labeled and commented source code. Open sourced and easy for more advanced user to cut/add features, resize or reorganize tables, and change addresing of files.

Download current release vicious tracker b3.1

Any feedback and input is appreciated, thank you.

Last edited by R'zo on Sat Jul 18, 2020 1:13 pm, edited 1 time in total.
R'zo
I do not believe in obsolete...
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Vicious Tracker

Post by chysn »

This looks awesome, I can't wait to spend some time with it. Electronic music (modular synthesizer) is one of my other pursuits, so I have a lot of interest in the Musical VIC!
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
User avatar
R'zo
Vic 20 Nerd
Posts: 514
Joined: Fri Jan 16, 2015 11:48 pm

Re: Vicious Tracker

Post by R'zo »

Thank you.
I tested it on hardware for the first time last night. Worked even better than I expected. Sounds so much better on the real thing.

I wrote another demo song, it sounds aersome, will get it posted as soon as I have a chance.

Waiting on feedback right now so I can get to work on the next release.
R'zo
I do not believe in obsolete...
User avatar
beamrider
Vic 20 Scientist
Posts: 1448
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: Vicious Tracker

Post by beamrider »

The only feedback I would offer is that it's quite an onerous requirement requiring block 5 RAM for playback. This usually means restriction to 32K Vics just to play music within a BASIC program. I imagine the target audience of your program would be mainly hobbyists using un-expanded or low memory configurations; large programs on the Vic are typically written in assembler.

Is there any chance the player could be relocatable so that it can be used for instance on un-expanded machines? The tracker of course could still require a 32K environment.
User avatar
R'zo
Vic 20 Nerd
Posts: 514
Joined: Fri Jan 16, 2015 11:48 pm

Re: Vicious Tracker

Post by R'zo »

beamrider wrote: Mon May 11, 2020 3:20 am The only feedback I would offer is that it's quite an onerous requirement requiring block 5 RAM for playback. This usually means restriction to 32K Vics just to play music within a BASIC program. I imagine the target audience of your program would be mainly hobbyists using un-expanded or low memory configurations; large programs on the Vic are typically written in assembler.

Is there any chance the player could be relocatable so that it can be used for instance on un-expanded machines? The tracker of course could still require a 32K environment.
Generally speaking I think most people at this point are using penultimate, ultimem or fe3. I have it in block 5 to leave basic area open for basic.

I have been thinking about different versions of the tracker. Different addressing can easily be done. I was planning in providing source so it can be readdresses by others but I can provide a couple versions with different addressing.

As for unexpanded, the music file+player take up 4k of ram. I can configure it for unexpanded but there wouldn't be much room left for anything else. I could do perhaps a more stripped down version for unexpanded that would be around 2k. The user interface would still require at least 16-24k.
R'zo
I do not believe in obsolete...
User avatar
R'zo
Vic 20 Nerd
Posts: 514
Joined: Fri Jan 16, 2015 11:48 pm

Re: Vicious Tracker

Post by R'zo »

Here is demo song #2
Earwig

I wanted to write something to show just how vicious the Vicious Tracker can be.

I wish I had a better way to record on hardware. Vice sound isn't bad but it does not do this full justice.

R'zo
I do not believe in obsolete...
User avatar
R'zo
Vic 20 Nerd
Posts: 514
Joined: Fri Jan 16, 2015 11:48 pm

Re: Vicious Tracker

Post by R'zo »

Project Update: release V B1.1
Vicious Tracker B1.1

I have uploaded the 2nd release of the Vicious Tracker.
There are a few changes but any music written with the first will still run on this version.

I've removed the preference screen to save space. I didn't feel screen color controls were neccasary.

I'm currently dropping pal and ntsc note table support. I am currently only going to have support for the true interval note table (designed by Mike here in denial). This is up for change if others would like it to be included.

I have decided to keep the amp mod on and off switch. It is now implemented in code. 0 in the volume setting with switch amplitude modulation on. 1-f will set volume to that value and switch amp mod off(volume in this mode is not set by the irq it is set by the interface and will have to be set manually by the user for use with other programs).

The player has now been updated. It displays the arranger, pattern, sound and time counters as well as the voice and volume channel input.

I will more than likely offer different versions of the program for use at different ram locations.

I am also planning on writing a more simple tracker for use with the unexpanded Vic.

Here's another piece of music written with Vicious Tracker.

R'zo
I do not believe in obsolete...
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: Vicious Tracker

Post by chysn »

Ryan, how long should we remain on the "LOADING..." splash screen?
VIC-20 Projects: wAx Assembler, TRBo: Turtle RescueBot, Helix Colony, Sub Med, Trolley Problem, Dungeon of Dance, ZEPTOPOLIS, MIDI KERNAL, The Archivist, Ed for Prophet-5

WIP: MIDIcast BASIC extension

he/him/his
User avatar
R'zo
Vic 20 Nerd
Posts: 514
Joined: Fri Jan 16, 2015 11:48 pm

Re: Vicious Tracker

Post by R'zo »

chysn wrote: Sun May 17, 2020 9:26 am Ryan, how long should we remain on the "LOADING..." splash screen?
The main Load screen takes a few minutes. It's loading 4k from an seq file to $a000. Loading and saving songs takes a couple of minutes as well.
R'zo
I do not believe in obsolete...
cTrix
Vic 20 Newbie
Posts: 2
Joined: Mon May 18, 2020 3:04 am

Re: Vicious Tracker

Post by cTrix »

Might have a play later this week when I get time :-) Looks awesome and miles ahead of my crappy BASIC play routine I was writing. Does it play nice with an SD2IEC? I recently received a memory expander of some description (haven't even unpacked it yet) so will certainly be configuring that to the full 32kb and giving it a go :-)
User avatar
R'zo
Vic 20 Nerd
Posts: 514
Joined: Fri Jan 16, 2015 11:48 pm

Re: Vicious Tracker

Post by R'zo »

cTrix wrote: Mon May 18, 2020 3:18 am Might have a play later this week when I get time :-) Looks awesome and miles ahead of my crappy BASIC play routine I was writing. Does it play nice with an SD2IEC? I recently received a memory expander of some description (haven't even unpacked it yet) so will certainly be configuring that to the full 32kb and giving it a go :-)
Imo it works pretty nice with sd2iec.

If using sd2iec use the you will need the zip file entitled sd2iec file pack.zip. The d64 image won't work from sd2iec. Make sure all the files are copied to the main directory on the sd card and not a sub folder. Then load"vicious tracker",8 and run.
R'zo
I do not believe in obsolete...
User avatar
Mike
Herr VC
Posts: 4831
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Vicious Tracker

Post by Mike »

R'zo wrote:The main Load screen takes a few minutes. It's loading 4k from an seq file to $a000. Loading and saving songs takes a couple of minutes as well.
I was wondering why this takes so long and took a quick peek at the code:

Code: Select all

!-writes new data to file, close and jump to controls
79fort=.tofs:x=peek(sb+t):print#2,x:nextt:close2:goto58
[...]
!-loads file and jumps to controls
99fort=.tofs:input#2,x:pokesb+t,x:nextt:close2:goto58
This is extremely inefficient code to save and load a memory range. For each byte in memory, you write 3 to 5 bytes to a file (blank, 1 to 3 digits, and a carriage return). The usual transfer rate of IEC of ~400 bytes/s thus is reduced by the same factor. Furthermore, even when compiled this code still has to make lots of ASCII <-> float conversions which aren't substantially sped up by any compiler. Much like putting both feet down on gas and brake.

Please take a look at the code snippets for SAVEing and LOADing memory blocks in the sticky thread "ROM calls and other tricks" for a better method. The method given there won't work well when compiled (due to a non-standard use of a SYS call), but as I said - it's no use to compile code that's inherently slow. Keep the interface uncompiled. If there are other passages in the interface that could be sped up, I'll be glad to help out.

For example, this one (even if it's no anyway slow):

Code: Select all

!-scratch old file and open for writing
70onx+1goto71,72,73,74,75,76,77,78
71open15,8,15,"s:0":close15:open2,8,2,"0,s,w":goto79
72open15,8,15,"s:1":close15:open2,8,2,"1,s,w":goto79
73open15,8,15,"s:2":close15:open2,8,2,"2,s,w":goto79
74open15,8,15,"s:3":close15:open2,8,2,"3,s,w":goto79
75open15,8,15,"s:4":close15:open2,8,2,"4,s,w":goto79
76open15,8,15,"s:5":close15:open2,8,2,"5,s,w":goto79
77open15,8,15,"s:6":close15:open2,8,2,"6,s,w":goto79
78open15,8,15,"s:7":close15:open2,8,2,"7,s,w":goto79
... could do away with somewhat less code:

Code: Select all

70 open15,8,15,"s:"+chr$(48+x):close15:open2,8,2,chr$(48+x)+",s,w"
... immediately followed by line 79. Should you plan to go beyond files "8" and "9", define the file names with a string array.

Greetings,

Michael
User avatar
srowe
Vic 20 Scientist
Posts: 1338
Joined: Mon Jun 16, 2014 3:19 pm

Re: Vicious Tracker

Post by srowe »

Mike wrote: Mon May 25, 2020 2:33 am This is extremely inefficient code to save and load a memory range. For each byte in memory, you write 3 to 5 bytes to a file (blank, 1 to 3 digits, and a carriage return). The usual transfer rate of IEC of ~400 bytes/s thus is reduced by the same factor. Furthermore, even when compiled this code still has to make lots of ASCII <-> float conversions which aren't substantially sped up by any compiler. Much like putting both feet down on gas and brake.
In addition it causes a LISTEN, UNLISTEN sequence for each PRINT#. This adds an extra 3 bytes for each operation.
User avatar
R'zo
Vic 20 Nerd
Posts: 514
Joined: Fri Jan 16, 2015 11:48 pm

Re: Vicious Tracker

Post by R'zo »

Mike wrote: Mon May 25, 2020 2:33 am
R'zo wrote:The main Load screen takes a few minutes...
Thank you this is very helpful and will help with a handfull of projects i have working at the moment. Data load times from basic have been a consistent thorn in my side and usually the only thing i really have problems with in terms of speed with basic.

I was under the impression that file names from basic had to be set. If i can simply get file name from user into string and save/load with string than i can just let the user name their files and do away with the slot system. The slot system was cluttered and clunky anyway and I will be glad to do away with it.

I am also working on (thought i had just finished ) a simple tracker for the unexpanded vic. These techniques will help clean it up nicely.

The one thing I am struggling with is the time it takes for me to transfer data from ram to screen. It becomes complicated because it's not a direct value transfered. I.e. each note is stored as 1 byte divided into 3 values ({tone}+({note}*2)+({octave}*24) which is used to address a data table. These has to then be converted into hex before put on the screen. I didn't expect these routines to be fast when i designed them and they operate a little faster than I expected. i still find the small load times from screen to screen to be a bit of a pain. These routines are the main reason i compiled it for. Even at compiled speeds I would still like it to be a little faster.

here is an example. this is the screen setup for the pattern editor. 1510 to 1560

Code: Select all

PATTERNS----------------------------------------------------------------------
!-Screen setup
!-opens screen file and jumps to screen print routine
!-sets x1 and y1 for data and screen handling
!-sets subpage handler (pa) to 0
!-gets pattern data from ram
!-puts pattern on screen
!-sets cursor

1480 open2,8,2,"s4":gosub20:pa=0

1490 x1=6:y1=2:pokess+21,pk(pa)+128:pokess+68,pk(pa)+128:pokess+156,pk(pa)+128

1500 pokess+244,pk(pa)+128:pokess+332,pk(pa)+128:pokess+420,pk(pa)+128

1510 fort=.to3:fort1=.to15:x=peek(pl+t1+(t*512)+(pa*16)):a=int(x/24):x=x-(a*24)

1520 b=int(x/2):x=x-(b*2):y=(int(peek(pl+256+t1+(t*512)+(pa*16)))/16)

1530 pokess+x1+t1+((y1+(t*4))*22),pk(x):pokess+x1+t1+((y1+1+(t*4))*22),pk(b)

1540 pokess+x1+t1+((y1+2+(t*4))*22),pk(a):pokess+x1+t1+((y1+3+(t*4))*22),pk(y)

1550 nextt1:nextt:fort=.to15:pokess+t+x1+(18*22),pk(int(peek(pv+t+(pa*16))/16))

1560nextt:pokesc+x1+(y1*22),cc
R'zo
I do not believe in obsolete...
User avatar
R'zo
Vic 20 Nerd
Posts: 514
Joined: Fri Jan 16, 2015 11:48 pm

Re: Vicious Tracker

Post by R'zo »

I'm going to drop the current source code for the unexpanded tracker i've been working on.

it puts the irq player in the rs232 area, the song and irq initializer into the tape buffer leaving unexpanded basic open for the user.

basic interface

Code: Select all

!-******************************************************************************
!- MICRO TRACKER V 1.0 (interface(commented version))
!- BY: RYAN LISTON
!- MAY / 24 / 2020
!- FOR: UNEXPANDED COMODORE VIC-20
!- CODE: BASIC V 2.0
!-******************************************************************************

!-ARRAYS

!-v(x)=voice and volume controls(0to3=voice 0to3, 4=volume)
!-hx$(x)hex handler for getting hex input from user(0to15=$0-$f)
!-pk(x)=hex handler for getting character code from hex value

0dimv(5):fort=0to4:v(t)=36874+t:nextt:dimhx$(16):fort=.to15:reada$:hx$(t)=a$
1nextt:dimpk(16):fort=.to15:reada:pk(t)=a:next:restore
2data"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"
3data48,49,50,51,52,53,54,55,56,57,1,2,3,4,5,6

!-------------------------------------------------------------------------------

!-FUNCTIONS

!-hh(f)=gets upper 4 bits from a value
!-hl(f)=gets lower 4 bits from a value

4deffnhh(f)=int(f/16):deffnhl(f)=f-((int(f/16))*16)

!-------------------------------------------------------------------------------

!-VATIABLES

!-a1=start of arrangment data
!-p1=start of pattern data
!-in=start of irq initalizer routine
!-at=arrangement counter
!-pt=pattern counter
!-sp=timer(speed)
!-ss=start of screen map
!-cs=star of color map
!-x1/y1=cursor x/y screen postition in data field
!-x2/y2=for user x/y input
!-x=x/y start position of screen data field/recyclable local variable
!-z,z1,z2,z3 recyclable local variables
!-t-t2=reserved for for to next loops
!-a$=string input from disk and user
!-a%numerical input from disk

5a1=833:p1=897:in=1001:at=831:pt=830:sp=829:ss=7680:cs=38400:rp=832:x1=0

!-------------------------------------------------------------------------------

!-LOAD ASSEMBLY ROUTINES AND DATA

!-7 loads music player routine to rs232 buffer @ 664
!-8 load irq initializer routine to tape buffer @ 1001
!-9 clear music file area in taper buffer @ 824

7open2,8,2,"player":fort=0to92:input#2,a%:poke664+t,a%:nextt:close2
8open2,8,2,"init":fort=0to11:input#2,a%:poke1001+t,a%:nextt:close2
9fort=0to176:poke824+t,0:nextt

!-------------------------------------------------------------------------------

!-SCREEN SETUP

!-10 prints screen from disk
!-11 to 14 copies song settings from ram to screen

10open2,8,2,"scr":fort=0to18:input#2,a$:printa$;:nextt:close2
11pokess+90,peek(827)+176:pokess+156,peek(828)+176
12pokess+288,peek(pt)+176:pokess+222,pk(fnhh(peek(at)))+128
13pokess+223,pk(fnhl(peek(at)))+128:pokess+420,pk(fnhh(peek(sp)))+128
14pokess+421,pk(fnhl(peek(sp)))+128:pokess+354,peek(rp)+176

!-15 to 18 copies song data from ram to screen

15x=72:fort=0to3:fort1=0to15:pokess+x+t1+(t*22),pk(peek(a1+t1+(t*16))/8)+128
16nextt1:nextt:x=182:fort=0to11:fort1=0to7
17pokess+x+(t1*2)+(t*22),pk(fnhh(peek(8+p1+t1+(t*8))))+128
18pokess+x+(t1*2)+(t*22)+1,pk(fnhl(peek(8+p1+t1+(t*8))))+128:nextt1:nextt

!-sets cursor start position in color ram and cursor x/y start position

19pokecs+72,0:x1=0:y1=0

!-------------------------------------------------------------------------------

!-CONTROLS

!-sets start of data field
!-clears user x/y input variables
!-retrieves and checks for user input

20x=72:x2=0:y2=0:geta$:ifa$=""then20

!-checks for f1-f8 keypress for settings controls

21ifasc(a$)>132andasc(a$)<141thenx=asc(a$)-132:goto46

!-checks user input for file controls
!-p=play,l=load,s=save,n=new

22ifa$="p"then80
23ifa$="l"then65
24ifa$="n"then42
25ifa$="s"then73

!-checks user input for cursor control

26ifa$="{left}"thenx2=x2-1:goto39
27ifa$="{right}"thenx2=x2+1:goto39
28ifa$="{up}"theny2=y2-1:goto39
29ifa$="{down}"theny2=y2+1:goto39

!-checks for hex input from user
!-if z=-1 then no hex input
!-if z= 0-15 then handle as hex input
 
30z=-1:fort=0to15:ifa$=hx$(t)thenz=t
31nextt:ifz=-1then20

!-if y1>4 then treat for pattern  field 
!-if <=4 then treat for arranger field
!-if y1>4 and z(hex input)>12(b#) then jump to controls

32ify1>4then35
33ifz>12then20

!-------------------------------------------------------------------------------

!-DATA FIELD CONTROLS

!-34 sets user input to arranger data area on screen and in ram
 
34pokess+x+x1+(y1*22),pk(z)+128:pokea1+x1+(y1*16),z*8:goto20

!-35 sets user input to pattern data area on screen 
!-36 retrieves pattern high bits from screen 
!-37 retrieves pattern low bits from screen
!-38 adds bits togather and sets note value to pattern area in ram

35pokess+x+x1+(y1*22),pk(z)+128
36fort=0to15:ifpeek(ss+x+(int(x1/2)*2)+(y1*22))-128=pk(t)thenz1=t*16
37ifpeek(ss+x+(int(x1/2)*2)+1+(y1*22))-128=pk(t)thenz2=t
38nextt:pokep1-32+x1/2+(y1*8),z1+z2:goto20

!-------------------------------------------------------------------------------

!-CURSOR CONTROLS

!-39 tests for datafield border and inc/dec y2 if true to skip over boarder
!-40 tests for outer borders jumps to controls if true
!-41 sets new cursor position to x/y and color ram

39ify1+y2=4theny2=y2*2:goto41
40ifpeek(ss+x+x1+x2+((y1+y2)*22))<128then20
41pokecs+x+x1+x2+((y1+y2)*22),0:pokecs+x+x1+(y1*22),6:x1=x1+x2:y1=y1+y2:goto20

!-------------------------------------------------------------------------------

!-NEW SONG

!-confirms delete current song data
!-if yes then clears song fata
!-if no then jump to message delete

42print"{home}{down*21}delete current song?  y 0r n?{home}";
43geta$:ifa$="y"thenprint"{clear}";:goto9
44ifa$="n"then68
45goto42


!-------------------------------------------------------------------------------

!-SETTINGS CONTROLS

!-checks for f1-f8 jumps to sub approprate controller

46onxgoto48,60,69,55,52,62,50,57
47goto20

!-voice 1 controler

48ifpeek(827)=3thenpoke827,0:pokess+90,176:goto20
49poke827,peek(827)+1:pokess+90,peek(ss+90)+1:goto20

!-repeat controler

50ifpeek(rp)=0thenpokerp,1:pokess+354,177:goto20
51pokerp,0:pokess+354,176:goto20

!-voice 2 controler

52ifpeek(828)=3thenpoke828,0:pokess+156,176:goto20
53poke828,peek(828)+1:pokess+156,peek(ss+156)+1:goto20

!-speed (timer) controler

55ifpeek(sp)<255thenpokesp,peek(sp)+1:goto59
56pokesp,0:goto59
57ifpeek(sp)>0thenpokesp,peek(sp)-1:goto59
58pokesp,255
59pokess+420,pk(fnhh(peek(sp)))+128:pokess+421,pk(fnhl(peek(sp)))+128:goto20

!-arrangement counter controler

60ifpeek(at)<31thenpokeat,peek(at)+1:goto64
61pokeat,0:goto64
62ifpeek(at)>0thenpokeat,peek(at)-1:goto64
63pokeat,31
64pokess+222,pk(fnhh(peek(at)))+128:pokess+223,pk(fnhl(peek(at)))+128:goto20

!-------------------------------------------------------------------------------

!-LOAD SONG 
!-confirms load from user 
65print"{home}{down*21}load file y or n?{home}"
66geta$:ifa$=""then66
67ifa$="y"then71

!-------------------------------------------------------------------------------
!-CLEAR MESSAGE
68print"{home}{down*21}                              {home}";:goto20

69ifpeek(pt)=7thenpokept,0:pokess+288,176:goto20
70pokept,peek(pt)+1:pokess+288,peek(pt)+176:goto20

!-------------------------------------------------------------------------------
!-LOAD SONG CONT'

!-loads song data from disk

71open2,8,2,"song":print"{home}{down*21}loading...          {home}";
72fort=0to176:input#2,a%:poke824+t,a%:nextt:close2:goto10

!-------------------------------------------------------------------------------

!-SAVE SONG

!-confirms save

73print"{home}{down*21}save file y or n?{home}";
74geta$:ifa$=""then74
75ifa$="y"then77
76goto68

!-saves song to disk

77open15,8,15,"s:song":close15:open2,8,2,"song,s,w"
78print"{home}{down*21}saving...                 {home}"
79fort=0to176:print#2,peek(824+t):nextt:close2:goto68

!-------------------------------------------------------------------------------

!-TEST PLAYER

!-sets volume:initializes irq:sets play controller to 1 (play)
!-if keypress then pause song, reset counters and jump to controler

80poke36878,15:sys1001:poke756,1:print"{home}{down*21}playing{home}"
81geta$:ifa$=""then81
82poke756,0:fort=0to3:poke36874+t,0:ift<3thenpoke824+t,0
83nextt:goto68

!-============================================================================== 


irq player

Code: Select all

!-******************************************************************************
!- MICRO TRACKER V 1.0 (player)
!- BY: RYAN LISTON
!- MAY / 24 / 2020
!- FOR: UNEXPANDED COMODORE VIC-20
!- CODE: ASSEMBLY
!-******************************************************************************

*=664

!-DECLARES CONSTATS

chnl=$900a      ;start of voice registers
arcnt=$033a      ;arrangement counter
ptcnt=$0339       ;pattern counter
spcnt=$0838       ;timer (speed counter)
voc0=$033b        ;voice 1 controler 
voc1=$033c        ;coice 2 controler
artp=$033f        ;arrangment counter controler
pttp=$033e        ;pattern counter controler
spd=$033d         ;speed counter controler
rpt=$0340         ;repeat controler
ar1=$0341         ;start of voice 1 arrangment data
ar2=$0361         ;start of voice 2 arrangment data
ptn=$0381         ;start of pattern data
irqx=$eabf        ;irq handler      
init=$03e9        ;irq initializer



!-MUSIC PLAYER

!-------------------------------------------------------------------------------

!-start

start   lda     cntrl   ;load control byte
        cmp     #$01    ;compares to 1 
        beq     loop1$  ;if 1 then jump to play
        jmp     irqx    ;if 0 then exit irq

!-------------------------------------------------------------------------------

!-play

loop1$  ldx     arcnt   ;loads x with arrangment counter
        lda     ar1,x   ;loads a with arrangmenent data for voice 1
                        ;incremented by x (arrangment counter)
        ldy     voc0    ;loads y with voice 1 controler
        jsr     jump    ;jumps to note drop
        
        ldx     arcnt   ;loads x with arrangment counter  
        lda     ar2,x   ;loads a with arrangmenent data for voice 2
                        ;incremented by x (arrangment counter)
        ldy     voc1    ;loads y with voice 2 controler
        jsr     jump    ;jumps to note drop

!-------------------------------------------------------------------------------
!-counter
                                
counter ldx     #$00    ;loads x with 0
        ldy     #$00    ;loads y with 0
loop2$  lda     spcnt,x ;loads a with counter incremented by x
                        ;(0=speed,1=pattern,2=speed)
        cmp     spd,x   ;compare to controler incremented by x
                        ;(0=speed,1=pattern,2=speed)
        beq     next    ;if counter = controler then jump
        inc     spcnt,x ;increments counter

!-------------------------------------------------------------------------------

exit    jmp     irqx    ;exits irq

!-------------------------------------------------------------------------------

!-counter turnover

next    tya             ;transfers y (0) to a     
        sta     spcnt,x ;stores 0 to current counter under x
        cpx     #$02    ;compares x to 2
        beq     end     ;if x=2 then jump to end
        inx             ;increments x 
        jmp     loop2$  ;loop for all counters

!-------------------------------------------------------------------------------

end     lda     rpt     ;loads repeat controler
        cmp     #$01    ;compares to 1 
        beq     exit    ;if 1 then jump to exit and restart song
        lda     #$00    ;if 0 then load a with 0
        sta     cntrl   ;set control byte to 0 (paused)
        jmp     exit    ;jump to exit

!-------------------------------------------------------------------------------
     

!-note drop
jump    clc             ;clears carry bit
        adc             ;ptcnt adds pattern count to pattern number
                        ;from arranger stored in a 
        clc             ;clears carry bit
        tax             ;transfers total pattern address to x
        lda     ptn,x   ;loads note value at ptn + x 
        sta     chnl,y  ;stores note value in voice channel(y)
        rts             ;returns to jump point 

!-------------------------------------------------------------------------------

!-control byte
cntrl   byte    $00     ;0=pause,1=play

;poke 756,1 to play  756,0 to pause
;poke 824 to 826,0 to reset counters befor restart

!-==============================================================================  
blank song file

Code: Select all

!-******************************************************************************
!- MICRO TRACKER V 1.0 (blank song file)
!- BY: RYAN LISTON
!- MAY / 24 / 2020
!- FOR: UNEXPANDED COMODORE VIC-20
!- CODE: ASSEMBLY
!-******************************************************************************

*=824

;-settings
spcnt$  byte    $00
ptcnt$  byte    $00
arcnt$  byte    $00


voice0$ byte    $00
voice1$ byte    $00
speed$  byte    $00
pttop$  byte    $00
artop$  byte    $00


repeat$ byte    $00

;-arranger

arng1$  byte    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 

arng2$  byte    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 
;patterns        

ptrn$   byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        byte    $00,$00,$00,$00,$00,$00,$00,$00
        


initializer

Code: Select all

!-******************************************************************************
!- MICRO TRACKER V 1.0 (irq initializer)
!- BY: RYAN LISTON
!- MAY / 24 / 2020
!- FOR: UNEXPANDED COMODORE VIC-20
!- CODE: ASSEMBLY
!-******************************************************************************


*=$03e9


init$   sei             ;sets interupt bit 
        lda     #$02    ;loads irq start high byte
        sta     $0315   ;stores at $0315
        lda     #$98    ;loads irq low byte
        sta     $0314   ;stores at $0314
        rts             ;return to basic
R'zo
I do not believe in obsolete...
Post Reply