Skip to content

Commit

Permalink
0.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
AndroidModLoader committed May 3, 2022
1 parent 300caf8 commit 315b647
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 107 deletions.
3 changes: 2 additions & 1 deletion Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ LOCAL_CPP_EXTENSION := .cpp .cc
LOCAL_MODULE := SkyGfxMobile
LOCAL_SRC_FILES := main.cpp colorfilter.cpp shader.cpp shading.cpp pipeline.cpp effects.cpp plantsurfprop.cpp shadows.cpp rtshadowman.cpp mod/logger.cpp mod/config.cpp
LOCAL_CXXFLAGS = -O3 -mfloat-abi=softfp -mfpu=neon -DNDEBUG
#LOCAL_CXXFLAGS += -DNEW_LIGHTING # Nah, too dark...
LOCAL_CXXFLAGS += -DNEW_LIGHTING # Nah, too dark...
#LOCAL_CXXFLAGS += -DSTOCHASTIC_TEX # Does not work for some reason. And causes a lag, heavy thing.
LOCAL_C_INCLUDES += ./include
LOCAL_LDLIBS += -llog
include $(BUILD_SHARED_LIBRARY)
2 changes: 1 addition & 1 deletion gtasa_things.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ extern void* hGTASA;
extern int nColorFilter;
extern uintptr_t pGTASA;

void Redirect(uintptr_t addr, uintptr_t to);
#define Redirect aml->Redirect
35 changes: 8 additions & 27 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ConfigEntry* pVehicleShadowDistance;
ConfigEntry* pMaxRTShadows;
ConfigEntry* pDynamicObjectsShadows;
ConfigEntry* pAllowPlayerClassicShadow;
ConfigEntry* pNewShaderLighting;

/* Patch Saves */
//const uint32_t sunCoronaRet = 0xF0F7ECE0;
Expand All @@ -60,29 +61,6 @@ const uint32_t sunCoronaDel = 0xBF00BF00;
void* hGTASA = NULL;
uintptr_t pGTASA = 0;

////////////////////////////////////////////////////////////////////////
// Was taken from TheOfficialFloW's git repo (will be in AML 1.0.0.6) //
////////////////////////////////////////////////////////////////////////
void Redirect(uintptr_t addr, uintptr_t to)
{
if(!addr) return;
uint32_t hook[2] = {0xE51FF004, to};
if(addr & 1)
{
addr &= ~1;
if (addr & 2)
{
aml->PlaceNOP(addr, 1);
addr += 2;
}
hook[0] = 0xF000F8DF;
}
aml->Write(addr, (uintptr_t)hook, sizeof(hook));
}
////////////////////////////////////////////////////////////////////////
// Was taken from TheOfficialFloW's git repo (will be in AML 1.0.0.6) //
////////////////////////////////////////////////////////////////////////

extern DECL_HOOKv(PlantMgrInit);
extern DECL_HOOKv(PlantMgrRender);
extern DECL_HOOKv(PlantSurfPropMgrInit);
Expand Down Expand Up @@ -156,6 +134,11 @@ extern "C" void OnModLoad()
cfg->Bind("IdeasFrom", "", "About")->SetString("aap, TheOfficialFloW");
cfg->Bind("Discord", "", "About")->SetString("https://discord.gg/2MY7W39kBg");
cfg->Bind("GitHub", "", "About")->SetString("https://github.com/AndroidModLoader/GTASA_SkyGfxMobile");

// Config: Information
cfg->Bind("About_PS2_Reflections", "Works only on low reflections setting with PS2 Shading enabled", "About");
cfg->Bind("Colorfilter_Values", "default none ps2 pc", "About");

cfg->Save();

// Config: Render
Expand Down Expand Up @@ -209,10 +192,6 @@ extern "C" void OnModLoad()
//pDynamicObjectsShadows = cfg->Bind("DynamicObjectsShadows", false, "Shadows");
//pAllowPlayerClassicShadow = cfg->Bind("AllowPlayerClassicShadow", false, "Shadows");

// Config: Information
cfg->Bind("About_PS2_Reflections", "Works only on low reflections setting with PS2 Shading enabled", "About");
cfg->Bind("Colorfilter_Values", "default none ps2 pc", "About");

HOOKPLT(InitRW, pGTASA + 0x66F2D0);

// Patches
Expand Down Expand Up @@ -243,6 +222,7 @@ extern "C" void OnModLoad()
SET_TO(emu_glEnable, aml->GetSym(hGTASA, "_Z12emu_glEnablej"));
SET_TO(emu_glDisable, aml->GetSym(hGTASA, "_Z13emu_glDisablej"));
#ifdef NEW_LIGHTING
pNewShaderLighting = cfg->Bind("PS2_Shading_NewLight", true, "Render");
Redirect(aml->GetSym(hGTASA, "_Z36_rwOpenGLLightsSetMaterialPropertiesPK10RpMaterialj"), (uintptr_t)_rwOpenGLLightsSetMaterialProperties);
#endif // NEW_LIGHTING
Redirect(aml->GetSym(hGTASA, "_Z28SetLightsWithTimeOfDayColourP7RpWorld"), (uintptr_t)SetLightsWithTimeOfDayColour);
Expand Down Expand Up @@ -468,6 +448,7 @@ extern "C" void OnModLoad()
SET_TO(RpClumpDestroy, aml->GetSym(hGTASA, "_Z14RpClumpDestroyP7RpClump"));
SET_TO(RwFrameCreate, aml->GetSym(hGTASA, "_Z13RwFrameCreatev"));
SET_TO(RpAtomicSetFrame, aml->GetSym(hGTASA, "_Z16RpAtomicSetFrameP8RpAtomicP7RwFrame"));
SET_TO(RenderAtomicWithAlpha, aml->GetSym(hGTASA, "_ZN18CVisibilityPlugins21RenderAtomicWithAlphaEP8RpAtomici"));

SET_TO(PlantMgr_rwOpenGLSetRenderState, aml->GetSym(hGTASA, "_Z23_rwOpenGLSetRenderState13RwRenderStatePv"));
SET_TO(IsSphereVisibleForCamera, aml->GetSym(hGTASA, "_ZN7CCamera15IsSphereVisibleERK7CVectorf"));
Expand Down
5 changes: 4 additions & 1 deletion plantsurfprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ RpAtomic* (*RpAtomicClone)(RpAtomic*);
void (*RpClumpDestroy)(RpClump*);
RwFrame* (*RwFrameCreate)();
void (*RpAtomicSetFrame)(RpAtomic*, RwFrame*);
void (*RenderAtomicWithAlpha)(RpAtomic*, int alphaVal);
RpMaterial* SetGrassMaterial(RpMaterial* material, void* rgba)
{
material->color = *(RwRGBA*)rgba;
Expand Down Expand Up @@ -257,7 +258,7 @@ void InitPlantManager()
logger->Error("Failed to load ENVGRASS.TEXDB!");
}

StreamingMakeSpaceFor(0x8800);
StreamingMakeSpaceFor(0x8800); // Does nothing

PC_PlantTextureTab0[0] = GetTextureFromTextureDB("txgrass0_0");
PC_PlantTextureTab0[1] = GetTextureFromTextureDB("txgrass0_1");
Expand Down Expand Up @@ -325,6 +326,8 @@ DECL_HOOKv(PlantMgrRender)
PlantMgr_rwOpenGLSetRenderState(rwRENDERSTATEALPHATESTFUNCTIONREF, 0);
PlantMgr_rwOpenGLSetRenderState(rwRENDERSTATEALPHATESTFUNCTION, 8u);

RenderAtomicWithAlpha(PC_PlantModelsTab0[0], 128);

for(int type = 0; type < DDDAFSF; ++type)
{
static PPTriPlant plant = {0};
Expand Down
1 change: 1 addition & 0 deletions plantsurfprop.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extern RpAtomic* (*RpAtomicClone)(RpAtomic*);
extern void (*RpClumpDestroy)(RpClump*);
extern RwFrame* (*RwFrameCreate)();
extern void (*RpAtomicSetFrame)(RpAtomic*, RwFrame*);
extern void (*RenderAtomicWithAlpha)(RpAtomic*, int alphaVal);

extern void (*PlantMgr_rwOpenGLSetRenderState)(RwRenderState, int);
extern bool (*IsSphereVisibleForCamera)(CCamera*, const CVector*, float);
Expand Down
Loading

0 comments on commit 315b647

Please sign in to comment.