-
Notifications
You must be signed in to change notification settings - Fork 3
/
rm2c_support.patch
1919 lines (1801 loc) · 68.6 KB
/
rm2c_support.patch
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
diff --git a/Makefile b/Makefile
index 9b15874..5451aaa 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,8 @@ DEFINES :=
COMPILER_N64 ?= gcc
$(eval $(call validate-option,COMPILER_N64,ido gcc))
+# Accept RM2C level folder output
+RM2C ?= 0
# Build debug version
DEBUG ?= 0
# Build for original N64 (no pc code)
@@ -103,6 +105,16 @@ AUDIO_API ?= SDL2
# WII_U (forced if the target is Wii U), 3DS (forced if the target is 3DS), SWITCH (forced if the target is SWITCH)
CONTROLLER_API ?= SDL2
+.PHONY: RM2CPC
+RM2CPC:
+ $(info "Running ...")
+ make -j4 RM2C=1 TARGET_N64=0 DEBUG=1 NODRAWINGDISTANCE=1 GODDARD_MFACE=0 PORT_MOP_OBJS=1
+
+.PHONY: RM2CN64
+RM2CN64:
+ $(info "Running ...")
+ make -j4 RM2C=1 TARGET_N64=1 DEBUG=1 GODDARD_MFACE=0 PORT_MOP_OBJS=1
+
ifeq ($(TARGET_WII_U),1)
RENDER_API := WHB
WINDOW_API := WHB
@@ -552,7 +564,7 @@ endif
include Makefile.split
# Source code files
-LEVEL_C_FILES := $(wildcard levels/*/leveldata.c) $(wildcard levels/*/script.c) $(wildcard levels/*/geo.c)
+LEVEL_C_FILES := $(wildcard levels/*/leveldata.c) $(wildcard levels/*/script.c) $(wildcard levels/*/geo.c) $(wildcard levels/*/custom.geo.c) $(wildcard levels/*/custom.script.c) $(wildcard levels/*/custom.leveldata.c)
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(LEVEL_C_FILES)
CXX_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cpp))
S_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.s))
@@ -706,6 +718,12 @@ endif # !TARGET_PORT_CONSOLE
endif # !TARGET_N64
+# Add RM2C to flags, add var for internal name
+ifeq ($(RM2C),1)
+ CUSTOM_C_DEFINES += -DRM2C
+ RM2C_C_FLAGS = -fno-toplevel-reorder
+endif
+
# Check for Debug option
ifeq ($(DEBUG),1)
CUSTOM_C_DEFINES += -DDEBUG
@@ -884,7 +902,7 @@ LDFLAGS := -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/
# -mdivide-breaks: Uses IDO compiler like behavior for dividing by zero (Old emus such as Project64 1.6)
# -fno-jump-tables: Disables jump function tables (Wii/Wii U virtual console)
ifeq ($(COMPILER_N64),gcc)
- CFLAGS := -march=vr4300 -mfix4300 -mabi=32 -mno-shared -G 0 $(COMMON_CFLAGS) -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -I include -I $(BUILD_DIR) -I $(BUILD_DIR)/include -I src -I . -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -fno-jump-tables -ffreestanding -fwrapv -Wall -Wextra
+ CFLAGS := -march=vr4300 -mfix4300 -mabi=32 -mno-shared -G 0 $(COMMON_CFLAGS) -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -I include -I $(BUILD_DIR) -I $(BUILD_DIR)/include -I src -I . -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -fno-jump-tables -ffreestanding -fwrapv -Wall -Wextra $(RM2C_C_FLAGS)
endif
CC_CHECK += $(CUSTOM_C_DEFINES)
@@ -1056,22 +1074,22 @@ endif
ifeq ($(WINDOWS_BUILD),1)
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -Wall -Wextra -Wno-format-security
- CFLAGS := $(OPT_FLAGS) $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -fno-strict-aliasing -fwrapv
+ CFLAGS := $(OPT_FLAGS) $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -fno-strict-aliasing -fwrapv $(RM2C_C_FLAGS)
else ifeq ($(TARGET_WEB),1)
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -Wall -Wextra -Wno-format-security -s USE_SDL=2
- CFLAGS := $(OPT_FLAGS) $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -fno-strict-aliasing -fwrapv -s USE_SDL=2
+ CFLAGS := $(OPT_FLAGS) $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -fno-strict-aliasing -fwrapv -s USE_SDL=2 $(RM2C_C_FLAGS)
# Linux / Other builds below
else
CC_CHECK := $(CC) -fsyntax-only -fsigned-char $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -Wall -Wextra -Wno-format-security
- CFLAGS := $(OPT_FLAGS) $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -fno-strict-aliasing -fwrapv
+ CFLAGS := $(OPT_FLAGS) $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -fno-strict-aliasing -fwrapv $(RM2C_C_FLAGS)
endif
ifeq ($(TARGET_WII_U),1)
CC_CHECK += -ffunction-sections $(MACHDEP) -ffast-math -D__WIIU__ -D__WUT__ $(INCLUDE)
- CFLAGS += -ffunction-sections $(MACHDEP) -ffast-math -D__WIIU__ -D__WUT__ $(INCLUDE)
+ CFLAGS += -ffunction-sections $(MACHDEP) -ffast-math -D__WIIU__ -D__WUT__ $(INCLUDE) $(RM2C_C_FLAGS)
endif
ifeq ($(TARGET_N3DS),1)
@@ -1079,7 +1097,7 @@ ifeq ($(TARGET_N3DS),1)
LIBDIRS := $(CTRULIB)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
CC_CHECK += -mtp=soft -DARM11 -DosGetTime=n64_osGetTime -D_3DS -march=armv6k -mtune=mpcore -mfloat-abi=hard -mword-relocations -fomit-frame-pointer -ffast-math $(foreach dir,$(LIBDIRS),-I$(dir)/include)
- CFLAGS += -mtp=soft -DARM11 -DosGetTime=n64_osGetTime -D_3DS -march=armv6k -mtune=mpcore -mfloat-abi=hard -mword-relocations -fomit-frame-pointer -ffast-math $(foreach dir,$(LIBDIRS),-I$(dir)/include)
+ CFLAGS += -mtp=soft -DARM11 -DosGetTime=n64_osGetTime -D_3DS -march=armv6k -mtune=mpcore -mfloat-abi=hard -mword-relocations -fomit-frame-pointer -ffast-math $(foreach dir,$(LIBDIRS),-I$(dir)/include) -fno-toplevel-reorder
ifeq ($(DISABLE_N3DS_AUDIO),1)
CFLAGS += -DDISABLE_N3DS_AUDIO
@@ -1091,7 +1109,7 @@ endif
ifeq ($(TARGET_SWITCH),1)
CC_CHECK := $(CC) $(NXARCH) -fsyntax-only -fsigned-char $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -Wall -Wextra -Wno-format-security -D__SWITCH__=1
- CFLAGS := $(NXARCH) $(OPT_FLAGS) $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -fno-strict-aliasing -ftls-model=local-exec -fPIC -fwrapv -D__SWITCH__=1
+ CFLAGS := $(NXARCH) $(OPT_FLAGS) $(BACKEND_CFLAGS) $(DEF_INC_CFLAGS) -fno-strict-aliasing -ftls-model=local-exec -fPIC -fwrapv -D__SWITCH__=1 $(RM2C_C_FLAGS)
endif
CC_CHECK += $(CUSTOM_C_DEFINES)
@@ -1178,6 +1196,7 @@ MIO0TOOL = $(TOOLS_DIR)/mio0$(EXT_PREFIX)
N64CKSUM = $(TOOLS_DIR)/n64cksum$(EXT_PREFIX)
N64GRAPHICS = $(TOOLS_DIR)/n64graphics$(EXT_PREFIX)
N64GRAPHICS_CI = $(TOOLS_DIR)/n64graphics_ci$(EXT_PREFIX)
+BINPNG = $(TOOLS_DIR)/BinPNG.py
TEXTCONV = $(TOOLS_DIR)/textconv$(EXT_PREFIX)
AIFF_EXTRACT_CODEBOOK = $(TOOLS_DIR)/aiff_extract_codebook$(EXT_PREFIX)
VADPCM_ENC = $(TOOLS_DIR)/vadpcm_enc$(EXT_PREFIX)
@@ -1451,14 +1470,14 @@ endif
ifeq ($(EXTERNAL_DATA),0)
# Color Index CI8
-$(BUILD_DIR)/%.ci8: %.ci8.png
- $(call print,Converting:,$<,$@)
- $(V)$(N64GRAPHICS_CI) -i $@ -g $< -f ci8
+$(BUILD_DIR)/%.ci8.inc.c: %.ci8.png
+ $(call print,Converting CI:,$<,$@)
+ python3 $(BINPNG) $< $@ 8
# Color Index CI4
-$(BUILD_DIR)/%.ci4: %.ci4.png
- $(call print,Converting:,$<,$@)
- $(V)$(N64GRAPHICS_CI) -i $@ -g $< -f ci4
+$(BUILD_DIR)/%.ci4.inc.c: %.ci4.png
+ $(call print,Converting CI:,$<,$@)
+ python3 $(BINPNG) $< $@ 4
endif
@@ -1474,7 +1493,7 @@ $(BUILD_DIR)/%.elf: $(BUILD_DIR)/%.o
# Override for level.elf, which otherwise matches the above pattern
.SECONDEXPANSION:
$(BUILD_DIR)/levels/%/leveldata.elf: $(BUILD_DIR)/levels/%/leveldata.o $(BUILD_DIR)/bin/$$(TEXTURE_BIN).elf
- $(call print,Linking ELF file:,$<,$@)
+ $(call print,Linking Level ELF file:,$<,$@)
$(V)$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map [email protected] --just-symbols=$(BUILD_DIR)/bin/$(TEXTURE_BIN).elf -o $@ $<
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf
diff --git a/Makefile.split b/Makefile.split
index 0df73d0..b74ea58 100644
--- a/Makefile.split
+++ b/Makefile.split
@@ -87,6 +87,9 @@ ifeq ($(PORT_MOP_OBJS),1)
MOP_DIRS := Blargg_MOP Checkpoint_Flag_MOP FlipBlock_MOP Flipswap_Platform_MOP Flipswap_Platform_Border_MOP Flipswitch_Panel_MOP Green_Switchboard_MOP Green_Switchboard_Gears_MOP Moving_Rotating_Block_MOP Noteblock_MOP SandBlock_MOP Shrink_Platform_MOP Shrink_Platform_Border_MOP Spring_MOP Switchblock_MOP Switchblock_Switch_MOP
endif
+#custom leveldata rules
+$(BUILD_DIR)/levels/%/custom.leveldata.elf: SEGMENT_ADDRESS := 0x0E000000
+
# Actor Textures
AMP_CHUCKYA_TEXTURES := $(foreach dir,$(AMP_DIRS), $(wildcard actors/$(dir)/*.png))
BOBOMBS_BUBBLE_TEXTURES := $(foreach dir,$(KING_BOBOMB_DIRS),$(wildcard actors/$(dir)/*.png))
diff --git a/data/behavior_data.c b/data/behavior_data.c
index 17d3adb..f1f3814 100644
--- a/data/behavior_data.c
+++ b/data/behavior_data.c
@@ -2988,6 +2988,22 @@ const BehaviorScript bhvAnimatedTexture[] = {
END_LOOP(),
};
+#ifdef RM2C
+const BehaviorScript RM_Scroll_Texture[] = {
+ BEGIN(OBJ_LIST_GENACTOR),
+ BEGIN_LOOP(),
+ CALL_NATIVE(uv_update_scroll),
+ END_LOOP(),
+};
+
+const BehaviorScript editor_Scroll_Texture[] = {
+ BEGIN(OBJ_LIST_GENACTOR),
+ BEGIN_LOOP(),
+ CALL_NATIVE(uv_update_scroll),
+ END_LOOP(),
+};
+#endif
+
const BehaviorScript bhvBooInCastle[] = {
BEGIN(OBJ_LIST_DEFAULT),
OR_INT(oFlags, (OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO | OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)),
@@ -5987,7 +6003,11 @@ const BehaviorScript bhvPenguinRaceFinishLine[] = {
BEGIN(OBJ_LIST_DEFAULT),
OR_INT(oFlags, (OBJ_FLAG_ACTIVE_FROM_AFAR | OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)),
BEGIN_LOOP(),
+ #ifdef RM2C
+ CALL_NATIVE(bhv_penguin_race_shortcut_check_update),
+ #else
CALL_NATIVE(bhv_penguin_race_finish_line_update),
+ #endif
END_LOOP(),
};
diff --git a/include/behavior_data.h b/include/behavior_data.h
index 55b4070..5a34813 100644
--- a/include/behavior_data.h
+++ b/include/behavior_data.h
@@ -3,6 +3,10 @@
#include "types.h"
+#ifdef RM2C
+extern const BehaviorScript editor_Scroll_Texture[];
+extern const BehaviorScript RM_Scroll_Texture[];
+#endif
extern const BehaviorScript bhvStarDoor[];
extern const BehaviorScript bhvMrI[];
extern const BehaviorScript bhvMrIBody[];
diff --git a/include/segment_symbols.h b/include/segment_symbols.h
index 4e77ddf..0484579 100644
--- a/include/segment_symbols.h
+++ b/include/segment_symbols.h
@@ -14,6 +14,11 @@
DECLARE_SEGMENT(name) \
DECLARE_SEGMENT(name##_segment_7)
+#define DECLARE_CUSTOM_LEVEL_SEGMENT(name) \
+ DECLARE_SEGMENT(name) \
+ DECLARE_SEGMENT(name##_segment_E) \
+ DECLARE_SEGMENT(name##_segment_19)
+
DECLARE_ACTOR_SEGMENT(common0)
DECLARE_ACTOR_SEGMENT(common1)
DECLARE_ACTOR_SEGMENT(group0)
@@ -63,6 +68,20 @@ DECLARE_LEVEL_SEGMENT(ending)
#undef STUB_LEVEL
#undef DEFINE_LEVEL
+#define DEFINE_LEVEL(folder,_0) DECLARE_CUSTOM_LEVEL_SEGMENT(folder)
+
+#include "levels/custom_level_defines.h"
+
+#undef DEFINE_LEVEL
+
+#define MIO0_SEG(name, addr) \
+ extern u8 _##name##_mio0SegmentRomStart[]; \
+ extern u8 _##name##_mio0SegmentRomEnd[];
+
+#include "textures/skyboxes/Skybox_Rules.ld"
+
+#undef MIO0_SEG
+
DECLARE_SEGMENT(segment2_mio0)
DECLARE_SEGMENT(water_skybox_mio0)
diff --git a/include/sm64.h b/include/sm64.h
index 75de983..cbe1127 100644
--- a/include/sm64.h
+++ b/include/sm64.h
@@ -14,6 +14,14 @@
#include "surface_terrains.h"
#include "macros.h"
+//defines
+#include "game/tweaks.inc.c"
+
+#define bhvFish2 bhvManyBlueFishSpawner
+#define bhvFish3 bhvFewBlueFishSpawner
+#define bhvLargeFishGroup bhvFishSpawner
+#define MODEL_VCUTM_CHECKERBOARD_PLATFORM_SPAWNER MODEL_NONE
+
#if defined(__GNUC__) && defined(TARGET_N64)
void *memset(void *dest, int c, size_t n);
int memcmp(const void *str1, const void *str2, size_t n);
diff --git a/levels/custom_level_defines.h b/levels/custom_level_defines.h
new file mode 100644
index 0000000..451d68b
--- /dev/null
+++ b/levels/custom_level_defines.h
@@ -0,0 +1 @@
+// Replace with RM2C Output after exporting a level
diff --git a/levels/menu/script.c b/levels/menu/script.c
index 890fc64..1b6444e 100644
--- a/levels/menu/script.c
+++ b/levels/menu/script.c
@@ -55,7 +55,7 @@ const LevelScript level_main_menu_entry_1[] = {
SLEEP(/*frames*/ 16),
CLEAR_LEVEL(),
SLEEP_BEFORE_EXIT(/*frames*/ 1),
- SET_REG(/*value*/ LEVEL_CASTLE_GROUNDS),
+ SET_REG(/*value*/ START_LEVEL),
EXIT_AND_EXECUTE(/*seg*/ 0x15, _scriptsSegmentRomStart, _scriptsSegmentRomEnd, level_main_scripts_entry),
};
diff --git a/levels/scripts.c b/levels/scripts.c
index 26930ab..40b43ed 100644
--- a/levels/scripts.c
+++ b/levels/scripts.c
@@ -40,6 +40,9 @@
#define DEFINE_LEVEL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) + 3
static const LevelScript script_exec_level_table[2
#include "level_defines.h"
+ #undef DEFINE_LEVEL
+ #define DEFINE_LEVEL(_0, _1) + 3
+ #include "custom_level_defines.h"
];
#undef DEFINE_LEVEL
#undef STUB_LEVEL
@@ -51,7 +54,8 @@ static const LevelScript goto_mario_head_dizzy[4];
static const LevelScript script_L5[4];
#define STUB_LEVEL(_0, _1, _2, _3, _4, _5, _6, _7, _8)
-#define DEFINE_LEVEL(_0, _1, _2, folder, _4, _5, _6, _7, _8, _9, _10) static const LevelScript script_exec_ ## folder [4 + 1];
+#define DEFINE_LEVEL(_0, _1, _2, folder, _4, _5, _6, _7, _8, _9, _10) static const LevelScript script_exec_ ## folder [4 + 1]; \
+static const LevelScript custom_script_exec_ ## folder [4 + 1];
#include "level_defines.h"
@@ -166,17 +170,44 @@ static const LevelScript script_L5[] = {
// Include the level jumptable.
-#define STUB_LEVEL(_0, _1, _2, _3, _4, _5, _6, _7, _8)
-
-#define DEFINE_LEVEL(_0, levelenum, _2, folder, _4, _5, _6, _7, _8, _9, _10) JUMP_IF(OP_EQ, levelenum, script_exec_ ## folder),
-
static const LevelScript script_exec_level_table[] = {
GET_OR_SET(/*op*/ OP_GET, /*var*/ VAR_CURR_LEVEL_NUM),
+#define DEFINE_LEVEL(folder,levelenum) JUMP_IF(OP_EQ, levelenum, custom_script_exec_ ## folder),
+
+ #include "levels/custom_level_defines.h"
+
+#undef DEFINE_LEVEL
+
+#define STUB_LEVEL(_0, _1, _2, _3, _4, _5, _6, _7, _8)
+#define DEFINE_LEVEL(_0, levelenum, _2, folder, _4, _5, _6, _7, _8, _9, _10) JUMP_IF(OP_EQ, levelenum, script_exec_ ## folder),
#include "levels/level_defines.h"
EXIT(),
};
#undef DEFINE_LEVEL
+#ifdef RM2C
+
+#define DEFINE_LEVEL(folder,_0) \
+static const LevelScript custom_script_exec_ ## folder [] = { \
+ EXECUTE(0x19, _ ## folder ## _segment_19SegmentRomStart, _ ## folder ## _segment_19SegmentRomEnd, level_ ## folder ## _custom_entry), \
+ RETURN(), \
+};
+
+#include "levels/custom_level_defines.h"
+
+#undef DEFINE_LEVEL
+#define DEFINE_LEVEL(_0, _1, _2, folder, _4, _5, _6, _7, _8, _9, _10) \
+static const LevelScript script_exec_ ## folder [] = { \
+ EXECUTE(0x1A, _ ## folder ## SegmentRomStart, _ ## folder ## SegmentRomEnd, level_ ## folder ## _entry), \
+ RETURN(), \
+};
+
+#include "levels/level_defines.h"
+#undef STUB_LEVEL
+#undef DEFINE_LEVEL
+
+#else
+
#define DEFINE_LEVEL(_0, _1, _2, folder, _4, _5, _6, _7, _8, _9, _10) \
static const LevelScript script_exec_ ## folder [] = { \
EXECUTE(0x1A, _ ## folder ## SegmentRomStart, _ ## folder ## SegmentRomEnd, level_ ## folder ## _entry), \
@@ -187,6 +218,8 @@ static const LevelScript script_exec_ ## folder [] = { \
#undef STUB_LEVEL
#undef DEFINE_LEVEL
+#endif
+
const LevelScript script_func_global_1[] = {
LOAD_MODEL_FROM_GEO(MODEL_BLUE_COIN_SWITCH, blue_coin_switch_geo),
LOAD_MODEL_FROM_GEO(MODEL_AMP, dAmpGeo),
diff --git a/sm64.ld b/sm64.ld
index bd1560c..6cdc489 100644
--- a/sm64.ld
+++ b/sm64.ld
@@ -51,6 +51,20 @@ OUTPUT_ARCH (mips)
} \
END_SEG(name)
+#define CUSTOM_LEVEL(name) \
+ BEGIN_SEG(name##_segment_E, 0x0E000000) \
+ { \
+ BUILD_DIR/levels/name/custom.leveldata.o(.data); \
+ } \
+ END_SEG(name##_segment_E) \
+ BEGIN_SEG(name##_segment_19, 0x19000000) \
+ { \
+ BUILD_DIR/levels/name/custom.geo.o(.data); \
+ BUILD_DIR/levels/name/custom.script.o(.data); \
+ . = ALIGN(0x10); \
+ } \
+ END_SEG(name##_segment_19)
+
#define STANDARD_OBJECTS(name, segAddr, geoAddr) \
BEGIN_SEG(name##_mio0, segAddr) \
{ \
@@ -1125,6 +1139,11 @@ SECTIONS
MIO0_SEG(bidw_skybox, 0x0A000000)
MIO0_SEG(bits_skybox, 0x0A000000)
+ // Custom Skyboxes from RM2C. In base repo dummy file exists
+#ifdef RM2C
+ #include "textures/skyboxes/Skybox_Rules.ld"
+#endif
+
// Texture bins
MIO0_SEG(fire, 0x09000000)
MIO0_SEG(spooky, 0x09000000)
@@ -1148,6 +1167,11 @@ SECTIONS
#undef STUB_LEVEL
#undef DEFINE_LEVEL
+//So RM2C can partially output custom levels instead of forcing all levels to have custom content
+#define DEFINE_LEVEL(folder,_0) CUSTOM_LEVEL(folder)
+ #include "levels/custom_level_defines.h"
+#undef DEFINE_LEVEL
+
/* 4E9FA0-? [?] */
BEGIN_SEG(assets, __romPos)
{
diff --git a/src/audio/data.c b/src/audio/data.c
index 06727c0..71bdd0f 100644
--- a/src/audio/data.c
+++ b/src/audio/data.c
@@ -60,7 +60,7 @@ struct AudioSessionSettings gAudioSessionPresets[18] = {
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3F00, 0x6200, 0x4400, 0x2A80 },
{ 32000, 20, 1, 0x0800, 0x37FF, 0x7FFF, 0x3300, 0x5500, 0x4000, 0x1B00 },
#else
- { 32000, 16, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x3A00, 0x6D00, 0x4400, 0x2A00 },
+ { 32000, 16, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x5A00, 0xBD00, 0x6400, 0x4A00 },
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3A00, 0x6D00, 0x4400, 0x2A00 },
{ 32000, 16, 1, 0x1000, 0x2FFF, 0x7FFF, 0x3A00, 0x6D00, 0x4400, 0x2A00 },
{ 32000, 16, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x3A00, 0x6D00, 0x4400, 0x2A00 },
diff --git a/src/audio/data.h b/src/audio/data.h
index ee8b30b..c12d61a 100644
--- a/src/audio/data.h
+++ b/src/audio/data.h
@@ -140,8 +140,8 @@ extern OSMesgQueue *D_SH_80350FA8;
#define AUDIO_INIT_POOL_SIZE 0x2c00
#else
#define UNUSED_COUNT_80333EE8 16
-#define AUDIO_HEAP_SIZE 0x31150
-#define AUDIO_INIT_POOL_SIZE 0x2500
+#define AUDIO_HEAP_SIZE 0x3c150
+#define AUDIO_INIT_POOL_SIZE 0x3500
#endif
#ifdef VERSION_SH
diff --git a/src/audio/external.c b/src/audio/external.c
index 0053464..8d3ecbe 100644
--- a/src/audio/external.c
+++ b/src/audio/external.c
@@ -2114,10 +2114,6 @@ static u8 begin_background_music_fade(u16 fadeDuration) {
if (targetVolume != 0xff) {
seq_player_fade_to_target_volume(SEQ_PLAYER_LEVEL, fadeDuration, targetVolume);
} else {
-#if defined(VERSION_JP) || defined(VERSION_US)
- gSequencePlayers[SEQ_PLAYER_LEVEL].volume =
- sBackgroundMusicDefaultVolume[sCurrentBackgroundMusicSeqId] / 127.0f;
-#endif
seq_player_fade_to_normal_volume(SEQ_PLAYER_LEVEL, fadeDuration);
}
}
diff --git a/src/audio/load.c b/src/audio/load.c
index 7d91de0..77eb0f8 100644
--- a/src/audio/load.c
+++ b/src/audio/load.c
@@ -1086,8 +1086,8 @@ void audio_init() {
// Load bank sets for each sequence
data = LOAD_DATA(gBankSetsData);
- gAlBankSets = soundAlloc(&gAudioInitPool, 0x100);
- audio_dma_copy_immediate((uintptr_t) data, gAlBankSets, 0x100);
+ gAlBankSets = soundAlloc(&gAudioInitPool, 0x200);
+ audio_dma_copy_immediate((uintptr_t) data, gAlBankSets, 0x200);
#else
// Load headers for sounds and sequences
data = LOAD_DATA(gMusicData);
diff --git a/src/buffers/buffers.c b/src/buffers/buffers.c
index 70169a8..6b4d9a4 100644
--- a/src/buffers/buffers.c
+++ b/src/buffers/buffers.c
@@ -5,7 +5,7 @@
ALIGNED8 u8 gDecompressionHeap[0xD000];
-ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x32000)];
+ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x40000)];
ALIGNED8 u8 gIdleThreadStack[0x800];
ALIGNED8 u8 gThread3Stack[0x2000];
diff --git a/src/game/behavior_actions.c b/src/game/behavior_actions.c
index 9e155ae..de3d2e5 100644
--- a/src/game/behavior_actions.c
+++ b/src/game/behavior_actions.c
@@ -76,6 +76,9 @@ static s16 sBooHitRotations[] = {
#include "behaviors/breakable_wall.inc.c"
#include "behaviors/kickable_board.inc.c"
#include "behaviors/tower_door.inc.c"
+#ifdef RM2C
+#include "behaviors/texscroll.inc.c"
+#endif
#include "behaviors/rotating_platform.inc.c"
#include "behaviors/koopa_shell_underwater.inc.c"
#include "behaviors/warp.inc.c"
diff --git a/src/game/behavior_actions.h b/src/game/behavior_actions.h
index 9793917..ca7b61a 100644
--- a/src/game/behavior_actions.h
+++ b/src/game/behavior_actions.h
@@ -1,6 +1,16 @@
#ifndef BEHAVIOR_ACTIONS_H
#define BEHAVIOR_ACTIONS_H
+#include "types.h"
+
+struct Struct802C0DF0 {
+ u8 unk0;
+ u8 unk1;
+ u8 unk2;
+ u8 model;
+ const BehaviorScript *behavior;
+};
+
void spawn_mist_particles_variable(s32 count, s32 offsetY, f32 size);
void bhv_spawn_star_no_level_exit(u32);
void bhv_star_door_loop_2(void);
@@ -17,6 +27,7 @@ void play_penguin_walking_sound(s32 walk);
s32 update_angle_from_move_flags(s32 *angle);
void cur_obj_spawn_strong_wind_particles(s32 windSpread, f32 scale, f32 relPosX, f32 relPosY, f32 relPosZ);
+void uv_update_scroll(void);
void bhv_cap_switch_loop(void);
void bhv_tiny_star_particles_init(void);
void bhv_grindel_thwomp_loop(void);
diff --git a/src/game/behaviors/boo.inc.c b/src/game/behaviors/boo.inc.c
index 6bfcc54..333f3a0 100644
--- a/src/game/behaviors/boo.inc.c
+++ b/src/game/behaviors/boo.inc.c
@@ -575,6 +575,15 @@ static void big_boo_act_2(void) {
}
}
+#ifdef RM2C
+static void big_boo_spawn_ghost_hunt_star(void) {
+ spawn_default_star(GhostHuntBooStarPos);
+}
+
+static void big_boo_spawn_balcony_star(void) {
+ spawn_default_star(BalconyBooStarPos);
+}
+#else
static void big_boo_spawn_ghost_hunt_star(void) {
spawn_default_star(980.0f, 1100.0f, 250.0f);
}
@@ -582,11 +591,16 @@ static void big_boo_spawn_ghost_hunt_star(void) {
static void big_boo_spawn_balcony_star(void) {
spawn_default_star(700.0f, 3200.0f, 1900.0f);
}
+#endif
static void big_boo_spawn_merry_go_round_star(void) {
struct Object *merryGoRound;
+ #ifdef RM2C
+ spawn_default_star(MerryGoRoundStarPos);
+ #else
spawn_default_star(-1600.0f, -2100.0f, 205.0f);
+ #endif
merryGoRound = cur_obj_nearest_object_with_behavior(bhvMerryGoRound);
diff --git a/src/game/behaviors/bully.inc.c b/src/game/behaviors/bully.inc.c
index 6d5fc5c..1fe15b2 100644
--- a/src/game/behaviors/bully.inc.c
+++ b/src/game/behaviors/bully.inc.c
@@ -214,9 +214,17 @@ void bully_act_level_death(void) {
spawn_mist_particles();
if (o->oBullySubtype == BULLY_STYPE_CHILL) {
- spawn_default_star(130.0f, 1600.0f, -4335.0f);
+ #ifdef RM2C
+ spawn_default_star(ChillBullyStarPos);
+ #else
+ spawn_default_star(130.0f, 1600.0f, -4335.0f);
+ #endif
} else {
- spawn_default_star(0, 950.0f, -6800.0f);
+ #ifdef RM2C
+ spawn_default_star(BigBullyStarPos);
+ #else
+ spawn_default_star(0, 950.0f, -6800.0f);
+ #endif
spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvLllTumblingBridge,
0, 154, -5631, 0, 0, 0);
}
diff --git a/src/game/behaviors/exclamation_box.inc.c b/src/game/behaviors/exclamation_box.inc.c
index 714400a..866c54e 100644
--- a/src/game/behaviors/exclamation_box.inc.c
+++ b/src/game/behaviors/exclamation_box.inc.c
@@ -12,14 +12,9 @@ struct ObjectHitbox sExclamationBoxHitbox = {
/* hurtboxHeight: */ 30,
};
-struct Struct802C0DF0 {
- u8 unk0;
- u8 unk1;
- u8 unk2;
- u8 model;
- const BehaviorScript *behavior;
-};
-
+#ifdef RM2C
+extern struct Struct802C0DF0 sExclamationBoxContents[];//#include "Item_Box.inc.c"
+#else
struct Struct802C0DF0 sExclamationBoxContents[] = {
{ 0, 0, 0, MODEL_MARIOS_WING_CAP, bhvWingCap },
{ 1, 0, 0, MODEL_MARIOS_METAL_CAP, bhvMetalCap },
@@ -38,6 +33,7 @@ struct Struct802C0DF0 sExclamationBoxContents[] = {
{ 14, 0, 5, MODEL_STAR, bhvSpawnedStar },
{ 99, 0, 0, 0, NULL }
};
+#endif
void bhv_rotating_exclamation_box_loop(void) {
if (o->parentObj->oAction != 1) {
diff --git a/src/game/behaviors/eyerok.inc.c b/src/game/behaviors/eyerok.inc.c
index 89799af..13faab8 100644
--- a/src/game/behaviors/eyerok.inc.c
+++ b/src/game/behaviors/eyerok.inc.c
@@ -119,7 +119,11 @@ static void eyerok_boss_act_fight(void) {
static void eyerok_boss_act_die(void) {
if (o->oTimer == 60) {
if (cur_obj_update_dialog_with_cutscene(MARIO_DIALOG_LOOK_UP, DIALOG_FLAG_NONE, CUTSCENE_DIALOG, DIALOG_118)) {
+ #ifdef RM2C
+ spawn_default_star(EyerockStarPos);
+ #else
spawn_default_star(0.0f, -900.0f, -3700.0f);
+ #endif
} else {
o->oTimer--;
}
diff --git a/src/game/behaviors/fire_piranha_plant.inc.c b/src/game/behaviors/fire_piranha_plant.inc.c
index be1ea9c..dd9a147 100644
--- a/src/game/behaviors/fire_piranha_plant.inc.c
+++ b/src/game/behaviors/fire_piranha_plant.inc.c
@@ -69,7 +69,11 @@ static void fire_piranha_plant_act_hide(void) {
if ((u16)(o->oBehParams >> 16) != 0 && o->oHealth == 0) {
if (++sNumKilledFirePiranhaPlants == 5) {
+ #ifdef RM2C
+ spawn_default_star(BigPiranhasStarPos);
+ #else
spawn_default_star(-6300.0f, -1850.0f, -6300.0f);
+ #endif
}
obj_die_if_health_non_positive();
diff --git a/src/game/behaviors/hidden_star.inc.c b/src/game/behaviors/hidden_star.inc.c
index 9dd2c1e..033bb5c 100644
--- a/src/game/behaviors/hidden_star.inc.c
+++ b/src/game/behaviors/hidden_star.inc.c
@@ -59,7 +59,7 @@ void bhv_bowser_course_red_coin_star_loop(void) {
switch (o->oAction) {
case 0:
- if (o->oHiddenStarTriggerCounter == 8) {
+ if (o->oHiddenStarTriggerCounter == REDS_REQ) {
o->oAction = 1;
}
break;
diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c
index f867cdf..e2f7133 100644
--- a/src/game/behaviors/king_bobomb.inc.c
+++ b/src/game/behaviors/king_bobomb.inc.c
@@ -30,7 +30,7 @@ void king_bobomb_act_0(void) {
gSecondCameraFocus = o;
cur_obj_init_animation_with_sound(5);
cur_obj_set_pos_to_home();
- o->oHealth = 3;
+ o->oHealth = KING_BOMB_HEALTH;
if (cur_obj_can_mario_activate_textbox_2(500.0f, 100.0f)) {
o->oSubAction++;
@@ -76,8 +76,8 @@ void king_bobomb_act_2(void) {
}
if (o->oKingBobombUnk108 == 0) {
- o->oForwardVel = 3.0f;
- cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x100);
+ o->oForwardVel = KING_BOMB_FVEL;
+ cur_obj_rotate_yaw_toward(o->oAngleToMario, KING_BOMB_YAWVEL);
} else {
o->oForwardVel = 0.0f;
o->oKingBobombUnk108--;
@@ -214,11 +214,10 @@ void king_bobomb_act_7(void) {
spawn_mist_particles_variable(0, 0, 200.0f);
spawn_triangle_break_particles(20, MODEL_DIRT_ANIMATION, 3.0f, 4);
cur_obj_shake_screen(SHAKE_POS_SMALL);
-#ifndef VERSION_JP
- cur_obj_spawn_star_at_y_offset(2000.0f, 4500.0f, -4500.0f, 200.0f);
+#ifdef RM2C
+ cur_obj_spawn_star_at_y_offset(KingBobOmbStarPos, 200.0f);
#else
- o->oPosY += 100.0f;
- spawn_default_star(2000.0f, 4500.0f, -4500.0f);
+ cur_obj_spawn_star_at_y_offset(2000.0f, 4500.0f, -4500.0f, 200.0f);
#endif
o->oAction = 8;
}
diff --git a/src/game/behaviors/klepto.inc.c b/src/game/behaviors/klepto.inc.c
index 3cf3369..48c93fe 100644
--- a/src/game/behaviors/klepto.inc.c
+++ b/src/game/behaviors/klepto.inc.c
@@ -377,7 +377,11 @@ void bhv_klepto_update(void) {
|| o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_TRANSPARENT_STAR
#endif
) {
+ #ifdef RM2C
+ spawn_default_star(KleptoStarPos);
+ #else
spawn_default_star(-5550.0f, 300.0f, -930.0f);
+ #endif
}
o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_NOTHING;
diff --git a/src/game/behaviors/koopa.inc.c b/src/game/behaviors/koopa.inc.c
index 04b345c..a1ec1fa 100644
--- a/src/game/behaviors/koopa.inc.c
+++ b/src/game/behaviors/koopa.inc.c
@@ -60,10 +60,19 @@ struct KoopaTheQuickProperties {
/**
* Properties for the BoB race and the THI race.
*/
+#ifdef RM2C
+//grab trajectory from Trajectories.inc.c and star pos from star_pos.inc.c
+static struct KoopaTheQuickProperties sKoopaTheQuickProperties[] = {
+ { DIALOG_005, DIALOG_007, KoopaBoB_path, KoopaBoBStarPos },
+ { DIALOG_009, DIALOG_031, KoopaTHI_path, KoopaTHIStarPos }
+};
+#else
+//vanilla
static struct KoopaTheQuickProperties sKoopaTheQuickProperties[] = {
{ DIALOG_005, DIALOG_007, bob_seg7_trajectory_koopa, { 3030, 4500, -4600 } },
{ DIALOG_009, DIALOG_031, thi_seg7_trajectory_koopa, { 7100, -1300, -6000 } },
};
+#endif
/**
* Initialization function.
@@ -618,11 +627,11 @@ static void koopa_the_quick_act_race(void) {
&& (o->oPathedPrevWaypointFlags & WAYPOINT_MASK_00FF) < 28) {
// Move faster if mario has already finished the race or
// cheated by shooting from cannon
- o->oKoopaAgility = 8.0f;
+ o->oKoopaAgility = KOOPA_SPEED_RACE_END;
} else if (o->oKoopaTheQuickRaceIndex != KOOPA_THE_QUICK_BOB_INDEX) {
- o->oKoopaAgility = 6.0f;
+ o->oKoopaAgility = KOOPA_SPEED_THI;
} else {
- o->oKoopaAgility = 4.0f;
+ o->oKoopaAgility = KOOPA_SPEED_BOB;
}
obj_forward_vel_approach(o->oKoopaAgility * 6.0f * downhillSteepness,
diff --git a/src/game/behaviors/mips.inc.c b/src/game/behaviors/mips.inc.c
index 0aed1ec..17216da 100644
--- a/src/game/behaviors/mips.inc.c
+++ b/src/game/behaviors/mips.inc.c
@@ -12,7 +12,7 @@ void bhv_mips_init(void) {
u8 starFlags = save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_NONE));
// If the player has >= 15 stars and hasn't collected first MIPS star...
- if (save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= 15
+ if (save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= MIPS1_STAR_REQ
&& !(starFlags & SAVE_FLAG_TO_STAR_FLAG(SAVE_FLAG_COLLECTED_MIPS_STAR_1))) {
o->oBehParams2ndByte = 0;
#ifndef VERSION_JP
@@ -20,7 +20,7 @@ void bhv_mips_init(void) {
#endif
}
// If the player has >= 50 stars and hasn't collected second MIPS star...
- else if (save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= 50
+ else if (save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1) >= MIPS2_STAR_REQ
&& !(starFlags & SAVE_FLAG_TO_STAR_FLAG(SAVE_FLAG_COLLECTED_MIPS_STAR_2))) {
o->oBehParams2ndByte = 1;
#ifndef VERSION_JP
diff --git a/src/game/behaviors/mr_i.inc.c b/src/game/behaviors/mr_i.inc.c
index f50fb43..8463bfe 100644
--- a/src/game/behaviors/mr_i.inc.c
+++ b/src/game/behaviors/mr_i.inc.c
@@ -140,7 +140,11 @@ void mr_i_act_3(void) {
o->oMrIScale = sp1C * 0.6;
if (o->oBehParams2ndByte != 0) {
o->oPosY += 100.0f;
+ #ifdef RM2C
+ spawn_default_star(MrIStarPos);
+ #else
spawn_default_star(1370, 2000.0f, -320.0f);
+ #endif
obj_mark_for_deletion(o);
} else {
cur_obj_spawn_loot_blue_coin();
diff --git a/src/game/behaviors/platform_on_track.inc.c b/src/game/behaviors/platform_on_track.inc.c
index b7c72db..af36e68 100644
--- a/src/game/behaviors/platform_on_track.inc.c
+++ b/src/game/behaviors/platform_on_track.inc.c
@@ -18,6 +18,19 @@ static Collision const *sPlatformOnTrackCollisionModels[] = {
/**
* Paths for the different instances of these platforms.
*/
+#ifdef RM2C
+static void const *sPlatformOnTrackPaths[] = {
+ rr_seg7_trajectory_0702EC3C_RM2C_path,
+ rr_seg7_trajectory_0702ECC0_RM2C_path,
+ ccm_seg7_trajectory_0701669C_RM2C_path,
+ bitfs_seg7_trajectory_070159AC_RM2C_path,
+ hmc_seg7_trajectory_0702B86C_RM2C_path,
+ lll_seg7_trajectory_0702856C_RM2C_path,
+ lll_seg7_trajectory_07028660_RM2C_path,
+ rr_seg7_trajectory_0702ED9C_RM2C_path,
+ rr_seg7_trajectory_0702EEE0_RM2C_path,
+};
+#else
static Trajectory const *sPlatformOnTrackPaths[] = {
rr_seg7_trajectory_0702EC3C,
rr_seg7_trajectory_0702ECC0,
@@ -29,6 +42,7 @@ static Trajectory const *sPlatformOnTrackPaths[] = {
rr_seg7_trajectory_0702ED9C,
rr_seg7_trajectory_0702EEE0,
};
+#endif
/**
* Despawn all track balls and enter the init action.
diff --git a/src/game/behaviors/racing_penguin.inc.c b/src/game/behaviors/racing_penguin.inc.c
index 21639ec..1cf0148 100644
--- a/src/game/behaviors/racing_penguin.inc.c
+++ b/src/game/behaviors/racing_penguin.inc.c
@@ -38,8 +38,13 @@ static void racing_penguin_act_show_init_text(void) {
child = cur_obj_nearest_object_with_behavior(bhvPenguinRaceShortcutCheck);
child->parentObj = o;
+ #ifdef RM2C
o->oPathedStartWaypoint = o->oPathedPrevWaypoint =
+ segmented_to_virtual(ccm_seg7_trajectory_penguin_race_RM2C_path);
+ #else
+ o->oPathedStartWaypoint = o->oPathedPrevWaypoint =
segmented_to_virtual(ccm_seg7_trajectory_penguin_race);
+ #endif
o->oPathedPrevWaypointFlags = 0;
o->oAction = RACING_PENGUIN_ACT_PREPARE_FOR_RACE;
@@ -147,8 +152,8 @@ static void racing_penguin_act_show_final_text(void) {
o->oTimer = 0;
}
} else if (o->oRacingPenguinMarioWon) {
-#ifdef VERSION_JP
- spawn_default_star(-7339.0f, -5700.0f, -6774.0f);
+#ifdef RM2C
+ cur_obj_spawn_star_at_y_offset(RacingPenguinStarPos, 200.0f);
#else
cur_obj_spawn_star_at_y_offset(-7339.0f, -5700.0f, -6774.0f, 200.0f);
#endif
@@ -194,8 +199,16 @@ void bhv_penguin_race_finish_line_update(void) {
}
}
+//This is used as a 2d camera object in hacks
+#ifdef RM2C
+void bhv_penguin_race_shortcut_check_update(void) {
+ gMarioState->pos[0] = 0.0f;
+ gCurrentArea->camera->mode = CAMERA_MODE_2_DIRECTIONS;
+}
+#else
void bhv_penguin_race_shortcut_check_update(void) {
if (o->oDistanceToMario < 500.0f) {
o->parentObj->oRacingPenguinMarioCheated = TRUE;
}
}
+#endif
diff --git a/src/game/behaviors/red_coin.inc.c b/src/game/behaviors/red_coin.inc.c
index 6c4ef8e..89838d5 100644
--- a/src/game/behaviors/red_coin.inc.c
+++ b/src/game/behaviors/red_coin.inc.c
@@ -61,7 +61,7 @@ void bhv_red_coin_loop(void) {
create_sound_spawner(SOUND_GENERAL_RED_COIN);
#endif
// Spawn the orange number counter, as long as it isn't the last coin.
- if (o->parentObj->oHiddenStarTriggerCounter != 8) {
+ if (o->parentObj->oHiddenStarTriggerCounter < REDS_REQ) {
spawn_orange_number(o->parentObj->oHiddenStarTriggerCounter, 0, 0, 0);
}
diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c
index ed74da3..f961032 100644
--- a/src/game/behaviors/spawn_star.inc.c
+++ b/src/game/behaviors/spawn_star.inc.c
@@ -172,7 +172,7 @@ void bhv_hidden_red_coin_star_loop(void) {
gRedCoinsCollected = o->oHiddenStarTriggerCounter;
switch (o->oAction) {
case 0:
- if (o->oHiddenStarTriggerCounter == 8) {
+ if (o->oHiddenStarTriggerCounter == REDS_REQ) {
o->oAction = 1;
}
break;
diff --git a/src/game/behaviors/texscroll.inc.c b/src/game/behaviors/texscroll.inc.c
new file mode 100644
index 0000000..2409491
--- /dev/null
+++ b/src/game/behaviors/texscroll.inc.c
@@ -0,0 +1,146 @@
+#include "engine/math_util.h"
+
+/* SCROLLING BHVS */
+#define SCROLL_X 0
+#define SCROLL_Y 1
+#define SCROLL_Z 2
+#define SCROLL_UV_X 4
+#define SCROLL_UV_Y 5
+
+/* SCROLLING TYPES */
+#define MODE_SCROLL_UV 0
+#define MODE_SCROLL_SINE 1
+#define MODE_SCROLL_JUMP 2
+
+// typedef struct {
+// #ifndef GBI_FLOATS
+ // short ob[3]; /* x, y, z */
+// #else
+ // float ob[3]; /* x, y, z */
+// #endif
+ // unsigned short flag;
+ // short tc[2]; /* texture coord */
+ // signed char n[3]; /* normal */
+ // unsigned char a; /* alpha */
+// } Vtx_tn;
+
+// typedef union {
+ // Vtx_t v; /* Use this one for colors */
+ // Vtx_tn n; /* Use this one for normals */
+ // long long int force_structure_alignment;
+// } Vtx;
+extern Vtx *ScrollTargets[];
+#ifndef F3DEX_GBI_2E
+static void shift_UV_NORMAL(u32 vert, u16 vertcount, s16 speed, u16 bhv) {
+ u16 overflownum = 0x1000;
+ u32 i;
+ Vtx *verts = segmented_to_virtual(ScrollTargets[vert]);
+ u16 *Varray;
+ s16 correction=0;
+ if (verts[0].n.flag * absi(speed) > overflownum) {
+ correction = (u16) overflownum * signum_positive(speed);
+ verts[0].n.flag = 0;
+ }
+ for (i = 0; i < vertcount; i++) {
+ Varray = &verts[i].n;
+ if (correction==0)
+ Varray[bhv] += speed;
+ else
+ Varray[bhv] -= correction;
+ }
+ verts[0].n.flag++;
+}
+
+static void shift_UV_SINE(u32 vert, u16 vertcount, s16 speed, u16 bhv) {
+ u32 i;
+ Vtx *verts = segmented_to_virtual(ScrollTargets[vert]);
+ u16 cycle = o->oFaceAngleRoll*180/ 0x8000;
+ u16 *Varray;
+ for (i = 0; i < vertcount; i++) {
+ Varray = &verts[i].n;
+ Varray[bhv] += sins(verts[0].n.flag) * speed;
+ }
+ verts[0].n.flag += cycle * 0x20;
+}
+
+static void shift_uv(u8 scrollbhv, u32 vert, u16 vertcount, s16 spd, u16 scrolltype) {
+ switch (scrollbhv) {
+ case MODE_SCROLL_UV:
+ shift_UV_NORMAL(vert, vertcount, spd, scrolltype);
+ break;
+ case MODE_SCROLL_SINE:
+ case MODE_SCROLL_JUMP:
+ shift_UV_SINE(vert, vertcount, spd, scrolltype);
+ break;
+ }
+}
+#else
+
+static void shift_UV_NORMAL(u32 vert, u16 vertcount, s16 speed, u16 bhv) {
+ u16 overflownum = 0x1000;
+ u16 i;
+ Vtx *verts = ScrollTargets[vert];
+ u16 correction=0;
+ u16 offset=o->oFaceAnglePitch*180/ 0x8000;
+ vertcount=vertcount+(vertcount-1+offset)/15; // PC has padding between vert arrays that I need to compensate for
+ if (verts[0].n.flag * absi(speed) > overflownum) {
+ correction = overflownum * signum_positive(speed);
+ verts[0].n.flag = 0;
+ }