summaryrefslogtreecommitdiff
path: root/src/scene.S
blob: 8a8404cdb824640824b14cfd4ad1bed35bf10a76 (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
.extern currentHeap
.extern MakeScene
.extern DVDClass
.extern GetSceneLightInfo
.extern GetRes
.extern GetAnmScn
.extern BindAnmScn
.extern AssignAnmScnToLightInfo
.extern LoadBlight
.extern LoadBlmap


.text

.set sp,1
.set rtoc,2

.global LoadMapScene
LoadMapScene:
	stwu sp, -0x30(sp)
	mflr r0
	stw r0, 0x34(sp)

	stw r31, 0x2C(sp)



	lis r3, currentHeap@h
	ori r3, r3, currentHeap@l
	lwz r3, 0(r3)

	li r4, 36	#Light count
	li r5, 8	#Ambient light count
	li r6, 2	#Dunno
	li r7, 0	#Make fog (bool)
	li r8, 0	#Scene ID

	bl MakeScene


	# Now make the actual scene!
	# Get light info
	li r3, 0
	bl GetSceneLightInfo
	mr r31, r3

	# Get scene/scene.brres
	lis r3, DVDClass@h
	ori r3, r3, DVDClass@l
	addi r3, r3, 4

	lis r4, EnvWorld@h
	ori r4, r4, EnvWorld@l

	lis r5, SceneBrres@h
	ori r5, r5, SceneBrres@l

	bl GetRes

	# Got that, now get the AnmScn we want (MainSelect)
	stw r3, 0x0C(sp)	#ResFile

	addi r3, sp, 0xC
	lis r4, MainSelect@h
	ori r4, r4, MainSelect@l
	bl GetAnmScn
	stw r3, 0x10(sp)

	# Bind it
	addi r3, sp, 0x10
	addi r4, sp, 0x10
	bl BindAnmScn

	# Add it to lightinfo
	mr r3, r31			#This
	addi r4, sp, 0x10	#AnmScn pointer
	li r5, -1			#Dunno
	li r6, 3			#Dunno

	lis r9, Zero@h
	ori r9, r9, Zero@l
	lfs f1, 0(r9)		#Dunno

	bl AssignAnmScnToLightInfo


	# Now set up the rest of the scene
	# Get blight
	lis r3, DVDClass@h
	ori r3, r3, DVDClass@l
	addi r3, r3, 4

	lis r4, EnvWorld@h
	ori r4, r4, EnvWorld@l

	lis r5, BlightW1@h
	ori r5, r5, BlightW1@l

	bl GetRes

	# Load it into lightinfo
	mr r4, r3
	mr r3, r31
	bl LoadBlight



	# Do the same for blmap
	lis r3, DVDClass@h
	ori r3, r3, DVDClass@l
	addi r3, r3, 4

	lis r4, EnvWorld@h
	ori r4, r4, EnvWorld@l

	lis r5, BlmapW1@h
	ori r5, r5, BlmapW1@l

	bl GetRes

	# Load it into its class
	mr r4, r3
	lwz r3, 0x14(r31)
	bl LoadBlmap


	# DONE!!
	lwz r31, 0x2C(sp)

	lwz r0, 0x34(sp)
	mtlr r0
	addi sp, sp, 0x30
	blr






.data
EnvWorld:	.string "Env_world"
SceneBrres:	.string "scene/scene.brres"
MainSelect:	.string "MainSelect"
Zero:		.float 0.0
BlightW1:	.string "light/W8.blight"
BlmapW1:	.string "light/W8.blmap"

.align 4