From dd3c897b0cfde003d744ad9438c28183175b953d Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Sun, 10 Jul 2016 22:43:00 -0700 Subject: [PATCH] audio experiments --- src/libsrc/tone.pla | 121 ++++++++++++++++++++++++++++++++++++++++++++ src/makefile | 7 ++- 2 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/libsrc/tone.pla diff --git a/src/libsrc/tone.pla b/src/libsrc/tone.pla new file mode 100644 index 0000000..a2b46e4 --- /dev/null +++ b/src/libsrc/tone.pla @@ -0,0 +1,121 @@ +export asm tone(pitch, duration) +!SOURCE "vmsrc/plvmzp.inc" + DEX + LDA ESTKL+1,X + STA ESTKL,X + LDA ESTKH+1,X + STA ESTKH,X + LDA #$00 + STA ESTKL+1,X + STA ESTKH+1,X +end +export asm tone2(pitch1, pitch2, duration) + STX ESP + LDY ESTKH,X + LDA ESTKL,X + BEQ + + INY ++ STA DSTL + STY DSTH + LDA ESTKL+1,X + STA TMPL + LDA ESTKL+2,X + CMP TMPL + BNE + + LDA #$00 ++ STA TMPH + LDY TMPL + LDX TMPH + LDA #$00 + PHP + SEI +- CLC +-- DEY + BNE + + LDY TMPL + BEQ ++ ; SILENCE + STA $C030 + BNE +++ ++ NOP + NOP +++ NOP + NOP + NOP ++++ DEX + BNE + + LDX TMPH + BEQ ++ ; SILENCE + STA $C030 + BNE +++ ++ NOP + NOP +++ NOP + NOP + NOP ++++ ADC #$01 + BNE -- + DEC DSTL + BNE - + DEC DSTH + BNE - + PLP + LDX ESP + INX + INX + RTS +end +export asm tonePWM(sample, speed, len) + STX ESP + LDA ESTKL,X + BEQ + + INC ESTKH,X ++ LDA ESTKL+2,X + STA SRCL + LDA ESTKH+2,X + STA SRCH + LDA ESTKL+1,X + BNE ++ + LDY #$00 +- LDA (SRC),Y + SEC +-- SBC #$01 + BCS -- + LDA $C030 + INY + BNE + + INC SRCH ++ LDX ESP + DEC ESTKL,X + BNE - + DEC ESTKH,X + BNE - + INX + RTS +++ STA TMPL + LDY #$00 +- LDA (SRC),Y + SEC +-- LDX TMPL +--- DEX + BNE --- + SBC #$01 + BCS -- + LDA $C030 + INY + BNE + + INC SRCH ++ LDX ESP + DEC ESTKL,X + BNE - + DEC ESTKH,X + BNE - + INX + RTS +++ +end +def toneTest + byte t + tonePWM($D000, 0, $2000) +end +toneTest() +done \ No newline at end of file diff --git a/src/makefile b/src/makefile index 96b66ea..6d1917b 100644 --- a/src/makefile +++ b/src/makefile @@ -17,6 +17,7 @@ INET = INET\#FE1000 DHCP = DHCP\#FE1000 HTTPD = HTTPD\#FE1000 DGR = DGR\#FE1000 +TONE = TONE\#FE1000 ROGUE = ROGUE\#FE1000 ROGUEIO = ROGUEIO\#FE1000 ROGUEMAP= ROGUEMAP\#FE1000 @@ -51,7 +52,7 @@ TXTTYPE = .TXT #SYSTYPE = \#FF2000 #TXTTYPE = \#040000 -all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(MEMMGR) $(MEMTEST) $(FIBER) $(SB) $(MON) $(ROD) $(SIEVE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1) $(DGR) $(DGRTEST) +all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(MEMMGR) $(MEMTEST) $(FIBER) $(SB) $(MON) $(ROD) $(SIEVE) $(UTHERNET2) $(UTHERNET) $(ETHERIP) $(INET) $(DHCP) $(HTTPD) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1) $(TONE) $(DGR) $(DGRTEST) clean: -rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) @@ -156,6 +157,10 @@ $(HTTPD): samplesrc/httpd.pla $(PLVM02) $(PLASM) ./$(PLASM) -AM < samplesrc/httpd.pla > samplesrc/httpd.a acme --setpc 4094 -o $(HTTPD) samplesrc/httpd.a +$(TONE): libsrc/tone.pla $(PLVM02) $(PLASM) + ./$(PLASM) -AM < libsrc/tone.pla > libsrc/tone.a + acme --setpc 4094 -o $(TONE) libsrc/tone.a + $(DGR): libsrc/dgr.pla $(PLVM02) $(PLASM) ./$(PLASM) -AM < libsrc/dgr.pla > libsrc/dgr.a acme --setpc 4094 -o $(DGR) libsrc/dgr.a