diff --git a/Makefile b/Makefile index 22235d2b6..4cd551163 100644 --- a/Makefile +++ b/Makefile @@ -154,6 +154,7 @@ ifeq ($(filter clean distclean,$(MAKECMDGOALS)),) endif + #==============================================================================# # Universal Dependencies # #==============================================================================# @@ -187,6 +188,7 @@ ifeq ($(filter clean distclean print-%,$(MAKECMDGOALS)),) endif + #==============================================================================# # Target Executable and Sources # #==============================================================================# @@ -335,6 +337,8 @@ endif # Prevent a crash with -sopt export LANG := C + + #==============================================================================# # Miscellaneous Tools # #==============================================================================# @@ -510,6 +514,7 @@ COURSE_PACKED_DL := $(foreach dir,$(COURSE_DIRS),$(BUILD_DIR)/$(dir)/packed_dl.i $(V)$(DLPACKER) $< $@ + #==============================================================================# # Course Geography Generation # #==============================================================================# @@ -530,6 +535,8 @@ COURSE_MODEL_TARGETS := $(foreach dir,$(COURSE_DIRS),$(BUILD_DIR)/$(dir)/model.i %/model.inc.mio0.s: %/model.inc.mio0 %/packed_dl.inc.bin printf ".include \"macros.inc\"\n\n.section .data\n\n.balign 4\n\n.incbin \"$(@D)/model.inc.mio0\"\n\n.balign 4\n\nglabel d_course_$(lastword $(subst /, ,$*))_packed\n\n.incbin \"$(@D)/packed_dl.inc.bin\"\n\n.balign 0x10\n" > $@ + + #==============================================================================# # Course Data Generation # #==============================================================================# @@ -609,8 +616,10 @@ ifeq ($(COMPILER),ido) $(BUILD_DIR)/src/audio/external.o: OPT_FLAGS := -O2 -framepointer endif + + #==============================================================================# -# Compile Trophy Model(s) and Podium Models # +# Compile Trophy and Podium Models # #==============================================================================# $(BUILD_DIR)/src/trophy_model.inc.mio0.o: $(BUILD_DIR)/src/trophy_model.inc.o @@ -621,6 +630,8 @@ $(BUILD_DIR)/src/trophy_model.inc.mio0.o: $(BUILD_DIR)/src/trophy_model.inc.o printf ".include \"macros.inc\"\n\n.data\n\n.balign 4\n\nglabel trophy_model\n\n.incbin \"build/us/src/trophy_model.inc.mio0\"\n\n.balign 16\nglabel data_821D10_end\n" > build/us/src/trophy_model.inc.mio0.s $(AS) $(ASFLAGS) -o $(BUILD_DIR)/src/trophy_model.inc.mio0.o $(BUILD_DIR)/src/trophy_model.inc.mio0.s + + #==============================================================================# # Compile Startup Logo # #==============================================================================# @@ -633,6 +644,8 @@ $(BUILD_DIR)/src/startup_logo.inc.mio0.o: src/startup_logo.inc.c printf ".include \"macros.inc\"\n\n.data\n\n\n\n.balign 4\n\n\nglabel startup_logo\n\n.incbin \"build/us/src/startup_logo.inc.mio0\"\n\n.balign 16\n\nglabel data_825800_end\n" > build/us/src/startup_logo.inc.mio0.s $(AS) $(ASFLAGS) -o $(BUILD_DIR)/src/startup_logo.inc.mio0.o $(BUILD_DIR)/src/startup_logo.inc.mio0.s + + #==============================================================================# # Compile Common Textures # #==============================================================================# @@ -652,6 +665,8 @@ LDFLAGS += -R $(BUILD_DIR)/src/common_textures.inc.elf %/common_textures.inc.mio0.s: %/common_textures.inc.mio0 printf ".include \"macros.inc\"\n\n.section .data\n\n.balign 4\n\n.incbin \"$<\"\n\n" > $@ + + #==============================================================================# # Finalize and Link # #==============================================================================# diff --git a/asm/bss_after_diskinit.s b/asm/bss_after_diskinit.s deleted file mode 100644 index 59be09fc1..000000000 --- a/asm/bss_after_diskinit.s +++ /dev/null @@ -1,6 +0,0 @@ -.include "macros.inc" - -.section .bss - -glabel D_801978D0 -.skip 12 diff --git a/asm/bss_after_ostimer.s b/asm/bss_after_ostimer.s deleted file mode 100644 index f62daeb24..000000000 --- a/asm/bss_after_ostimer.s +++ /dev/null @@ -1,6 +0,0 @@ -.include "macros.inc" - -.section .bss - -glabel D_801976A0 -.skip 432 diff --git a/asm/bss_main_audio2.s b/asm/bss_main_audio2.s deleted file mode 100644 index d797ca5cf..000000000 --- a/asm/bss_main_audio2.s +++ /dev/null @@ -1,6 +0,0 @@ -.include "macros.inc" - -.section .bss - -glabel D_80194040 -.skip 16 diff --git a/asm/os/__osException.s b/asm/os/__osException.s index b7c7c2f7d..b243c45a6 100644 --- a/asm/os/__osException.s +++ b/asm/os/__osException.s @@ -19,6 +19,10 @@ glabel jpt_800F3A20 .word L800D1420, L800D15B4, L800D13E8, L800D13F4 .word L800D1400 +.section .bss +glabel D_801976A0 +.skip 432 + .section .text, "ax" diff --git a/courses/battle/block_fort/model.inc.c b/courses/battle/block_fort/model.inc.c index 8d822947f..ebd1f2e1b 100644 --- a/courses/battle/block_fort/model.inc.c +++ b/courses/battle/block_fort/model.inc.c @@ -1092,31 +1092,3 @@ mk64_Vtx d_course_block_fort_vertex[] = { {{ 781, 83, 390}, { 0, 0}, {0x00, 0x01, 0x00, 0x00}}, }; - -/* -int d_course_block_fort_packed[] = { - gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), - gsSPTexture(qu016(1.52588e-05), qu016(1.52588e-05), 0, G_TX_RENDERTILE, G_OFF), - gsSPVertex(0x04000000, 3, 0), - gsSP2Triangles(0, 1, 2, 0, 0, 0, 0, 0), - gsSPTexture(qu016(0.999985), qu016(0.999985), 0, G_TX_RENDERTILE, G_ON), - gsDPSetCombineMode(G_CC_MODULATEIA, G_CC_MODULATEIA), - gsDPSetRenderMode(G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2), - gsDPTileSync(), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0x0000, G_TX_RENDERTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, 5, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 5, G_TX_NOLOD), - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, qu102(31), qu102(31)), - gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, 0x05000800), - gsDPTileSync(), - gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0x0000, G_TX_LOADTILE, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD), - gsDPLoadSync(), - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 1023, 256), - gsSPVertex(0x04000030, 20, 0), - gsSP2Triangles(0, 1, 2, 0, 0, 2, 3, 0), - gsSP2Triangles(4, 5, 6, 0, 4, 6, 7, 0), - gsSP2Triangles(8, 4, 7, 0, 9, 10, 11, 0), - gsSP2Triangles(9, 11, 12, 0, 13, 10, 9, 0), - gsSP2Triangles(11, 14, 12, 0, 15, 16, 17, 0), - gsSP2Triangles(15, 17, 18, 0, 5, 19, 6, 0), - gsSPEndDisplayList(), -}; -*/ diff --git a/include/debug.h b/include/debug.h index ec3c10cae..de202bfbb 100644 --- a/include/debug.h +++ b/include/debug.h @@ -19,7 +19,7 @@ #define CHARACTER_BUFFER_SIZE 200 // size of the string buffer -/** +/** * This is the position of the displayed text. * It's calculated from the top left. */ diff --git a/include/segment_symbols.h b/include/segment_symbols.h index df44eb46d..c65aad3fc 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -1,6 +1,8 @@ #ifndef SEGMENT_SYMBOLS_H #define SEGMENT_SYMBOLS_H +extern u8 _mainSegNoloadEnd[]; + extern u8 _code_80280000SegmentStart[]; extern u8 _code_80280000SegmentRomStart[]; extern u8 _code_80280000SegmentRomEnd[]; diff --git a/mk64.ld b/mk64.ld index 0eeb99682..162890da0 100644 --- a/mk64.ld +++ b/mk64.ld @@ -355,7 +355,7 @@ SECTIONS #endif BUILD_DIR/asm/bss_main_audio.o(.bss); BUILD_DIR/src/audio/port_eu.o(.bss); - BUILD_DIR/asm/bss_main_audio2.o(.bss); + BUILD_DIR/src/os/osInitialize.o(.bss); BUILD_DIR/src/os/osCreateViManager.o(.bss); BUILD_DIR/src/os/osCreatePiManager.o(.bss); BUILD_DIR/src/os/osSetEventMesg.o(.bss); @@ -369,9 +369,8 @@ SECTIONS BUILD_DIR/src/os/__osPiCreateAccessQueue.o(.bss); BUILD_DIR/src/os/__osSiCreateAccessQueue.o(.bss); BUILD_DIR/src/os/osEepromWrite.o(.bss); - BUILD_DIR/asm/bss_after_ostimer.o(.bss); + BUILD_DIR/asm/os/__osException.o(.bss); BUILD_DIR/src/os/osLeoDiskInit.o(.bss); - BUILD_DIR/asm/bss_after_diskinit.o(.bss); } END_NOLOAD(main) diff --git a/src/actors.c b/src/actors.c index 77fcc3c10..3d5c009ee 100644 --- a/src/actors.c +++ b/src/actors.c @@ -564,29 +564,9 @@ void update_obj_kiwano_fruit(struct KiwanoFruit *fruit) { } } -void update_obj_paddle_wheel(struct PaddleWheelBoat *boat) { - boat->wheelRot += 0x38E; -} +#include "actors/boat.inc.c" -// wheels -void update_obj_train_engine(struct TrainCar *arg0) { - arg0->wheelRot -= 0x666; - - if (arg0->unk_08 != 0.0f) { - arg0->unk_08 = 0.0f; - func_800C9D80(arg0->pos, arg0->velocity, 0x51018000); - } -} - -// wheels -void update_obj_train_car1(struct TrainCar *tender) { - tender->wheelRot -= 0x4FA; -} - -// wheels -void update_obj_train_car2(struct TrainCar *arg0) { - arg0->wheelRot -= 0x666; -} +#include "actors/train.inc.c" void update_obj_piranha_plant(struct PiranhaPlant *arg0) { if ((arg0->flags & 0x800) == 0) { @@ -1981,121 +1961,10 @@ void place_palm_trees(struct ActorSpawnData *spawnData) { } } -void func_8029CF0C(struct ActorSpawnData *spawnData, struct FallingRock *rock) { - s32 segment = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); - struct ActorSpawnData *temp_v0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); - Vec3s sp24 = {60, 120, 180}; - temp_v0 += rock->unk_06; - rock->respawnTimer = sp24[rock->unk_06]; // * 2 - rock->pos[0] = (f32) temp_v0->pos[0] * gCourseDirection; - rock->pos[1] = (f32) temp_v0->pos[1] + 10.0f; - rock->pos[2] = (f32) temp_v0->pos[2]; - vec3f_set(rock->velocity, 0, 0, 0); - vec3s_set(rock->rot, 0, 0, 0); -} +#include "actors/falling_rocks.inc.c" -void place_falling_rocks(struct ActorSpawnData *spawnData) { - s32 addr = SEGMENT_NUMBER2(spawnData); - s32 offset = SEGMENT_OFFSET(spawnData); - // Casting this to prevent warning does not work. - struct ActorSpawnData *temp_s0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr] + offset); - struct FallingRock *temp_v1; - Vec3f startingPos; - Vec3f startingVelocity; - Vec3s startingRot; - s16 temp; - - while (temp_s0->pos[0] != -0x8000) { - startingPos[0] = temp_s0->pos[0] * gCourseDirection; - startingPos[1] = temp_s0->pos[1] + 10.0f; - startingPos[2] = temp_s0->pos[2]; - vec3f_set(startingVelocity, 0, 0, 0); - vec3s_set(startingRot, 0, 0, 0); - temp = addActorToEmptySlot(startingPos, startingRot, startingVelocity, ACTOR_FALLING_ROCK); - temp_v1 = (struct FallingRock *) &gActorList[temp]; - - temp_v1->unk_06 = temp_s0->someId; - func_802AAAAC((Collision *) &temp_v1->unk30); - temp_s0++; - } -} - -void update_obj_falling_rocks(struct FallingRock *rock) { - Vec3f unkVec; - f32 pad0; - f32 pad1; - - if (rock->respawnTimer != 0) { - rock->respawnTimer -= 1; - return; - } - if (rock->pos[1] < D_8015F8E4) { - func_8029CF0C(d_course_choco_mountain_falling_rock_spawns, rock); - } - rock->rot[0] += (s16) ((rock->velocity[2] * 5461.0f) / 20.0f); - rock->rot[2] += (s16) ((rock->velocity[0] * 5461.0f) / 20.0f); - rock->velocity[1] -= 0.1; - if (rock->velocity[1] < (-2.0f)) { - rock->velocity[1] = -2.0f; - } - rock->pos[0] += rock->velocity[0]; - rock->pos[1] += rock->velocity[1]; - rock->pos[2] += rock->velocity[2]; - pad1 = rock->velocity[1]; - func_802ADDC8(&rock->unk30, 10.0f, rock->pos[0], rock->pos[1], rock->pos[2]); - pad0 = rock->unk30.unk3C[2]; - if (pad0 < 0.0f) { - unkVec[0] = -rock->unk30.unk60[0]; - unkVec[1] = -rock->unk30.unk60[1]; - unkVec[2] = -rock->unk30.unk60[2]; - rock->pos[0] += unkVec[0] * rock->unk30.unk3C[2]; - rock->pos[1] += unkVec[1] * rock->unk30.unk3C[2]; - rock->pos[2] += unkVec[2] * rock->unk30.unk3C[2]; - func_802AC114(unkVec, pad0, rock->velocity, 2.0f); - rock->velocity[1] = -1.2f * pad1; - func_800C98B8(rock->pos, rock->velocity, 0x1900800FU); - } - pad0 = rock->unk30.unk3C[0]; - if (pad0 < 0.0f) { - unkVec[1] = -rock->unk30.unk48[1]; - if (unkVec[1] == 0.0f) { - rock->velocity[1] *= -1.2f; - return; - } - else { - unkVec[0] = -rock->unk30.unk48[0]; - unkVec[2] = -rock->unk30.unk48[2]; - rock->pos[0] += unkVec[0] * rock->unk30.unk3C[0]; - rock->pos[1] += unkVec[1] * rock->unk30.unk3C[0]; - rock->pos[2] += unkVec[2] * rock->unk30.unk3C[0]; - func_802AC114(unkVec, pad0, rock->velocity, 2.0f); - rock->velocity[1] = -1.2f * pad1; - func_800C98B8(rock->pos, rock->velocity, 0x1900800FU); - } - } - pad0 = rock->unk30.unk3C[1]; - if (pad0 < 0.0f) { - unkVec[1] = -rock->unk30.unk54[1]; - if (unkVec[1] == 0.0f) { - rock->velocity[1] *= -1.2f; - } - else { - unkVec[0] = -rock->unk30.unk54[0]; - unkVec[2] = -rock->unk30.unk54[2]; - rock->pos[0] += unkVec[0] * rock->unk30.unk3C[1]; - rock->pos[1] += unkVec[1] * rock->unk30.unk3C[1]; - rock->pos[2] += unkVec[2] * rock->unk30.unk3C[1]; - pad1 = rock->velocity[1]; - func_802AC114(unkVec, pad0, rock->velocity, 2.0f); - rock->velocity[1] = -1.2f * pad1; - func_800C98B8(rock->pos, rock->velocity, 0x1900800FU); - } - } -} - -// This function may be better named "init_trees_cacti_shrubs" -void place_segment_06(struct ActorSpawnData *arg0) { +// Trees, cacti, shrubs, etc. +void spawn_foliage(struct ActorSpawnData *arg0) { UNUSED s32 pad[4]; Vec3f position; Vec3f velocity; @@ -2269,7 +2138,7 @@ void place_course_actors(void) { gNumPermanentActors = 0; switch (gCurrentCourseId) { case COURSE_MARIO_RACEWAY: - place_segment_06(d_course_mario_raceway_tree_spawns); + spawn_foliage(d_course_mario_raceway_tree_spawns); place_piranha_plants(d_course_mario_raceway_piranha_plant_spawns); place_all_item_boxes(d_course_mario_raceway_item_box_spawns); vec3f_set(position, 150.0f, 40.0f, -1300.0f); @@ -2285,21 +2154,21 @@ void place_course_actors(void) { place_falling_rocks(d_course_choco_mountain_falling_rock_spawns); break; case COURSE_BOWSER_CASTLE: - place_segment_06(d_course_bowsers_castle_tree_spawn); + spawn_foliage(d_course_bowsers_castle_tree_spawn); place_all_item_boxes(d_course_bowsers_castle_item_box_spawns); break; case COURSE_BANSHEE_BOARDWALK: place_all_item_boxes(d_course_banshee_boardwalk_item_box_spawns); break; case COURSE_YOSHI_VALLEY: - place_segment_06(d_course_yoshi_valley_tree_spawn); + spawn_foliage(d_course_yoshi_valley_tree_spawn); place_all_item_boxes(d_course_yoshi_valley_item_box_spawns); vec3f_set(position, -2300.0f, 0.0f, 634.0f); position[0] *= gCourseDirection; addActorToEmptySlot(position, rotation, velocity, ACTOR_YOSHI_VALLEY_EGG); break; case COURSE_FRAPPE_SNOWLAND: - place_segment_06(d_course_frappe_snowland_tree_spawns); + spawn_foliage(d_course_frappe_snowland_tree_spawns); place_all_item_boxes(d_course_frappe_snowland_item_box_spawns); break; case COURSE_KOOPA_BEACH: @@ -2308,17 +2177,17 @@ void place_course_actors(void) { place_palm_trees(d_course_koopa_troopa_beach_tree_spawn); break; case COURSE_ROYAL_RACEWAY: - place_segment_06(d_course_royal_raceway_tree_spawn); + spawn_foliage(d_course_royal_raceway_tree_spawn); place_all_item_boxes(d_course_royal_raceway_item_box_spawns); place_piranha_plants(d_course_royal_raceway_piranha_plant_spawn); break; case COURSE_LUIGI_RACEWAY: - place_segment_06(d_course_luigi_raceway_tree_spawn); + spawn_foliage(d_course_luigi_raceway_tree_spawn); place_all_item_boxes(d_course_luigi_raceway_item_box_spawns); break; case COURSE_MOO_MOO_FARM: if (gPlayerCountSelection1 != 4) { - place_segment_06(d_course_moo_moo_farm_tree_spawn); + spawn_foliage(d_course_moo_moo_farm_tree_spawn); } place_all_item_boxes(d_course_moo_moo_farm_item_box_spawns); break; @@ -2326,7 +2195,7 @@ void place_course_actors(void) { place_all_item_boxes(d_course_toads_turnpike_item_box_spawns); break; case COURSE_KALAMARI_DESERT: - place_segment_06(d_course_kalimari_desert_cactus_spawn); + spawn_foliage(d_course_kalimari_desert_cactus_spawn); place_all_item_boxes(d_course_kalimari_desert_item_box_spawns); vec3f_set(position, -1680.0f, 2.0f, 35.0f); position[0] *= gCourseDirection; diff --git a/src/actors.h b/src/actors.h index 461ce7c76..1c408c5fe 100644 --- a/src/actors.h +++ b/src/actors.h @@ -72,7 +72,7 @@ void place_palm_trees(struct ActorSpawnData*); void func_8029CF0C(struct ActorSpawnData*, struct FallingRock*); void place_falling_rocks(struct ActorSpawnData*); void update_obj_falling_rocks(struct FallingRock*); -void place_segment_06(struct ActorSpawnData*); +void spawn_foliage(struct ActorSpawnData*); void place_all_item_boxes(struct ActorSpawnData*); void init_kiwano_fruit(void); void destroy_all_actors(void); diff --git a/src/actors/boat.inc.c b/src/actors/boat.inc.c new file mode 100644 index 000000000..de3fbba31 --- /dev/null +++ b/src/actors/boat.inc.c @@ -0,0 +1,3 @@ +void update_obj_paddle_wheel(struct PaddleWheelBoat *boat) { + boat->wheelRot += 0x38E; +} diff --git a/src/actors/falling_rocks.inc.c b/src/actors/falling_rocks.inc.c new file mode 100644 index 000000000..47e4d1896 --- /dev/null +++ b/src/actors/falling_rocks.inc.c @@ -0,0 +1,112 @@ +void func_8029CF0C(struct ActorSpawnData *spawnData, struct FallingRock *rock) { + s32 segment = SEGMENT_NUMBER2(spawnData); + s32 offset = SEGMENT_OFFSET(spawnData); + struct ActorSpawnData *temp_v0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[segment] + offset); + Vec3s sp24 = {60, 120, 180}; + temp_v0 += rock->unk_06; + rock->respawnTimer = sp24[rock->unk_06]; // * 2 + rock->pos[0] = (f32) temp_v0->pos[0] * gCourseDirection; + rock->pos[1] = (f32) temp_v0->pos[1] + 10.0f; + rock->pos[2] = (f32) temp_v0->pos[2]; + vec3f_set(rock->velocity, 0, 0, 0); + vec3s_set(rock->rot, 0, 0, 0); +} + +void place_falling_rocks(struct ActorSpawnData *spawnData) { + s32 addr = SEGMENT_NUMBER2(spawnData); + s32 offset = SEGMENT_OFFSET(spawnData); + // Casting this to prevent warning does not work. + struct ActorSpawnData *temp_s0 = (struct ActorSpawnData *) VIRTUAL_TO_PHYSICAL2(gSegmentTable[addr] + offset); + struct FallingRock *temp_v1; + Vec3f startingPos; + Vec3f startingVelocity; + Vec3s startingRot; + s16 temp; + + while (temp_s0->pos[0] != -0x8000) { + startingPos[0] = temp_s0->pos[0] * gCourseDirection; + startingPos[1] = temp_s0->pos[1] + 10.0f; + startingPos[2] = temp_s0->pos[2]; + vec3f_set(startingVelocity, 0, 0, 0); + vec3s_set(startingRot, 0, 0, 0); + temp = addActorToEmptySlot(startingPos, startingRot, startingVelocity, ACTOR_FALLING_ROCK); + temp_v1 = (struct FallingRock *) &gActorList[temp]; + + temp_v1->unk_06 = temp_s0->someId; + func_802AAAAC((Collision *) &temp_v1->unk30); + temp_s0++; + } +} + +void update_obj_falling_rocks(struct FallingRock *rock) { + Vec3f unkVec; + f32 pad0; + f32 pad1; + + if (rock->respawnTimer != 0) { + rock->respawnTimer -= 1; + return; + } + if (rock->pos[1] < D_8015F8E4) { + func_8029CF0C(d_course_choco_mountain_falling_rock_spawns, rock); + } + rock->rot[0] += (s16) ((rock->velocity[2] * 5461.0f) / 20.0f); + rock->rot[2] += (s16) ((rock->velocity[0] * 5461.0f) / 20.0f); + rock->velocity[1] -= 0.1; + if (rock->velocity[1] < (-2.0f)) { + rock->velocity[1] = -2.0f; + } + rock->pos[0] += rock->velocity[0]; + rock->pos[1] += rock->velocity[1]; + rock->pos[2] += rock->velocity[2]; + pad1 = rock->velocity[1]; + func_802ADDC8(&rock->unk30, 10.0f, rock->pos[0], rock->pos[1], rock->pos[2]); + pad0 = rock->unk30.unk3C[2]; + if (pad0 < 0.0f) { + unkVec[0] = -rock->unk30.unk60[0]; + unkVec[1] = -rock->unk30.unk60[1]; + unkVec[2] = -rock->unk30.unk60[2]; + rock->pos[0] += unkVec[0] * rock->unk30.unk3C[2]; + rock->pos[1] += unkVec[1] * rock->unk30.unk3C[2]; + rock->pos[2] += unkVec[2] * rock->unk30.unk3C[2]; + func_802AC114(unkVec, pad0, rock->velocity, 2.0f); + rock->velocity[1] = -1.2f * pad1; + func_800C98B8(rock->pos, rock->velocity, 0x1900800FU); + } + pad0 = rock->unk30.unk3C[0]; + if (pad0 < 0.0f) { + unkVec[1] = -rock->unk30.unk48[1]; + if (unkVec[1] == 0.0f) { + rock->velocity[1] *= -1.2f; + return; + } + else { + unkVec[0] = -rock->unk30.unk48[0]; + unkVec[2] = -rock->unk30.unk48[2]; + rock->pos[0] += unkVec[0] * rock->unk30.unk3C[0]; + rock->pos[1] += unkVec[1] * rock->unk30.unk3C[0]; + rock->pos[2] += unkVec[2] * rock->unk30.unk3C[0]; + func_802AC114(unkVec, pad0, rock->velocity, 2.0f); + rock->velocity[1] = -1.2f * pad1; + func_800C98B8(rock->pos, rock->velocity, 0x1900800FU); + } + } + pad0 = rock->unk30.unk3C[1]; + if (pad0 < 0.0f) { + unkVec[1] = -rock->unk30.unk54[1]; + if (unkVec[1] == 0.0f) { + rock->velocity[1] *= -1.2f; + } + else { + unkVec[0] = -rock->unk30.unk54[0]; + unkVec[2] = -rock->unk30.unk54[2]; + rock->pos[0] += unkVec[0] * rock->unk30.unk3C[1]; + rock->pos[1] += unkVec[1] * rock->unk30.unk3C[1]; + rock->pos[2] += unkVec[2] * rock->unk30.unk3C[1]; + pad1 = rock->velocity[1]; + func_802AC114(unkVec, pad0, rock->velocity, 2.0f); + rock->velocity[1] = -1.2f * pad1; + func_800C98B8(rock->pos, rock->velocity, 0x1900800FU); + } + } +} diff --git a/src/actors/train.inc.c b/src/actors/train.inc.c new file mode 100644 index 000000000..39d81d1d0 --- /dev/null +++ b/src/actors/train.inc.c @@ -0,0 +1,19 @@ +// wheels +void update_obj_train_engine(struct TrainCar *arg0) { + arg0->wheelRot -= 0x666; + + if (arg0->unk_08 != 0.0f) { + arg0->unk_08 = 0.0f; + func_800C9D80(arg0->pos, arg0->velocity, 0x51018000); + } +} + +// wheels +void update_obj_train_car1(struct TrainCar *tender) { + tender->wheelRot -= 0x4FA; +} + +// wheels +void update_obj_train_car2(struct TrainCar *arg0) { + arg0->wheelRot -= 0x666; +} diff --git a/src/audio/external.c b/src/audio/external.c index 7834317e7..b5aae2d95 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -10,6 +10,12 @@ #include #include "port_eu.h" +/** bss +s8 D_8018EF10; + +*/ + + // Requires void in the argument list to match properly. void func_800C13F0(void) { } diff --git a/src/ceremony_and_credits.c b/src/ceremony_and_credits.c index 7588da1c4..d2896d967 100644 --- a/src/ceremony_and_credits.c +++ b/src/ceremony_and_credits.c @@ -352,7 +352,7 @@ void func_80282C40(struct struct_80283430 *arg0, struct struct_80282C40 *arg1, s j++; goto dummy_label_888430; - while(1) { + while(TRUE) { do { dummy_label_888430: ; diff --git a/src/code_800029B0.c b/src/code_800029B0.c index 8d343ef74..ee1f1b79a 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -305,7 +305,7 @@ void func_80003040(void) { switch (gCurrentCourseId) { case COURSE_MARIO_RACEWAY: dma_textures(D_0F04F45C, 0x35B, 0x800); - place_segment_06(d_course_mario_raceway_tree_spawns); + spawn_foliage(d_course_mario_raceway_tree_spawns); break; case COURSE_BOWSER_CASTLE: find_vtx_and_set_colours(0x7001350, 0x32, 0, 0, 0); @@ -331,7 +331,7 @@ void func_80003040(void) { dma_textures(D_0F0532F8, 0x400, 0x800); dma_textures(D_0F05363C, 0x400, 0x800); dma_textures(D_0F053950, 0x400, 0x800); - place_segment_06(d_course_moo_moo_farm_tree_spawn); + spawn_foliage(d_course_moo_moo_farm_tree_spawn); break; case COURSE_SHERBET_LAND: find_vtx_and_set_colours(0x7001EB8, -0x4C, 0xFF, 0xFF, 0xFF); diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index aba930b8e..057e43144 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -20,6 +20,11 @@ #include "bomb_kart.h" #include "courses/all_course_data.h" + +//Collision D_80162E70; +//s16 D_80162EB0; LIkely a float. + + // Strings, presented by google translate! // Note that these are EUC-JP encoded, see: // https://en.wikipedia.org/wiki/Extended_Unix_Code#EUC-JP @@ -5789,6 +5794,7 @@ void func_800122D8(void) { //generated by m2c commit 8267401fa4ef7a38942dcca43353cc1bcc6efabc extern s16 D_80162EB0; +// arg1 struct tbd void func_80012780(TrainCarStuff *trainCar, void *arg1, s16 arg2) { trainCar->position[0] = (f32) arg1->unk0; trainCar->position[1] = (f32) D_80162EB0; diff --git a/src/code_80091750.c b/src/code_80091750.c index 4a573f1fc..e910ab7d5 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -5121,7 +5121,7 @@ s32 func_8009A374(MkAnimation *arg0) { while (D_8018DEE0[var_a1].visible != 0) { var_a1++; if (var_a1 >= 0x10) { - while(1){} + while(TRUE); } } temp_v1 = &D_8018DEE0[var_a1]; diff --git a/src/main.c b/src/main.c index 5da3474fe..6267d3bf4 100644 --- a/src/main.c +++ b/src/main.c @@ -505,7 +505,13 @@ void setup_game_memory(void) { init_seg_8028DF00(); gHeapEndPtr = SEG_8028DF00; set_segment_base_addr(0, (void *) SEG_START); - initialize_memory_pool((uintptr_t) &D_801978D0, (uintptr_t) 0x80242F00); + // Memory pool size of 0xAB630 + // todo: is it possible to shift this value? +#ifdef AVOID_UB + initialize_memory_pool((uintptr_t) &_mainSegNoloadEnd, (uintptr_t) (&_mainSegNoloadEnd[0] + 0xAB630)); +#else + initialize_memory_pool((uintptr_t) &_mainSegNoloadEnd, (uintptr_t) 0x80242F00); +#endif func_80000BEC(); osInvalDCache((void *) SEG_802BA370, 0x5810); osPiStartDma(&gDmaIoMesg, 0, 0, (uintptr_t) &_data_802BA370SegmentRomStart, (void *) SEG_802BA370, 0x5810, &gDmaMesgQueue); diff --git a/src/memory.c b/src/memory.c index a53316b53..57eb029af 100644 --- a/src/memory.c +++ b/src/memory.c @@ -974,7 +974,7 @@ void displaylist_unpack(uintptr_t *data, uintptr_t finalDisplaylistOffset, u32 a sGfxSeekPosition = 0; sPackedSeekPosition = 0; - while(1) { + while(TRUE) { // Seek to the next byte opcode = packed_dl[sPackedSeekPosition++]; diff --git a/src/os/libultra_internal.h b/src/os/libultra_internal.h index 9d2fbd010..3e7032370 100644 --- a/src/os/libultra_internal.h +++ b/src/os/libultra_internal.h @@ -61,6 +61,8 @@ s32 __osSpSetPc(void *); s32 __osSpDeviceBusy(void); s32 __osSiDeviceBusy(void); s32 __osSpRawStartDma(u32 dir, void *sp_ptr, void *dram_ptr, size_t size); +void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void)); +s32 __osLeoInterrupt(); void __osViInit(void); OSViContext *__osViGetCurrentContext(void); OSViContext *__osViGetCurrentContext2(void); diff --git a/src/os/osInitialize.c b/src/os/osInitialize.c index 2974ff539..921c969ae 100644 --- a/src/os/osInitialize.c +++ b/src/os/osInitialize.c @@ -11,8 +11,7 @@ typedef struct { u32 instr03; } exceptionPreamble; -extern u32 D_80194040; // maybe initialized? -extern s32 __osLeoInterrupt; +u32 D_80194040; u64 osClockRate = 62500000; u32 D_800EA5E8 = 0; diff --git a/tools/Makefile b/tools/Makefile index 7172ffb1b..b509a3b08 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,7 +1,18 @@ +# Makefile to build tools and recomp + +# Compilation flags CC := gcc CFLAGS := -I . -Wall -Wextra -Wno-unused-parameter -pedantic -std=c99 -O2 -s + +# Tools to compile PROGRAMS := mio0 n64graphics displaylist_packer n64cksum tkmk00 extract_data_for_mio + + +#==============================================================================# +# Source Files and Flags for Each Tool # +#==============================================================================# + n64graphics_SOURCES := n64graphics.c utils.c n64graphics_CFLAGS := -DN64GRAPHICS_STANDALONE @@ -19,15 +30,26 @@ n64cksum_CFLAGS := -DN64CKSUM_STANDALONE extract_data_for_mio_SOURCES := extract_data_for_mio.c + +# Build tools and recomp all: $(PROGRAMS) subsystem +# Build recomp subsystem: $(MAKE) -C ido5.3_recomp +# Remove generated files clean: $(RM) $(PROGRAMS) $(MAKE) -C ido5.3_recomp clean + + +#==============================================================================# +# Compile Tools # +#==============================================================================# + +# Compile tools based on the foreach loop define COMPILE = $(1): $($1_SOURCES) $(CC) $(CFLAGS) $($1_CFLAGS) $$^ -o $$@