diff --git a/src/addresses.h b/src/addresses.h
index c8c8175d8f..494d31c8ca 100644
--- a/src/addresses.h
+++ b/src/addresses.h
@@ -38,7 +38,7 @@
#define RCT2_CALLPROC_2(address, a1, a2, v1, v2) RCT2_CALLFUNC_2(address, void, a1, a2, v1, v2)
#define RCT2_CALLPROC_3(address, a1, a2, a3, v1, v2, v3) RCT2_CALLFUNC_3(address, void, a1, a2, a3, v1, v2, v3)
#define RCT2_CALLPROC_4(address, a1, a2, a3, a4, v1, v2, v3, v4) RCT2_CALLFUNC_4(address, void, a1, a2, a3, a4, v1, v2, v3, v4)
-#define RCT2_CALLPROC_5(address, a1, a2, a3, a4, a5, v1, v2, v3, v4, v5) RCT2_CALLFUNC_4(address, void, a1, a2, a3, a4, a5, v1, v2, v3, v4, v5)
+#define RCT2_CALLPROC_5(address, a1, a2, a3, a4, a5, v1, v2, v3, v4, v5) RCT2_CALLFUNC_5(address, void, a1, a2, a3, a4, a5, v1, v2, v3, v4, v5)
#define RCT2_ADDRESS_LAND_TOOL_SIZE 0x009A9800
diff --git a/src/game.c b/src/game.c
index d23d70a00a..d801911bdc 100644
--- a/src/game.c
+++ b/src/game.c
@@ -61,6 +61,7 @@ void game_update()
if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0) {
for (; eax > 0; eax--) {
game_logic_update();
+ RCT2_CALLPROC_EBPSAFE(0x006BD0F8); // play title screen music
/*
if (rctmem->dword_009E2D74 == 1) {
@@ -141,7 +142,6 @@ void game_logic_update()
RCT2_CALLPROC_EBPSAFE(0x006BBC6B);
RCT2_CALLPROC_EBPSAFE(0x006BD18A);
RCT2_CALLPROC_EBPSAFE(0x006BCB91);
- RCT2_CALLPROC_EBPSAFE(0x006BD0F8);
news_item_update_current();
RCT2_CALLPROC_EBPSAFE(0x0067009A);
diff --git a/src/title.c b/src/title.c
index f23be3b851..818a8daf28 100644
--- a/src/title.c
+++ b/src/title.c
@@ -18,6 +18,8 @@
* along with this program. If not, see .
*****************************************************************************/
+#include
+#include
#include "addresses.h"
#include "date.h"
#include "game.h"
@@ -65,15 +67,18 @@ static int _scriptWaitCounter;
static void title_init_showcase();
static void title_update_showcase();
+static void title_play_music();
+
+static uint8 *generate_random_script();
#pragma endregion
static void title_create_windows();
/**
-*
-* rct2: 0x0068E8DA
-*/
+ *
+ * rct2: 0x0068E8DA
+ */
void title_load()
{
if (RCT2_GLOBAL(0x009DEA6E, uint8) & 1)
@@ -106,10 +111,10 @@ void title_load()
}
/**
-* Creates the windows shown on the title screen; New game, load game,
-* tutorial, toolbox and exit.
-* rct2: 0x0066B5C0 (part of 0x0066B3E8)
-*/
+ * Creates the windows shown on the title screen; New game, load game,
+ * tutorial, toolbox and exit.
+ * rct2: 0x0066B5C0 (part of 0x0066B3E8)
+ */
static void title_create_windows()
{
// RCT2_CALLPROC_EBPSAFE(0x0066B3E8);
@@ -122,20 +127,21 @@ static void title_create_windows()
}
/**
-*
-* rct2: 0x00678680
-*/
+ *
+ * rct2: 0x00678680
+ */
static void title_init_showcase()
{
_currentScript = _magicMountainScript;
+ // _currentScript = generate_random_script();
_scriptWaitCounter = 0;
title_update_showcase();
}
/**
-*
-* rct2: 0x00678761
-*/
+ *
+ * rct2: 0x00678761
+ */
static void title_update_showcase()
{
rct_window* w;
@@ -229,6 +235,7 @@ void title_update()
if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0) {
title_update_showcase();
game_logic_update();
+ title_play_music();
}
RCT2_GLOBAL(0x009DE518, uint32) &= ~0x80;
@@ -264,4 +271,61 @@ void title_update()
RCT2_CALLPROC_EBPSAFE(0x00675487);
}
}
+}
+
+/**
+ *
+ * rct2: 0x00678761
+ */
+static void title_play_music()
+{
+ // RCT2_CALLPROC_EBPSAFE(0x006BD0F8); // play title screen music
+
+ if (!(RCT2_GLOBAL(0x009AF284, uint32) & 1) || !(RCT2_GLOBAL(0x009AF59D, uint8) & 1)) {
+ if (RCT2_GLOBAL(0x009AF600, uint8) != 0)
+ RCT2_CALLPROC_EBPSAFE(0x006BD0BD); // stop music
+ return;
+ }
+
+ if (RCT2_GLOBAL(0x009AF600, uint8) != 0)
+ return;
+
+ // Play old title music
+ // char musicPath[_MAX_PATH];
+ // strcpy(musicPath, RCT2_ADDRESS(RCT2_ADDRESS_APP_PATH, char));
+ // strcat(musicPath, "\\data\\css50.dat");
+
+ if (RCT2_CALLFUNC_3(0x0040194E, int, int, int, int, 3, get_file_path(PATH_ID_CSS17), 0)) // play music
+ RCT2_CALLPROC_5(0x00401999, int, int, int, int, int, 3, 1, 0, 0, 0);
+
+ RCT2_GLOBAL(0x009AF600, uint8) = 1;
+}
+
+static uint8 *generate_random_script()
+{
+ int i, j;
+ const int views = 16;
+
+ srand(time(NULL));
+
+ uint8 *script = malloc(views * 8 + 2);
+ i = 0;
+ script[i++] = TITLE_SCRIPT_LOAD;
+ for (j = 0; j < views; j++) {
+ script[i++] = TITLE_SCRIPT_LOCATION;
+ script[i++] = 64 + (rand() % 128);
+ script[i++] = 64 + (rand() % 128);
+
+ int rotationCount = rand() % 4;
+ if (rotationCount > 0) {
+ script[i++] = TITLE_SCRIPT_ROTATE;
+ script[i++] = rotationCount;
+ }
+
+ script[i++] = TITLE_SCRIPT_WAIT;
+ script[i++] = 8 + (rand() % 6);
+ }
+ script[i] = TITLE_SCRIPT_RESTART;
+
+ return script;
}
\ No newline at end of file