KanedaFr Posted May 4 Share Posted May 4 Hi  Here and there I read about "streaming" sprite data. I'm not sure I understand what it means 😊 For the name, I suspect it's using lynx_load every frame to change sprite data   pseudo code  while(1) { lynx_load(sprite_data[X]); <wait_frame> ++X; }   Can someone correct me ? Quote Link to comment Share on other sites More sharing options...
Nop90 Posted May 5 Share Posted May 5 (edited) The basic idea is right and this is used when a character has one or more animations with a huge number of frames (and usually of large dimensions) that all the frames can't stay in memory at the same time.  But you can't load a data array with lynx_load(), you load a cart segment in memory with lynx_load((int)SPRITEFRAME_X_FILENR), and usually you don't need to load every frame, and  If the character animation has N frames per second and the game runs at X FPS, you need to load a new sprite frame every X/N (e.g. with a character with 4 frames per second and the game running at 20FPS, 20/4=5, you need to load a new character frame every 5 seconds screen frames)   Usually I adopt two tricks when loading resources from the cart this way for saving some ram and computing time.  The first one is to put the sprites frames in subsequent cart segments, and to use for all of them the same pointer variable name, this way I don't have to change the value in the SCB.data field when the sprite changes (the compiler throws several warning for duplicate variable names, but as long as you know what your doing everything works fine).  It also saves a lot of memory because you don't have to define an array with all the pointers to the several sprite frames.  The other trick is to use lynx_load with the pointer to the first frame segment + an unsigned char offset to the number of the sprite frame to load, i.e.  lynx_load(((int)SPRITEFRAME_0_FILENR) + animframe), this way you don't need to have an array with all the segments indexes, but the cart segments must be in the same order of the sprite animation frame.  I hope this helps. Edited May 7 by Nop90 1 Quote Link to comment Share on other sites More sharing options...
LX.NET Posted May 6 Share Posted May 6 Hi @Nop90 Just so I understand it all: when you have 4 animated frames every second, running at 20fps requires you to load a frame every 4/20 is 0,,2 sec (instead of 5)? Or am I missing something? Quote Link to comment Share on other sites More sharing options...
Nop90 Posted May 7 Share Posted May 7 (edited) 16 hours ago, LX.NET said: Hi @Nop90 Just so I understand it all: when you have 4 animated frames every second, running at 20fps requires you to load a frame every 4/20 is 0,,2 sec (instead of 5)? Or am I missing something? A new character frame every 5 seconds 😆, it's obviously a silly mistake, I corected the above post writing "a new character frame every 5 screen frames".  BTW your formula is not correct: 16 hours ago, LX.NET said: running at 20fps requires you to load a frame every 4/20 is 0,,2 sec 20 FPS / 5 Frames = 0,25 sec is the time to wait before loading a new frame. But counting time is not simple, I count frames with a variable incremented every VBLANK.   Edited May 7 by Nop90 1 Quote Link to comment Share on other sites More sharing options...
LX.NET Posted May 9 Share Posted May 9 Yep, you are right about my improper calculation. Thanks for pointing it out. Get it now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.