News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Cwiiis

When *shouldn't* you upload sprite data on the Plus?

Started by Cwiiis, 18:25, 11 October 22

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Cwiiis

In a game I'm working on, the player sprite is animated dynamically - I upload it over several frames on-demand (oh if only the Plus hardware sprites let you set vram addresses rather than each pointing to specific vram...) This has generally worked ok, but every now and again I get some unexpected junk in the sprite.

After a recent spate of optimising, this is happening much more frequently than it used to, to the point where I can't just fiddle with a bunch of nops to avoid it. I mean, maybe I could, but I'd rather understand what's happening than paper over it.

So does anyone know when it is and isn't ok to upload sprite data? Note, I'm never uploading data to sprites that are enabled (i.e. scale is set to zero on the sprite that is being uploaded).

Cwiiis

Of course I find an acceptable work-around immediately after posting... If I do my sprite upload almost immediately after a vsync, everything seems to be fine - it seems doing it towards the end of a frame has issues... I don't really know why this is though (this is all on real hardware)

andycadley

It's ok to do it any time, although the sprite will be disabled while you do which can cause on screen flickering. If you're seeing actual corruption of the data, most likely your interrupt routine is messing something up. Or you've discovered another incompatibility with third party memory expansions. Or another bug in the Plus hardware.   :laugh:

dthrone

If no data corruption, flickering on real hardware but NO flickering on emulator then very likely you're writing the sprite whilst parts are being drawn like Andy mentions.
SOH Digital Entertainments

Cwiiis

So this is data corruption, not flickering - I've not tried in an emulator yet, I suppose I should revert the fix and give it a go. I suspected interrupts, but the issue happens with interrupts disabled... (Some of) The data is in the ASIC register region though (they're unmapped, the data is copied to a buffer, then decompressed from there), so perhaps there's some oddness with mapping/unmapping at certain times... Note, the data isn't actually corrupted in storage, the result varies with timing.

andycadley

Odd. Can't think of a reason why (assuming the buffer isn't in the ASIC region and you don't page it in while reading from it).

It's not impossible that it's a Plus bug, but I'd be surprised if nobody has encountered it before. Feel free to share code if more eyeballs on it might help.

Nemo59

Quote from: Cwiiis on 18:25, 11 October 22Note, I'm never uploading data to sprites that are enabled (i.e. scale is set to zero on the sprite that is being uploaded).
Hi. And what happens without this constraint that you impose on yourself?
CPC 6128+ / CPM+/ Turbo PASCAL v3
https://cpcrulez.fr/auteur-nemo59.htm

Cwiiis

Quote from: Nemo59 on 00:28, 31 October 22
Quote from: Cwiiis on 18:25, 11 October 22Note, I'm never uploading data to sprites that are enabled (i.e. scale is set to zero on the sprite that is being uploaded).
Hi. And what happens without this constraint that you impose on yourself?
It works fine, just you see the update - I'll need to test further at some point, if there's an issue here, I expect it's to do with where I'm keeping the data.

roudoudou

there is 2 side FX to upload data or (change settings!)

you can have tearing when you change data during the lines where the sprite is displayed
you can have transparency when you change data during the very display of the sprite


Powered by SMFPacks Menu Editor Mod