pouët.net

Classic issue of finding the octant for Blitter in line mode on Ami.

category: code [glöplog]
 
Hop-hop!


I've been searching through many sources in net - winnicki.net, Aminet, Amiga SDK, Adam Doligalski... also in few other places and I couldn't find proper procedure for it. All are erronous.

So... I developed it by myself. It's not that hard when U get focus on and mind made-up.

about octant decides three comparisons:
- octants leaning to X axis - the ones with DeltaX>=DeltaY and to Y axis DeltaX<DeltaY
- octants for X2>=X1 - on right side of Y axis and X2<X1 - on left side
- octants for Y2>=Y1 - under X axis and Y2<Y1 - above

for the first comparison true sets bit 2 of temporary variable
for the second comparison true sets bit 1 of temporary variable
for the third comparison true sets bit 0 of temporary variable

next goes serie where from we read value with position indicated by our temporary variable:

0,4,1,6,2,5,3,7

such octant has to be multiplied by four and logically summed (OR.B) with BLTCON1 - $dff042

Here's the code part, that selects octant for line drawn from x1,y1 to x2,y2.

Code: x1 -> d1 y1 -> d2 x2 -> d3 y2 -> d4 Start: MOVE.L d1,d5 SUB.L d3,d5 CMP.L #0,d5 BGE noneg NEG.L d5 noneg: MOVE.L d5,DeltaX MOVE.L d2,d6 SUB.L d4,d6 CMP.L #0,d6 BGE noneg2 NEG.L d6 noneg2: MOVE.L d6,DeltaY CMP.L d5,d6 BGE nooneset1 BSET.L #0,d0 nooneset1: CMP.L d2,d4 BGE nooneset2 BSET.L #1,d0 nooneset2: CMP.L d1,d3 BGE nooneset3 BSET.L #2,d0 nooneset3: LEA Function,a3 MOVE.B (a3,d0.w),d7 d7 -> octant RTS Function: DC.B 0,16,4,24,8,20,12,28


octant in this procedure is already multiplied by four.

and here is the link for full procedure:
https://www.laffik.com/freebies/Lafficka%20Kurewska%20Kreska%20Blitterem%20MC680x0%20AsmOne.S


Howk!!!
added on the 2023-03-29 21:32:22 by Laffik Laffik
it's always nice to see some 68k asm on pouet..
added on the 2023-03-30 12:32:56 by arm1n arm1n
cheers!
added on the 2023-04-04 03:42:26 by Laffik Laffik
Especially noteworthy are the cmp.l #0,dn and the almost exclusive usage of
longwords :-)
added on the 2023-04-12 09:45:37 by ROG_VF ROG_VF
A clear sign of high-quality code. :)
added on the 2023-04-12 10:18:25 by StingRay StingRay
most important is this, that none of you, nor anywhere else on the world, ever before, found shorter way of finding octants.

cmp.l or no, it still works faster than your ways, anyway.

Pfffrrrrt!!!!! 8^p
added on the 2023-04-12 14:00:48 by Laffik Laffik
Quote:
most important is this, that none of you, nor anywhere else on the world, ever before, found shorter way of finding octants.

I think everyone here can point out several ways of making your code both shorter and faster. Please do share with us when you're able to figure it out yourself
added on the 2023-04-12 14:08:57 by britelite britelite
Quote:

cmp.l or no, it still works faster than your ways, anyway.


Indeed, and this from someone who invents non-existent instructions (bset.l *cough*). Thanks for the entertainment, which is much better than your code.
added on the 2023-04-12 14:13:53 by StingRay StingRay
Laffik is someones AI bot, right?
added on the 2023-04-12 17:09:34 by spiny spiny

login