📄 tm2.asx
字号:
;-------------------; TMC 2.00 Player;------------------player equ $200normal equ 1 ; change to 0 for short version org playeraddr equ $fabyte equ $fcbajt equ $fdfilter equ $femaxvol equ $ff; some tables on start (to avoid page breaking)voltab dta d' ' dta d' !!!!!!!!' dta d' !!!!!!!!""""' dta d' !!!!!"""""###' dta d' !!!!""""####$$' dta d' !!!"""###$$$%%' dta d' !!"""##$$$%%&&' dta d' !!""##$$%%&&''''' dta d' !!""##$$%%&&''''(' dta d' !!""#$$%%&''''(()' dta d' !!"##$%%&''''())*' dta d' !!"#$$%&''''()**+' dta d' !""#$%&&''()**+,' dta d' !"##$%&''()**+,-' dta d' !"#$%&''''()*+,-.' dta d' !"#$%&''()*+,-./'frqtab dta 0,$f1,$e4,$d7 dta $cb,$c0,$b5,$aa dta $a1,$98,$8f,$87 dta $7f,$78,$72,$6b dta $65,$5f,$5a,$55 dta $50,$4b,$47,$43 dta $3f,$3c,$38,$35 dta $32,$2f,$2c,$2a dta $27,$25,$23,$21 dta $1f,$1d,$1c,$1a dta $18,$17,$16,$14 dta $13,$12,$11,$10 dta 15,14,13,12 dta 11,10,9,8 dta 7,6,5,4 dta 3,2,1,0 dta 0,$f2,$e9,$da dta $ce,$bf,$b6,$aa dta $a1,$98,$8f,$89 dta $80,$7a,$71,$6b dta $65,$5f,$5c,$56 dta $50,$4d,$47,$44 dta $3e,$3c,$38,$35 dta $32,$2f,$2d,$2a dta $28,$25,$23,$21 dta $1f,$1d,$1c,$1a dta $18,$17,$16,$14 dta $13,$12,$11,$10 dta 15,14,13,12 dta 11,10,9,8 dta 7,6,5,4 dta 3,2,1,0 dta 0,$ff,$f1,$e4 dta $d8,$ca,$c0,$b5 dta $ab,$a2,$99,$8e dta $87,$7f,$79,$73 dta $70,$66,$61,$5a dta $55,$52,$4b,$48 dta $43,$3f,$3c,$39 dta $37,$33,$30,$2d dta $2a,$28,$25,$24 dta $21,$1f,$1e,$1c dta $1b,$19,$17,$16 dta $15,$13,$12,$11 dta $10,15,14,13 dta 12,11,10,9 dta 8,7,6,5 dta 4,3,2,1 dta 0,$f3,$e6,$d9 dta $cc,$c1,$b5,$ad dta $a2,$99,$90,$88 dta $80,$79,$72,$6c dta $66,$60,$5b,$55 dta $51,$4c,$48,$44 dta $40,$3c,$39,$35 dta $32,$2f,$2d,$2a dta $28,$25,$23,$21 dta $1f,$1d,$1c,$1a dta $18,$17,$16,$14 dta $13,$12,$11,$10 dta 15,14,13,12 dta 11,10,9,8 dta 7,6,5,4 dta 3,2,1,0basslo dta l($be2,$b38,$a8c,$a00) dta l($96a,$8e8,$86a,$7ef) dta l($780,$708,$6ae,$646) dta l($5e6,$595,$541,$4f6) dta l($4b0,$46e,$430,$3f6) dta l($3bb,$384,$352,$322) dta l($2f4,$2c8,$2a0,$27a) dta l($255,$234,$214,$1f5) dta l($1d8,$1bd,$1a4,$18d) dta l($177,$160,$14e,$138) dta l($127,$115,$106,$0f7) dta l($0e8,$0db,$0cf,$0c3) dta l($0b8,$0ac,$0a2,$09a) dta l($090,$088,$07f,$078) dta l($070,$06a,$064,$05e) dta l($057,$052,$032,$00a) dta 0,$f2,$33,$96 dta $e2,$38,$8c,$00 dta $6a,$e8,$6a,$ef dta $80,$08,$ae,$46 dta $e6,$95,$41,$f6 dta $b0,$6e,$30,$f6 dta $bb,$84,$52,$22 dta $f4,$c8,$a0,$7a dta $55,$34,$14,$f5 dta $d8,$bd,$a4,$8d dta $77,$60,$4e,$38 dta $27,$15,$06,$f7 dta $e8,$db,$cf,$c3 dta $b8,$ac,$a2,$9a dta $90,$88,$7f,$78 dta $70,$6a,$64,$5ebasshi dta h($be2,$b38,$a8c,$a00) dta h($96a,$8e8,$86a,$7ef) dta h($780,$708,$6ae,$646) dta h($5e6,$595,$541,$4f6) dta h($4b0,$46e,$430,$3f6) dta h($3bb,$384,$352,$322) dta h($2f4,$2c8,$2a0,$27a) dta h($255,$234,$214,$1f5) dta h($1d8,$1bd,$1a4,$18d) dta h($177,$160,$14e,$138) dta h($127,$115,$106,$0f7) dta h($0e8,$0db,$0cf,$0c3) dta h($0b8,$0ac,$0a2,$09a) dta h($090,$088,$07f,$078) dta h($070,$06a,$064,$05e) dta h($057,$052,$032,$00a) dta 0,13,13,12 dta 11,11,10,10 dta 9,8,8,7 dta 7,7,6,6 dta 5,5,5,4 dta 4,4,4,3 dta 3,3,3,3 dta 2,2,2,2 dta 2,2,2,1 dta 1,1,1,1 dta 1,1,1,1 dta 1,1,1,0 dta 0,0,0,0 dta 0,0,0,0 dta 0,0,0,0 dta 0,0,0,0tables_len equ *-player; org +$300 jmp init jmp play jmp sound; some external controlsquadro dta 1 ; 0=mono, 1-63=stereo, 64-127= RMT stereo, 128-255=quadropokeys dta 16 ; which data should go to which pokey (0,1,2 and 3 respectively) dta 20 ; for stereo config: 16=first 4 tracks, 20=last 4 tracks dta 0 ; for quadro values should be: dta 0 ; 0=main volume from tracks 0-3, 4=main volume from tracks 4-5 ; 8=additional volume from tracks 0-3, 12=additional volume from tracks 4-5 ; typical: 0,4,12,8 which should sound well on pokeys 0&2 on left channel ; and pokeys 1&3 on right channel ; (on stereo atari these settings should also sound well)silent dta d' ' ; which channel should be silent; these values are usable from the outside of playerczygrc dta 0 ; if song should be playedpozsng dta 0 ; position in songspecialflag dta 0 ; flag triggered in song dataadrsng dta a(0) ; address of song linetempo dta 0 ; tempo of songltempo dta 0 ; counter of tempopozptr dta 0 ; counter of positions in patterns (64 means end of pattern) ift normal ; !!!aud1 dta 0 ; total AUDCTL of left channelaud2 dta 0 ; and rightvoltabs equ * ; (24 bytes) eif ; !!!vol1ch dta d' ' ; volume of main channels ift normal ; !!!vol2ch dta d' ' ; volume of additional channelsvolume dta d' ' ; volume of channels in stereo (taken from vol1ch and vol2ch)freqtabs equ * ; (24 bytes) eif ; !!!frq dta d' ' ; frequency ift normal ; !!!note dta d' ' ; actual note played on channel (taken from aktwys)freqen dta d' ' ; frequency of channels in stereo (taken from frq) eif ; !!!; data for accesing pattern dataadrptl dta d' ' ; address of pattern dataadrpth dta d' ' ;pozwpt dta d' ' ; index for accesing data in patternpoddzw dta d' ' ; change of notedelay dta d' ' ; how many spaces in pattern should be skipped; data for accesing instrument dataczygrx dta d' ' ; if something is played on channeladrsnl dta d' ' ; address of instrument dataadrsnh dta d' ' ;numdzw dta d' ' ; number of instrumentwysdzw dta d' ' ; note to playaktwys dta d' ' ; actual played noteznksz dta d' ' ; distortionaudctl dta d' ' ; AUDCTLslupy dta d' ' ; counter for data inside instrument; data for specific sound effectssndlen dta d' ' ; length of instrumentsndlop dta d' ' ; where to loop sound dataactvol dta d' ' ; volume of soundsactvl1 dta d' ' ; actual control of main volume ift normal ; !!!actvl2 dta d' ' ; and additional volume eif ; !!!opad1 dta d' ' ; how soon the sound should fade (main volume)opad2 dta d' ' ; and additional volumelopad1 dta d' ' ; counters for fadinglopad2 dta d' ' ;opadst dta d' ' ; start of fadingtyp dta d' ' ; type of effectparam dta d' ' ; parameter for effecttypdat dta d' ' ; data for effectczekaj dta d' ' ; how soon the effect should startdtyp dta d' ' ; how often the effect should chanfeltyp dta d' ' ; counter for effect changeilperm dta d' ' ; how many arpeggio soundsaperm dta d' ' ; actual arpeggio sounddperm dta d' ' ; how soon the arpeggio should changelperm dta d' ' ; counter for arpeggiokolejn dta d' ' ; order of arpeggiosndfilter dta d' ' ; filter from sound datamainaudctl dta d' ' ; main audctladdaudctl dta d' ' ; additional audctlshiftfrq dta d' 'shiftnote dta d' 'shiftfilter dta d' '; some useful tables ift normal ; !!!przeci dta 4,5,6,7 ; which channel is the opposite (used only in stereo) dta 0,1,2,3 eif ; !!!audtb1 dta 4,2,0,0 ; which byte in audctl has to be set to make sound "2 channel synth" dta 4,2,0,0audtb2 dta 0,16,0,8 ; which byte in audctl has to be set to make sound "2 channel bass" dta 0,16,0,8usedaudctl dta 4+129,$50+2+129,129,$28+129 ; bits of AUDCTL used in channel dta 4+129,$50+2+129,129,$28+129;-------------------------; start of player programplayer_program equ *; new address of song linep3 dey lda (addr),y sta pozsng mvx #0 byte asl @ rol byte asl @ rol byte asl @ rol byte asl @ rol byte adc pozsng ; clc scc:inc byte clczm0 adc #0 sta addr lda bytezm1 adc #0 sta addr+1 jmp p1; play song (call only one time per frame)play jsr pokey lda czygrc beq rsound dec ltempo bmi p4rsound jmp sound+3p4 dec pozptr bne r1; get new patterns from song ldx #0 inc pozsng mwa adrsng addrp1 ldy #16 lda (addr),y bmi p3 jeq stop sta pozptr deyp2 lda (addr),y dey sty byte tayzm2 lda $ffff,y sta adrptl,xzm3 lda $ffff,y sta adrpth,x lda #0 sta delay,x sta pozwpt,x ldy byte lda (addr),y sta poddzw,x inx dey bpl p2 lda #17 add addr sta adrsng lda #0 adc addr+1 sta adrsng+1; get new data from patternsr1 mva tempo ltempo ldx #7r2 dec delay,x bmi r13r14 dex bpl r2 jmp sound+3r13 mva adrptl,x addr mva adrpth,x addr+1 ldy pozwpt,xr3 lda (addr),y ; get data bne r4 iny ; $00: only new volume lda (addr),y sta actvol,x and #$f0 sta actvl1,x ift normal ; !!! lda (addr),y asl @ asl @ asl @ asl @ sta actvl2,x eif ; !!! iny tya sta pozwpt,x jmp r14r4 cmp #$40 bcs r5 adc poddzw,x ; $01-$3f: new note with sound and maybe volume sta wysdzw,x iny lda (addr),y bpl r11 and #$7f sta byte iny lda (addr),y sta actvol,x and #$f0 sta actvl1,x ift normal ; !!! lda (addr),y asl @ asl @ asl @ asl @ sta actvl2,x eif ; !!! iny tya sta pozwpt,x ldy byte jsr dzwiek jmp r14r11 tay ; without volume inc pozwpt,x inc pozwpt,x lda actvol,x and #$f0 sta actvl1,x ift normal ; !!! lda actvol,x asl @ asl @ asl @ asl @ sta actvl2,x eif ; !!! jsr dzwiek jmp r14r5 cmp #$80 bcs r6 and #$3f ; $41-$7f: new note with volume add poddzw,x sta wysdzw,x iny lda (addr),y sta actvol,x and #$f0 sta actvl1,x ift normal ; !!! lda (addr),y asl @ asl @ asl @ asl @ sta actvl2,x eif ; !!! iny tya sta pozwpt,x jmp r14r6 bne r7 iny ; $80: more than 15 spaces lda (addr),y sta delay,x iny tya sta pozwpt,x jmp r14r7 cmp #$c0 bcs r8 and #$3f ; $81-$bf: new note add poddzw,x sta wysdzw,x inc pozwpt,x jmp r14r8 cmp #$d0 bcs r9 iny ; $c0-$cf: new tempo inc pozwpt,x and #15 sta tempo sta ltempo jmp r3r9 cmp #$e0 ; special code bcs r15 mva (addr),y byte iny mva (addr),y bajt iny tya sta pozwpt,x lda byte jsr specialcode jmp r14r15 cmp #$f0 ; special code with volume bcs r12 mva (addr),y byte iny mva (addr),y bajt lda byte jsr specialcode ldy pozwpt,x iny iny lda (addr),y sta actvol,x and #$f0 sta actvl1,x ift normal ; !!! lda (addr),y asl @ asl @ asl @ asl @ sta actvl2,x eif ; !!! iny tya sta pozwpt,x jmp r14r12 cmp #$ff bcs r10 sbc #$ef ; $f0-$fe: spaces-$f0 (c is clear here) sta delay,x inc pozwpt,x jmp r14r10 lda #$40 ; $ff: spaces till the end of pattern sta delay,x jmp r14; main play sound loopsound jsr pokey ldx #7p5 lda czygrx,x beq p6 jmp grajgrajreturn equ * lda silent,x beq p7 lda #0 ; silent channel sta vol1ch,x ift normal ; !!! sta vol2ch,x eif ; !!! dex bpl p5 jmp p8p7 ldy bajt lda frqtab,y add byte sta frq,x tya sta aktwys,x lda audctl,x and audtb2,x beq p11 lda bajt ; 2 channel bass and #$7f tay lda basslo,y add byte sta frq-1,x lda basshi,y adc #0 sta frq,x lda #0 sta vol1ch-1,x ldy przeci,x sta vol2ch-1,y dex dex bpl p5 jmp p8p11 lda audctl,x and audtb1,x beq p6 lda sndfilter,x ;two channel filter add bajt sta aktwys+2,x tay lda frqtab,y add byte sec adc filter sta frq+2,xp6 dex bpl p5; sound postprocessingp8 inx stx byte ift normal ; !!! ldx #3 lda quadro beq p9 and #$40 bne p12 ldx #7 ; standard stereo settingsp9 txa tay lda vol1ch,y bne p10 ldy przeci,x lda vol2ch,y bne p10 txa tay lda #0p10 ora znksz,y sta volume,x lda frq,y sta freqen,x lda aktwys,y sta note,x lda audctl,y ora byte sta byte cpx #4 sne:sta aud2 dex bpl p9 sta aud1 rtsp12 equ * ; RMT stereop13 lda vol1ch,x ora znksz,x sta volume,x lda vol2ch+4,x ora znksz+4,x sta volume+4,x mva frq,x freqen,x mva frq+4,x freqen+4,x mva aktwys,x note,x mva aktwys+4,x note+4,x dex bpl p13 lda audctl ora audctl+1 ora audctl+2 ora audctl+3 sta aud1 lda audctl+4 ora audctl+5 ora audctl+6 ora audctl+7 sta aud2 rts; set pokeypokey lda quadro jeq pokey1 jpl pokey2 lda pokeys+3 ; data for pokey 3 tax lsr @ lsr @ and #1 tay lda aud1,y sta $d238 txa and #4 tay lda freqtabs,y sta $d230 lda voltabs,x sta $d231 lda freqtabs+1,y sta $d232 lda voltabs+1,x sta $d233 lda freqtabs+2,y sta $d234 lda voltabs+2,x sta $d235 lda freqtabs+3,y sta $d236 lda voltabs+3,x sta $d237 lda pokeys+2 ; data for pokey 2 tax lsr @ lsr @ and #1 tay lda aud1,y sta $d228 txa and #4 tay lda freqtabs,y sta $d220 lda voltabs,x sta $d221 lda freqtabs+1,y sta $d222 lda voltabs+1,x sta $d223 lda freqtabs+2,y sta $d224 lda voltabs+2,x sta $d225 lda freqtabs+3,y sta $d226 lda voltabs+3,x sta $d227pokey2 lda pokeys+1 ; data for pokey 1 tax lsr @ lsr @ and #1 tay
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -