readme
[bootcard] / bootcard.asm
index 29f0e5c..dddf846 100644 (file)
@@ -1,15 +1,37 @@
-; boot me!
-; nasm -f bin -o foo.img foo.asm
-; cat foo.img >/dev/<usbstick>
+; ---- boot me! ----
+; nasm -f bin -o bootcard.img bootcard.asm
+; cat bootcard.img >/dev/<usbstick>
 
        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)
+       xor bx, bx
+       mov ah, 2
+       int 10h
+%endmacro
+%macro spkon 0
+       in al, 61h
+       or al, 3
+       out 61h, al
+%endmacro
+%macro spkoff 0
+       in al, 61h
+       and al, 0fch
+       out 61h, al
+%endmacro
 %macro stimer 2
        mov al, (%1 << 6) | 36h
        out 43h, al
@@ -32,6 +54,7 @@ start:        xor ax, ax
        cli
        mov word [32], tintr
        mov [34], ax
+
        stimer 0, 5966
 
        mov ax, 13h
@@ -39,30 +62,21 @@ start:      xor ax, ax
        push 0a000h
        pop es
 
+       
        mov al, 16
-       mov di, 48640
-       mov bx, 11
-.bars:
-       mov cx, 1280
+       mov di, barstart * 320
+       mov bx, nbars
+.drawbars:
+       mov cx, barh * 320
        rep stosb
        inc al
        dec bx
-       jnz .bars
+       jnz .drawbars
 
-       mov dx, 100ch
-       xor bx, bx
-       mov ah, 2
-       int 10h
+       setcur 12, 16
        mov si, str1
-.txout:        mov al, [si]
-       and al, al
-       jz .done
-       mov ah, 0eh
-       mov bx, 82
-       int 10h
-       inc si
-       jmp .txout
-.done:
+       call textout
+
        sti
 
 mainloop:
@@ -80,12 +94,13 @@ drawbg:
 .fillgrad:
        mov ax, bx
        mov ah, al
-       mov cx, 2400
+       mov cx, 2400 ; 15 lines
        rep stosw
        inc bx
        cmp bx, 208
        jnz .fillgrad
 
+       ; mountains
        mov cx, 320
        mov bp, sp
 .mnt:  mov [bp - 2], cx
@@ -109,6 +124,7 @@ drawbg:
        dec cx
        jnz .mnt
 
+       ; upd colormap
        mov dx, 3c8h
        mov al, 16
        out dx, al
@@ -119,6 +135,18 @@ drawbg:
 
        jmp mainloop
 
+textout:
+       mov al, [si]
+       and al, al
+       jz .done
+       mov ah, 0eh
+       mov bx, 82
+       int 10h
+       inc si
+       jmp textout
+.done: ret
+
+
 tintr:
        pusha
        mov ax, [nticks]
@@ -153,14 +181,10 @@ tintr:
 
        mov bx, ax
        stimer 2, bx
-       in al, 61h
-       or al, 3
-       out 61h, al
+       spkon
        jmp .end
 
-.off:  in al, 61h
-       and al, 0fch
-       out 61h, al
+.off:  spkoff
 
 .end:  test word [nticks], 1
        jnz .eoi
@@ -199,3 +223,4 @@ w30:        dw 30
 
        times 510-($-$$) db 0
        dw 0aa55h
+; vi:ft=nasm ts=8 sts=8 sw=8: