PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

memcpy problems

Hi all I'm using eaxyce to define memory space in PIXEL format etc, anyhow I'm placing multiple pictures stacked on top of one another, so I only have to load 1 file, i.e a 240x960 file, containing 3 "screens", the first one loads fine:

memcpy(screen_buffer_p,screens_p,153600);

but the second not:

memcpy(screen_buffer_p,(screens_p + 153600),153600);

eh... it seems to load the 3'rd picture? any ideas?

-Brendan

probably a simple mistake on my behalf.....
hmm, if it loads the third pic maybe it's because screens_p is type WORD/short(16bit) so he treats screens_p+1 as screens_p+1*WORD.
you always tell memcpy the amount of bytes, but if you change the WORD pointer like pointer+1; it always goes to the next WORD, not BYTE.
So simple use

memcpy(screen_buffer_p,(screens_p + (153600/2)),153600);

and it should work fine.

PS.the same happens if you use DWORD/int(32bits) and write pointer+=1. It goes to the next DWORD.
Cool, thanks, I did get it working, the way you said, but I was unsure as to "why" it worked! I recon the PIXEL def used in easyce is WORD.....

-thanks