1
0
mirror of synced 2024-11-28 01:10:55 +01:00

Configurable drum randomness

This commit is contained in:
BroGamer 2022-06-22 11:53:28 +12:00
parent 3b0d9764bf
commit 4eadb7499d
5 changed files with 41 additions and 27 deletions

3
dist/config.toml vendored Normal file
View File

@ -0,0 +1,3 @@
# Values for random drum hit amounts
drumMax = 0xFFFF
drumMin = 0xFFFF

View File

@ -5,15 +5,27 @@ i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) {
if (cause != DLL_PROCESS_ATTACH) if (cause != DLL_PROCESS_ATTACH)
return 1; return 1;
WRITE_MEMORY (ASLR(0x1400239C0), u8, 0xC3); // Stop error void *handle = GetModuleHandle (0);
WRITE_MEMORY (ASLR(0x140314E8D), u8, 0xB0, 0x01); // Unlock songs
WRITE_MEMORY (ASLR(0x140692E17), u8, 0xEB); // Shared audio WRITE_MEMORY (ASLR(0x1400239C0, handle), u8, 0xC3); // Stop error
WRITE_MEMORY (ASLR(0x140313726), u8, 0x00, 0x7F); // Remove song limit WRITE_MEMORY (ASLR(0x140314E8D, handle), u8, 0xB0, 0x01); // Unlock songs
WRITE_MEMORY (ASLR(0x140517339), u8, 0xBA, 0x00, 0x00, 0x00, 0x00, WRITE_MEMORY (ASLR(0x140692E17, handle), u8, 0xEB); // Shared audio
WRITE_MEMORY (ASLR(0x140313726, handle), u8, 0x00, 0x7F); // Remove song limit
WRITE_MEMORY (ASLR(0x140517339, handle), u8, 0xBA, 0x00, 0x00, 0x00, 0x00,
0x90); // Disable VSync 0x90); // Disable VSync
// Save settings cross session // Save settings cross session
WRITE_MEMORY (ASLR(0x140B5C528), u8, "./Setting1.bin"); WRITE_MEMORY (ASLR(0x140B5C528, handle), u8, "./Setting1.bin");
WRITE_MEMORY (ASLR(0x140B5C538), u8, "./Setting2.bin"); WRITE_MEMORY (ASLR(0x140B5C538, handle), u8, "./Setting2.bin");
void *amHandle = GetModuleHandle ("AMFrameWork.dll");
WRITE_MEMORY (amHandle + 0x33EF7, u8, 0xEB);
WRITE_MEMORY (amHandle + 0x3404A, u8, 0xEB);
WRITE_MEMORY (amHandle + 0x34429, u8, 0xEB);
WRITE_MEMORY (amHandle + 0x3457C, u8, 0xEB);
WRITE_MEMORY (amHandle + 0x3497A, u8, 0xEB);
WRITE_MEMORY (amHandle + 0x34ACD, u8, 0xEB);
WRITE_MEMORY (amHandle + 0x148AF, u8, 0xEB);
WRITE_MEMORY (amHandle + 0x14A1A, u8, 0xEB);
return 1; return 1;
} }

View File

@ -18,7 +18,11 @@ enumWindows (HWND handle, LPARAM param) {
// force show cursor // force show cursor
HOOK_DYNAMIC (i32, __stdcall, ShowMouse, i32 show) { return originalShowMouse (true); } HOOK_DYNAMIC (i32, __stdcall, ShowMouse, i32 show) { return originalShowMouse (true); }
#define ON_HIT(bind) IsButtonTapped (bind) ? 0xFFFF : 0 bool testEnabled = false;
u16 drumMax = 0xFFFF;
u16 drumMin = 0xFFFF;
#define ON_HIT(bind) IsButtonTapped (bind) ? drumMax == drumMin ? drumMax : (u16)(rand () % drumMax + drumMin) : 0
struct Keybindings EXIT = { .keycodes = { VK_ESCAPE } }; struct Keybindings EXIT = { .keycodes = { VK_ESCAPE } };
struct Keybindings COIN_ADD = { .keycodes = { VK_RETURN }, .buttons = { SDL_CONTROLLER_BUTTON_START } }; struct Keybindings COIN_ADD = { .keycodes = { VK_RETURN }, .buttons = { SDL_CONTROLLER_BUTTON_START } };
@ -36,8 +40,6 @@ struct Keybindings P2_LEFT_RED = {};
struct Keybindings P2_RIGHT_RED = {}; struct Keybindings P2_RIGHT_RED = {};
struct Keybindings P2_RIGHT_BLUE = {}; struct Keybindings P2_RIGHT_BLUE = {};
bool testEnabled = false;
u16 __fastcall bnusio_GetAnalogIn (u8 which) { u16 __fastcall bnusio_GetAnalogIn (u8 which) {
switch (which) { switch (which) {
case 0: return ON_HIT (P1_LEFT_BLUE); // Player 1 Left Blue case 0: return ON_HIT (P1_LEFT_BLUE); // Player 1 Left Blue
@ -135,5 +137,12 @@ i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) {
FindClose (hFind); FindClose (hFind);
} }
toml_table_t *config = openConfig (configPath ("config.toml"));
if (config) {
drumMax = readConfigInt (config, "drumMax", drumMax);
drumMin = readConfigInt (config, "drumMin", drumMin);
toml_free (config);
}
return true; return true;
} }

View File

@ -16,7 +16,7 @@ typedef uint32_t u32;
typedef uint64_t u64; typedef uint64_t u64;
#ifdef BASE_ADDRESS #ifdef BASE_ADDRESS
#define ASLR(address) ((u64)GetModuleHandle (0) + (u64)address - (u64)BASE_ADDRESS) #define ASLR(address, handle) ((u64)handle + (u64)address - (u64)BASE_ADDRESS)
#endif #endif
#define FUNCTION_PTR(returnType, callingConvention, function, location, ...) \ #define FUNCTION_PTR(returnType, callingConvention, function, location, ...) \
@ -49,8 +49,6 @@ typedef uint64_t u64;
INSTALL_HOOK (functionName); \ INSTALL_HOOK (functionName); \
} }
#define READ_MEMORY(location, type) *(type *)location
#define WRITE_MEMORY(location, type, ...) \ #define WRITE_MEMORY(location, type, ...) \
{ \ { \
const type data[] = { __VA_ARGS__ }; \ const type data[] = { __VA_ARGS__ }; \

View File

@ -150,20 +150,15 @@ InitializePoll (void *DivaWindowHandle) {
if (SDL_Init (SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS | SDL_INIT_VIDEO) == 0) { if (SDL_Init (SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS | SDL_INIT_VIDEO) == 0) {
hasRumble = false; hasRumble = false;
} else { } else {
printError ( printError ("SDL_Init (SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS | SDL_INIT_VIDEO): "
"%s\n",
"SDL_Init (SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | " SDL_GetError ());
"SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS | SDL_INIT_VIDEO): "
"%s\n",
SDL_GetError ());
return false; return false;
} }
} }
if (SDL_GameControllerAddMappingsFromFile (configPath ("gamecontrollerdb.txt")) == -1) if (SDL_GameControllerAddMappingsFromFile (configPath ("gamecontrollerdb.txt")) == -1)
printError ("%s (): Cannot read " printError ("%s (): Cannot read plugins/gamecontrollerdb.txt\n", __func__);
"plugins/gamecontrollerdb.txt\n",
__func__);
SDL_GameControllerEventState (SDL_ENABLE); SDL_GameControllerEventState (SDL_ENABLE);
for (int i = 0; i < SDL_NumJoysticks (); i++) { for (int i = 0; i < SDL_NumJoysticks (); i++) {
@ -211,11 +206,8 @@ UpdatePoll (void *DivaWindowHandle) {
SDL_GameController *controller = SDL_GameControllerOpen (event.cdevice.which); SDL_GameController *controller = SDL_GameControllerOpen (event.cdevice.which);
if (!controller) { if (!controller) {
printError ( printError ("%s (): Could not open gamecontroller %s: %s\n", __func__, SDL_GameControllerNameForIndex (event.cdevice.which),
SDL_GetError ());
"%s (): Could not open "
"gamecontroller %s: %s\n",
__func__, SDL_GameControllerNameForIndex (event.cdevice.which), SDL_GetError ());
continue; continue;
} }