26 02 27 pjb dev 2 (#41)

* fix kankyo UB

* Fix TEV Stage DL writing

BE issue

* BE Fixes in materials/shapes

* Move to Aurora GD impl

* JUTDataFileHeader

* j3d: load vertex and texture not through GD

* Endian swap vertex data (mostly)

* Just exit(0) when closing the game

Fix crashes :godo:

* fix fopAcM_ct_placement and remove memcpy

* J3D: track vertex arrays correctly, swap work

* fix visibility, turn off overridden new/delete when we call into aurora

* event: cut name be

* Default window improvements

Double size, allow OS to decide position

* survive TParse::parseHeader_next

* color swap fix

* swap endian/fixes oob function pointer

* Remove GXGetViewportv stub

Aurora has it now

* Set array pointers via GD again

Relies on https://github.com/encounter/aurora/pull/35

* Let Aurora decide graphics backend

* disable procbar drawing

* Fix TColor endianness conversion issues

Fixes the wrong color for the flashing logo

* cam param swap

* simplify vtx loading, mat/amb color fix

* endian swap stb/fvb data

* aurora stat changes

* fix storage buffer crash

dont unnecessarily reassign vertex buffers in a way that forces aurora to recache things

* set bgobj spec fix

* add camera debug, endian swap more stb data, d_a_bg_obj::spec_data_c swapped

* JKRExpHeap: fix bad allocator slowdown

* solid tex

* texture caching

* log level

* fix window aspect ratio, disable bloom, endian swap camera type data

camera is now actually playing opening cutscene!!!!

* add GXDestroyTexObj to a couple stack init'd GXTexObjs, remove some diag printfs

* endian swap joint weight envelope data

* move to dusk config

* verbose arg errors

* better stub logging (for now)

* less logging, more BE

* more stubbing, move logging stuff around

* move all logging to aurora logging

* fix STUB_LOG, __FUNCTION__ isn't a string literal, wasn't building as it
was.

* update aurora

* fix heap alignment mismatch and always head align for now

* prevent them from fucking up my shit

* forward jut warning to DuskLog

* remove report logging

* maybe and i must emphasize maybe fix JMessage parsing

* this was a dumb idea

* preserve negative alignment for JKRHeap

* use normal free on macos and linux

* ^

* fix JMAHermiteInterpolation c impl

* endian swap J2DScreen mColor (oops)

* swap more J3D anim data, remove weird pointer addr check in J3DMaterial getMaterialAnm

* typo fix

* Fix aligned_alloc() size issues on POSIX

aligned_alloc() requires its input size to be a multiple of alignment. This wasn't being upheld so there were allocation failures in init code that made the game fail to start outside Windows.

Also just cleaned up some of this code a bit and removed fallback cases that *shouldn't* get hit.

* _Exit instead of exit()

Seriously I don't want destructors to run. Let the OS reclaim that shit.

* Reapply "Isolate JKRHeap operator overloads" (#39)

This reverts commit 3623b27f37.

* Fix some oopsies

* Fix hardcoded pointer size in JUTCacheFont::allocArray

* More operator overload fixes

Add void template specialization for jkrDelete

Add new[] placement overload. Apparently.

* Fix delete macros on nullptr

TIL C++ allows that.

* fix delete[]

* fix new(std::nothrow) overload

* fix avoid ub

* swap remaining anim data needed for title logo

* get rid of op 7

* move aurora_end_frame to correct spot

* juttexture destroy tex

* j2d animation be

* shutdown crash

* link warp material fix

* mDoExt_3DlineMat1_c fix

* hacky keyboard controls

* endian swap J2DResReference, add kb_pad to files.cmake

* fix some missing endian swaps in J2D, remove addr alignment check

* Remove heap unsetting in aurora calls

Never worked properly and not the right solution even if it did

* Don't print in DC stubs

They're fine to never implement

* Fix alignment stuff again

* Compile GF from dolphin lib

Doesn't seem to break anything and shuts up some stub warnings

* j3dtexture tlut obj fix

* addTexMtxIndexInDL fix

* don't recreate null tex data every frame

* the actual fix i wanted to push

* its kinda fakematch city over here

* insert hte efb copy

* limited window size / viewport support

* IsDelete FIX

---------

Co-authored-by: madeline <qwertytrogi@gmail.com>
Co-authored-by: Jasper St. Pierre <jstpierre@mecheye.net>
Co-authored-by: Jeffrey Crowell <jeff@crowell.biz>
Co-authored-by: TakaRikka <takarikka@outlook.com>
Co-authored-by: CraftyBoss <talibabdulmaalik@gmail.com>
Co-authored-by: Lurs <2795933+Lurs@users.noreply.github.com>
This commit is contained in:
Pieter-Jan Briers
2026-03-08 23:27:15 +01:00
committed by GitHub
parent 820e2e3df6
commit b289dece80
726 changed files with 5289 additions and 4237 deletions
+4 -2
View File
@@ -5,6 +5,8 @@
#include <cstring>
#include <algorithm>
#include "JSystem/JKernel/JKRHeap.h"
JStudio::ctb::TObject::~TObject() {}
JStudio::ctb::TObject_TxyzRy::TObject_TxyzRy(JStudio::ctb::data::TParse_TBlock const& param_0)
@@ -68,14 +70,14 @@ JStudio::ctb::TFactory::~TFactory() {}
JStudio::ctb::TObject* JStudio::ctb::TFactory::create(JStudio::ctb::data::TParse_TBlock const& param_0) {
switch(param_0.get_scheme()) {
case 1:
return new TObject_TxyzRy(param_0);
return JKR_NEW TObject_TxyzRy(param_0);
default:
return NULL;
}
}
void JStudio::ctb::TFactory::destroy(JStudio::ctb::TObject* param_0) {
delete param_0;
JKR_DELETE(param_0);
}
// NONMATCHING TParse_header_block vtable location
+54 -27
View File
@@ -4,6 +4,18 @@
#include "JSystem/JUtility/JUTException.h"
#include <cstring>
#if TARGET_PC
namespace {
void endianSwapListData(const f32* data, u32 count) {
// const hack to swap endianness
f32* nonConstData = const_cast<f32*>(data);
for (int i = 0; i < count; i++) {
be_swap(nonConstData[i]);
}
}
}
#endif
namespace JStudio {
namespace fvb {
@@ -26,6 +38,7 @@ void TObject::prepare(data::TParse_TBlock const& rBlock, TControl* pControl) {
const void* pContent = dat.pContent;
switch (u32Type) {
case 0:
pData = dat.next;
goto end;
case 1:
prepare_data_(dat, pControl);
@@ -41,10 +54,10 @@ void TObject::prepare(data::TParse_TBlock const& rBlock, TControl* pControl) {
}
JGadget::TVector_pointer<TFunctionValue*>& rCnt = pfvaRefer->refer_referContainer();
u8* content = (u8*)pContent;
u32 i = *(u32*)content;
u32 i = *(BE(u32)*)content;
u8* ptr = content + 4;
for (; i != 0; i--) {
u32 size = *(u32*)ptr;
u32 size = *(BE(u32)*)ptr;
TObject* pObject = pControl->getObject(ptr + 4, size);
if (pObject != NULL) {
TFunctionValue* const rfv = pObject->referFunctionValue();
@@ -68,9 +81,9 @@ void TObject::prepare(data::TParse_TBlock const& rBlock, TControl* pControl) {
JGadget::TVector_pointer<TFunctionValue*>& rCnt = pfvaRefer->refer_referContainer();
u8* ptr = (u8*)pContent;
u32 i = *(u32*)ptr;
u32 i = *(BE(u32)*)ptr;
for (; ptr += 4, i != 0; i--) {
u32 index = *(u32*)ptr;
u32 index = *(BE(u32)*)ptr;
TObject* pObject = pControl->getObject_index(index);
if (pObject != NULL) {
TFunctionValue* const rfv = pObject->referFunctionValue();
@@ -90,7 +103,7 @@ void TObject::prepare(data::TParse_TBlock const& rBlock, TControl* pControl) {
JGADGET_WARNMSG(127, "invalid paragraph");
break;
}
f32* arr = (f32*)pContent;
BE(f32)* arr = (BE(f32)*)pContent;
pfvaRange->range_set(arr[0], arr[1]);
} break;
case 0x13: {
@@ -103,7 +116,7 @@ void TObject::prepare(data::TParse_TBlock const& rBlock, TControl* pControl) {
break;
}
TFunctionValue::TEProgress prog = *(TFunctionValue::TEProgress*)pContent;
TFunctionValue::TEProgress prog = (TFunctionValue::TEProgress)BSWAP32(*(TFunctionValue::TEProgress*)pContent);
pfvaRange->range_setProgress(prog);
} break;
case 0x14: {
@@ -116,7 +129,7 @@ void TObject::prepare(data::TParse_TBlock const& rBlock, TControl* pControl) {
break;
}
TFunctionValue::TEAdjust adjust = *(TFunctionValue::TEAdjust*)pContent;
TFunctionValue::TEAdjust adjust = (TFunctionValue::TEAdjust)BSWAP32(*(TFunctionValue::TEAdjust*)pContent);
pfvaRange->range_setAdjust(adjust);
} break;
case 0x15: {
@@ -129,9 +142,9 @@ void TObject::prepare(data::TParse_TBlock const& rBlock, TControl* pControl) {
break;
}
u16* out = (u16*)pContent;
pfvaRange->range_setOutside((TFunctionValue::TEOutside)out[0],
(TFunctionValue::TEOutside)out[1]);
BE(u16)* out = (BE(u16)*)pContent;
pfvaRange->range_setOutside((TFunctionValue::TEOutside)(u16)out[0],
(TFunctionValue::TEOutside)(u16)out[1]);
} break;
case 0x16: {
JGADGET_ASSERTWARN(193, u32Size==4);
@@ -143,7 +156,7 @@ void TObject::prepare(data::TParse_TBlock const& rBlock, TControl* pControl) {
break;
}
TFunctionValue::TEInterpolate interp = *(TFunctionValue::TEInterpolate*)pContent;
TFunctionValue::TEInterpolate interp = (TFunctionValue::TEInterpolate)BSWAP32(*(TFunctionValue::TEInterpolate*)pContent);
pfvaInterpolate->interpolate_set(interp);
} break;
default:
@@ -164,27 +177,27 @@ TFunctionValue_composite::TData getCompositeData_raw_(const void* arg1) {
}
TFunctionValue_composite::TData getCompositeData_index_(const void* arg1) {
return TFunctionValue_composite::TData(*(u32*)arg1);
return TFunctionValue_composite::TData(*(BE(u32)*)arg1);
}
TFunctionValue_composite::TData getCompositeData_parameter_(const void* arg1) {
return TFunctionValue_composite::TData(*(f32*)arg1);
return TFunctionValue_composite::TData(*(BE(f32)*)arg1);
}
TFunctionValue_composite::TData getCompositeData_add_(const void* arg1) {
return TFunctionValue_composite::TData(*(f32*)arg1);
return TFunctionValue_composite::TData(*(BE(f32)*)arg1);
}
TFunctionValue_composite::TData getCompositeData_subtract_(const void* arg1) {
return TFunctionValue_composite::TData(*(f32*)arg1);
return TFunctionValue_composite::TData(*(BE(f32)*)arg1);
}
TFunctionValue_composite::TData getCompositeData_multiply_(const void* arg1) {
return TFunctionValue_composite::TData(*(f32*)arg1);
return TFunctionValue_composite::TData(*(BE(f32)*)arg1);
}
TFunctionValue_composite::TData getCompositeData_divide_(const void* arg1) {
return TFunctionValue_composite::TData(*(f32*)arg1);
return TFunctionValue_composite::TData(*(BE(f32)*)arg1);
}
const data::CompositeOperation saCompositeOperation_[8] = {
@@ -219,7 +232,7 @@ void TObject_composite::prepare_data_(const data::TParse_TParagraph::TData& rDat
JGADGET_ASSERTWARN(310, u32Size== 8);
JUT_ASSERT(311, pContent!=NULL);
data::TEComposite type = pContent->composite_type;
data::TEComposite type = (data::TEComposite)BSWAP32(pContent->composite_type);
const data::CompositeOperation* op = getCompositeOperation_(type);
data::CompositeDataFunc pfn = op->getCompositeData;
JUT_ASSERT(316, pfn!=NULL);
@@ -234,7 +247,7 @@ void TObject_constant::prepare_data_(const data::TParse_TParagraph::TData& rData
JUT_ASSERT(337, rData.u32Type==data::PARAGRAPH_DATA);
u32 u32Size = rData.u32Size;
const f32* pContent = static_cast<const f32*>(rData.pContent);
const BE(f32)* pContent = static_cast<const BE(f32)*>(rData.pContent);
JGADGET_ASSERTWARN(341, u32Size==4);
JUT_ASSERT(342, pContent!=NULL);
f32 val = pContent[0];
@@ -251,7 +264,7 @@ void TObject_transition::prepare_data_(const data::TParse_TParagraph::TData& rDa
u32 u32Size = rData.u32Size;
JGADGET_ASSERTWARN(0, u32Size == 8);
const f32* pContent = static_cast<const f32*>(rData.pContent);
const BE(f32)* pContent = static_cast<const BE(f32)*>(rData.pContent);
ASSERT(pContent != NULL);
fnValue.data_set(pContent[0], pContent[1]);
@@ -268,6 +281,10 @@ void TObject_list::prepare_data_(const data::TParse_TParagraph::TData& rData, TC
const ListData* pContent = static_cast<const ListData*>(rData.pContent);
ASSERT(pContent != NULL);
#if TARGET_PC
endianSwapListData(pContent->_8, pContent->_4);
#endif
fnValue.data_setInterval(pContent->_0);
fnValue.data_set(pContent->_8, pContent->_4);
}
@@ -285,6 +302,9 @@ void TObject_list_parameter::prepare_data_(const data::TParse_TParagraph::TData&
const ListData* pContent = static_cast<const ListData*>(rData.pContent);
ASSERT(pContent != NULL);
#if TARGET_PC
endianSwapListData(pContent->_4, pContent->_0 * 2);
#endif
fnValue.data_set(pContent->_4, pContent->_0);
}
@@ -300,7 +320,14 @@ void TObject_hermite::prepare_data_(const data::TParse_TParagraph::TData& rData,
const ListData* pContent = static_cast<const ListData*>(rData.pContent);
ASSERT(pContent != NULL);
#if TARGET_PC
u32 u = BE<u32>::swap(pContent->_0 & 0xFFFFFFF);
u32 uSize = BE<u32>::swap(pContent->_0 >> 0x1C);
endianSwapListData(pContent->_4, u * uSize);
fnValue.data_set(pContent->_4, u, uSize);
#else
fnValue.data_set(pContent->_4, pContent->_0 & 0xFFFFFFF, pContent->_0 >> 0x1C);
#endif
}
TControl::TControl() : pFactory(NULL) {}
@@ -351,17 +378,17 @@ TFactory::~TFactory() {}
TObject* TFactory::create(data::TParse_TBlock const& rBlock) {
switch (rBlock.get_type()) {
case 1:
return new TObject_composite(rBlock);
return JKR_NEW TObject_composite(rBlock);
case 2:
return new TObject_constant(rBlock);
return JKR_NEW TObject_constant(rBlock);
case 3:
return new TObject_transition(rBlock);
return JKR_NEW TObject_transition(rBlock);
case 4:
return new TObject_list(rBlock);
return JKR_NEW TObject_list(rBlock);
case 5:
return new TObject_list_parameter(rBlock);
return JKR_NEW TObject_list_parameter(rBlock);
case 6:
return new TObject_hermite(rBlock);
return JKR_NEW TObject_hermite(rBlock);
default:
JUTWarn w;
w << "unknown type : ";
@@ -370,7 +397,7 @@ TObject* TFactory::create(data::TParse_TBlock const& rBlock) {
}
void TFactory::destroy(TObject* pObject) {
delete pObject;
JKR_DELETE(pObject);
}
TParse::TParse(TControl* pControl) : pControl_(pControl) {
@@ -246,14 +246,14 @@ void JStudio::TAdaptor::adaptor_setVariableValue_IMMEDIATE_(JStudio::TAdaptor* p
JStudio::TControl* param_2, u32 param_3,
void const* param_4, u32 param_5) {
TVariableValue* value = &param_1->pValue_[param_3];
value->setValue_immediate(*(f32*)param_4);
value->setValue_immediate(*(BE(f32)*)param_4);
}
void JStudio::TAdaptor::adaptor_setVariableValue_TIME_(JStudio::TAdaptor* param_1,
JStudio::TControl* param_2, u32 param_3,
void const* param_4, u32 param_5) {
TVariableValue* value = &param_1->pValue_[param_3];
value->setValue_time(*(f32*)param_4);
value->setValue_time(*(BE(f32)*)param_4);
}
void JStudio::TAdaptor::adaptor_setVariableValue_FVR_NAME_(JStudio::TAdaptor* param_1,
@@ -267,11 +267,11 @@ void JStudio::TAdaptor::adaptor_setVariableValue_FVR_INDEX_(JStudio::TAdaptor* p
JStudio::TControl* param_2, u32 param_3,
void const* param_4, u32 param_5) {
TVariableValue* value = &param_1->pValue_[param_3];
value->setValue_functionValue(param_2->getFunctionValue_index(*(u32*)param_4));
value->setValue_functionValue(param_2->getFunctionValue_index(*(BE(u32)*)param_4));
}
JStudio::TObject::~TObject() {
delete mpAdaptor;
JKR_DELETE(mpAdaptor);
}
void JStudio::TObject::forward_value(u32 param_0) {
@@ -1,6 +1,6 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "dusk/endian.h"
#include "JSystem/JStudio/JStudio/stb-data.h"
const s32 JStudio::stb::data::gauDataSize_TEParagraph_data[8] = {0x0, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40};
const u32 JStudio::stb::data::ga4cSignature = 'STB\0';
const BE(u32) JStudio::stb::data::ga4cSignature = 'STB\0';
+1 -1
View File
@@ -373,7 +373,7 @@ JStudio::TObject* TFactory::create(data::TParse_TBlock_object const& param_0) {
}
void TFactory::destroy(TObject* p) {
delete p;
JKR_DELETE(p);
}
TParse::TParse(TControl* pControl) : pControl(pControl) {}
@@ -27,7 +27,7 @@ bool JStudio_JAudio2::TCreateObject::create(
JStudio::TObject* JStudio_JAudio2::TCreateObject::createObject_JAI_SOUND_(
JStudio::stb::data::TParse_TBlock_object const& param_1,
JStudio_JAudio2::TCreateObject* param_2) {
JStudio_JAudio2::TAdaptor_sound* adaptor = new JStudio_JAudio2::TAdaptor_sound(param_2);
JStudio_JAudio2::TAdaptor_sound* adaptor = JKR_NEW JStudio_JAudio2::TAdaptor_sound(param_2);
if (adaptor == NULL) {
return NULL;
}
@@ -5,8 +5,10 @@
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JStudio/JStudio_JAudio2/object-sound.h"
#include "JSystem/JStudio/JStudio_JAudio2/control.h"
#include "JSystem/JStudio/JStudio_JStage/control.h"
#include "dusk/audio.h"
namespace JStudio_JAudio2 {
namespace {
@@ -146,6 +148,7 @@ void JStudio_JAudio2::TAdaptor_sound::adaptor_do_update(u32 param_1) {
void JStudio_JAudio2::TAdaptor_sound::adaptor_do_SOUND(JStudio::data::TEOperationData param_1,
void const* pContent, u32 uSize) {
DUSK_AUDIO_SKIP()
switch(param_1) {
case JStudio::data::UNK_0x19:
JUT_ASSERT(283, pContent!=NULL);
@@ -41,7 +41,7 @@ void JStudio_JParticle::TCreateObject::emitter_destroy(JPABaseEmitter* pEmitter)
JStudio::TObject* JStudio_JParticle::TCreateObject::createObject_JPA_PARTICLE_(
JStudio::stb::data::TParse_TBlock_object const& param_1,
JStudio_JParticle::TCreateObject* param_2) {
JStudio_JParticle::TAdaptor_particle* adaptor = new JStudio_JParticle::TAdaptor_particle(param_2);
JStudio_JParticle::TAdaptor_particle* adaptor = JKR_NEW JStudio_JParticle::TAdaptor_particle(param_2);
if (adaptor == NULL) {
return NULL;
}
@@ -206,7 +206,7 @@ void JStudio_JStage::TAdaptor_actor::adaptor_do_RELATION_NODE(
case JStudio::data::UNK_0x19:
JUT_ASSERT(358, uSize==4);
JUT_ASSERT(359, pContent!=NULL);
field_0x14c = *(u32*)pContent;
field_0x14c = *(BE(u32)*)pContent;
break;
}
}
@@ -217,7 +217,7 @@ void JStudio_JStage::TAdaptor_actor::adaptor_do_RELATION_ENABLE(
case JStudio::data::UNK_0x2:
JUT_ASSERT(378, uSize==4);
JUT_ASSERT(379, pContent!=NULL);
pJSGObject_->JSGSetRelation(*(u32*)pContent, field_0x148, field_0x14c);
pJSGObject_->JSGSetRelation(*(BE(u32)*)pContent, field_0x148, field_0x14c);
break;
}
}
@@ -227,7 +227,7 @@ void JStudio_JStage::TAdaptor_actor::setJSG_ID_(void (JStage::TActor::*function)
void const* pContent, u32 uSize) {
switch (operation) {
case JStudio::data::UNK_0x19:
(((JStage::TActor*)pJSGObject_)->*function)(*(u32*)pContent);
(((JStage::TActor*)pJSGObject_)->*function)(*(BE(u32)*)pContent);
break;
}
}