summaryrefslogtreecommitdiff
path: root/src/randomcrap.S
blob: 63363def835eddc928b5028cba4b42a9ac8c2a38 (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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
.text

.global TitleScreenFucker
.extern RESTART_CRSIN_LevelStartStruct
.extern SaveFileBuffer
TitleScreenFucker:
	lis r3, RESTART_CRSIN_LevelStartStruct@h
	ori r3, r3, RESTART_CRSIN_LevelStartStruct@l
	li r4, 0
	stb r4, 7(r3)
	
	# now get the FUCKING WORLD and FUCKING LEVEL
	lis r4, SaveFileBuffer@h
	ori r4, r4, SaveFileBuffer@l
	#lwz r4, 0(r4)
	lbz r5, 6(r4)
	extsb r5, r5
	mulli r5, r5, 0x980
	addi r4, r4, 0x6A0
	add r4, r4, r5

	# do we need to use Quick Save? get the QS block
	addi r4, r4, 0x1C80
	lbz r6, 2(r4)
	clrlwi. r6, r6, 31
	beq quickSaveExists
	subi r4, r4, 0x1C80
quickSaveExists:

	# now we have the save block in r4
	lbz r6, 2(r4)
	clrlwi. r6, r6, 31
	beq saveIsNotNew
	li r5, 0
	li r6, 9
	b chosenTitle
saveIsNotNew:
	lbz r5, 0x73A(r4)
	lbz r6, 0x73B(r4)
chosenTitle:
	cmpwi r5, 0
	bne isntWorld1_1
	cmpwi r6, 0
	bne isntWorld1_1
	li r5, 0
	li r6, 9
isntWorld1_1:
	stb r5, 0xC(r3)
	stb r6, 0xD(r3)
	blr


.global mpPauseFix1
.global mpPauseFix2
.extern continueFromMpPauseFix1
.extern continueFromMpPauseFix2

mpPauseFix1:
	lis r5, continueFromMpPauseFix1@h
	ori r5, r5, continueFromMpPauseFix1@l
	b mpPauseFix
mpPauseFix2:
	lis r5, continueFromMpPauseFix2@h
	ori r5, r5, continueFromMpPauseFix2@l
	b mpPauseFix

.extern CheckIfSinglePlayer

mpPauseFix:
	stwu r1, -0x20(r1)
	mflr r0
	stw r0, 0x24(r1)
	stw r31, 0x1C(r1)
	stw r30, 0x18(r1)
	mr r31, r3
	mr r30, r4

	bl CheckIfSinglePlayer
	cmpwi r3, 1
	bne DontDoThis
	mr r3, r31
	mr r4, r30
	mtctr r5
	bctrl
DontDoThis:
	
	lwz r30, 0x18(r1)
	lwz r31, 0x1C(r1)
	lwz r0, 0x24(r1)
	mtlr r0
	addi r1, r1, 0x20
	blr

.global newClimbSounds
newClimbSounds:
	li r7, 0x134
	b effectNewClimbSounds
.global newClimbSoundsJump
newClimbSoundsJump:
	li r7, 0x136
	b effectNewClimbSounds
.global newClimbSoundsJumpS
newClimbSoundsJumpS:
	li r7, 0x137
	b effectNewClimbSounds
.global newClimbSoundsJumpSS
newClimbSoundsJumpSS:
	li r7, 0x138
	b effectNewClimbSounds
.global newClimbSoundsLand
newClimbSoundsLand:
	li r7, 0x139
	b effectNewClimbSounds
.global newClimbSoundsAttack
newClimbSoundsAttack:
	li r7, 0x13A
	b effectNewClimbSounds


.extern StagePtr
effectNewClimbSounds:
	lis r6, StagePtr@h
	ori r6, r6, StagePtr@l
	lwz r6, 0(r6)
	lhz r6, 0x120C(r6)

	cmpwi r6, 14
	beq pngn
	cmpwi r6, 0x903
	beq pngn
	cmpwi r6, 0x40E
	beq climb
	mr r4, r7
	blr
pngn:
	li r4, 0xE1
	blr
climb:
	li r4, 0xC9
	blr

.global TextWriterCrap
.extern TextWriterCrapContinue
TextWriterCrap:
	lis r6, 0xFFFF
	ori r6, r6, 0xFF00
	lwz r0, 8(r5)
	or r0, r0, r6
	stw r0, 0x18(r1)
	lwz r0, 0xC(r5)
	or r0, r0, r6
	stw r0, 0x1C(r1)
	lwz r0, 0x10(r5)
	or r0, r0, r6
	stw r0, 0x20(r1)
	lwz r0, 0x14(r5)
	or r0, r0, r6
	stw r0, 0x24(r1)

	b TextWriterCrapContinue

.global HeapChangeAttempt
HeapChangeAttempt:
	lis 4, 0x8037
	ori 4, 4, 0x7F50
	lwz 4, 0(4)
	blr


.extern OSReport
.global UniversalFunctionLog
UniversalFunctionLog:
	stwu r1, -0x10(r1)
	stw r0, 0x14(r1)
	stw r31, 0xC(r1)
	stw r30, 0x8(r1)
	mr r31, r3
	mr r30, r4

	crclr 4*cr1+eq
	mr r4, r31
	#Loop through callstack, kind of
	lwz r3, 0(r1)
	lwz r5, 4(r3)
	lwz r3, 0(r3)
	lwz r6, 4(r3)
	lwz r3, 0(r3)
	lwz r7, 4(r3)
	lwz r3, 0(r3)
	lwz r8, 4(r3)
	lwz r3, 0(r3)
	lwz r9, 4(r3)
	lwz r3, 0(r3)
	lwz r10, 4(r3)
	#lwz r10, 0x14(r29)

	lis r3, UniLogStr@h
	ori r3, r3, UniLogStr@l
	bl OSReport
	
	mr r3, r31
	mr r4, r30
	lwz r30, 0x8(r1)
	lwz r31, 0xC(r1)
	lwz r0, 0x14(r1)
	mtlr r0
	addi r1, r1, 0x10
	blr

.data
UniLogStr: .string "[ULog] returning %8x to: %x > %x > %x > %x > %x > %x\n"