| |
Oswald
Registered: Apr 2002 Posts: 5076 |
Sorting
are sorters really so slow in games? :) I have made my unrolled version for my theoretical game (;), and it takes 132 rlines to sort 32 numbers o_O worst case is ~200 lines. tho when its the case of 4 numbers have to be swapped only it does the job in ~10 lines. wastes a lot of memory but I like it :) |
|
... 193 posts hidden. Click here to view all posts.... |
| |
chatGPZ
Registered: Dec 2001 Posts: 11293 |
keep in mind that eg your first "logical" sprite doesnt always have to be the first hardware sprite, it could be any of the 8 hardware sprites in the first bucket. you only have to maintain that if priorities matter (which they often dont in games, since sprites dont overlap) |
| |
doynax Account closed
Registered: Oct 2004 Posts: 212 |
Quote: keep in mind that eg your first "logical" sprite doesnt always have to be the first hardware sprite, it could be any of the 8 hardware sprites in the first bucket. you only have to maintain that if priorities matter (which they often dont in games, since sprites dont overlap)
In fact it's often useful to write them in reverse order to insure reasonably good priorities in top-down games and the like (i.e. so lower sprites overlaps the higher ones).
Another possibility is to "center" the multiplexer in such a way as to insure the priority of a single sprite (i.e. always assign the player to the first sprite). |
| |
Oswald
Registered: Apr 2002 Posts: 5076 |
you might miss sprites otherwise possible to display with the bucket sort.
spr1=70
spr2=74
bucket sort result:
spr2
spr1
then you fire an irq for the next sprite that will be spr2, and already late from spr1 |
| |
doynax Account closed
Registered: Oct 2004 Posts: 212 |
Quote: you might miss sprites otherwise possible to display with the bucket sort.
spr1=70
spr2=74
bucket sort result:
spr2
spr1
then you fire an irq for the next sprite that will be spr2, and already late from spr1
The way I do it is to attach the IRQ to the end of the last use of the new sprite, and thus try to reprogram the "channel" as soon as possible. Then all you have to do is check if you're too late to generate next IRQ (if it is to run before the current scanline) and if so jump straight to the next handler. |
| |
cadaver
Registered: Feb 2002 Posts: 1159 |
If you preprocess the sprite-IRQs, you can take care to always take the upmost Y-coordinate as the basis for the IRQ, even if it isn't the first sprite in sort order. Did this in MW1-3 which had inexact sprite sorting. Brr, never again! :) |
| |
chatGPZ
Registered: Dec 2001 Posts: 11293 |
now you are assuming too much :) ofcourse the displayer code must be written in a way that such thing can not happen. |
| |
Oswald
Registered: Apr 2002 Posts: 5076 |
Quote: If you preprocess the sprite-IRQs, you can take care to always take the upmost Y-coordinate as the basis for the IRQ, even if it isn't the first sprite in sort order. Did this in MW1-3 which had inexact sprite sorting. Brr, never again! :)
what was so bad about it, when you could get it 'right' afterall ? |
| |
Oswald
Registered: Apr 2002 Posts: 5076 |
Quote: The way I do it is to attach the IRQ to the end of the last use of the new sprite, and thus try to reprogram the "channel" as soon as possible. Then all you have to do is check if you're too late to generate next IRQ (if it is to run before the current scanline) and if so jump straight to the next handler.
hmm 'before the new' sprite approach allows more tight packing ;) clever solution nevertheless. |
| |
cadaver
Registered: Feb 2002 Posts: 1159 |
Oswald: well it was never completely "right" in those games, you could create unnecessary artifacts for example when several motorcycles (2x2 sprites) were coming at you and you jumped. But for example, if you have mostly airborne enemies coming at you from several heights and you're mostly on ground, it doesn't matter. |
| |
Oswald
Registered: Apr 2002 Posts: 5076 |
radix sort is a very interesting approach :) offers a constant sort time, but sadly that is much worse than progressive insertion sort. when fully unrolled I estimate a running time of ~55 rasterlines. |
Previous - 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ... | 21 - Next |