ref: 44f142d8e75f71df89a9710f11c678b3a3bf6cc7
parent: 765beff57af868176765c5a96e3039264722aace
author: Clownacy <[email protected]>
date: Thu Jun 20 16:06:55 EDT 2019
Big ugly rework of WindowsWrapper.h Okay so WindowsWrapper.h now just includes Windows.h if it wants non-portability. This meant I had to split the custom RECT struct back to the original RECT and unknown nameless struct (one uses left/right, while the other uses front/back).
--- a/src/Bullet.h
+++ b/src/Bullet.h
@@ -29,7 +29,13 @@
int enemyYL;
int blockXL;
int blockYL;
- RECT view;
+ struct
+ {
+ int front;
+ int top;
+ int back;
+ int bottom;
+ } view;
};
struct BULLET_TABLE
@@ -42,7 +48,13 @@
int enemyYL;
int blockXL;
int blockYL;
- RECT view;
+ struct
+ {
+ int front;
+ int top;
+ int back;
+ int bottom;
+ } view;
};
#define BULLET_MAX 0x40
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -5,18 +5,6 @@
#endif
#include <string.h>
-#ifdef WINDOWS
-#define RECT WINRECT
-#define FindResource WinFindResource // All these damn name collisions...
-#define DrawText WinDrawText
-#define LoadFont WinLoadFont
-#include <windows.h>
-#undef LoadFont
-#undef DrawText
-#undef FindResource
-#undef RECT
-#endif
-
#include "SDL.h"
#include "WindowsWrapper.h"
@@ -50,7 +38,7 @@
#define FRAMERATE 20
-BOOL Flip_SystemTask(int hWnd)
+BOOL Flip_SystemTask(HWND hWnd)
{
(void)hWnd;
--- a/src/Draw.h
+++ b/src/Draw.h
@@ -52,7 +52,7 @@
extern SURFACE surf[SURFACE_ID_MAX];
-BOOL Flip_SystemTask(int hWnd);
+BOOL Flip_SystemTask(HWND hWnd);
BOOL StartDirectDraw(int lMagnification, int lColourDepth);
void EndDirectDraw();
void ReleaseSurface(int s);
--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -434,7 +434,7 @@
}
// Scene of the island falling
-int Scene_DownIsland(int hWnd, int mode)
+int Scene_DownIsland(HWND hWnd, int mode)
{
// Setup background
RECT rc_frame = {(WINDOW_WIDTH - 160) / 2, (WINDOW_HEIGHT - 80) / 2, (WINDOW_WIDTH + 160) / 2, (WINDOW_HEIGHT + 80) / 2};
--- a/src/Ending.h
+++ b/src/Ending.h
@@ -50,4 +50,4 @@
void ActionCredit();
void SetCreditIllust(int a);
void CutCreditIllust();
-int Scene_DownIsland(int hWnd, int mode);
+int Scene_DownIsland(HWND hWnd, int mode);
--- a/src/Escape.cpp
+++ b/src/Escape.cpp
@@ -7,7 +7,7 @@
#include "KeyControl.h"
#include "Main.h"
-int Call_Escape(int hWnd)
+int Call_Escape(HWND hWnd)
{
RECT rc = {0, 128, 208, 144};
--- a/src/Escape.h
+++ b/src/Escape.h
@@ -1,3 +1,5 @@
#pragma once
-int Call_Escape(int hWnd);
+#include "WindowsWrapper.h"
+
+int Call_Escape(HWND hWnd);
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -31,7 +31,7 @@
int gJoystickButtonTable[8];
-int ghWnd; // Placeholder until we restore the WinAPI code
+HWND ghWnd; // Placeholder until we restore the WinAPI code
BOOL gbUseJoystick = FALSE;
BOOL bFps = FALSE;
--- a/src/Main.h
+++ b/src/Main.h
@@ -1,6 +1,8 @@
#pragma once
-extern int ghWnd;
+#include "WindowsWrapper.h"
+
+extern HWND ghWnd;
void PutFramePerSecound();
int GetFramePerSecound();
--- a/src/MyChar.cpp
+++ b/src/MyChar.cpp
@@ -201,7 +201,7 @@
if (gMC.direct == 0)
PutBitmap3(
&grcGame,
- (gMC.x - gMC.view.left) / 0x200 - fx / 0x200 - 8,
+ (gMC.x - gMC.view.front) / 0x200 - fx / 0x200 - 8,
(gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y,
&gMC.rect_arms,
SURFACE_ID_ARMS);
@@ -208,7 +208,7 @@
else
PutBitmap3(
&grcGame,
- (gMC.x - gMC.view.left) / 0x200 - fx / 0x200,
+ (gMC.x - gMC.view.front) / 0x200 - fx / 0x200,
(gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y,
&gMC.rect_arms,
SURFACE_ID_ARMS);
@@ -224,7 +224,7 @@
rect.bottom += 32;
}
- PutBitmap3(&grcGame, (gMC.x - gMC.view.left) / 0x200 - fx / 0x200, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200, &rect, SURFACE_ID_MY_CHAR);
+ PutBitmap3(&grcGame, (gMC.x - gMC.view.front) / 0x200 - fx / 0x200, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200, &rect, SURFACE_ID_MY_CHAR);
// Draw air tank
RECT rcBubble[2] = {
--- a/src/MyChar.h
+++ b/src/MyChar.h
@@ -21,8 +21,20 @@
int ym;
int ani_wait;
int ani_no;
- RECT hit;
- RECT view;
+ struct
+ {
+ int front;
+ int top;
+ int back;
+ int bottom;
+ } hit;
+ struct
+ {
+ int front;
+ int top;
+ int back;
+ int bottom;
+ } view;
RECT rect;
RECT rect_arms;
int level;
--- a/src/MycHit.cpp
+++ b/src/MycHit.cpp
@@ -36,11 +36,11 @@
// Left wall
if (gMC.y - gMC.hit.top < (y * 0x10 + 4) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 4) * 0x200
- && gMC.x - gMC.hit.left < (x * 0x10 + 8) * 0x200
- && gMC.x - gMC.hit.left > x * 0x10 * 0x200)
+ && gMC.x - gMC.hit.back < (x * 0x10 + 8) * 0x200
+ && gMC.x - gMC.hit.back > x * 0x10 * 0x200)
{
// Clip
- gMC.x = ((x * 0x10 + 8) * 0x200) + gMC.hit.left;
+ gMC.x = ((x * 0x10 + 8) * 0x200) + gMC.hit.back;
// Halt momentum
if (gMC.xm < -0x180)
@@ -55,11 +55,11 @@
// Right wall
if (gMC.y - gMC.hit.top < (y * 0x10 + 4) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 4) * 0x200
- && gMC.x + gMC.hit.right > (x * 0x10 - 8) * 0x200
- && gMC.x + gMC.hit.left < x * 0x10 * 0x200)
+ && gMC.x + gMC.hit.back > (x * 0x10 - 8) * 0x200
+ && gMC.x + gMC.hit.back < x * 0x10 * 0x200)
{
// Clip
- gMC.x = ((x * 0x10 - 8) * 0x200) - gMC.hit.right;
+ gMC.x = ((x * 0x10 - 8) * 0x200) - gMC.hit.back;
// Halt momentum
if (gMC.xm > 0x180)
@@ -72,8 +72,8 @@
}
// Ceiling
- if (gMC.x - gMC.hit.right < (x * 0x10 + 5) * 0x200
- && gMC.x + gMC.hit.right > (x * 0x10 - 5) * 0x200
+ if (gMC.x - gMC.hit.back < (x * 0x10 + 5) * 0x200
+ && gMC.x + gMC.hit.back > (x * 0x10 - 5) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 + 8) * 0x200
&& gMC.y - gMC.hit.top > y * 0x10 * 0x200)
{
@@ -91,8 +91,8 @@
}
// Floor
- if (gMC.x - gMC.hit.right < (x * 0x10 + 5) * 0x200
- && gMC.x + gMC.hit.right > ((x * 0x10 - 5) * 0x200)
+ if (gMC.x - gMC.hit.back < (x * 0x10 + 5) * 0x200
+ && gMC.x + gMC.hit.back > ((x * 0x10 - 5) * 0x200)
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 8) * 0x200
&& gMC.y + gMC.hit.bottom < y * 0x10 * 0x200)
{
@@ -324,8 +324,8 @@
{
int hit = 0;
- if (gMC.x - gMC.hit.right < (x * 0x10 + 5) * 0x200
- && gMC.x + gMC.hit.right > ((x * 0x10 - 5) * 0x200)
+ if (gMC.x - gMC.hit.back < (x * 0x10 + 5) * 0x200
+ && gMC.x + gMC.hit.back > ((x * 0x10 - 5) * 0x200)
&& gMC.y - gMC.hit.top < ((y * 0x10 + 5) * 0x200)
&& gMC.y + gMC.hit.bottom > y * 0x10 * 0x200)
hit |= 0x100;
@@ -362,8 +362,8 @@
int JudgeHitMyCharVectLeft(int x, int y)
{
int hit = 0;
- if (gMC.x - gMC.hit.right < (x * 0x10 + 6) * 0x200
- && gMC.x + gMC.hit.right > (x * 0x10 - 6) * 0x200
+ if (gMC.x - gMC.hit.back < (x * 0x10 + 6) * 0x200
+ && gMC.x + gMC.hit.back > (x * 0x10 - 6) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 + 6) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 6) * 0x200)
hit |= 0x1000;
@@ -374,8 +374,8 @@
int JudgeHitMyCharVectUp(int x, int y)
{
int hit = 0;
- if (gMC.x - gMC.hit.right < (x * 0x10 + 6) * 0x200
- && gMC.x + gMC.hit.right > (x * 0x10 - 6) * 0x200
+ if (gMC.x - gMC.hit.back < (x * 0x10 + 6) * 0x200
+ && gMC.x + gMC.hit.back > (x * 0x10 - 6) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 + 6) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 6) * 0x200)
hit |= 0x2000;
@@ -386,8 +386,8 @@
int JudgeHitMyCharVectRight(int x, int y)
{
int hit = 0;
- if (gMC.x - gMC.hit.right < (x * 0x10 + 6) * 0x200
- && gMC.x + gMC.hit.right > (x * 0x10 - 6) * 0x200
+ if (gMC.x - gMC.hit.back < (x * 0x10 + 6) * 0x200
+ && gMC.x + gMC.hit.back > (x * 0x10 - 6) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 + 6) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 6) * 0x200)
hit |= 0x4000;
@@ -398,8 +398,8 @@
int JudgeHitMyCharVectDown(int x, int y)
{
int hit = 0;
- if (gMC.x - gMC.hit.right < (x * 0x10 + 6) * 0x200
- && gMC.x + gMC.hit.right > (x * 0x10 - 6) * 0x200
+ if (gMC.x - gMC.hit.back < (x * 0x10 + 6) * 0x200
+ && gMC.x + gMC.hit.back > (x * 0x10 - 6) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 + 6) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 6) * 0x200)
hit |= 0x8000;
@@ -591,8 +591,8 @@
if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom - 0x600
&& gMC.y + gMC.hit.bottom > npc->y - npc->hit.top + 0x600
- && gMC.x - gMC.hit.right < npc->x + npc->hit.back
- && gMC.x - gMC.hit.right > npc->x)
+ && gMC.x - gMC.hit.back < npc->x + npc->hit.back
+ && gMC.x - gMC.hit.back > npc->x)
{
if (gMC.xm < 0x200)
gMC.xm += 0x200;
@@ -601,8 +601,8 @@
if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom - 0x600
&& gMC.y + gMC.hit.bottom > npc->y - npc->hit.top + 0x600
- && gMC.x + gMC.hit.right - 0x200 > npc->x - npc->hit.back
- && gMC.x + gMC.hit.right - 0x200 < npc->x)
+ && gMC.x + gMC.hit.back - 0x200 > npc->x - npc->hit.back
+ && gMC.x + gMC.hit.back - 0x200 < npc->x)
{
if (gMC.xm > -0x200)
gMC.xm -= 0x200;
@@ -609,8 +609,8 @@
hit |= 4;
}
- if (gMC.x - gMC.hit.right < npc->x + npc->hit.back - 0x600
- && gMC.x + gMC.hit.right > npc->x - npc->hit.back + 0x600
+ if (gMC.x - gMC.hit.back < npc->x + npc->hit.back - 0x600
+ && gMC.x + gMC.hit.back > npc->x - npc->hit.back + 0x600
&& gMC.y - gMC.hit.top < npc->y + npc->hit.bottom
&& gMC.y - gMC.hit.top > npc->y)
{
@@ -619,8 +619,8 @@
hit |= 2;
}
- if (gMC.x - gMC.hit.right < npc->x + npc->hit.back - 0x600
- && gMC.x + gMC.hit.right > npc->x - npc->hit.back + 0x600
+ if (gMC.x - gMC.hit.back < npc->x + npc->hit.back - 0x600
+ && gMC.x + gMC.hit.back > npc->x - npc->hit.back + 0x600
&& gMC.y + gMC.hit.bottom > npc->y - npc->hit.top
&& gMC.hit.bottom + gMC.y < npc->y + 0x600)
{
@@ -692,7 +692,7 @@
if (fy1 / fx1 > fy2 / fx2)
{
- if (gMC.x - gMC.hit.right < npc->x + npc->hit.back && gMC.x + gMC.hit.right > npc->x - npc->hit.back)
+ if (gMC.x - gMC.hit.back < npc->x + npc->hit.back && gMC.x + gMC.hit.back > npc->x - npc->hit.back)
{
if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom && gMC.y - gMC.hit.top > npc->y)
{
@@ -739,22 +739,22 @@
{
if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top)
{
- if (gMC.x - gMC.hit.right < npc->x + npc->hit.back && gMC.x - gMC.hit.right > npc->x)
+ if (gMC.x - gMC.hit.back < npc->x + npc->hit.back && gMC.x - gMC.hit.back > npc->x)
{
if (gMC.xm < npc->xm)
gMC.xm = npc->xm;
- gMC.x = npc->hit.back + npc->x + gMC.hit.right;
+ gMC.x = npc->hit.back + npc->x + gMC.hit.back;
hit |= 1;
}
- if (gMC.x + gMC.hit.right > npc->x - npc->hit.back && gMC.hit.right + gMC.x < npc->x)
+ if (gMC.x + gMC.hit.back > npc->x - npc->hit.back && gMC.hit.back + gMC.x < npc->x)
{
if (gMC.xm > npc->xm)
gMC.xm = npc->xm;
- gMC.x = npc->x - npc->hit.back - gMC.hit.right;
+ gMC.x = npc->x - npc->hit.back - gMC.hit.back;
hit |= 4;
}
--- a/src/NpChar.h
+++ b/src/NpChar.h
@@ -55,8 +55,20 @@
int count2;
int act_no;
int act_wait;
- RECT hit;
- RECT view;
+ struct
+ {
+ int front;
+ int top;
+ int back;
+ int bottom;
+ } hit;
+ struct
+ {
+ int front;
+ int top;
+ int back;
+ int bottom;
+ } view;
unsigned char shock;
int damage_view;
int damage;
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -1251,7 +1251,7 @@
char str_0[0x40];
#ifdef NONPORTABLE
sprintf(str_0, "�s���̃R�[�h:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
- MessageBoxA(0, str_0, "�G���[", 0);
+ MessageBoxA(ghWnd, str_0, "�G���[", 0);
#else
#ifdef JAPANESE
sprintf(str_0, "�s���̃R�[�h:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
--- a/src/WindowsWrapper.h
+++ b/src/WindowsWrapper.h
@@ -1,8 +1,14 @@
#pragma once
-int rep_rand();
-void rep_srand(unsigned int seed);
+#ifdef NONPORTABLE
+#include <Windows.h>
+// Avoid name collisions
+#undef DrawText
+#undef FindResource
+#else
+typedef int HWND;
+
typedef int BOOL;
#ifndef FALSE
@@ -13,6 +19,15 @@
#define TRUE 1
#endif
+struct RECT
+{
+ long left;
+ long top;
+ long right;
+ long bottom;
+};
+#endif
+
#define SET_RECT(rect, l, t, r, b) \
rect.left = l; \
rect.top = t; \
@@ -19,20 +34,7 @@
rect.right = r; \
rect.bottom = b;
-struct RECT
-{
- union
- {
- int left;
- int front;
- };
- int top;
- union
- {
- int right;
- int back;
- };
- int bottom;
-};
+int rep_rand();
+void rep_srand(unsigned int seed);
BOOL SystemTask();