Some refactoring

This commit is contained in:
Arceveti
2021-09-26 20:47:23 -07:00
parent 7da55b1456
commit c3a68d48a7
37 changed files with 581 additions and 746 deletions

View File

@@ -66,7 +66,7 @@ KING_BOBOMB_DIRS := king_bobomb water_bubble
BOO_DIRS := bookend book chair small_key mad_piano boo haunted_cage
MR_I_DIRS := mr_i_eyeball mr_i_iris swoop snufit dorrie scuttlebug
HOOT_DIRS := yellow_sphere_small hoot yoshi_egg thwomp bullet_bill heave_ho
COINS_DIRS := mist explosion butterfly coin warp_pipe door bowser_key flame blue_fish pebble leaves warp_collision mario_cap breath_meter power_meter mushroom_1up star sand dirt transparent_star white_particle wooden_signpost tree
COINS_DIRS := mist explosion butterfly coin warp_pipe door bowser_key flame blue_fish pebble leaves mario_cap breath_meter power_meter mushroom_1up star sand dirt transparent_star white_particle wooden_signpost tree
BUBBA_DIRS := bubba wiggler wiggler_body_part lakitu_enemy spiny_egg spiny
SKEETER_DIRS := skeeter seaweed water_mine cyan_fish bub water_ring treasure_chest
KLEPTO_DIRS := klepto eyerok pokey tornado

View File

@@ -27,6 +27,7 @@ UNUSED static const u64 binid_4 = 4;
#include "door/model.inc.c"
#include "door/anims/data.inc.c"
#include "door/anims/table.inc.c"
#include "door/collision.inc.c"
UNUSED static const u64 binid_5 = 5;
#include "bowser_key/model.inc.c"
@@ -48,8 +49,6 @@ UNUSED static const u64 binid_9 = 9;
#include "leaves/model.inc.c"
UNUSED static const u64 binid_10 = 10;
// this is still weird...
#include "warp_collision/collision.inc.c"
UNUSED static const u64 binid_11 = 11;
#include "mario_cap/model.inc.c"

View File

@@ -113,6 +113,7 @@ extern const Gfx door_seg3_dl_03015078[];
extern const Gfx door_seg3_dl_030150E8[];
extern const Gfx door_seg3_dl_03015158[];
extern const struct Animation *const door_seg3_anims_030156C0[];
extern const Collision door_seg3_collision_door[];
// explosion
extern const GeoLayout explosion_geo[];
@@ -230,10 +231,6 @@ extern const Gfx tree_seg3_dl_spiky[];
extern const Gfx tree_seg3_dl_snowy_pine[];
extern const Gfx tree_seg3_dl_palm[];
// warp_collision
extern const Collision door_seg3_collision_0301CE78[];
extern const Collision lll_hexagonal_mesh_seg3_collision_0301CECC[];
// warp_pipe
extern const GeoLayout warp_pipe_geo[];
extern const Gfx warp_pipe_seg3_dl_03008E40[];

View File

@@ -0,0 +1,21 @@
// 0x0301CE78 - 0x0301CECC
const Collision door_seg3_collision_door[] = {
COL_INIT(),
COL_VERTEX_INIT(0x8),
COL_VERTEX(-80, 240, 30),
COL_VERTEX(80, 240, 30),
COL_VERTEX(80, 0, 30),
COL_VERTEX(-80, 0, 30),
COL_VERTEX(-80, 240, -30),
COL_VERTEX(80, 0, -30),
COL_VERTEX(80, 240, -30),
COL_VERTEX(-80, 0, -30),
COL_TRI_INIT(SURFACE_DEFAULT, 4),
COL_TRI(2, 1, 0),
COL_TRI(3, 2, 0),
COL_TRI(6, 5, 4),
COL_TRI(5, 7, 4),
COL_TRI_STOP(),
COL_END(),
};

View File

@@ -1,39 +0,0 @@
// Warp Collision (seems strange to put these collision in another file. Only instance of this seperation thus far. Not sure what this is doing as a file.)
// 0x0301CE78 - 0x0301CECC
const Collision door_seg3_collision_0301CE78[] = {
COL_INIT(),
COL_VERTEX_INIT(0x8),
COL_VERTEX(-80, 240, 30),
COL_VERTEX(80, 240, 30),
COL_VERTEX(80, 0, 30),
COL_VERTEX(-80, 0, 30),
COL_VERTEX(-80, 240, -30),
COL_VERTEX(80, 0, -30),
COL_VERTEX(80, 240, -30),
COL_VERTEX(-80, 0, -30),
COL_TRI_INIT(SURFACE_DEFAULT, 4),
COL_TRI(2, 1, 0),
COL_TRI(3, 2, 0),
COL_TRI(6, 5, 4),
COL_TRI(5, 7, 4),
COL_TRI_STOP(),
COL_END(),
};
// 0x0301CECC - 0x0301CEFC
const Collision lll_hexagonal_mesh_seg3_collision_0301CECC[] = {
COL_INIT(),
COL_VERTEX_INIT(0x4),
COL_VERTEX(-200, 0, -200),
COL_VERTEX(200, 0, -200),
COL_VERTEX(200, 0, 200),
COL_VERTEX(-200, 0, 200),
COL_TRI_INIT(SURFACE_DEFAULT, 2),
COL_TRI(2, 1, 0),
COL_TRI(3, 2, 0),
COL_TRI_STOP(),
COL_END(),
};

View File

@@ -1069,7 +1069,7 @@ const BehaviorScript bhvDoor[] = {
OR_INT(oFlags, (OBJ_FLAG_ACTIVE_FROM_AFAR | OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE)),
LOAD_ANIMATIONS(oAnimations, door_seg3_anims_030156C0),
ANIMATE(0),
LOAD_COLLISION_DATA(door_seg3_collision_0301CE78),
LOAD_COLLISION_DATA(door_seg3_collision_door),
SET_HITBOX(/*Radius*/ 80, /*Height*/ 100),
SET_INT(oIntangibleTimer, 0),
SET_FLOAT(oCollisionDistance, 1000),
@@ -2419,15 +2419,6 @@ const BehaviorScript bhvPiranhaPlant[] = {
END_LOOP(),
};
const BehaviorScript bhvLllHexagonalMesh[] = {
BEGIN(OBJ_LIST_SURFACE),
OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE),
LOAD_COLLISION_DATA(lll_hexagonal_mesh_seg3_collision_0301CECC),
BEGIN_LOOP(),
CALL_NATIVE(load_object_collision_model),
END_LOOP(),
};
const BehaviorScript bhvLllBowserPuzzlePiece[] = {
BEGIN(OBJ_LIST_SURFACE),
OR_LONG(oFlags, (OBJ_FLAG_COMPUTE_DIST_TO_MARIO | OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE | OBJ_FLAG_DONT_CALC_COLL_DIST | OBJ_FLAG_UCODE_LARGE)),

View File

@@ -195,7 +195,6 @@ extern const BehaviorScript bhvKoopaShell[];
extern const BehaviorScript bhvKoopaShellFlame[];
extern const BehaviorScript bhvToxBox[];
extern const BehaviorScript bhvPiranhaPlant[];
extern const BehaviorScript bhvLllHexagonalMesh[];
extern const BehaviorScript bhvLllBowserPuzzlePiece[];
extern const BehaviorScript bhvLllBowserPuzzle[];
extern const BehaviorScript bhvTuxiesMother[];

View File

@@ -66,7 +66,7 @@
// 1 is similar to vanilla, but prevents Mario from moving in the wrong direction, and allows finer control with the analog stick.
// 2 is similar to mode 1, but a bit further from vanilla, and allows instant turnaround if Mario is moving slower than a certain threshold.
// 3 is instant turning to the intended direction regardless of speed and angle.
#define GROUND_TURN_MODE 0
#define GROUND_TURN_MODE 0
// Improved hanging:
// - Doesn't require holding down the A button
// - Percise turning control ()
@@ -187,11 +187,13 @@
// This allows you to quickly test the level you're working on.
// If you want the game to boot normally, just comment out the define again.
//#define TEST_LEVEL LEVEL_BOB
// Enable debug level select
//#define DEBUG_LEVEL_SELECT
// Custom debug mode. Press DPAD left to show the debug UI. Press DPAD right to enter the noclip mode.
//#define CUSTOM_DEBUG
// Include Puppyprint, a display library for text and large images. Also includes a custom, enhanced performance profiler.
//#define PUPPYPRINT
#define PUPPYPRINT_DEBUG 0
#define PUPPYPRINT
#define PUPPYPRINT_DEBUG 1
// Use cycles instead of microseconds
//#define PUPPYPRINT_DEBUG_CYCLES
// Visual debug enables some collision visuals. Tapping Right on the dpad will cycle between visual hitboxes, visual surfaces, both, and neither.

View File

@@ -144,14 +144,14 @@ typedef struct OSMesgQueue_s {
/* Message operations */
extern void osCreateMesgQueue(OSMesgQueue *, OSMesg *, s32);
extern s32 osSendMesg(OSMesgQueue *, OSMesg, s32);
extern s32 osJamMesg(OSMesgQueue *, OSMesg, s32);
extern s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32);
extern void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msg, s32 count);
extern s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flag);
extern s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag);
extern s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flag);
/* Event operations */
extern void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg);
extern void osSetEventMesg(OSEvent e, OSMesgQueue *mq, OSMesg m);
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */

View File

@@ -81,7 +81,7 @@ enum RenderLayers
#define INPUT_IN_WATER /* 0x0200 */ (1 << 9)
#define INPUT_STOMPED /* 0x0400 */ (1 << 10)
#define INPUT_INTERACT_OBJ_GRABBABLE /* 0x0800 */ (1 << 11)
#define INPUT_UNKNOWN_12 /* 0x1000 */ (1 << 12)
#define INPUT_B_DOWN /* 0x1000 */ (1 << 12)
#define INPUT_B_PRESSED /* 0x2000 */ (1 << 13)
#define INPUT_Z_DOWN /* 0x4000 */ (1 << 14)
#define INPUT_Z_PRESSED /* 0x8000 */ (1 << 15)
@@ -208,7 +208,7 @@ enum RenderLayers
#define ACT_COUGHING 0x0C40020A // (0x00A | ACT_FLAG_STATIONARY | ACT_FLAG_IDLE | ACT_FLAG_ALLOW_FIRST_PERSON | ACT_FLAG_PAUSE_EXIT)
#define ACT_SHIVERING 0x0C40020B // (0x00B | ACT_FLAG_STATIONARY | ACT_FLAG_IDLE | ACT_FLAG_ALLOW_FIRST_PERSON | ACT_FLAG_PAUSE_EXIT)
#define ACT_IN_QUICKSAND 0x0002020D // (0x00D | ACT_FLAG_STATIONARY | ACT_FLAG_INVULNERABLE)
#define ACT_UNKNOWN_0002020E 0x0002020E // (0x00E | ACT_FLAG_STATIONARY | ACT_FLAG_INVULNERABLE)
#define ACT_NO_STANDING_DEATH 0x0002020E // (0x00E | ACT_FLAG_STATIONARY | ACT_FLAG_INVULNERABLE)
#define ACT_CROUCHING 0x0C008220 // (0x020 | ACT_FLAG_STATIONARY | ACT_FLAG_SHORT_HITBOX | ACT_FLAG_ALLOW_FIRST_PERSON | ACT_FLAG_PAUSE_EXIT)
#define ACT_START_CROUCHING 0x0C008221 // (0x021 | ACT_FLAG_STATIONARY | ACT_FLAG_SHORT_HITBOX | ACT_FLAG_ALLOW_FIRST_PERSON | ACT_FLAG_PAUSE_EXIT)
#define ACT_STOP_CROUCHING 0x0C008222 // (0x022 | ACT_FLAG_STATIONARY | ACT_FLAG_SHORT_HITBOX | ACT_FLAG_ALLOW_FIRST_PERSON | ACT_FLAG_PAUSE_EXIT)

View File

@@ -13,7 +13,7 @@
#include "levels/hmc/header.h"
#include "levels/hmc/areas/1/grill_door/geo.inc.c"
#include "levels/hmc/grill_door/geo.inc.c"
#include "levels/hmc/rolling_rock/geo.inc.c"
#include "levels/hmc/rolling_rock_fragment_1/geo.inc.c"
#include "levels/hmc/rolling_rock_fragment_2/geo.inc.c"

View File

@@ -38,7 +38,6 @@
#include "levels/hmc/areas/1/26/model.inc.c"
#include "levels/hmc/areas/1/27/model.inc.c"
#include "levels/hmc/areas/1/28/model.inc.c"
#include "levels/hmc/areas/1/grill_door/model.inc.c"
#include "levels/hmc/areas/1/29/model.inc.c"
#include "levels/hmc/areas/1/30/model.inc.c"
#include "levels/hmc/areas/1/31/model.inc.c"
@@ -54,7 +53,8 @@
#include "levels/hmc/areas/1/macro.inc.c"
#include "levels/hmc/areas/1/room.inc.c"
#include "levels/hmc/elevator_platform/collision.inc.c"
#include "levels/hmc/areas/1/grill_door/collision.inc.c" // This is odd, but the model data for this is in the middle of area 1. I have to conclude it is an area local object, despite the fact it has collision. Let's hope this is the only oddity...
#include "levels/hmc/grill_door/model.inc.c"
#include "levels/hmc/grill_door/collision.inc.c" // This is odd, but the model data for this is in the middle of area 1. I have to conclude it is an area local object, despite the fact it has collision. Let's hope this is the only oddity...
#include "levels/hmc/arrow_platform/collision.inc.c"
#include "levels/hmc/arrow_platform_button/collision.inc.c"
#include "levels/hmc/areas/1/trajectory.inc.c"

View File

@@ -1,7 +1,7 @@
// 0x0701ADE8 - 0x0701CE18
const Collision lll_seg7_area_1_collision[] = {
COL_INIT(),
COL_VERTEX_INIT(0x20F),
COL_VERTEX_INIT(0x213),
COL_VERTEX(2775, 1280, 4567),
COL_VERTEX(2816, 1280, 4608),
COL_VERTEX(5888, 1280, 4608),
@@ -529,7 +529,11 @@ const Collision lll_seg7_area_1_collision[] = {
COL_VERTEX(6724, 554, -6532),
COL_VERTEX(6863, 376, -6392),
COL_VERTEX(6934, 166, -6321),
COL_TRI_INIT(SURFACE_DEFAULT, 622),
COL_VERTEX(-5315, 300, -3400),
COL_VERTEX(-4915, 300, -3400),
COL_VERTEX(-4915, 300, -3000),
COL_VERTEX(-5315, 300, -3000),
COL_TRI_INIT(SURFACE_DEFAULT, 624),
COL_TRI(142, 143, 144),
COL_TRI(48, 49, 50),
COL_TRI(48, 50, 51),
@@ -1152,6 +1156,8 @@ const Collision lll_seg7_area_1_collision[] = {
COL_TRI(97, 521, 522),
COL_TRI(97, 92, 521),
COL_TRI(376, 524, 525),
COL_TRI(529, 528, 527),
COL_TRI(530, 529, 527),
COL_TRI_INIT(SURFACE_BURNING, 82),
COL_TRI(77, 73, 41),
COL_TRI(41, 39, 72),

View File

@@ -31,10 +31,7 @@ static const LevelScript script_func_local_hmc_flames_and_poles[] = {
OBJECT(/*model*/ MODEL_LEVEL_GEOMETRY_0C, /*pos*/ -4607, 0, 3456, /*angle*/ 0, 270, 0, /*behParam*/ 0x00000000, /*beh*/ bhvStaticObject),
OBJECT(/*model*/ MODEL_LEVEL_GEOMETRY_0C, /*pos*/ -5119, 0, -511, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvStaticObject),
OBJECT(/*model*/ MODEL_LEVEL_GEOMETRY_0D, /*pos*/ 0, 0, -2047, /*angle*/ 0, 0, 0, /*behParam*/ 0x00000000, /*beh*/ bhvStaticObject),
// This behavior differs from the rest in that it actually has collision rather than being purely visual.
// A likely explanation is that this object was added in after the collision model was made, and they didn't want
// to redo the collision so they just added a new behavior for it.
OBJECT(/*model*/ MODEL_LEVEL_GEOMETRY_0E, /*pos*/ -5115, 300, -3200, /*angle*/ 0, 90, 0, /*behParam*/ 0x00000000, /*beh*/ bhvLllHexagonalMesh),
OBJECT(/*model*/ MODEL_LEVEL_GEOMETRY_0E, /*pos*/ -5115, 300, -3200, /*angle*/ 0, 90, 0, /*behParam*/ 0x00000000, /*beh*/ bhvStaticObject),
RETURN(),
};

View File

@@ -65,7 +65,11 @@ s8 sAudioEnabled = TRUE;
u32 gNumVblanks = 0;
s8 gResetTimer = 0;
s8 gNmiResetBarsTimer = 0;
#ifdef DEBUG_LEVEL_SELECT
s8 gDebugLevelSelect = TRUE;
#else
s8 gDebugLevelSelect = FALSE;
#endif
s8 gShowProfiler = FALSE;
s8 gShowDebugText = FALSE;
@@ -150,12 +154,8 @@ void receive_new_tasks(void) {
while (osRecvMesg(&gSPTaskMesgQueue, (OSMesg *) &spTask, OS_MESG_NOBLOCK) != -1) {
spTask->state = SPTASK_STATE_NOT_STARTED;
switch (spTask->task.t.type) {
case 2:
sNextAudioSPTask = spTask;
break;
case 1:
sNextDisplaySPTask = spTask;
break;
case 2: sNextAudioSPTask = spTask; break;
case 1: sNextDisplaySPTask = spTask; break;
}
}
@@ -171,8 +171,6 @@ void receive_new_tasks(void) {
}
void start_sptask(s32 taskType) {
UNUSED s32 pad; // needed to pad the stack
if (taskType == M_AUDTASK) {
gActiveSPTask = sCurrentAudioSPTask;
} else {
@@ -195,9 +193,9 @@ void start_gfx_sptask(void) {
if (gActiveSPTask == NULL && sCurrentDisplaySPTask != NULL
&& sCurrentDisplaySPTask->state == SPTASK_STATE_NOT_STARTED) {
profiler_log_gfx_time(TASKS_QUEUED);
#if PUPPYPRINT_DEBUG
#if PUPPYPRINT_DEBUG
rspDelta = osGetTime();
#endif
#endif
start_sptask(M_GFXTASK);
}
}
@@ -237,9 +235,9 @@ void handle_vblank(void) {
if (gActiveSPTask == NULL && sCurrentDisplaySPTask != NULL
&& sCurrentDisplaySPTask->state != SPTASK_STATE_FINISHED) {
profiler_log_gfx_time(TASKS_QUEUED);
#if PUPPYPRINT_DEBUG
#if PUPPYPRINT_DEBUG
rspDelta = osGetTime();
#endif
#endif
start_sptask(M_GFXTASK);
}
}
@@ -248,15 +246,9 @@ void handle_vblank(void) {
#endif
// Notify the game loop about the vblank.
if (gVblankHandler1 != NULL) {
osSendMesg(gVblankHandler1->queue, gVblankHandler1->msg, OS_MESG_NOBLOCK);
}
if (gVblankHandler2 != NULL) {
osSendMesg(gVblankHandler2->queue, gVblankHandler2->msg, OS_MESG_NOBLOCK);
}
if (gVblankHandler3 != NULL) {
osSendMesg(gVblankHandler3->queue, gVblankHandler3->msg, OS_MESG_NOBLOCK);
}
if (gVblankHandler1 != NULL) osSendMesg(gVblankHandler1->queue, gVblankHandler1->msg, OS_MESG_NOBLOCK);
if (gVblankHandler2 != NULL) osSendMesg(gVblankHandler2->queue, gVblankHandler2->msg, OS_MESG_NOBLOCK);
if (gVblankHandler3 != NULL) osSendMesg(gVblankHandler3->queue, gVblankHandler3->msg, OS_MESG_NOBLOCK);
}
void handle_sp_complete(void) {
@@ -305,9 +297,9 @@ void handle_sp_complete(void) {
// The SP process is done, but there is still a Display Processor notification
// that needs to arrive before we can consider the task completely finished and
// null out sCurrentDisplaySPTask. That happens in handle_dp_complete.
#if PUPPYPRINT_DEBUG
#if PUPPYPRINT_DEBUG
profiler_update(rspGenTime, rspDelta);
#endif
#endif
profiler_log_gfx_time(RSP_COMPLETE);
}
}
@@ -344,10 +336,10 @@ void thread3_main(UNUSED void *arg) {
osSyncPrintf("Linker : %s\n", __linker__);
#endif
create_thread(&gSoundThread, 4, thread4_sound, NULL, gThread4Stack + 0x2000, 20);
create_thread(&gSoundThread, 4, thread4_sound, NULL, (gThread4Stack + 0x2000), 20);
osStartThread(&gSoundThread);
create_thread(&gGameLoopThread, 5, thread5_game_loop, NULL, gThread5Stack + 0x2000, 10);
create_thread(&gGameLoopThread, 5, thread5_game_loop, NULL, (gThread5Stack + 0x2000), 10);
osStartThread(&gGameLoopThread);
while (TRUE) {
@@ -355,24 +347,13 @@ void thread3_main(UNUSED void *arg) {
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
osRecvMesg(&gIntrMesgQueue, &msg, OS_MESG_BLOCK);
switch ((uintptr_t) msg) {
case MESG_VI_VBLANK:
handle_vblank();
break;
case MESG_SP_COMPLETE:
handle_sp_complete();
break;
case MESG_DP_COMPLETE:
handle_dp_complete();
break;
case MESG_START_GFX_SPTASK:
start_gfx_sptask();
break;
case MESG_NMI_REQUEST:
handle_nmi_request();
break;
case MESG_VI_VBLANK: handle_vblank(); break;
case MESG_SP_COMPLETE: handle_sp_complete(); break;
case MESG_DP_COMPLETE: handle_dp_complete(); break;
case MESG_START_GFX_SPTASK: start_gfx_sptask(); break;
case MESG_NMI_REQUEST: handle_nmi_request(); break;
}
#if PUPPYPRINT_DEBUG
profiler_update(taskTime, first);
@@ -385,15 +366,9 @@ void set_vblank_handler(s32 index, struct VblankHandler *handler, OSMesgQueue *q
handler->msg = msg;
switch (index) {
case 1:
gVblankHandler1 = handler;
break;
case 2:
gVblankHandler2 = handler;
break;
case 3:
gVblankHandler3 = handler;
break;
case 1: gVblankHandler1 = handler; break;
case 2: gVblankHandler2 = handler; break;
case 3: gVblankHandler3 = handler; break;
}
}
@@ -435,52 +410,34 @@ void turn_off_audio(void) {
}
void change_vi(OSViMode *mode, int width, int height){
mode->comRegs.width = width;
mode->comRegs.xScale = (width*512)/320;
if(height > 240)
{
mode->comRegs.ctrl |= 0x40;
mode->fldRegs[0].origin = width*2;
mode->fldRegs[1].origin = width*4;
mode->fldRegs[0].yScale = 0x2000000|((height*1024)/240);
mode->fldRegs[1].yScale = 0x2000000|((height*1024)/240);
mode->fldRegs[0].vStart = mode->fldRegs[1].vStart-0x20002;
}
else
{
mode->fldRegs[0].origin = width*2;
mode->fldRegs[1].origin = width*4;
mode->fldRegs[0].yScale = ((height*1024)/240);
mode->fldRegs[1].yScale = ((height*1024)/240);
mode->comRegs.width = width;
mode->comRegs.xScale = ((width * 512) / 320);
if (height > 240) {
mode->comRegs.ctrl |= 0x40;
mode->fldRegs[0].origin = (width * 2);
mode->fldRegs[1].origin = (width * 4);
mode->fldRegs[0].yScale = (0x2000000 | ((height * 1024) / 240));
mode->fldRegs[1].yScale = (0x2000000 | ((height * 1024) / 240));
mode->fldRegs[0].vStart = (mode->fldRegs[1].vStart - 0x20002);
} else {
mode->fldRegs[0].origin = (width * 2);
mode->fldRegs[1].origin = (width * 4);
mode->fldRegs[0].yScale = ((height * 1024) / 240);
mode->fldRegs[1].yScale = ((height * 1024) / 240);
}
}
void get_audio_frequency(void)
{
switch (gConfig.tvType)
{
#if defined(VERSION_JP) || defined(VERSION_US)
case MODE_NTSC:
gConfig.audioFrequency = 1.0f;
break;
case MODE_MPAL:
gConfig.audioFrequency = 0.9915f;
break;
case MODE_PAL:
gConfig.audioFrequency = 0.9876f;
break;
#else
case MODE_NTSC:
gConfig.audioFrequency = 1.0126f;
break;
case MODE_MPAL:
gConfig.audioFrequency = 1.0086f;
break;
case MODE_PAL:
gConfig.audioFrequency = 1.0f;
break;
#endif
void get_audio_frequency(void) {
switch (gConfig.tvType) {
#if defined(VERSION_JP) || defined(VERSION_US)
case MODE_NTSC: gConfig.audioFrequency = 1.0f; break;
case MODE_MPAL: gConfig.audioFrequency = 0.9915f; break;
case MODE_PAL: gConfig.audioFrequency = 0.9876f; break;
#else
case MODE_NTSC: gConfig.audioFrequency = 1.0126f; break;
case MODE_MPAL: gConfig.audioFrequency = 1.0086f; break;
case MODE_PAL: gConfig.audioFrequency = 1.0f; break;
#endif
}
}
@@ -529,8 +486,7 @@ void thread1_idle(UNUSED void *arg) {
}
#if CLEARRAM
void ClearRAM(void)
{
void ClearRAM(void) {
bzero(_mainSegmentEnd, (size_t)osMemSize - (size_t)OS_K0_TO_PHYSICAL(_mainSegmentEnd));
}
#endif
@@ -559,7 +515,6 @@ void main_func(void) {
#ifdef ISVPRINT
osInitialize_fakeisv();
#endif
create_thread(&gIdleThread, 1, thread1_idle, NULL, gIdleThreadStack + 0x800, 100);
osStartThread(&gIdleThread);
}

View File

@@ -77,7 +77,7 @@ struct MainPoolBlock *sPoolListHeadR;
static struct MainPoolState *gMainPoolState = NULL;
uintptr_t set_segment_base_addr(s32 segment, void *addr) {
sSegmentTable[segment] = (uintptr_t) addr & 0x1FFFFFFF;
sSegmentTable[segment] = ((uintptr_t) addr & 0x1FFFFFFF);
return sSegmentTable[segment];
}
@@ -87,15 +87,14 @@ void *get_segment_base_addr(s32 segment) {
#ifndef NO_SEGMENTED_MEMORY
void *segmented_to_virtual(const void *addr) {
size_t segment = (uintptr_t) addr >> 24;
size_t offset = (uintptr_t) addr & 0x00FFFFFF;
size_t segment = ((uintptr_t) addr >> 24);
size_t offset = ((uintptr_t) addr & 0x00FFFFFF);
return (void *) ((sSegmentTable[segment] + offset) | 0x80000000);
}
void *virtual_to_segmented(u32 segment, const void *addr) {
size_t offset = ((uintptr_t) addr & 0x1FFFFFFF) - sSegmentTable[segment];
return (void *) ((segment << 24) + offset);
}
@@ -125,8 +124,8 @@ void move_segment_table_to_dmem(void) {
* freeing the object that was most recently allocated from a side.
*/
void main_pool_init(void *start, void *end) {
sPoolStart = (u8 *) ALIGN16((uintptr_t) start) + 16;
sPoolEnd = (u8 *) ALIGN16((uintptr_t) end - 15) - 16;
sPoolStart = ((u8 *) ALIGN16((uintptr_t) start) + 16);
sPoolEnd = ((u8 *) ALIGN16((uintptr_t) end - 15) - 16);
sPoolFreeSpace = sPoolEnd - sPoolStart;
sPoolListHeadL = (struct MainPoolBlock *) (sPoolStart - 16);
@@ -149,23 +148,23 @@ void *main_pool_alloc(u32 size, u32 side) {
struct MainPoolBlock *newListHead;
void *addr = NULL;
size = ALIGN16(size) + 16;
size = (ALIGN16(size) + 16);
if (size != 0 && sPoolFreeSpace >= size) {
sPoolFreeSpace -= size;
if (side == MEMORY_POOL_LEFT) {
newListHead = (struct MainPoolBlock *) ((u8 *) sPoolListHeadL + size);
sPoolListHeadL->next = newListHead;
newListHead->prev = sPoolListHeadL;
newListHead->next = NULL;
addr = (u8 *) sPoolListHeadL + 16;
sPoolListHeadL = newListHead;
newListHead->prev = sPoolListHeadL;
newListHead->next = NULL;
addr = ((u8 *) sPoolListHeadL + 16);
sPoolListHeadL = newListHead;
} else {
newListHead = (struct MainPoolBlock *) ((u8 *) sPoolListHeadR - size);
sPoolListHeadR->prev = newListHead;
newListHead->next = sPoolListHeadR;
newListHead->prev = NULL;
sPoolListHeadR = newListHead;
addr = (u8 *) sPoolListHeadR + 16;
newListHead->next = sPoolListHeadR;
newListHead->prev = NULL;
sPoolListHeadR = newListHead;
addr = ((u8 *) sPoolListHeadR + 16);
}
}
return addr;
@@ -178,7 +177,7 @@ void *main_pool_alloc(u32 size, u32 side) {
* Return the amount of free space left in the pool.
*/
u32 main_pool_free(void *addr) {
struct MainPoolBlock *block = (struct MainPoolBlock *) ((u8 *) addr - 16);
struct MainPoolBlock *block = (struct MainPoolBlock *) ((u8 *) addr - 16);
struct MainPoolBlock *oldListHead = (struct MainPoolBlock *) ((u8 *) addr - 16);
if (oldListHead < sPoolListHeadL) {
@@ -290,16 +289,16 @@ void *dynamic_dma_read(u8 *srcStart, u8 *srcEnd, u32 side, u32 alignment, u32 bs
u32 size = ALIGN16(srcEnd - srcStart);
u32 offset = 0;
if (alignment && side == MEMORY_POOL_LEFT)
{
if (alignment && side == MEMORY_POOL_LEFT) {
offset = ALIGN((uintptr_t)sPoolListHeadL + 16, alignment) - ((uintptr_t)sPoolListHeadL + 16);
}
dest = main_pool_alloc(offset + size + bssLength, side);
if (dest != NULL) {
dma_read((u8 *)dest + offset, srcStart, srcEnd);
if (bssLength)
if (bssLength) {
bzero((u8 *)dest + offset + size, bssLength);
}
}
return dest;
}
@@ -308,20 +307,15 @@ void *dynamic_dma_read(u8 *srcStart, u8 *srcEnd, u32 side, u32 alignment, u32 bs
s32 gTlbEntries = 0;
u8 gTlbSegments[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
void mapTLBPages(uintptr_t virtualAddress, uintptr_t physicalAddress, s32 length, s32 segment)
{
while (length > 0)
{
if (length > TLB_PAGE_SIZE)
{
void mapTLBPages(uintptr_t virtualAddress, uintptr_t physicalAddress, s32 length, s32 segment) {
while (length > 0) {
if (length > TLB_PAGE_SIZE) {
osMapTLB(gTlbEntries++, OS_PM_4K, (void *)virtualAddress, physicalAddress, physicalAddress + TLB_PAGE_SIZE, -1);
virtualAddress += TLB_PAGE_SIZE;
physicalAddress += TLB_PAGE_SIZE;
length -= TLB_PAGE_SIZE;
gTlbSegments[segment]++;
}
else
{
} else {
osMapTLB(gTlbEntries++, OS_PM_4K, (void *)virtualAddress, physicalAddress, -1, -1);
gTlbSegments[segment]++;
}
@@ -339,17 +333,14 @@ void mapTLBPages(uintptr_t virtualAddress, uintptr_t physicalAddress, s32 length
void *load_segment(s32 segment, u8 *srcStart, u8 *srcEnd, u32 side, u8 *bssStart, u8 *bssEnd) {
void *addr;
if (bssStart != NULL && side == MEMORY_POOL_LEFT)
{
if (bssStart != NULL && side == MEMORY_POOL_LEFT) {
addr = dynamic_dma_read(srcStart, srcEnd, side, TLB_PAGE_SIZE, (uintptr_t)bssEnd - (uintptr_t)bssStart);
if (addr != NULL) {
u8 *realAddr = (u8 *)ALIGN((uintptr_t)addr, TLB_PAGE_SIZE);
set_segment_base_addr(segment, realAddr);
mapTLBPages(segment << 24, VIRTUAL_TO_PHYSICAL(realAddr), (srcEnd - srcStart) + ((uintptr_t)bssEnd - (uintptr_t)bssStart), segment);
}
}
else
{
} else {
addr = dynamic_dma_read(srcStart, srcEnd, side, 0, 0);
if (addr != NULL) {
set_segment_base_addr(segment, addr);
@@ -392,7 +383,6 @@ void *load_to_fixed_pool_addr(u8 *destAddr, u8 *srcStart, u8 *srcEnd) {
*/
void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) {
void *dest = NULL;
#ifdef GZIP
u32 compSize = (srcEnd - 4 - srcStart);
#else
@@ -439,8 +429,7 @@ void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) {
}
void *load_segment_decompress_heap(u32 segment, u8 *srcStart, u8 *srcEnd) {
UNUSED void *dest = NULL;
// UNUSED void *dest = NULL;
#ifdef GZIP
u32 compSize = (srcEnd - 4 - srcStart);
#else
@@ -640,7 +629,7 @@ void *alloc_display_list(u32 size) {
void *ptr = NULL;
size = ALIGN8(size);
if (gGfxPoolEnd - size >= (u8 *) gDisplayListHead) {
if ((gGfxPoolEnd - size) >= (u8 *) gDisplayListHead) {
gGfxPoolEnd -= size;
ptr = gGfxPoolEnd;
}

View File

@@ -7,7 +7,7 @@
/**
* Hitbox for spiny both while thrown and walking. The interaction type is
* changed to INTERACT_UNKNOWN_08 while walking.
* changed to INTERACT_SPINY_WALKING while walking.
*/
static struct ObjectHitbox sSpinyHitbox = {
/* interactType: */ INTERACT_MR_BLIZZARD,
@@ -113,7 +113,7 @@ static void spiny_act_walk(void) {
// Don't allow mario to punch the spiny two frames in a row?
o->oInteractType = INTERACT_MR_BLIZZARD;
} else {
o->oInteractType = INTERACT_UNKNOWN_08;
o->oInteractType = INTERACT_SPINY_WALKING;
}
}
}

Some files were not shown because too many files have changed in this diff Show More