fixed
[bootcard] / bootcard.asm
index 1f29b88..384dd2d 100644 (file)
@@ -21,7 +21,6 @@ nticks        dd 0
 tmoffs         dd 0
 musptr         dd 0
 frame  dd 0
-pnote  dd 0
 fval   dd 0
 cmap   dd 0
 
@@ -32,7 +31,6 @@ nticks        equ 7e00h
 tmoffs equ 7e04h
 musptr equ 7e08h
 frame  equ 7e0ch
-pnote  equ 7e18h
 fval   equ 7e10h
 cmap   equ 7e14h
 %endif
@@ -70,10 +68,6 @@ start:
        mov ss, ax
        mov sp, 7c00h
 
-       mov di, nticks
-       mov cx, 16
-       rep stosw
-
        cli
        mov word [32], tintr
        mov [34], ax
@@ -92,6 +86,10 @@ start:
        mov [es:34], ax
 %endif
 
+       mov di, nticks
+       mov cx, 16
+       rep stosw
+
        stimer 0, 5966
 %ifdef MIDI
        call resetmidi
@@ -201,33 +199,24 @@ drawbg:
 textout:
        mov al, [si]
        and al, al
-       jz .done
+       jz textout_done
        mov ah, 0eh
        mov bx, 82
        int 10h
        inc si
        jmp textout
-.done: ret
+textout_done:
+       ret
 
 %ifdef MIDI
 note_on:
-       mov [pnote], ax
+       push ax
        mov ax, 90h     ; note-on command for channel 0
        call sendmidi
-       mov ax, [pnote]
+       pop ax
        call sendmidi
        mov ax, 127
-       call sendmidi
-       ret
-
-note_off:
-       mov ax, 80h     ; note-off command for channel 0
-       call sendmidi
-       mov ax, [pnote]
-       call sendmidi
-       mov ax, 64
-       call sendmidi
-       ret
+       jmp sendmidi
 
 all_notes_off:
        mov ax, 0b0h    ; channel mode message for channel 0...
@@ -235,11 +224,10 @@ all_notes_off:
        mov ax, 7bh     ; all notes off
        call sendmidi
        xor ax, ax
-       call sendmidi
-       ret
+       jmp sendmidi
 
 waitmidi:
-       mov ax, 331h
+       mov dx, 331h
 .wait: in al, dx       ; read status port
        test al, 40h    ; test output-ready bit (0: ready)
        jnz .wait
@@ -289,7 +277,6 @@ tintr:
        jb .end
 
 %ifdef MIDI
-       call note_off
        mov al, [music + 1 + bx]
        xor ah, ah
        add bx, 2
@@ -313,6 +300,9 @@ tintr:
        mov word [cmap + bx + 1], 2f2fh
 
 %ifdef MIDI
+       push ax
+       call all_notes_off
+       pop ax
        call note_on
 %else
        mov bx, ax