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.
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!!!
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!!!
it's always nice to see some 68k asm on pouet..
cheers!
Especially noteworthy are the cmp.l #0,dn and the almost exclusive usage of
longwords :-)
longwords :-)
A clear sign of high-quality code. :)
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
cmp.l or no, it still works faster than your ways, anyway.
Pfffrrrrt!!!!! 8^p
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
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.
Laffik is someones AI bot, right?