EXAMPLE: SimpleLine
;
; This example uses the line draw mode of the blitter
; to draw a line. The line is drawn with no pattern
; and a simple 'or' blit into a single bitplane.
;
; Input: d0=x1 dl=y1 d2=x2 d3=y2 d4=width a0=aptr
;
include 'exec/types.i'
include 'hardware/custom.i'
include 'hardware/blit.i'
include 'hardware/dmabits.i'
include 'hardware/hw_examples.i'
;
xref _custom
;
xdef simpleline
;
; Our entry point.
;
simpleline:
lea custom,a1 ; snarf up the custom address register
sub.w d0,d2 ; calculate dx
bmi xneg ; if negative, octant is one of [3,4,5,6]
sub.w d1,d3 ; calculate dy octant is one of [1,2,7,8]
bmi yneg ; if negative, octant is one of [7,8]
cmp.w d3,d2 ; cmp |dx|,|dy|octant is one of [1,2]
bmi ygtx ; if y>x, octant is 2
moveq.l #OCTANT1+LINEMODE,d5 ; otherwise octant is 1
bra lineagain ; go to the common section
ygtx:
exg d2,d3 ; X must be greater than Y
moveq.l #OCTANT2+LINEMODE,d5 ; we are in octant 2
bra lineagain ; and common again.
yneg:
neg.w d3 ; calculate abs(dy)
cmp.w d3,d2 ; cmp |dx|,|dy|, octant is [7,8]
bmi ynygtx ; if y>x, octant is 7
moveq.l #OCTANT8+LINEMODE,d5 ; otherwise octant is 8
bra lineagain
ynygtx:
exg d2,d3 ; X must be greater than Y
moveq.l #OCTANT7+LINEMODE,d5 ; we are in octant 7
bra lineagain
xneg:
neg.w d2 ; dx was negative! octant is [3,4,5,6]
sub.w d1,d3 ; we calculate dy
bmi xyneg ; if negative, octant is one of [5,6]
cmp.w d3,d2 ; otherwise it's one of [3,4]
bmi xnygtx ; if y>x, octant is 3
moveq.l #OCTANT4+LINEMODE,d5 ; otherwise it's 4
bra lineagain
xnygtx:
exg d2,d3 ; X must be greater than Y
moveq.l #OCTANT3+LINEMODE,d5 ; we are in octant 3
bra lineagain
- Blitter Hardware 197 -