Compare commits

..

No commits in common. "attiny13" and "master" have entirely different histories.

3 changed files with 70 additions and 88 deletions

View file

@ -4,11 +4,11 @@
all: flash all: flash
noiseplug.o: noiseplug.s noiseplug.o: noiseplug.S
avr-gcc -Os -nostdlib -mmcu=attiny13 -o $@ -c $< avr-gcc -Os -nostdlib -mmcu=attiny9 -o $@ -c $<
noiseplug.elf: noiseplug.o noiseplug.elf: noiseplug.o
avr-gcc -Os -nostdlib -mmcu=attiny13 -o $@ $< avr-gcc -Os -nostdlib -mmcu=attiny9 -o $@ $<
noiseplug.hex: noiseplug.elf noiseplug.hex: noiseplug.elf
avr-objcopy -O ihex $< $@ avr-objcopy -O ihex $< $@
@ -18,4 +18,4 @@ flash: noiseplug.hex
dump: noiseplug.elf dump: noiseplug.elf
avr-objdump -Sr $< | less avr-objdump -Sr $< | less

View file

@ -5,16 +5,21 @@
.global __vectors .global __vectors
SREG = 0x3F SREG = 0x3F
SPH = 0x3E
SPL = 0x3D SPL = 0x3D
TIMSK0 = 0x39 CCP = 0x3C
TIFR0 = 0x38 SMCR = 0x3A
OCR0A = 0x36 CLKPSR = 0x36
MCUCR = 0x35 TCCR0A = 0x2E
TCCR0B = 0x33 TCCR0B = 0x2D
TCCR0A = 0x2F TCCR0C = 0x2C
CLKPS = 0x26 TIMSK0 = 0x2B
PORTB = 0x18 TIFR0 = 0x2A
DDRB = 0x17 OCR0AL = 0x26
PUEB = 0x03
PORTB = 0x02
DDRB = 0x01
PINB = 0x00
LEADSIZE = 174 LEADSIZE = 174
LEADINIT1 = 1601 LEADINIT1 = 1601
@ -38,48 +43,40 @@ LEADINIT2 = 3571
__vectors: __vectors:
NULL: NULL:
; this next three instructions of the code are sitting clr r16
; in the place of the vectors for interrupts 0, 1 and 2 ldi r17, 0xD8
; it doesn't matter because we are only using interrupt 3 out PUEB, r16
ldi r30, 0x60
ldi r18, LEADSIZE
rjmp main_cont rjmp main_cont
.type __vector_3, @function .type __vector_4, @function
__vector_3: __vector_4:
push r16 push r16
in r16, SREG in r16, SREG
push r16 push r16
lds r16,int_ctr lds r16,int_ctr
subi r16, -1 subi r16, -1
cpi r16, 5 ; count up to 5, not 4 andi r16, 3
brne no_overflow
ldi r16, 0
no_overflow:
sts int_ctr, r16 sts int_ctr, r16
pop r16 pop r16
out SREG, r16 out SREG, r16
pop r16 pop r16
reti reti
.size __vector_3, .-__vector_3 .size __vector_4, .-__vector_4
main_cont: main_cont:
clr r31
ldi r30, 0x40
clear_sram:
st Z+, r16
sbrs r30, 5
rjmp clear_sram
; this is not really needed, but enable if it makes you feel better ldi r18, 0x5F
;clr r16 out SPL, r18
;clear_sram: out SPH, r16
; st Z+, r16
; ldi r19, 0x9F
; cpse r30, r19
; rjmp clear_sram
; the stack is automatically set up by the attiny13, but
; this next two lines do it if you still want to do it
; note that the attiny13 doesn't have a SPH, since it doesn't
; have that much memory anyway
;ldi r18, 0x9F
;out SPL, r18
ldi r18, LEADSIZE
sts lead1, r18 sts lead1, r18
sts lead2, r18 sts lead2, r18
sts lead3, r18 sts lead3, r18
@ -92,39 +89,24 @@ main_cont:
ldi r18, lo8(LEADINIT2) ldi r18, lo8(LEADINIT2)
sts lead3 + 3, r18 sts lead3 + 3, r18
; set clock divisor = 1, ~9mhz out CCP, r17
ldi r17, 128 out CLKPSR, r16
ldi r16, 0
out CLKPS, r17
out CLKPS, r16
; set portb0 and portb3 as output pins
ldi r17, 5 ldi r17, 5
out DDRB, r17 out DDRB, r17
out PORTB, r16 ldi r17, 0x81
; set pwm to fast pwm
ldi r17, 0x83
out TCCR0A, r17 out TCCR0A, r17
ldi r17, 0x01 ldi r17, 0x09
out TCCR0B, r17 out TCCR0B, r17
ldi r17, 1
; enable sleep, idle mode and disable pullups out SMCR, r17
ldi r17, 96
out MCUCR, r17
; set interrupts
ldi r17, 2
out TIMSK0, r17 out TIMSK0, r17
; enable interrupts
sei sei
out TIFR0, r17 out TIFR0, r17
; YH and ZH never change ; YH and ZH never change
ldi r31, hi8(notes) ldi r31, hi8(bassline+0x4000)
clr r29 clr r29
; init i ; init i
clr r17 clr r17
clr r18 clr r18
@ -175,11 +157,11 @@ norestart:
; note = notes[bassline[bassptr]] ; note = notes[bassline[bassptr]]
ldi r30, lo8(bassline) ldi r30, lo8(bassline)
add r30, r20 add r30, r20
lpm r20, Z ld r20, Z
ldi r30, lo8(notes) ldi r30, lo8(notes)
add r30, r20 add r30, r20
lpm r21, Z+ ld r21, Z+
lpm r20, Z ld r20, Z
; if (bassbeat[(i >> 10) & 7]): note <<= 1 ; if (bassbeat[(i >> 10) & 7]): note <<= 1
mov r22, r18 mov r22, r18
@ -188,7 +170,7 @@ norestart:
andi r22, 7 andi r22, 7
ldi r30, lo8(bassbeat) ldi r30, lo8(bassbeat)
add r30, r22 add r30, r22
lpm r22, Z ld r22, Z
tst r22 ; assuming this resets C tst r22 ; assuming this resets C
breq nobassbeat breq nobassbeat
rol r21 rol r21
@ -237,7 +219,7 @@ noaddbass:
; arpptr(r30) = arpseq1[arpseq2[i >> 16]][(i >> 14) & 3] ; arpptr(r30) = arpseq1[arpseq2[i >> 16]][(i >> 14) & 3]
mov r30, r17 mov r30, r17
subi r30, lo8(NULL-arpseq2) subi r30, lo8(NULL-arpseq2)
lpm r30, Z ld r30, Z
lsl r30 lsl r30
lsl r30 lsl r30
mov r20, r18 mov r20, r18
@ -247,12 +229,12 @@ noaddbass:
andi r20, 3 andi r20, 3
or r30, r20 or r30, r20
subi r30, lo8(NULL-arpseq1) subi r30, lo8(NULL-arpseq1)
lpm r30, Z ld r30, Z
; if (!(i & (1 << 13))): arpptr >>= 14 ; if (!(i & (1 << 13))): arpptr >>= 14
sbrs r18, 5 sbrs r18, 5
swap r30 swap r30
; arpptr = arpeggio[arpptr & 0xF][(i >> 8) & 1] ; arpptr = arpeggio[arpptr & 0xF][(i >> 8) & 1]
andi r30, 0xF andi r30, 0xF
lsl r30 lsl r30
@ -260,19 +242,19 @@ noaddbass:
andi r20, 1 andi r20, 1
or r30, r20 or r30, r20
subi r30, lo8(NULL-arpeggio) subi r30, lo8(NULL-arpeggio)
lpm r30, Z ld r30, Z
; if (!(i & 0x80)): arpptr >>= 14 ; if (!(i & 0x80)): arpptr >>= 14
sbrs r19, 7 sbrs r19, 7
swap r30 swap r30
; note = arpnotes[arpptr & 0xF] ; note = arpnotes[arpptr & 0xF]
andi r30, 0xF andi r30, 0xF
lsl r30 lsl r30
subi r30, lo8(NULL-arpnotes) subi r30, lo8(NULL-arpnotes)
lpm r21, Z+ ld r21, Z+
lpm r20, Z ld r20, Z
; arp_osc += note ; arp_osc += note
lds r22, arposc lds r22, arposc
lds r23, arposc + 1 lds r23, arposc + 1
@ -280,7 +262,7 @@ noaddbass:
adc r22, r20 adc r22, r20
sts arposc, r22 ; keep r22 for later! sts arposc, r22 ; keep r22 for later!
sts arposc + 1, r23 sts arposc + 1, r23
; if (!(i >> 17)): break arp ; if (!(i >> 17)): break arp
mov r20, r17 mov r20, r17
lsr r20 lsr r20
@ -291,7 +273,7 @@ noaddbass:
swap r30 swap r30
andi r30, 3 andi r30, 3
subi r30, lo8(NULL-arptiming) subi r30, lo8(NULL-arptiming)
lpm r20, Z ld r20, Z
; if (!((r20 << ((i >> 9) & 7)) & 0x80)): break arp ; if (!((r20 << ((i >> 9) & 7)) & 0x80)): break arp
mov r21, r18 mov r21, r18
@ -342,7 +324,7 @@ noarp:
lsr r23 lsr r23
add r16, r23 add r16, r23
out OCR0A, r16 out OCR0AL, r16
cbi PORTB, 2 cbi PORTB, 2
rjmp mainloop rjmp mainloop
@ -410,13 +392,13 @@ getleaddata:
swap r30 swap r30
andi r30, 0xF andi r30, 0xF
subi r30, lo8(NULL-leadseq) subi r30, lo8(NULL-leadseq)
lpm r30, Z ld r30, Z
swap r30 swap r30
or r30, r23 or r30, r23
; data = leaddata[leadptr] ; data = leaddata[leadptr]
subi r30, lo8(NULL-leaddata) subi r30, lo8(NULL-leaddata)
lpm r24, Z ; r24 = data! ld r24, Z ; r24 = data!
; if (0 == leadtimer) { ; if (0 == leadtimer) {
com r25 com r25
@ -429,7 +411,7 @@ getleaddata:
lsr r30 lsr r30
andi r30, 7 andi r30, 7
subi r30, lo8(NULL-leadtimes) subi r30, lo8(NULL-leadtimes)
lpm r27, Z ld r27, Z
st Y, r27 st Y, r27
; boosts |= boostmask ; boosts |= boostmask
@ -444,8 +426,8 @@ noleadupdate:
ldi r30, lo8(notes) ldi r30, lo8(notes)
lsl r24 lsl r24
add r30, r24 add r30, r24
lpm r21, Z+ ld r21, Z+
lpm r20, Z ld r20, Z
; leadosc += note ; leadosc += note
inc r28 inc r28
@ -487,9 +469,9 @@ skiplead:
.org 0x300 .org 0x300
notes: notes:
.word -1, 112, 133, 149, 167 .word -1, 134, 159, 179, 201
arpnotes: arpnotes:
.word 177, 199, 223, 251, 265, 298, 335, 354, 375, 398, 447, 501, 531, 596 .word 213, 239, 268, 301, 319, 358, 401, 425, 451, 477, 536, 601, 637, 715
bassline: bassline:
.byte 14, 14, 18, 12, 14, 14, 20, 12, 14, 14, 18, 8, 10, 10, 4, 8 .byte 14, 14, 18, 12, 14, 14, 20, 12, 14, 14, 18, 8, 10, 10, 4, 8

Binary file not shown.