Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: directional system: more magic code cleanups
Home

[Freeciv-Dev] Re: directional system: more magic code cleanups

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: jdorje@xxxxxxxxxxxxxxxxxxxxx, freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: directional system: more magic code cleanups
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 19 Sep 2001 09:21:06 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Tue, Sep 18, 2001 at 11:57:06PM -0400, Ross W. Wetmore wrote:
> Attached is a copy of straightest_dir with yet another explanation 
> of the algorithm embedded as comments in hopes that repetition will
> eventually penetrate those that still haven't got it :-).

> Note that to choose one of 8 directions, the absolute minimum work
> is 3 binary compares, so there is still room for improvement in the
> attached algorithm.

I agree that the the method can be implemented in three compares. My
documentation of the Amiga custom chip Blitter agrees with this.

x1<x2:  possible octanes: 0,1,6,7
x1>x2:  possible octanes: 2,3,4,5
x1==x2: possible octanes: all

y1<y2:  possible octanes: 0,1,2,3
y1>y2:  possible octanes: 4,5,6,7
y1==y2: possible octanes: all

|x2-x1|>|y2-y1|:  possible octanes: 0,3,4,7
|x2-x1|<|y2-y1|:  possible octanes: 1,2,5,6
|x2-x1|==|y2-y1|: possible octanes: all

Note that the octanes used here have to be rotated by \pi/8 to be used
by freeciv.

IF straightest_dir is implemented in such a fashion I would like to
ask you to implement it such as:

 int mask1=0xff,mask2=0xff,mask3=0xff;

 ...

 if(y1<y2)
    mask1=0x0f;
 else
    mask1=0xf0;

 ...
 
 mask=mask1&mask2&mask3;

 return mask_to_dir[mask];
}

Overall is looks like this we are already spending our times at the
wrong places.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Life is too short for reboots."


[Prev in Thread] Current Thread [Next in Thread]