English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Asm / Hardware

 
 
Thread Tools
Old 14 April 2018, 23:30   #21
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,658
Quote:
Originally Posted by borchen View Post
@mcgeezer

He does indeed, but the moving rasterbar in his tutorials does not go beyond the $ffdf point...
It's all about the learning curve, it must be free of bumps and steep upward slopes. The $ffdf wrap is covered much later in the scroller bounce part.

It's just... you wouldn't explain how to build a Copper List dynamically to someone who doesn't know how to create a variable in Assembler, and you wouldn't start explaining what a Copper List is until you've gotten the general idea of programming the chips, lists in memory, etc across.

Building a Copper list each frame dynamically is fine, but it won't remove the required understanding of how to conditionally insert the extra wait.

Some live with scanline stagger at the right edge of the screen, but I'm not going to teach that since it's clearly visible on any Amiga display. HPOS 07 is it.
Photon is offline  
Old 16 April 2018, 12:19   #22
fstarred
Registered User
 
fstarred's Avatar
 
Join Date: Mar 2018
Location: Rome
Posts: 173
@borchen

Congratulations, your code is definitely more clear than mine

Thanks for your support !!!
fstarred is offline  
Old 22 April 2018, 10:34   #23
borchen
Registered User
 
Join Date: Jan 2016
Location: NL
Posts: 32
Quote:
Congratulations, your code is definitely more clear than mine
Thanks!

Here's another (rather silly) version that pre-generates all the copper-instructions and uses the movem-command to write them into the copper.
As you see I now use available CPU registers instead of variables in memory, which is perfectly possible in such a small program.

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

;--- generate rasterbar linedata
	lea	linedata,a1
	move.l	#$2c07,d0	; start line
	move.l	#$ff,d7		; 256 lines
.rb_l
	cmpi.w	#$2c07,d0
	blo.s	.below

	cmpi.w	#$ff07,d0
	bne.s	.above
.at:					; $ff = special part
	move.w	d0,(a1)+		; vert pos start
	move.w	#$fffe,(a1)+		; wait
	move.l	#$1800f00,(a1)+		; COLOR00 red line
	move.l	#$ffdffffe,(a1)+	; extra wait
	add.w	#$0100,d0
	move.w	d0,(a1)+		; vert pos stop
	move.w	#$fffe,(a1)+		; wait
	move.l	#$1800000,(a1)+		; COLOR00 black
	bra.s	.next
.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
	bra.s	.next
.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

.next	dbf	d7,.rb_l

;--- Init Movebar
	lea	linedata,a0		; source pre-generated
	lea	redbar,a1		; destination in copperlist
	moveq	#10*2,d6		; delta startvalue
					; down=20, up=-20	

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

;--- MoveBar
	add.w	d6,a0			; add delta to linedata address

	cmpa.l	#linedata+5120,a0	; bottom?
	bne.s	.notbot			; no
	neg	d6			; yes -> reverse delta
;	Pause
.notbot
	cmpa.l	#linedata-20,a0		; top?
	bne.s	.nottop			; no
	neg	d6			; yes -> reverse delta
;	Pause
.nottop
	movem.l	(a0),d1-d5		; read  10 words of linedata and
	movem.l	d1-d5,(a1)		; write them into copperlist

	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:				; offset "graphics.library"
	dc.l	0	 
oldcop:					; system COP address
	dc.l	0
oldint:
	dc.w	0			; INTENA(R)
olddma:
	dc.w	0			; DMACON(R)

linedata:
	ds.w	2*5*256			; 5KB


	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
P.S. as you see, there are more solutions to this problem, or as we say in Holland; there are more roads leading to Rome.

Update: I moved the whole MoveBar routine into the Main-code...so the program jumps around even less!

Last edited by borchen; 22 April 2018 at 10:57.
borchen is offline  
Old 22 April 2018, 11:17   #24
DanScott
Lemon. / Core Design
 
DanScott's Avatar
 
Join Date: Mar 2016
Location: Tier 5
Posts: 1,213
Another solution for you:

Insert this in the copperlist...

Code:
Copper_Bars:
Wait1  set $2c07
Wait2  set $2cdf
rept 256
dc.w Wait1,$fffe
dc.w $0180,$0000
dc.w Wait2,$fffe
Wait1 set (Wait1+$0100)&$0000ffff
Wait2 set (Wait2+$0100)&$0000ffff
endr
then you can just calculate the offset to write your colour bar to:

Code:
lea Copper_Bars,a0
move.w BarYPosition,d0
mulu #12,d0
move.w #$f00,6(a0,d0.w)
This eliminates the need to have special code that checks for the Y crossing into the PAL area, and each line has the same number of copper instruction, so you can easily calculate the offset with a multiply (or a series of adds will also be quicker)

You could then write as many bars as you like at any positions.

At the start of each frame you could clear ALL the colours back to $0000 in a simple loop, or just reset the colour at the bar position back to $0000 before updating it's value, and writing colour to a new position.
DanScott is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tool to convert asm to gnu asm (gas) Asman Coders. Asm / Hardware 13 30 December 2020 11:57
A newbie to the Amiga and ASM, what approach to take? P-J Coders. General 19 18 September 2007 14:36
General asm question Haakon Coders. General 14 15 February 2006 21:42
Some general newbie questions Pixel New to Emulation or Amiga scene 10 14 March 2002 18:35

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 20:26.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.14484 seconds with 16 queries