Author Topic: How do plus hardware sprites work?  (Read 1443 times)

0 Members and 1 Guest are viewing this topic.

Offline zhulien

  • 6128 Plus
  • ******
  • Posts: 921
  • Country: au
  • aka Vorax
    • 8bitology
    • Awards
How do plus hardware sprites work?
« on: 13:59, 22 August 21 »
Hi


I am curious to know how plus hardware sprites work.


I know they are memory mapped likely inside memory contained within ASIC.


Upon a screen refresh of normal video memory what is the order of hardware operations that occur for hawdware sprites to render?


Are they rendered in frame? Within the scanline? Is the memory mapped ram read even if a hardware sprite is at a particular overlapping pixel?


Can plus hardware sprites be multiplexed? Has anyone worked out the per scan line limitations or timings to multiplex?


Thanks
like
0
No reactions

Offline roudoudou

  • 6128 Plus
  • ******
  • Posts: 1.156
  • Country: fr
    • urban exploration
    • Awards
Re: How do plus hardware sprites work?
« Reply #1 on: 14:08, 22 August 21 »
you may change sprite data/coordinates anytime, even during display of it (some side effects)
there is almost instant refresh of all sprites, you may display the same sprite many times on a single line if you want (but this will be very time consuming)
sprite data is always from Asic RAM
like
0
No reactions
use RASM, the best assembler ever made :p

I will survive

Offline Shining

  • Supporter
  • 464 Plus
  • *
  • Posts: 320
  • Country: de
    • Shinings little CPC page
    • Awards
Re: How do plus hardware sprites work?
« Reply #2 on: 14:13, 22 August 21 »
Yes, as roudoudou says. Also you can, like with the normal display, change the sprite palette during the screen is painted.
Like in the beer part in my schnapps demo. There the sprites are reused at the bottom with a different palette.
Also you can use a different sprite-zoom-factor for the multiplexed sprites.
like
0
No reactions
TGS is back

Download my productions at:
cpc.scifinet.org

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.024
    • Awards
Re: How do plus hardware sprites work?
« Reply #3 on: 14:58, 22 August 21 »
Yes, the normal video operations occur exactly as if the sprites weren't present. The ASIC internally decides if a pixel is obscured by a hardware sprite and, if so, changes the colour pixel being output.


You can certainly multiplex them and even chop them up by moving them during the part of the screen where they would be displayed. Iirc changing a sprites registers temporarily turns it off during the write, but it's probably in the Arnold V documentation. Multiplexing isn't enormously useful, as it is on say the C64, because you still need to write a new image into the ASIC registers and that's not as quick as one would like.
like
0
No reactions

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.426
  • Country: fr
    • Awards
Re: How do plus hardware sprites work?
« Reply #4 on: 15:29, 22 August 21 »
Multiplexing isn't enormously useful

Mmmh, I don't know anything the Plus, but I guess multiplexing is how @norecess displays the many rings in Sonic GX. So multiplexing shouldn't be dismissed lightly :).
like
0
No reactions
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 4.076
  • Country: fr
    • ?area=showdonations;u=4
    • Awards
Re: How do plus hardware sprites work?
« Reply #5 on: 15:43, 22 August 21 »
Multiplexing isn't enormously useful, as it is on say the C64, because you still need to write a new image into the ASIC registers and that's not as quick as one would like.
Multiplexed sprites are useful and used (arcade and consoles) to draw weapon bullets, snow layers, common ennemies, ...

@Targhan Yes, it allows to display up to 40 rings !!!
« Last Edit: 15:55, 22 August 21 by TotO »
like
0
No reactions
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.024
    • Awards
Re: How do plus hardware sprites work?
« Reply #6 on: 16:23, 22 August 21 »
Multiplexed sprites are useful and used (arcade and consoles) to draw weapon bullets, snow layers, common ennemies, ...

@Targhan Yes, it allows to display up to 40 rings !!!
I meant very specifically in the case of the Plus hardware. On other machines it's obviously enormously useful, but most other machines making swapping a sprites visual representation very fast, whereas on a Plus you have to write 256 bytes to do it.
like
0
No reactions

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.024
    • Awards
Re: How do plus hardware sprites work?
« Reply #7 on: 16:27, 22 August 21 »
Mmmh, I don't know anything the Plus, but I guess multiplexing is how @norecess displays the many rings in Sonic GX. So multiplexing shouldn't be dismissed lightly :) .
The specific case of displaying many rings, where all the multiplexed sprites look the same is one of the cases where you can more easily bend the hardware to do what you want.


On a C64, for example, though you might use the same sprite for the top and bottom half of a play character which is nigh on impossible on the Plus hardware (unless you have insanely precise timing)
like
0
No reactions

Offline TotO

  • 6128 Plus
  • ******
  • Posts: 4.076
  • Country: fr
    • ?area=showdonations;u=4
    • Awards
Re: How do plus hardware sprites work?
« Reply #8 on: 16:27, 22 August 21 »
The multiplexing is not related to the sprite data update. So, if your game already update the sprites (not at the same frame) to make something animated, instead of displaying one, you are displaying more.
like
0
No reactions
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Offline Targhan

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.426
  • Country: fr
    • Awards
Re: How do plus hardware sprites work?
« Reply #9 on: 16:43, 22 August 21 »
I meant very specifically in the case of the Plus hardware.
The Plus might be limited compared to other hardware, but imagine a shooter with many, many, sprites, thanks to multiplexing (bullets, or enemies). So, one must not think about the weakness, but how the feature can be used in an awesome way.
like
0
No reactions
Targhan/Arkos

Arkos Tracker 2.0.1 now released! - Follow the news on Twitter!
Disark - A cross-platform Z80 disassembler/source converter
FDC Tool 1.1 - Read Amsdos files without the system

Imperial Mahjong
Orion Prime

Offline zhulien

  • 6128 Plus
  • ******
  • Posts: 921
  • Country: au
  • aka Vorax
    • 8bitology
    • Awards
Re: How do plus hardware sprites work?
« Reply #10 on: 17:02, 22 August 21 »
I was actually thinking if a game like Recca for NES could be possible on a plus.  I guess for waves of the same enemies that should work well. And if animations are kept sparingly we may only need to update actual sprite data between waves.
like
0
No reactions

Offline roudoudou

  • 6128 Plus
  • ******
  • Posts: 1.156
  • Country: fr
    • urban exploration
    • Awards
Re: How do plus hardware sprites work?
« Reply #11 on: 18:31, 22 August 21 »
whereas on a Plus you have to write 256 bytes to do it.
this is the worst case, not a rule  ;D
like
0
No reactions
use RASM, the best assembler ever made :p

I will survive

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.024
    • Awards
Re: How do plus hardware sprites work?
« Reply #12 on: 18:49, 22 August 21 »
The Plus might be limited compared to other hardware, but imagine a shooter with many, many, sprites, thanks to multiplexing (bullets, or enemies). So, one must not think about the weakness, but how the feature can be used in an awesome way.
I'm a massive fan of the Plus hardware, I certainly think it has enormous scope for achieving things beyond how far it has been pushed so far. I'm also quite willing to admit it has some weaknesses compared to other machines (those the tradeoffs aren't all one way, the advantage to having the sprites defined the way they are on the Plus is that there aren't sprite-on-a-line limitations like there are on other machines for example)


If you can find a way to make multiplexed sprites work in your game then definitely go for it, but even if you can't it certainly doesn't make them useless either.
like
0
No reactions

Offline roudoudou

  • 6128 Plus
  • ******
  • Posts: 1.156
  • Country: fr
    • urban exploration
    • Awards
Re: How do plus hardware sprites work?
« Reply #13 on: 19:17, 22 August 21 »
If you can find a way to make multiplexed sprites work in your game then definitely go for it, but even if you can't it certainly doesn't make them useless either.
maybe you miss this tech-demo with 3 sprites for bullets...
https://www.cpc-power.com/index.php?page=detail&num=17425

like
0
No reactions
use RASM, the best assembler ever made :p

I will survive

Offline andycadley

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.024
    • Awards
Re: How do plus hardware sprites work?
« Reply #14 on: 19:50, 22 August 21 »
maybe you miss this tech-demo with 3 sprites for bullets...
https://www.cpc-power.com/index.php?page=detail&num=17425



I'd not seen that particular one, but I had my own multiplexer that would attempt to juggle sprites around so they could be reused for a shoot em up that never went anywhere.


The trick was having enemies use different animation frames so that all the frames would be "in use" at the same time you'd just cycle which ones were assigned to which enemies. And occasionally drop frames on a cyclic basis (like a lot of GB sprite engines) so if the screen got too busy everything would still work but a flicker slightly.
like
0
No reactions

Offline zhulien

  • 6128 Plus
  • ******
  • Posts: 921
  • Country: au
  • aka Vorax
    • 8bitology
    • Awards
Re: How do plus hardware sprites work?
« Reply #15 on: 02:10, 23 August 21 »
The trick was having enemies use different animation frames so that all the frames would be "in use" at the same time you'd just cycle which ones were assigned to which enemies. And occasionally drop frames on a cyclic basis (like a lot of GB sprite engines) so if the screen got too busy everything would still work but a flicker slightly.


Actually that is a great idea that I didn't see before applying to hardware sprites (software sprites would be the norm).  Imagine each spaceship having 3 frames of animation, moving forward, bank left/bank right.  instead of updating the sprite data, re-assign the frame from the bank of available sprites that can be multiplexed. 
« Last Edit: 02:12, 23 August 21 by zhulien »
like
0
No reactions

Offline zhulien

  • 6128 Plus
  • ******
  • Posts: 921
  • Country: au
  • aka Vorax
    • 8bitology
    • Awards
Re: How do plus hardware sprites work?
« Reply #16 on: 02:11, 23 August 21 »
maybe you miss this tech-demo with 3 sprites for bullets...
https://www.cpc-power.com/index.php?page=detail&num=17425



Is there a downloadable version of that demo somewhere? or perhaps youtube video?
like
0
No reactions

Offline roudoudou

  • 6128 Plus
  • ******
  • Posts: 1.156
  • Country: fr
    • urban exploration
    • Awards
Re: How do plus hardware sprites work?
« Reply #17 on: 08:58, 23 August 21 »

Is there a downloadable version of that demo somewhere? or perhaps youtube video?
the message you quoted contains a link  :laugh:
like
0
No reactions
use RASM, the best assembler ever made :p

I will survive

Offline norecess

  • CPC6128
  • ****
  • Posts: 279
  • Country: ca
    • Awards
Re: How do plus hardware sprites work?
« Reply #18 on: 15:58, 23 August 21 »
Upon a screen refresh of normal video memory what is the order of hardware operations that occur for hawdware sprites to render?
Are they rendered in frame? Within the scanline?
Scanline.
Like @roudoudou mentioned, hardware sprites "follows" the canon beam (like a typical "raster"). At each iterations, the ASIC sprite coordinates / properties / etc and reevaluated, so you can make funny things like multiplexing (change X/Y positions, scaling, etc).

Is the memory mapped ram read even if a hardware sprite is at a particular overlapping pixel?
Yes. The overlapping is defined by sprite order, cf. Sprite0 will overlap Sprite1, that will overlap Sprite2, etc etc. The pen0 is used for transparency, so a sprite can use pen1-15.
There is an issue with memory writes. If you update the sprite's content while it's being rendered, some white artifacts can appear, because the ASIC is busy writing so it can't read the value back. So you are better to update a sprite before it's being rendered.
Also, please note that memory location is fixed. Unlike the C64 where you define which memory location is used for a sprite, the ASIC uses #4000 for Sprite0, #4100 for Sprite1, etc. This is a severe limitation because it implies developer must update the sprite's content or switch to another sprite to do animation. While the sprite's data is 256-bytes large in memory, of course the trick here is to update only the bytes that changed.. updating sprites on a 25hz basis instead of 50hz is also another workaround.

Can plus hardware sprites be multiplexed? Has anyone worked out the per scan line limitations or timings to multiplex?
Yes for multiplex. Weirdly, this was not exploited during the commercial existence of the GX-4000... the tech-demo from @Overflow referenced above with all those bullets displayed on screen is the best example that comes to me. SonicGX also makes uses of sprite multiplexing to display rings.
Note that sprite positions are based on "Mode 2 sprite pixels", which means X value can be > 255, so it's 2 bytes to update. When you start playing with sprites being dynamically re-positioned during the frame display, updating 3 bytes (2 for X, 1 for Y) on a scanline basis starts to become loud to manage. So here again, there are different strategies to ease the process (avoid to update all values at the same time, etc).

--
Now going further... I would like to point things that really sucks with the ASIC sprites (when compared to traditional consoles):
- inability to define a memory location
- inability to mirror / vertical flip a sprite

But, the ASIC features 16 (SIXTEEN !) hardware sprites, which is pretty great when compared to the C64's 8 hardware sprites.
« Last Edit: 16:00, 23 August 21 by norecess »
like
0
No reactions

Offline roudoudou

  • 6128 Plus
  • ******
  • Posts: 1.156
  • Country: fr
    • urban exploration
    • Awards
Re: How do plus hardware sprites work?
« Reply #19 on: 16:14, 23 August 21 »
Yes for multiplex. Weirdly, this was not exploited during the commercial existence of the GX-4000...
waaaaaaaaaaaaaaaaaaaaaaat?

 :P
like
0
No reactions
use RASM, the best assembler ever made :p

I will survive

Offline dthrone

  • CPC6128
  • ****
  • Posts: 220
  • Country: gb
    • SOHDE
    • Awards
Re: How do plus hardware sprites work?
« Reply #20 on: 16:52, 23 August 21 »
There is an issue with memory writes. If you update the sprite's content while it's being rendered, some white artifacts can appear, because the ASIC is busy writing so it can't read the value back.


I see this issue on real GX but not in Winape so I don't think this effect is included in the emulation.  Are any plus emulators taking this into account?
like
0
No reactions

Offline zhulien

  • 6128 Plus
  • ******
  • Posts: 921
  • Country: au
  • aka Vorax
    • 8bitology
    • Awards
Re: How do plus hardware sprites work?
« Reply #21 on: 18:01, 23 August 21 »
waaaaaaaaaaaaaaaaaaaaaaat?

 :P


The trees?
like
0
No reactions

Offline norecess

  • CPC6128
  • ****
  • Posts: 279
  • Country: ca
    • Awards
Re: How do plus hardware sprites work?
« Reply #22 on: 18:20, 23 August 21 »
@roudoudou I was curious so I checked :) (see attached screenshot). I always thought there was no sprite multiplexing in that screen. But now I see you are right :) Elmar stored 2 entire palms (to get the 2 trees at same level) and yes indeed make use of multiplexing. Good catch !

like
0
No reactions

Offline Optimus

  • 464 Plus
  • *****
  • Posts: 374
  • Country: gr
    • Awards
Re: How do plus hardware sprites work?
« Reply #23 on: 18:39, 23 August 21 »
I always thought "sprite multiplexing" means to draw more than the theoritical max on the screen by changing the sprite positions at certain rasterlines. I thought that was the main definition even on C64. I know the C64 can change the address or something while the CPC+ uses the same sprite, but I never thought that as the definition of multiplexing so like when I read on the wiki. Even with just changing positions and other stuff it's still very powerful.
like
0
No reactions

Offline zhulien

  • 6128 Plus
  • ******
  • Posts: 921
  • Country: au
  • aka Vorax
    • 8bitology
    • Awards
Re: How do plus hardware sprites work?
« Reply #24 on: 18:57, 23 August 21 »
Sprites 8 to 15 are all the same, i am guessing it was just faster to process than multiplex the 1 sprite all the way down the trunk? or... that is the limit of trees display on a horizontal?
like
0
No reactions