]> git.gir.st - Chiptunes.git/commitdiff
fix melody for voices 3 and 4
authorTobias Girstmair <t@thi3nkpad.lan>
Sun, 1 Mar 2020 20:31:13 +0000 (21:31 +0100)
committerTobias Girstmair <t@thi3nkpad.lan>
Sun, 1 Mar 2020 20:31:13 +0000 (21:31 +0100)
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

foo.S

diff --git a/foo.S b/foo.S
index 1f7a5c30e65af7b9df8ac97e394532af535ba49c..bde793cb03c0f8ed7c3c9009e21255e51bcb4fbb 100644 (file)
--- a/foo.S
+++ b/foo.S
@@ -1,4 +1,3 @@
-; TODO: melody is still not 100% correct!
 /* REGISTER NAMES */
 #define acc  r16
 #define i0   r17
@@ -77,7 +76,7 @@ mod3: ; mod3(Mh.Ml) -> t
        ANDI    Ml, 0x03
        ADD     Ml, tmp
        CPI     Ml, 3
-       BRPL    skip
+       BRCS    skip
        SUBI    Ml, 3
        skip:
        RET
Imprint / Impressum