shithub: cstory

Download patch

ref: d9043a7c49406054b0a6b3468ea282ba75810507
parent: 2f56effc51b5f5e6156b54a2fb7d06c5f64fa1da
author: Clownacy <Clownacy@users.noreply.github.com>
date: Fri Aug 30 20:22:07 EDT 2019

Added Dialog.cpp

The filename is a total guess, but Microsoft's own word for these
menus is 'dialog', and these functions appear before the Draw.cpp
functions (the source files are linked alphabetically).

--- a/msvc2003/CSE2.vcproj
+++ b/msvc2003/CSE2.vcproj
@@ -275,6 +275,9 @@
 				RelativePath="..\src\Config.cpp">
 			</File>
 			<File
+				RelativePath="..\src\Dialog.cpp">
+			</File>
+			<File
 				RelativePath="..\src\Draw.cpp">
 			</File>
 			<File
@@ -506,6 +509,9 @@
 			</File>
 			<File
 				RelativePath="..\src\Config.h">
+			</File>
+			<File
+				RelativePath="..\src\Dialog.h">
 			</File>
 			<File
 				RelativePath="..\src\Draw.h">
--- a/msvc2003/devilution/comparer-config.toml
+++ b/msvc2003/devilution/comparer-config.toml
@@ -356,6 +356,22 @@
 addr = 0x40AE30
 
 [[func]]
+name = "VersionDialog"
+addr = 0x40AEC0
+
+[[func]]
+name = "DebugMuteDialog"
+addr = 0x40AFC0
+
+[[func]]
+name = "DebugSaveDialog"
+addr = 0x40B1D0
+
+[[func]]
+name = "QuitDialog"
+addr = 0x40B290
+
+[[func]]
 name = "ActionStripper"
 addr = 0x40CF90
 
--- /dev/null
+++ b/src/Dialog.cpp
@@ -1,0 +1,157 @@
+#include "Dialog.h"
+
+#include <stdio.h>
+
+#include "WindowsWrapper.h"
+
+#include "Generic.h"
+#include "Organya.h"
+#include "Profile.h"
+
+// All of the original names for the functions/variables in this file are unknown
+
+static const char *version_string = 
+	"version.%d.%d.%d.%d\r\n"
+	"2004/12/20 - %04d/%02d/%02d\r\n"
+	"Studio Pixel"
+	;
+
+// TODO - Inaccurate stack frame
+BOOL __stdcall VersionDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+	char string_buffer[104];
+
+	int year;
+	int month;
+	int day;
+
+	int version1;
+	int version2;
+	int version3;
+	int version4;
+
+	switch (Msg)
+	{
+		case WM_INITDIALOG:
+			GetCompileDate(&year, &month, &day);
+			GetCompileVersion(&version1, &version2, &version3, &version4);
+			sprintf(string_buffer, version_string, version1, version2, version3, version4, year, month, day);
+			SetDlgItemTextA(hWnd, 1011, string_buffer);
+
+			CenterWindow(hWnd);
+
+			return TRUE;
+
+		case WM_COMMAND:
+			switch (LOWORD(wParam))
+			{
+				case 1:
+					EndDialog(hWnd, 1);
+					break;
+			}
+
+			break;
+	}
+
+	return FALSE;
+}
+
+BOOL __stdcall DebugMuteDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+	switch (Msg)
+	{
+		case WM_INITDIALOG:
+			CenterWindow(hWnd);
+			CheckDlgButton(hWnd, 1010, g_mute[0] != 0);
+			CheckDlgButton(hWnd, 1018, g_mute[1] != 0);
+			CheckDlgButton(hWnd, 1019, g_mute[2] != 0);
+			CheckDlgButton(hWnd, 1020, g_mute[3] != 0);
+			CheckDlgButton(hWnd, 1021, g_mute[4] != 0);
+			CheckDlgButton(hWnd, 1022, g_mute[5] != 0);
+			CheckDlgButton(hWnd, 1023, g_mute[6] != 0);
+			CheckDlgButton(hWnd, 1024, g_mute[7] != 0);
+			return TRUE;
+
+		case WM_COMMAND:
+			switch (LOWORD(wParam))
+			{
+				case 2:
+					EndDialog(hWnd, 0);
+					break;
+
+				case 1:
+					g_mute[0] = IsDlgButtonChecked(hWnd, 1010);
+					g_mute[1] = IsDlgButtonChecked(hWnd, 1018);
+					g_mute[2] = IsDlgButtonChecked(hWnd, 1019);
+					g_mute[3] = IsDlgButtonChecked(hWnd, 1020);
+					g_mute[4] = IsDlgButtonChecked(hWnd, 1021);
+					g_mute[5] = IsDlgButtonChecked(hWnd, 1022);
+					g_mute[6] = IsDlgButtonChecked(hWnd, 1023);
+					g_mute[7] = IsDlgButtonChecked(hWnd, 1024);
+					EndDialog(hWnd, 1);
+					break;
+			}
+
+			break;
+	}
+
+	return FALSE;
+}
+
+BOOL __stdcall DebugSaveDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+	char string[100];
+
+	switch (Msg)
+	{
+		case WM_INITDIALOG:
+			SetDlgItemTextA(hWnd, 1008, "000.dat");
+			CenterWindow(hWnd);
+			return TRUE;
+
+		case WM_COMMAND:
+			switch (LOWORD(wParam))
+			{
+				case 2:
+					EndDialog(hWnd, 0);
+					break;
+
+				case 1:
+					GetDlgItemTextA(hWnd, 1008, string, sizeof(string));
+					SaveProfile(string);
+					EndDialog(hWnd, 1);
+					break;
+			}
+
+			break;
+	}
+
+	return FALSE;
+}
+
+BOOL __stdcall QuitDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
+{
+	switch (Msg)
+	{
+		case WM_INITDIALOG:
+			SetDlgItemTextA(hWnd, 1009, (LPCSTR)lParam);
+			CenterWindow(hWnd);
+			return TRUE;
+
+		case WM_COMMAND:
+			switch (LOWORD(wParam))
+			{
+				case 2:
+					EndDialog(hWnd, 2);
+					break;
+
+				case 1:
+					EndDialog(hWnd, 1);
+					break;
+			}
+
+			break;
+	}
+
+	return FALSE;
+}
--- /dev/null
+++ b/src/Dialog.h
@@ -1,0 +1,2 @@
+#pragma once
+
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -22,10 +22,6 @@
 #define VOLDUMMY 0xFF
 #define KEYDUMMY 0xFF
 
-#define MAXTRACK 16
-#define MAXMELODY 8
-#define MAXDRAM 8
-
 #define ALLOCNOTE 4096
 
 #define DEFVOLUME	200//255はVOLDUMMY。MAXは254
--- a/src/Organya.h
+++ b/src/Organya.h
@@ -4,6 +4,12 @@
 
 #include "WindowsWrapper.h"
 
+#define MAXTRACK 16
+#define MAXMELODY 8
+#define MAXDRAM 8
+
+extern BOOL g_mute[MAXTRACK];	// Used by the debug Mute menu
+
 BOOL MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi);
 void OrganyaPlayData();
 void SetPlayPointer(long x);