Get sprite position/tile/palette etc.

SGDK only sub forum

Moderator: Stef

Post Reply
Xynxyn
Very interested
Posts: 54
Joined: Fri Jun 15, 2012 10:32 am
Location: Poland

Get sprite position/tile/palette etc.

Post by Xynxyn » Sat Aug 10, 2013 12:31 pm

Is there any function in SGDK that allows to directly get (for example) position of sprite?

Moon-Watcher
Very interested
Posts: 117
Joined: Sun Jan 02, 2011 9:14 pm
Contact:

Post by Moon-Watcher » Sun Aug 11, 2013 11:56 am

You can use spriteDefCache array to get sprite data

Xynxyn
Very interested
Posts: 54
Joined: Fri Jun 15, 2012 10:32 am
Location: Poland

Post by Xynxyn » Sun Aug 11, 2013 12:21 pm

But I want to get it directly from VRAM. ;| (Sorry, I forgot to write it)

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Sun Aug 11, 2013 1:47 pm

VRAM reads are slow and can cause issues with mixed writes if you aren't careful. Reading out from that same cache would be the fastest way to get the info, I imagine the cache is just straight DMA'd into VRAM when needed.
The data does not change in VRAM on its own so there's not a whole lot need to go poke at it directly.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Sun Aug 11, 2013 7:39 pm

You can do VRAM read operation but this is not direct way of doing it as indeed, that would not be a great idea. usually you always keep a work ram version of your sprites data then you upload it to VRAM when needed. Working exclusively from VRAM would make operations lot slower.

Xynxyn
Very interested
Posts: 54
Joined: Fri Jun 15, 2012 10:32 am
Location: Poland

Post by Xynxyn » Sun Aug 11, 2013 9:45 pm

I thought mainly about RAM usage, but that usage if using the spriteDefCache isn't much bigger, and operating directly on VRAM is much slower, I probably would stay with the standard option. (I used it before, but want to know the black magic ;D)

Post Reply