spritesort reduces spriteflicker

Page 3/13
1 | 2 | | 4 | 5 | 6 | 7 | 8

By PingPong

Prophet (3459)

PingPong's picture

09-03-2010, 20:23

In a recent msx2 project I tried to do sprite rotation (I mean mine, using the 9th sprite info from the vdp) using the copy engine in the VDP to move color definitions.

In I/O terms, one vdp command costs generally 15 bytes while the color definition is 16 bytes (:-P) but in my case the idea works as I use two sprite layer per object.

In this way the cost of issuing the command is lower than the cost of coping the data (thus 32 bytes of color definition) with the cpu.

A much simpler rotate scheme could move a block of sprites at once, resulting in less commands for vdp, with bigger size.
Just a note: the Sprite color table is 512 bytes in lenght 4 full rows of screen5. Plus is 1024 bytes aligned.

for example if one want to achieve the standard method with ring buffer, each of 8 sprites at once, maybe it's ok to do:

(move planes 0-7 to a tmp buffer. 8 sprites = 128 bytes = 1 scanline)
copy (0,ys)-(255,ys) to (0,ys-1) -> first line in a tmp location (planes 0-7)
copy (0,ys+1)-(255,ys+3) to (0,ys) -> copy from second line to fourth line (planes 8-31) into first line (planes 0-7)
copy (0,ys-1)-(255,ys-1) to (ys+3) -> store tmp to fourth line (planes 23-31)

or better, one can move the first of 4 lines into a fifth one, then move rows 2-5 to rows 1-4
(only two commands)

limitations: you can only rotate at 8 sprites at time. works in screen5/6

By ARTRAG

Enlighted (6275)

ARTRAG's picture

09-03-2010, 21:29

yes, this is correct, but in this way you cannot update the sat, only rotate it

My code builds the actual SAT in VRAM from a shortned version of the SAT stored in ram
While doing this, it sends VDP commands to copy from a large table of color definitions held in VRAM
the actual color definitions on top of the SAT

By PingPong

Prophet (3459)

PingPong's picture

10-03-2010, 20:53

yes, this is correct, but in this way you cannot update the sat, only rotate it

my goal was to only rotate SCT, SAT was rotated by z80, doing command in parallel with vdp work.
However my solution is still more limited, allows for 8 sprites to rotate efficiently.

On msx2 the best way is to turn off sprites that are displayed to allow hidden to be displayed.
But finding a good algo is a problem.....

By hit9918

Prophet (2868)

hit9918's picture

13-03-2010, 00:00

so is the sprite color copy solved? or are there still showstoppers?

when there are two copies, you got to wait for the blitter for the
first copy to finish?

- blitter copy head behind tail
- z80, instead waiting for blitter, update the SAT
- second blitter copy (tail + copied_head) to head address

how much megabyte per second is MSX2 blitter in vblank?

By PingPong

Prophet (3459)

PingPong's picture

13-03-2010, 14:04

so is the sprite color copy solved?
or are there still showstoppers?

not solved in a good way IMHO. i think the best algo is to remove sprites instead of rotating planes....


when there are two copies, you got to wait for the blitter for the
first copy to finish?

z80 does not have to wait for the blitter, even if it's need to output to vram at maximum speed, even with sprites displayed, even in active area. even if one execute a bunch of outi instructions (that are the fastest way to transfer ram to vram)

how much megabyte per second is MSX2 blitter in vblank?

Megabytes? you are dreaming!!!!!! Wink the vdp blitter is barely as fast as the z80 doing an LDIR.

a rectangular block copy can reach about 170 Kb/s (disabling sprites reach to 220Kb/s)

look at this for vdp speed http://map.grauw.nl/articles/vdp_commands_speed.php

the old limitations (built-in the TMS) still are here. Very slow bandwidth. :P:P:P:P:P:P:P

By PingPong

Prophet (3459)

PingPong's picture

14-03-2010, 10:24

Another solution, (only msx2) is here:
on msx2 there is a sprite color table (SCT) placed 512 bytes before the SAT address.
SCT rotation can be done at 8 planes at time, by having 4 SAT tables (with each SCT already rotated by 8 planes). By putting a different address in the VDP register that points the SAT address one can rotate without too much cpu-time. the cpu only need to update the SAT, by rotating it as on msx1.
The drawback is when one need to change the color of the sprite. instead of writing 16 bytes to change a color of the sprite one need to write 4 times the amount, even if it is not needed to do all 4 writes in a single frame or vblk.

A variation is to use only 2 SATs. with a double buffer scheme, one can prepare the not active SAT+SCT in active area then switch on vblank

By hit9918

Prophet (2868)

hit9918's picture

20-03-2010, 13:55

Another solution, (only msx2) is here:
on msx2 there is a sprite color table (SCT) placed 512 bytes before the SAT address.

I tested with vpoke, ouch they only use the low nibble?
they could have used the other nibble for the right 8 pixels.

I suspect back then they had to draw the chips by hand.

By Edwin

Paragon (1182)

Edwin's picture

20-03-2010, 14:51

hit9918> The high nibble is used for per line flags. Bit 5 = collision ignore, bit 6 = color mix, bit 7 = early clock.

By hit9918

Prophet (2868)

hit9918's picture

20-03-2010, 16:12

hit9918> The high nibble is used for per line flags. Bit 5 = collision ignore, bit 6 = color mix, bit 7 = early clock.

"early clock" makes me think that it is a hack retargeting the old color byte in the SAT.
So 16 bits need to be set to move the sprite into the left border?

collision ignore: I cant see use of collision features with flicker engines?

color mix: can it modify the color of another sprite?

By Edwin

Paragon (1182)

Edwin's picture

20-03-2010, 16:24

Yep, indeed necessary to change all 16 bits to move into the left border. Collision ignore takes the line out of sprite collision detection. But since you almost always need to manually check what collides with what, it's still not particularly useful. The color mix bit is useful since it ORs the sprite color with the next higher priority sprite(s). Of course it would still have been much more useful if it was tied to patterns instead of SAT entries.

Page 3/13
1 | 2 | | 4 | 5 | 6 | 7 | 8