Pārlūkot izejas kodu

added virtual batchmaptile

SBird1337 7 gadus atpakaļ
vecāks
revīzija
f0b847e472

+ 1
- 1
makefile Parādīt failu

@@ -18,7 +18,7 @@ PAGB_LINK := $(PAGB_MAIN)/build/linker/BPRE.ld
18 18
 
19 19
 DEFINES   := -DBPRE -DSOFTWARE_VERSION=0
20 20
 ASFLAGS   := -mthumb
21
-CFLAGS    := -mthumb -mthumb-interwork -g -mcpu=arm7tdmi -fno-inline -mlong-calls -march=armv4t -Og -std=c11 -Wall -Wextra -Wunreachable-code -Isrc/include -fdiagnostics-color $(DEFINES)
21
+CFLAGS    := -mthumb -mthumb-interwork -g -mcpu=arm7tdmi -fno-inline -mlong-calls -march=armv4t -Og -std=c11 -Wall -Wextra -Wunreachable-code -I$(PAGB_INCLUDE) -Isrc/include -fdiagnostics-color $(DEFINES)
22 22
 GRITFLAGS := -ftc -fa
23 23
 LDFLAGS   := -z muldefs
24 24
 BLDPATH   := object

+ 9
- 0
src/overworld/dyn_npc_hooks.S Parādīt failu

@@ -0,0 +1,9 @@
1
+.align 2
2
+.text
3
+.thumb
4
+
5
+.global npc_spawn_hook:
6
+npc_spawn_hook:
7
+    ldrh r0, [r6, #2]
8
+    bl dynamic_npc_load_palette
9
+    lsl r1, r0, #4

+ 21
- 3
src/overworld/dynamic_overworld.c Parādīt failu

@@ -1,4 +1,22 @@
1
-void npc_spawn()
1
+#include <pokeagb/pokeagb.h>
2
+
3
+enum PalStoreType{
4
+    UNUSED,
5
+    NPC,
6
+    REFLECTION,
7
+    OTHER
8
+};
9
+
10
+struct PalStoreEntry{
11
+    enum PalStoreType type;
12
+    u8 reference_count;
13
+    u16 tag; 
14
+};
15
+
16
+extern struct PalStoreEntry stored_palettes[16];
17
+
18
+u8 dynamic_npc_load_palette(u16 tag)
2 19
 {
3
-    //placeholder for now
4
-}
20
+
21
+}
22
+

+ 20
- 0
src/specials/batch_maptile.c Parādīt failu

@@ -0,0 +1,20 @@
1
+#include <pokeagb/pokeagb.h>
2
+
3
+void sp_batchmaptile(void) {
4
+    u16 tid_from = var_8000;
5
+    u16 tid_to = var_8001;
6
+    u8 collision_from = var_8002;
7
+    u8 collision_to = var_8003;
8
+
9
+    for (u8 x = 0; x < virtual_map_header.width; ++x) {
10
+        for(u8 y = 0; y < virtual_map_header.height; ++y)
11
+        {
12
+            struct MapTile *current = &virtual_map_header.data[x + virtual_map_header.width * y];
13
+            if(current->tile == tid_from && current->permission == collision_from)
14
+            {
15
+                current->tile = tid_to;
16
+                current->permission = collision_to;
17
+            }
18
+        }
19
+    }
20
+}

+ 5
- 2
src/specials/custom_specials.c Parādīt failu

@@ -66,6 +66,8 @@ void sp_clear_variables();
66 66
  */
67 67
 void sp_random_number();
68 68
 
69
+extern void sp_batchmaptile(void);
70
+
69 71
 
70 72
 void get_text_pointer_from_lookup();
71 73
 
@@ -73,14 +75,15 @@ void sp_check_tileset();
73 75
 
74 76
 /* === STATICS === */
75 77
 
76
-static callback special_routines[7] = {
78
+static callback special_routines[8] = {
77 79
     met_play,
78 80
     cam_sp_move_camera,
79 81
     sp_init_script,
80 82
     debug_some_test,
81 83
     sp_dns_switch,
82 84
     sp_random_number,
83
-    sp_check_tileset
85
+    sp_check_tileset,
86
+    sp_batchmaptile
84 87
 };
85 88
 
86 89
 /* === IMPLEMENTATIONS === */