Bläddra i källkod

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

SBird1337 7 år sedan
förälder
incheckning
3ebfc749e5
1 ändrade filer med 7 tillägg och 5 borttagningar
  1. 7
    5
      src/overworld/tileset_animation/text_animator.c

+ 7
- 5
src/overworld/tileset_animation/text_animator.c Visa fil

@@ -9,7 +9,7 @@
9 9
 #define CANVAS_FIRST (u8 *)(574 * 0x20 + 0x06000000)
10 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 14
 s16 char_to_tile_index(char chr) {
15 15
     if (chr >= 'A' && chr <= 'P')
@@ -32,7 +32,7 @@ s16 char_to_tile_index(char chr) {
32 32
 }
33 33
 
34 34
 void draw_text_on_canvas(const char *txt) {
35
-    
35
+
36 36
     u16 current_tile = 0;
37 37
     while (*txt) {
38 38
         s16 tile = char_to_tile_index(*txt);
@@ -61,7 +61,7 @@ void set_pixel(u8 x, u8 y, u16 *start, u16 pixel) {
61 61
     if (x % 2 == 0)
62 62
         *addr = (*addr & 0xFF00) | (pixel);
63 63
     else
64
-        *addr = (*((u8*)addr)) | (pixel << 8);
64
+        *addr = (*((u8 *)addr)) | (pixel << 8);
65 65
 }
66 66
 
67 67
 #define ANIMATION_FRAME_SPEED 2
@@ -93,7 +93,9 @@ void text_animator(u16 current_frame) {
93 93
 void anim_init_text(void) {
94 94
     blockset_one_current_tile = 0;
95 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 98
         draw_text_on_canvas(map_texts[var_8000]);
99
+        blockset_one_animator = text_animator;
100
+    }
99 101
 }