Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Sprite multiplexing *with* priorities
2009-01-24 14:40
Bregalad
Account closed

Registered: Jul 2008
Posts: 42
Sprite multiplexing *with* priorities

I'm willing to port a game on the C64 but for sure I'll need more than 8 sprites per screen. The game uses a top-down perspective so sprites that are southern on the screen must show above the sprites that are nothern, else it will look weird.
Unfortunately, most sprite multiplexing tehniques I've seen arround the net seems to kill any priorities, and that's not good.

I guess I can come up with a solution, but I'm not sure how good it is :
- The screen is sepearated into 10 areas of 20 pixel tall
- There is a raster interrupt each 20 pixels that will handle the multiplexing, and the interrupt at line 250 will also be used for the other usual stuff (screen updates, sound code, etc...)
- Each sprite always crosses 2 areas no matter where they are positionned (this assumes Y expanding is never used)

Now during the frame :
In the first area (lines 0-20), the sprites are mapped to hardware sprites with regards to their sorted priorities. If there is more than 8 then the lowest pirority is discarded.

In the second area, the sprites that were already used in the first area cannot be used, so I map the sprites that are still unused to the sprites starting in the second area, regarding to their priorities.

In the third area, all sprites that were used in the first are done being displayed and I can re-map them to sprites of the third area according to their priorities, etc....

Now the priorities are not matched between areas, but at least they are inside each area. Also the number of interrupts is constant, and everything can be pre-calculed during the non-display time, so that interrupts just do a few writes each 20 scanlines which is not too bothersome and allow it to be mixed with other raster split without too much trouble.

I know Cadavers said it was a bad idea to split the screen with areas, but I can't come with anything else. I could use the generic method in a way so that top sprites are lowest priorities than bottom sprites, and hoping it won't look too weird.
 
... 61 posts hidden. Click here to view all posts....
 
2009-02-05 13:09
Oswald

Registered: Apr 2002
Posts: 5094
well, if he has the enemys coming not totally randomly he ofcourse can gain a lot with realtime spritemirroring with generating the phases for the upcoming attacks. another possibility to save vic bank memory is to have only 1-2 buffer sprites for the main character, and copy its animation frames there from another place for each frame.
2009-02-05 14:28
Jetboy

Registered: Jul 2006
Posts: 337
Quote: well, if he has the enemys coming not totally randomly he ofcourse can gain a lot with realtime spritemirroring with generating the phases for the upcoming attacks. another possibility to save vic bank memory is to have only 1-2 buffer sprites for the main character, and copy its animation frames there from another place for each frame.

Copying one sprite data is over 9 full rasterlines. IMHO should be avoided if possible.

@Bregalad: how many sprite cells do you need for your character? How many for enemies per level? there is 16 explosions, right?

What game are you trying to port? It might be easier to give us hints if we know what do you want to do exactly.
2009-02-05 15:02
Bregalad
Account closed

Registered: Jul 2008
Posts: 42
I'm planning to port a NES game I'm making (that is not finished yet, but the engine is finished and fully fuctionnal).
I know the graphics will have to be a little worsened to fit the C64's limitations. I normally can deal with 207 separate sprites loaded at a time, which is not bad (the NES can have 256, but they are 8x8 instead of 24x21 which is VERY different), and I have to half that number because of the mirroring issue.

I can have up to 8 enemies, 1 player and 8 exlosions at a time, but normally there is rarely so much. Many enemies are originally 16x16 or 16x24 pixels large, but this will have to change on the C64. Either I will squeeze the same graphics removing 4 columns so that they fit respectively 1 or 2 multicolor sprites, or I will keep the pixel art intact and make them looks stretched horizontally, and be 2/4 multicolor sprites. Or I could stack up hires sprites, but they would look tiny and that would do too many sprites.

The player is 16x26 pixels on the NES version so I'll either squeeze it in 2 multicolor sprites (degrading pixel art) or enlarge it to use 4 (will look streched and a big part of the sprites will be empty). At any rate, I'll see how many sprites it takes up, and if I have not enough space I could rewrite the player's sprite each time it changes (not every frame), and have all other sprites pre-loaded, this should work fine, since the players typically takes up a LOT of sprites.
2009-02-05 15:16
Jetboy

Registered: Jul 2006
Posts: 337
You could also try using hires sprites over multicolor sprites. You can get quite nice effects with that, but you would have to repaint all the sprites for that mode, and effectively you would have only 4 sprites.

Main hero in this game is using that thing, enemies are normal multicolor sprites: http://www.lemon64.com/?game_id=560
2009-02-05 15:16
Oswald

Registered: Apr 2002
Posts: 5094
Quote: Copying one sprite data is over 9 full rasterlines. IMHO should be avoided if possible.

@Bregalad: how many sprite cells do you need for your character? How many for enemies per level? there is 16 explosions, right?

What game are you trying to port? It might be easier to give us hints if we know what do you want to do exactly.


9 rasterlines is not much if you need to squeeze in more sprite data.
2009-02-05 15:28
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
Quote: You could also try using hires sprites over multicolor sprites. You can get quite nice effects with that, but you would have to repaint all the sprites for that mode, and effectively you would have only 4 sprites.

Main hero in this game is using that thing, enemies are normal multicolor sprites: http://www.lemon64.com/?game_id=560


Were you thinking of Mayhem in monsterland perhaps?
http://www.lemon64.com/?game_id=560
2009-02-05 17:59
Playboy

Registered: Feb 2005
Posts: 20
Quote: Were you thinking of Mayhem in monsterland perhaps?
http://www.lemon64.com/?game_id=560


He meant this link:

http://www.lemon64.com/games/details.php?ID=1625[/url]

2009-02-05 22:45
Bregalad
Account closed

Registered: Jul 2008
Posts: 42
Quote:
This code is bigger than the data for a sprite anyway and would be required to be duplicated for each sprite since the adresses are hard coded. Perhaps you meant to use something like lda (source_zp),y instead? I have to agree with others here, that you seem to underestimate how slow the C64 really is, assuming that you are supposed to do this stuff at the same time as a lot of other game logic and graphics stuff is running.

I don't want to dublicate one sprite, but almost all enemy sprites. And you could use self-modifying code to modify the arguement of lda $xxxx,X to simulate indirect adressing.
Quote:

well, if he has the enemys coming not totally randomly he ofcourse can gain a lot with realtime spritemirroring with generating the phases for the upcoming attacks. another possibility to save vic bank memory is to have only 1-2 buffer sprites for the main character, and copy its animation frames there from another place for each frame.

Yeah for the main charater this sounds a good idea. Too bad I don't know how much sprite it will do.

I don't think stretching the artwork from 16 pixel wide to 12 "multicolor-dash-pixels" would look very well, unless I can somehow make it looks good. Preserving the pixel art would be a good thing, but I can only stack up 3 hires sprites (won't look wide enough), or make multicolour sprites that are wider (will look too wide). In either case, it will become a waste, 8 pixel used in sprites that allow 12. On the good side this could speed the inversion up and make less graphics to load as the third byte would alway be zero...

Almost all characters have black outlines, it would be an idea to make the black outline hires and the colored stuff multi-color, and if the pixels of the colored stuff are slighly off it really shouldn't matter. Also since the borders are almost alway black outlines I could cheat a little with that. I guess I have to try different things and see how well it works.
2009-02-06 10:11
Jetboy

Registered: Jul 2006
Posts: 337
Quote:
I don't want to dublicate one sprite, but almost all enemy sprites. And you could use self-modifying code to modify the arguement of lda $xxxx,X to simulate indirect adressing.


If there is 8 sprites and a hero using 2 sprites, and it happens that you need to flip them all at once, it would take 9*10 = 90 raster lines, that not counting code to modyfy flipping routine. You need a few interupts going, doing sorting, sprite multiplexing, playing music and running game logic. Are you sure there will be enough cycles left to do that all?

As for sprite graphics - i think the best way would be to repaint them for c64 with c64 restrictions in mind. Any other method would make them look bad.

You told us how do you intent to convert data, but my question was how many cells of animation you have for enemies and hero. And how many different enemies will there be per level?
2009-02-06 10:40
Bregalad
Account closed

Registered: Jul 2008
Posts: 42
Quote:

As for sprite graphics - i think the best way would be to repaint them for c64 with c64 restrictions in mind. Any other method would make them look bad.

Yes you are entierely right. I'll do that, it would look bad to have a lot of sprites that aren't entierely filled. Altough in some way I'd still have to "port" the graphics at some point. Too bad so many graphics editor are for the 64 and not for a modern PC, and that many PC graphic editor does not allow 64 multicolor format (or use full-screen bitmapped-FLI stuff). Hires 1BP format is no match, but not very practical for in-game use.
Quote:

If there is 8 sprites and a hero using 2 sprites, and it happens that you need to flip them all at once, it would take 9*10 = 90 raster lines, that not counting code to modyfy flipping routine. You need a few interupts going, doing sorting, sprite multiplexing, playing music and running game logic. Are you sure there will be enough cycles left to do that all?

Well, I said only the hero's sprite would be rewritten in real time, so that's only 2 or 3 sprite, that wouldn't even be rewritten every frame. Enemy's sprite should be pre-loaded and flipped by software before the level begin (not in real time). That way I don't store the graphics twice, but this doesn't slow anything down.
I guess there would be about 4-6 different enemies per level, altough I haven't put a definite number on that.

Some palette swapping to get more different enemies is planned too.
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
BYB/Hokuto Force
Chesser/Blazon
Da Snake
Rub_0201
Fred/Channel 4
Paul Bearer
blitzed
DivertigO
t0m3000/hf^boom!^ibx
megasoftargentina
Guests online: 134
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Musicians
1 Rob Hubbard  (9.7)
2 Mutetus  (9.7)
3 Jeroen Tel  (9.7)
4 Linus  (9.6)
5 Stinsen  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.166 sec.