HackerSM64 v2.0.0
* buffers: refresh 15 and revert to base decomp * behavior script * color helper functions * extended bounds * egeo_layout * fixed model ids * camera conf improved * message panel ucode small * graph node * level script * mathutil updates * mathutil updates (allow unused funcs) * behaviors a - beta_fish * Add librtc and fix some data declarations * Move GRUCODE define to proper location in makefile * Refresh 15 * extra * Make ROM name smaller and change messages printed on build a bit * Fix console (lol) * Update UNF to latest master * Make ucode load from .o's (and also fix Super3D) * Fix crash with rumble + custom mario model * graph node and mathutil * removed behaviors * Ldtob documentation * _Putfld labeling * area * behavior actions * camera * debug updates * bubbles * envfx snow * farcall helpers * game init * geo misc * hud * only check if VC on render init * ingame menu * revert goddard to base decomp * insn disasm * interaction documentation * level geo * level update defines * macro special objects formatting changes * main.h documentation * map parser documentation & formatting * airborne documentation * mario actions automatic documentation * mario actions cutscene documentation * mario actions moving documentation and options * mario actions object documentation and options * mario stationary documentation * mario submerged documentation * mario misc documentation * mario step: ledge grab fixes and documentation * mario documentation * memory.h documentation * moving textures * object behaviors * object collision * fix flamethrower bug * object helpers * object list processor documentation * paintings * platform displacement * print / printf * puppycam absf * puppyprint updates and formatting changes * rendering graph node performance optimizations * rumble opt and doc * hqvm back to ultrasm64 * save file documentation and unlock defines * s2d engine * reset various files to ultrasm64 * file select * intro geo documentation * screen transition documentation * segment2.h * shadow overhaul * skybox refactor * sound init: clean up define usage + documentation * spawn object optimizations and documentation * spawn sound cleanup * sram to ultrasm64 * star select cleanup * title screen cleanup * dialogs / text * rename stomp smoke * stomp smoke -> small water splash * updated README * compilation flags * optimized file positions + support function/data sections * surface collision performance improvements * surface load optimizations * camera conf documentation * Allow easier command for opening puppyprint debug * Rearranged framebuffers & fixed puppyprint console printing * Fix shadow scaling and shifting * Fix SILHOUETTE, OBJECTS_REJ, and ucode loading, also clean up render phase system a bit. * Fixed build with BETTER_HANGING off * Clean up OBJECTS_REJ ifdefs * Fix duplicate comment & graph render layers/flags bitmask * Fixed build with BETTER_HANGING off * Fix Fast64 importing by reverting sSegmentTable change * Readded missing functions that caused build errors with Mario head enabled * Fixed clang compilation issues * Add INTER mode for geo_update_layer_transparency * Fix build warnings * bugfix: miscalculation in obj_turn_toward_object * Some puppytech fixes * Further Puppycamera fixes * Fix BUGFIX_DIALOG_TIME_STOP Fixes #136 * Fix sliding platform bparams * Add LEGACY_SHADOW_IDS define for Fast64 compatibility * Apply suggested changes * Better find_in_bounds_yaw_wdw_bob_thi ifdef * Fix build warnings for unused functions * Fixed stale reference bug from obj_mark_for_deletion change * Fixed incorrect digit for 100s #145 * Change groundpound-fix define and functionality to just disable bonking * Fixed puppyroll #134 * Adjust height value for terrain angle to kick in * fixed hi score flashing * Remove menudata backup (#131) Not considered important enough to keep * Fix fread() build warning * Add COURSE_NUM_TO_INDEX to save_file_get_star_flags check in bhv_unagi_init * Fix approach_s16 return value * Use boolean defines for oCapDoScaleVertically * Make the door lock a part of the key door model to eliminate z-fighting, also reduce z fighting on numbered doors with AUTO_LOD enabled. * Move flames to LAYER_TRANSPARENT_INTER * Resolved some compiler warnings and added FALL_THROUGH define (#168) * Address some more compiler warnings with different define toggles * Remove unnecessary fallthrough attribute * fixed geo_process_billboard floating point exception * Allow water to face any direction * Initialize focOffset so that BBH doesn't crash * Removed superfluous RDP commands when switching microcodes which would override scissor * Set OBJ_FLAG_DONT_CALC_COLL_DIST on bhvUkikiCage * Fix rumble build * Fixed UNLOCK_FPS strobing * Update src/game/object_helpers.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update src/game/object_helpers.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Fix LEGACY_SHADOW_IDS id conflict * Use the vanilla default value for rotating fire bars if bparam2 is 0 * START_LEVEL safeguard * Fix some drawing distance issues caused by AUTO_COLLISION_DISTANCE * Fix rumble build * Fixed spline poll code using the wrong values for keyframes * Update readme with better credits Better credits for individual contributors * add arthur * added falco and moose * add fazana * le funny typo * added S2DEX engine to credits * silhouette + axo + ratio * remove specific callouts + add auto col distance * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Revert formatting changes to match vanilla decomp * Re-implement Y buffer for find_ceil * Re-implement POWER_STARS_HEAL for normal Power Stars * Start level comment & exit course comment/collapse * utilize reonucam technique for FAST_VERTICAL_CAMERA_MOVEMENT * Fix "MAX_REFERENCED_WALLS" typo * Allow stop_and_set_height_to_floor to work at any height if Mario is teleporting (#213) * Revert stop_and_set_height_to_floor to vanilla Fixes #208 * Fixed sAudioEnabled so that it disables audio CPU processing as well * Fixed puppyprint debug RDP us calculations * Renamed sAudioEnabled to gAudioEnabled * Replaced mtxf_to_mtx_asm with an equivalent implementation that supports WORLD_SCALE * Moved extended bounds and world scale configuration to a new config_world.h file * Default all objects to non-rej (#227) Fixes #221 (Default all objects to non-rej) * Fix #221 * Fix VISUAL_DEBUG breaking/crashing when OBJECTS_REJ is disabled (#211) * Fix VISUAL_DEBUG breaking/crashing when OBJECTS_REJ is disabled * Change vtl decrement in visual_surface_display from 6 to 3 Fixes #207 * Make area in SL igloo wider to prevent a softlock (#233) Fixes #210 * Fix coin formation coins being deleted if they spawn in the middle of a floor, also fix TTM slide coin position (#232) Fixes #201 * Make UNLOCK_ALL apply to more things * Fix wrong ifdef/ifndef in bhv_invisible_objects_under_bridge_init * Change chain chomp load/unload distances depending on number of segments (#237) Fixes #192 * added WATER_PLUNGE_UPWARP define * Add reonucam patch (#239) * added reonucam patch Fixes #218 * Fix how shadows handle water/transparency/height (#228) * Fix how shadows handle water/transparency/height * Change shadow check for flying carpets from a level specific check to a oPlatformOnTrackType check Fixes #179 * added reonucam credit * delete unnecesary patches * Apply suggested changes * murdered more patches * UNLOCK_ALL unlocks the cap boxes * UNLOCK_ALL unlocks cap boxes (slightly more epic edition) * revert ceil buffer * Renamed HD_INTRO_TEXTURES define, separated intro floombas * prevent double definition of floombas * actually prevent floomba redefinition * Develop/refactor default defines (#242) * Changed default config options * Added build dir to includePaths for pngs * disable NO_SLEEP by default * Disable puppyprint by default Sorry fazana 😔 * fix typos * add comment about BETTER_REVERB console perf * disable blue coin switch retry by default * Update config_audio.h Co-authored-by: Reonu <danileon95@gmail.com> Co-authored-by: Mr-Wiseguy <68165316+Mr-Wiseguy@users.noreply.github.com> * revert air step line to vanilla to fix bitfs scaling platform issue (#247) Fixes #200 * Fix stuttering on thin slopes (#248) * Fix stuttering on thin slopes * Revert vec3f_find_ceil calls to vanilla * Rename vec3f_find_ceil to find_mario_ceil * Update src/engine/surface_collision.h Fixes #249 * Swap static and dynamic surface checks back to vanilla order (#253) * Swap static and dynamic surface checks back to vanilla order * re-enable DISABLE_ALL config Fixes #251 #252 * Fixed save and quitting while in widescreen (#257) * Fixed save and quitting while in widescreen * use define for the level * all my homies hate ifdefs * skip wall offsets < 0 (#255) Fixes #255 * #264: Document non-stop stars' issues (#267) * #264: Document non-stop stars' issues * Update include/config/config_game.h * nonstop vanilla comment * derive margin_radius from radius after capping at 200 (#266) Fixes #259 * Config cleanup/refactor (#269) * Moved puppyprint define to graphics / rearranged some debug defines for ease of access * Moved compatibility safeguards to config_safeguards.h * spacing and comment formatting * #272 Move GFX_POOL_SIZE to config_graphics.h * disable EASIER_DIALOG_TRIGGER by default * prevent redefining warnings * small ifdef typo * changed ifndef to undefs Fixes #262 Fixes #272 * Improved movement config documentation related to turning around (#271) Fixes #270 * rename CUSTOM_DEBUG, add comments (#275) * Update README.md (#277) * v2.0.0 Co-authored-by: CrashOveride95 <crashoveride953@gmail.com> Co-authored-by: Arceveti <73617174+Arceveti@users.noreply.github.com> Co-authored-by: n64 <n64> Co-authored-by: Fazana <52551480+FazanaJ@users.noreply.github.com> Co-authored-by: Mr-Wiseguy <mrwiseguyromhacking@gmail.com> Co-authored-by: aglab2 <aglab3@gmail.com> Co-authored-by: gheskett <gheskett@gmail.com> Co-authored-by: Reonu <danileon95@gmail.com> Co-authored-by: Axollyon <20480418+Axollyon@users.noreply.github.com> Co-authored-by: Mr-Wiseguy <68165316+Mr-Wiseguy@users.noreply.github.com>
This commit is contained in:
924 files changed
+44258
-30676
No files matched your search
+102
-83
@@ -21,13 +21,15 @@
|
||||
#include "game/puppylights.h"
|
||||
|
||||
// Message IDs
|
||||
#define MESG_SP_COMPLETE 100
|
||||
#define MESG_DP_COMPLETE 101
|
||||
#define MESG_VI_VBLANK 102
|
||||
#define MESG_START_GFX_SPTASK 103
|
||||
#define MESG_NMI_REQUEST 104
|
||||
enum MessageIDs {
|
||||
MESG_SP_COMPLETE = 100,
|
||||
MESG_DP_COMPLETE,
|
||||
MESG_VI_VBLANK,
|
||||
MESG_START_GFX_SPTASK,
|
||||
MESG_NMI_REQUEST,
|
||||
};
|
||||
|
||||
OSThread gUnkThread; // unused?
|
||||
// OSThread gUnkThread; // unused?
|
||||
OSThread gIdleThread;
|
||||
OSThread gMainThread;
|
||||
OSThread gGameLoopThread;
|
||||
@@ -52,41 +54,41 @@ OSViMode VI;
|
||||
|
||||
struct Config gConfig;
|
||||
|
||||
struct VblankHandler *gVblankHandler1 = NULL;
|
||||
struct VblankHandler *gVblankHandler2 = NULL;
|
||||
struct VblankHandler *gVblankHandler3 = NULL;
|
||||
struct SPTask *gActiveSPTask = NULL;
|
||||
struct SPTask *sCurrentAudioSPTask = NULL;
|
||||
struct SPTask *sCurrentDisplaySPTask = NULL;
|
||||
struct SPTask *sNextAudioSPTask = NULL;
|
||||
struct SPTask *sNextDisplaySPTask = NULL;
|
||||
s8 sAudioEnabled = TRUE;
|
||||
u32 gNumVblanks = 0;
|
||||
s8 gResetTimer = 0;
|
||||
s8 gNmiResetBarsTimer = 0;
|
||||
#ifdef DEBUG_LEVEL_SELECT
|
||||
s8 gDebugLevelSelect = TRUE;
|
||||
#else
|
||||
s8 gDebugLevelSelect = FALSE;
|
||||
#endif
|
||||
struct VblankHandler *gVblankHandler1 = NULL;
|
||||
struct VblankHandler *gVblankHandler2 = NULL;
|
||||
struct VblankHandler *gVblankHandler3 = NULL;
|
||||
struct SPTask *gActiveSPTask = NULL;
|
||||
struct SPTask *sCurrentAudioSPTask = NULL;
|
||||
struct SPTask *sCurrentDisplaySPTask = NULL;
|
||||
struct SPTask *sNextAudioSPTask = NULL;
|
||||
struct SPTask *sNextDisplaySPTask = NULL;
|
||||
s8 gAudioEnabled = TRUE;
|
||||
u32 gNumVblanks = 0;
|
||||
s8 gResetTimer = 0;
|
||||
s8 gNmiResetBarsTimer = 0;
|
||||
s8 gDebugLevelSelect = FALSE;
|
||||
|
||||
#ifdef VANILLA_DEBUG
|
||||
s8 gShowDebugText = FALSE;
|
||||
|
||||
// unused
|
||||
void handle_debug_key_sequences(void) {
|
||||
static u16 sDebugTextKeySequence[] = { D_JPAD, D_JPAD, U_JPAD, U_JPAD,
|
||||
L_JPAD, R_JPAD, L_JPAD, R_JPAD };
|
||||
static s16 sDebugTextKey = 0;
|
||||
UNUSED static u16 sDebugTextKeySequence[] = {
|
||||
D_JPAD, D_JPAD, U_JPAD, U_JPAD, L_JPAD, R_JPAD, L_JPAD, R_JPAD
|
||||
};
|
||||
static s16 sDebugTextKey = 0;
|
||||
UNUSED void handle_debug_key_sequences(void) {
|
||||
if (gPlayer3Controller->buttonPressed != 0) {
|
||||
if (sDebugTextKeySequence[sDebugTextKey++] == gPlayer3Controller->buttonPressed) {
|
||||
if (sDebugTextKey == ARRAY_COUNT(sDebugTextKeySequence)) {
|
||||
sDebugTextKey = 0, gShowDebugText ^= 1;
|
||||
sDebugTextKey = 0;
|
||||
gShowDebugText ^= 1;
|
||||
}
|
||||
} else {
|
||||
sDebugTextKey = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void setup_mesg_queues(void) {
|
||||
osCreateMesgQueue(&gDmaMesgQueue, gDmaMesgBuf, ARRAY_COUNT(gDmaMesgBuf));
|
||||
@@ -107,10 +109,10 @@ void alloc_pool(void) {
|
||||
void *end = (void *) (SEG_POOL_START + POOL_SIZE);
|
||||
|
||||
main_pool_init(start, end);
|
||||
gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT);
|
||||
#ifdef PUPPYLIGHTS
|
||||
gEffectsMemoryPool = mem_pool_init(EFFECTS_MEMORY_POOL, MEMORY_POOL_LEFT);
|
||||
#ifdef PUPPYLIGHTS
|
||||
gLightsPool = mem_pool_init(PUPPYLIGHTS_POOL, MEMORY_POOL_LEFT);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void create_thread(OSThread *thread, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri pri) {
|
||||
@@ -140,8 +142,12 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,8 +182,9 @@ void interrupt_gfx_sptask(void) {
|
||||
}
|
||||
|
||||
void start_gfx_sptask(void) {
|
||||
if (gActiveSPTask == NULL && sCurrentDisplaySPTask != NULL
|
||||
&& sCurrentDisplaySPTask->state == SPTASK_STATE_NOT_STARTED) {
|
||||
if (gActiveSPTask == NULL
|
||||
&& sCurrentDisplaySPTask != NULL
|
||||
&& sCurrentDisplaySPTask->state == SPTASK_STATE_NOT_STARTED) {
|
||||
#if PUPPYPRINT_DEBUG
|
||||
rspDelta = osGetTime();
|
||||
#endif
|
||||
@@ -192,7 +199,6 @@ void pretend_audio_sptask_done(void) {
|
||||
}
|
||||
|
||||
void handle_vblank(void) {
|
||||
|
||||
gNumVblanks++;
|
||||
if (gResetTimer > 0 && gResetTimer < 100) {
|
||||
gResetTimer++;
|
||||
@@ -209,15 +215,16 @@ void handle_vblank(void) {
|
||||
if (gActiveSPTask != NULL) {
|
||||
interrupt_gfx_sptask();
|
||||
} else {
|
||||
if (sAudioEnabled) {
|
||||
if (gAudioEnabled) {
|
||||
start_sptask(M_AUDTASK);
|
||||
} else {
|
||||
pretend_audio_sptask_done();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (gActiveSPTask == NULL && sCurrentDisplaySPTask != NULL
|
||||
&& sCurrentDisplaySPTask->state != SPTASK_STATE_FINISHED) {
|
||||
if (gActiveSPTask == NULL
|
||||
&& sCurrentDisplaySPTask != NULL
|
||||
&& sCurrentDisplaySPTask->state != SPTASK_STATE_FINISHED) {
|
||||
#if PUPPYPRINT_DEBUG
|
||||
rspDelta = osGetTime();
|
||||
#endif
|
||||
@@ -240,20 +247,19 @@ void handle_sp_complete(void) {
|
||||
gActiveSPTask = NULL;
|
||||
|
||||
if (curSPTask->state == SPTASK_STATE_INTERRUPTED) {
|
||||
// handle_vblank tried to start an audio task while there was already a
|
||||
// gfx task running, so it had to interrupt the gfx task. That interruption
|
||||
// just finished.
|
||||
// handle_vblank tried to start an audio task while there was already a gfx task
|
||||
// running, so it had to interrupt the gfx task. That interruption just finished.
|
||||
if (osSpTaskYielded(&curSPTask->task) == 0) {
|
||||
// The gfx task completed before we had time to interrupt it.
|
||||
// Mark it finished, just like below.
|
||||
curSPTask->state = SPTASK_STATE_FINISHED;
|
||||
#if PUPPYPRINT_DEBUG
|
||||
#if PUPPYPRINT_DEBUG
|
||||
profiler_update(rspGenTime, rspDelta);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// Start the audio task, as expected by handle_vblank.
|
||||
if (sAudioEnabled) {
|
||||
if (gAudioEnabled) {
|
||||
start_sptask(M_AUDTASK);
|
||||
} else {
|
||||
pretend_audio_sptask_done();
|
||||
@@ -262,8 +268,8 @@ void handle_sp_complete(void) {
|
||||
curSPTask->state = SPTASK_STATE_FINISHED;
|
||||
if (curSPTask->task.t.type == M_AUDTASK) {
|
||||
// After audio tasks come gfx tasks.
|
||||
if (sCurrentDisplaySPTask != NULL
|
||||
&& sCurrentDisplaySPTask->state != SPTASK_STATE_FINISHED) {
|
||||
if ((sCurrentDisplaySPTask != NULL)
|
||||
&& (sCurrentDisplaySPTask->state != SPTASK_STATE_FINISHED)) {
|
||||
start_sptask(M_GFXTASK);
|
||||
}
|
||||
sCurrentAudioSPTask = NULL;
|
||||
@@ -311,10 +317,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, THREAD_4_SOUND, thread4_sound, NULL, gThread4Stack + 0x2000, 20);
|
||||
osStartThread(&gSoundThread);
|
||||
|
||||
create_thread(&gGameLoopThread, 5, thread5_game_loop, NULL, (gThread5Stack + 0x2000), 10);
|
||||
create_thread(&gGameLoopThread, THREAD_5_GAME_LOOP, thread5_game_loop, NULL, gThread5Stack + 0x2000, 10);
|
||||
osStartThread(&gGameLoopThread);
|
||||
|
||||
while (TRUE) {
|
||||
@@ -324,11 +330,21 @@ void thread3_main(UNUSED void *arg) {
|
||||
#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);
|
||||
@@ -341,9 +357,15 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +375,7 @@ void send_sp_task_message(OSMesg *msg) {
|
||||
}
|
||||
|
||||
void dispatch_audio_sptask(struct SPTask *spTask) {
|
||||
if (sAudioEnabled && spTask != NULL) {
|
||||
if (gAudioEnabled && spTask != NULL) {
|
||||
osWritebackDCacheAll();
|
||||
osSendMesg(&gSPTaskMesgQueue, spTask, OS_MESG_NOBLOCK);
|
||||
}
|
||||
@@ -374,11 +396,11 @@ void exec_display_list(struct SPTask *spTask) {
|
||||
}
|
||||
|
||||
void turn_on_audio(void) {
|
||||
sAudioEnabled = TRUE;
|
||||
gAudioEnabled = TRUE;
|
||||
}
|
||||
|
||||
void turn_off_audio(void) {
|
||||
sAudioEnabled = FALSE;
|
||||
gAudioEnabled = FALSE;
|
||||
while (sCurrentAudioSPTask != NULL) {
|
||||
;
|
||||
}
|
||||
@@ -420,27 +442,23 @@ void get_audio_frequency(void) {
|
||||
* Initialize hardware, start main thread, then idle.
|
||||
*/
|
||||
void thread1_idle(UNUSED void *arg) {
|
||||
|
||||
osCreateViManager(OS_PRIORITY_VIMGR);
|
||||
switch ( osTvType ) {
|
||||
case OS_TV_NTSC:
|
||||
// NTSC
|
||||
//osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]);
|
||||
VI = osViModeTable[OS_VI_NTSC_LAN1];
|
||||
gConfig.tvType = MODE_NTSC;
|
||||
break;
|
||||
case OS_TV_MPAL:
|
||||
// MPAL
|
||||
//osViSetMode(&osViModeTable[OS_VI_MPAL_LAN1]);
|
||||
VI = osViModeTable[OS_VI_NTSC_LAN1];
|
||||
gConfig.tvType = MODE_MPAL;
|
||||
break;
|
||||
case OS_TV_PAL:
|
||||
// PAL
|
||||
//osViSetMode(&osViModeTable[OS_VI_PAL_LAN1]);
|
||||
VI = osViModeTable[OS_VI_NTSC_LAN1];
|
||||
gConfig.tvType = MODE_PAL;
|
||||
break;
|
||||
switch (osTvType) {
|
||||
case OS_TV_NTSC:
|
||||
//osViSetMode(&osViModeTable[OS_VI_NTSC_LAN1]);
|
||||
VI = osViModeTable[OS_VI_NTSC_LAN1];
|
||||
gConfig.tvType = MODE_NTSC;
|
||||
break;
|
||||
case OS_TV_MPAL:
|
||||
//osViSetMode(&osViModeTable[OS_VI_MPAL_LAN1]);
|
||||
VI = osViModeTable[OS_VI_NTSC_LAN1];
|
||||
gConfig.tvType = MODE_MPAL;
|
||||
break;
|
||||
case OS_TV_PAL:
|
||||
//osViSetMode(&osViModeTable[OS_VI_PAL_LAN1]);
|
||||
VI = osViModeTable[OS_VI_NTSC_LAN1];
|
||||
gConfig.tvType = MODE_PAL;
|
||||
break;
|
||||
}
|
||||
get_audio_frequency();
|
||||
change_vi(&VI, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
@@ -449,7 +467,7 @@ void thread1_idle(UNUSED void *arg) {
|
||||
osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON);
|
||||
osViSetSpecialFeatures(OS_VI_GAMMA_OFF);
|
||||
osCreatePiManager(OS_PRIORITY_PIMGR, &gPIMesgQueue, gPIMesgBuf, ARRAY_COUNT(gPIMesgBuf));
|
||||
create_thread(&gMainThread, 3, thread3_main, NULL, gThread3Stack + 0x2000, 100);
|
||||
create_thread(&gMainThread, THREAD_3_MAIN, thread3_main, NULL, gThread3Stack + 0x2000, 100);
|
||||
osStartThread(&gMainThread);
|
||||
|
||||
osSetThreadPri(NULL, 0);
|
||||
@@ -461,7 +479,8 @@ 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
|
||||
@@ -490,6 +509,6 @@ void main_func(void) {
|
||||
#ifdef ISVPRINT
|
||||
osInitialize_fakeisv();
|
||||
#endif
|
||||
create_thread(&gIdleThread, 1, thread1_idle, NULL, gIdleThreadStack + 0x800, 100);
|
||||
create_thread(&gIdleThread, THREAD_1_IDLE, thread1_idle, NULL, gIdleThreadStack + 0x800, 100);
|
||||
osStartThread(&gIdleThread);
|
||||
}
|
||||
+59
-49
@@ -2,8 +2,6 @@
|
||||
|
||||
#include "sm64.h"
|
||||
|
||||
#define INCLUDED_FROM_MEMORY_C
|
||||
|
||||
#include "buffers/buffers.h"
|
||||
#include "slidec.h"
|
||||
#include "game/game_init.h"
|
||||
@@ -82,7 +80,7 @@ uintptr_t set_segment_base_addr(s32 segment, void *addr) {
|
||||
return sSegmentTable[segment];
|
||||
}
|
||||
|
||||
void *get_segment_base_addr(s32 segment) {
|
||||
UNUSED void *get_segment_base_addr(s32 segment) {
|
||||
return (void *) (sSegmentTable[segment] | 0x80000000);
|
||||
}
|
||||
|
||||
@@ -96,6 +94,7 @@ void *segmented_to_virtual(const void *addr) {
|
||||
|
||||
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);
|
||||
@@ -135,11 +134,16 @@ void main_pool_init(void *start, void *end) {
|
||||
sPoolListHeadL->next = NULL;
|
||||
sPoolListHeadR->prev = NULL;
|
||||
sPoolListHeadR->next = NULL;
|
||||
#if PUPPYPRINT_DEBUG
|
||||
#if PUPPYPRINT_DEBUG
|
||||
mempool = sPoolFreeSpace;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
extern u8 _framebuffersSegmentBssStart[];
|
||||
extern u8 _framebuffersSegmentBssEnd[];
|
||||
extern u8 _zbufferSegmentBssStart[];
|
||||
extern u8 _zbufferSegmentBssEnd[];
|
||||
|
||||
/**
|
||||
* Allocate a block of memory from the pool of given size, and from the
|
||||
* specified side of the pool (MEMORY_POOL_LEFT or MEMORY_POOL_RIGHT).
|
||||
@@ -149,23 +153,29 @@ 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);
|
||||
if ((u32)newListHead >= (u32)&_framebuffersSegmentBssStart && (u32)newListHead <= (u32)&_framebuffersSegmentBssEnd) {
|
||||
newListHead = (struct MainPoolBlock *)ALIGN16((u32)&_framebuffersSegmentBssEnd + 0x40);
|
||||
}
|
||||
if ((u32)newListHead >= (u32)&_zbufferSegmentBssStart && (u32)newListHead <= (u32)&_zbufferSegmentBssEnd) {
|
||||
newListHead = (struct MainPoolBlock *)ALIGN16((u32)&_zbufferSegmentBssEnd + 0x40);
|
||||
}
|
||||
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 +188,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) {
|
||||
@@ -260,9 +270,9 @@ u32 main_pool_pop_state(void) {
|
||||
*/
|
||||
void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd) {
|
||||
u32 size = ALIGN16(srcEnd - srcStart);
|
||||
#if PUPPYPRINT_DEBUG
|
||||
#if PUPPYPRINT_DEBUG
|
||||
OSTime first = osGetTime();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
osInvalDCache(dest, size);
|
||||
while (size != 0) {
|
||||
@@ -276,9 +286,9 @@ void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd) {
|
||||
srcStart += copySize;
|
||||
size -= copySize;
|
||||
}
|
||||
#if PUPPYPRINT_DEBUG
|
||||
dmaTime[perfIteration] += osGetTime()-first;
|
||||
#endif
|
||||
#if PUPPYPRINT_DEBUG
|
||||
dmaTime[perfIteration] += (osGetTime() - first);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,43 +296,42 @@ void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd) {
|
||||
* Return the destination address.
|
||||
*/
|
||||
void *dynamic_dma_read(u8 *srcStart, u8 *srcEnd, u32 side, u32 alignment, u32 bssLength) {
|
||||
void *dest;
|
||||
u32 size = ALIGN16(srcEnd - srcStart);
|
||||
u32 offset = 0;
|
||||
|
||||
if (alignment && side == MEMORY_POOL_LEFT) {
|
||||
offset = ALIGN((uintptr_t)sPoolListHeadL + 16, alignment) - ((uintptr_t)sPoolListHeadL + 16);
|
||||
offset = ALIGN(((uintptr_t)sPoolListHeadL + 16), alignment) - ((uintptr_t)sPoolListHeadL + 16);
|
||||
}
|
||||
|
||||
dest = main_pool_alloc(offset + size + bssLength, side);
|
||||
void *dest = main_pool_alloc((offset + size + bssLength), side);
|
||||
if (dest != NULL) {
|
||||
dma_read((u8 *)dest + offset, srcStart, srcEnd);
|
||||
dma_read(((u8 *)dest + offset), srcStart, srcEnd);
|
||||
if (bssLength) {
|
||||
bzero((u8 *)dest + offset + size, bssLength);
|
||||
bzero(((u8 *)dest + offset + size), bssLength);
|
||||
}
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
#define TLB_PAGE_SIZE 4096 //Blocksize of TLB transfers. Larger values can be faster to transfer, but more wasteful of RAM.
|
||||
#define TLB_PAGE_SIZE 4096 // Blocksize of TLB transfers. Larger values can be faster to transfer, but more wasteful of RAM.
|
||||
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};
|
||||
u8 gTlbSegments[NUM_TLB_SEGMENTS] = { 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) {
|
||||
osMapTLB(gTlbEntries++, OS_PM_4K, (void *)virtualAddress, physicalAddress, physicalAddress + TLB_PAGE_SIZE, -1);
|
||||
virtualAddress += 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;
|
||||
length -= TLB_PAGE_SIZE;
|
||||
gTlbSegments[segment]++;
|
||||
} else {
|
||||
osMapTLB(gTlbEntries++, OS_PM_4K, (void *)virtualAddress, physicalAddress, -1, -1);
|
||||
gTlbSegments[segment]++;
|
||||
}
|
||||
virtualAddress += TLB_PAGE_SIZE;
|
||||
virtualAddress += TLB_PAGE_SIZE;
|
||||
physicalAddress += TLB_PAGE_SIZE;
|
||||
length -= TLB_PAGE_SIZE;
|
||||
length -= TLB_PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,12 +343,12 @@ 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) {
|
||||
addr = dynamic_dma_read(srcStart, srcEnd, side, TLB_PAGE_SIZE, (uintptr_t)bssEnd - (uintptr_t)bssStart);
|
||||
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);
|
||||
mapTLBPages((segment << 24), VIRTUAL_TO_PHYSICAL(realAddr), ((srcEnd - srcStart) + ((uintptr_t)bssEnd - (uintptr_t)bssStart)), segment);
|
||||
}
|
||||
} else {
|
||||
addr = dynamic_dma_read(srcStart, srcEnd, side, 0, 0);
|
||||
@@ -347,9 +356,9 @@ void *load_segment(s32 segment, u8 *srcStart, u8 *srcEnd, u32 side, u8 *bssStart
|
||||
set_segment_base_addr(segment, addr);
|
||||
}
|
||||
}
|
||||
#if PUPPYPRINT_DEBUG
|
||||
ramsizeSegment[segment+nameTable-2] = (s32)srcEnd- (s32)srcStart;
|
||||
#endif
|
||||
#if PUPPYPRINT_DEBUG
|
||||
ramsizeSegment[(segment + nameTable) - 2] = ((s32)srcEnd - (s32)srcStart);
|
||||
#endif
|
||||
return addr;
|
||||
}
|
||||
|
||||
@@ -384,6 +393,7 @@ 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
|
||||
@@ -423,14 +433,15 @@ void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) {
|
||||
main_pool_free(compressed);
|
||||
}
|
||||
}
|
||||
#if PUPPYPRINT_DEBUG
|
||||
ramsizeSegment[segment+nameTable-2] = (s32)srcEnd - (s32)srcStart;
|
||||
#endif
|
||||
#if PUPPYPRINT_DEBUG
|
||||
ramsizeSegment[(segment + nameTable) - 2] = (s32)srcEnd - (s32)srcStart;
|
||||
#endif
|
||||
return dest;
|
||||
}
|
||||
|
||||
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
|
||||
@@ -467,7 +478,7 @@ void *load_segment_decompress_heap(u32 segment, u8 *srcStart, u8 *srcEnd) {
|
||||
void load_engine_code_segment(void) {
|
||||
void *startAddr = (void *) _engineSegmentStart;
|
||||
u32 totalSize = _engineSegmentEnd - _engineSegmentStart;
|
||||
UNUSED u32 alignedSize = ALIGN16(_engineSegmentRomEnd - _engineSegmentRomStart);
|
||||
// UNUSED u32 alignedSize = ALIGN16(_engineSegmentRomEnd - _engineSegmentRomStart);
|
||||
|
||||
bzero(startAddr, totalSize);
|
||||
osWritebackDCacheAll();
|
||||
@@ -630,7 +641,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;
|
||||
}
|
||||
@@ -658,7 +669,6 @@ void setup_dma_table_list(struct DmaHandlerList *list, void *srcAddr, void *buff
|
||||
}
|
||||
|
||||
s32 load_patchable_table(struct DmaHandlerList *list, s32 index) {
|
||||
s32 ret = FALSE;
|
||||
struct DmaTable *table = list->dmaTable;
|
||||
|
||||
if ((u32)index < table->count) {
|
||||
@@ -668,8 +678,8 @@ s32 load_patchable_table(struct DmaHandlerList *list, s32 index) {
|
||||
if (list->currentAddr != addr) {
|
||||
dma_read(list->bufTarget, addr, addr + size);
|
||||
list->currentAddr = addr;
|
||||
ret = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
return FALSE;
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef SLIDEC_H
|
||||
#define SLIDEC_H
|
||||
|
||||
void slidstart(unsigned char*, unsigned char *);
|
||||
void slidstart(unsigned char *compress, unsigned char *decompress);
|
||||
|
||||
void decompress(void *mio0, void *dest);
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
* Programmed By Melody-Yoshi *
|
||||
******************************/
|
||||
/* How to use this function.
|
||||
void slidstart(unsigned char *,unsigned char *);
|
||||
void slidstart(unsigned char *compress, unsigned char *decompress);
|
||||
first argument is top address of compress data.(align 4)
|
||||
next argument is top address of decompress.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user