music
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 18 Jun 2022 13:38:56 +0000 (16:38 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 18 Jun 2022 13:38:56 +0000 (16:38 +0300)
bootcard.asm
notes [new file with mode: 0644]

index f22c65c..b5c42f9 100644 (file)
@@ -8,9 +8,11 @@
 
 data_start     equ 7e00h
 nticks         equ data_start
-muscur         equ nticks + 4
+tmoffs         equ nticks + 4
+muscur         equ tmoffs + 4
 spkstat                equ muscur + 4
 vol            equ spkstat + 4
+data_end       equ vol + 4
 
 OSC_FREQ       equ 1193182
 PIT_DATA0      equ 40h
@@ -50,12 +52,14 @@ KB_CTRL             equ 61h
 
        xor eax, eax
        mov ds, ax
+       mov es, ax
        mov ss, ax
        mov sp, 7c00h
 
-       mov [nticks], eax
-       mov [muscur], eax
-       ;mov [spkstat], eax
+       mov di, data_start
+       mov cx, (data_end - data_start) / 2
+       rep stosw
+
        ;mov word [vol], 04h
        mov word [32], timer_intr
        mov word [34], 0
@@ -102,6 +106,7 @@ timer_intr:
        inc ax
        mov [nticks], ax
 
+       sub ax, [tmoffs]
 .pmus: mov bx, [muscur]
        shl bx, 2
        mov cx, [music + bx]    ; event time
@@ -146,35 +151,54 @@ timer_intr:
 
 .loop: neg cx
        mov [muscur], cx
+       mov ax, [nticks]
+       mov [tmoffs], ax
        jmp .pmus
        
 
 str1:  db 'message message blah',0
 str2:  db 'Michael & Athina',0
 
-music:
-       dw 0, 2000
-       dw 10, 1900
-       dw 20, 1800
-       dw 30, 1700
-       dw 40, 1600
-       dw 50, 1500
-       dw 60, 1400
-       dw 70, 1300
-       dw 80, 1200
-       dw 90, 1100
-       dw 100, 1000
-       dw 110, 1100
-       dw 120, 1200
-       dw 130, 1300
-       dw 140, 1400
-       dw 150, 1500
-       dw 160, 1600
-       dw 170, 1700
-       dw 180, 1800
-       dw 190, 1900
-       dw 200, 2000
-       dw 210, 0
+G1     equ 24351
+C2     equ 18243
+D2     equ 16252
+B1     equ 19328
+F2     equ 13666
+E2     equ 14479
+
+%define TM(x)  (40 + (x) * 2)
+
+music: dw 0, 0
+       dw TM(0),       G1
+       dw TM(40),      C2
+       dw TM(70),      C2
+
+       dw TM(80),      C2
+       dw TM(140),     0
+
+       dw TM(160),     G1
+       dw TM(200),     D2
+       dw TM(230),     B1
+
+       dw TM(240),     C2
+       dw TM(300),     0
+
+       dw TM(320),     G1
+       dw TM(360),     C2
+       dw TM(390),     F2
+
+       dw TM(400),     F2
+       dw TM(440),     E2
+       dw TM(470),     D2
+
+       dw TM(480),     C2
+       dw TM(520),     B1
+       dw TM(550),     C2
+
+       dw TM(560),     D2
+       dw TM(640),     0
+
+       dw TM(680),     0
        dw 0ffffh, 0
 
        times 446-($-$$) db 0
diff --git a/notes b/notes
new file mode 100644 (file)
index 0000000..0c9bc35
--- /dev/null
+++ b/notes
@@ -0,0 +1,44 @@
+1/16: 0.1s     10 ticks
+
+G1     1/4             48.999          40, 24351
+C2     3/16            65.406          30, 18243
+C2     1/16            65.406          10, 18243
+
+C2     3/8             65406           60, 18243
+-      1/8                             20
+
+G1     1/4             48.999          40, 24351
+D2     3/16            73.416          30, 16252
+B1     1/16            61.735          10, 19328
+
+C2     3/8             65.406          60, 18243
+-      1/8                             20
+
+G1     1/4             48.999          40, 24351
+C2     3/16            65.406          30, 18243
+F2     1/16            87.307          10, 13666
+
+F2     1/4             87.307          40, 13666
+E2     3/16            82.407          30, 14479
+D2     1/16            73.416          10, 16252
+
+C2     1/4             65.406          40, 18243
+B1     3/16            61.735          30, 19328
+C2     1/16            65.406          10, 18243
+
+D2     2/4             73.416          80, 16252
+
+-----------------
+G1     1/4
+C2     3/16
+C2     1/6
+
+C2     3/8
+-      2/4 - 3/8
+
+G1     1/4
+D2     3/16
+B1     1/16
+
+C2     3/8
+-      2/4 - 3/8