let's start on the splash effect
[bootsplash] / bootsplash.asm
1         org 7c00h
2         bits 16
3
4 stacktop equ 7b00h
5 boot_driveno equ 7b00h  ; 1 byte
6 stage2_size equ stage2_end - stage2_start
7
8 start:
9         xor ax, ax
10         mov ds, ax
11         mov es, ax
12         mov ss, ax
13         mov gs, ax
14         mov fs, ax
15
16         mov sp, stacktop
17         mov [boot_driveno], dl
18
19         ; load the rest of the code at 7e00
20         xor ax, ax
21         mov es, ax
22         mov bx, stage2_start
23         mov ah, 2               ; read sectors LBA call
24         mov al, (stage2_size + 511) / 512  ; num sectors
25         mov cx, 2               ; ch: cylinder, cl: sector
26         xor dx, dx              ; dh: head
27         mov dl, [boot_driveno]
28         int 13h
29         jnc stage2_start        ; loaded successfully, jump to it
30
31         ; failed to load second sector
32         mov ax, str_load_fail
33         call printstr
34 .hang:  cli
35         hlt
36         jmp .hang
37
38         ; expects string ptr in ax
39 printstr:
40         mov si, ax
41 .loop:  mov al, [si]
42         inc si
43         test al, al
44         jz .done
45         mov ah, 0eh
46         mov bx, 7
47         int 10h
48         jmp .loop
49 .done:  ret
50
51 str_load_fail db "Failed to load second stage!",0
52 str_booting db "Booting ...",0
53
54
55         times 510-($-$$) db 0
56         dw 0xaa55
57
58         ; start of the second stage
59 stage2_start:
60         call splash
61
62         xor ax, ax
63         mov es, ax
64
65         mov ax, str_booting
66         call printstr
67
68         cli
69 .hang:  hlt
70         jmp .hang
71
72 splash:
73         mov ax, 13h
74         int 10h
75
76         mov ax, 0a000h
77         mov es, ax
78         xor di, di
79         mov cx, 32000
80         mov ax, 0505h
81         rep stosw
82
83         call waitkey
84
85         mov ax, 3
86         int 10h
87
88 waitkey:
89         in al, 64h
90         test al, 1
91         jz waitkey
92         in al, 60h
93         ret
94
95 stage2_end:
96
97 ; vi:set ft=nasm: