aboutsummaryrefslogtreecommitdiff
path: root/map/generationevents.gbasm
blob: 5fc35de3adb07c7bce85cb2bc2a297b721aa29fa (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
Generation_Event_Execution:
	LD A, $mem_floor_count
	LD D, A
	LD HL, $mem_dungeon_generation_events
	.loop:
		LD A, (HL+)
		AND A
		JR Z, =.skip
		CP D
		JR NZ, =.skip

		LD A, (HL+)
		PUSH HL
		PUSH DE
		LD BC, =Generation_Event_Jump_Table

		.JUMP_TABLE

		POP DE
		POP HL

		.skip:
		LD A, L
		AND $f8
		ADD $08
		LD L, A
		AND A
		JR NZ, =.loop
	RET

Generation_Event_Jump_Table:
	; 00
	RET
	NOP
	NOP
	NOP

	; 01
	JP =.Dialogue_Script
	NOP

	; 02
	JP =.Remove_Stairs
	NOP

	; 03
	JP =.Load_Entity
	NOP

	; 04
	JP =.Entity_Random_Room
	NOP

	; 05
	JP =.Entity_XY
	NOP

	.Dialogue_Script:
	LD A, $enum_dungeon_dialogue_mode
	LD $mem_requested_mode, A

	LD A, (HL+)
	LD $mem_dialogue_script_bank, A
	LD A, (HL+)
	LD ($mem_dialogue_script_program_counter), A
	LD A, (HL)
	LD ($mem_dialogue_script_program_counter+1), A
	JP =Dialogue_script_step

	.Load_Entity:
		LD A, (HL+)
		LD E, A
		LD D, $00
		LD A, (HL)
		LD HL, $mem_loaded_entities_indices
		ADD HL, DE
		LD (HL), A
		RET

	.Entity_Random_Room:
		LD A, $01
		LD $tmp_var_3, A

		LD D, (HL)
		CALL =FindFreeEntity
		LD A, D
		JP =Initialize_Entity

	.Entity_XY:
		LD A, (HL+)
		LD D, A
		LD A, (HL+)
		LD B, A
		LD A, (HL+)
		LD C, A
		LD A, (HL)
		DBG
		SWAP A
		OR $02
		LD $tmp_var_3, A
		CALL =FindFreeEntity
		LD A, D
		JP =Initialize_Entity

	.Remove_Stairs:
		LD HL, $mem_object_list
		LD (HL), $00
	RET