aboutsummaryrefslogtreecommitdiff
path: root/entity/bug.gbasm
blob: fd6bc831f88c00c26f29d63589b18e86826989d3 (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
Bug_Drop:
	PUSH DE
	LD D, $64
	LD E, $02
	CALL =RNG_Step
	AND $03
	CP $00
	CALL Z, =Spawn_object
	POP DE
	RET

Bug_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

	.RESET_BLINKING_MODE

	.ENTITY_HEALTH_CHECK =.Skip_turn =Mouse_Drop
	.ENTITY_FREEZE_SHIVER =.Skip_turn
	.ENTITY_STATUS_SKIP_TURN =.Skip_turn

	LD A, $mem_moving_animation_step
	CP $00
	JR NZ, =.attack_end

	.ENTITY_TRY_ATTACK =Poison_sight_check =Poison_Enemy_Attack =.attack_end
	CALL =Walking
	BIT 3, D
	JR Z, =.attack_end
	LD A, L
	AND $f0
	OR $0a
	LD L, A
	LD (HL), $05
	LD A, (HL)
	.attack_end:

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

		BIT 3, D
		JR Z, =.Mid_movement.end

		LD A, L
		AND $f0
		OR $0a
		LD L, A
		LD A, $05
		CP (HL)
		LD A, (HL)
		JR NZ, =.Mid_movement.end

		LD A, L
		AND $f0
		OR $0a
		LD L, A
		LD (HL), $00

		LD A, D
		RES 3, A
		LD D, A
		LD A, $01
		.ADD_A_TO_DIRECTION_BC

		.Mid_movement.Try_Walking:
		PUSH DE
		CALL =Walking
		BIT 3, D
		JR Z, =.Mid_movement.Walk_cancelled
		LD A, L
		AND $f0
		OR $0a
		LD L, A
		LD (HL), $05
		ADD SP, $02
		JR =.Mid_movement.end
		.Mid_movement.Walk_cancelled:
		POP DE
		RES 3, D
	.Mid_movement.end:

	.Die_After_Attack:
		LD A, $mem_moving_animation_step
		CP $07
		JR NZ, =.Die_After_Attack.end
		LD A, L
		AND $f0
		OR $07
		LD L, A
		BIT 2, (HL)
		JR Z, =.Die_After_Attack.end

		DEC HL

		LD (HL), $00

	.Die_After_Attack.end:

	CALL =Entity_End_movement

	.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