bootwriter:
	org 100h
textcolor=70h
	mov ax,cs
	mov [disk.segment],ax
	mov [disk.offset],bootsector
	call disk.write
	call mode_3
	mov si,labels.write
	mov di,74+160*12
	call print_text
	mov si,labels.hard_disk
	mov di,68+160*13
	call print_text
	mov si,labels.ok
	mov di,76+160*14
	call print_text
	mov ah,key.echap
	call waitk
	mov ax,3
	int 10h
	ret
db 'boot-writer version 0.1',0
labels:
.write db 'write',0
.read db 'read',0
.hard_disk db 'hard  disk',0
.ok db 'ok',0
print_text:
	mov ah,textcolor
@@:
	mov al,[ds:si]
	cmp al,0
	je @f
	mov [es:di],ax
	inc si
	add di,2
	jmp @b
@@:
	ret

mode_3:
	mov ax,3
	int 10h
	mov ax,0b800h
	mov es,ax
	mov di,80*50
	mov ah,textcolor
	mov al,0
@@:
	mov [es:di],ax
	sub di,2
	jnl @b
	ret

waitk:
@@:
	in al,60h
	cmp al,ah
	jne @b
	ret
include 'scancode.inc'
disk:
.write:
	mov al,[.sectors]
	mov cx,[.track]
	mov bl,cl
	mov cl,ch
	mov ch,cl
	shl cl,6
	and cl,11000000b
	or cl,[.sector]
	mov dh,[.head]
	mov dl,[.drive]
	mov bx,[.segment]
	push es
	mov es,bx
	mov bx,[.offset]
	mov ah,3
	int 13h
	pop es
	ret
.sectors db 1
.sector db 1
.track dw 0
.head db 0
.drive db 81h
.segment rw 1
.offset rw 1
bootsector:
file 'boot.bin'
