Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

line program

i'm trying to make an assembly program that prints out ten vertical lines, each in a different color. heres my program:

INCLUDE Irvine16.inc

DrawVerticalLine PROTO,
Xcoord:WORD,
Ycoord:WORD,
lineLength:WORD,
color:BYTE

.data
saveMode BYTE ? ; saved video mode

.code
main PROC
mov ax,@data
mov ds,ax

call SetVideoMode
call SetScreenBackground

mov eax, red + (blue * 16)
;call settextcolor
INVOKE DrawVerticalLine, 20, 30, 80, 1
INVOKE DrawVerticalLine, 40, 30, 80,2
INVOKE DrawVerticalLine, 60, 30, 80,3
INVOKE DrawVerticalLine, 80, 30, 80,4
INVOKE DrawVerticalLine, 100, 30, 80,5
INVOKE DrawVerticalLine, 120, 30, 80,6
INVOKE DrawVerticalLine, 140, 30, 80,7
INVOKE DrawVerticalLine, 160, 30, 80,8
INVOKE DrawVerticalLine, 180, 30, 80,9
INVOKE DrawVerticalLine, 200, 30, 80,1

call RestoreVideoMode
exit
main ENDP

SetScreenBackground PROC
mov dx,3c8h
mov al,0
out dx,al


mov dx,3c9h
mov al,0
out dx,al
mov al,0
out dx,al
mov al,35
out dx,al

ret
SetScreenBackground ENDP

SetVideoMode PROC

mov ah,0Fh ; get current video mode
int 10h
mov saveMode,al ; save it

mov ah,0 ; set new video mode
mov al,13h ; to mode 13h
int 10h

push 0A000h ; video segment address
pop es ; ES = A000h (video segment).

ret
SetVideoMode ENDP


RestoreVideoMode PROC

mov ah,10h ; wait for keystroke
int 16h
mov ah,0 ; reset video mode
mov al,saveMode ; to saved mode
int 10h
ret
RestoreVideoMode ENDP


DrawVerticalLine PROC,
Xcoord:WORD,
Ycoord:WORD,
lineLength:WORD,
color:BYTE

pusha


; Change color at index 1 to white (63,63,63)
mov dx,3c8h ; video palette port (3C8h)
mov al,color ; set palette index 1
out dx,al

mov dx,3c9h ; colors go to port 3C9h
mov al,30 ; red
out dx,al
mov al,30 ; green
out dx,al
mov al,0 ; blue
out dx,al


mov ax, 320 ; 320 for video mode 13h
mov esi, ecx

inc ax

mul yCoord ; y-coordinate
add ax, xCoord ; x-coordinate
dec ecx
.if(ecx==0)
exit
.endif

; Place the color index into the video buffer.
mov cx, lineLength ; pixel counter
mov di,ax ; AX contains buffer offset

; Draw the vertical line

DP1:
mov BYTE PTR es:[di], 1 ; store color index
add di,320 ; move one pixel down
Loop DP1

popa
ret

DrawVerticalLine ENDP
END main

IF SOMEONE CAN FIGURE OUT WHAT TO ADD TO THIS PROGRAM TO MAKE IT WORK, OR GIVE ME ANOTHER PROGRAM, AND SEND IT TO ntolles1@rochester.rr.com
IT WOULD BE GREATLY APPRECIATED!!!
Sign In or Register to comment.