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).
This commit is contained in:
Clownacy 2019-06-20 20:06:55 +01:00
parent 765beff57a
commit 44f142d8e7
15 changed files with 110 additions and 80 deletions

View file

@ -29,7 +29,13 @@ struct BULLET
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 @@ struct BULLET_TABLE
int enemyYL;
int blockXL;
int blockYL;
RECT view;
struct
{
int front;
int top;
int back;
int bottom;
} view;
};
#define BULLET_MAX 0x40

View file

@ -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 @@ FontObject *gFont;
#define FRAMERATE 20
BOOL Flip_SystemTask(int hWnd)
BOOL Flip_SystemTask(HWND hWnd)
{
(void)hWnd;

View file

@ -52,7 +52,7 @@ struct SURFACE;
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);

View file

@ -434,7 +434,7 @@ void CutCreditIllust()
}
// 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};

View file

@ -50,4 +50,4 @@ BOOL StartCreditScript();
void ActionCredit();
void SetCreditIllust(int a);
void CutCreditIllust();
int Scene_DownIsland(int hWnd, int mode);
int Scene_DownIsland(HWND hWnd, int mode);

View file

@ -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};

View file

@ -1,3 +1,5 @@
#pragma once
int Call_Escape(int hWnd);
#include "WindowsWrapper.h"
int Call_Escape(HWND hWnd);

View file

@ -31,7 +31,7 @@ char gDataPath[PATH_LENGTH];
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;

View file

@ -1,6 +1,8 @@
#pragma once
extern int ghWnd;
#include "WindowsWrapper.h"
extern HWND ghWnd;
void PutFramePerSecound();
int GetFramePerSecound();

View file

@ -201,14 +201,14 @@ void PutMyChar(int fx, int fy)
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);
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 @@ void PutMyChar(int fx, int fy)
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] = {

View file

@ -21,8 +21,20 @@ struct MYCHAR
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;

View file

@ -36,11 +36,11 @@ int JudgeHitMyCharBlock(int x, int y)
// 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 @@ int JudgeHitMyCharBlock(int x, int y)
// 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 @@ int JudgeHitMyCharBlock(int x, int y)
}
// 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 @@ int JudgeHitMyCharBlock(int x, int y)
}
// 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 JudgeHitMyCharWater(int x, int y)
{
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 JudgeHitMyCharDamageW(int x, int y)
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 JudgeHitMyCharVectLeft(int x, int y)
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 JudgeHitMyCharVectUp(int x, int y)
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 JudgeHitMyCharVectRight(int x, int y)
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 @@ int JudgeHitMyCharNPC(NPCHAR *npc)
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,16 +601,16 @@ int JudgeHitMyCharNPC(NPCHAR *npc)
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;
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 @@ int JudgeHitMyCharNPC(NPCHAR *npc)
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 @@ int JudgeHitMyCharNPC4(NPCHAR *npc)
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 @@ int JudgeHitMyCharNPC4(NPCHAR *npc)
{
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;
}

View file

@ -55,8 +55,20 @@ struct NPCHAR
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;

View file

@ -1251,7 +1251,7 @@ int TextScriptProc()
char str_0[0x40];
#ifdef NONPORTABLE
sprintf(str_0, "不明のコード:<%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, "エラー", 0);
MessageBoxA(ghWnd, str_0, "エラー", 0);
#else
#ifdef JAPANESE
sprintf(str_0, "不明のコード:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);

View file

@ -1,7 +1,13 @@
#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;
@ -13,26 +19,22 @@ typedef int BOOL;
#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; \
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();