English Amiga Board


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

 
 
Thread Tools
Old 06 August 2021, 10:38   #1
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
Multiplexing sprites By changing pointers

I'm trying to change sprite pointers, after they are displayed on screen, in order to multiplex them and have more flexibility and waste less memory.

I'm doing something like this, but nothing is happening:

Sprite1: (first sprite pointers)
dc.w $0130,$0000
dc.w $0132,$0000
dc.w $0134,$0000
dc.w $0136,$0000
dc.w $cb01,$fffe ; copper wait
Sprite2: (second sprite pointers)
dc.w $0130,$0000
dc.w $0132,$0000
dc.w $0134,$0000
dc.w $0136,$0000

My "second '' sprite is placed at $cc y position, just right one line after copper wait. Should I take care of something else?
sandruzzo is offline  
Old 06 August 2021, 11:25   #2
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Yes, you should take care of SPRxPOS/SPRxCTL SV and EV bits.

You are thinking of sprite pointers as if they were bitplane pointers.
As for bitplanes there are DIW start/stop registers for the DMA, same for sprites are the SV and EV y-coordinates.

So for the DMA to be active and the data to be fetched where you set the pointers, you must be inside the 'window' defined by those bits.
ross is offline  
Old 06 August 2021, 15:12   #3
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
So if I set the first two sprites as sprite1+sprite2 height, it should work? Now My sprites are 6 pixel Height, and they should be 12 pixel, isnt?
sandruzzo is offline  
Old 06 August 2021, 15:19   #4
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Yes, if the sprites are consecutive.

Of course if there is a gap between them you have to point to a zeroed memory area (during the gap, and increase the height), or disable the DMA for a this period.
Also you have to set SPRxPOS and SPRxCTL registers before the first y sprite position (but this is obvious ) [the DMA does this automatically on PAL line $19]
ross is offline  
Old 06 August 2021, 15:21   #5
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
SPRxPoS and SPRxCTL must be set outside the sprite structure, so copper must do it: Do I get it right? I'm using two different sprites, not the same ones
sandruzzo is offline  
Old 06 August 2021, 15:27   #6
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Yes, you could set it manually by copper after line $19.
Basically SV should be first_line of first sprite, EV last_line+1 of second sprite.

Remember to set the sprites DMA bit and to set the pointers of the unused sprites to a zeroed area.
ross is offline  
Old 06 August 2021, 15:32   #7
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Quote:
Originally Posted by sandruzzo View Post
I'm using two different sprites, not the same ones
This is not clear..

Do you mean two different shape for the same sprite number or two totally different sprite number?
Because if it's the second case what you want to do doesn't make much sense..
ross is offline  
Old 06 August 2021, 15:33   #8
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
Somenthig like that:

Sprite1: (first sprite pointers)
dc.w $0130,$0000
dc.w $0132,$0000
dc.w $0134,$0000
dc.w $0136,$0000
dc.w $0160 $0000 SPR4POS
dc.w $0162 $0000 SPR4CTL
dc.w $0168 $0000 SPR5POS
dc.w $016A $0000 SPR5CTL
dc.w $cb01,$fffe ; copper wait
Sprite2: (second sprite pointers)
dc.w $0130,$0000
dc.w $0132,$0000
dc.w $0134,$0000
dc.w $0136,$0000
dc.w $0160 $0000 SPR4POS
dc.w $0162 $0000 SPR4CTL
dc.w $0168 $0000 SPR5POS
dc.w $016A $0000 SPR5CTL

BTW, My sprites aren't consecutive
sandruzzo is offline  
Old 06 August 2021, 15:34   #9
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
Quote:
Originally Posted by ross View Post
This is not clear..

Do you mean two different shape for the same sprite number or two totally different sprite number?
Because if it's the second case what you want to do doesn't make much sense..
Sorry, different shapes. I'm using two different shapes, so i thought That would not be necessary to change POS AND CTL INTO copper list
sandruzzo is offline  
Old 06 August 2021, 15:42   #10
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Follow the rules I told you and you will see that it will work

You just have to pay attention to the values present in EV because it is the line in which the DMA automatically retrieves the values for the new values of SPRxPOS/CTL (for the auto-y-multiplex).
Then make sure that the sprites whose pointers you change are inside the SV/EV 'window'.
ross is offline  
Old 06 August 2021, 15:52   #11
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
Thanks ross.

I'm think about this: by setting SPRxPOS/CTL of the second sprites into the structure of the first sprites, and then let the sprites pointers pointo to the actuall dat of the second sprites, will work, like this:

SpriteData1
$0000,0000 ;POS,CTL first sprite
$ffff,$ffff ; sprite datas
.....,......
$0000,0000 ; POS CTL of multiplexed sprites


SpriteData2:
$ffff,$ffff ; actual data
....,......
$0000,$0000 ; end sprites
sandruzzo is offline  
Old 06 August 2021, 16:37   #12
ross
Defendit numerus
 
ross's Avatar
 
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
Yes, this is a good way, because DMA 'work for you' to fetch sprite positions
(and you don't waste DMA cycles because in idle mode between the two positions).
ross is offline  
Old 06 August 2021, 21:04   #13
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
Very good. Maybe I can multiplex it many times, since I need it. Is it better to set copper wait one line before, or the exact same line, as "new" sprites?
sandruzzo is offline  
Old 06 August 2021, 21:17   #14
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
It seems to work. But sprites height work with regular size: 8 pixel instead 16!

Red box is multiplexed!




I'm gonna try to multiplex it many more times
sandruzzo is offline  
Old 07 August 2021, 04:01   #15
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
It definitely works! With this way you can save 4 copper moves for each sprite (8 if you attach them), but you need more ram for sprites, since every instance must be unique. Faster but ram expensive.

Another way to do sprites magic on Amiga!

Red boxes are multiplexed!

sandruzzo is offline  
Old 07 August 2021, 15:08   #16
Antiriad_UK
OCS forever!
 
Antiriad_UK's Avatar
 
Join Date: Mar 2019
Location: Birmingham, UK
Posts: 418
This is what I do in Planet Disco Balls end scene. It’s one big sprite list and then the sprite data is animated and blitted into the list. (Video and source in sig)
Antiriad_UK is offline  
Old 07 August 2021, 16:16   #17
sandruzzo
Registered User
 
Join Date: Feb 2011
Location: Italy/Rome
Posts: 2,281
No blitting here. Just changing sprites' pointers
sandruzzo is offline  
Old 26 August 2021, 18:51   #18
Photon
Moderator
 
Photon's Avatar
 
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
The Amiga sprite engine really is powerful, and there are probably more than half a dozen different ways of multiplexing sprites. They really aren't used much though, but soo nice to play with. And I think a used sprite is a happy sprite. [ Show youtube player ]
Photon 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
Sprite multiplexing on Amiga majikeyric Coders. General 51 27 April 2023 11:06
Copper changing sprite pointers Muzza Coders. General 7 30 July 2021 13:58
Multiplexing Using Vsprites Code Havie Coders. Blitz Basic 23 08 September 2019 21:37
Sprite multiplexing & copper bars? E-Penguin Coders. Blitz Basic 6 22 December 2018 17:07
2 Mouse Pointers!!! wandeep support.WinUAE 3 21 May 2008 13:44

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

Top

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