aboutsummaryrefslogtreecommitdiff
path: root/entity/mouse.gbasm
blob: 4a09009e50dde9d334b46b1704f3597be563fc5e (plain)
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Mouse_Turn:
	LD A, $mem_map_loading_flags
	BIT 3, A
	RET Z

	PUSH HL
	PUSH BC
	PUSH DE
	INC HL
	LD A, (HL+)
	LD B, A
	LD A, (HL+)
	LD C, A
	LD A, (HL+)
	LD D, A

	.Health_check:
		LD A, L
		AND $f0
		ADD $06
		LD L, A

		LD A, (HL)
		CP $00
		JR NZ, =.Health_check.end

		LD A, L
		AND $f0
		LD L, A

		LD (HL), $00
		LD A, $mem_enemies_alive_count
		DEC A
		LD $mem_enemies_alive_count, A

		PUSH DE
		LD D, $6C
		LD E, $04
		CALL =RNG_Step
		AND $03
		CP $00
		CALL Z, =Spawn_object
		POP DE

		JP =.Skip_turn
	.Health_check.end:

	.Freeze_shiver:
		LD A, $mem_moving_animation_step
		CP $00
		JP NZ, =.Freeze_shiver.end
		LD A, L
		AND $f0
		ADD $08
		LD L, A
		LD A, $01
		CP (HL)
		JR NZ, =.Freeze_shiver.end
		LD A, D
		AND $07
		LD D, A
		CALL =RNG_Step
		CP $55
		JP NC, =.Skip_turn
		LD A, D
		OR $40
		LD D, A

		CALL =RNG_Step
		CP $55
		JP NC, =.Skip_turn

		LD A, $00
		LD (HL-), A
		RES 1, (HL)
		JP =.Skip_turn
	.Freeze_shiver.end:

	.Should_turn_be_skipped:
		LD A, L
		AND $f0
		ADD $08
		LD L, A

		BIT 0, (HL)
		JP NZ, =.Skip_turn

	.Start_action_or_movement:
		LD A, $mem_moving_animation_step
		CP $00
		JP NZ, =.Start_action_or_movement.end

		LD A, L
		AND $f0
		OR $07
		LD L, A
		RES 3, (HL)

		.Try_Basic_Attack:
		CALL =Check_player_next_to
		LD A, E
		CP $00
		JR Z, =.Try_Walking
		CALL =Basic_Enemy_Attack

		JR =.Start_action_or_movement.end

		.Try_Walking:
		CALL =Walking
		BIT 3, D
		JR Z, =.Start_action_or_movement.end
		LD A, D
		OR $50
		LD D, A
	.Start_action_or_movement.end:

	.Mid_movement:
		LD A, $mem_moving_animation_step
		CP $07
		JR NZ, =.Mid_movement.end

		LD A, D
		AND $f0
		CP $50
		JR NZ, =.Mid_movement.end

		LD A, D
		AND $07
		BIT 3, D
		LD D, A
		JR Z, =.Mid_movement.end
		LD A, $01
		.ADD_A_TO_DIRECTION_BC

		.Mid_movement.Try_Walking:
		CALL =Walking
		BIT 3, D
		JR Z, =.Mid_movement.end
		LD A, D
		OR $50
		LD D, A
	.Mid_movement.end:

	.End_movement:
		LD A, $mem_moving_animation_step
		CP $0f
		JR NZ, =.End_movement.end

		LD A, D
		AND $07
		BIT 3, D
		LD D, A
		JR Z, =.End_movement.end
		LD A, $01
		.ADD_A_TO_DIRECTION_BC
	.End_movement.end:

	.Skip_Turn:
	LD A, L
	AND $f0
	LD L, A
	INC HL
	LD A, B
	LD (HL+), A
	LD A, C
	LD (HL+), A
	LD A, D
	LD (HL+), A
	POP DE
	POP BC
	POP HL
	RET