Vicious Tracker

Basic and Machine Language

Moderator: Moderators

User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Vicious Tracker

Post by Mike »

R'zo wrote: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.
{tone}+({note}*2)+({octave}*32) might lead to a more efficient encoding. Depends on how many octaves are there. As this requires changes at other places, I didn't do any change in the procedure below.

You use lots of complicated expressions for address calculations. Their constant parts can be factored out of the loops, so they're not recalculated over and over. I introduced new variables: A1, A2, A3, A4 as base addresses. Also CH, which is a bit faster than recalculating PK(PA)+128 for 6 times. I also eliminated some superfluous parentheses and INT() functions. Array indices are automatically truncated to integer:

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
     CH=pk(pa)+128
     pokess+21,CH
     pokess+68,CH
     pokess+156,CH

1500 pokess+244,CH
     pokess+332,CH
     pokess+420,CH

1510 fort=0to3
       A1=PL+512*T+16*PA
       A2=SS+ 88*T+22*Y1+X1
       fort1=0to15
         x=peek(A1+T1)
         a=int(x/24)
         x=x-(a*24)

1520     b=int(x/2)
         x=x-(b*2)
         y=peek(A1+T1+256)/16

1530     pokeA2+T1,pk(x)
         pokeA2+T1+22,pk(b)

1540     pokeA2+T1+44,pk(a)
         pokeA2+T1+66,pk(y)

1550   nextt1
     nextt
     A3=SS+X1+18*22
     A4=PV+16*PA
     fort=0to15
       pokeA3+t,pk(peek(A4+T)/16)

1560 nextt
     pokesc+x1+(y1*22),cc
Of course you *are* drawing 80 objects on the screen with single POKEs. That will take some time regardless. This routine would be one of the first candidates for a translation to machine code, if it was a time critical part of the user interface. If however the screen is only drawn in full once, and subsequent changes in the pattern display are local, then you can leave the code in BASIC - with the optimizations I laid out above. :)

Other than that, the tool you're using to create the screen masks should also have a function to directly emit BASIC code with PRINT statements. Reading the screen mask from a SEQ file is a lot slower than PRINTing it directly. Also, INPUT# fails on non-expected input, like commas and colons in strings.
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 9:56 pm
{tone}+({note}*2)+({octave}*32) ...
Wow! Thank you. I can't believe I didn't see that myself. This would still provide room for 8 octaves. I need 7. 1 for a base octave of 0s for a silent from the pattern editor, 3 for the 3 actual octaves and 3 octaves of 0s at the top for a guaranteed silent from the pitch mod editor.

This makes the formula easier to handle from assembly. No complex formulas, all I have to do it shift some bits around. Sys calls for screen handling will be in the works soon.

As far as screen printing from disk. It only takes a split second to print a few strings from disk. I wasn't so much concerned about that part. However I am currently able to run this at 8k expansion. I was planning on full 32 k expansion so I deffinately have room to spare. I've had complaints that all the files make it confusing to run from sd2iec. Since I can do away with the slot files taking away the screen files will greatly help reduce the file clutter.
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 »

Update:

I have made quite a bit of progress on the next release. Unfortunately the new build will break old song files but I plan on releasing a program to fix them.

-Screen data loaders are now done with assembly. Screens now load insanely making for a huge inprovement.

-new load/save routines are working very nicely and also show an improvement in speed. (Todo- need to figure out how to overwrite these files. There will be little disk space for those running the interface off if disk. being able to overwrite files will keep the disk from filling up quickly and make things easier on the user.

-title screen is gone. Everything loads so fast now there is no need for it.

-since the user can now name their files the song name has been removed from song data.

-settings and load/save screens have been combined.

-carry bits are now cleared befor adc commands so now the player works the way it should.

To do
-finish rebuilding the interface to work with changes.

-write a song file updater to update the song files written with previous releases to work with the new build.

Hopefully I'll have the next release ready in 1 to 2 weeks.

Thank you everyone for your help and input.
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 »

in another thread, Mike wrote:
R'zo wrote:Is there any way to scratch or overwrite these files? Specifically using string input from user for the filename.
You'd use the standard CBM DOS commands for this, e.g.:

OPEN15,8,15,"S0:"+N$:CLOSE15

deletes file N$ on disk.

You should *not* use the save-and-replace variant of the filename, i.e. prepend "@" or "@0:", as the implementation of this function is bugged on many 15xx disk drives and can corrupt the disk contents.
Thank you.
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 »

Progress update

Unfortunately progress on this has come to a current stand still. My laptop died on me last night. Fortunately I saw it coming so my files are backed up so nothing is lost. It should only be a few days befor I'm up and running again.

I have reconstructed the note table due to formula changes. This will be another breaking change in the next release. And again I do plan on releasing an updater to fix song files written with older builds.

The old formula to determine notes through table index was. .. [simitone]+([note]×2)+([octave]×24)
The note table looked something like...
Note,semitone,note,semitone....
Oct0
Oct1
Oct2
...
Oct6

As Mike printed out if this is changed to...
[simitone]+([note]×2)+([octave]×32)
Then the formulas become easier to handle from assembly.

However I remembered why I didn't go with that. It leaves a 6 byte gap between octaves. In order for pitch modulation to work i need the table to be able to be indexed in a linear fashion. So that the note value for B plus a note value of 1 would be C.

So the formula is now. ..
[Octave]+([semitone]×8)+([note]×32)
This note table now runs some thing like this...
Oct0,oct1,oct3....oct8
Note
Simitone
Note
Semitone
...

So now u have a formula that is easier to handle from assembly allowing screen transitions in the interface to be instantaneous and a more clean and symmetrical note table as well.

I only have a couple more blocks of basic code left to edit and the next build will be ready for release. (As soon as I'm up and running again.
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 »

Is the latest version still 1.1 beta? That's what it looks like. I don't think I've tried that one yet.

Do you mind if I make a suggestion? GitHub gives you as many repos as you want. You might consider organizing your code with one project per repo. That way, it's easier to distribute news about one project, and easier for users to track updates. It also clarifies bug reports if people start reporting bugs.

And if you do that, I'd strongly suggest using the wiki to do per-project markdown documentation. It's not exactly feature-rich, but it works nicely and looks clean.
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: Mon Jun 22, 2020 6:14 pm Is the latest version still 1.1 beta? That's what it looks like. I don't think I've tried that one yet.

Do you mind if I make a suggestion? GitHub gives you as many repos as you want. You might consider organizing your code with one project per repo. That way, it's easier to distribute news about one project, and easier for users to track updates. It also clarifies bug reports if people start reporting bugs.

And if you do that, I'd strongly suggest using the wiki to do per-project markdown documentation. It's not exactly feature-rich, but it works nicely and looks clean.
Yes 1.1 is the latest release.

I'm still learning how everything is set up on github. I was wanting to keep all my Vic work together under 1 repo but I didn't realize exactly how the releases worked. It is deffinately becoming a mess. Future releases will have there own page.

I ordered my new laptop but it's going to be a week befor it arrives so it will still be a bit befor I can get back to work on the next release. It's like torture to be so deep into a project and then loose the ability to work on it for some time. I find myself sitting here typing on my knees wishing I could do some dev work.
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 »

VICIOUS TRACKER B3.1 IS FINALLY RELEASED!!!
...and with a few major improvements.

Vicious Tracker B3.1

Improvements and changes
-song files have been reformatted. A converter program has been included to reformat songs.
-Vicious tracker now has 16k, 24k and 32k versions. Songs written in any expansion are playable at any expansion, exported modules are only usable in their original expansion area.
-you can now overwrite previously saved files.
-file size has decreased.
-files now load/save much more quickly.
-screen transitions are now nearly instantaneous.
-you can now get a guaranteed silence from the pitch modulator with an octave value of 4.
-bug fix in pattern addressing.
-now unnecessary screens have been removed from the user interface (editor).
-note table has been reorganized to be more efficient and easier to handle.
-editor, player, song files and all other source code can now be reformatted for any address by changing the start address of the .asm file.

To dos
-write a detailed user manual.
-fix any bugs that may possibly occur.

Special Thanks to Mike.


Code: Select all

export speed
export sndlen
export patlen
export ends
export volxo
export rpt
export lowxo
export midxo
export hixo
export nsxo
export pmod
export amod
export patlv
export arh
export arl
export arm
export arn
export arv
export paths
export pathv
export patls
export patms
export patmv
export patns
export patnv
export patv
export alenc
export buff0
export buff1
export buff2
export buff3
export buff4
export cntrl
export plenc
export slenc
export spdc
export vlshfl
export hext
export init
export mscrn
export astart
export pstart
export pmstart
export amstart
export notbl
export init


*=$abb0

;-constants


vocl=$900a
vocm=$900b
voch=$900c
vocn=$900d
vol=$900e
irqx=$eabf

pmod1=speed+$1a
pmod2=pmod1+$10
pmod3=pmod1+$20
amod0=pmod1+$f0
amod1=amod0+$10     
amod2=amod1+$10
amod3=amod2+$10
amod4=amod3+$10
amod5=amod4+$10
amod6=amod5+$10
amod7=amod6+$10
amod8=amod7+$10
amod9=amod8+$10
amoda=amod9+$10
amodb=amoda+$10
amodc=amodb+$10
amodd=amodc+$10
amode=amodd+$10
amodf=amode+$10


;===============================================================================

; MAIN SCREEN

;-------------------------------------------------------------------------



mscrn   ldy     #$00
right   lda     speed
        cpy     #$00
        beq     left2
        
        clc             ;clears carry bit
        asl
        asl
        asl
        asl
        

left2   clc
        lsr             ;shifts byte right 4 times
        lsr             ;to clear low bits     
        lsr
        lsr
        tax
        lda     hext,x
        sta     $1086,y
        cpy     #$01
        beq     next1
        iny
        jmp     right

next1   lda     sndlen
        tax
        lda     hext,x
        sta     $109c
        lda     patlen
        tax
        lda     hext,x
        sta     $10b2
        

start1  ldy     #$00
right1  lda     ends
        cpy     #$00
        beq     left1
        
        clc             ;clears carry bit
        asl
        asl
        asl
        asl
        

left1   clc
        lsr             ;shifts byte right 4 times
        lsr             ;to clear low bits     
        lsr
        lsr
        tax
        lda     hext,x
        sta     $10c8,y
        cpy     #$01
        beq     next2
        iny
        jmp     right1
                
next2   lda     volxo
        tax
        lda     hext,x
        sta     $10de

        lda     rpt
        tax
        lda     hext,x
        sta     $10f4

        lda     lowxo
        tax
        lda     hext,x
        sta     $110a
        
        lda     midxo
        tax
        lda     hext,x
        sta     $1120

        lda     hixo
        tax
        lda     hext,x
        sta     $1136
        
        lda     nsxo
        tax
        lda     hext,x
        sta     $114c
        rts

                                

hext    byte    $b0,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8,$b9,$81,$82,$83,$84,$85,$86

;=====================================================================

; ARRANGER

;----------------------------------------------------------------------



;4096=1000



astart  ldy     #$00
s1      lda     buff4
s2      tax     

        lda     arl,x
        ;stx     buff4
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1032,y
        
        ldx     buff4
        lda     arm,x
        ;stx     buff4
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1048,y
        
        ldx     buff4
        lda     arh,x
        ;stx     buff4
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $105e,y
        ldx     buff4
        lda     arn,x
        ;stx     buff4
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1074,y
        
        ldx     buff4
        lda     arv,x
        ;stx     buff4
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $108a,y

        jmp     s4

s3      jmp     s1        
s4      inc     buff4
        iny
        cpy     #$10
        bne     s3
        rts
        
        
        
        
        
        
        
        
        
        
;============================================================================

; PATTERN

;-----------------------------------------------------------------------


pstart  ldy     #$00
ps1     ldx     buff4
ps2     lda     patlv,x
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1032,y

        ldx     buff4
        lda     patlv,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1048,y
        
        ldx     buff4
        lda     patlv,x
        asl
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $105e,y

        ldx     buff4
        lda     patls,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1074,y

        
;-------------------------------                

        ldx     buff4
        lda     patmv,x
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $108a,y

        ldx     buff4
        lda     patmv,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $10a0,y
        
        ldx     buff4
        lda     patmv,x
        asl
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $10b6,y

        ldx     buff4
        lda     patms,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $10cc,y
;--------------------------------------


        ldx     buff4
        lda     pathv,x
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $10e2,y

        ldx     buff4
        lda     pathv,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $10f8,y
        
        ldx     buff4
        lda     pathv,x
        asl
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $110e,y

        ldx     buff4
        lda     paths,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1124,y
        jmp     ps4

ps3     jmp     ps1
;----------------------------------

ps4     ldx     buff4
        lda     patnv,x
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $113a,y

        ldx     buff4
        lda     patnv,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1150,y
        
        ldx     buff4
        lda     patnv,x
        asl
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1166,y


        ldx     buff4
        lda     patns,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $117c,y
        jmp     ps7

ps6     jmp     ps3  
;-----------------------------------------



ps7     ldx     buff4
        lda     patv,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1192,y

        iny
        inc     buff4
        cpy     #$10    
        bne     ps6
        rts        

;========================================================================

; PITCH MOD

;-----------------------------------------------------------------------



pmstart ldy     #$00
pms1    ldx     buff4
pms2    lda     pmod,x
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1032,y

        ldx     buff4
        lda     pmod,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1048,y
        
        ldx     buff4
        lda     pmod,x
        asl
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $105e,y

;---------------------------
        ldx     buff4
        lda     pmod1,x
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1074,y

        ldx     buff4
        lda     pmod1,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $108a,y
        
        ldx     buff4
        lda     pmod1,x
        asl
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $10a0,y
              
;----------------------------


        ldx     buff4
        lda     pmod2,x
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $10b6,y

        ldx     buff4
        lda     pmod2,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $10cc,y
        
        ldx     buff4
        lda     pmod2,x
        asl
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $10e2,y
        jmp     pms4

pms3    jmp     pms1
----------------------------

pms4    ldx     buff4
        lda     pmod3,x
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $10f8,y

        ldx     buff4
        lda     pmod3,x
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $110e,y
        
        ldx     buff4
        lda     pmod3,x
        asl
        asl
        asl
        asl
        asl
        clc
        lsr
        lsr
        lsr
        lsr
        lsr
        clc
        tax
        lda     hext,x
        sta     $1124,y

;-------------------------------

        iny
        inc     buff4
        cpy     #$10    
        bne     pms3
        rts         

;===================================================================

; AMP MOD

;-----------------------------------------------------------






amstart ldy     #$00
as1     lda     amod0,y
        tax
        lda     hext,x
        sta     $1032,y

        lda     amod1,y
        tax
        lda     hext,x
        sta     $1048,y

        lda     amod2,y
        tax
        lda     hext,x
        sta     $105e,y

        lda     amod3,y
        tax
        lda     hext,x
        sta     $1074,y

        lda     amod4,y
        tax
        lda     hext,x
        sta     $108a,y

        lda     amod5,y
        tax
        lda     hext,x
        sta     $10a0,y

        lda     amod6,y
        tax
        lda     hext,x
        sta     $10b6,y

        lda     amod7,y
        tax
        lda     hext,x
        sta     $10cc,y
        jmp     as3
as2     jmp     as1
        
as3     lda     amod8,y
        tax
        lda     hext,x
        sta     $10e2,y

        lda     amod9,y
        tax
        lda     hext,x
        sta     $10f8,y
   
        lda     amoda,y
        tax
        lda     hext,x
        sta     $110e,y
        lda     amodb,y
        tax
        lda     hext,x
        sta     $1124,y
        lda     amodc,y
        tax
        lda     hext,x
        sta     $113a,y
   
        lda     amodd,y
        tax
        lda     hext,x
        sta     $1150,y

        lda     amode,y
        tax
        lda     hext,x
        sta     $1166,y
        jmp     as5
as4     jmp     as2
as5     lda     amodf,y
        tax
        lda     hext,x
        sta     $117c,y
        
        iny
        cpy     #$10
        bne     as4
        rts
;======================================================================

;  SONG FILE

;-----------------------------------------------------------
;-settings

speed   byte    $02
sndlen  byte    $0f
patlen  byte    $0f
ends    byte    $7f

volxo   byte    $0f
rpt     byte    $01
lowxo   byte    $01
midxo   byte    $01
hixo    byte    $01 
nsxo    byte    $01

    

;-sounds
pmod    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
        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
        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
        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
        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
        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
        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
        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
        
amod    byte    $08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08
        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
        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
        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
        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
        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
        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
        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
        byte    $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
        
;-patterns:tune+(note*2)+(0ct*24) low voice
patlv   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
        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
        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
        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
        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
        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
        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
        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-sounds low voice
patls   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
        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
        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
        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
        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
        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
        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
        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:tune+(note*2)+(0ct*24) mid voice        
patmv   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
        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
        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
        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
        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
        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
        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
        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-sounds mid voice
patms   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
        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
        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
        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
        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
        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
        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
        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:tune+(note*2)+(0ct*24) high voice
pathv   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
        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
        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
        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
        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
        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
        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
        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-sounds high voice        
paths   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
        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
        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
        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
        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
        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
        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
        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:tune+(note*2)+(0ct*32) noise
patnv   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
        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
        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
        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
        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
        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
        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
        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-sounds noise
patns   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
        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
        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
        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
        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
        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
        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
        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
                
;-pattern-volume  
patv    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
        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
        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
        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
        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
        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
        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
        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
        
;-arrangment
arl     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
        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
        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
        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
       
arm     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
        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
        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
        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
       
arh     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
        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
        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
        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

arn     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
        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
        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
        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
       
arv     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
        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
        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
        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


;==========================================================================

; NOTE TABLE

;-tru int note table

;-tru int note table

;{note index}={oct}+({simitone}*8)+({note}*16
;       oct     semitone  note
;       000     0         0000
;       0-7     0-1       0-11

       ;oct     0,1  ,2  ,3  ,4,5,6,7
notbl   byte    0,255,191,223,0,0,0,0   ;c  
        byte    0,131,193,224,0,0,0,0   ;c+
        byte    0,134,195,225,0,0,0,0   ;c#
        byte    0,137,197,225,0,0,0,0   ;c#+
        byte    0,141,198,226,0,0,0,0   ;d
        byte    0,144,199,227,0,0,0,0   ;d+
        byte    0,147,201,228,0,0,0,0   ;d#
        byte    0,150,203,229,0,0,0,0   ;d#+
        byte    0,153,204,228,0,0,0,0   ;e
        byte    0,156,206,230,0,0,0,0   ;e+
        byte    0,159,207,231,0,0,0,0   ;f
        byte    0,162,208,231,0,0,0,0   ;f+
        byte    0,164,210,232,0,0,0,0   ;f#
        byte    0,167,211,233,0,0,0,0   ;f#+
        byte    0,170,212,234,0,0,0,0   ;g
        byte    0,172,213,234,0,0,0,0   ;g+
        byte    0,174,215,235,0,0,0,0   ;g#
        byte    0,176,216,235,0,0,0,0   ;g#+
        byte    0,179,217,236,0,0,0,0   ;a
        byte    0,181,218,236,0,0,0,0   ;a+
        byte    0,183,219,237,0,0,0,0   ;a#
        byte    0,185,220,238,0,0,0,0   ;a#+
        byte    0,187,221,239,0,0,0,0   ;b
        byte    0,189,222,238,0,0,0,0   ;b+
;===========================================================================

; INITIALIZER

;----------------------------------------------------------------



;-irq initializer
init    sei
        lda     #$be
        sta     $0315
        lda     #$76
        sta     $0314
        cli
        rts

;======================================================================

; PLAYER

;-------------------------------------------------------------------------

;-player controls
;-loops if stop  
start   lda     cntrl
        cmp     #$01
        beq     player
        cmp     #$02
        beq     rstart
        jmp     irqx

;-resets song settings and goes to play
rstart  lda     #$00
        ldx     #$00
rsloop  sta     spdc,x
        inx
        cpx     #$09
        bne     rsloop
        lda     #$01   
        sta     cntrl


;-player

;-gets arrangement data and store in buffer

player  ldx     alenc   ;loads value in arrangment counter
        lda     arl,x  ;loads val in arrangement voice 0 at x
        sta     buff0  ;stores v0 av  in buffer
        lda     arm,x  ;v1""
        sta     buff1  
        lda     arh,x  ;v2""
        sta     buff2
        lda     arn,x  ;v3""
        sta     buff3
        lda     arv,x    ;vol""
        sta     buff4
        


;-voice 0
vox_0   lda     lowxo
        cmp     #$00
        beq     vox_1
        lda     buff0  ;gets v0 av from buffer     
        
        clc

        adc     plenc   ;inc by pattern counter
        tax             ;transfers to x
        lda     patlv,x  ;gets note val from pattern
        sta     vlshfl  ;stores in left shift registor
        lda     patls,x ;loads sound val from pattern
        
        clc

        adc     slenc   ;increments by sound counter
        tax             ;transfers to x
        lda     pmod,x;loads pitch mod val    
       
        clc

        adc     vlshfl  ;adds to note val to pitch mod valt
        tay
        lda     notbl,y
        sta     buff0  ;stores in buffer
       

;-voice 1
vox_1   lda     midxo
        cmp     #$00
        beq     vox_21
        lda     buff1  ;gets v1 av from buffer     
        
        clc

        adc     plenc   ;inc by pattern counter
        tax             ;transfers to x
        lda     patmv,x  ;gets note val from pattern
        sta     vlshfl  ;stores in left shift registor
        jmp     v22
vox_21  jmp     vox_2
v22     lda     patms,x ;loads sound val from pattern
        
        clc

        adc     slenc   ;increments by sound counter
        tax             ;transfers to x
        lda     pmod,x;loads pitch mod val    
        clc

        adc     vlshfl  ;adds to note val to pitch mod val
        tay
        lda     notbl,y
        sta     buff1  ;stores in buffer
        
        
;-voice 2
vox_2   lda     hixo
        
        cmp     #$00
        beq     v2

       

        lda     buff2  ;gets v1 av from buffer     
        clc
        adc     plenc   ;inc by pattern counter
        tax             ;transfers to x
        jmp     v3
v2      jmp     vox_3
 
v3      lda     pathv,x  ;gets note val from pattern
        sta     vlshfl  ;stores in left shift registor
        lda     paths,x ;loads sound val from pattern
        clc
        adc     slenc   ;increments by sound counter
        tax             ;transfers to x
        lda     pmod,x;loads pitch mod val    
        clc
        adc     vlshfl  ;adds to note val to pitch mod val
        tay
        lda     notbl,y
        sta     buff2  ;stores in buffer
        
;-voice 3
vox_3   lda     nsxo
        cmp     #$00
        beq     vol_0
        lda     buff3  ;gets v0 av from buffer     
        
        clc

        adc     plenc   ;inc by pattern counter
        tax             ;transfers to x
        lda     patnv,x  ;gets note val from pattern
        sta     vlshfl  ;stores in left shift registor
        lda     patns,x ;loads sound val from pattern
        
        clc

        adc     slenc   ;increments by sound counter
        tax             ;transfers to x
        lda     pmod,x;loads pitch mod val    

        clc

        adc     vlshfl  ;adds to note val to pitch mod val
        tay
        lda     notbl,y        
        sta     buff3  ;stores in buffer
        
vol_0   lda     volxo  ;loads a with volume control
        cmp     #$00    ;compares to 0
        bne     drop    ;if not then drop
        lda     buff4   ;gets pattern count
        
        clc

        adc     plenc  ;ads arrangemnt count in buffer
        tax             ;transfers to x
        lda     patv,x ;loads volume pattern value indexed by x(arr+patt)
        
        clc
        adc     slenc
        tax             ;transfers to x
        lda     amod,x;loads volume value indexed by x (patt val)
        sta     buff4  ;stores volume in buffer
        lda     vol     ;loads current volume 
        
        
left    lsr             ;shifts byte right 4 times
        lsr             ;to clear low bits     
        lsr
        lsr
        
        clc             ;clears carry bit
        asl             ;shifts byte left 4 times   
        asl             ;to shift aux color back to    
        asl             ;high bits
        asl
        
        clc
        adc     buff4  ;adds new volume  
        sta     buff4  ;stores sum in buffer

;play notes
drop    ldx     #$00    ;sets x to 0

drop4   cpx     #$04
        beq     dropl
        lda     lowxo,x
        cmp     #$00
        beq     drop3


dropl   lda     buff0,x;gets value from buffer indexed by x
        
        cpx     #$04    ;compares x to 4 for (volume)
        bne     drop2   ;if not then drop 2
        
        ldy     volxo  ;loads y with volume control register
        cpy     #$00    ;compares to 0
        bne     drop3   ;if not then drop 3    
        

drop2   sta     vocl,x  ;stores new value in vics audio registers
drop3   inx             ;increments x
        cpx     #$05    ;and loops                
        bne     drop4   ;for 4 voices+volume
        
;------------------
timers  ldx     #$00
timer   lda     spdc,x
        cmp     speed,x
        beq     trset
        inc     spdc,x
        jmp     irqx
trset   lda     #$00
        sta     spdc,x
        inx     
        cpx     #$04
        bne     timer
    





endtst  lda     rpt  ;gets repeat value
        cmp     #$00    ;if 0
        beq     end     ;then go to end song
                        

restrt  lda     #$02    ;loads accumulater with 2
        sta     cntrl  ;sets song play controls to restart
        jmp     irqx

end     lda     #$00             ;ends song
        sta     cntrl
        jmp     irqx


;-counters
spdc    byte    $00
slenc   byte    $00
plenc   byte    $00
alenc   byte    $00



;-registers
vlshfl  byte    $00

;-buffer
buff0   byte    $00
buff1   byte    $00
buff2   byte    $00
buff3   byte    $00
buff4   byte    $00    

;-play control
;0=stop:1=play:2=restart
cntrl   byte    $00

Code: Select all

!-TITLE SCREEN-----------------------------------------------
0poke36879,8:print"{clear}    {white}{161}{161}{reverse on}{187}{reverse off}{190}{reverse on}{172}{reverse off}{190}{reverse on}{187}{reverse off}{190}{reverse on}{172}{reverse off}{161}{161}{161}{reverse on}{172}{reverse off}{190}":PRINT"    {161}{161}{reverse on}{161}{reverse off} {161} {reverse on}{161}{reverse off} {161}{161}{161}{161}{reverse on}{162}{reverse off}{161}"
1PRINT"    {188} {reverse on}{162}{reverse off}{190}{reverse on}{162}{reverse off}{190}{reverse on}{162}{reverse off}{190}{reverse on}{162}{reverse off}{190}{reverse on}{162}{reverse off}{190}{reverse on}{162}{reverse off}{190}":PRINT"    {reverse on}{187}{reverse off}{190}{reverse on}{172}{reverse off}{161}{reverse on}{172}{reverse off}{161}{reverse on}{172}{reverse off}{190}{161}{161}{reverse on}{172}{reverse off}{190}{reverse on}{172}{reverse off}{161}"
2PRINT"    {reverse on}{161}{reverse off} {reverse on}{172}{reverse off}{187}{reverse on}{172}{reverse off}{161}{161} {reverse on}{172}{reverse off}{187}{reverse on}{172}{reverse off} {reverse on}{172}{reverse off}{187}":PRINT"    {188} {190}{190}{190}{190}{reverse on}{162}{reverse off}{190}{190}{190}{reverse on}{162}{reverse off}{190}{190}{190}"
3PRINT"    version  b.3.1":PRINT"{down}   ryan liston 2020{home}"
4poke55,0:poke56,64:clr:goto14
!-GOSUB ROUTINES-------------------------------------------
!-page handler
5pa=0:ifa$=chr$(133)then:p=1
6ifa$=chr$(137)thenp=2
7ifa$=chr$(134)thenp=3
8ifa$=chr$(138)thenp=4
9ifa$=chr$(135)thenp=5
10ifa$=chr$(139)thenp=5
11onpgoto27,99,127,179,220
!-file loader
12sys57809(f$),8:poke780,0:poke781,sb-(int(sb/256)*256):poke782,int(sb/256)
13sys65493:return
!-VARIABLE DECLARATION-----------------------------
14sb=speed:ss=4096:sc=37888:ar=arl:la=arl:ma=arm
15ha=arh:na=arn:vr=arv:pl=patlv:pm=patmv:ph=pathv:pn=patnv
16pv=patv:sd=pmod:vd=amod:p=1:cs=0:cb=0:ct=1:cc=5:cr=0:pa=0:f$="blank"
17pb=buff4:xo=cntrl:se=notbl:sf=mscrn
!-Arrays----------------------------------------
18dimhx$(16):fort=.to15:reada$:hx$(t)=a$:nextt:dimac(16):fort=.to15:reada
19ac(t)=a:nextt:dimpk(16):fort=.to15:reada:pk(t)=a+128:next
20dimcv(8):fort=0to7:reada:cv(t)=a:nextt:restore
21data"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"
22data48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70
23data48,49,50,51,52,53,54,55,56,57,1,2,3,4,5,6
24data144,5,28,159,156,30,31,158
!-load assembly routines and tables
25sys57809("f32"),8,1:poke780,0:sys65493:sysinit:goto27
!----------------------------------------------------
26gosub12
!-SETTING SCREEN---------------------------------------
27PRINT"{reverse off}{clear}{white}song file:"
28PRINT"                      ";
29PRINTf$
30PRINT"                      ";
31PRINT"{reverse on}l{reverse off}oad  {reverse on}s{reverse off}ave  {reverse on}n{reverse off}ew  {reverse on}x{reverse off}port";
32PRINT"                      ";
33PRINT"  {reverse on}  {reverse off} song speed"
34PRINT"  {reverse on} {reverse off}  sound length     ";
35PRINT"  {reverse on} {reverse off}  pattern length   ";
36PRINT"  {reverse on}  {reverse off} song length      ";
37PRINT"  {reverse on} {reverse off}  volume           ";
38PRINT"  {reverse on} {reverse off}  repeat           ";
39PRINT"  {reverse on} {reverse off}  low voice        ";
40PRINT"  {reverse on} {reverse off}  mid voice        ";
41PRINT"  {reverse on} {reverse off}  high voice       ";
42PRINT"  {reverse on} {reverse off}  noise            {home}";
43sysmscrn:x1=2:y1=6:pokesc+x1+(y1*22),cc
!-Control
44x2=0:y2=0:geta$:ifa$=""then44
45ifa$="s"then71
46ifa$="l"then79
47ifa$="n"then85
48ifa$="x"then90
49ifasc(a$)=140orasc(a$)=136then:gosub251:goto27
50ifasc(a$)>132andasc(a$)<140thengoto5
51ifa$=chr$(17)theny2=1:goto58
52ifa$=chr$(145)theny2=-1:goto58
53ifa$=chr$(29)thenx2=1:goto58
54ifa$=chr$(157)thenx2=-1:goto58
55ifasc(a$)>47andasc(a$)<58then60
56ifasc(a$)>64andasc(a$)<91then60
57goto44
!-cursor
58ifpeek(ss+x1+x2+((y1+y2)*22))<128then44
59pokesc+x1+(y1*22),ct:x1=x1+x2:y1=y1+y2:pokesc+x1+(y1*22),cc:goto44
!-Data input controls
60ifasc(a$)<48orasc(a$)>70then44
61fort=.to15:ifhx$(t)=a$thenx=t
62nextt
63ify1>10andx<2thenpokess+x1+(y1*22),pk(x):pokesb+y1-6,x:goto44
64ify1>10then44
65ify1>9or(y1<9andy1>6)thenpokess+x1+(y1*22),pk(x):pokesb+y1-6,x:goto44
!-sets arrangment lenght and speed
!-sets data to screen and ram
!-jumps to controls
66ifx1+(y1*22)=200andx>7thenx=peek(ss+x1+(y1*22))-48-128
67pokess+x1+(y1*22),pk(x):fort=.to15
68ifpeek(ss+2+(y1*22))=pk(t)thenx=t
69ifpeek(ss+3+(y1*22))=pk(t)theny=t
70nextt:pokesb+y1-6,(x*16)+y:goto44
!-save
71print"{clear}save?   y or n"
72geta$:ifa$="y"then75
73ifa$="n"then27
74goto72
75input"{down*2}enter filename{left*14}{down}";f$
76print"{down}saving...":printf$:open15,8,15,"s0:"+f$:close15
77sys57809(f$),8,1:poke193,sb-(int(sb/256)*256):poke194,int(sb/256):poke780,193
78poke781,se-(int(se/256)*256):poke782,int(se/256):sys65496:goto27
!-load
79print"{clear}load?   y or n"
80geta$:ifa$="y"then83
81ifa$="n"then27
82goto80
83input"{down*2}enter filename{left*14}{down}";f$
84print"{down}loading...":printf$:goto26
!-new
85print"{clear}new?   y or n"
86geta$:ifa$="y"then89
87ifa$="n"then27
88goto86
89f$="blank":print"{down}loading new":print"song file...":gosub12:goto27
!-export
90print"{clear}export?   y or n"
91geta$:ifa$="y"then94
92ifa$="n"then27
93goto91
94input"{down*2}enter filename{left*14}{down}";f$
95print"{down}exporting...":printf$:open15,8,15,"s0:"+f$:close15
96sys57809(f$),8,1:poke193,sf-(int(sf/256)*256):poke194,int(sf/256)
97poke780,193:poke781,(xo+1)-(int((xo+1)/256)*256)
98poke782,int((xo+1)/256):sys65496:goto27
!-------------------------------------------------------------------------------
!-ARRANGEMENT EDITOR
99PRINT"{reverse off}{clear}{white}arranger            p0";
100PRINT"                      ";
101PRINT"low   {reverse on}                ";
102PRINT"{reverse off}mid   {reverse on}                ";
103PRINT"{reverse off}high  {reverse on}                ";
104PRINT"{reverse off}nois  {reverse on}                ";
105PRINT"{reverse off}vol   {reverse on}                {home}";
106pokess+21,pk(pa):pokepb,pa*16:sysastart:x1=6:y1=2:pokesc+x1+(y1*22),cc
107x2=0:y2=0:geta$:ifa$=""then107
108ifasc(a$)=140orasc(a$)=136then:gosub251:goto99
109ifasc(a$)>132andasc(a$)<140thengoto5
110ifa$=chr$(17)theny2=1:goto125
111ifa$=chr$(145)theny2=-1:goto125
112ifa$=chr$(29)thenx2=1:goto125
113ifa$=chr$(157)thenx2=-1:goto125
114ifa$="+"andpa<7thenpa=pa+1:pokesc+x1+(y1*22),1:goto106
115ifa$="-"andpa>0thenpa=pa-1:pokesc+x1+(y1*22),1:goto106
116ifasc(a$)>47andasc(a$)<58thenx=asc(a$)-48:goto119
117ifasc(a$)>64andasc(a$)<71thenx=asc(a$)-55:goto119
!-loops to controls
118goto107
!-screen data input
119pokess+x1+(y1*22),pk(x)
120ify1=6thenpokevr+(pa*16)+x1-6+((y1-6)*16),x*16:goto107
121ify1=5thenpokena+(pa*16)+x1-6+((y1-5)*16),x*16:goto107
122ify1=4thenpokeha+(pa*16)+x1-6+((y1-4)*16),x*16:goto107
123ify1=3thenpokema+(pa*16)+x1-6+((y1-3)*16),x*16:goto107
124pokela+(pa*16)+x1-6+((y1-2)*16),x*16:goto107
!-Cursor controls
125ifpeek(ss+x1+x2+((y1+y2)*22))<128then107
126pokesc+x1+(y1*22),ct:x1=x1+x2:y1=y1+y2:pokesc+x1+(y1*22),cc:goto107
!-------------------------------------------------------------------------------
!-PATTERN EDITOR
127PRINT"{clear}{reverse off}{white}patterns            p0";
128PRINT"                      ";
129PRINT"low  t{reverse on}                ";
130PRINT"{reverse off}p0   n{reverse on}                ";
131PRINT"{reverse off}     o{reverse on}                ";
132PRINT"{reverse off}     s{reverse on}                ";
133PRINT"{reverse off}mid  t{reverse on}                ";
134PRINT"{reverse off}p0   n{reverse on}                ";
135PRINT"{reverse off}     o{reverse on}                ";
136PRINT"{reverse off}     s{reverse on}                ";
137PRINT"{reverse off}high t{reverse on}                ";
138PRINT"{reverse off}p0   n{reverse on}                ";
139PRINT"{reverse off}     o{reverse on}                ";
140PRINT"{reverse off}     s{reverse on}                ";
141PRINT"{reverse off}nois t{reverse on}                ";
142PRINT"{reverse off}p0   n{reverse on}                ";
143PRINT"{reverse off}     o{reverse on}                ";
144PRINT"{reverse off}     s{reverse on}                ";
145PRINT"{reverse off}vol  v{reverse on}                ";
146PRINT"{reverse off}p0                    {home}";
147pokess+21,pk(pa):pokepb,pa*16:syspstart:x1=6:y1=2:pokesc+x1+(y1*22),cc
148fort=0to4:pokess+67+(t*88),pk(pa):nextt
!-Controls
!-gets user imput
!-f1-f8 jumps to page control
!-arrows jumps to cursor control
!-"+" and "-" jumps to sub page controls
!-"0"-"f" converts to 0-15 and jumps to data input controls
149x2=0:y2=0:geta$:ifa$=""then149
150ifasc(a$)=140orasc(a$)=136then:gosub251:goto147
151ifasc(a$)>132andasc(a$)<140thengoto5
152ifa$=chr$(17)theny2=1:goto161
153ifa$=chr$(145)theny2=-1:goto161
154ifa$=chr$(29)thenx2=1:goto161
155ifa$=chr$(157)thenx2=-1:goto161
156ifa$="+"andpa<15thenpa=pa+1:pokesc+x1+(y1*22),1:goto147
157ifa$="-"andpa>0thenpa=pa-1:pokesc+x1+(y1*22),1:goto147
158ifasc(a$)>47andasc(a$)<58thenx=asc(a$)-48:goto163
159ifasc(a$)>64andasc(a$)<71thenx=asc(a$)-55:goto163
!-loops to controls
160goto149
!-Cursor controls
161ifpeek(ss+x1+x2+((y1+y2)*22))<128then149
162pokesc+x1+(y1*22),ct:x1=x1+x2:y1=y1+y2:pokesc+x1+(y1*22),cc:goto149
!-Input controls
!-sets y3 for note hadling
!-note value = {tone}+{note*2}+{octave*24}
!-for silent tone set oct to 0
!-checks y1 for tone,note,oct,sound and volume fields
!-if input is valid for field then jump to data controls
!-else jump to controls
163y3=int((y1-2)/4)
164if((y1=2ory1=6)or(y1=10ory1=14))andx<2then170
165if((y1=3ory1=7)or(y1=11ory1=15))andx<12then170
166if((y1=4ory1=8)or(y1=12ory1=16))andx<4then170
167if((y1=5ory1=9)or(y1=13ory1=17))andx<16then170
168ify1=18andx<16then170
169goto149
!-Data controls
!-sets volume (amp) pattern data
170pokess+x1+(y1*22),pk(x):ify1=18thenpokepv+(x1-6)+(pa*16),x*16:goto149
!-If sound line jump to sound line control
171if((y1=5ory1=9)or(y1=13ory1=17))then178
!-sets ram and screen fiels for note values
!-jumps to controls
172y=(y1-2)-(y3*4):z=peek(ss+x1+(((y3*4)+2)*22))
173a=peek(ss+x1+(((y3*4)+3)*22)):b=peek(ss+x1+(((y3*4)+4)*22))
174fort=.to15:ifz=pk(t)thenc=t
175ifa=pk(t)thend=t
176ifb=pk(t)thene=t
!-c=simtn d=note e=oct
177nextt:pokepl+x1-6+(y3*512)+(pa*16),e+(c*8)+(d*16):goto149
!-sets sound data and screen fields and jumps to controls
178pokepl+256+x1-6+(y3*512)+(pa*16),x*16:goto149
!---------------------------------------------------------------------------
!-PITCH MOD
179PRINT"{clear}{reverse off}{white}pitch mod           p0";
180PRINT"{down}s0   t{reverse on}                ";
181PRINT"{reverse off}     n{reverse on}                ";
182PRINT"{reverse off}     o{reverse on}                ";
183PRINT"{reverse off}s1   t{reverse on}                ";
184PRINT"{reverse off}     n{reverse on}                ";
185PRINT"{reverse off}     o{reverse on}                ";
186PRINT"{reverse off}s2   t{reverse on}                ";
187PRINT"{reverse off}     n{reverse on}                ";
188PRINT"{reverse off}     o{reverse on}                ";
189PRINT"{reverse off}s3   t{reverse on}                ";
190PRINT"{reverse off}     n{reverse on}                ";
191PRINT"{reverse off}     o{reverse on}                {home}";
192pokess+21,pk(pa):pokepb,pa*64:syspmstart:x1=6:y1=2:pokesc+x1+(y1*22),cc
193fort=0to3:pokess+45+(t*66),pk(pa*4+t):nextt
!-Controls
!-gets user imput
!-f1-f8 jumps to page control
!-arrows jumps to cursor control
!-"+" and "-" jumps to sub page controls
!-"0"-"f" converts to 0-15 and jumps to data input controls
194x2=0:y2=0:geta$:ifa$=""then194
195ifasc(a$)=140orasc(a$)=136then:gosub251:goto179
196ifasc(a$)>132andasc(a$)<140thengoto5
197ifa$=chr$(17)theny2=1:goto206
198ifa$=chr$(145)theny2=-1:goto206
199ifa$=chr$(29)thenx2=1:goto206
200ifa$=chr$(157)thenx2=-1:goto206
201ifa$="+"andpa<3thenpa=pa+1:pokesc+x1+(y1*22),1:goto192
202ifa$="-"andpa>0thenpa=pa-1:pokesc+x1+(y1*22),1:goto192
203ifasc(a$)>47andasc(a$)<58thenx=asc(a$)-48:goto208
204ifasc(a$)>64andasc(a$)<71thenx=asc(a$)-55:goto208
!-loop to control
205goto194
!-Cursor control
206ifpeek(ss+x1+x2+((y1+y2)*22))<128then194
207pokesc+x1+(y1*22),ct:x1=x1+x2:y1=y1+y2:pokesc+x1+(y1*22),cc:goto194
!-Input controls
!-sets y3 for note hadling
!-sound (pitch mod) value = {tone}+{note*2}+{octave*24}
!-final note value={sound value}+{note value}
!-checks y1 for tone,note and oct fields
!-for silent tone set oct to 4
!-if input is valid for field then jump to data controls
!-else jump to controls
208y3=int((y1-2)/3)
209if((y1=2ory1=5)or(y1=8ory1=11))andx<2then213
210if((y1=3ory1=6)or(y1=9ory1=12))andx<12then213
211if((y1=4ory1=7)or(y1=10ory1=13))andx<5then213
212goto194
!-Data controls
!-sets data to screen and ram
!-jumps to controls
213pokess+x1+(y1*22),pk(x)
214y=(y1-2)-(y3*3):z=peek(ss+x1+(((y3*3)+2)*22))
215a=peek(ss+x1+(((y3*3)+3)*22)):b=peek(ss+x1+(((y3*3)+4)*22))
216fort=.to15:ifz=pk(t)thenc=t
217ifa=pk(t)thend=t
218ifb=pk(t)thene=t
219nextt:pokesd+x1-6+(y3*16)+(pa*64),e+(c*8)+(d*16):goto194
!---------------------------------------------------------------------------
!-amp mod
220PRINT"{clear}{reverse off}{white}amp mod"
221PRINT"{down}v0    {reverse on}                ";
222PRINT"{reverse off}v1    {reverse on}                ";
223PRINT"{reverse off}v2    {reverse on}                ";
224PRINT"{reverse off}v3    {reverse on}                ";
225PRINT"{reverse off}v4    {reverse on}                ";
226PRINT"{reverse off}v5    {reverse on}                ";
227PRINT"{reverse off}v6    {reverse on}                ";
228PRINT"{reverse off}v7    {reverse on}                ";
229PRINT"{reverse off}v8    {reverse on}                ";
230PRINT"{reverse off}v9    {reverse on}                ";
231PRINT"{reverse off}va    {reverse on}                ";
232PRINT"{reverse off}vb    {reverse on}                ";
233PRINT"{reverse off}vc    {reverse on}                ";
234PRINT"{reverse off}vd    {reverse on}                ";
235PRINT"{reverse off}ve    {reverse on}                ";
236PRINT"{reverse off}vf    {reverse on}                {home}";
237sysamstart:x1=6:y1=2:pokesc+x1+(y1*22),cc
!-Controls
!-gets user imput
!-f1-f8 jumps to page control
!-arrows jumps to cursor control
!-"+" and "-" jumps to sub page controls
!-"0"-"f" converts to 0-15 and jumps to data input controls
238x2=0:y2=0:geta$:ifa$=""then238
239ifasc(a$)=140orasc(a$)=136then:gosub251:goto220
240ifasc(a$)>132andasc(a$)<140thengoto5
241ifa$=chr$(17)theny2=1:goto248
242ifa$=chr$(145)theny2=-1:goto248
243ifa$=chr$(29)thenx2=1:goto248
244ifa$=chr$(157)thenx2=-1:goto248
245ifasc(a$)>47andasc(a$)<58thenx=asc(a$)-48:goto250
246ifasc(a$)>64andasc(a$)<71thenx=asc(a$)-55:goto250
!-jumps to controls
247goto238
!-Cursor controls
248ifpeek(ss+x1+x2+((y1+y2)*22))<128then238
249pokesc+x1+(y1*22),ct:x1=x1+x2:y1=y1+y2:pokesc+x1+(y1*22),cc:goto238
!-Input controls
!-sets amp mod data to screen and ram
!-jumps to controls
250pokess+x1+(y1*22),pk(x):pokevd+x1-6+((y1-2)*16),x:goto238
!-PLAYER------------------------------------------------------------------------
251pokecntrl,2:poke36878,peek(volxo)
252print"{clear}{white}{reverse on}vicious tracker "
253print"{down}"f$
254geta$
255ifa$=""then257
256pokecntrl,0:fort=0to3:poke36874+t,0:nextt:return
257print"{home}{down*4}arranger"peek(alenc)"{left}   "
258print"pattern "peek(plenc)"{left}   "
259print"sound   "peek(slenc)"{left}   "
260print"timer   "peek(spdc)"{left}   "
261print"low     "peek(36874)"{left}   "
262print"mid     "peek(36875)"{left}   "
263print"high    "peek(36876)"{left}   "
264print"noise   "peek(36877)"{left}   "
265print"volume  "peek(36878)"{left}   "
266goto254
R'zo
I do not believe in obsolete...
User avatar
Noizer
Vic 20 Devotee
Posts: 297
Joined: Tue May 15, 2018 12:00 pm
Location: Europa

Re: Vicious Tracker

Post by Noizer »

Nice. But what means all these lsr and asl in the ml code?
Are you wasting valuable processor time and RAM doing this?
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
User avatar
R'zo
Vic 20 Nerd
Posts: 514
Joined: Fri Jan 16, 2015 11:48 pm

Re: Vicious Tracker

Post by R'zo »

Noizer wrote: Sun Jul 19, 2020 1:52 am Nice. But what means all these lsr and asl in the ml code?
Are you wasting valuable processor time and RAM doing this?
All code before the song file is for screen data handling in the editor and not part of the Tracker. It's being used to separate high/low values for hex representation as well as breaking down nibble based values.

Only the code from speed to cntrl are exported for the final song module.
R'zo
I do not believe in obsolete...
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Vicious Tracker

Post by Mike »

Yet, the code you posted shows somewhat inconsiderate use of shift instructions, most probably to mask out bits, where a minimal use of those - to bring a bit group into the proper position within a byte and then masking the value with an AND instruction would be the canonical way to do this. Also, there are quite some useless CLC instructions lingering around, ASL and LSR do not "shift in" the carry flag. Finally, all that repeated code could be replaced by a single sub-routine that places a decoded hex value in A to two consecutive screen RAM bytes, the first of them being pointed to by X/Y (zp and zp+1 are two free bytes in the zeropage):

Code: Select all

.PokeHex
 STX zp
 STY zp+1
 LDY #&00
 PHA
 LSR A
 LSR A
 LSR A
 LSR A
 JSR PokeHex_00
 PLA
 INY
 AND #&0F
.PokeHex_00
 TAX
 LDA PokeHex_01,X
 STA (zp),Y
 RTS
.PokeHex_01
 EQUB &B0:EQUB &B1:EQUB &B2:EQUB &B3:EQUB &B4:EQUB &B5:EQUB &B6:EQUB &B7
 EQUB &B8:EQUB &B9:EQUB &81:EQUB &82:EQUB &83:EQUB &84:EQUB &85:EQUB &86
Translation of above code into the preferred assembler syntax left as exercise for the reader.
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: Sun Jul 19, 2020 6:41 am Yet, the code...
After staring at your code for the last 24 hours I've figured out everything your doing. I had considered trying zp indexing for this. I shied away because I was already working with techniques and optcodes that I hadn't used yet and I'm trying to take my learning process a few steps at a time. At this point I say, why not, I'm going for it all.

Pushing the accumulator to the stack to temporarily store a value seemed clever to me at first. After referencing compute I see that is exactly what pla and pha are intended to do. I wasn't intending on takling the stack for a bit but there it is. This as well as using and for masking will help speed up my player routine as well where I I'm juggling quite a few values back and forth through registers. If my understand how the stack works I should be able to push multiple values and pull them back in reverse sequence (please don't spoil it for me :) ). If this is the case it will help speed up the player as well.

Using the AND to mask bits will allow me to compress my song file as well. The arranger area only uses values of 0 to f to for pattern index. With this I'll should able to combine to values in 1 byte and double potential song length without slowing down the player. At least not more than the previous improvements will balance out.

From this point my first task will be to rework the song file and player. I want the song file to be in a stable so the user doesn't have to worry about having their work broken upon future updates. Writing the file converter was also a real headache.

Once the song file is stable I will work on implementing your suggestions into the screen data routines that you've suggested. Past that I think I'll make this a long term project and start converting the editor over to ML. This should allow me to free up enough space to provide an 8k build. I would also like to add my own text characters as well so I can provide actual note representation (c,c#,d,d# etc.) And make it more user friendly for musicians.
R'zo
I do not believe in obsolete...
User avatar
Noizer
Vic 20 Devotee
Posts: 297
Joined: Tue May 15, 2018 12:00 pm
Location: Europa

Re: Vicious Tracker

Post by Noizer »

Very good decision R’zo, to learn some new opcodes. Your wasting style of ml coding remembers myself how my earlier codes looks like, but I learned with the time to squeeze codes to a minimal length and execution time, as a sort of own challenge.
Finally, I guess, the final step to perfection may using illegal opcodes. One can substitute code sequences with different ones, you have only to recognize these.
For example, your code is full of LDA xxxx,y TAX which results in an LAX xxxx,y - less bytes, faster code at all.
Furthermore you shouldn‘t forget to implement the golden gift code examples from Mike. IMHO
Valid rule today as earlier: 1 Byte = 8 Bits
-._/classes instead of masses\_.-
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 has come a long way! To be honest, I didn't spend a ton of time with earlier versions because everything I did was followed by a massive delay. But now the interface is pretty snappy, and I can figure most things out without the manual being done. So getting a song going is fun now.

I have noticed that when I move from the Patterns screen (f3) to Play (f7), pressing any function key redraws the Patterns screen without the left-hand labels. Other screens (Pitch and Amp Mod) seem to work correctly in bouncing back to the previous screen.

During playback, the step number isn't keeping up with the actual step. Sometimes it skips a step in the display (though the playback itself is fine).

If you're up for navigation suggestions, consider using the back-arrow key as an "escape" key to always return you to the file/settings screen, then you'll have f1/f3/f5/f7 available for Arranger/Patterns/Pitch Mod/Amp Mod, without needing to use shift+f1 and shift+f3. Maybe Play could be on Space or Return.

I'm sure I'll have other comments as I go along.

Edit: Consider disabling the STOP key during execution.
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: Wed Jul 22, 2020 2:41 pm This has come a long way! ...
Thank you for your feedback. Mike's suggestions really helped speed things up.

I've noticed the bug on the pattern screen. Really not sure what's causing it. Since I'm planning on rewriting the editor in assembly I'm not to concerned with it at the moment.

The playback display is currently in basic. It just can't quite keep. Earlier builds were compiled so it looked a little better before. I couldn't compile this build because the routines that make everything else run faster can't be compiled. This issue will be resolved once converted over to assembly.

Your navigation suggestions are excellent. Will definitely implement. Do you think a quick jump feature for pages within sections would be helpful? I.e. shift + 0-f would jump jump from any page 0-f in pattern editor.

I have chosen not to disable the run/stop key because I'm planning on giving the user commands for extracting the player, initializer and notable independently. Features not available in the editor itself. The user would be able to exit the program with everything still in memory and enter commands from basic to extract whatever part they choose. This will go away once I rewrite everything in assembly but I can still put in a feature to exit to basic.
R'zo
I do not believe in obsolete...
Post Reply