		org	100h
		segment	.text

                mov     AX, 0A000h              ; nastaveni adresy rezimu
                mov     ES, AX
                mov     AH, 0Fh
                int     10h			; zjistim mod
	        mov	[rezim], AL	        ; ulozim mod
                mov     AX, 13h                 ; inicializuju graficky rezim 320x200x256
                int     10h

		mov DX, 0
		mov AX, 63880
		mov BL, 15
		call bressenham
		mov	AH, 8
		int	21h
		ret		

bressenham:	push DX
		sub AX, DX
		mov CX, 320
		div CX			; AX = deltaY, DX = deltaX
		mov CX, AX		; CX = deltaY
		mov [d], CX		; [d] = deltaY
		shl DX, 1
		mov [k], DX		; [k] = 2*deltaX
		not AX
		mov [dc], AX		; dc = -deltaY
		pop AX

br_loop:	mov DI, AX
		mov [ES:DI], BL
		add AX, 320
		push AX

		mov AX, [k]
		add [dc], AX		; [dc] += [k]
		jnc br_next		; nezvysovat o 1

		pop AX
		inc AX
		push AX
		mov AX, [d]
		sub [dc], AX

br_next:	pop AX
		loop br_loop
		ret
		

d	db	0h, 0h
k	db	0h, 0h
dc	db	0h, 0h

rezim	db	0h