summaryrefslogtreecommitdiff
path: root/src/spritetex.S
blob: 563d81a9c8f1d99cdce3e5bc65bbc69ec497b4e8 (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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
.extern sprintf
.extern GenerateRandomNumber
.extern BombExplodeState
.extern AbsValue

#ifndef __MWERKS__
.set r0,0;   .set r1,1;   .set r2,2; .set r3,3;   .set r4,4
.set r5,5;   .set r6,6;   .set r7,7;   .set r8,8;   .set r9,9
.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3
#endif

.text
.align 4
.global GetTexFilenameForR5, TexFilenameBuffer, TexFormatString

.set sp, 1

GetTexFilenameForR5:
	# obj number should be put into r5
	# returned filename is in r5
	# this makes it easy to use with dRes_c::GetResource

	stwu sp, -0x20(sp)
	mflr r0
	stw r0, 0x24(sp)
	stw r3, 0x1C(sp)
	stw r4, 0x18(sp)
	stw r6, 0x14(sp)
	stw r7, 0x10(sp)
	stw r8, 0xC(sp)
	stw r9, 0x8(sp)

	lis r3, TexFilenameBuffer@h
	ori r3, r3, TexFilenameBuffer@l

	lis r4, TexFormatString@h
	ori r4, r4, TexFormatString@l

	crclr 4*cr1+eq
	bl sprintf

	lis r5, TexFilenameBuffer@h
	ori r5, r5, TexFilenameBuffer@l

	lwz r0, 0x24(sp)
	lwz r3, 0x1C(sp)
	lwz r4, 0x18(sp)
	lwz r6, 0x14(sp)
	lwz r7, 0x10(sp)
	lwz r8, 0xC(sp)
	lwz r9, 0x8(sp)
	mtlr r0
	addi sp, sp, 0x20
	blr


.global TEX_YoshiEggSetColour
TEX_YoshiEggSetColour:

	stwu sp, -0x30(sp)
	mflr r0
	stw r0, 0x24(sp)
	mr r9, r3 
	stw r4, 0x18(sp)
	stw r5, 0x14(sp)
	stw r6, 0x10(sp)
	stw r7, 0x0C(sp)

	li r3, 10
	bl GenerateRandomNumber
	stw r3, 0x5F8(r9)

	lwz r0, 0x24(sp)
	mr r3, r9
	lwz r4, 0x18(sp)
	lwz r5, 0x14(sp)
	lwz r6, 0x10(sp)
	lwz r7, 0x0C(sp)
	mtlr r0
	addi sp, sp, 0x30
	blr


.global TEX_YoshiEggSetBrres
TEX_YoshiEggSetBrres:

	lwz r5, 0x5F8(r27)
	clrlwi r5, r5, 28
	
	cmpwi r5, 4
	blt YoshiEggOne
	
	cmpwi r5, 8
	blt YoshiEggTwo
	
	li r5, 2
	b GetTexFilenameForR5
	
	
YoshiEggOne:
	li r5, 0
	b GetTexFilenameForR5

YoshiEggTwo:
	li r5, 1
	b GetTexFilenameForR5



.global TEX_YoshiEggSetFrame
TEX_YoshiEggSetFrame:
	
	lwz r5, 0x5F8(r27)
	clrlwi r5, r5, 30
	blr

	
.global TEX_YoshiEggEffect
TEX_YoshiEggEffect:

	lwz r0, 0x5F8(r3)
	clrlwi r0, r0, 30
	blr


.global TEX_YoshiSetColour
TEX_YoshiSetColour:

	lwz r4, 0x5F8(r31)
	oris r4, r4, 1
	blr
	

.global TEX_YoshiHack
TEX_YoshiHack:
	
	stwu sp, -0x30(sp)
	mflr r0
	stw r0, 0x24(sp)
	stw r3, 0x1C(sp)
	stw r4, 0x18(sp)
	stw r5, 0x14(sp)
	stw r6, 0x10(sp)
	stw r7, 0x0C(sp)
	stw r8, 0x08(sp)
	stw r9, 0x04(sp)

	lwz r5, 0x24C(r31)
	clrlwi r5, r5, 28
		
	lis r3, TexFilenameBuffer@h
	ori r3, r3, TexFilenameBuffer@l

	lis r4, TexFormatString@h
	ori r4, r4, TexFormatString@l

	crclr 4*cr1+eq
	bl sprintf

	lis r5, TexFilenameBuffer@h
	ori r5, r5, TexFilenameBuffer@l

	lis r4, YoshiArc@h
	ori r4, r4, YoshiArc@l
	
	lwz r0, 0x24(sp)
	lwz r3, 0x1C(sp)
	lwz r6, 0x10(sp)
	lwz r7, 0x0C(sp)
	lwz r8, 0x08(sp)
	lwz r9, 0x04(sp)
	mtlr r0
	addi sp, sp, 0x30
	blr




.global TEX_WoodBox
TEX_WoodBox:
	lwz r5, 4(r30)
	srwi r5, r5, 24
	b GetTexFilenameForR5


.global TEX_Bush
TEX_Bush:
	srwi r5, r27, 28
	b GetTexFilenameForR5


# The below was added by Tempus


.global TEX_Goomba
TEX_Goomba:
.global TEX_BuzzyShell
TEX_BuzzyShell:
.global TEX_SpinyShell
TEX_SpinyShell:
.global TEX_Coaster
TEX_Coaster:
	lwz r5, 4(r3)
	srwi r5, r5, 24
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_BigBoo
TEX_BigBoo:
	lwz r5, 4(r27)
	srwi r5, r5, 24
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_GabonRock
TEX_GabonRock:
.global TEX_BigBlock
TEX_BigBlock:
.global TEX_Manta
TEX_Manta:
.global TEX_BlockSlide
TEX_BlockSlide:
.global TEX_CloudBounce
TEX_CloudBounce:
	lwz r5, 4(r28)
	srwi r5, r5, 24
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_Thwomp
TEX_Thwomp:
.global TEX_GiantBuzzy
TEX_GiantBuzzy:
.global TEX_Buzzy
TEX_Buzzy:
.global TEX_SpikeTop
TEX_SpikeTop:
.global TEX_Koopa
TEX_Koopa:
.global TEX_Gabon
TEX_Gabon:
.global TEX_Bramball
TEX_Bramball:
.global TEX_Monty
TEX_Monty:
.global TEX_ChainChomp
TEX_ChainChomp:
.global TEX_Parabeetle
TEX_Parabeetle:
.global TEX_Bomb
TEX_Bomb:
.global TEX_ParaBomb
TEX_ParaBomb:
.global TEX_CheepChomp
TEX_CheepChomp:
.global TEX_PokeyB
TEX_PokeyB:
.global TEX_Huckit
TEX_Huckit:
	lwz r5, 4(r29)
	srwi r5, r5, 24
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_BigGoomba
TEX_BigGoomba:
.global TEX_Barrel
TEX_Barrel:
.global TEX_Blooper
TEX_Blooper:
.global TEX_Spiny
TEX_Spiny:
.global TEX_SpringBlock
TEX_SpringBlock:
.global TEX_Boo
TEX_Boo:
.global TEX_Goal
TEX_Goal:
.global TEX_StretchMush
TEX_StretchMush:
.global TEX_Spinner
TEX_Spinner:
.global TEX_AirshipGear
TEX_AirshipGear:
.global TEX_BigShell
TEX_BigShell:
.global TEX_PokeyA
TEX_PokeyA:
.global TEX_SpikeBall
TEX_SpikeBall:
.global TEX_HuckitBalls
TEX_HuckitBalls:
.global HammerColour
HammerColour:
	lwz r5, 4(r30)
	srwi r5, r5, 24
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_Podoboo
TEX_Podoboo:
	lwz r5, 4(r31)
	srwi r5, r5, 24
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


# All these vary
.global TEX_MushroomPlatform
TEX_MushroomPlatform:
	lwz r5, 4(r30)
	srwi r5, r5, 20
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_RollingHills
TEX_RollingHills:
	lwz r5, 4(r30)

	# Get style
	extrwi. r9, r5, 4, 8
	beq JustUseZero

	extrwi r5, r5, 8, 16
	b GetTexFilenameForR5

JustUseZero:
	li r5, 0
	b GetTexFilenameForR5

.global TEX_Gabon_Spike
TEX_Gabon_Spike:
	andis. r4, r4, 0xFFF0
	blr

.global TEX_Switch
TEX_Switch:
	lwz r5, 4(r29)
	srwi r5, r5, 16
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_WiggleShroom
TEX_WiggleShroom:
	lwz r5, -0x520(r3)
	# This sprite is pretty complex
	# The register with THIS is r29
	# before the loading function,
	# it passes it into r3, and then mr's
	# it into r30. r3 is then overwritten.
	# Then, it puts r31 into r5, r30 partly
	# into r3 and partly into r4. Why?
	# So, the possibilities for THIS are
	# r30, r3, and r4, no? In the next function,
	# r30 is stored over before our getFile, as
	# are r29/r28.
	
	srwi r5, r5, 24
	andi. r5, r5, 0xF
	b GetTexFilenameForR5



.global TEX_MantaInherit
TEX_MantaInherit:
	lwz r5, 4(r28)
	andis. r5, r5, 0x0F00
	
	or r5, r5, r0
	oris r5, r5, 0x8000
	blr



.global TEX_CheepA
TEX_CheepA:
	lwz r5, 4(r27)
	srwi r5, r5, 20
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_CheepB
TEX_CheepB:
	lwz r5, 4(r28)
	srwi r5, r5, 20
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_CheepC
TEX_CheepC:
	lwz r5, 4(r28)
	srwi r5, r5, 20
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_Midway
TEX_Midway:
	lwz r5, 4(r29)
	srwi r5, r5, 24
	andi. r5, r5, 0xFF
	b GetTexFilenameForR5


.global TEX_ColorBlock
TEX_ColorBlock:

	cmpwi r0, 0xB0
	bnelr

	subi r9, r29, 0x4E0

	lwz r5, 4(r9)
	srwi r5, r5, 28
	andi. r5, r5, 0xF
	b GetTexFilenameForR5



.global TEX_Platforms
TEX_Platforms:

	li r5, 1
	b GetTexFilenameForR5
#	cmpwi r0, 9
#	blt ReplacePlatforms
#
#	lwzx r5, r5, r0
#	blr
	

ReplacePlatforms:

	lwz r5, 4(r29)
	srwi r5, r5, 4
	andi. r5, r5, 0xF
	b GetTexFilenameForR5


.global TEX_Platform_ShifterH
TEX_Platform_ShifterH:

	stw r5, 0x504(r30)
	lwz r5, 4(r30)
	stw r5, 0x3D8(r30)
	blr

.global TEX_Platform_ShifterF
TEX_Platform_ShifterF:

	stw r4, 0x504(r30)
	lwz r4, 4(r30)
	stw r4, 0x3D8(r30)
	blr

.global TEX_Platform_ShifterL
TEX_Platform_ShifterL:

	stw r5, 0x504(r28)
	lwz r5, 4(r28)
	stw r5, 0x3D8(r28)
	blr

.global TEX_Platform_ShifterR
TEX_Platform_ShifterR:

	stw r4, 0x504(r31)
	lwz r4, 4(r31)
	stw r4, 0x3D8(r31)
	blr

.global TEX_Platform_ShifterS
TEX_Platform_ShifterS:

	stw r30, 0x4C4(r27)
	lwz r30, 4(r27)
	stw r30, 0x398(r27)
	blr

.global TEX_Platform_ShifterK
TEX_Platform_ShifterK:

	stw r4, 0x5A4(r27)
	lwz r4, 4(r27)
	stw r4, 0x478(r27)
	blr

.global TEX_Platform_ShifterW
TEX_Platform_ShifterW:

	stw r0, 0x504(r29)
	lwz r0, 4(r29)
	stw r0, 0x3D8(r29)
	blr

.global TEX_Platform_ShifterSL
TEX_Platform_ShifterSL:

	stw r4, 0x504(r29)
	lwz r4, 4(r29)
	stw r4, 0x3D8(r29)
	blr



# The small sand pieces that fall from the snowman
.global TEX_SnowmanSandToSnow
TEX_SnowmanSandToSnow:

	lwz r10, 4(r29)
	srwi r10, r10, 24
	andi. r10, r10, 0xF
	
	cmpwi r10, 0x2
	bne SnowmanSandToSnow

	lis r4, snoweffectC@h
	ori r4, r4, snoweffectC@l
	blr

SnowmanSandToSnow:
	addi r4, r4, 0x792C
	blr


# The small sand puffs that occur when it moves
.global TEX_SnowmanSandToSnowB
TEX_SnowmanSandToSnowB:

	lwz r10, 4(r30)
	srwi r10, r10, 24
	andi. r10, r10, 0xF
	
	cmpwi r10, 0x2
	bne SnowmanSandToSnowB

	lis r4, snoweffectD@h
	ori r4, r4, snoweffectD@l
	blr

SnowmanSandToSnowB:
	addi r4, r4, 0x7944
	blr


.global TEX_PokeySnowman
TEX_PokeySnowman:

	lwz r10, 4(r30)
	srwi r10, r10, 24
	andi. r10, r10, 0xF
	
	cmpwi r10, 0x2
	bne SnowmanPokey

	lwz r10, 4(r30)
	# r10 is the current height
	andi. r10, r10, 0xF
	
	# Find it
	lis r11, SnowmanTable@h
	ori r11, r11, SnowmanTable@l
	slwi r10, r10, 2	# size *= 4 (size of float)
	lfsx f0, r11, r10	# get it from the array
	
	# We should probably change ActivePhysics and maybe some other rects here
	addi r10, r30, 0x148

	lfs f10, 0(r10)
	fmuls f10, f0, f10
	stfs f10, 0(r10)

	lfs f10, 4(r10)
	fmuls f10, f0, f10
	stfs f10, 4(r10)

	lfs f10, 8(r10)
	fmuls f10, f0, f10
	stfs f10, 8(r10)

	lfs f10, 0xC(r10)
	fmuls f10, f0, f10
	stfs f10, 0xC(r10)

	blr
	

SnowmanPokey:

	lfs f0, 0x54(r31)
	blr




.global TEX_PokeySnowmanPos
TEX_PokeySnowmanPos:

	mr r3, r30
	
	lwz r10, 4(r30)
	andi. r10, r10, 0xF
	
	lis r11, SnowmanTable@h
	ori r11, r11, SnowmanTable@l
	slwi r10, r10, 2	# size *= 4 (size of float)
	lfsx f0, r11, r10	# get it from the array	
	
	lis r5, AddAmount@h
	ori r5, r5, AddAmount@l
	slwi r6, r6, 2	# size *= 4 (size of float)
	lfsx f3, r5, r6	# get it from the array

	lfs f2, 0xB0(r30)
	fmuls f3, f3, f0
	fmuls f3, f3, f0
	fmuls f3, f3, f0
	fsubs f2, f2, f3
	stfs f2, 0xB0(r30)

	blr
	
SnowmanPokeyPos:

	fsubs f0, f0, f31
	fsubs f0, f0, f31
	fsubs f1, f1, f31
	fsubs f1, f1, f31


	lfs f2, 8(r1)
	fadds f2, f2, f31
	stfs f2, 8(r1)
	blr


.global TEX_PokeyC
TEX_PokeyC:

	lwz r5, 4(r30)
	andis. r5, r5, 0xFFF0
	or r5, r5, r31
	or r5, r5, r0

	lwz r0, 0x524(r30)
	slwi r0, r0, 8
	or r5, r5, r0

	blr


.global TEX_PokeyNoSand
TEX_PokeyNoSand:
	cmpwi r3, 0x20
	blr


.global TEX_HuckitBallsInherit
TEX_HuckitBallsInherit:
	lwz r10, 4(r9)
	andis. r10, r10, 0xF00
	or r4, r4, r0
	or r4, r4, r10
	blr



.global HammerTime
HammerTime:
	lwz r8, 4(r31)

	srwi r8, r8, 8
	andi. r8, r8, 0xF

	cmpwi r8, 1
	beq ThrowBobomb

	cmpwi r8, 2
	beq ThrowGoomba

	cmpwi r8, 3
	beq ThrowSpiny

	cmpwi r8, 4
	beq ThrowCoin

	cmpwi r8, 5
	beq ThrowLemmyBall

	blr


ThrowBobomb:
	li r3, 133
	lis r4, 0x3000
	ori r4, r4, 0x0041
	blr

ThrowGoomba:
	li r3, 0x33
	li r4, 1
	blr

ThrowSpiny:
	li r3, 0x39
	li r4, 1
	blr

ThrowCoin:
	li r3, 10
	mflr r8
	mr r9, r5
	bl GenerateRandomNumber
	mr r5, r9
	
	mtlr r8
	cmpwi r3, 1
	beq ThrowItem
	
	li r3, 0x193
	li r4, 0
	li r6, 0
	li r7, 0
	blr

ThrowItem:
	li r3, 6
	mflr r8
	mr r9, r5
	bl GenerateRandomNumber
	mtlr r8
	mr r5, r9

	li r4, 0

	mr r4, r3
	li r3, 0x3C
	li r6, 0
	li r7, 0
	blr
	
	
ThrowLemmyBall:
	li r3, 0x232
	li r4, 0
	blr




.global HammerLaunch
HammerLaunch:
	mr r3, r30
	mr r10, r30
	# r31 is the new actor currently
	# r30 is self, all others are volatile
	
	lwz r5, 4(r30)
	lbz r8, 0x348(r30)
	
	srwi r5, r5, 8
	andi. r5, r5, 0xF

	cmpwi r5, 0
	beqlr

	lis r7, LaunchAngle@h
	ori r7, r7, LaunchAngle@l

#	lfs f0, 0(r7)
#	stfs f0, 0xDC(r31)
#	stfs f0, 0xE0(r31)
#	stfs f0, 0xE4(r31)
	
	# Nybble 11 is for y right now
	li r6, 0
	slwi r6, r6, 2	# size *= 4 (size of float)
	lfsx f0, r7, r6	# get it from the array	
	
	stfs f0, 0xEC(r31)
	
	cmpwi r5, 5
	beq LemmyLaunch

#	cmpwi r5, 1
#	beq BombLaunch

	li r6, 1
	slwi r6, r6, 2	# size *= 4 (size of float)

	cmpwi r8, 0
	bne FacingLeft	

	# Nybble 12 is for x right now
	lfsx f0, r7, r6	# get it from the array	
	
	stfs f0, 0xE8(r31)
	
	blr


FacingLeft:

	lis r7, LaunchAngleLeft@h
	ori r7, r7, LaunchAngleLeft@l
	
	# Nybble 12 is for x right now
	lfsx f0, r7, r6	# get it from the array	
	
	stfs f0, 0xE8(r31)
	blr


LemmyLaunch:	
	
	li r6, 2
	slwi r6, r6, 2	# size *= 4 (size of float)

	cmpwi r8, 0
	bne FacingLeft	

	# Nybble 12 is for x right now
	lfsx f0, r7, r6	# get it from the array	
	
	stfs f0, 0xE8(r31)
	blr	


BombLaunch:

	stwu sp, -0x40(sp)
	mflr r0
	stw r31, 0x2C(sp)
	stw r30, 0x28(sp)
	stw r0, 0x24(sp)
	stw r3, 0x20(sp)
	stw r4, 0x1C(sp)
	stw r5, 0x18(sp)
	stw r6, 0x10(sp)
	stw r7, 0x8(sp)
	stw r8, 0x34(sp)
	stw r9, 0x30(sp)

	mr r3, r31

	lwz r12, 0x60(r31)
	lwz r12, 0xD4(r12)
	mtctr r12
	lis r4, BombExplodeState@h
	ori r4, r4, BombExplodeState@l

	lwz r5, 4(r30)
	srwi r5, r5, 28

	mulli r5, r5, 0x40

	add r4, r4, r5
	bctrl


	lwz r31, 0x2C(sp)
	lwz r30, 0x28(sp)
	lwz r0, 0x24(sp)
	lwz r3, 0x20(sp)
	lwz r4, 0x1C(sp)
	lwz r5, 0x18(sp)
	lwz r6, 0x10(sp)
	lwz r7, 0x8(sp)
	lwz r8, 0x34(sp)
	lwz r9, 0x30(sp)
	mr r3, r30

	lis r7, LaunchAngle@h
	ori r7, r7, LaunchAngle@l

	li r6, 0
	slwi r6, r6, 2	# size *= 4 (size of float)

	lwz r8, 0x348(r30)
	cmpwi r8, 0
	bne BombFacingLeft	

	lfsx f0, r7, r6
	stfs f0, 0xE8(r31)

	mtlr r0
	addi sp, sp, 0x40
	blr

BombFacingLeft:

	lis r7, LaunchAngleLeft@h
	ori r7, r7, LaunchAngleLeft@l
	
	lfsx f0, r7, r6
	stfs f0, 0xE8(r31)
	
	mtlr r0
	addi sp, sp, 0x40
	blr




.global HammerSpin
HammerSpin:
#	sth r3, 0x100(r31)
	blr


.global HammerLeft
HammerLeft:

	lbz r8, 0x348(r10)
	lha r7, 0x102(r31)

	cmpwi r8, 0
	bne GoingLeft
	blr
	
	
GoingLeft:

	li r8, 1
	stb r8, 0x348(r31)

	li r6, 0xFD00
	add r7, r6, r7
	sth r7, 0x102(r31)
	sth r7, 0x108(r31)
	sth r7, 0xC(r1)
	blr




.global TEX_BlackFlakes
TEX_BlackFlakes:

	mflr r9

	lwz r6, 4(r23)
	srwi r6, r6, 24
	andi. r6, r6, 0xF

	cmpwi r6, 0
	beql FlakeySnow

	cmpwi r6, 1
	beql FlakeyLeavesRed

	cmpwi r6, 2
	beql FlakeyLeavesScarlet

	cmpwi r6, 3
	beql FlakeyLeavesBrown

	cmpwi r6, 4
	beql FlakeyLeavesGold

	cmpwi r6, 5
	beql FlakeyLeavesChestnut

	cmpwi r6, 6
	beql FlakeySakura

	cmpwi r6, 7
	beql FlakeyStardustWhite

	cmpwi r6, 8
	beql FlakeyStardustGold

	cmpwi r6, 9
	beql FlakeyStardustPurple

	cmpwi r6, 10
	beql FlakeyStardustMauve

	stb r5, 0x5B4(r23)
	stb r5, 0x5B8(r23)

	stb r4, 0x5B5(r23)
	stb r4, 0x5B9(r23)

	stb r3, 0x5B6(r23)
	stb r3, 0x5BA(r23)

	stb r0, 0x5B7(r23)
	stb r0, 0x5BB(r23)

	mtlr r9
	blr

FlakeySnow:
	li r5, 0xFF
	li r4, 0xFF
	li r3, 0xFF
	li r0, 0xA0
	blr

FlakeyLeavesRed:
	li r5, 0xCC
	li r4, 0x0
	li r3, 0x0
	li r0, 0xFF
	blr

FlakeyLeavesScarlet:
	li r5, 0x66
	li r4, 0x0
	li r3, 0x0
	li r0, 0xFF
	blr

FlakeyLeavesBrown:
	li r5, 0x99
	li r4, 0x66
	li r3, 0x0
	li r0, 0xFF
	blr

FlakeyLeavesGold:
	li r5, 0xFF
	li r4, 0x80
	li r3, 0x0
	li r0, 0xFF
	blr

FlakeyLeavesChestnut:
	li r5, 0x66
	li r4, 0x33
	li r3, 0x0
	li r0, 0xFF
	blr

FlakeySakura:
	li r5, 0xFF
	li r4, 0x99
	li r3, 0xCC
	li r0, 0xFF
	blr
	
FlakeyStardustWhite:
	li r5, 0xFF
	li r4, 0xFF
	li r3, 0xD0
	bl GenerateRandomNumber
	mr r0, r3
	li r3, 0xFF
	blr
	
FlakeyStardustGold:
	li r5, 0xFF
	li r4, 0x80
	li r3, 0xD0
	bl GenerateRandomNumber
	mr r0, r3
	li r3, 0x0
	blr
	
FlakeyStardustPurple:
	li r5, 0x66
	li r4, 0x00
	li r3, 0xD0
	bl GenerateRandomNumber
	mr r0, r3
	li r3, 0x99
	blr
	
FlakeyStardustMauve:
	li r5, 0xCC
	li r4, 0x99
	li r3, 0xD0
	bl GenerateRandomNumber
	mr r0, r3
	li r3, 0xCC
	blr
	
	
	
.global TEX_Flakes
TEX_Flakes:
	stwu sp, -0x20(sp)
	mflr r0
	stw r0, 0x24(sp)
	stw r3, 0x1C(sp)
	stw r5, 0x18(sp)
	stw r6, 0x14(sp)
	stw r7, 0x10(sp)
	stw r8, 0xC(sp)
	stw r9, 0x8(sp)

	lwz r5, 4(r30)
	srwi r5, r5, 24
	andi. r5, r5, 0xF

	cmpwi r5, 5
	blel LeafString

	cmpwi r5, 0
	beql SnowString

	cmpwi r5, 6
	beql PetalString

	cmpwi r5, 7
	bgel StardustString

	lwz r0, 0x24(sp)
	lwz r3, 0x1C(sp)
	lwz r5, 0x18(sp)
	lwz r6, 0x14(sp)
	lwz r7, 0x10(sp)
	lwz r8, 0xC(sp)
	lwz r9, 0x8(sp)
	mtlr r0
	addi sp, sp, 0x20
	blr


SnowString:
	lis r4, stringsnow@h
	ori r4, r4, stringsnow@l
	blr

LeafString:
	lis r4, stringleaf@h
	ori r4, r4, stringleaf@l
	blr

PetalString:
	lis r4, stringpetal@h
	ori r4, r4, stringpetal@l
	blr

StardustString:
	lis r4, stringstardust@h
	ori r4, r4, stringstardust@l
	blr


.global TEX_CrabBallBurst
TEX_CrabBallBurst:
	lwz r3, 4(r29)
	srwi r3, r3, 24
	andi. r3, r3, 0xF
	
	cmpwi r3, 0
	beq huckitRockBallEffectsA

	lis r3, snoweffectA@h
	ori r3, r3, snoweffectA@l
	blr


huckitRockBallEffectsA:
	lis r3, rockeffectA@h
	ori r3, r3, rockeffectA@l
	blr


.global TEX_CrabBallSmoke
TEX_CrabBallSmoke:
	lwz r3, 4(r29)
	srwi r3, r3, 24
	andi. r3, r3, 0xF
	
	cmpwi r3, 0
	beq huckitRockBallEffectsB

	lis r3, snoweffectB@h
	ori r3, r3, snoweffectB@l
	blr

huckitRockBallEffectsB:
	lis r3, rockeffectB@h
	ori r3, r3, rockeffectB@l
	blr



.data
BomombDir:
	.word 0x0400FC00

TexFilenameBuffer:
	.long 0,0,0,0

TexFormatString:
	.string "g3d/t%02d.brres"


.global TEX_FlakeArcs
TEX_FlakeArcs:
	.long stringsnow
	.long stringleaf
	.long stringpetal
	.long stringstardust
	.long 0

stringsnow:
	.string "env_snow"
.align 4

stringleaf:
	.string "env_leaf"
.align 4

stringpetal:
	.string "env_petal"
.align 4

stringstardust:
	.string "env_stardust"
.align 4


snoweffectA:
	.string "Wm_en_blockcloud"
.align 4

snoweffectB:
	.string "Wm_ob_iceattack"
.align 4

rockeffectA:
	.string "Wm_ob_cmnboxsmoke"
.align 4

rockeffectB:
	.string "Wm_ob_cmnrockpiece"
.align 4

snoweffectD:
	.string "Wm_ob_icebreaksmk"
.align 4

snoweffectC:
	.string "Wm_ob_icewait"
.align 4



ConvertFloat:
	.word  0x43300000,0x0,0x43300000,0x80000000

.align 4


SnowmanTable:
	.float 1.0, 1.333, 1.666, 2.0, 2.333, 2.666, 3.0, 3.333, 3.666, 4.0, 4.333, 4.666
	
AddAmount:
	.float 32.0

LaunchAngle:
	.float 4.0, 2.5, 1.5

LaunchAngleLeft:
	.float -4.0, -2.5, -1.5

.align 4



YoshiArc:
	.string "Y_TexGreen"
.align 4

Y_TexGreen:
	.string "Y_TexGreen"
.align 4
Y_TexRed:
	.string "Y_TexRed"
.align 4
Y_TexYellow:
	.string "Y_TexYellow"
.align 4
Y_TexBlue:
	.string "Y_TexBlue"
.align 4
Y_TexPurple:
	.string "Y_TexPurple"
.align 4
Y_TexOrange:
	.string "Y_TexOrange"
.align 4
Y_TexSkyBlue:
	.string "Y_TexSkyBlue"
.align 4
Y_TexBlack:
	.string "Y_TexBlack"
.align 4
Y_TexWhite:
	.string "Y_TexWhite"
.align 4

YoshiStrings:
	.long Y_TexGreen, Y_TexRed, Y_TexYellow, Y_TexBlue, Y_TexPurple, Y_TexOrange, Y_TexSkyBlue, Y_TexBlack, Y_TexWhite

.align 4