View Single Post
Old 14 April 2018, 20:49   #20
borchen
Registered User
 
Join Date: Jan 2016
Location: NL
Posts: 32
@mcgeezer
Quote:
Doesn't Photon cover this in his tutorials?
He does indeed, but the moving rasterbar in his tutorials does not go beyond the $ffdf point...

@fstarred
Quote:
Redbar is getting really faster than before!
Great to hear! The new version certainly runs a lot better.

Just for good measure, here's my version, which contains a simple to use Pause MACRO:
Code:
; Constants

OldOpenLibrary	= -$198		; -408
CloseLibrary	= -$19E		; -414

DMASET	= %1000001010000000
;	  %-----axbcdefghij
;	a: Blitter Nasty
;	x: Enable DMA
;	b: Bitplane DMA (if this isn't set, sprites disappear!)
;	c: Copper DMA
;	d: Blitter DMA
;	e: Sprite DMA
;	f: Disk DMA
;	g-j: Audio 3-0 DMA

;--- Macros
Pause:	MACRO
.pause\@:
	btst	#10,$dff016		; check for right mouse button
	bne.s	.pause\@		; pressed? continue!
	ENDM


	SECTION	CODESECTION,CODE	; This command will run the below code
					; on FAST RAM (if enough) or CHIP RAM
Start:
	movem.l	d1-a6,-(sp)		; save CPU registers
	move.l	4.w,a6			; a6 = execbase

	move.l	#gfxname,a1		; a1 = gfxname
	jsr	OldOpenLibrary(a6)	; open gfxlibrary
	move.l	d0,a1			; a1 = gfxlibrary
	move.l	38(a1),oldcop		; save COPPER
	jsr	CloseLibrary(a6)	; close gfxlibrary

	move.w	$dff01c,oldint		; save INTENAR
	move.w	$dff002,olddma		; save DMACONR

	move.w	#$7fff,$dff09a		; disable INTENA = turn off OS
	move.w	#$7fff,$dff09c		; disable INTREQ
	move.w	#$7fff,$dff09c		; twice -> amiga4000 hw bug!
	move.w	#$7fff,$dff096		; disable DMACON

	move.w	#DMASET,$dff096		; enable necessary bits in DMACON
	move.l	#copperlist,$dff080	; COP1LCH set custom copperlist
	move.w	#0,$dff088		; COPJMP1 activate copperlist

;--- Init Movebar
	move.w	#$0100,d0		; down=$0100, up=$ff00
	move.w	d0,delta		; set delta startvalue

	move.w	#$aa07,line		; line counter

Main:
	move.l	$dff004,d0		; check VPOSR
	and.l	#$0001ff00,d0		; for
	cmp.l	#301<<8,d0		; rasterline 301
	bne.s	Main

	bsr.s	Movebar

	btst	#6,$bfe001		; check for left mouse button
	bne.s	Main			; if not, goto Main

End:
	move.w	#$7fff,$dff096		; clear DMACON

	move.w	olddma,d0
	or.w	#$8200,d0		; set bits of DMACON state
	move.w	d0,$dff096		; restore original DMACON

	move.l	oldcop,$dff080		; restore original copperlist
	move.w	#0,$dff088		; and activate it

	move.w	oldint,d0
	or.w	#$c000,d0		; set bits of INTENAR state
	move.w	d0,$dff09a		; restore INTENA state = turn on OS

	movem.l	(sp)+,d1-a6		; restore CPU registers
	moveq	#0,d0			; nice clean
	rts				; exit


gfxname:
	dc.b	"graphics.library",0,0
gfxbase:			; Dedicated to offset "graphics.library"
	dc.l	0	 
oldcop:				; Dedicated to system COP address
	dc.l	0
oldint:
	dc.w	0		; Dedicated to INTENA(R)
olddma:
	dc.w	0		; Dedicated to DMACON(R)


Movebar:
	move.w	line,d0			; current vert pos
	add.w	delta,d0		; down=1 / up=-1
	move.w	d0,line			; save new vert pos

	lea	redbar,a1		; where to write in copperlist

	cmpi.w	#$2c07,d0
	blo.s	Below

	cmpi.w	#$ff07,d0
	bne.s	Above
At:					; $ff = special part
	move.l	#$ff07fffe,(a1)+	; vert pos start
	move.l	#$1800f00,(a1)+		; COLOR00 red line

	move.l	#$ffdffffe,(a1)+	; extra wait

	move.l	#$0007fffe,(a1)+	; vert pos stop
	move.l	#$1800000,(a1)		; COLOR00 black
	Pause
	rts

Above:					; $2c - $fe = upper part
	move.w	d0,(a1)+		; vert pos start
	move.w	#$fffe,(a1)+		; wait
	move.l	#$1800f00,(a1)+		; COLOR00 red

	add.w	#$0100,d0
	move.w	d0,(a1)+		; vert pos stop
	move.w	#$fffe,(a1)+		; wait
	move.l	#$1800000,(a1)+		; COLOR00 black

	move.l	#$ffdffffe,(a1)		; extra wait

	cmpi.w	#$2d07,d0		; $2c07+$0100 = top?
	bne.s	.ret
	neg.w	delta			; switch direction 1 -> -1
	Pause
.ret
	rts

Below:					; $00 - $2b = lower part
	move.l	#$ffdffffe,(a1)+	; extra wait

	move.w	d0,(a1)+		; vert pos start
	move.w	#$fffe,(a1)+		; wait
	move.l	#$1800f00,(a1)+		; COLOR00 red

	add.w	#$0100,d0		; stop between $01-$2c
	move.w	d0,(a1)+		; vert pos stop
	move.w	#$fffe,(a1)+		; wait
	move.l	#$1800000,(a1)		; COLOR00 black

	cmpi.w	#$2c07,d0		; $2b07+$0100 = bottom?
	bne.s	.ret
	neg.w	delta			; switch direction 1 -> -1
	Pause
.ret	rts


delta:
	dc.w	0
line:
	dc.w	0


	SECTION	GRAPHIC,DATA_C	; Section below MUST be executen on CHIP RAM,
				; because copperlist requires it
copperlist:
	dc.w	$100,$0200	; BPLCON0 - THE BITLANE CONTROL
	dc.w	$180,$000	; Color 0 - BLACK

;--- top blue
	dc.w	$2b07,$FFFE	; line 43
	dc.w	$180,$00f	; Color 0 - BLUE
	dc.w	$2c07,$FFFE	; TOP LIMIT
	dc.w	$180,$000

;--- generated in Movebar
redbar:
	dc.w	$aa07,$fffe	; wait start
	dc.w	$180,$f00	; COLOR00 red
	dc.w	$ab07,$fffe	; wait stop
	dc.w	$180,$000	; COLOR00 black

	dc.w	$ffdf,$fffe	; extra wait

;--- bottom blue
	dc.w	$2c07,$FFFE	; Wait for last line
	dc.w	$180,$00F	; Color 0 - BLUE
	dc.w	$2d07,$FFFE	; BOTTOM LIMIT
	dc.w	$180,$000

	dc.w	$FFFF,$FFFE	; END OF copperlist
END
F.Y.I. i'm by no means a seasoned assembler programmer. Not long ago I was at the same point you are on now...
borchen is offline  
 
Page generated in 0.04513 seconds with 11 queries