summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-11-16 22:20:04 +0800
committerIru Cai <mytbk920423@gmail.com>2018-11-16 22:41:31 +0800
commitaf67008636f6e1805df626ca3862a36d0992251d (patch)
tree22157bc6ff8dab9664ecc69b502f1ce49d08db32
parentd2415c282518bfc0ff72bcbcdb1be6c37208efab (diff)
downloadrich4-af67008636f6e1805df626ca3862a36d0992251d.tar.xz
make main.c more buildable
-rw-r--r--csrc/global.h8
-rw-r--r--csrc/main.c24
-rw-r--r--csrc/misc.c17
3 files changed, 43 insertions, 6 deletions
diff --git a/csrc/global.h b/csrc/global.h
index a564023..307e338 100644
--- a/csrc/global.h
+++ b/csrc/global.h
@@ -36,3 +36,11 @@ extern char mid_status[7]; // 0x46cb00
/* card.c */
extern uint8_t card_amount[30];
+
+/* misc.c */
+extern char b_46caf8;
+extern char b_46caf9;
+extern char b_46cafa;
+extern char b_46cafb;
+extern char b_46cafc;
+extern char b_46cafd;
diff --git a/csrc/main.c b/csrc/main.c
index 6a0fd08..da62bb6 100644
--- a/csrc/main.c
+++ b/csrc/main.c
@@ -7,6 +7,9 @@
#include <ddraw.h>
#include "global.h"
#include "window_util.h"
+#include "mkf.h"
+#include "drawing.h"
+#include "misc.h"
HINSTANCE ghInstance; // 48a064
HWND gwindowHandle; // 48a0d4
@@ -14,7 +17,7 @@ RECT g_rect;
char mid_status[7]; // 0x46cb00
-typedef struct { int16_t x; int16_t y } pos_t;
+typedef struct { int16_t x; int16_t y; } pos_t;
static pos_t mpos[5] = { // central position of the buttons @0x46cb28
{190, 380}, // start
{328, 380}, // load
@@ -29,8 +32,18 @@ int price_index;
static struct spr_smp *data1; // 0x48a180
+void deinit_game(void);
+
+static void fcn_0045174a(void)
+{
+ mid_status[2] = 0;
+ Post_0402_Message(0);
+}
+
static LRESULT CALLBACK windowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
+ static int initiated = 0;
+
if (message < 0x1c) {
if (message == WM_DESTROY) {
deinit_game();
@@ -45,7 +58,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
}
if (message == WM_ACTIVATEAPP) {
if (wParam != 0) {
- if (dw_46cb0b != 0) {
+ if (initiated != 0) {
if (pddrawsf1 != NULL) {
IDirectDrawSurface_Restore(pddrawsf1);
}
@@ -63,7 +76,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
mid_status[1] = 1;
return 0;
}
- dw_46cb0b = 1;
+ initiated = 1;
mid_status[1] = 0;
if (mid_status[2] != 0) {
mciSendStringA("pause vfw", 0,0,0);
@@ -83,7 +96,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
fcn_0045174a();
return 0;
}
- sub_mciSendStringA_d2c();
+ playmid_454d2c();
return 0;
}
if (windowCallbacks[cb_top] == NULL) {
@@ -157,8 +170,7 @@ static LRESULT CALLBACK entryCallback(HWND hWnd, UINT message, WPARAM wParam, LP
switch (status) {
case 1:
fcn_00402460(0);
- eax = load_ui(0);
- if (eax != -1) {
+ if (load_ui(0) != -1) {
Post_0402_Message(status);
break;
}
diff --git a/csrc/misc.c b/csrc/misc.c
index 49cecfa..f4d28b1 100644
--- a/csrc/misc.c
+++ b/csrc/misc.c
@@ -21,3 +21,20 @@ void close_mid_454acb(void)
mid_status[3] = 0;
b_47e772 = 0;
}
+
+void play_avi(const char *fn, RECT *r, int x)
+{
+ /* TODO */
+}
+
+char b_46caf8;
+char b_46caf9;
+char b_46cafa;
+char b_46cafb;
+char b_46cafc;
+char b_46cafd;
+
+void playmid_454d2c(void)
+{
+ /* TODO */
+}