From: werner_huysegoms@my-dejanews.com
Newsgroups: comp.sys.hp48
Subject: Re: line.s
Date: Thu, 19 Nov 1998 16:43:07 GMT
Organization: Deja News - The Leader in Internet Discussion
Lines: 202
Message-ID: <731hqk$idn$1@nnrp1.dejanews.com>
References: <slrn7565jd.ko.mozgy@danielle.mozgy.hr> <qrgyrscebivqr.f2ngyh1.pminews@news.hamburg.pop.de>
NNTP-Posting-Host: 158.169.10.59
X-Article-Creation-Date: Thu Nov 19 16:43:07 1998 GMT
X-Http-User-Agent: Mozilla/4.05 [en] (WinNT; I ;Nav) via proxy gateway CERN-HTTPD/3.0 libwww/2.17
X-Http-Proxy: 1.0 x9.dejanews.com:80 (Squid/1.1.22) for client 158.169.10.59
Xref: republic.btigate.com comp.sys.hp48:18774

In article <qrgyrscebivqr.f2ngyh1.pminews@news.hamburg.pop.de>,
  "Detlef Mueller" <I.h8.spam@dont.even.try> wrote:
> Hey Mozgy -- here's my version. Competition is open, which one is
> faster ? Anyone w/ an even faster/shorter version ?
>
> Bye,
> 	Detlef

And here's mine:
It does not check the boundaries of the grob.

*
* draw a straight line from (x1,y1) to (x2,y2)
*
* In  : grob {#x1 #y1} {#x2 #y2}
* Out : grob'
*
* bytes: 259.0
* check: #6EAFh
*
::
  0LASTOWDOB!
  CK3NOLASTWD
  CK&DISPATCH1
  # C55
  ::
    2HXSLIST?
    ROT
    2HXSLIST?
    CODE
	GOSBVL  =POP2#          * read coordinates
	R1=A
	R2=C
	GOSBVL  =POP2#
	R4=C
	GOSBVL  =SAVPTR
	C=R1
	?C<=A   A
	GOYES   L01
	AR1EX
	CR2EX
	CR4EX
	CR2EX
L01     R3=A
	A=DAT1  A               * determine #nibs in a row
	D0=A
	D0=D0+  15
	A=DAT0  A
	A=A+CON A,7
	A=A+A   A
	ASR     A
	A=A+A   A
	D1=A
	C=R4                    * +/- according to dy = y2-y1
	D=C     A
	C=R2
	D=D-C   A
	GONC    L02
	D=-D    A               * D.A holds abs(dy)
	A=-A    A               * D1 holds sign(dy)*#rownibs
	AD1EX                   * A.A holds #rownibs
L02     C=R2                    * determine nibble that holds (x1,y1)
	GOSBVL  =MUL#           * = D0 + 5 + y1.#rownibs + x1 DIV 4
	B=0     S
	B=B+1   S
	C=R1                    * and the starting pixel
	SB=0
	CSRB.F  A
	?SB=0
	GOYES   L03
	SB=0
	B=B+B   S
L03     CSRB.F  A
	?SB=0
	GOYES   L04
	B=B+B   S
	B=B+B   S
L04     D0=D0+  5
	AD0EX
	A=A+B   A
	A=A+C   A
	D0=A
	A=R3
	C=R1
	A=A-C   A       * A.A = dx
	C=D     A       * C.A = abs(dy)
	?A#0    A
	GOYES   L05
*
* dx=0 : vertical
*
	AD1EX
	CD0EX
L11     D0=C
	A=DAT0  S
	A=A!B   S
	DAT0=A  S
	C=C+A   A
	D=D-1   A
	GONC    L11
	GOTO    L50
L05     ?C#0    A
	GOYES   L06
*
* dy=0 : horizontal
*
	AD1EX
	A=DAT0  S
L21     A=A!B   S
	D1=D1-  1
	GOC     L25
	B=B+B   S
	GONC    L21
	DAT0=A  S
	A=0     S
	A=A-1   S               * A.S = 1111b
	GOC     L23             * BET
L22     DAT0=A  S
L23     D0=D0+  1
	D1=D1-  4
	GONC    L22
	D1=D1+  4
	B=B+1   S
	A=DAT0  S
L24     A=A!B   S
	B=B+B   S
	D1=D1-  1
	GONC    L24
L25     GOTO    L49
L06     B=A     A
	B=C-B   A
	B=B+B   A
	GOC     L40
*
* dx<=dy : more vertical
*
	A=C     A
	D=D+D   A
	AD1EX
	GONC    L33             * BET
L31     CD0EX
	C=C+A   A
	CD0EX
	C=C-B   A
	GOC     L32
	B=B+B   S
	GONC    L33
	B=B+1   S
	D0=D0+  1
	GONC    L33             * BET
L32     C=C+D   A
L33     A=DAT0  S               * read&write nib
	A=A!B   S
	DAT0=A  S
	D1=D1-  1
	GONC    L31
	GOC     L50             * BET
*
* dx>dy : more horizontal
*
L40     B=-B    A
	C=A     A
	D=C     A
	D=D+D   A
	AD1EX
	GONC    L44             * BET
L41     C=C-B   A               * loop for 'more horizontal'
	GONC    L42
	C=C+D   A
	B=B+B   S
	GONC    L45
	DAT0=A  S
	GOC     L43             * BET
L42     DAT0=A  S               * write nib
	CD0EX                   * move vertical
	C=C+A   A
	CD0EX
	B=B+B   S               * next pixel
	GONC    L44
L43     B=B+1   S               * move right
	D0=D0+  1
L44     A=DAT0  S               * read nib
L45     A=A!B   S
	D1=D1-  1
	GONC    L41
L49     DAT0=A  S
L50     GOVLNG  =GETPTRLOOP
    ENDCODE
  ;
;

Now to find someone to test them all..


--
Best Regards,
Werner Huysegoms
Reply-To: werner.huysegoms@dgx11.cec.be
remove the x before replying