Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
268 changes: 134 additions & 134 deletions data/mcswitch_functions.csv

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions src/4JLibraries_Source/NX/Render/RendererCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,47 @@ Renderer::Renderer() : C4JRender() {
Renderer::sInstance = this;
}

// NON_MATCHING: define some of the nvn functions and finish properly last but one call
void Renderer::GammaCorrect() {
NVNdepthStencilState _depthStencil;
NVNpolygonState _polygon;
NVNcolorState _color;

nvnCommandBufferBindProgram(&this->m_nvNcommandBuffer, this->m_shaders8, 1);
nvnCommandBufferBindProgram(&this->m_nvNcommandBuffer, this->m_shaders15, 2);

nvnDepthStencilStateSetDefaults(&_depthStencil);
nvnCommandBufferBindDepthStencilState(&this->m_nvNcommandBuffer, &_depthStencil);

nvnPolygonStateSetDefaults(&_polygon);
nvnCommandBufferBindPolygonState(&this->m_nvNcommandBuffer, &_polygon);

nvnColorStateSetDefaults(&_color);
nvnCommandBufferBindColorState(&this->m_nvNcommandBuffer, &_color);

float buf[4] = {0.0f, 0.0f, 1.0f, 1.0f};
this->BindShaderUniformData(NVN_SHADER_STAGE_VERTEX, 9, buf, sizeof(buf));

float buf2[4] = {1.0f / (this->m_gammaIntensity * 1.5f + 0.5f), 0.0f, 0.0f, 0.0f};
this->BindShaderUniformData(NVN_SHADER_STAGE_FRAGMENT, 5, buf2, sizeof(buf2));

// those functions aren't called directly, they instead call some function that isn't defined by
// nnheaders, would have to dig through games with symbols that also call that function to grab
// signature... blahblah
nvnCommandBufferSetViewport(&this->m_nvNcommandBuffer, 0, 0, textureWidths[this->m_dword28E8],
textureHeights[this->m_dword28E8]);
nvnCommandBufferSetScissor(&this->m_nvNcommandBuffer, 0, 0, textureWidths[this->m_dword28E8],
textureHeights[this->m_dword28E8]);
nvnCommandBufferBindTexture(&this->m_nvNcommandBuffer, NVN_SHADER_STAGE_FRAGMENT, 0,
this->m_gap2858[8 * this->m_dword28E8]);
nvnCommandBufferBarrier(&this->m_nvNcommandBuffer, 18);

// this is poorly *decompiled* as I didn't care later as I got sidetracked
/* nvnCommandBufferSetRenderTargets(&this->mNVNcommandBuffer, 1, this->qword26E0 +
*(int*)&this->gap2708[24], nullptr, nullptr, nullptr);*/
nvnCommandBufferDrawArrays(&this->m_nvNcommandBuffer, NVN_DRAW_PRIMITIVE_TRIANGLE_STRIP, 0, 4);
}

// NON_MATCHING: inline the tls offset getter, could be some compiler flag
void Renderer::InitialiseContext(bool idk) {
sContext = new Renderer::Context(this, idk);
Expand Down
5 changes: 4 additions & 1 deletion src/4JLibraries_Source/NX/Render/RendererCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Renderer : public C4JRender {
void LoadShaders();
void SetupShaders();
void Initialise(bool);
void GammaCorrect();
void BindShaderUniformData(NVNshaderStage stage, int index, void* buffer, size_t bufferSize);

virtual void Tick();
virtual void UpdateGamma(unsigned short gamma);
Expand Down Expand Up @@ -274,7 +276,8 @@ class Renderer : public C4JRender {
NVNprogram* m_shaders12;
NVNprogram* m_shaders13;
NVNprogram* m_shaders14;
char m_gap2960[48];
NVNprogram* m_shaders15;
char m_gap2960[40];
int m_textureId1;
unsigned short m_gammaIntensity;
int m_dword2998;
Expand Down
15 changes: 10 additions & 5 deletions src/DecompUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

// this can be depracated if musl is fixed

inline __attribute__((__always_inline__)) float decomp_fmax1(float x, float y) {
__asm__("fmax %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
return x;
}

inline __attribute__((__always_inline__)) float decomp_fmax(float x, float y) {
__asm__("fmaxnm %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
return x;
Expand All @@ -16,3 +11,13 @@ inline __attribute__((__always_inline__)) float decomp_fminf(float x, float y) {
__asm__("fminnm %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
return x;
}

inline __attribute__((__always_inline__)) float decomp_fmax1(float x, float y) {
__asm__("fmax %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
return x;
}

inline __attribute__((__always_inline__)) float decomp_fmin1(float x, float y) {
__asm__("fmin %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
return x;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

class GameSessionData;

class CGameNetworkManager {
public:
static CGameNetworkManager sInstance;
Expand All @@ -13,4 +15,9 @@ class CGameNetworkManager {
void DoWork();
bool IsLocalGame();
int GetPlayerCount();
int GetPrimaryPad();
bool ServerStoppedValid();
void ServerStoppedWait();
void ServerStoppedDestroy();
int GetMaxPlayers(GameSessionData*);
};
6 changes: 5 additions & 1 deletion src/Minecraft.Client/net/minecraft/client/CMinecraftApp.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "net/minecraft/client/model/geom/ModelPart.h"
#include "net/minecraft/world/entity/SkinAdjustments.h"
#include "types.h"

#include "NX/Commerce/cCommerceNintendo.h"
Expand Down Expand Up @@ -54,7 +56,6 @@ class CMinecraftApp {
int GetGameHostOption(eGameHostOption option);
bool GetChangingSessionType();
bool GetGameStarted();
static unsigned int getSkinIdFromPath(const std::wstring& path);
bool isXuidNotch(PlayerUID* id);
static void StaticCtor();
void loadDefaultGameRules(); // is this virtual?
Expand All @@ -72,6 +73,8 @@ class CMinecraftApp {
void SetAction(int, eXuiAction, void*);
void setLevelGenerationOptions(LevelGenerationOptions* options);
void SetGameHostOption(eGameHostOption option, unsigned int value);
std::vector<ModelPart*>* GetAdditionalModelParts(unsigned int);
_SkinAdjustments GetSkinAdjustments(unsigned int);

void UpdateTrialPausedTimer();
void UpdateTime();
Expand All @@ -82,6 +85,7 @@ class CMinecraftApp {
static void SignInChangeCallback(void*, bool, unsigned int);
static void ProfileReadErrorCallback(void*);
static void UpsellReturnedCallback(void*, eUpsellType, eUpsellResponse, int);
static unsigned int getSkinIdFromPath(const std::wstring& path);

bool getSomething(); // dunno

Expand Down
4 changes: 4 additions & 0 deletions src/Minecraft.Client/net/minecraft/client/GameSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

#include "types.h"

// TODO: Go through UIScenes and grab those
enum eGameSetting { eGameSetting_CustomSkinAnimation = 25 };

class GameSettings {
public:
static void ClearGameSettingsChangedFlag(int pad);
static void ApplyGameSettingsChanged(int pad);
static void SetDefaultActionMapping(uchar, int, uchar);
static int OldProfileVersionCallback(void*, unsigned char*, unsigned short, int);
static int GetGameSettings(eGameSetting);
};
26 changes: 26 additions & 0 deletions src/Minecraft.Client/net/minecraft/client/dlc/DLCManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class DLCManager {
public:
enum EDLCParameterType {
DISPLAYNAME,
THEMENAME,
FREE,
CREDIT,
CAPEPATH,
BOX,
ANIM,
GAME_FLAGS,
PACKID,
NETHERPARTICLECOLOUR,
ENCHANTTEXTCOLOUR,
ENCHANTTEXTFOCUSCOLOUR,
DATAPATH,
PACKVERSION,
DISPLAYNAMEID,
THEMENAMEID,
CLOUDHEIGHT,
CREDITID,
DISABLEMIPMAP,
OFFSET,
XMLVERSION
};
};
1 change: 1 addition & 0 deletions src/Minecraft.Client/net/minecraft/client/dlc/DLCPack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class DLCPack {};
1 change: 1 addition & 0 deletions src/Minecraft.Client/net/minecraft/client/model/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ class Model {
int m_texHeight;
ModelPartsSkinned m_modelPartsSkinned;
bool m_byte88;
bool m_byte89;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include "net/minecraft/client/model/ModelDefinition.h"
#include "net/minecraft/client/model/geom/ModelPartSkin.h"
#include "net/minecraft/client/model/models/ElytraModel.h"
#include "net/minecraft/client/renderer/platform/GlStateManager.h"
#include "net/minecraft/util/Mth.h"
#include "net/minecraft/world/eINSTANCEOF.h"
#include "net/minecraft/world/entity/Entity.h"
#include "net/minecraft/world/entity/LivingEntity.h"
#include <cmath>
#include <memory>

ElytraModel::ElytraModel(const ModelDefinition&) : Model() {
this->m_byte89 = false;
this->m_mLeftWing = new ModelPartSkin(this, 22, 0);
this->m_mLeftWing->addBox(-10.0f, 0.0f, 0.0f, 10, 20, 2, 1.0f);

this->m_mRightWing = new ModelPartSkin(this, 22, 0);
this->m_mRightWing->m_mirror = true;
this->m_mRightWing->addBox(0.0f, 0.0f, 0.0f, 10, 20, 2, 1.0f);

this->m_mLeftWing->m_xPos = 5.0f;
this->m_mLeftWing->m_xRot = Mth::RAD * 15.0f;
this->m_mLeftWing->m_yPos = 0.0f;
this->m_mLeftWing->m_yRot = 0.0f;
this->m_mLeftWing->m_zRot = Mth::RAD * -15.0f;

this->m_mRightWing->m_xPos = -this->m_mLeftWing->m_xPos;
this->m_mRightWing->m_xRot = this->m_mLeftWing->m_xRot;
this->m_mRightWing->m_yPos = this->m_mLeftWing->m_yPos;
this->m_mRightWing->m_yRot = -this->m_mLeftWing->m_yRot;
this->m_mRightWing->m_zRot = -this->m_mLeftWing->m_zRot;

this->compileSkinnedDrawlist();
}

void ElytraModel::render(std::shared_ptr<Entity>& entity, float, float, float, float, float, float scale,
bool callList) {
GlStateManager::disableRescaleNormal();
GlStateManager::disableCull();
if (Entity::instanceof(entity, eLivingEntity)
&& std::static_pointer_cast<LivingEntity>(entity)->isBaby()) {
GlStateManager::pushMatrix();
GlStateManager::scalef(0.5F, 0.5F, 0.5F);
GlStateManager::translatef(0.0F, 1.5F, -0.1F);
this->m_mLeftWing->render(scale, callList, false);
this->m_mRightWing->render(scale, callList, false);
GlStateManager::popMatrix();
} else {
this->m_mLeftWing->render(scale, callList, false);
this->m_mRightWing->render(scale, callList, false);
}
this->callSkinnedDrawlist();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "net/minecraft/client/model/Model.h"

class ModelDefinition;

class ElytraModel : public Model {
public:
ElytraModel(const ModelDefinition&);

void render(std::shared_ptr<Entity>&, float, float, float, float, float, float, bool) override;
void setupAnim(float, float, float, float, float, float, std::shared_ptr<Entity>,
_SkinAdjustments) override;

ModelPartSkin* m_mRightWing;
ModelPartSkin* m_mLeftWing;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#pragma once

#include "net/minecraft/client/model/Model.h"
#include "net/minecraft/world/entity/EquipmentSlot.h"
#include "net/minecraft/world/entity/HumanoidArm.h"
#include "net/minecraft/world/entity/SkinAdjustments.h"

class HumanoidModel : public Model {
public:
// TODO: fill in
enum eArmPose {};

HumanoidModel(const ModelDefinition&, float, float, int, int, bool, bool, bool);

void _init(float, float, int, int, bool, bool, const ModelDefinition&, bool);

virtual void render(HumanoidModel*, float, bool); // ?
virtual void setAllVisible(bool);
virtual void translateToHandItem(float, const HumanoidArm*);
virtual void setArmPose(const HumanoidArm*, HumanoidModel::eArmPose);
virtual void setArmPose(std::shared_ptr<Entity>, HumanoidModel::eArmPose, bool);

ModelPart* m_mHeadPart;
ModelPart* m_mHatPart;
ModelPart* m_mBodyPart;
ModelPart* m_mRightArmPart;
ModelPart* m_mLeftArmPart;
ModelPart* m_mRightLegPart;
ModelPart* m_mLeftLegPart;
ModelPart* m_mRightItemPart;
ModelPart* m_mLeftItemPart;
char m_gapD8[8];
bool m_flag1;
bool m_flag2;
bool m_flag3;
int m_dwordE4;
int m_dwordE8;
_SkinAdjustments m_mSkinAdjustments;
float m_float13C;
bool m_mSlim;
EquipmentSlot* m_mEquipSlot; // Equipment slot of what?
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include "net/minecraft/client/model/models/HumanoidModel.h"

// TODO: grab shit for this
enum EPlayerModelType {};

class PlayerModel : public HumanoidModel {
public:
void renderCloak(float);

void render(HumanoidModel*, float, bool) override;
void setAllVisible(bool) override;
void translateToHandItem(float, const HumanoidArm*) override;

char m_fill[0x1E0 - 336];
};
5 changes: 5 additions & 0 deletions src/Minecraft.Client/net/minecraft/client/renderer/Lighting.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Lighting {
public:
static void turnOn();
static void turnOff();
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#pragma once

#include "net/minecraft/client/model/models/PlayerModel.h"

class EntityRenderer;
class Textures;
class ItemRenderer;

class EntityRenderDispatcher {
public:
EntityRenderDispatcher(Textures* textures, ItemRenderer* renderer);

EntityRenderer* getPlayerRenderer(EPlayerModelType);

unsigned char m_padding[0xE0];
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class BlockPos;
class TexturePack;
class ModelDefinition;
class EntityRenderDispatcher;
class Model;

class EntityRenderer {
public:
Expand Down Expand Up @@ -40,14 +41,14 @@ class EntityRenderer {
virtual void renderSecondPass(SharedEntity&, double, double, double, float, float);
virtual void setupForTexturePack(TexturePack*);
virtual void SetItemFrame(bool);
virtual void getModel();
virtual Model* getModel();
virtual void getModelName();
virtual void createModel(const ModelDefinition&);

EntityRenderDispatcher* mDispatcher;
int field_10;
float field_14;
void* field_18;
void* field_20;
void* field_28;
EntityRenderDispatcher* m_mDispatcher;
int m_field10;
float m_field14;
void* m_field18;
void* m_field20;
void* m_field28;
};
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,5 @@ class GlStateManager {
static TexGenCoord* getTexGen(GlStateManager::TexGen coord);
static int genTexture();
static void deleteTexture(int texture);
static void enableCull();
};
Loading
Loading