diff --git a/dist/config.toml b/dist/config.toml new file mode 100644 index 0000000..5ab3b65 --- /dev/null +++ b/dist/config.toml @@ -0,0 +1,3 @@ +# Values for random drum hit amounts +drumMax = 0xFFFF +drumMin = 0xFFFF diff --git a/patches/8.18/dllmain.c b/patches/8.18/dllmain.c index 20295cd..4754499 100644 --- a/patches/8.18/dllmain.c +++ b/patches/8.18/dllmain.c @@ -5,15 +5,27 @@ i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) { if (cause != DLL_PROCESS_ATTACH) return 1; - WRITE_MEMORY (ASLR(0x1400239C0), u8, 0xC3); // Stop error - WRITE_MEMORY (ASLR(0x140314E8D), u8, 0xB0, 0x01); // Unlock songs - WRITE_MEMORY (ASLR(0x140692E17), u8, 0xEB); // Shared audio - WRITE_MEMORY (ASLR(0x140313726), u8, 0x00, 0x7F); // Remove song limit - WRITE_MEMORY (ASLR(0x140517339), u8, 0xBA, 0x00, 0x00, 0x00, 0x00, + void *handle = GetModuleHandle (0); + + WRITE_MEMORY (ASLR(0x1400239C0, handle), u8, 0xC3); // Stop error + WRITE_MEMORY (ASLR(0x140314E8D, handle), u8, 0xB0, 0x01); // Unlock songs + 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 // Save settings cross session - WRITE_MEMORY (ASLR(0x140B5C528), u8, "./Setting1.bin"); - WRITE_MEMORY (ASLR(0x140B5C538), u8, "./Setting2.bin"); + WRITE_MEMORY (ASLR(0x140B5C528, handle), u8, "./Setting1.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; } diff --git a/src/dllmain.c b/src/dllmain.c index 32547a3..eaf67fb 100644 --- a/src/dllmain.c +++ b/src/dllmain.c @@ -18,7 +18,11 @@ enumWindows (HWND handle, LPARAM param) { // force show cursor 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 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_BLUE = {}; -bool testEnabled = false; - u16 __fastcall bnusio_GetAnalogIn (u8 which) { switch (which) { 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); } + 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; } \ No newline at end of file diff --git a/src/helpers.h b/src/helpers.h index 5318e9a..4867ed5 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -16,7 +16,7 @@ typedef uint32_t u32; typedef uint64_t u64; #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 #define FUNCTION_PTR(returnType, callingConvention, function, location, ...) \ @@ -49,8 +49,6 @@ typedef uint64_t u64; INSTALL_HOOK (functionName); \ } -#define READ_MEMORY(location, type) *(type *)location - #define WRITE_MEMORY(location, type, ...) \ { \ const type data[] = { __VA_ARGS__ }; \ diff --git a/src/poll.c b/src/poll.c index b43a934..754d13e 100644 --- a/src/poll.c +++ b/src/poll.c @@ -150,20 +150,15 @@ InitializePoll (void *DivaWindowHandle) { if (SDL_Init (SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS | SDL_INIT_VIDEO) == 0) { hasRumble = false; } else { - printError ( - - "SDL_Init (SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | " - "SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS | SDL_INIT_VIDEO): " - "%s\n", - SDL_GetError ()); + printError ("SDL_Init (SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_EVENTS | SDL_INIT_VIDEO): " + "%s\n", + SDL_GetError ()); return false; } } if (SDL_GameControllerAddMappingsFromFile (configPath ("gamecontrollerdb.txt")) == -1) - printError ("%s (): Cannot read " - "plugins/gamecontrollerdb.txt\n", - __func__); + printError ("%s (): Cannot read plugins/gamecontrollerdb.txt\n", __func__); SDL_GameControllerEventState (SDL_ENABLE); for (int i = 0; i < SDL_NumJoysticks (); i++) { @@ -211,11 +206,8 @@ UpdatePoll (void *DivaWindowHandle) { SDL_GameController *controller = SDL_GameControllerOpen (event.cdevice.which); if (!controller) { - printError ( - - "%s (): Could not open " - "gamecontroller %s: %s\n", - __func__, SDL_GameControllerNameForIndex (event.cdevice.which), SDL_GetError ()); + printError ("%s (): Could not open gamecontroller %s: %s\n", __func__, SDL_GameControllerNameForIndex (event.cdevice.which), + SDL_GetError ()); continue; }