diff --git a/CMakeLists.txt b/CMakeLists.txt index 51bc4561..419f2f30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,6 +158,10 @@ if (MSVC) set_source_files_properties(extern/longjmp_win64/longjmp_win64.asm PROPERTIES LANGUAGE ASM_MASM) endif () target_link_options(dol PRIVATE "/DEF:${CMAKE_SOURCE_DIR}/dol.def") + target_compile_options(dol PRIVATE "/Zi") + target_compile_options(dol PRIVATE "/Ob0") + target_compile_options(dol PRIVATE "/Od") + target_compile_options(dol PRIVATE "/RTC1") else () # target_compile_options(dol PRIVATE "-fvisibility=hidden") # target_link_options(dol PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/dol.map") @@ -187,6 +191,10 @@ foreach (dir ${REL_DIRS}) target_include_directories(${dir} PRIVATE include build/GMPE01_00/include) if (MSVC) set_target_properties(${dir} PROPERTIES LINK_FLAGS "/EXPORT:ObjectSetup") + target_compile_options(${dir} PRIVATE "/Zi") + target_compile_options(${dir} PRIVATE "/Ob0") + target_compile_options(${dir} PRIVATE "/Od") + target_compile_options(${dir} PRIVATE "/RTC1") elseif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows) target_compile_options(${dir} PRIVATE "-fvisibility=hidden") target_link_options(${dir} PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/rel.map") diff --git a/extern/aurora b/extern/aurora index 357ecba0..cd349a9d 160000 --- a/extern/aurora +++ b/extern/aurora @@ -1 +1 @@ -Subproject commit 357ecba0ae00246332447823fddd83b8da89357f +Subproject commit cd349a9d85600c01b54c430afa9a1f794695d048 diff --git a/include/dolphin/ar.h b/include/dolphin/ar.h index db0adaf3..bbdea48a 100644 --- a/include/dolphin/ar.h +++ b/include/dolphin/ar.h @@ -20,7 +20,7 @@ typedef void (*ARCallback)(void); ARCallback ARRegisterDMACallback(ARCallback callback); u32 ARGetDMAStatus(void); -void ARStartDMA(u32 type, u32 mainmem_addr, u32 aram_addr, u32 length); +void ARStartDMA(u32 type, uintptr_t mainmem_addr, u32 aram_addr, u32 length); u32 ARInit(u32* stack_index_addr, u32 num_entries); u32 ARGetBaseAddress(void); BOOL ARCheckInit(void); diff --git a/include/dolphin/gx/GXDispList.h b/include/dolphin/gx/GXDispList.h index 552eda2d..8e49bfc2 100644 --- a/include/dolphin/gx/GXDispList.h +++ b/include/dolphin/gx/GXDispList.h @@ -7,8 +7,15 @@ extern "C" { #endif +#ifdef AURORA +#define GXCALLDISPLAYLISTLE GXCallDisplayListLE +#else +#define GXCALLDISPLAYLISTLE GXCallDisplayList +#endif + void GXBeginDisplayList(void* list, u32 size); u32 GXEndDisplayList(void); +void GXCallDisplayListLE(const void* list, u32 nbytes); void GXCallDisplayList(const void* list, u32 nbytes); #ifdef __cplusplus diff --git a/include/game/animdata.h b/include/game/animdata.h index 63876d94..b4199a7e 100644 --- a/include/game/animdata.h +++ b/include/game/animdata.h @@ -78,6 +78,13 @@ typedef struct anim_data { /* 0x08 */ AnimBankData *bank; /* 0x0C */ AnimPatData *pat; /* 0x10 */ AnimBmpData *bmp; +#ifdef TARGET_PC + u32 valid; +#endif } AnimData; //sizeof 0x14 +#ifdef TARGET_PC +#define ANIM_DATA_ALLOCATION_VALID 0xD3D3D3D3 +#endif + #endif diff --git a/include/game/hsfanim.h b/include/game/hsfanim.h index c2dc2c4e..e251c5fb 100644 --- a/include/game/hsfanim.h +++ b/include/game/hsfanim.h @@ -9,6 +9,10 @@ typedef struct model_data ModelData; typedef struct particle_data ParticleData; +#ifdef TARGET_PC +typedef void (*ParticleDLCallFunc)(ParticleData *particle); +#endif + typedef void (*ParticleHook)(ModelData *model, ParticleData *particle, Mtx matrix); typedef struct { @@ -45,11 +49,11 @@ struct particle_data { /* 0x34 */ u32 unk_34; /* 0x38 */ s32 unk_38; /* 0x3C */ u32 unk_3C; - /* 0x40 */ s32 unk_40; + /* 0x40 */ s32 unk_40; // dlSize /* 0x44 */ AnimData *unk_44; /* 0x48 */ HsfanimStruct01 *unk_48; /* 0x4C */ Vec *unk_4C; - /* 0x50 */ void *unk_50; + /* 0x50 */ void *unk_50; // dlPtr /* 0x54 */ ParticleHook unk_54; }; // Size 0x58 diff --git a/include/game/msm.h b/include/game/msm.h index 032b876c..2916a32e 100644 --- a/include/game/msm.h +++ b/include/game/msm.h @@ -165,6 +165,7 @@ s32 msmSysDelGroupAll(void); s32 msmSysGetSampSize(BOOL baseGrp); s32 msmSysDelGroupBase(s32 grpNum); s32 msmSysSetAux(s32 auxA, s32 auxB); +void msmSysRegularProc(void); s32 msmSeSetParam(int seNo, MSM_SEPARAM *param); int msmSePlay(int seId, MSM_SEPARAM *param); diff --git a/src/REL/bootDll/main.c b/src/REL/bootDll/main.c index 391a9065..3850bc7d 100644 --- a/src/REL/bootDll/main.c +++ b/src/REL/bootDll/main.c @@ -546,8 +546,6 @@ void ObjectSetup(void) s16 sprite; AnimData *sprite_data; s16 i; -#ifdef __MWERKS__ - // TODO PC titleMdlId[0] = model = Hu3DModelCreateFile(TITLE_CHAR_HSF); Hu3DModelAttrSet(model, HU3D_ATTR_DISPOFF); Hu3DModelAttrSet(model, HU3D_MOTATTR_LOOP); @@ -559,7 +557,6 @@ void ObjectSetup(void) Hu3DModelAttrSet(model, HU3D_MOTATTR_LOOP); Hu3DModelCameraInfoSet(model, 1); Hu3DModelLightInfoSet(model, 1); -#endif #if VERSION_NTSC bootGrpId = HuSprGrpCreate(4); #else diff --git a/src/REL/m440Dll/main.c b/src/REL/m440Dll/main.c index 97152388..7dce13e0 100644 --- a/src/REL/m440Dll/main.c +++ b/src/REL/m440Dll/main.c @@ -1901,7 +1901,7 @@ void fn_1_806C(ModelData *arg0, Mtx arg1) temp_r29 = &temp_r31->unk2C[temp_r31->unk28->unk38[0]]; fn_1_7D60(temp_r29->unk80, temp_r29, 0); lbl_1_bss_2C = 1; - HuSprTexLoad(*hiliteAnim, 0, lbl_1_bss_2C, GX_CLAMP, GX_CLAMP, GX_LINEAR); + HuSprTexLoad(hiliteAnim[0], 0, lbl_1_bss_2C, GX_CLAMP, GX_CLAMP, GX_LINEAR); fn_1_8470(temp_r31->unk28, temp_r29); } GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); diff --git a/src/REL/mentDll/main.c b/src/REL/mentDll/main.c index db8375f3..789030fc 100644 --- a/src/REL/mentDll/main.c +++ b/src/REL/mentDll/main.c @@ -4,6 +4,7 @@ #include "game/armem.h" #include "game/chrman.h" #include "game/hsfdraw.h" +#include "game/hsfex.h" #include "game/hsfman.h" #include "game/hsfmotion.h" #include "game/minigame_seq.h" @@ -15,6 +16,11 @@ #include "game/window.h" #include "game/wipe.h" +#ifndef __MWERKS__ +extern s32 rand8(void); +#include "game/audio.h" +#endif + typedef struct MentDllUnkBssE4Struct { /* 0x00 */ s32 unk_00; /* 0x04 */ s32 unk_04; diff --git a/src/REL/modeseldll/modesel.c b/src/REL/modeseldll/modesel.c index 42f3d771..1501d249 100644 --- a/src/REL/modeseldll/modesel.c +++ b/src/REL/modeseldll/modesel.c @@ -31,8 +31,6 @@ s16 lbl_1_bss_80; void fn_1_3668(void); -// Scratch is at https://decomp.me/scratch/iirXp -// Register allocation issues at line 180 with load of 1.0 double constant s32 fn_1_2490(void) { float sp10[2]; diff --git a/src/game/data.c b/src/game/data.c index 5376eab5..f962c140 100644 --- a/src/game/data.c +++ b/src/game/data.c @@ -337,7 +337,12 @@ void *HuDataReadNum(s32 data_num, s32 num) } read_stat = &ReadDataStat[status]; GetFileInfo(read_stat, data_num & 0xFFFF); +#ifdef TARGET_PC + // TODO PC why is the allocation invalid if we use HEAP_SYSTEM? + buf = HuMemDirectMallocNum(HEAP_DATA, DATA_EFF_SIZE(read_stat->raw_len), num); +#else buf = HuMemDirectMallocNum(HEAP_SYSTEM, DATA_EFF_SIZE(read_stat->raw_len), num); +#endif if(buf) { HuDecodeData(read_stat->file, buf, read_stat->raw_len, read_stat->comp_type); } diff --git a/src/game/gamework.c b/src/game/gamework.c index 3c066ff6..fb9c6fda 100644 --- a/src/game/gamework.c +++ b/src/game/gamework.c @@ -4,6 +4,10 @@ #include "string.h" #include "version.h" +#ifndef __MWERKS__ +#include "game/pad.h" +#endif + SHARED_SYM s16 GwLanguage = 1; SHARED_SYM s16 GwLanguageSave = -1; diff --git a/src/game/hsfanim.c b/src/game/hsfanim.c index c24c6a98..349d3bb4 100755 --- a/src/game/hsfanim.c +++ b/src/game/hsfanim.c @@ -9,6 +9,10 @@ #include "ext_math.h" #include "string.h" +#ifndef __MWERKS__ +#include "game/frand.h" +#endif + typedef struct { /* 0x00 */ s16 unk00; /* 0x02 */ s16 unk02; @@ -824,13 +828,13 @@ static void particleFunc(ModelData *arg0, Mtx arg1) { } GXClearVtxDesc(); GXSetVtxDesc(GX_VA_POS, GX_INDEX16); - GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_RGBA6, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); GXSETARRAY(GX_VA_POS, temp_r31->unk_4C, temp_r31->unk_30 * 4 * sizeof(Vec), sizeof(Vec)); GXSetVtxDesc(GX_VA_CLR0, GX_INDEX16); GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0); GXSETARRAY(GX_VA_CLR0, &temp_r31->unk_48->unk40, temp_r31->unk_30 * sizeof(GXColor), 0x44); GXSetVtxDesc(GX_VA_TEX0, GX_INDEX16); - GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_RGBA6, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0); GXSETARRAY(GX_VA_TEX0, baseST, sizeof(baseST), 8); GXCallDisplayList(temp_r31->unk_50, temp_r31->unk_40); } diff --git a/src/game/hsfdraw.c b/src/game/hsfdraw.c index c225d85d..8e14490f 100755 --- a/src/game/hsfdraw.c +++ b/src/game/hsfdraw.c @@ -90,7 +90,6 @@ static u16 *faceNumBuf; static s32 DLTotalNum; static u32 totalSize; static uintptr_t mallocNo; -static uintptr_t mallocNo; static s32 curModelID; static s16 polySize; static s32 PGFinishF; @@ -189,10 +188,6 @@ static void objCall(ModelData *arg0, HsfObject *arg1) static void objMesh(ModelData *arg0, HsfObject *arg1) { -#ifdef TARGET_PC - // TODO PC - return; -#endif HsfDrawObject *temp_r29; HsfConstData *temp_r25; HsfTransform *var_r30; @@ -753,11 +748,11 @@ static void FaceDraw(HsfDrawObject *arg0, HsfFace *arg1) SetTevStageTex(arg0, temp_r30); } sp28 = (u8 *)DLBufStartP + DrawData[drawCnt].dlOfs; - GXCallDisplayList(sp28, DrawData[drawCnt].dlSize); + GXCALLDISPLAYLISTLE(sp28, DrawData[drawCnt].dlSize); } else { sp28 = (u8 *)DLBufStartP + DrawData[drawCnt].dlOfs; - GXCallDisplayList(sp28, DrawData[drawCnt].dlSize); + GXCALLDISPLAYLISTLE(sp28, DrawData[drawCnt].dlSize); } drawCnt++; } @@ -1778,7 +1773,7 @@ static void FaceDrawShadow(HsfDrawObject *arg0, HsfFace *arg1) else { GXSetVtxDesc(GX_VA_NRM, GX_INDEX16); if (temp_r28->hsfData->cenvCnt == 0) { - GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_RGB8, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_NRM, GX_NRM_XYZ, GX_S8, 0); GXSETARRAY(GX_VA_NRM, temp_r31->data.normal->data, temp_r31->data.vertex->count * 3, 3); } else { @@ -1807,7 +1802,7 @@ static void FaceDrawShadow(HsfDrawObject *arg0, HsfFace *arg1) GXSetChanCtrl(GX_COLOR0A0, GX_FALSE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); GXSetChanCtrl(GX_COLOR1A1, GX_FALSE, GX_SRC_REG, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); var_r26 = (u8 *)DLBufStartP + DrawData[drawCnt].dlOfs; - GXCallDisplayList(var_r26, DrawData[drawCnt].dlSize); + // GXCALLDISPLAYLISTLE(var_r26, DrawData[drawCnt].dlSize); } else { if (!(temp_r27->flags & 0x400)) { @@ -1815,7 +1810,7 @@ static void FaceDrawShadow(HsfDrawObject *arg0, HsfFace *arg1) return; } var_r26 = (u8 *)DLBufStartP + DrawData[drawCnt].dlOfs; - GXCallDisplayList(var_r26, DrawData[drawCnt].dlSize); + // GXCALLDISPLAYLISTLE(var_r26, DrawData[drawCnt].dlSize); } drawCnt++; } @@ -2514,12 +2509,9 @@ void MakeDisplayList(s16 arg0, uintptr_t arg1) var_r30 = &Hu3DData[arg0]; curModelID = arg0; mallocNo = arg1; -#ifdef __MWERKS__ - // TODO PC faceNumBuf = HuMemDirectMallocNum(HEAP_DATA, 0x800 * sizeof(u16), mallocNo); MDObjCall(temp_r31, temp_r31->root); HuMemDirectFree(faceNumBuf); -#endif if (var_r30->attr & HU3D_ATTR_SHADOW) { Hu3DShadowCamBit++; } @@ -2629,7 +2621,7 @@ static void MDFaceDraw(HsfObject *arg0, HsfFace *arg1) if (temp_r30 != materialBak || polyTypeBak != (arg1->type & 7) || (arg1->type & 7) == 4) { polyTypeBak = arg1->type & 7; materialBak = temp_r30; - DrawData[drawCnt].dlOfs = (u32)DLBufP - (u32)DLBufStartP; + DrawData[drawCnt].dlOfs = (uintptr_t)DLBufP - (uintptr_t)DLBufStartP; GXBeginDisplayList(DLBufP, 0x20000); GXResetWriteGatherPipe(); if (temp_r30->numAttrs == 0) { @@ -2729,9 +2721,6 @@ static void MDFaceDraw(HsfObject *arg0, HsfFace *arg1) GXTexCoord1x16(arg1->indices[1][3]); } } -#ifdef TARGET_PC - GXEnd(); -#endif faceCnt = faceNumBuf[drawCnt] / 3; break; case 3: @@ -2806,9 +2795,6 @@ static void MDFaceDraw(HsfObject *arg0, HsfFace *arg1) GXTexCoord1x16(arg1->indices[1][3]); } } -#ifdef TARGET_PC - GXEnd(); -#endif faceCnt = faceNumBuf[drawCnt] / 4; break; case 4: @@ -2884,9 +2870,6 @@ static void MDFaceDraw(HsfObject *arg0, HsfFace *arg1) GXTexCoord1x16(var_r24[3]); } } -#ifdef TARGET_PC - GXEnd(); -#endif faceCnt = arg1->strip.count + 1; break; } diff --git a/src/game/hsfex.c b/src/game/hsfex.c index 9455c65d..beac8a84 100644 --- a/src/game/hsfex.c +++ b/src/game/hsfex.c @@ -2,9 +2,11 @@ #include "game/hsfman.h" #include "game/hsfmotion.h" #include "game/disp.h" +#include "game/process.h" #include "ext_math.h" + #define DISP_HALF_W (HU_DISP_WIDTH/2.0f) #define DISP_HALF_H (HU_DISP_HEIGHT/2.0f) diff --git a/src/game/hsfload.c b/src/game/hsfload.c index c5eebe8b..aa4d93c8 100644 --- a/src/game/hsfload.c +++ b/src/game/hsfload.c @@ -962,6 +962,7 @@ static void CenvLoad(void) dual_new = dual_file = cenv_new[i].dualData; for(j=0; jattribute); - HuMemDirectFree(data->bitmap); - HuMemDirectFree(data->cenv); - HuMemDirectFree(data->skeleton); - for (i = 0; i < data->faceCnt; i++) { - HuMemDirectFree(data->face[i].data); + if (data->attributeCnt) + HuMemDirectFree(data->attribute); + if (data->bitmapCnt) + HuMemDirectFree(data->bitmap); + if (data->skeletonCnt) + HuMemDirectFree(data->skeleton); + if (data->faceCnt) { + for (i = 0; i < data->faceCnt; i++) { + HuMemDirectFree(data->face[i].data); + } + HuMemDirectFree(data->face); } - HuMemDirectFree(data->face); - HuMemDirectFree(data->material); - for (i = 0; i < data->motionCnt; i++) { - HsfMotion *motion = &data->motion[i]; + if (data->materialCnt) + HuMemDirectFree(data->material); + if (data->motionCnt) { + HsfMotion *motion = data->motion; for (j = 0; j < motion->numTracks; j++) { HsfTrack *track = motion->track; if (track->type == HSF_TRACK_ATTRIBUTE && track->curveType == HSF_CURVE_BITMAP) { @@ -1915,24 +1926,36 @@ void KillHSF(HsfData *data) } } HuMemDirectFree(motion->track); + HuMemDirectFree(data->motion); } - HuMemDirectFree(data->motion); - HuMemDirectFree(data->normal); - HuMemDirectFree(data->object); - HuMemDirectFree(data->matrix); - HuMemDirectFree(data->palette); - HuMemDirectFree(data->st); - HuMemDirectFree(data->vertex); - for (i = 0; i < data->cenvCnt; i++) { - HsfCenv *cenv = &data->cenv[i]; - HuMemDirectFree(cenv->dualData); - HuMemDirectFree(cenv->multiData); + if (data->normalCnt) + HuMemDirectFree(data->normal); + if (data->objectCnt) + HuMemDirectFree(data->object); + if (data->matrixCnt) + HuMemDirectFree(data->matrix); + if (data->paletteCnt) + HuMemDirectFree(data->palette); + if (data->stCnt) + HuMemDirectFree(data->st); + if (data->vertexCnt) + HuMemDirectFree(data->vertex); + if (data->cenvCnt) { + for (i = 0; i < data->cenvCnt; i++) { + HsfCenv *cenv = &data->cenv[i]; + HuMemDirectFree(cenv->dualData); + HuMemDirectFree(cenv->multiData); + } + HuMemDirectFree(data->cenv); } - HuMemDirectFree(data->cenv); - HuMemDirectFree(data->cluster); - HuMemDirectFree(data->part); - HuMemDirectFree(data->shape); - HuMemDirectFree(data->mapAttr); + if (data->clusterCnt) + HuMemDirectFree(data->cluster); + if (data->partCnt) + HuMemDirectFree(data->part); + if (data->shapeCnt) + HuMemDirectFree(data->shape); + if (data->mapAttrCnt) + HuMemDirectFree(data->mapAttr); HuMemDirectFree(data->symbol); } #endif diff --git a/src/game/hsfman.c b/src/game/hsfman.c index 7d640d35..04820c45 100644 --- a/src/game/hsfman.c +++ b/src/game/hsfman.c @@ -293,10 +293,13 @@ void Hu3DAllKill(void) { Hu3DCameraAllKill(); Hu3DLightAllKill(); Hu3DAnimAllKill(); +#if __MWERKS__ + // this causes anim to be reallocated, so we lose the old allocation if(reflectAnim[0] != (AnimData *)refMapData0) { HuMemDirectFree(reflectAnim[0]); } reflectAnim[0] = HuSprAnimRead(refMapData0); +#endif if(Hu3DShadowData.unk_04) { HuMemDirectFree(Hu3DShadowData.unk_04); Hu3DShadowCamBit = 0; @@ -2030,10 +2033,13 @@ void Hu3DShadowExec(void) { GXSetChanCtrl(GX_COLOR0A0, 0, GX_SRC_REG, GX_SRC_REG, 0, GX_DF_CLAMP, GX_AF_NONE); GXBegin(GX_QUADS, GX_VTXFMT0, 4); - GXColor3u8(0, 0, 0); - GXColor3u8(1, 0, 0); - GXColor3u8(1, 1, 0); - GXColor3u8(0, 1, 0); + GXPosition3u8(0, 0, 0); + GXPosition3u8(1, 0, 0); + GXPosition3u8(1, 1, 0); + GXPosition3u8(0, 1, 0); +#ifdef TARGET_PC + GXEnd(); +#endif } s16 Hu3DProjectionCreate(void *arg0, f32 arg8, f32 arg9, f32 argA) { diff --git a/src/game/minigame_seq.c b/src/game/minigame_seq.c index e74486ee..c0dd07a7 100644 --- a/src/game/minigame_seq.c +++ b/src/game/minigame_seq.c @@ -1,4 +1,5 @@ #include "game/armem.h" +#include "game/audio.h" #include "game/disp.h" #include "game/gamework_data.h" #include "game/hsfman.h" diff --git a/src/game/objsub.c b/src/game/objsub.c index 6a402e3e..faf45970 100644 --- a/src/game/objsub.c +++ b/src/game/objsub.c @@ -1,6 +1,7 @@ #include "game/objsub.h" #include "game/data.h" #include "game/gamework_data.h" +#include "game/hsfman.h" #include "game/object.h" #include "game/pad.h" #include "game/window.h" diff --git a/src/game/saveload.c b/src/game/saveload.c index 4a8f1ea1..b267efc6 100644 --- a/src/game/saveload.c +++ b/src/game/saveload.c @@ -5,12 +5,14 @@ #include "game/flag.h" #include "game/gamework_data.h" #include "game/pad.h" +#include "game/process.h" #include "game/sprite.h" #include "game/window.h" #include "stddef.h" #include "string.h" + #if VERSION_ENG #define SAVE_WRITE_BEGIN _SetFlag(FLAG_ID_MAKE(3, 0)); #define SAVE_WRITE_END _ClearFlag(FLAG_ID_MAKE(3, 0)); diff --git a/src/game/sprman.c b/src/game/sprman.c index d685c795..1a656295 100644 --- a/src/game/sprman.c +++ b/src/game/sprman.c @@ -218,19 +218,25 @@ AnimData *HuSprAnimRead(void *data) AnimBankData *bank; AnimPatData *pat; + AnimData *anim = data; #ifdef TARGET_PC - AnimData *anim = HuMemDirectMallocNum(HEAP_DATA, sizeof(AnimData), MEMORY_DEFAULT_NUM); + s16 j; + if (anim->valid == ANIM_DATA_ALLOCATION_VALID) { + anim->useNum++; + return anim; + } + anim = HuMemDirectMalloc(HEAP_DATA, sizeof(AnimData)); byteswap_animdata(data, anim); + anim->valid = ANIM_DATA_ALLOCATION_VALID; #else - AnimData *anim = (AnimData *)data; -#endif if((uintptr_t)anim->bank & ~0xFFFF) { anim->useNum++; return anim; } +#endif bank = (void *)((uintptr_t)anim->bank+(uintptr_t)data); #ifdef TARGET_PC - bank = HuMemDirectMallocNum(HEAP_DATA, anim->bankNum * sizeof(AnimBankData), MEMORY_DEFAULT_NUM); + bank = HuMemDirectMalloc(HEAP_DATA, anim->bankNum * sizeof(AnimBankData)); for(i=0; ibankNum; i++) { byteswap_animbankdata(&((AnimBankData32b*)((uintptr_t)anim->bank+(uintptr_t)data))[i], &bank[i]); } @@ -238,7 +244,7 @@ AnimData *HuSprAnimRead(void *data) anim->bank = bank; pat = (void *)((uintptr_t)anim->pat+(uintptr_t)data); #ifdef TARGET_PC - pat = HuMemDirectMallocNum(HEAP_DATA, anim->patNum * sizeof(AnimPatData), MEMORY_DEFAULT_NUM); + pat = HuMemDirectMalloc(HEAP_DATA, anim->patNum * sizeof(AnimPatData)); for(i=0; ipatNum; i++) { byteswap_animpatdata(&((AnimPatData32b*)((uintptr_t)anim->pat+(uintptr_t)data))[i], &pat[i]); } @@ -246,7 +252,7 @@ AnimData *HuSprAnimRead(void *data) anim->pat = pat; bmp = (void *)((uintptr_t)anim->bmp+(uintptr_t)data); #ifdef TARGET_PC - bmp = HuMemDirectMallocNum(HEAP_DATA, anim->bmpNum * sizeof(AnimBmpData), MEMORY_DEFAULT_NUM); + bmp = HuMemDirectMalloc(HEAP_DATA, anim->bmpNum * sizeof(AnimBmpData)); for(i=0; ibmpNum; i++) { byteswap_animbmpdata(&((AnimBmpData32b*)((uintptr_t)anim->bmp+(uintptr_t)data))[i], &bmp[i]); } @@ -261,7 +267,9 @@ AnimData *HuSprAnimRead(void *data) for(i=0; ipatNum; i++, pat++) { pat->layer = (AnimLayerData *)((uintptr_t)pat->layer+(uintptr_t)data); #ifdef TARGET_PC - byteswap_animlayerdata(pat->layer); + for (j = 0; j < pat->layerNum; j++) { + byteswap_animlayerdata(&pat->layer[j]); + } #endif } for(i=0; ibmpNum; i++, bmp++) { @@ -649,6 +657,15 @@ AnimData *HuSprAnimMake(s16 sizeX, s16 sizeY, s16 dataFmt) AnimBankData *bank; AnimData *new_anim; +#ifdef TARGET_PC + // as these are allocated in HuSprAnimRead, we need to do so here too so we don't get issues when freeing + anim = HuMemDirectMalloc(HEAP_DATA, sizeof(AnimData)); + anim->bank = bank = HuMemDirectMalloc(HEAP_DATA, sizeof(AnimBankData)); + bank->frame = frame = HuMemDirectMalloc(HEAP_DATA, sizeof(AnimFrameData)); + anim->pat = pat = HuMemDirectMalloc(HEAP_DATA, sizeof(AnimPatData)); + pat->layer = layer = HuMemDirectMalloc(HEAP_DATA, sizeof(AnimLayerData)); + anim->bmp = bmp = HuMemDirectMalloc(HEAP_DATA, sizeof(AnimBmpData)); +#else anim = new_anim = HuMemDirectMalloc(HEAP_DATA, sizeof(AnimData)+sizeof(AnimBankData)+sizeof(AnimFrameData) +sizeof(AnimPatData)+sizeof(AnimLayerData)+sizeof(AnimBmpData)); @@ -662,6 +679,7 @@ AnimData *HuSprAnimMake(s16 sizeX, s16 sizeY, s16 dataFmt) pat->layer = layer; bmp = temp = ((char *)temp+sizeof(AnimLayerData)); anim->bmp = bmp; +#endif anim->useNum = 0; anim->bankNum = 1; anim->patNum = 1; diff --git a/src/port/ar.c b/src/port/ar.c index 71a1ae93..10c2fc37 100644 --- a/src/port/ar.c +++ b/src/port/ar.c @@ -20,7 +20,7 @@ u32 ARGetSize() return sizeof(ARAM); } -void ARStartDMA(u32 type, u32 mainmem_addr, u32 aram_addr, u32 length) +void ARStartDMA(u32 type, uintptr_t mainmem_addr, u32 aram_addr, u32 length) { switch (type) { diff --git a/src/port/audio.c b/src/port/audio.c index 0e5423df..07a9dfcb 100644 --- a/src/port/audio.c +++ b/src/port/audio.c @@ -316,7 +316,7 @@ s32 HuAudSeqMidiCtrlGet(s32 musNo, s8 channel, s8 ctrl) { s32 HuAudSStreamPlay(s16 streamId) { MSM_STREAMPARAM param; - s32 result; + s32 result = 0; if (musicOffF != 0 || omSysExitReq != 0) { return 0; @@ -502,12 +502,12 @@ void HuAudSndCommonGrpSet(s16 grpId, s32 groupCheck) { // while ((msmMusGetNumPlay(1) != 0 || msmSeGetNumPlay(1) != 0) // && OSTicksToMilliseconds(OSGetTick() - osTick) < 500); OSReport("CommonGrpSet %d\n", grpId); - if (groupCheck != 0) { - // err = msmSysDelGroupBase(0); - if (err < 0) { - OSReport("Del Group Error %d\n", err); - } - } + // if (groupCheck != 0) { + // // err = msmSysDelGroupBase(0); + // if (err < 0) { + // OSReport("Del Group Error %d\n", err); + // } + // } // buf = HuMemDirectMalloc(HEAP_DATA, msmSysGetSampSize(grpId)); // msmSysLoadGroupBase(grpId, buf); // HuMemDirectFree(buf); diff --git a/src/port/byteswap.cpp b/src/port/byteswap.cpp index 81e8b2c7..d9fec8e0 100644 --- a/src/port/byteswap.cpp +++ b/src/port/byteswap.cpp @@ -570,10 +570,13 @@ template void bswap(B &base, HsfCenvMulti32b &obj, HsfCenvMulti &de bswap(base, obj.posCnt); bswap(base, obj.normal); bswap(base, obj.normalCnt); + bswap(base, obj.weight); dest.weightCnt = obj.weightCnt; dest.pos = obj.pos; dest.posCnt = obj.posCnt; + dest.normal = obj.normal; + dest.normalCnt = obj.normalCnt; dest.weight = reinterpret_cast(static_cast(obj.weight)); } @@ -695,13 +698,13 @@ template void bswap(B &base, HsfBitmapKey32b &obj, HsfBitmapKey &de template void bswap(B &base, HsfTrack32b &obj, HsfTrack &dest) { - bswap(base, obj.type); - bswap(base, obj.start); + bswap(base, obj.target); bswap(base, obj.curveType); bswap(base, obj.numKeyframes); dest.type = obj.type; dest.start = obj.start; + dest.target = obj.target; dest.curveType = obj.curveType; dest.numKeyframes = obj.numKeyframes; diff --git a/src/port/stubs.c b/src/port/stubs.c index 75c5ca5e..e5442505 100644 --- a/src/port/stubs.c +++ b/src/port/stubs.c @@ -624,18 +624,14 @@ void GXUnknownu16(const u16 x) void GXWaitDrawDone(void) { - puts("GXWaitDrawDone is a stub"); + // puts("GXWaitDrawDone is a stub"); } void GXSetTevIndTile(GXTevStageID tev_stage, GXIndTexStageID ind_stage, u16 tilesize_s, u16 tilesize_t, u16 tilespacing_s, u16 tilespacing_t, GXIndTexFormat format, GXIndTexMtxID matrix_sel, GXIndTexBiasSel bias_sel, GXIndTexAlphaSel alpha_sel) { - puts("GXSetTevIndTile is a stub"); -} - -void GXSetTexCoordScaleManually(GXTexCoordID coord, u8 enable, u16 ss, u16 ts) -{ - puts("GXSetTexCoordScaleManually is a stub"); + // TODO + // puts("GXSetTevIndTile is a stub"); } void GXResetWriteGatherPipe(void) @@ -680,11 +676,6 @@ void GXGetViewportv(f32 *vp) // TODO } -void GXSetZTexture(GXZTexOp op, GXTexFmt fmt, u32 bias) -{ - // TODO -} - // Hudson void HuDvdErrDispInit(GXRenderModeObj *rmode, void *xfb1, void *xfb2) { }