Pārlūkot izejas kodu

add sideway stairs

SBird1337 6 gadus atpakaļ
vecāks
revīzija
9921881551
Parakstījis: SBird1337 <philipp@karathan.at> GPG atslēgas ID: C9A4764515931448

+ 1
- 1
g3headers

@@ -1 +1 @@
1
-Subproject commit 732e4c1cc26397d8ac95c28886d29501b0baf5b4
1
+Subproject commit 1063239b4b46f6e4b87978f62aee78306e1b4015

+ 26
- 1
patches/overworlds/npc_walk.asm Parādīt failu

@@ -5,4 +5,29 @@
5 5
 .word npc_walk_animations
6 6
 
7 7
 .org 0x080645B4
8
-.word npc_walk_animations
8
+.word npc_walk_animations
9
+
10
+.org 0x0805BBA8
11
+push {r4, lr}
12
+ldr r4, [sp, #8] //block role
13
+push {r4}
14
+ldr r4, =npc_get_walkable_status+1
15
+bl bxr4_npc_walk
16
+add sp, #4
17
+pop {r4}
18
+pop {r1}
19
+bx r1
20
+
21
+bxr4_npc_walk:
22
+    bx r4
23
+.pool
24
+
25
+.org 0x0805B9E4
26
+    ldr r1, =npc_run_hook|1
27
+    bx r1
28
+.pool
29
+
30
+.org 0x080BD308
31
+    ldr r1, =npc_bike_hook|1
32
+    bx r1
33
+.pool

+ 80
- 0
src/player_interaction/sideway_stair.c Parādīt failu

@@ -0,0 +1,80 @@
1
+#include <pokeagb/pokeagb.h>
2
+#include <agb_debug.h>
3
+
4
+#define BLOCK_STATE_SIDEWAY_NW 0x80
5
+#define BLOCK_STATE_SIDEWAY_NE 0x81
6
+#define BLOCK_STATE_SIDEWAY_SW 0x82
7
+#define BLOCK_STATE_SIDEWAY_SE 0x83
8
+#define BEHAVIOR_STAIR_WEST 0xE0
9
+#define BEHAVIOR_STAIR_EAST 0xE1
10
+
11
+const u8 diagonal_animations[4] = {170,171,172,173};
12
+
13
+bool npc_sideway_try_walking(u8 block_state)
14
+{
15
+    if(block_state >= BLOCK_STATE_SIDEWAY_NW) {
16
+        npc_player_set_movement_and_x22(diagonal_animations[block_state - BLOCK_STATE_SIDEWAY_NW], 2);
17
+        // Kinda have to do the thing when the player runs (ish)
18
+        return true;
19
+    }
20
+    return false;
21
+}
22
+
23
+u8 npc_get_walkable_status(struct NpcState *npc, u16 x, u16 y, enum Direction direction, u8 roleTo) {
24
+    dprintf("get_walkable: %d, %d, %d, %d\n", x,y, direction, roleTo);
25
+    u8 block = npc_block_way(npc, x,y,direction);
26
+
27
+    //check for diagonal stair stuff here
28
+    struct NpcState dummyNpc;
29
+    memcpy(&dummyNpc, npc, sizeof(struct NpcState));
30
+
31
+    u16 roleFrom = cur_mapdata_block_role_at(npc->from.x, npc->from.y);
32
+    if (direction == WEST) {
33
+        dprintf("WEST with from: %d\n", roleFrom);
34
+        if(roleFrom == BEHAVIOR_STAIR_WEST) {
35
+            //walk up the stair to the west
36
+            dummyNpc.from.y--;
37
+            dummyNpc.to.y--;
38
+            u8 altBlocked = npc_block_way(&dummyNpc, x,y-1, direction);
39
+            dprintf("trying NW: %d\n", altBlocked);
40
+            return (altBlocked == 0) ? BLOCK_STATE_SIDEWAY_NW : altBlocked;
41
+        }
42
+        else if(roleFrom == BEHAVIOR_STAIR_EAST){
43
+            //walk down the stair to the west
44
+            dummyNpc.from.y++;
45
+            dummyNpc.to.y++;
46
+            u8 altBlocked = npc_block_way(&dummyNpc, x,y+1, direction);
47
+            dprintf("trying SE: %d\n", altBlocked);
48
+            return (altBlocked == 0) ? BLOCK_STATE_SIDEWAY_SW : altBlocked;
49
+        }
50
+    } else if(direction == EAST) {
51
+        if(roleFrom == BEHAVIOR_STAIR_EAST) {
52
+            //walk up the stair to the east
53
+            dummyNpc.from.y--;
54
+            dummyNpc.to.y--;
55
+            u8 altBlocked = npc_block_way(&dummyNpc, x,y-1, direction);
56
+            dprintf("trying NE: %d\n", altBlocked);
57
+            return (altBlocked == 0) ? BLOCK_STATE_SIDEWAY_NE : altBlocked;
58
+        } else if (roleFrom == BEHAVIOR_STAIR_WEST) {
59
+            //walk down the stair to the east
60
+            dummyNpc.from.y++;
61
+            dummyNpc.to.y++;
62
+            u8 altBlocked = npc_block_way(&dummyNpc, x,y+1, direction);
63
+            dprintf("trying SW: %d\n", altBlocked);
64
+            return (altBlocked == 0) ? BLOCK_STATE_SIDEWAY_SE : altBlocked;
65
+        }
66
+    }
67
+
68
+    //continue with game code
69
+
70
+    if(block == 3 && npc_is_passable_maybe(x,y,direction))
71
+        return 5;
72
+    if(npc_handle_jump(x,y,direction)) {
73
+        sav1_secure_increment(0x2B);
74
+        return 6;
75
+    }
76
+    else if(block == 4 && npc_handle_strength(x,y,direction)) {
77
+        return 7;
78
+    }
79
+    return block;
80
+}

+ 38
- 0
src/player_interaction/sideway_stair_hooks.s Parādīt failu

@@ -0,0 +1,38 @@
1
+.align 2
2
+.thumb
3
+.text
4
+.global npc_run_hook
5
+
6
+npc_run_hook:
7
+    //we just got our result from npc_get_walkable_status in r0
8
+    lsl r0, #0x18
9
+    lsr r0, #0x18
10
+    mov r6, r0
11
+    bl npc_sideway_try_walking
12
+    cmp r0, #1
13
+    bne continue
14
+walkable:
15
+    ldr r6, =0x0805BA18|1
16
+    bx r6
17
+continue:
18
+    mov r0, r6
19
+    mov r1, r0
20
+    cmp r0, #0
21
+    beq walkable
22
+    ldr r6, =0x0805B9EE|1
23
+    bx r6
24
+
25
+.global npc_bike_hook
26
+npc_bike_hook:
27
+    lsr r5, r0, #0x18
28
+    bl npc_sideway_try_walking
29
+    cmp r0, #0
30
+    beq continue_bike
31
+    pop {r4-r6}
32
+    pop {r0}
33
+    bx r0
34
+    continue_bike:
35
+    mov r1, r5
36
+    sub r0, r1, #1
37
+    ldr r2, =0x080BD312|1
38
+    bx r2