diff --git a/src/Bullet.h b/src/Bullet.h index 5e08a593..070b4565 100644 --- a/src/Bullet.h +++ b/src/Bullet.h @@ -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 diff --git a/src/Draw.cpp b/src/Draw.cpp index b5834958..602b71fb 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -5,18 +5,6 @@ #endif #include -#ifdef WINDOWS -#define RECT WINRECT -#define FindResource WinFindResource // All these damn name collisions... -#define DrawText WinDrawText -#define LoadFont WinLoadFont -#include -#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; diff --git a/src/Draw.h b/src/Draw.h index 0ee159e7..cfef72b7 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -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); diff --git a/src/Ending.cpp b/src/Ending.cpp index 3ab2cefd..635bf66c 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -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}; diff --git a/src/Ending.h b/src/Ending.h index 04dea864..cbbcc1e7 100644 --- a/src/Ending.h +++ b/src/Ending.h @@ -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); diff --git a/src/Escape.cpp b/src/Escape.cpp index bd7c80d3..fb8cba56 100644 --- 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}; diff --git a/src/Escape.h b/src/Escape.h index d63213c1..508da8c9 100644 --- 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); diff --git a/src/Main.cpp b/src/Main.cpp index ec5c9eb7..6e41ec36 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -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; diff --git a/src/Main.h b/src/Main.h index 4213ccfe..51172956 100644 --- 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(); diff --git a/src/MyChar.cpp b/src/MyChar.cpp index ab7e18c8..c4551183 100644 --- a/src/MyChar.cpp +++ b/src/MyChar.cpp @@ -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] = { diff --git a/src/MyChar.h b/src/MyChar.h index 797a6e92..fb034341 100644 --- a/src/MyChar.h +++ b/src/MyChar.h @@ -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; diff --git a/src/MycHit.cpp b/src/MycHit.cpp index 3e52aa7a..e0aa7209 100644 --- a/src/MycHit.cpp +++ b/src/MycHit.cpp @@ -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; } diff --git a/src/NpChar.h b/src/NpChar.h index b60eed51..3ba59f80 100644 --- a/src/NpChar.h +++ b/src/NpChar.h @@ -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; diff --git a/src/TextScr.cpp b/src/TextScr.cpp index fce73941..5ef9e289 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -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]); diff --git a/src/WindowsWrapper.h b/src/WindowsWrapper.h index 8feb6218..0994a3f2 100644 --- a/src/WindowsWrapper.h +++ b/src/WindowsWrapper.h @@ -1,7 +1,13 @@ #pragma once -int rep_rand(); -void rep_srand(unsigned int seed); +#ifdef NONPORTABLE +#include +// 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();