Drawing lines on an Amiga

Focus Design - Monotit, lines and arrows

Drawing lines on an Amiga

  • Nils Thiebosch
  • 15-02-2023 12:21:13
  • 0 Comments

Drawing lines is, when you work with vector graphics, necesairy. But it is also an expansive routine. 
Here is my linedraw routine that I use to draw my screens. 

The image is taken from the 64K intro from: Focus Design - Monotit, lines & arrows



** ------------------------------- **
** Linedraw
** ------------------------------- **
; Sync Line Drawing Routine
; d0=X1  
; d1=Y1  
; d2=X2  
; d3=Y3
; a0=Bitplane 
; a4-a5 storage of cliplines (each plane)

Width = SCREEN_WIDTH
Heigth = SCREEN_Y
Depth = 1
MINTERM = $4a

; Make sure that when you start to call this function that you have called LineInit first

LineDraw:
	tst.w 	d4
	beq.w 	.LineOut
	cmp.w 	d1, d3
	beq.w 	.LineOut
	bgt.s 	.Line1
	exg     d0, d2
	exg     d1, d3
.Line1:	
	sub.w 	d0,d2
	sub.w 	d1,d3
	subq.w 	#1,d3
	moveq 	#0,d4
	ror.w 	#4,d0
	move.b 	d0,d4
	and.w 	#$f000,d0
	add.b 	d4,d4
	add.w 	d1,d1
	add.w 	Line_Mulu(pc,d1.w),d4
	lea     0(a0,d4.w),a0
	move.w 	d0,d4
	or.w 	#$0b<<8|MINTERM,d4
	moveq 	#0,d1
	tst.w 	d2
	bpl.s 	.Line2
	neg.w	d2
	moveq	#4,d1
.Line2:
	cmp.w	d2,d3
	bpl.s 	.Line3
	or.     #16,d1
	bra.s	.Line4
.Line3:
	exg 	d2,d3
	add.b 	d1,d1
.Line4:
	addq.b 	#3,d1
	or.w 	d0,d1
	add.w 	d3,d3
	add.w 	d3,d3
	add.w 	d2,d2
	
	tst.w 	(a6)
.Line5:
	btst    #6,$2(a6)
	bne.s 	.Line5
	move.w 	d3,$062(a6)
	sub.w 	d2,d3
	bge.s 	.Line6
	or.w 	#$40,d1
.Line6	
	move.w 	d1,$042(a6)
	move.w 	d3,$052(a6)
	sub.w 	d2,d3
	move.w 	d3,$064(a6)
	move.w 	d4,$040(a6)
	move.l 	a0,$048(a6)
	move.l 	a0,$054(a6)
	addq.w 	#1<<1,d2
	lsl.w 	#5,d2
	addq.b 	#2,d2
	move.w 	d2,$058(a6)
.LineOut:
	rts

** ------------------------------- **
Line_Mulu:
MuluCount set 0
	rept Heigth
	dc.w MuluCount*Width*Depth
MuluCount set MuluCount+1
	endr
** ------------------------------- **
** Init linedraw
** ------------------------------- **
LineInit:
	tst.w 	(a6)
.wb:	btst 	#6,$2(a6)
	bne.s 	.wb
	move.w 	#Width*Depth,$060(a6)
	move.w 	#Width*Depth,$066(a6)
	move.l 	#-1,$044(a6)
	move.l 	#-$8000,$072(a6)
	rts
	
0 Comments

relevant Stories

Amiga dots

Dot draw on Amiga

  • Nils Thiebosch
  • 15-02-2023 05:28:06
  • 0 Comments

Drawing dots is relative easy and there are multiple ways to do it on the Amiga. This is my dot-draw routine. Nothing fancy.

Amiga OS

Intro startup assembly code

  • Nils Thiebosch
  • 01-06-2023 04:51:56
  • 0 Comments

When starting an intro on the amiga you want that all processes belonging to the OS are frozen and stored away.