Nessuna descrizione

main_animator.c 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include <pokeagb/pokeagb.h>
  2. #include <tileset_animation/smoke.h>
  3. struct TilesetAnimation {
  4. u16 tile_start;
  5. u16 frame_length;
  6. u16 tile_length;
  7. u16 frame_count;
  8. const void *image;
  9. };
  10. const struct TilesetAnimation hesperia_second_animations[] = {
  11. {.tile_start = 0x114, .frame_length = 7, .tile_length = 4, .frame_count = 5, .image = smokeTiles},
  12. {.tile_start = 0, .frame_length = 0, .tile_length = 0, .frame_count = 0, .image = (void *)0xFFFFFFFF},
  13. };
  14. void animate_from_structure(const struct TilesetAnimation *anim, u16 tile_skip, u16 current_frame) {
  15. void *vram_address = (void *)(0x06000000 + (tile_skip * 0x20));
  16. u8 current_animation = 0;
  17. while (anim[current_animation].image != (void *)0xFFFFFFFF) {
  18. void *current_vram = vram_address + (0x20 * anim[current_animation].tile_start);
  19. u16 max_frame = anim[current_animation].frame_length * anim[current_animation].frame_count;
  20. u16 used_frame = current_frame % max_frame;
  21. used_frame /= anim[current_animation].frame_length;
  22. memcpy(current_vram, anim[current_animation].image + (0x20 * anim[current_animation].tile_length * used_frame),
  23. anim[current_animation].tile_length * 0x20);
  24. current_animation++;
  25. }
  26. }
  27. void main_animator(u16 current_frame) { (void)current_frame; }
  28. extern struct MapBlockset maptileset128;
  29. extern struct MapBlockset maptileset0;
  30. void main_second_animator(u16 current_frame) {
  31. animate_from_structure(hesperia_second_animations, 0x280, current_frame);
  32. }
  33. void main_animator_init(void) {
  34. blockset_one_current_tile = 0;
  35. blockset_one_max_tile = 0x280;
  36. blockset_one_animator = main_animator;
  37. }
  38. void main_second_animator_init(void) {
  39. blockset_two_current_tile = 0;
  40. blockset_two_max_tile = 0x100;
  41. blockset_two_animator = main_second_animator;
  42. }