Chiptunes.git
8 months agofix melody for voices 3 and 4
Tobias Girstmair [Sun, 1 Mar 2020 20:31:13 +0000 (21:31 +0100)]
fix melody for voices 3 and 4

15 months later, I took another look at why the music was off for
channels 3 and 4 and pretty fast noticed that it affects only the voices
using the mod3 subroutine. Executing mod3 with simavr[1] showed that the
compare-branch step is broken. Switching BRPL for the correct BRCS fixed
the problem.

[1]: in the hackiest way imaginable:
  gdb> layout regs
  gdb> set $r24 = 0x15  # test value for Mh
  gdb> set $r23 = 0x16  # test value for Ml
  gdb> set $pc = 0x1a   # start of mod3 routine
  gdb> ni  # repeatedly

23 months agocleanup some TODOs, #defines
Tobias Girstmair [Fri, 21 Dec 2018 20:10:59 +0000 (21:10 +0100)]
cleanup some TODOs, #defines

also: hide PORTB2 behind -DDEBUG to save 4 bytes :D

23 months agoconserve 6 bytes of progmem
Tobias Girstmair [Fri, 21 Dec 2018 19:33:10 +0000 (20:33 +0100)]
conserve 6 bytes of progmem

replace NOPs in intr.vector with useful instructions

23 months agoit werks!
Tobias Girstmair [Fri, 21 Dec 2018 19:10:37 +0000 (20:10 +0100)]
it werks!

putting the notes into .text instead of .data was orignially inteded to
"look better" in avr-size, but actually fixed the
wrong-notes-played-problem!?

23 months agocalibrate oscillator
Tobias Girstmair [Fri, 21 Dec 2018 18:58:08 +0000 (19:58 +0100)]
calibrate oscillator

just measure frequency of PORTB2 and fiddle with the number until it's
close enough. don't forget to hold your tongue at the right angle!

23 months agofix jitter
Tobias Girstmair [Tue, 18 Dec 2018 14:11:30 +0000 (15:11 +0100)]
fix jitter

yeah...don't rjmp into interrupt instead of main loop m(

23 months agofix Ml register, clear interrupt before RETI
Tobias Girstmair [Fri, 14 Dec 2018 11:09:47 +0000 (12:09 +0100)]
fix Ml register, clear interrupt before RETI

23 months agofix bug: a2 (as tmp) was not cleared after use
Tobias Girstmair [Thu, 13 Dec 2018 15:31:19 +0000 (16:31 +0100)]
fix bug: a2 (as tmp) was not cleared after use

23 months agoremove dedicated zero register (saves 4 bytes of progmem)
Tobias Girstmair [Tue, 11 Dec 2018 22:34:35 +0000 (23:34 +0100)]
remove dedicated zero register (saves 4 bytes of progmem)

23 months agoswap registers for `t` and `_`
Tobias Girstmair [Tue, 11 Dec 2018 22:13:46 +0000 (23:13 +0100)]
swap registers for `t` and `_`

LDing to Xhi or Xlo is undefined, so we had to move `t` somewhere else
and then back. swapping these registers globally solves this.
also rename 'data' to 'notes' to be more expressive

23 months agooptimize mul_8c / mul_84
Tobias Girstmair [Tue, 11 Dec 2018 21:47:07 +0000 (22:47 +0100)]
optimize mul_8c / mul_84

23 months agorefactor mul .macros
Tobias Girstmair [Tue, 11 Dec 2018 21:22:52 +0000 (22:22 +0100)]
refactor mul .macros

23 months agoadd debug pin, remove 2 unnecessary instructions
Tobias Girstmair [Tue, 11 Dec 2018 20:58:15 +0000 (21:58 +0100)]
add debug pin, remove 2 unnecessary instructions

23 months agoinitialisation code, interrupt vector table
Tobias Girstmair [Tue, 11 Dec 2018 02:25:03 +0000 (03:25 +0100)]
initialisation code, interrupt vector table

it werks! (it's completely out of tune and too fast, but audio is coming
out of the chip. program at 5v, then play at 3v3. chip can't handle the
stereo amp, but headphones work)

23 months agotranscribe fakeasm into realasm (IV)
Tobias Girstmair [Tue, 11 Dec 2018 01:30:35 +0000 (02:30 +0100)]
transcribe fakeasm into realasm (IV)

23 months agotranscribe fakeasm into realasm (III)
Tobias Girstmair [Tue, 11 Dec 2018 01:15:07 +0000 (02:15 +0100)]
transcribe fakeasm into realasm (III)

23 months agotranscribe fakeasm into realasm (II)
Tobias Girstmair [Tue, 11 Dec 2018 01:06:41 +0000 (02:06 +0100)]
transcribe fakeasm into realasm (II)

23 months agotranscribe fakeasm into realasm (I)
Tobias Girstmair [Tue, 11 Dec 2018 01:03:47 +0000 (02:03 +0100)]
transcribe fakeasm into realasm (I)

23 months agopreparing for C -> ASM
Tobias Girstmair [Tue, 11 Dec 2018 00:48:46 +0000 (01:48 +0100)]
preparing for C -> ASM

23 months agoimport Makefile
Tobias Girstmair [Tue, 11 Dec 2018 00:47:47 +0000 (01:47 +0100)]
import Makefile

23 months agonew version
Tobias Girstmair [Tue, 11 Dec 2018 00:38:43 +0000 (01:38 +0100)]
new version

using this we can save a few more cycles (code size not yet compared).
working principle:
 we can distinguish which number to multiply by with the lower nibble
 only. to have maximum overlap, use a decision tree to select where to
 go. the upper nibble is then just a straight path (there is not much
 to deduplicate).

worst case (roughly):
- mul-tree: 30cy tree + 5cy to load data[t]
- cpi-breq-rjmp: 37cy mul_xx + 5cy to load data[t]
- ldZ-ijmp: 28cy mul_xx + 10cy to load mul_jmptable[t]

23 months agonew version
Tobias Girstmair [Mon, 10 Dec 2018 23:44:03 +0000 (00:44 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sun, 18 Nov 2018 21:50:43 +0000 (22:50 +0100)]
new version

bring cycle count down from 425 to 409

2 years agonew version
Tobias Girstmair [Sun, 18 Nov 2018 20:45:30 +0000 (21:45 +0100)]
new version

NOTE: `t` and `x` registers swapped, otherwise we would overwrite Xlo

2 years agonew version
Tobias Girstmair [Sun, 18 Nov 2018 20:29:07 +0000 (21:29 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sun, 18 Nov 2018 19:37:26 +0000 (20:37 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sun, 18 Nov 2018 19:36:11 +0000 (20:36 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sun, 18 Nov 2018 19:34:48 +0000 (20:34 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sun, 18 Nov 2018 19:15:41 +0000 (20:15 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sun, 18 Nov 2018 19:09:06 +0000 (20:09 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sun, 18 Nov 2018 19:02:55 +0000 (20:02 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sun, 18 Nov 2018 19:01:01 +0000 (20:01 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 20:21:50 +0000 (21:21 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 20:12:26 +0000 (21:12 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 20:07:57 +0000 (21:07 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 20:01:03 +0000 (21:01 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 19:59:16 +0000 (20:59 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 19:53:38 +0000 (20:53 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 19:44:48 +0000 (20:44 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 19:42:45 +0000 (20:42 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 19:42:04 +0000 (20:42 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 19:40:37 +0000 (20:40 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 19:31:00 +0000 (20:31 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 17:51:19 +0000 (18:51 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 17:44:31 +0000 (18:44 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 17:42:30 +0000 (18:42 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 17:33:40 +0000 (18:33 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 17:29:35 +0000 (18:29 +0100)]
new version

2 years agonew version
Tobias Girstmair [Sat, 17 Nov 2018 12:16:56 +0000 (13:16 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 19:00:33 +0000 (20:00 +0100)]
new version

var to register association (not final, but close)

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:54:29 +0000 (19:54 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:52:16 +0000 (19:52 +0100)]
new version

check which registers are first used by MOV, which rely on being cleared

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:42:30 +0000 (19:42 +0100)]
new version

use `_` as tmpregister consistently; use x as Xhi

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:29:22 +0000 (19:29 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:20:23 +0000 (19:20 +0100)]
new version

can now get rid of `o` completely, saving 1 register

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:20:11 +0000 (19:20 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:18:33 +0000 (19:18 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:17:47 +0000 (19:17 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:16:31 +0000 (19:16 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:14:59 +0000 (19:14 +0100)]
new version

move `o` out of g() to get rid of variable shift

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:10:39 +0000 (19:10 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:10:14 +0000 (19:10 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:09:22 +0000 (19:09 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 18:07:54 +0000 (19:07 +0100)]
new version

move `x` out of g(), so we can use it as tempvar in g()

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 17:54:46 +0000 (18:54 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 17:50:14 +0000 (18:50 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 17:47:54 +0000 (18:47 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 17:45:42 +0000 (18:45 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 17:38:27 +0000 (18:38 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 17:16:17 +0000 (18:16 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 16:51:54 +0000 (17:51 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 16:18:51 +0000 (17:18 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 16:13:26 +0000 (17:13 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 16:12:49 +0000 (17:12 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 16:12:28 +0000 (17:12 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 16:08:34 +0000 (17:08 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 16:07:52 +0000 (17:07 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 16:05:36 +0000 (17:05 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 15:54:17 +0000 (16:54 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 15:51:28 +0000 (16:51 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 02:54:11 +0000 (03:54 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 02:43:30 +0000 (03:43 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 02:37:17 +0000 (03:37 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 02:31:26 +0000 (03:31 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 02:27:42 +0000 (03:27 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 02:23:06 +0000 (03:23 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 02:22:39 +0000 (03:22 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 02:13:10 +0000 (03:13 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 02:12:09 +0000 (03:12 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 02:11:02 +0000 (03:11 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 01:59:37 +0000 (02:59 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 01:56:21 +0000 (02:56 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 01:54:43 +0000 (02:54 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 01:53:22 +0000 (02:53 +0100)]
new version

WARN: breaks at ~ 70min, but who cares

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 00:33:18 +0000 (01:33 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 00:31:03 +0000 (01:31 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 00:28:05 +0000 (01:28 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 00:27:28 +0000 (01:27 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 00:26:51 +0000 (01:26 +0100)]
new version

2 years agonew version
Tobias Girstmair [Tue, 13 Nov 2018 00:25:40 +0000 (01:25 +0100)]
new version

Imprint / Impressum