English Amiga Board


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

 
 
Thread Tools
Old 26 April 2020, 10:53   #1
JoeJoe
Registered User

 
Join Date: Feb 2020
Location: Germany
Posts: 28
copper loop?

Hi there!

I have tried to create a CopperLoop based on this code. Unfortunately I can only jump every second line into CopperList 2.
Is this even possible?

Code:
start:
  lea$dff000,a5
  move.w  #$4000,$9a(a5)
  move.w  #$0100,$96(a5)

  move.l #cop2,$84(a5) ; pointer COP
  move.l #cop1,$80(a5) ; pointer COP

MainLoop:
  move.b$bfe801,d0
WaitVBRA:   
  cmp.b$bfe801,d0
  beq.s     WaitVBRA
  ; no end dude
  nop
  bra.s   MainLoop

  SECTION CHIP,data_c

****************************************************************************
cop1: ; copperlist 1
  dc.w$0007,$fffe
  dc.w$0180,$0000

  dc.w$500f,$fffe; wait =80
  dc.w$5101,$ffff; skip >81
  dc.w$008a,$0000; copjmp2 start or CNOP  ($dff08a)

  dc.w$520f,$fffe; wait =82
  dc.w$5301,$ffff; skip >83
  dc.w$008a,$0000; copjmp2 start or CNOP  ($dff08a)

  dc.w$540f,$fffe; wait =84
  dc.w$5501,$ffff; skip >85
  dc.w$008a,$0000; copjmp2 start or CNOP  ($dff08a)

  dc.w$f007,$fffe
  dc.w$0180,$0000
  dc.w$ffff,$fffe

****************************************************************************
cop2: ; copperlist 2
  dc.w$0180,$0100
  dc.w$0180,$0200
  dc.w$0180,$0300
  dc.w$0180,$0400
  dc.w$0180,$0500
  dc.w$0180,$0600
  dc.w$0180,$0700
  dc.w$0180,$0800
  dc.w$0180,$0900
  dc.w$0180,$0a00
  dc.w$0180,$0b00
  dc.w$0180,$0c00
  dc.w$0180,$0d00
  dc.w$0180,$0e00
  dc.w$0180,$0f10
  dc.w$0180,$0f20
  dc.w$0180,$0f30
  dc.w$0180,$0f40
  dc.w$0180,$0f50
  dc.w$0180,$0f60
  dc.w$0180,$0f70
  dc.w$0180,$0f80
  dc.w$0180,$0f90
  dc.w$0180,$0fa0
  dc.w$0180,$0fb0
  dc.w$0180,$0fc0
  dc.w$0180,$0fd0
  dc.w$0180,$0fe0
  dc.w$0180,$0ff0
  dc.w$0180,$0fe0
  dc.w$0180,$0fd0
  dc.w$0180,$0fc0
  dc.w$0180,$0fb0
  dc.w$0180,$0fa0
  dc.w$0180,$0f90
  dc.w$0180,$0f80
  dc.w$0180,$0f70
  dc.w$0180,$0f60
  dc.w$0180,$0f50
  dc.w$0180,$0f40
  dc.w$0180,$0f30
  dc.w$0180,$0f20
  dc.w$0180,$0f10
 
  dc.w$0088,$0000;copjmp1  ($dff088)
  dc.w$ffff,$fffe
Thanks and greetings
JoeJoe

Last edited by JoeJoe; 26 April 2020 at 10:56. Reason: formate code
JoeJoe is offline  
Old 26 April 2020, 22:26   #2
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 2,602
You can do it.
This is not the most suitable code and it is a bit tricky, just a working example..
Code:
start:
	lea	$dff000,a5
	move.w	#$4000,$9a(a5)
	move.w	#$0100,$96(a5)

	lea	cop2,a0
	move.l #cop1,$80(a5)	; pointer COP1
	move.l a0,$84(a5)		; pointer COP2

.wb	moveq	#$20,d0
	and.w	$1e(a5),d0
	beq.b	.wb
	move.w	d0,$9c(a5)
	bchg	#7,(a0)
.w8	cmpi.w	#$7f80,6(a5)
	bls.b	.w8
	bchg	#7,(a0)
	bra.b	.wb


	SECTION	CHIP,data_c

****************************************************************************
cop1: ; copperlist 1
	dc.w	$0180,$0000
	dc.w	$5001,$ff00	; wait for line $50
	dc.w	$ef81,$ffff	; skip loop for lines >=$f0
	dc.w	$008a,$0000	; copjmp2
	dc.w	$ffff,$fffe

****************************************************************************
cop2: ; copperlist 2
	dc.w	$802d,$80fe
	dc.w	$0180,$0100
	dc.w	$0180,$0200
	dc.w	$0180,$0300
	dc.w	$0180,$0400
	dc.w	$0180,$0500
	dc.w	$0180,$0600
	dc.w	$0180,$0700
	dc.w	$0180,$0800
	dc.w	$0180,$0900
	dc.w	$0180,$0a00
	dc.w	$0180,$0b00
	dc.w	$0180,$0c00
	dc.w	$0180,$0d00
	dc.w	$0180,$0e00
	dc.w	$0180,$0f10
	dc.w	$0180,$0f20
	dc.w	$0180,$0f30
	dc.w	$0180,$0f40
	dc.w	$0180,$0f50
	dc.w	$0180,$0f60
	dc.w	$0180,$0f70
	dc.w	$0180,$0f80
	dc.w	$0180,$0f90
	dc.w	$0180,$0fa0
	dc.w	$0180,$0fb0
	dc.w	$0180,$0fc0
	dc.w	$0180,$0fd0
	dc.w	$0180,$0fe0
	dc.w	$0180,$0ff0
	dc.w	$0180,$0fe0
	dc.w	$0180,$0fd0
	dc.w	$0180,$0fc0
	dc.w	$0180,$0fb0
	dc.w	$0180,$0fa0
	dc.w	$0180,$0f90
	dc.w	$0180,$0f80
	dc.w	$0180,$0f70
	dc.w	$0180,$0f60
	dc.w	$0180,$0f50
	dc.w	$0180,$0f40
	dc.w	$0180,$0f30
	dc.w	$0180,$0f20
	dc.w	$0180,$0f10
 
	dc.w	$ef81,$ffff	; skip loop for lines >=$f0
	dc.w	$008a,$0000	; copjmp2
	dc.w	$0088,$0000	; copjmp1
	dc.w	$ffff,$fffe


160 copper loop from line $50 to line $ef (inclusive).
Attached Thumbnails
Click image for larger version

Name:	coploop.jpg
Views:	346
Size:	1.6 KB
ID:	67041  
ross is online now  
Old 27 April 2020, 15:40   #3
JoeJoe
Registered User

 
Join Date: Feb 2020
Location: Germany
Posts: 28
Thx for your help. It is not my favorite solution but it work.
JoeJoe is offline  
Old 01 May 2020, 08:50   #4
xaind
Registered User

 
Join Date: Apr 2006
Location: Sydney / Australia
Posts: 106
Quote:
Originally Posted by ross View Post
Code:
	bchg	#7,(a0)
.w8	cmpi.w	#$7f80,6(a5)
	bls.b	.w8
	bchg	#7,(a0)
Hi Ross - I'm trying to follow this code. Could you explain why you're changing the initial wait instruction in copperlist 2 like this?

Thanks.
xaind is offline  
Old 01 May 2020, 10:20   #5
ross
Per aspera ad astra

ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 50
Posts: 2,602
Quote:
Originally Posted by xaind View Post
Hi Ross - I'm trying to follow this code. Could you explain why you're changing the initial wait instruction in copperlist 2 like this?

Thanks.
The concerned WAIT instruction:
dc.w $802D,$80fe

As you can see I've a wait for any position >=$80 because I completely mask the vertical positions excluding bit 7
(so I could have put any value for the lower 7 WAIT pos bits since they would have been ignored).
Why haven't I also masked bit 7? Because it's used to wait for a blitter finished operation (BFD) and therefore, since I am not interested in it, I ignore it and leave it at 1.
This forces me to break my wait into two blocks: for positions between 0 and $7f and between $80 and $ff (I would also have the case for the positions >$ff but I've not treated it in this example).
[EDIT: yes, bits that you cannot explicit mask is like a 1 in the mask, so actually you can mask only 7 bit y-positions with WAIT/SKIP copper instructions]

With the CPU I therefore wait for when the beam is in a position >$7f2d in order to change the bit 7 of the WAIT and to be able to use the same copper code in both cases.
If you wonder why I used the exact x=$2d position: it's the one that allows me to change the background color immediately after the horizontal blank when I am in maximum overscan.
The first bchg is executed immediately after the vertical blank start, so to zero the bit 7 and wait with the copper in the first $80 lines.

I use the bchg instruction to make it clear that it is a switch between two cases, but I could also use a bclr followed by a bset (or a andi then a ori, and use a constant [EDIT: in a Dx register] instead of #7).

I hope I was clear.

Last edited by ross; 01 May 2020 at 10:35. Reason: []
ross is online now  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitting from main loop and level 3 interrupt (copper) nandius_c Coders. Asm / Hardware 9 07 February 2020 19:15
It Came from the Desert crashing in a Loop gb_pdx support.FS-UAE 5 04 January 2017 20:43
Best way to mix blitting with copper and copper effects roondar Coders. Asm / Hardware 3 12 September 2016 13:12
Copper loop confusions Fell Coders. Asm / Hardware 15 21 September 2015 21:02
Combining copper scrolling with copper background phx Coders. Asm / Hardware 14 16 June 2013 07:26

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 02:02.


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