Browse Source

do not register text_animator's update handler unless there is text to update

SBird1337 7 years ago
parent
commit
3ebfc749e5
1 changed files with 7 additions and 5 deletions
  1. 7
    5
      src/overworld/tileset_animation/text_animator.c

+ 7
- 5
src/overworld/tileset_animation/text_animator.c View File

9
 #define CANVAS_FIRST (u8 *)(574 * 0x20 + 0x06000000)
9
 #define CANVAS_FIRST (u8 *)(574 * 0x20 + 0x06000000)
10
 #define CANVAS_SECOND (u8 *)(592 * 0x20 + 0x06000000)
10
 #define CANVAS_SECOND (u8 *)(592 * 0x20 + 0x06000000)
11
 
11
 
12
-static const char *map_texts[] = {"--------","< Carun City", "Route 2 >", NULL};
12
+static const char *map_texts[] = {"--------", "< Carun City", "Route 2 >", NULL};
13
 
13
 
14
 s16 char_to_tile_index(char chr) {
14
 s16 char_to_tile_index(char chr) {
15
     if (chr >= 'A' && chr <= 'P')
15
     if (chr >= 'A' && chr <= 'P')
32
 }
32
 }
33
 
33
 
34
 void draw_text_on_canvas(const char *txt) {
34
 void draw_text_on_canvas(const char *txt) {
35
-    
35
+
36
     u16 current_tile = 0;
36
     u16 current_tile = 0;
37
     while (*txt) {
37
     while (*txt) {
38
         s16 tile = char_to_tile_index(*txt);
38
         s16 tile = char_to_tile_index(*txt);
61
     if (x % 2 == 0)
61
     if (x % 2 == 0)
62
         *addr = (*addr & 0xFF00) | (pixel);
62
         *addr = (*addr & 0xFF00) | (pixel);
63
     else
63
     else
64
-        *addr = (*((u8*)addr)) | (pixel << 8);
64
+        *addr = (*((u8 *)addr)) | (pixel << 8);
65
 }
65
 }
66
 
66
 
67
 #define ANIMATION_FRAME_SPEED 2
67
 #define ANIMATION_FRAME_SPEED 2
93
 void anim_init_text(void) {
93
 void anim_init_text(void) {
94
     blockset_one_current_tile = 0;
94
     blockset_one_current_tile = 0;
95
     blockset_one_max_tile = 0x280;
95
     blockset_one_max_tile = 0x280;
96
-    blockset_one_animator = text_animator;
97
-    if(var_8000 != 0)
96
+    blockset_one_animator = NULL;
97
+    if (var_8000 != 0) {
98
         draw_text_on_canvas(map_texts[var_8000]);
98
         draw_text_on_canvas(map_texts[var_8000]);
99
+        blockset_one_animator = text_animator;
100
+    }
99
 }
101
 }