any asm code for line primitives? 
Author Message
 any asm code for line primitives?

Can anyone send me any asm sourcecode for drawing lines.I am looking
for inline asm for powerbasic but i welcome any asm code at all.I dont
care what screen mode but i am mainly looking for mode 13h.If you have
any at all that you are willing to share please send it to me or post it
here.
                  Thanks,

--
      ___________       THE       ___________
     / _________ \  <\PRINCE />  / _________ \
    / /   __    \/   \\     //   \/    __   \ \
   / /   /  \         \\   //         /  \   \ \
  / /   / /\/        /""""""\         \/\ \   \ \
  \ \  / /  SEE HIS (  /   \ \  SEE HIS  \ \  / /
   \ \ \ \   FACE    \/<> <>\/   SMILE   / / / /
    \ \ \ \          /   W   \          / / / /
    / /  \ \        /\_|||||_/\        / /  \ \
   / /   /  \      //   |||   \\      /  \   \ \
  / /   / /\ \    //     '     \\    / /\ \   \ \
 / /   / / / /   </ TIME TO DIE \>   \ \ \ \   \ \
/ /   /  \/  \_______________________/  \/  \   \ \
\ \  / /\_________________________________/\ \  / /

  \__/      Remove no.to.spam to reply       \__/
    http://www.*-*-*.com/ ~carcher/krogg/aani.htm
   {*filter*}javascript animations for your enjoyment



Sat, 21 Oct 2000 03:00:00 GMT  
 any asm code for line primitives?

Quote:

>Can anyone send me any asm sourcecode for drawing lines.I am looking
>for inline asm for powerbasic but i welcome any asm code at all.I dont
>care what screen mode but i am mainly looking for mode 13h.If you have
>any at all that you are willing to share please send it to me or post it
>here.

Note: portions of this routine are from "Bluebook of Assembly Language
Routines for the IBM PC & XT" by The Waite Group.

Usage from QuickBasic:

    CALL PLOTLINE(X1%,Y1%,X2%,Y2%,COLOR%)

For PowerBasic, you will need to change the stack frame at least.

---------------------------------------------------
 Page 60,132
Title Plotline -- Plot Line at (X1,Y1,X2,Y2,Color)

; --- Data Segment ---

data segment para public 'data'

delta_x dw ?  ; |x2-x1|
delta_y dw ?  ; |y2-y1|
halfy label word  ; |y2-y1| / 2
halfx dw ?  ; |x2-x1| / 2
count dw ?  ; set to long axis

x1 dw ?  ; first X coordinate
y1 dw ?  ; first Y coordinate
x2 dw ?  ; second X coordinate
y2 dw ?  ; second Y coordinate
color dw ?  ; color, 0-1 or 0-3 or 0-16

data ends

; --- Code Segment ---

code segment para public 'code'
 public Plotline

; PLOTLINE -- Subroutine to plot a line callable from Compiled BASIC only

;    CALL PLOTLINE(X1%,Y1%,X2%,Y2%,COLOR%)

plotline proc far

 assume cs:code,ds:data

begin: push bp  ;initialize
 mov bp,sp

 mov si,[bp+6] ; color
 mov ax,[si]
 mov color,ax

 mov si,[bp+8] ; Y2
 mov ax,[si]
 mov y2,ax

 mov si,[bp+10] ; X2
 mov ax,[si]
 mov x2,ax

 mov si,[bp+12] ; Y1
 mov ax,[si]
 mov y1,ax

 mov si,[bp+14] ; X1
 mov ax,[si]
 mov x1,ax

 call linesub  ; plot line

 pop bp
 ret 10  ; return to BASIC

plotline endp

; LINESUB -- Subroutine to Draw Line

; Input is: x1,y1 (start of line)
;           x2,y2 (end of line)
;           color (0-1 or 0-3 or 0-15)

linesub proc near

;find |y2-y1| -- result is delta_y
 mov ax,y2  ;get y2
 sub ax,y1  ;subtract y1 result in AX

;figure out if delta_y is positive or negative
;  SI=1 if positive, SI=-1 if negative
 mov si,1  ;set flag to positive
 jge store_y  ;  keep it that way
 mov si,-1  ;set flag to negative
 neg ax  ;set to absolute value
store_y:
 mov delta_y,ax ;store delta_y

;find |x2-x1| -- result is delta_x
 mov ax,x2  ;get x2
 sub ax,x1  ;subtract x1 result in ax

;figure out if delta_x is positive or negative
;  DI=1 if positive, DI=-1 if negative
 mov di,1  ;set flag to positive
 jge store_x  ;  keep it that way
 mov di,-1  ;set flag to negative
 neg ax  ;set to absolute value
store_x:
 mov delta_x,ax ;store delta_x

;figure out if slope is greater or less then 1
 mov ax,delta_x ;get delta_x
 cmp ax,delta_y ;compare deltas
 jl csteep  ;slope > 1
 call easy  ;slope < 1 or = 1
 jmp finish

csteep:
 call steep  ;slope > 1

finish: ret   ;line done

linesub endp

;--------

easy proc near

; SLOPE < 1

;calculate half of delta_x, call it halfx
 mov ax,delta_x ;get |x2-x1|
 shr ax,1  ;shift right to divide
 mov halfx,ax ;  by 2

;initialize values

 mov cx,x1  ;set x1
 mov dx,y1  ;set y1
 mov bx,0  ;clear BX
 mov ax,delta_x ;set count
 mov count,ax ;  to |x2-x1|
newdot1:
 call dotplot  ;plot the dot
 add cx,di  ;inc/dec X
 add bx,delta_y ;add |y2-y1| to BX
 cmp bx,halfx ;compare to |x2-x1|/2
 jle dcount1  ;  (don't inc/dec Y)
 sub bx,delta_x ;subtract |x2-x1| from BX
 add dx,si  ;inc/dec Y
dcount1:
 dec count  ;done line yet?
 jge newdot1  ;not yet

 ret   ;done line

easy endp

;--------

steep proc near

; SLOPE > 1

;calculate half of delta_y, call it halfy
 mov ax,delta_y ;get |y2-y1|
 shr ax,1  ;shift right to divide
 mov halfy,ax ;  by 2

;initialize values

 mov cx,x1  ;set x1
 mov dx,y1  ;set y1
 mov bx,0  ;clear BX
 mov ax,delta_y ;set count
 mov count,ax ;  to y2-y1
newdot2:
 call dotplot  ;plot the dot
 add dx,si  ;inc/dec Y
 add bx,delta_x ;add |x2-x1| to BX
 cmp bx,halfy ;compare to |y2-y1|/2
 jle dcount2  ;don't inc/dec X
 sub bx,delta_y ;subtract |y2-y1| from BX
 add cx,di
dcount2:
 dec count  ;done line yet?
 jge newdot2  ;not yet

 ret   ;done line

steep endp

;--------

dotplot proc near

 push ax  ;save registers
 push bx
 push cx
 push dx
 push si
 push di

 mov bh,0  ;display page
 mov ax,color ;set color value
 mov ah,0CH  ;write dot function
 int 10H

 pop di  ;restore registers
 pop si
 pop dx
 pop cx
 pop bx
 pop ax

 ret   ;dot plotted

dotplot endp

code ends
 end
--
Judson McClendon          This is a faithful saying and worthy of all
Sun Valley Systems        acceptance, that Christ Jesus came into the

(please remove numbers from email id to respond)



Sun, 22 Oct 2000 03:00:00 GMT  
 any asm code for line primitives?

I have sent Krogg some PB inline source code to draw lines. If you want
it please e-mail me, as I'd rather not gobble up bandwidth sending to
all of you.

Quote:

> Can anyone send me any asm sourcecode for drawing lines.I am looking
> for inline asm for powerbasic but i welcome any asm code at all.I dont
> care what screen mode but i am mainly looking for mode 13h.If you have
> any at all that you are willing to share please send it to me or post it
> here.
>                   Thanks,

> --
>       ___________       THE       ___________
>      / _________ \  <\PRINCE />  / _________ \
>     / /   __    \/   \\     //   \/    __   \ \
>    / /   /  \         \\   //         /  \   \ \
>   / /   / /\/        /""""""\         \/\ \   \ \
>   \ \  / /  SEE HIS (  /   \ \  SEE HIS  \ \  / /
>    \ \ \ \   FACE    \/<> <>\/   SMILE   / / / /
>     \ \ \ \          /   W   \          / / / /
>     / /  \ \        /\_|||||_/\        / /  \ \
>    / /   /  \      //   |||   \\      /  \   \ \
>   / /   / /\ \    //     '     \\    / /\ \   \ \
>  / /   / / / /   </ TIME TO DIE \>   \ \ \ \   \ \
> / /   /  \/  \_______________________/  \/  \   \ \
> \ \  / /\_________________________________/\ \  / /

>   \__/      Remove no.to.spam to reply       \__/
>     http://www.*-*-*.com/ ~carcher/krogg/aani.htm
>    {*filter*}javascript animations for your enjoyment

--
- Ray Zwitserloot.


 Change the E-mail address to reply!

----------------------------------------------------



Sun, 22 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Line drawing graphics primitive

2. HELP - Manually Place Long Lines of Code over Several Lines in Code Window

3. Translate asm code to Basic

4. Source code: BSEARCH.ASM

5. Source code: SORTINT.ASM

6. Source code: SORTLONG.ASM

7. Source code: CHARCNT.ASM

8. Source Code: REPLACE.ASM

9. Source code: ISTR.ASM

10. Source Code: RINSTR.ASM

11. Source code: MIDASC.ASM

12. Source Code: SPEAKER.ASM

 

 
Powered by phpBB® Forum Software