readme
[bootcard] / bootcard.asm
index 1288c4a..dddf846 100644 (file)
@@ -1,14 +1,20 @@
 ; ---- boot me! ----
 ; nasm -f bin -o bootcard.img bootcard.asm
 ; cat bootcard.img >/dev/<usbstick>
-; reboot
 
        org 7c00h
        bits 16
 
+barh   equ 4
+nbars  equ 11
+barstart equ 200 - (nbars+1) * barh
+
 nticks equ 7e00h
 tmoffs equ 7e04h
 musptr equ 7e08h
+frame  equ 7e0ch
+fval   equ 7e10h
+cmap   equ 7e14h
 
 %macro setcur 2
        mov dx, %1 | (%2 << 8)
@@ -42,9 +48,10 @@ start:       xor ax, ax
        mov sp, 7c00h
 
        mov di, nticks
-       mov cx, 6
+       mov cx, 16
        rep stosw
 
+       cli
        mov word [32], tintr
        mov [34], ax
 
@@ -55,12 +62,20 @@ start:      xor ax, ax
        push 0a000h
        pop es
 
-       setcur 10, 0
+       
+       mov al, 16
+       mov di, barstart * 320
+       mov bx, nbars
+.drawbars:
+       mov cx, barh * 320
+       rep stosb
+       inc al
+       dec bx
+       jnz .drawbars
+
+       setcur 12, 16
        mov si, str1
        call textout
-       setcur 12, 1
-       mov si, str2
-       call textout
 
        sti
 
@@ -73,17 +88,13 @@ mainloop:
        and al, 8
        jz .novb
 
-       call drawbg
-
-       jmp mainloop
-
 drawbg:
        mov bx, 200
-       mov di, 5120
+       xor di, di
 .fillgrad:
        mov ax, bx
        mov ah, al
-       mov cx, 2400    ; 15 lines
+       mov cx, 2400 ; 15 lines
        rep stosw
        inc bx
        cmp bx, 208
@@ -101,20 +112,28 @@ drawbg:
        fistp word [bp - 2]
        fstp st0
        mov bx, [bp - 2]
-       add bx, 100
+       add bx, 84
        imul bx, bx, 320
        add bx, cx
 .mntcol:
        mov byte [es:bx], 0
        add bx, 320
-       cmp bx, 64000
+       cmp bx, 128 * 320
        jb .mntcol
 
        dec cx
        jnz .mnt
-       
-       ret
 
+       ; upd colormap
+       mov dx, 3c8h
+       mov al, 16
+       out dx, al
+       inc dx
+       mov si, cmap
+       mov cx, 16 * 3
+       rep outsb
+
+       jmp mainloop
 
 textout:
        mov al, [si]
@@ -127,6 +146,7 @@ textout:
        jmp textout
 .done: ret
 
+
 tintr:
        pusha
        mov ax, [nticks]
@@ -134,7 +154,7 @@ tintr:
        mov [nticks], ax
 
        mov bx, [musptr]
-       cmp bx, 23*3
+       cmp bx, 22*3
        jnz .skiploop
        xor bx, bx
        mov [tmoffs], ax
@@ -144,27 +164,48 @@ tintr:
        shl cx, 4
        sub ax, [tmoffs]
        cmp ax, cx
-       jb .eoi
+       jb .end
 
        mov ax, [music + 1 + bx]
        add bx, 3
        mov [musptr], bx
        test ax, ax
        jz .off
+
+       mov bx, ax
+       shr bx, 9
+       sub bx, 13
+       imul bx, bx, 3
+       mov byte [cmap + bx], 3fh
+       mov word [cmap + bx + 1], 2f2fh
+
        mov bx, ax
        stimer 2, bx
        spkon
-       jmp .eoi
+       jmp .end
 
 .off:  spkoff
 
+.end:  test word [nticks], 1
+       jnz .eoi
+       mov cx, 16 * 3
+       mov si, cmap
+.fadecol:
+       lodsb
+       test al, al
+       jz .skipdec
+       dec al
+       mov [si-1], al
+.skipdec:
+       dec cx
+       jnz .fadecol
+       
 .eoi:  mov al, 20h
        out 20h, al
        popa
        iret
 
-str1:  db 'message blah',0
-str2:  db 'Michael & Athena',0
+str1:  db 'Michael ',3,' Athena',0
 
 music: dd 0a2f8f00h, 0a11123a1h, 23a11423h, 28000023h, 0be322f8fh, 25c0391fh
        dd 4b23a13ch, 8f500000h, 23a15a2fh, 641ab161h, 476e1ab1h, 1fbe751ch
@@ -182,5 +223,4 @@ w30:        dw 30
 
        times 510-($-$$) db 0
        dw 0aa55h
-
 ; vi:ft=nasm ts=8 sts=8 sw=8: