English Amiga Board


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

 
 
Thread Tools
Old 23 November 2021, 13:07   #1
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 413
Hardware sprites issue

Hi folks,

I'm having a go at hardware sprites, but I can't get them to display correctly.

Below is a link to a picture which visually describes the problem. I'm just using Sprite 0 for now, and the rest are set to a blank sprite. The block on the left is what should be displaying, but the block on the right is what I get (plus it's rapidly flickering on and off).

https://drive.google.com/file/d/1CoY...ew?usp=sharing

I think I'm loading the sprite registers wrong, as it seems to be displaying the control words as the first bitmap line and chopping off the last line of pixels. All l'm I'm doing is poking a data list in the copper, so I think that's where I'm messing up, but I can't see how. I generally put it where the rest of the pointers are updated.

No idea what the flickering is about. I've tried the sprites inside and outside the main loop, at the screen update, and everywhere else. It feels like the Sprite DMA is being toggled on and off, but I can't find anything in the code which could be doing that. I'm double buffering, but it still happens when I switch that off.

Everything moves ok when I poke the HSTART, but I have that turned off for now as well.

Anyway, below is my code for the various parts, so any advice would be greatly appreciated.

SPRITE DATA:
Code:
SPR_TRAINLIGHT_M:
	dc.w	$8460,$9400
	INCBIN "C:\Amiga\FFARES\ROUND2\2_2\TRAINLIGHT_M.RAW"
	dc.w	0,0
	EVEN

SPR_BLANKSPRITE:
	dc.w	$2a10,$2b00
	dc.w	0,0
	dc.w	0,0
	EVEN
LOAD SPRITE REGISTERS:
Code:
;--------------------------------------------------------------------------------------------------------------
;		SPRITE TEST
;--------------------------------------------------------------------------------------------------------------

HW_SPRITES:

	movem.l	a0-a1/d1,-(sp)
	
	;---------------------------------------
	
	lea 	SprPtr_MAIN,a1					; Where to poke the Sprite pointers in the Copper
		
	;---------------------------------------
	; 	SPRITE 0
	;---------------------------------------
	
HWSPRITE0;	

	lea 	SPR_TRAINLIGHT_M,a0	   			; Sprite Data

	move.l 	a0,d1
	swap 	d1
	move.w 	d1,2(a1)						; High word
	swap 	d1
	move.w 	d1,6(a1)						; Low word
	addq.l	#8,a1							; Point to next bpl to poke in copper
	
	;---------------------------------------
	; 	SPRITE 1
	;---------------------------------------
	
HWSPRITE1:	

	lea 	SPR_BLANKSPRITE,a0				; Sprite Data
	
	move.l 	a0,d1
	swap 	d1
	move.w 	d1,2(a1)						; High word
	swap 	d1
	move.w 	d1,6(a1)						; Low word
	addq.l	#8,a1							; Point to next bpl to poke in copper
	
	;---------------------------------------
	; 	SPRITE 2
	;---------------------------------------
	
HWSPRITE2:	

	lea 	SPR_BLANKSPRITE,a0				; Sprite Data

	move.l 	a0,d1
	swap 	d1
	move.w 	d1,2(a1)						; High word
	swap 	d1
	move.w 	d1,6(a1)						; Low word
	addq.l	#8,a1							; Point to next bpl to poke in copper
	
	;---------------------------------------
	; 	SPRITE 3
	;---------------------------------------
	
HWSPRITE3:

	lea 	SPR_BLANKSPRITE,a0				; Sprite Data
	
	move.l 	a0,d1
	swap 	d1
	move.w 	d1,2(a1)						; High word
	swap 	d1
	move.w 	d1,6(a1)						; Low word
	addq.l	#8,a1							; Point to next bpl to poke in copper
	
	;---------------------------------------
	; 	SPRITE 4
	;---------------------------------------
	
HWSPRITE4:

	lea 	SPR_BLANKSPRITE,a0				; Sprite Data
	
	move.l 	a0,d1
	swap 	d1
	move.w 	d1,2(a1)						; High word
	swap 	d1
	move.w 	d1,6(a1)						; Low word
	addq.l	#8,a1							; Point to next bpl to poke in copper
	
	;---------------------------------------
	; 	SPRITE 5
	;---------------------------------------
	
HWSPRITE5:

	lea 	SPR_BLANKSPRITE,a0				; Sprite Data
	
	move.l 	a0,d1
	swap 	d1
	move.w 	d1,2(a1)						; High word
	swap 	d1
	move.w 	d1,6(a1)						; Low word
	addq.l	#8,a1							; Point to next bpl to poke in copper
	
	;---------------------------------------
	; 	SPRITE 6 
	;---------------------------------------
	
HWSPRITE6:

	lea 	SPR_BLANKSPRITE,a0				; Sprite Data

	move.l 	a0,d1
	swap 	d1
	move.w 	d1,2(a1)						; High word
	swap 	d1
	move.w 	d1,6(a1)						; Low word
;	addq.l	#8,a1							; Point to next bpl to poke in copper

	;---------------------------------------
	; 	SPRITE 7 (Disabled for scrolling)
	;---------------------------------------
	
HWSPRITE7:

;	lea 	SPR_BLANKSPRITE,a0				; Sprite Data
	
;	move.l 	a0,d1
;	swap 	d1
;	move.w 	d1,2(a1)						; High word
;	swap 	d1
;	move.w 	d1,6(a1)						; Low word
;	addq.l	#8,a1							; Point to next bpl to poke in copper

	;---------------------------------------
	;	ENABLE SPRITE DMA
	;---------------------------------------
	
	move.w 	#%1000000000100000,$dff096		
	
	;---------------------------------------
	;	MOVE SPRITES (Off for now)
	;---------------------------------------
	
	;move.b 	(SPR_TRAINLIGHT_M+1),d0
	;sub 		#2,d0
	;move.b 	d0,(SPR_TRAINLIGHT_M+1)
			
	;---------------------------------------
		
	movem.l	(sp)+,a0-a1/d1
		
	;---------------------------------------
	RTS
	;---------------------------------------
LIST IN COPPER:
Code:
SprPtr_MAIN:
	dc.w $120,0		; HW Sprite 0
	dc.w $122,0	
	
	dc.w $124,0		; HW Sprite 1
	dc.w $126,0						

	dc.w $128,0		; HW Sprite 2				
	dc.w $12a,0							

	dc.w $12c,0		; HW Sprite 3				
	dc.w $12e,0		

	dc.w $130,0		; HW Sprite 4		
	dc.w $132,0					

	dc.w $134,0		; HW Sprite 5
	dc.w $136,0						

	dc.w $138,0		; HW Sprite 6					
	dc.w $13a,0							

	dc.w $13c,0		; HW Sprite 7	(Disabled)		
	dc.w $13e,0
Brick Nash is offline  
Old 23 November 2021, 14:06   #2
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,228
the sprite part of the copperlist is okay (I would have started by a loop to zero all sprites instead of copy paste... or asm REPT instruction )

do you have bitplane registers loaded in your copperlist?

you also need a sprite position table at some point. I suggest you check my Pacman or MsPacman source, it's pretty simple and uses sprites for ghosts without issues.
jotd is offline  
Old 23 November 2021, 14:25   #3
Leo24
Registered User
 
Join Date: May 2017
Location: Sao Paulo
Posts: 17
I also can't find any issue with the sprites setup. Supposing the sprite data is 16x16 in 2bpp, VSTART and VSTOP in the control words are set correct.
The issue is probably outside the code you showed.
Leo24 is offline  
Old 23 November 2021, 14:27   #4
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 413
Quote:
Originally Posted by jotd View Post
the sprite part of the copperlist is okay (I would have started by a loop to zero all sprites instead of copy paste... or asm REPT instruction )

do you have bitplane registers loaded in your copperlist?

you also need a sprite position table at some point. I suggest you check my Pacman or MsPacman source, it's pretty simple and uses sprites for ghosts without issues.
Thanks for the reply.

Yes, the Bitplane pointers and Palette etc. are in the Copper and are updated when the screen buffers are switched.

I'm only using the sprite for a bit of background dressing, not as a game object, so it just moves from right to left and appears through the transparent sections of the Playfield.
Brick Nash is offline  
Old 23 November 2021, 14:30   #5
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 413
Quote:
Originally Posted by Leo24 View Post
I also can't find any issue with the sprites setup. Supposing the sprite data is 16x16 in 2bpp, VSTART and VSTOP in the control words are set correct.
The issue is probably outside the code you showed.
Thanks for the advice. I think you're right, as I've tried to look for errors within the sprites code but I can't see anything wrong myself. It may be something wrong in the RAW image that I'm using.
Brick Nash is offline  
Old 23 November 2021, 15:41   #6
a/b
Registered User
 
Join Date: Jun 2016
Location: europe
Posts: 1,039
It looks like your raw sprite data already contains control words (look at the first few bytes of hexdump, they should have a distinct pattern, according to the image you posted).
Also, where exactly in the copper list are sprite pointers set, or more specifically how early?
a/b is offline  
Old 23 November 2021, 17:38   #7
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 413
Quote:
Originally Posted by a/b View Post
It looks like your raw sprite data already contains control words (look at the first few bytes of hexdump, they should have a distinct pattern, according to the image you posted).
Also, where exactly in the copper list are sprite pointers set, or more specifically how early?
I never thought of that. I'm using a tool that someone else wrote to covert to RAW, so it may include control words...although I'm not sure why it would bake it in to the file?

I have the Sprite pointers just after the Bitplane Pointers and the Bitplane control registers. I've tried shifting them around to different places in the copperlist but it doesn't seem to make a difference.
Brick Nash is offline  
Old 23 November 2021, 19:19   #8
paraj
Registered User
 
paraj's Avatar
 
Join Date: Feb 2017
Location: Denmark
Posts: 1,113
Quote:
Originally Posted by Brick Nash View Post
I have the Sprite pointers just after the Bitplane Pointers and the Bitplane control registers. I've tried shifting them around to different places in the copperlist but it doesn't seem to make a difference.

Have you placed them before any WAIT instructions? There was a recent post about sprite flicker issues: http://eab.abime.net/showthread.php?t=108629 and it was caused by setting the sprite pointers too late in the frame (which I guess is what A/B is also asking about).


Another thing to check is if you're manipulating DMACON other places and maybe disabling sprite DMA there.
paraj is offline  
Old 23 November 2021, 21:36   #9
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,228
the best thing to do would be to create a simple source file + sprite image reproducing the problem, that anyone can build & check themselves.

Maybe when you do that you find your mistake yourself.
jotd is offline  
Old 25 November 2021, 18:57   #10
Brick Nash
Prototron
 
Brick Nash's Avatar
 
Join Date: Mar 2015
Location: Glasgow, Scotland
Posts: 413
Apologies for the late reply.

Turns out it was a wait instruction after all. The trouble is that it means I've been doing a split screen all wrong - basically using 2 copper lists with a wait in between them at the point of the split (32 lines down). I'll need to do another one which just pokes a single copper at the right times.
Brick Nash 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
Bitmaps to hardware sprites mcgeezer Coders. General 4 08 September 2020 22:00
Sprite hardware vs blitting sprites Nightfox Coders. Asm / Hardware 55 21 May 2020 18:15
AGA Interlaced Hardware Sprites mcgeezer Coders. Asm / Hardware 10 19 April 2020 19:25
Displaying hardware sprites to the left of DDFSTART DanScott Coders. Asm / Hardware 12 10 March 2019 20:37
Sprites Issue sandruzzo Coders. Asm / Hardware 8 01 April 2018 17:43

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 09:08.

Top

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