Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster episode booting #70

Open
wants to merge 71 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
8b4660c
Wip redo
Jan 20, 2024
5684f54
Merge branch 'WohlSoft:master' into faster-episode-booting
Jan 20, 2024
69b24c4
Merge branch 'WohlSoft:master' into faster-episode-booting
Jan 21, 2024
2460364
Finally works, geez
Jan 21, 2024
667bc61
Fix Misc.loadEpisode()
Jan 21, 2024
4a92497
Oops
Jan 21, 2024
de2f75a
Oops again
Jan 21, 2024
2f5eb71
Whoops, again
Jan 21, 2024
52b5e41
Fix this check
Jan 21, 2024
0cc2ca9
Switch isBootingSinglePlayer bools, in case. Also add episodeLoadedOn…
Jan 21, 2024
279a12d
Add a check for the world path, if not found it doesn't load the episode
Jan 21, 2024
63770b0
Oops
Jan 21, 2024
6f3aecd
Oops x2
Jan 21, 2024
b836f2d
Oops x3
Jan 21, 2024
a98c27e
Let's shorten and fix this
Jan 21, 2024
df02b5e
Even MORE checks ugh
Jan 21, 2024
18416ba
Meh
Jan 21, 2024
d3db113
Idk how to make Misc.loadEpisode work at this point...
Jan 22, 2024
65a5cff
Fix autostart level loading (Kinda), and add episode list generation …
Jan 22, 2024
5b4217c
Ugh
Jan 22, 2024
201d3fb
Add gLunaLua.exitContext() when loading episode from Lua
Jan 22, 2024
85df082
Remove unused P2 functions, use playerStoredCharacters if after boote…
Jan 22, 2024
090bf6b
Make world.getEpisodeList global everywhere
Jan 22, 2024
12f9485
Add GameAutostart things into Misc.loadEpisode
Jan 22, 2024
11443bf
Add GameAutostart.setSelectedEpisodePath
Jan 22, 2024
5633156
Resort world-related global functions, bring GameAutostart functions …
Jan 22, 2024
4f09594
Oops
Jan 22, 2024
a15aae0
Forgot to remove this
Jan 22, 2024
f90bf7e
Add support for autostart.ini on boot, make error message when nothin…
Jan 22, 2024
1a2d960
Oops, again
Jan 22, 2024
44378a3
Add ANSI Windows path check to LaunchEpisode
Jan 22, 2024
2a3f0b2
Remove COMBOOL on the if statements
Jan 22, 2024
90b6ba5
Massive commit. Not completely finished yet though
Jan 23, 2024
f65b54b
Move LaunchEpisode to a new cpp/h file, add playerCount setting to Ga…
Jan 24, 2024
1de67bc
Epiodes now finally boot, but there's still a lot to do before I can …
Jan 24, 2024
edcd7db
Make LunaDLL compilable again
Jan 24, 2024
5ab9c3d
Remove level load stuff, will be moved to another branch
Jan 24, 2024
666ed5e
CMD has a new argument ("--playSfxOnStartup"), which can be used to p…
Jan 24, 2024
add9f7d
Fix potential issues with unused functions
Jan 24, 2024
121ee6f
Fix up "tempLocation = WorldPath(A).Location" mess
Jan 25, 2024
7501760
Fix for loop error
Jan 25, 2024
5d400d4
Fix templates, add GM_SAVE_PERCENTAGE_PTR (For later)
Jan 25, 2024
51e7222
Extended way to check for a wld file
Jan 25, 2024
f52eb10
Fix compile issues
Jan 25, 2024
8e91a30
More code reworking mess. Also added EpisodeMain::FindSaves
Jan 26, 2024
deb44c2
Oops
Jan 26, 2024
b20d601
Idk why world.getEpisodeList is nil... will have to check later
Jan 26, 2024
8fafc92
Make episode setting values private again, also fix Misc.loadEpisode …
Jan 26, 2024
0d3930a
Merge branch 'WohlSoft:master' into faster-episode-booting
Jan 27, 2024
7c0dcd5
Remove unused LunaLua loadEpisode function
Jan 27, 2024
b8a2ab1
Merge branch 'faster-episode-booting' of https://github.com/SpencerEv…
Jan 27, 2024
7d5e28e
Merge branch 'WohlSoft:master' into faster-episode-booting
Jan 28, 2024
c2b126a
Fix issue with episode booting wrong
Jan 28, 2024
2799bc3
Move getEpisodeList to Misc, and fix no world existence error
Jan 28, 2024
31717d1
Extend Misc.loadEpisode to also have a save slot, number of players, …
Jan 28, 2024
0d50c13
Specify GM_MAX_CHARACTERS instead of just 5, and fix something with t…
Jan 28, 2024
1cc7069
Move the private variables from GameAutostart back to the top
Jan 28, 2024
a739917
Remove unused canExecuteViaLua variables
Jan 28, 2024
df3de97
Fix some line spaces and comments
Jan 28, 2024
c1341f3
External wld files on Misc.loadEpisode can now be specified, but just…
Jan 30, 2024
bd8553c
Fix possible episodeName issue on Misc.loadEpisode
Jan 30, 2024
e28c757
Forgot this
Jan 30, 2024
1e891be
Fix things for episodes if the GM_EP_LIST_COUNT is more than 100, als…
Jan 30, 2024
99e97b3
Actually fix more than 100 episode booting
Jan 30, 2024
b9b9025
Attempt to fix everything to satisfy the devs (Part 1, after this com…
Feb 14, 2024
5593876
Merge remote-tracking branch 'upstream/master' into faster-episode-bo…
Feb 14, 2024
5fbe9d8
Make it compilable again
Feb 14, 2024
9703243
Merge remote-tracking branch 'upstream/master' into faster-episode-bo…
Jun 20, 2024
3d82193
Put this pull request's new GlobalFuncs functions in the cpp file to …
Jun 20, 2024
773c7e9
See description for changes
Jun 20, 2024
2b04f44
Remove useless "For(A, From, To)" function, since it's now unused
Jun 20, 2024
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
25 changes: 22 additions & 3 deletions LunaDll/Defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ enum NPCTransformationCause {
#define GM_PLAYER_KEY_SEL 8
#define GM_PLAYER_KEY_STR 9

#define GM_MAX_PLAYERS 200
#define GM_MAX_CHARACTERS 5

#define DEFMEM(name, type, addr) static auto& name = *(type*)(addr); \
static constexpr std::uintptr_t name ## _ADDR = addr; \
static auto name ## _POINTER = (type*)(addr);
Expand All @@ -207,7 +210,7 @@ DEFMEM(GM_DO_SCREENSHOT, short, 0x00B2504C);
DEFMEM(GM_CREDITS_MODE, WORD, 0x00B2C89C);
DEFMEM(GM_EPISODE_MODE, WORD, 0x00B2C5B4); // 0xFFFF = leave current level
DEFMEM(GM_LEVEL_MODE, WORD, 0x00B2C620);
DEFMEM(GM_TITLE_INTRO_MODE, WORD, 0x00B2C620)
DEFMEM(GM_TITLE_INTRO_MODE, WORD, 0x00B2C620);
/*
The modes work as followed:
GM_CREDITS_MODE == -1 --> Credits
Expand Down Expand Up @@ -254,6 +257,11 @@ DEFMEM(GM_PLAYERS_COUNT, WORD, 0x00B2595E);
DEFMEM(GM_EDIT_PLAYERS_PTR, void*, 0x00CF74D8); // Editor Template player
DEFMEM(GM_PLAYER_POS, Momentum*, 0x00B25148);

DEFMEM(GM_PLAYER_OWED_MOUNT_PTR, void*, 0x00B25180); // When a yoshi/boot is taken from the player this returns after going back to the world map
DEFMEM(GM_PLAYER_OWED_MOUNT_COUNT, WORD, 0x00B25178);
DEFMEM(GM_PLAYER_OWED_MOUNT_TYPE_PTR, void*, 0x00B2519C);
DEFMEM(GM_PLAYER_OWED_MOUNT_TYPE_COUNT, WORD, 0x00B25194);

// Star counting
DEFMEM(GM_STAR_COUNT, WORD, 0x00B251E0);
DEFMEM(GM_STARS_PTR, void*, 0x00B25714);
Expand Down Expand Up @@ -289,6 +297,7 @@ DEFMEM(GM_KEYRELEASED, WORD, 0x00B2C884);
// States
DEFMEM(GM_FREEZWITCH_ACTIV, WORD, 0x00B2C8B4);
DEFMEM(GM_PAUSE_OPEN, WORD, 0x00B250E2);
DEFMEM(GM_FORCED_CONTROLS, WORD, 0x00B2D712);

DEFMEM(GM_CHEAT_MONEYTREE_HAVEMONEY, DWORD, 0x00B2C8BA);

Expand All @@ -303,7 +312,7 @@ DEFMEM(GM_OVERWORLD_PTR, void*, 0x00B2C5C8);
// Overworld Level Array
DEFMEM(GM_LEVEL_COUNT, WORD, 0x00B25960);
DEFMEM(GM_LEVEL_BASE, void*, 0x00B25994);

DEFMEM(GM_OVERWORLD_CUR_LVL, WORD, 0x00B2C5D6);

// Level related memory
DEFMEM(GM_LVLFILENAME_PTR, VB6StrPtr, 0x00B2C5A4); // Lvl filename
Expand Down Expand Up @@ -396,12 +405,14 @@ DEFMEM(GM_INPUTTYPE, short*, 0x00B250A0);
DEFMEM(GM_INPUTSTR_BUF_PTR, VB6StrPtr, 0x00B2C898);

// Saves
DEFMEM(GM_CUR_SAVE_SLOT, WORD, 0x00B2C62A); // 1 2 or 3
DEFMEM(GM_CUR_SAVE_SLOT, WORD, 0x00B2C62A); // 1 2 or 3
DEFMEM(GM_SAVE_PERCENTAGE_PTR, void*, 0x00B2C644);

// Cheats
DEFMEM(GM_PLAYER_INVULN, WORD, 0x00B2C8C0); // 0xFFFF = invuln
DEFMEM(GM_PLAYER_INFJUMP, WORD, 0x00B2C8AC); // 0xFFFF = infinite jumps
DEFMEM(GM_PLAYER_SHADOWSTAR,WORD, 0x00B2C8AA); // 0xFFFF = shadowstar
DEFMEM(GM_WORLD_UNLOCK, WORD, 0x00B2C8B0); // 0xFFFF = illparkwhereiwant
DEFMEM(GM_CHEATED, WORD, 0x00B2C8C4); // 0xFFFF = cheated

// Frame counter
Expand Down Expand Up @@ -628,6 +639,12 @@ DEFMEM(GM_GAMETITLE_1, VB6StrPtr, 0x8BD869);
DEFMEM(GM_GAMETITLE_2, VB6StrPtr, 0x8BE25A);
DEFMEM(GM_GAMETITLE_3, VB6StrPtr, 0x96AF26);

// World Information
DEFMEM(GM_WORLD_NAME, VB6StrPtr, 0x00B2C624);
DEFMEM(GM_WORLD_INTRO_FILENAME, VB6StrPtr, 0x00B25724);
DEFMEM(GM_HUB_STYLED_EPISODE, WORD, 0x00B25728);
DEFMEM(GM_RESTART_ON_DEATH, WORD, 0x00B2572A);


/////////////////////
/// -Assembly- ///
Expand Down Expand Up @@ -842,6 +859,7 @@ DEFMEM(IMP_vbaInputFile, void*, 0x00401158); // Ptr to __cdecl
#define GF_UPDATE_BLOCK_ANIM 0x009E14B0

#define GF_CLEANUP_LEVEL 0x008DC6E0
#define GF_CLEANUP_WORLD 0x008E2E40
#define GF_LOAD_LEVEL 0x008D8F40
#define GF_INIT_CAMERA 0x009502E0
#define GF_RENDER_INIT_SCREEN 0x00987DE0
Expand Down Expand Up @@ -938,6 +956,7 @@ static const auto native_renderLevel = (void(__stdcall *)(void))GF_RENDER_LEV
static const auto native_updateBlockAnim = (void(__stdcall *)(void))GF_UPDATE_BLOCK_ANIM;

static const auto native_cleanupLevel = (void(__stdcall *)(void))GF_CLEANUP_LEVEL;
static const auto native_cleanupWorld = (void(__stdcall *)(void))GF_CLEANUP_WORLD;
static const auto native_loadLevel = (void(__stdcall *)(VB6StrPtr* /*path*/))GF_LOAD_LEVEL;
static const auto native_initCamera = (void(__stdcall *)(void))GF_INIT_CAMERA;
static const auto native_renderInitScreen = (void(__stdcall *)(void))GF_RENDER_INIT_SCREEN;
Expand Down
2 changes: 1 addition & 1 deletion LunaDll/EventStateMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "Misc/LoadScreen.h"
#include "Rendering/GL/GLEngineProxy.h"
#include "SdlMusic/SdlMusPlayer.h"
#include "SMBXInternal/Reconstructed/EpisodeMain.h"
#include "SMBXInternal/Variables.h"

// Global instance
Expand Down Expand Up @@ -193,7 +194,6 @@ void EventStateMachine::sendOnTick(void) {
m_onTickReady = false;

sendSimpleLuaEvent("onTick");

m_onTickEndReady = true;
}

Expand Down
2 changes: 2 additions & 0 deletions LunaDll/FileManager/SMBXFileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "../SMBXInternal/Layer.h"
#include "../SMBXInternal/SMBXEvents.h"

#include "../SMBXInternal/Reconstructed/EpisodeMain.h"

#include <DirManager/dirman.h>

SMBXLevelFileBase::SMBXLevelFileBase() :
Expand Down
15 changes: 15 additions & 0 deletions LunaDll/GameConfig/GameAutostart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ GameAutostart GameAutostart::createGameAutostartByIniConfig(IniProcessing &reade
autostarter.selectedWldPath = L"";
autostarter.selectedEpisode = reader.value("episode-name", "").toString();
autostarter.singleplayer = reader.value("singleplayer", true).toBool();
autostarter.playerCount = reader.value("players", 1).toInt();
autostarter.firstCharacter = static_cast<Characters>(reader.value("character-player1", 1).toInt());
autostarter.secondCharacter = static_cast<Characters>(reader.value("character-player2", 2).toInt());
autostarter.saveSlot = reader.value("save-slot", 1).toInt();
Expand All @@ -200,12 +201,26 @@ GameAutostart GameAutostart::createGameAutostartByStartupEpisodeSettings(const S
autostarter.selectedWldPath = settings.wldPath;
autostarter.selectedEpisode = "";
autostarter.singleplayer = (settings.players == 1);
autostarter.playerCount = settings.players;
autostarter.firstCharacter = static_cast<Characters>(settings.character1);
autostarter.secondCharacter = static_cast<Characters>(settings.character2);
autostarter.saveSlot = settings.saveSlot;
return autostarter;
}

GameAutostart GameAutostart::createGameAutostartByManualSettings(std::wstring wldPath, int players, int character1, int character2, int saveSlot)
{
GameAutostart autostarter;
autostarter.selectedWldPath = wldPath;
autostarter.selectedEpisode = "";
autostarter.singleplayer = (players == 1);
autostarter.playerCount = players;
autostarter.firstCharacter = static_cast<Characters>(character1);
autostarter.secondCharacter = static_cast<Characters>(character2);
autostarter.saveSlot = saveSlot;
return autostarter;
}

/*static*/ void GameAutostart::ClearAutostartPatch()
{
skipIntoPatch.Unapply();
Expand Down
36 changes: 34 additions & 2 deletions LunaDll/GameConfig/GameAutostart.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class GameAutostart
std::string selectedEpisode;
std::wstring selectedWldPath;
bool singleplayer;
int playerCount;
Characters firstCharacter;
Characters secondCharacter;
int saveSlot;
Expand All @@ -23,10 +24,41 @@ class GameAutostart
~GameAutostart();
static GameAutostart createGameAutostartByIniConfig(IniProcessing& reader);
static GameAutostart createGameAutostartByStartupEpisodeSettings(const StartupEpisodeSettings& settings);
static GameAutostart createGameAutostartByManualSettings(std::wstring wldPath, int players, int character1, int character2, int saveSlot);
static void ClearAutostartPatch();

void setSelectedEpisode(std::string val) { selectedEpisode = val; }
void setSaveSlot(int val) { saveSlot = val; }
void setSelectedEpisode(std::string val)
{
selectedEpisode = val;
}
void setSelectedEpisodePath(std::wstring val)
{
selectedWldPath = val;
}
void setPlayerCount(int val)
{
playerCount = val;
if(val >= 2)
{
singleplayer = false;
}
else if(val <= 1)
{
singleplayer = true;
}
}
void setFirstCharacter(int val)
{
firstCharacter = (Characters)val;
}
void setSecondCharacter(int val)
{
secondCharacter = (Characters)val;
}
void setSaveSlot(int val)
{
saveSlot = val;
}

bool applyAutostart();
};
Expand Down
Loading