Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <ultra64.h>
  2. #include "game/level_update.h"
  3. #include "game/area.h"
  4. #include "game/memory.h"
  5. #include "game/display.h"
  6.  
  7. #define PACK_TILESIZE(w, d) ((w << 2) + d)
  8.  
  9. typedef struct {
  10. int cmd:8;
  11. int s:12;
  12. int t:12;
  13. int pad:4;
  14. int i:4;
  15. int u:12;
  16. int v:12;
  17. } SetTileSize;
  18.  
  19. extern Gfx bob_seg7_dl_07004390;
  20.  
  21. /*
  22. * Scrolling texture system by red.
  23. * This file comes with Bob-Omb Battlefield as an example.
  24. */
  25.  
  26. /*
  27. * Parameters:
  28. * dl - Which display list to modify (make sure it's passed by reference).
  29. *
  30. * cmd - Location of the gsDPSetTileSize command in the display list.
  31. * In Bob-Omb Battlefield, it is 12.
  32. *
  33. * s/t - How much to scroll.
  34. */
  35.  
  36. static void shift_s(Gfx *dl, u32 cmd, u16 s) {
  37. SetTileSize *tile = segmented_to_virtual(dl);
  38. tile += cmd;
  39. tile->s += s;
  40. tile->u += s;
  41. }
  42.  
  43. static void shift_t(Gfx *dl, u32 cmd, u16 t) {
  44. SetTileSize *tile = segmented_to_virtual(dl);
  45. tile += cmd;
  46. tile->t += t;
  47. tile->v += t;
  48. }
  49.  
  50. /**
  51. * Main scrolling texture function. Call this every frame.
  52. * Add an entry to the switch (and make sure it's appropiate for the area you want it
  53. * to be active in, using another switch).
  54. */
  55.  
  56. void rgfx_update_scroll() {
  57. switch(gCurrLevelNum) {
  58. case LEVEL_BOB:
  59. if (gCurrAreaIndex == 1) {
  60. shift_s(&bob_seg7_dl_07004390, 12, PACK_TILESIZE(0, 1));
  61. }
  62. break;
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement