bootsector:
bootcode:
;to debug with windows9x versions
;org 100h
;you must have a slave hard disk on the ide0 bus
;to boot on d
;org 0
	org 100h
textcolor=70h
	jmp @f
db 'boot sector version 0.1',0
@@:
;        mov ax,0
;        mov ss,ax
;        mov sp,0ffffh
	push cs
	pop ds
	call mode_3
	mov si,labels.read
	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 si,labels.ready
	mov di,64+160*16
	call print_text
	mov ah,key.entrée
	call waitk
	call mode_3
	jmp [disk.segment]
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
@@:
	mov ax,3
	int 10h
	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
disk:
.read:
	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,2
	int 13h
	pop es
	ret
.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 128
.sector db 1
.track dw 0
.head db 0
.drive db 81h
.segment rw 1
.offset dw 0

labels:
.write db 'write',0
.read db 'read',0
.hard_disk db 'hard disk1',0
.ok db 'ok',0
.ready db 'je suis pret',0
waitk:
@@:
	in al,60h
	cmp al,ah
	jne @b
	ret
include 'scancode.inc'
times  512-351 db % mod 255
partitiontable:
part1:
.bootflag db 80h
.firsthead db 0
.firstHtrack db 0
.firstLtrack db 0
.sys db 66h
.lasthead db 10
.lastHtrack db 0
.lastLtrack db 100
.before dd 0
.size dd 8*664*63
part2:
rb 16
part3:
rb 16
part4:
rb 16
endmark db 055h,0aah
