  ; ›  ; RePlay.ASM›  ; ==========›  ; ›  ; Fuer mit SoundMonitor Professional›  ; erstelle Musikstuecke! (V1.2)›  ; ›  ; Kann So assembliert werden, dann›  ; aber ueber Sprungtabelle aufrufen!›  ; › OPT F,R,I›  ; › ORG $3000›  ; Sprungtabelle› JMP Mp.Init› JMP Mp.Play›  ; ›  ; MusicPlayer V1.2›  ; belegt ZP-Adresse $00 & $01 !›  ; Parametertabelle Abspielroutine›  ; › Mp.pos:DFB 0 ; Position› Mp.ptp:DFB 0,0 ; Pos. im Pattern› Mp.spd:DFB 0 ; Zaehler Geschw.› Mp.tim:DFB 0 ; Abspielgeschw.› Mp.len:DFB 0 ; Laenge Musikstueck› Mp.par:ASC %00000000% Audio-Werte› Mp.ctl:DFB 0 ; Audio-Control› Mp.TrkAdr:DFW 0 ; Abspielreihenfolge› Mp.TrkBas:DFW 0 ; Basisadresse Trackspeicher› Mp.HulBas:DFW 0 ; Basisadresse Huellk.›  ; › FlagTab:ASC %                % 16›  ; › Mp.pat:DFB 0,0,0,0 ; Pattern-Nr.› Mp.hkp:DFB 0,0,0,0 ; Zeiger Huellkurve› Mp.fmp:DFB 0,0,0,0 ; Zeiger FM-Kurve› Mp.hkn:DFB 0,0,0,0 ; Huellkurve› Mp.ton:DFB 0,0,0,0 ; Tonfreq.› Mp.vol:DFB 0,0,0,0 ; Kanal-Volume› Mp.not:DFB 0,0,0,0 ; Noten-Nr.› Mp.eff:DFB 0,0,0,0 ; Effekt› Mp.cnt:DFB 0 ; Interner Zaehler› Mp.wrk:DFW 0 ; Arbeitsbereich !› Mp.ende:DFB 0›  ; ›  ; Initialisierungsroutine›  ; Adresse des ungep. Songs in X/Y!› Mp.Init:STX 0› STY 1› LDX #Mp.ende-FlagTab› LDA #0› Mp.i1:STA FlagTab,X› DEX › BPL Mp.i1› LDA #7› STA Mp.tim› LDA #0› STA Mp.ctl› Mp.i2:LDA #1› STA Mp.spd› LDA #32› STA Mp.ptp› LDA #3› STA Skctl› LDA #0› STA $d208› LDX #7› Mp.i3:STA $d200,X› STA Mp.par,X› DEX › BPL Mp.i3› LDY #3› LDA (0),Y› STA Mp.len›  ; Basisadresse Trk-Abspielreihenfolge› LDA 0› CLC › ADC #5› STA Mp.TrkAdr› LDA 1› ADC #0› STA Mp.TrkAdr+1› LDA Mp.len› STA Mp.wrk› LDA #0› STA Mp.wrk+1› LDX #1› Mp.i4:ASL Mp.wrk› ROL Mp.wrk+1› DEX › BPL Mp.i4› LDA Mp.wrk› CLC › ADC Mp.trkAdr› STA Mp.TrkBas› LDA Mp.wrk+1› ADC Mp.TrkAdr+1› STA Mp.TrkBas+1› LDY #2› LDA (0),Y ; Anzahl Pattern› STA Mp.wrk› LDA #0› STA Mp.wrk+1› LDX #5› Mp.i5:ASL Mp.wrk› ROL Mp.wrk+1› DEX › BPL Mp.i5› LDA Mp.wrk› CLC › ADC Mp.TrkBas› STA Mp.HulBas› LDA Mp.wrk+1› ADC Mp.TrkBas+1› STA Mp.HulBas+1› LDA #-1› STA Mp.pos›  ; ›  ; Routine laeuft in Mp.PLay 'rein›  ; fuer 1. Initialisierungsphase !›  ; ›  ; Mp.Play alle 1/50 sekunden aufrufen!›  ; › Mp.Play:LDX #8› Mp.p1:LDA Mp.par,X› STA $d200,X› DEX › BPL Mp.p1› DEC Mp.spd› BEQ Mp.p1a› JMP Mp.DoSnd› Mp.p1a:LDA Mp.ptp+1› BEQ Mp.p1a1› SEC › SBC #1› STA Mp.pos› LDA #31› STA Mp.ptp› LDA #0› STA Mp.ptp+1› Mp.p1a1:LDA Mp.tim› STA Mp.spd›  ; naechste Note im Pattern !› INC Mp.ptp› LDA Mp.ptp› CMP #32› BCC Mp.p2›  ; naechstes Pattern› LDA #0› STA Mp.ptp› INC Mp.pos› LDX Mp.pos› CPX Mp.len ; Ende ?› BNE Mp.p1b› LDX #0› STX Mp.pos› Mp.p1b:› TXA › CLC › ADC Mp.TrkAdr› STA 0› LDA #0› ADC Mp.TrkAdr+1› STA 1› LDY #0› LDX #0› Mp.p1c:LDA (0),Y› STA Mp.pat,X› LDA 0› CLC › ADC Mp.len› STA 0› BCC Mp.p1d› INC 1› Mp.p1d:INX › CPX #4› BCC Mp.p1c› Mp.p2:› LDA #3 ; Kanal› STA Mp.cnt› Mp.p3:› LDX Mp.cnt› LDA #0› STA 1› LDA Mp.pat,X› LDY #5› Mp.p3a:ASL › ROL 1› DEY › BPL Mp.p3a› CLC › ADC Mp.TrkBas› STA 0› LDA 1› ADC Mp.TrkBas+1› STA 1› LDY Mp.ptp› LDA (0),Y ; Note + >hk› STA Mp.wrk› LSR › LSR › CMP #0› BEQ Mp.paronly› STA Mp.not,X› LDA #0› STA Mp.hkp,X› STA Mp.fmp,X› LDA Mp.ptp› CLC › ADC #32› TAY › LDA (0),Y ; parameter+<hk› STA Mp.wrk+1› AND #15› STA Mp.vol,X›  ; 4 * schieben fuer HK› Mp.p36:LDX Mp.cnt› LDA Mp.wrk+1› LSR Mp.wrk› ROR › LSR Mp.wrk› ROR › LSR › LSR › AND #63› STA Mp.hkn,X› Mp.nxt1:DEC Mp.cnt› BPL Mp.p3j› JMP Mp.DoSnd› Mp.p3j:JMP Mp.p3› Mp.Paronly: ; Keine Note, Parameter bearbeiten!›  ; bit 0-3 Parameter, 4-7 Kommando› LDA Mp.ptp› CLC › ADC #32› TAY › LDA (0),Y› PHA › LSR › LSR › LSR › AND #30 ; fuer Zugriff› TAX  ; auf Adresstabelle !› LDA Mp.FnAdr,X› STA Mp.p39+1› LDA Mp.FnAdr+1,X› STA Mp.p39+2› PLA › AND #15 ; parameter !› TAY  ; auch als Index› LDX Mp.cnt ; Kanal› Mp.p39:JSR $e474› JMP Mp.nxt1›  ; ›  ; Nach Hullkurvendaten und›  ; FM-Daten Sound berechnen›  ; › Mp.DoSnd:LDA #3› STA Mp.cnt› Mp.p4:› LDX Mp.cnt› LDA #0› STA 1› LDA Mp.hkn,X› LDY #4› Mp.p4a:ASL › ROL 1› DEY › BPL Mp.p4a› CLC › ADC Mp.HulBas› STA 0› LDA 1› ADC Mp.HulBas+1› STA 1› LDA Mp.hkp,X› CMP #31› BCS Mp.p40› INC Mp.hkp,X› Mp.p40:LDY #0› LDA (0),Y› LDY Mp.not,X› TAX › LDA Noten_tab0,Y› DEX › BMI Mp.p44› CPY #38› BCS Mp.p44› LDA Noten_Tab1,Y› DEX › BMI Mp.p44› LDA Noten_Tab2,Y› DEX › BMI Mp.p44› TYA › ASL › ASL › Mp.p44:LDX Mp.cnt› STA Mp.ton,X› Mp.p45:LDY Mp.hkp,X› LDA (0),Y› BPL Mp.p5›  ; Relativer Sprungbefehl !› AND #31› STA Mp.wrk› TYA › SEC › SBC Mp.wrk› STA Mp.hkp,X› BCS Mp.p45 ; immer› Mp.p5:STA Mp.wrk› AND #16 ; DEC Volume ?› BEQ Mp.p6› LDA Mp.vol,X› BEQ Mp.p6› DEC Mp.vol,X› Mp.p6:LDA Mp.wrk› AND #15› STA Mp.wrk+1› LDA Mp.vol,X› ASL › ASL › ASL › ASL › ORA Mp.wrk+1› TAY › LDA Mp.VolTab,Y› PHA › TXA › ASL › TAY › PLA › STA Mp.par+1,Y› STY Mp.p7a+1› LDA Mp.ton,X› PHA › ASL Mp.wrk› ASL Mp.wrk› ROL › ASL Mp.wrk› ROL › AND #3› ASL › TAX › LDA Mp.sub1,X› STA Mp.p7+1› LDA Mp.sub1+1,X› STA Mp.p7+2› PLA  ; Ton holen› STA Mp.wrk› Mp.p7:JSR $e474 ; Ton modifizieren› STA Mp.par,Y ; und merken› STA Mp.wrk›  ; FM-Berechnung› LDX Mp.cnt› LDY #32› LDA (0),Y ; Klang/Instr.› Mp.p7a:LDY #0 ; smd› ORA Mp.par+1,Y› STA Mp.par+1,Y› LDA Mp.fmp,X› CMP #31› BCS Mp.p8› INC Mp.fmp,X› Mp.p8:› LDA Mp.fmp,X› CLC › ADC #32 ; Huellkurve+32› TAY  ; ergibt FM-Huellk.!› LDA (0),Y› BPL Mp.p9›  ; Relativer Sprungbefehl !› AND #31› STA Mp.wrk› LDA Mp.fmp,X› SEC › SBC Mp.wrk› STA Mp.fmp,X› BCS Mp.p8 ; immer› Mp.p9:STA Mp.wrk› PHA › AND #15› TAY › PLA › LSR › LSR › LSR › LSR › LSR › AND #3› TAX  ; mod.-Grad› LDA Mp.FMtab,Y› Mp.p95:DEX › BMI Mp.p10› ASL › BNE Mp.p95› Mp.p10:STA Mp.wrk+1› LDA Mp.cnt› ASL › TAX › CPY #8› LDY Mp.cnt› BCC Mp.p10a›  ; subtrahieren› LDA Mp.par,X› SEC › SBC Mp.wrk+1› BCS Mp.p11› LDA #0› BEQ Mp.p11› Mp.p10a:› LDA Mp.par,X› CLC › ADC Mp.wrk+1› STA Mp.wrk+1› BCC Mp.p11› LDA #-1› Mp.p11:STA Mp.wrk+1› LDA Mp.cnt› TAX › ASL › TAY › LDA Mp.wrk+1› STA Mp.par,Y› DEC Mp.cnt› BMI Mp.quit› JMP Mp.p4›  ; mp.Eff-Kram (UpDate V1.0 nach V1.1)› Mp.quit:LDA #0› STA Mp.cnt› Mp.qt1:LDA Mp.cnt› TAX › ASL › TAY › LDA Mp.Eff,X› BEQ Mp.qt2› SEC › SBC #1› CMP #15› BCC Mp.qt3› Mp.qt2:INC Mp.cnt› LDA Mp.cnt› CMP #4› BCC Mp.qt1› RTS › Mp.qt3:CMP #12› BCC Mp.qt5› SBC #12› TAX › LDA Mp.par,Y› Mp.qt4:LSR › DEX › BPL Mp.qt4› STA Mp.par,Y› BMI Mp.qt2 ; immer !› Mp.qt5:PHA › AND #3 ; Ziel-Kanal› ASL › TAX › LDA Mp.par,Y› STA Mp.wrk› STA Mp.wrk+1› PLA › LSR › LSR › LSR › BCC Mp.qt6› PHA › LDA Mp.wrk› AND #254› STA Mp.wrk› LSR › STA Mp.wrk+1› PLA › Mp.qt6:LSR › BCC Mp.qt7› LDA Mp.wrk› ORA #1› STA Mp.wrk› LSR › STA Mp.wrk+1› Mp.qt7:LDA Mp.wrk› STA Mp.par,Y› LDA Mp.wrk+1› STA Mp.par,X› JMP Mp.qt2›  ; › Mp.sub1:DFW Mp.mod0,Mp.mod1› DFW Mp.mod2,Mp.mod3› Mp.mod1:LSR Mp.wrk› Mp.mod2:LSR Mp.wrk› Mp.mod3:LSR Mp.wrk› SEC › SBC Mp.wrk› Mp.mod0:RTS ›  ; › Mp.FMtab:DFB 8,7,6,5,4,3,2,1› DFB 0,1,2,3,4,5,6,7›  ; › Mp.FnAdr:DFW NoFn,FnVol,FnSet,FnClr› DFW FnUN,FnDN,FnLAC,FnHAC› DFW FnQt,FnEff,FnJpH,FnJpL› DFW FnTiH,FnTiL,FnAR,FnWt›  ; Reine Toene› Noten_Tab0:DFB 0› DFB 243,231,217,205,193› DFB 181,172,162,153,145› DFB 136,127,121,115,108› DFB 102,96,91,85,81,76,72› DFB 67,63,60,57,54,51,48› DFB 45,42,40,37,36,33,31› DFB 30,1,2,3,4,5,6,7,8,9›  ; "Harte" Basstoene› Noten_Tab1:DFB 0› DFB 243,231,217,205,193› DFB 181,172,162,153,145› DFB 136,127,121,115,108› DFB 100,96,91,85,81,76,72› DFB 67,63,60,57,55,52,48› DFB 45,42,40,37,36,33,31› DFB 30›  ; "Weiche" Basstoene› Noten_Tab2:DFB 0› DFB 242,230,218,203,191› DFB 182,173,161,152,143› DFB 137,128,122,113,107› DFB 101,95,92,86,80,77,71› DFB 68,65,62,56,53,50,47›  ; › DFB 45,41,40,37,35,33,31› DFB 30›  ; › Mp.VolTab:DFB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0› DFB 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1› DFB 0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2› DFB 0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3› DFB 0,0,1,1,1,2,2,2,2,2,3,3,3,3,4,4› DFB 0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5› DFB 0,0,1,1,2,2,2,3,3,4,4,4,5,5,6,6› DFB 0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7› DFB 0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8› DFB 0,1,1,2,2,3,4,4,5,5,6,7,7,8,8,9› DFB 0,1,1,2,3,3,4,5,5,6,7,7,8,9,9,10› DFB 0,1,1,2,3,4,4,5,6,7,7,8,9,10,10,11› DFB 0,1,2,2,3,4,5,6,6,7,8,9,10,10,11,12› DFB 0,1,2,3,3,4,5,6,7,8,9,10,10,11,12,13› DFB 0,1,2,3,4,5,6,7,7,8,9,10,11,12,13,14› DFB 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15›  ; › FnVol:STA Mp.Vol,X› NoFn:RTS › FnSet:LDA #-1› FnS1:STA FlagTab,Y› RTS › FnClr:LDA #0› BEQ FnS1› FnUN:STA 0› LDA Mp.Not,X› SEC › SBC 0› BEQ FnUn0› BCS FnUn1› Fnun0:LDA #1› FnUn1:STA Mp.Not,X› RTS › FnDN:STA 0› LDA Mp.Not,X› CLC › ADC 0› CMP #47› BCC FnUn1› LDA #46› BNE FnUn1› FnLAC:STA 0› LDA Mp.ctl› AND #240› FnAC:ORA 0› STA Mp.ctl› RTS › FnHAC:ASL › ASL › ASL › ASL › STA 0› LDA Mp.ctl› AND #15› BPL FnAC› FnQt:LDA Mp.pos› CLC › ADC #1› STA Mp.ptp+1› RTS › FnEff:STA Mp.Eff,X› RTS › FnJpH:ASL › ASL › ASL › ASL › STA 0› LDA Mp.ptp+1› AND #15› BPL Fnjp1› FnJpL:STA 0› LDA Mp.ptp+1› AND #240› Fnjp1:ORA 0› STA Mp.ptp+1› RTS › FnTiH:ASL › ASL › ASL › ASL › STA 0› LDA Mp.tim› AND #15› BPL Fnti1› FnTiL:STA 0› LDA Mp.tim› AND #240› Fnti1:ORA 0› STA Mp.tim› STA Mp.spd› RTS › FnAR:LDA #0› STA Mp.ctl› RTS › FnWt:LDA FlagTab,Y› BNE FnWt1› DEC Mp.ptp› LDA #1› STA Mp.spd› FnWt1:RTS ›  ; › ›