; CS 2011, A Term 1999
; Prof. Sergio A. Alvarez

title BIOS functions for pixel manipulation

.model small
.stack

.data
pixval db 0Ah
pixbyte db ?
maxrows = 200
maxcols = 600
pixrow dw maxrows
pixcol dw 32*maxcols
vidmode db ?
vidpage db 0
count dd ?

.code
.586

.startup
   call drawline
.exit

drawline proc
   mov ah,0Fh
   int 10h
   mov vidmode,al
   mov vidpage,bh

; set video mode to graphics
   mov ah,0
   mov al,12h
   int 10h

   mov bh,vidpage
   mov cx,pixcol
   shl ecx,4
   pixloop:
      push ecx
      call getcoords
      mov cx,pixcol
      mov dx,pixrow
      mov ah,0Ch
      mov al,pixval
      inc pixval
      int 10h
      pop ecx
   loopd pixloop

   ret
drawline endp

getcoords proc
; compute row and column coordinates from loop counter
; more complex versions might use floating point arithmetic
   mov pixcol,cx
   mov pixrow,cx
   ret
getcoords endp

end


