It is currently Sun Feb 17, 2019 4:30 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Sun Feb 10, 2019 5:33 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 11165
Location: Rio de Janeiro - Brazil
DRW wrote:
tokumaru wrote:
1 object = 1 metasprite, which isn't very flexible

Why is this not flexible? Or rather: Apart from my specific flickering issue, why would flexibility be even an issue here? What exactly can I not do with this setup?

In addition to allowing better flickering of large objects, like you seem to be needing right now, you can use it for decoration (e.g. things a character acquires that don't need separate objects, like a hat), customizable characters (like in Cocoron), or entities that are clusters of things that can move separately (such as the explosion when Mega Man dies).

There's probably a lot more things that can be done that I just can't think of right now, but it's just more versatile. And it's not like implementing this is any hard either: in my engines, each object has an update address (called in an specific order) and a draw address (called in random order each frame). Simple objects that don't need any special handling of metasprites can just point to a generic sprite rendering routine that will process a single metasprites and move on, but complex objects can have specialized routines that can modify the parameters and call the generic rendering routine as many times as necessary, to render multiple metasprites.


Top
 Profile  
 
PostPosted: Mon Feb 11, 2019 1:29 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7664
Location: Chexbres, VD, Switzerland
Is the order of tiles within a metasprite importnat (i.e. do you use sprite layering) ? If not, then you can just blit the sprites out of order.

Instead of doing something like, assuming shadow-OAM is at $200-$2FF
Code:
BlitMetasprite:
  [some calculations here]
BlitMetasprite_loop:
  [some calculations here]
  sta $200,X       ;
  [some calculations here]
  sta $201,X
  [some calculations here]
  sta $202,X
  [some calculations here]
  sta $203,X
  inx
  inx
  inx
  inx
  beq OAM_full
  [some calculations here]
  bne Blit_metasprite_loop
OAM_Full:
  rts


You do something like :

Code:
BlitMetasprite:
  [some calculations here]
BlitMetasprite_loop:
  [some calculations here]
  sta $200,X       ;
  [some calculations here]
  sta $201,X
  [some calculations here]
  sta $202,X
  [some calculations here]
  sta $203,X
  txa
  clc
  adc SpriteSpacingValue
  tax
  beq OAM_full
  [some calculations here]
  bne Blit_metasprite_loop
OAM_Full:
  rts


And SpriteSpacingValue can be any multiple of 4 which is not a multiple of 8, in order to blit the sprites out of order. A good idea is once per frame tie it to the pseudorandom-number generator, shift 3 times and add 4. This assures your sprites will be blitted in random order and makes it close to what Konami is doing in their games, which looks quite good in my opinion. Note that you still blit your metatiles in order, it's just that the individual sprites that are part of them are put in random order in OAM, so that the lower priority individual sprites who disapears are random. Another advantage is that sprite #0 remains always sprite #0, so it doesn't get in the way of sprite zero hit. However you can only use sprite layering if it doesn't rely on priorities (i.e. the non-used layer is "transparent").


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group