1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
HandleStoneQueue::
ldh a, [hROMBank]
push af
call SwitchToMapScriptsBank
call .WarpAction
pop bc
ld a, b
rst Bankswitch
ret
.WarpAction:
ld hl, OBJECT_MAP_OBJECT_INDEX
add hl, de
ld a, [hl]
cp $ff
jr z, .nope
ld l, a
push hl
call .IsObjectOnWarp
pop hl
jr nc, .nope
ld d, a
ld e, l
call .IsObjectInStoneTable
jr nc, .nope
call CallMapScript
farcall EnableScriptMode
scf
ret
.nope
and a
ret
.IsObjectOnWarp:
push de
ld hl, OBJECT_NEXT_MAP_X
add hl, de
ld a, [hl]
ld hl, OBJECT_NEXT_MAP_Y
add hl, de
ld e, [hl]
sub 4
ld d, a
ld a, e
sub 4
ld e, a
call .check_on_warp
pop de
ret
.check_on_warp
ld hl, wCurMapWarpsPointer
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [wCurMapWarpCount]
and a
jr z, .nope2
.loop
push af
ld a, [hl]
cp e
jr nz, .not_on_warp
inc hl
ld a, [hld]
cp d
jr nz, .not_on_warp
jr .found_warp
.not_on_warp
ld a, WARP_EVENT_SIZE
add l
ld l, a
jr nc, .no_carry
inc h
.no_carry
pop af
dec a
jr nz, .loop
.nope2
and a
ret
.found_warp
pop af
ld d, a
ld a, [wCurMapWarpCount]
sub d
inc a
scf
ret
.IsObjectInStoneTable:
inc e
ld hl, CMDQUEUE_ADDR
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
.loop2
ld a, [hli]
cp $ff
jr z, .nope3
cp d
jr nz, .next_inc3
ld a, [hli]
cp e
jr nz, .next_inc2
ld a, [hli]
ld h, [hl]
ld l, a
jr .yes
.next_inc3
inc hl
.next_inc2
inc hl
inc hl
jr .loop2
.nope3
and a
ret
.yes
scf
ret
|