Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Saturnyoshi committed Jul 24, 2024
2 parents 04b8cc0 + 184dfbf commit f7457d2
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "LunadllNewLauncher/SMBXLauncher/PGE_File_Formats"]
path = LunadllNewLauncher/SMBXLauncher/PGE_File_Formats
url = https://github.com/Wohlhabend-Networks/PGE-File-Library-STL.git
url = https://github.com/WohlSoft/PGE-File-Library-STL
[submodule "LunaDll/libs/PGE_File_Formats"]
path = LunaDll/libs/PGE_File_Formats
url = https://github.com/WohlSoft/PGE-File-Library-STL
Expand Down
19 changes: 19 additions & 0 deletions LunaDll/Input/LunaGameController.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <SDL2/SDL.h>
#include <memory>
#include <tuple>
#include "LunaGameController.h"
#if !defined(BUILDING_SMBXLAUNCHER)
# ifdef _WIN32
Expand Down Expand Up @@ -486,6 +487,16 @@ std::string LunaGameControllerManager::getSelectedControllerName(int playerNum)
return "Keyboard";
}

std::tuple<int, int> LunaGameControllerManager::getSelectedControllerStickPosition(int playerNum)
{
LunaGameController* controller = getController(playerNum);
if (controller != nullptr)
{
return controller->getStickPosition();
}
return {0, 0};
}

void LunaGameControllerManager::rumbleSelectedController(int playerNum, int ms, float strength)
{
LunaGameController* controller = getController(playerNum);
Expand Down Expand Up @@ -660,6 +671,8 @@ LunaGameController::LunaGameController(LunaGameControllerManager* _managerPtr, S
axisPadState(0),
padState(0),
buttonState(0),
xAxis(0),
yAxis(0),
activeFlag(false),
joyButtonMap()
{
Expand Down Expand Up @@ -773,6 +786,8 @@ LunaGameController::LunaGameController(LunaGameController &&other)
axisPadState = other.axisPadState;
padState = other.padState;
buttonState = other.buttonState;
xAxis = other.xAxis;
yAxis = other.yAxis;
activeFlag = other.activeFlag;
joyButtonMap = other.joyButtonMap;
other.joyPtr = nullptr;
Expand All @@ -795,6 +810,8 @@ LunaGameController & LunaGameController::operator=(LunaGameController &&other)
axisPadState = other.axisPadState;
padState = other.padState;
buttonState = other.buttonState;
xAxis = other.xAxis;
yAxis = other.yAxis;
activeFlag = other.activeFlag;
joyButtonMap = other.joyButtonMap;
other.joyPtr = nullptr;
Expand Down Expand Up @@ -986,11 +1003,13 @@ void LunaGameController::controllerAxisEvent(const SDL_ControllerAxisEvent& even
axisAsDirectional = true;
posPadNumber = CONTROLLER_PAD_RIGHT;
negPadNumber = CONTROLLER_PAD_LEFT;
xAxis = (int)event.value;
break;
case SDL_CONTROLLER_AXIS_LEFTY:
axisAsDirectional = true;
posPadNumber = CONTROLLER_PAD_DOWN;
negPadNumber = CONTROLLER_PAD_UP;
yAxis = (int)event.value;
break;
default:
break;
Expand Down
5 changes: 5 additions & 0 deletions LunaDll/Input/LunaGameController.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <SDL2/SDL.h>
#include <vector>
#include <tuple>
#include <unordered_map>

struct joyinfoex_tag;
Expand Down Expand Up @@ -55,6 +56,7 @@ class LunaGameController
inline void clearActive() { activeFlag = false; }
inline unsigned int getPadState() const { return padState; }
inline unsigned int getButtonState() const { return buttonState; }
inline std::tuple<int, int> getStickPosition() const { return {xAxis, yAxis}; }

SDL_JoystickPowerLevel getPowerLevel();

Expand Down Expand Up @@ -115,6 +117,8 @@ class LunaGameController
unsigned int axisPadState;
unsigned int padState;
unsigned int buttonState;
int xAxis;
int yAxis;
bool activeFlag;
std::vector<int> joyButtonMap;
};
Expand Down Expand Up @@ -156,6 +160,7 @@ class LunaGameControllerManager
public:
SDL_JoystickPowerLevel getSelectedControllerPowerLevel(int playerNum);
std::string getSelectedControllerName(int playerNum);
std::tuple<int, int> getSelectedControllerStickPosition(int playerNum);
void rumbleSelectedController(int playerNum, int ms, float strength);
LunaGameController* getController(int playerNum);
private:
Expand Down
24 changes: 24 additions & 0 deletions LunaDll/LuaMain/LuaProxyFFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,18 @@ extern "C" {
return (int)SDL_JOYSTICK_POWER_UNKNOWN;
}

struct StickPos
{
int x;
int y;
};
FFI_EXPORT(StickPos) LunaLuaGetSelectedControllerStickPosition(int playerNum)
{
const auto stickPos = gLunaGameControllerManager.getSelectedControllerStickPosition(playerNum);

return {std::get<0>(stickPos), std::get<1>(stickPos)};
}

FFI_EXPORT(const char*) LunaLuaGetSelectedControllerName(int playerNum)
{
static std::string name;
Expand Down Expand Up @@ -534,6 +546,18 @@ typedef struct ExtendedPlayerFields_\
}
}

FFI_EXPORT(void) LunaLuaSetNPCCeilingBugFix(bool enable)
{
if (enable)
{
gNPCCeilingBugFix.Apply();
}
else
{
gNPCCeilingBugFix.Unapply();
}
}

FFI_EXPORT(void) LunaLuaSetNPCSectionFix(bool enable)
{
if (enable)
Expand Down
1 change: 1 addition & 0 deletions LunaDll/LuaMain/LunaLuaMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ bool CLunaLua::shutdown()
gDisablePlayerDownwardClipFix.Apply();
gDisableNPCDownwardClipFix.Apply();
gDisableNPCDownwardClipFixSlope.Apply();
gNPCCeilingBugFix.Apply();
gNPCSectionFix.Apply();
gFenceFixes.Apply();
gLinkFairyClowncarFixes.Apply();
Expand Down
1 change: 1 addition & 0 deletions LunaDll/Misc/RuntimeHook.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void TrySkipPatch();
extern AsmPatch<777> gDisablePlayerDownwardClipFix;
extern AsmPatch<8> gDisableNPCDownwardClipFix;
extern AsmPatch<6> gDisableNPCDownwardClipFixSlope;
extern AsmPatch<21> gNPCCeilingBugFix;
extern Patchable& gNPCSectionFix;
extern Patchable& gFenceFixes;
extern Patchable& gLinkFairyClowncarFixes;
Expand Down
5 changes: 5 additions & 0 deletions LunaDll/Misc/RuntimeHookComponents/RuntimeHookGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,8 @@ static unsigned int __stdcall LatePatch(void)
AsmPatch<777> gDisablePlayerDownwardClipFix = PATCH(0x9A3FD3).JMP(runtimeHookCompareWalkBlockForPlayerWrapper).NOP_PAD_TO_SIZE<777>();
AsmPatch<8> gDisableNPCDownwardClipFix = PATCH(0xA16B82).JMP(runtimeHookCompareNPCWalkBlock).NOP_PAD_TO_SIZE<8>();

AsmPatch<21> gNPCCeilingBugFix = PATCH(0xA17155).NOP_PAD_TO_SIZE<21>();

// NOTE: This patch replaces a section 167 bytes long from 0xA13188 to 0xA1322E, but we don't NOP out the whole thing
// since that would conflict with NpcIdExtender, and this patch may be turned on/off at runtime.
AsmPatch<6> gDisableNPCDownwardClipFixSlope = PATCH(0xA13188).JMP(runtimeHookNPCWalkFixSlope).NOP_PAD_TO_SIZE<6>();
Expand Down Expand Up @@ -2083,6 +2085,9 @@ void TrySkipPatch()
// Hook to fix an NPC's section property when it spawn out of bounds
gNPCSectionFix.Apply();

// Hook to fix erroneous Y speed after an NPC hits a ceiling
gNPCCeilingBugFix.Apply();

// Patch to handle block reorder after p-switch handling
PATCH(0x9E441A).JMP(runtimeHookAfterPSwitchBlocksReorderedWrapper).NOP_PAD_TO_SIZE<242>().Apply();
PATCH(0x9E3D30).JMP(runtimeHookPSwitchStartRemoveBlockWrapper).NOP_PAD_TO_SIZE<110>().Apply();
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ LunaLua
=======
[![Build status](https://ci.appveyor.com/api/projects/status/72ttgr33ggar3x21?svg=true)](https://ci.appveyor.com/project/Wohlstand/lunadll)

LunaLua - LunaDLL with Lua is a free extension for SMBX game engine
This version is based on LunaDLL ver. 8 with Lua Support.
LunaLua (a.k.a. LunaDLL with Lua) - is a free extension for SMBX game engine.
This version is based on LunaDLL ver. 8 with Lua Support. After the release of 0.7.3.1, LunaLua is being developed as a core part of the [SMBX2 project](https://codehaus.moe).

Quick Overview
-------
Expand All @@ -14,12 +14,17 @@ Quick Overview
* npc-*.txt with decimal numbers will no more crash SMBX with "runtime error 13"
* fixes a random crash caused by contacting of the mushrooms with a lava blocks
* OpenGL render support
* SMBX's audio engine has been replaced with the better and more flexible SDL2_mixer library which also gives to SMBX the internal support of a [lots of additional music formats](http://wohlsoft.ru/pgewiki/SDL2_mixer#Music_Formats)
* Added PGE's [sounds.ini](http://wohlsoft.ru/pgewiki/Game_Configuration_Pack_References#sounds.ini) and [music.ini](http://wohlsoft.ru/pgewiki/Game_Configuration_Pack_References#music.ini) support which gives ability to have custom musics (include world map musics!) and custom sound effects per episode.
* SMBX's audio engine has been replaced with the better and more flexible `SDL2_mixer` (Later its fork called `SDL2 Mixer X` or just `MixerX`) library which also gives to SMBX the internal support of a [lots of additional music formats](https://wohlsoft.ru/pgewiki/SDL_Mixer_X#Music_Formats)
* Added Moondust's [sounds.ini](https://wohlsoft.ru/pgewiki/Sounds.ini_(Episode)) and [music.ini](https://wohlsoft.ru/pgewiki/Music.ini_(Episode)) support which gives ability to have custom musics (include world map musics!) and custom sound effects per episode.
* And more other stuff...

**Download links**
* [Download LunaLua](http://wohlsoft.ru/LunaLua/)
* [LunaLua Documenation](http://wohlsoft.ru/pgewiki/Category:LunaLua_API)
* [Download SMBX2 game](https://codehaus.moe/) - The mainstream game based on the LunaLua.
* [SMBX2 Documentation](https://docs.codehaus.moe/) - The most current documentation for the LunaLua API.

**Old downloads**
* [Download old releases of LunaLua](https://wohlsoft.ru/projects/LunaLua/) - Legacy standalone LunaLua releases.
* [Legacy LunaLua Documenation](https://wohlsoft.ru/pgewiki/Category:LunaLua_API) - The documentation mostly for old versions of LunaLua.

Requirements to build LunaLua yourself
------
Expand Down Expand Up @@ -51,7 +56,7 @@ If you wish you edit code via Qt Creator, you still must have Visual Studio beca
* Open project and configure it
* Go to the "Projects" tab
* Disable shadow build for both Debug and Release
* remove ALL items from "Building" and "Cenaring" sections
* remove ALL items from "Building" and "Cleaning" sections
* Add into "Building" a special item with:
** Command "build.bat"
** Argument "Debug" for debug build and "Release" argument for release build
Expand Down

0 comments on commit f7457d2

Please sign in to comment.