|
2 | 2 |
|
3 | 3 | void CTR_CycleTex_LEV(struct AnimTex* animtex, int timer) |
4 | 4 | { |
5 | | - int frameIndex; |
| 5 | + int frameCurr; |
6 | 6 | struct AnimTex* curAnimTex = animtex; |
7 | | - |
8 | | - if(animtex == NULL) { return; } |
9 | | - |
10 | | - // iterate over All AnimTex's in a row, |
11 | | - // last one loops back to the beginning, could've also just been a null terminator |
12 | | - while (*(int*)curAnimTex != (int)animtex)// I feel like this should just be a do/while with `(int)curAnimText != (int)animtex`, but idk |
| 7 | + |
| 8 | + #ifdef USE_NEWLEV |
| 9 | + if(animtex == 0) return; |
| 10 | + #endif |
| 11 | + |
| 12 | + // Termination is determined by pointer to First AnimTex |
| 13 | + while (*(int*)curAnimTex != (int)animtex) |
13 | 14 | { |
14 | | - frameIndex = FPS_HALF(timer) + curAnimTex->frameDuration >> |
15 | | - ((int)curAnimTex->shiftFactor & 0x1fU); |
16 | | - |
17 | | - frameIndex = frameIndex % curAnimTex->numFrames; |
18 | | - curAnimTex->frameIndex = frameIndex; |
19 | | - |
| 15 | + // which texture to draw this frame |
| 16 | + frameCurr = FPS_HALF(timer) + curAnimTex->frameOffset; |
| 17 | + |
| 18 | + // allow frames to skip updating (like 60fps hacks) |
| 19 | + frameCurr = frameCurr >> curAnimTex->frameSkip; |
| 20 | + |
| 21 | + // loop back to index[0] after finished cycle |
| 22 | + frameCurr = frameCurr % curAnimTex->numFrames; |
| 23 | + |
| 24 | + // save result |
| 25 | + curAnimTex->frameCurr = frameCurr; |
| 26 | + |
20 | 27 | struct IconGroup4** ptrArray = ANIMTEX_GETARRAY(curAnimTex); |
21 | | - |
| 28 | + |
22 | 29 | // Save new frame |
23 | | - curAnimTex->ptrActiveTex = (int*)ptrArray[frameIndex]; //why is this line slightly different than CTR_CycleTex_Model.c? |
24 | | - |
| 30 | + // For levels, this is just a pointer |
| 31 | + curAnimTex->ptrActiveTex = (int*)ptrArray[frameCurr]; |
| 32 | + |
25 | 33 | // Go to next AnimTex, which comes after this AnimTex's ptrarray |
26 | 34 | curAnimTex = (struct AnimTex*)&ptrArray[curAnimTex->numFrames]; |
27 | 35 | } |
|
0 commit comments