Merge pull request #68 from Clownacy/master

Just a bunch of stuff (accuracy improvements, code cleanup, portability improvements, etc.)
This commit is contained in:
Cucky 2019-02-19 17:07:16 -05:00 committed by GitHub
commit e7ad5271a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
199 changed files with 2028 additions and 1651 deletions

View file

@ -39,7 +39,10 @@ LIBS += `sdl2-config --static-libs` `pkg-config freetype2 --libs`
ifeq ($(STATIC), 1)
CXXFLAGS += -static
LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2 -lRpcrt4 -lDwrite -lusp10
LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2
ifeq ($(WINDOWS), 1)
LIBS += -lRpcrt4 -lDwrite -lusp10
endif
endif
# For an accurate result to the original's code, compile in alphabetical order
@ -65,6 +68,7 @@ SOURCES = \
Ending \
Escape \
Fade \
File \
Flags \
Flash \
Font \
@ -135,48 +139,48 @@ RESOURCES = \
BITMAP/CREDIT18.bmp \
CURSOR/CURSOR_IKA.bmp \
CURSOR/CURSOR_NORMAL.bmp \
ORG/ACCESS \
ORG/ANZEN \
ORG/BALCONY \
ORG/BALLOS \
ORG/BDOWN \
ORG/CEMETERY \
ORG/CURLY \
ORG/DR \
ORG/ENDING \
ORG/ESCAPE \
ORG/FANFALE1 \
ORG/FANFALE2 \
ORG/FANFALE3 \
ORG/FIREEYE \
ORG/GAMEOVER \
ORG/GINSUKE \
ORG/GRAND \
ORG/GRAVITY \
ORG/HELL \
ORG/IRONH \
ORG/JENKA \
ORG/JENKA2 \
ORG/KODOU \
ORG/LASTBT3 \
ORG/LASTBTL \
ORG/LASTCAVE \
ORG/MARINE \
ORG/MAZE \
ORG/MDOWN2 \
ORG/MURA \
ORG/OSIDE \
ORG/PLANT \
ORG/QUIET \
ORG/REQUIEM \
ORG/TOROKO \
ORG/VIVI \
ORG/WANPAK2 \
ORG/WANPAKU \
ORG/WEED \
ORG/WHITE \
ORG/XXXX \
ORG/ZONBIE \
ORG/ACCESS.org \
ORG/ANZEN.org \
ORG/BALCONY.org \
ORG/BALLOS.org \
ORG/BDOWN.org \
ORG/CEMETERY.org \
ORG/CURLY.org \
ORG/DR.org \
ORG/ENDING.org \
ORG/ESCAPE.org \
ORG/FANFALE1.org \
ORG/FANFALE2.org \
ORG/FANFALE3.org \
ORG/FIREEYE.org \
ORG/GAMEOVER.org \
ORG/GINSUKE.org \
ORG/GRAND.org \
ORG/GRAVITY.org \
ORG/HELL.org \
ORG/IRONH.org \
ORG/JENKA.org \
ORG/JENKA2.org \
ORG/KODOU.org \
ORG/LASTBT3.org \
ORG/LASTBTL.org \
ORG/LASTCAVE.org \
ORG/MARINE.org \
ORG/MAZE.org \
ORG/MDOWN2.org \
ORG/MURA.org \
ORG/OSIDE.org \
ORG/PLANT.org \
ORG/QUIET.org \
ORG/REQUIEM.org \
ORG/TOROKO.org \
ORG/VIVI.org \
ORG/WANPAK2.org \
ORG/WANPAKU.org \
ORG/WEED.org \
ORG/WHITE.org \
ORG/XXXX.org \
ORG/ZONBIE.org \
WAVE/WAVE100
ifeq ($(JAPANESE), 1)

Binary file not shown.

View file

@ -1,15 +1,18 @@
#include "ArmsItem.h"
#include <string.h>
#include "WindowsWrapper.h"
#include "CommonDefines.h"
#include "TextScr.h"
#include "ArmsItem.h"
#include "Draw.h"
#include "KeyControl.h"
#include "Escape.h"
#include "Sound.h"
#include "Main.h"
#include "Game.h"
#include "KeyControl.h"
#include "Main.h"
#include "Shoot.h"
#include "Sound.h"
#include "TextScr.h"
int gArmsEnergyX = 16;
@ -18,7 +21,7 @@ ITEM gItemData[ITEM_MAX];
int gSelectedArms;
int gSelectedItem;
int gCampTitleY;
bool gCampActive;
BOOL gCampActive;
void ClearArmsData()
{
@ -31,106 +34,122 @@ void ClearItemData()
memset(gItemData, 0, sizeof(gItemData));
}
bool AddArmsData(int code, int max_num)
BOOL AddArmsData(long code, long max_num)
{
for (int i = 0; i < ARMS_MAX; i++)
{
if (gArmsData[i].code == code || !gArmsData[i].code)
{
if (!gArmsData[i].code)
{
memset(&gArmsData[i], 0, sizeof(ARMS));
gArmsData[i].level = 1;
}
gArmsData[i].code = code;
gArmsData[i].max_num += max_num;
gArmsData[i].num += max_num;
if (gArmsData[i].num > gArmsData[i].max_num)
gArmsData[i].num = gArmsData[i].max_num;
return true;
}
}
return false;
}
bool SubArmsData(int code)
{
for (int i = 0; i < ARMS_MAX; i++)
int i = 0;
for (;i < ARMS_MAX;)
{
if (gArmsData[i].code == code)
{
//Shift all arms from the right to the left
int ia;
for (ia = i + 1; ia < ARMS_MAX; ++ia)
{
gArmsData[ia - 1].code = gArmsData[ia].code;
gArmsData[ia - 1].level = gArmsData[ia].level;
gArmsData[ia - 1].exp = gArmsData[ia].exp;
gArmsData[ia - 1].max_num = gArmsData[ia].max_num;
gArmsData[ia - 1].num = gArmsData[ia].num;
}
gArmsData[ia - 1].code = 0;
gSelectedArms = 0;
return true;
}
break;
if (gArmsData[i].code == 0)
break;
++i;
}
if (i == ARMS_MAX)
return FALSE;
if (gArmsData[i].code == 0)
{
memset(&gArmsData[i], 0, sizeof(ARMS));
gArmsData[i].level = 1;
}
return false;
gArmsData[i].code = code;
gArmsData[i].max_num += max_num;
gArmsData[i].num += max_num;
if (gArmsData[i].num > gArmsData[i].max_num)
gArmsData[i].num = gArmsData[i].max_num;
return TRUE;
}
bool TradeArms(int code1, int code2, int max_num)
BOOL SubArmsData(long code)
{
for (int i = 0; i < ARMS_MAX; i++)
int i = 0;
for (;i < ARMS_MAX; ++i)
if (gArmsData[i].code == code)
break;
#ifdef FIX_BUGS
if (i == ARMS_MAX)
#else
if (i == ITEM_MAX) // Oops
#endif
return FALSE;
//Shift all arms from the right to the left
for (i += 1; i < ARMS_MAX; ++i)
gArmsData[i - 1] = gArmsData[i];
gArmsData[i - 1].code = 0;
gSelectedArms = 0;
return TRUE;
}
BOOL TradeArms(long code1, long code2, long max_num)
{
int i = 0;
for (;i < ARMS_MAX;)
{
if (gArmsData[i].code == code1)
{
gArmsData[i].level = 1;
gArmsData[i].code = code2;
gArmsData[i].max_num += max_num;
gArmsData[i].num += max_num;
gArmsData[i].exp = 0;
return true;
}
break;
++i;
}
return false;
if (i == ARMS_MAX)
return FALSE;
gArmsData[i].level = 1;
gArmsData[i].code = code2;
gArmsData[i].max_num += max_num;
gArmsData[i].num += max_num;
gArmsData[i].exp = 0;
return TRUE;
}
bool AddItemData(int code)
BOOL AddItemData(long code)
{
for (int i = 0; i < ITEM_MAX; i++)
{
if (gItemData[i].code == code || !gItemData[i].code)
{
gItemData[i].code = code;
return true;
}
}
return false;
}
bool SubItemData(int code)
{
for (int i = 0; i < ITEM_MAX; i++)
int i = 0;
for (;i < ITEM_MAX;)
{
if (gItemData[i].code == code)
{
//Shift all items from the right to the left
int ia;
for (ia = i + 1; ia < ITEM_MAX; ++ia)
gItemData[ia - 1].code = gItemData[ia].code;
gItemData[ia - 1].code = 0;
gSelectedItem = 0;
return true;
}
break;
if (gItemData[i].code == 0)
break;
++i;
}
return false;
if (i == ITEM_MAX)
return false;
gItemData[i].code = code;
return true;
}
BOOL SubItemData(long code)
{
int i = 0;
for (;i < ITEM_MAX; ++i)
if (gItemData[i].code == code)
break;
if (i == ITEM_MAX)
return FALSE;
//Shift all items from the right to the left
for (i += 1; i < ITEM_MAX; ++i)
gItemData[i - 1] = gItemData[i];
gItemData[i - 1].code = 0;
gSelectedItem = 0;
return TRUE;
}
void MoveCampCursor()
@ -142,104 +161,107 @@ void MoveCampCursor()
while ( gItemData[item_num].code != 0 )
++item_num;
if (arms_num || item_num)
if (arms_num == 0 && item_num == 0)
return;
BOOL bChange = FALSE;
if (gCampActive == FALSE)
{
bool bChange = false;
if (gCampActive)
if (gKeyTrg & gKeyLeft)
{
if (gKeyTrg & gKeyLeft)
{
if (gSelectedItem % 6)
--gSelectedItem;
else
gSelectedItem += 5;
bChange = true;
}
--gSelectedArms;
bChange = TRUE;
}
if (gKeyTrg & gKeyRight)
{
++gSelectedArms;
bChange = TRUE;
}
if ((gKeyDown | gKeyUp) & gKeyTrg)
{
if (item_num)
gCampActive = TRUE;
bChange = TRUE;
}
if (gSelectedArms < 0)
gSelectedArms = arms_num - 1;
if (gSelectedArms > arms_num - 1)
gSelectedArms = 0;
}
else
{
if (gKeyTrg & gKeyLeft)
{
if (gSelectedItem % 6 == 0)
gSelectedItem += 5;
else
--gSelectedItem;
if (gKeyTrg & gKeyRight)
bChange = TRUE;
}
if (gKeyTrg & gKeyRight)
{
if (gSelectedItem == item_num - 1)
gSelectedItem = 6 * (gSelectedItem / 6);
else
{
if (item_num - 1 == gSelectedItem)
gSelectedItem = 6 * (gSelectedItem / 6);
else if (gSelectedItem % 6 == 5)
if (gSelectedItem % 6 == 5)
gSelectedItem -= 5;
else
++gSelectedItem;
bChange = true;
}
bChange = TRUE;
}
if (gKeyTrg & gKeyUp)
{
if (gSelectedItem / 6 == 0)
gCampActive = FALSE;
else
gSelectedItem -= 6;
if (gKeyTrg & gKeyUp)
{
if (gSelectedItem + 5 > 10)
gSelectedItem -= 6;
else
gCampActive = false;
bChange = true;
}
bChange = TRUE;
}
if ( gKeyTrg & gKeyDown )
{
if ( gSelectedItem / 6 == (item_num - 1) / 6 )
gCampActive = FALSE;
else
gSelectedItem += 6;
if ( gKeyTrg & gKeyDown )
{
if ( gSelectedItem / 6 == (item_num - 1) / 6 )
gCampActive = false;
else
gSelectedItem += 6;
bChange = true;
}
bChange = TRUE;
}
if (gSelectedItem >= item_num)
gSelectedItem = item_num - 1;
if (gCampActive && gKeyTrg & gKeyOk)
StartTextScript(gItemData[gSelectedItem].code + 6000);
}
if (bChange)
{
if (gCampActive == FALSE)
{
PlaySoundObject(4, 1);
if (gSelectedItem >= item_num)
gSelectedItem = item_num - 1;
if (gCampActive && gKeyTrg & gKeyOk)
StartTextScript(gItemData[gSelectedItem].code + 6000);
if (arms_num)
StartTextScript(gArmsData[gSelectedArms].code + 1000);
else
StartTextScript(1000);
}
else
{
if (gKeyTrg & gKeyLeft)
{
--gSelectedArms;
bChange = true;
}
if (gKeyTrg & gKeyRight)
{
++gSelectedArms;
bChange = true;
}
if ((gKeyDown | gKeyUp) & gKeyTrg)
{
if (item_num)
gCampActive = true;
bChange = true;
}
PlaySoundObject(1, 1);
if (gSelectedArms < 0)
gSelectedArms = arms_num - 1;
if (arms_num - 1 < gSelectedArms)
gSelectedArms = 0;
}
if (bChange)
{
if (gCampActive)
{
PlaySoundObject(1, 1);
if (item_num)
StartTextScript(gItemData[gSelectedItem].code + 5000);
else
StartTextScript(5000);
}
if (item_num)
StartTextScript(gItemData[gSelectedItem].code + 5000);
else
{
PlaySoundObject(4, 1);
if (arms_num)
StartTextScript(gArmsData[gSelectedArms].code + 1000);
else
StartTextScript(1000);
}
StartTextScript(5000);
}
}
}
@ -251,12 +273,8 @@ void PutCampObject()
RECT rcNone = {80, 48, 96, 56};
RECT rcLv = {80, 80, 96, 88};
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
RECT rcCur1[2];
RECT rcCur2[2];
rcCur1[0] = {0, 88, 40, 128};
rcCur1[1] = {40, 88, 80, 128};
rcCur2[0] = {80, 88, 112, 104};
rcCur2[1] = {80, 104, 112, 120};
RECT rcCur1[2] = {{0, 88, 40, 128}, {40, 88, 80, 128}};
RECT rcCur2[2] = {{80, 88, 112, 104}, {80, 104, 112, 120}};
RECT rcTitle1 = {80, 48, 144, 56};
RECT rcTitle2 = {80, 56, 144, 64};
RECT rcBoxTop = {0, 0, 244, 8};
@ -265,40 +283,43 @@ void PutCampObject()
//Draw box
int y;
PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, (WINDOW_HEIGHT - 224) / 2, &rcBoxTop, 26);
PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, (WINDOW_HEIGHT - 224) / 2, &rcBoxTop, SURFACE_ID_TEXT_BOX);
for (y = 1; y < 18; y++)
PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, ((WINDOW_HEIGHT - 240) / 2) + (8 * (y + 1)), &rcBoxBody, 26);
PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, ((WINDOW_HEIGHT - 240) / 2) + (8 * (y + 1)), &rcBoxBottom, 26);
PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, ((WINDOW_HEIGHT - 240) / 2) + (8 * (y + 1)), &rcBoxBody, SURFACE_ID_TEXT_BOX);
PutBitmap3(&rcView, (WINDOW_WIDTH - 244) / 2, ((WINDOW_HEIGHT - 240) / 2) + (8 * (y + 1)), &rcBoxBottom, SURFACE_ID_TEXT_BOX);
//Move titles
if (gCampTitleY > (WINDOW_HEIGHT - 208) / 2)
--gCampTitleY;
//Draw titles
PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY, &rcTitle1, 26);
PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY + 52, &rcTitle2, 26);
PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY, &rcTitle1, SURFACE_ID_TEXT_BOX);
PutBitmap3(&rcView, (WINDOW_WIDTH - 224) / 2, gCampTitleY + 52, &rcTitle2, SURFACE_ID_TEXT_BOX);
//Draw arms cursor
static int flash;
static unsigned int flash;
++flash;
if (gCampActive)
PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[1], 26);
if (gCampActive == FALSE)
PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[(flash / 2) % 2], SURFACE_ID_TEXT_BOX);
else
PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[(flash >> 1) & 1], 26);
PutBitmap3(&rcView, 40 * gSelectedArms + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT / 2) - 96, &rcCur1[1], SURFACE_ID_TEXT_BOX);
//Draw arms
for (int i = 0; i < ARMS_MAX && gArmsData[i].code; i++)
for (int i = 0; i < ARMS_MAX; i++)
{
if (gArmsData[i].code == 0)
break;
RECT rcArms;
rcArms.left = 16 * (gArmsData[i].code % 16);
rcArms.right = rcArms.left + 16;
rcArms.top = 16 * (gArmsData[i].code / 16);
rcArms.bottom = rcArms.top + 16;
PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 192) / 2, &rcArms, 12);
PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 128) / 2, &rcPer, 26);
PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 160) / 2, &rcLv, 26);
PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 192) / 2, &rcArms, SURFACE_ID_ARMS_IMAGE);
PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 128) / 2, &rcPer, SURFACE_ID_TEXT_BOX);
PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 160) / 2, &rcLv, SURFACE_ID_TEXT_BOX);
PutNumber4(40 * i + (WINDOW_WIDTH - 224) / 2, (WINDOW_HEIGHT - 160) / 2, gArmsData[i].level, 0);
//Draw ammo
@ -309,26 +330,29 @@ void PutCampObject()
}
else
{
PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT - 144) / 2, &rcNone, 26);
PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT - 128) / 2, &rcNone, 26);
PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT - 144) / 2, &rcNone, SURFACE_ID_TEXT_BOX);
PutBitmap3(&rcView, 40 * i + (WINDOW_WIDTH - 192) / 2, (WINDOW_HEIGHT - 128) / 2, &rcNone, SURFACE_ID_TEXT_BOX);
}
}
//Draw items cursor
if (gCampActive)
PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[(flash >> 1) & 1], 26);
if (gCampActive == TRUE)
PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[(flash / 2) % 2], SURFACE_ID_TEXT_BOX);
else
PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[1], 26);
PutBitmap3(&rcView, 32 * (gSelectedItem % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (gSelectedItem / 6) + (WINDOW_HEIGHT - 88) / 2, &rcCur2[1], SURFACE_ID_TEXT_BOX);
for (int i = 0; i < ITEM_MAX && gItemData[i].code; i++)
for (int i = 0; i < ITEM_MAX; i++)
{
if (gItemData[i].code == 0)
break;
RECT rcItem;
rcItem.left = 32 * (gItemData[i].code % 8);
rcItem.right = rcItem.left + 32;
rcItem.top = 16 * (gItemData[i].code / 8);
rcItem.bottom = rcItem.top + 16;
PutBitmap3(&rcView, 32 * (i % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (i / 6) + (WINDOW_HEIGHT - 88) / 2, &rcItem, 8);
PutBitmap3(&rcView, 32 * (i % 6) + (WINDOW_WIDTH - 224) / 2, 16 * (i / 6) + (WINDOW_HEIGHT - 88) / 2, &rcItem, SURFACE_ID_ITEM_IMAGE);
}
}
@ -340,24 +364,23 @@ int CampLoop()
char old_script_path[PATH_LENGTH];
GetTextScriptPath(old_script_path);
char name[13];
strcpy(name, "ArmsItem.tsc");
LoadTextScript2(name);
LoadTextScript2("ArmsItem.tsc");
gCampTitleY = (WINDOW_HEIGHT - 192) / 2;
gCampActive = 0;
gSelectedItem = 0;
//Run script
int arms_num;
for (arms_num = 0; gArmsData[arms_num].code != 0; arms_num++);
int arms_num = 0;
for (;gArmsData[arms_num].code != 0;)
++arms_num;
if (arms_num)
StartTextScript(gArmsData[gSelectedArms].code + 1000);
else
StartTextScript(gItemData[gSelectedItem].code + 5000);
while (true)
for (;;)
{
GetTrg();
@ -383,113 +406,141 @@ int CampLoop()
return 2;
}
PutBitmap4(&rcView, 0, 0, &rcView, 10);
PutBitmap4(&rcView, 0, 0, &rcView, SURFACE_ID_SCREEN_GRAB);
PutCampObject();
PutTextScript();
PutFramePerSecound();
if (!gCampActive && (gKeyItem | gKeyCancel | gKeyOk) & gKeyTrg)
break;
else if (g_GameFlags & 2 && (gKeyItem | gKeyCancel) & gKeyTrg)
break;
if (gCampActive)
{
if (g_GameFlags & 2 && (gKeyCancel | gKeyItem) & gKeyTrg)
{
StopTextScript();
break;
}
}
else
{
if ((gKeyCancel | gKeyOk | gKeyItem) & gKeyTrg)
{
StopTextScript();
break;
}
}
if (!Flip_SystemTask())
return 0;
}
//Resume original script
StopTextScript();
LoadTextScript_Stage(old_script_path);
gArmsEnergyX = 32;
return 1;
}
bool CheckItem(int a)
BOOL CheckItem(long a)
{
for (int i = 0; i < ITEM_MAX; i++)
{
if (gItemData[i].code == a)
return true;
return TRUE;
}
return false;
return FALSE;
}
bool CheckArms(int a)
BOOL CheckArms(long a)
{
for (int i = 0; i < ARMS_MAX; i++)
for (int i = 0; i < ARMS_MAX; i++)
{
if (gArmsData[i].code == a)
return true;
return TRUE;
}
return false;
return FALSE;
}
bool UseArmsEnergy(int num)
BOOL UseArmsEnergy(long num)
{
if (!gArmsData[gSelectedArms].max_num)
return true;
return TRUE;
if (!gArmsData[gSelectedArms].num)
return false;
return FALSE;
gArmsData[gSelectedArms].num -= num;
if (gArmsData[gSelectedArms].num < 0)
gArmsData[gSelectedArms].num = 0;
return true;
return TRUE;
}
bool ChargeArmsEnergy(int num)
BOOL ChargeArmsEnergy(long num)
{
gArmsData[gSelectedArms].num += num;
if (gArmsData[gSelectedArms].num > gArmsData[gSelectedArms].max_num)
gArmsData[gSelectedArms].num = gArmsData[gSelectedArms].max_num;
return true;
return TRUE;
}
void FullArmsEnergy()
{
for (int a = 0; a < ARMS_MAX; a++)
{
if (gArmsData[a].code)
gArmsData[a].num = gArmsData[a].max_num;
if (gArmsData[a].code == 0)
continue;
gArmsData[a].num = gArmsData[a].max_num;
}
}
int RotationArms()
{
int arms_num;
for ( arms_num = 0; gArmsData[arms_num].code != 0; arms_num++);
if (!arms_num)
int arms_num = 0;
for (;gArmsData[arms_num].code != 0;)
++arms_num;
if (arms_num == 0)
return 0;
ResetSpurCharge();
++gSelectedArms;
while (gSelectedArms < arms_num && !gArmsData[gSelectedArms].code)
while (gSelectedArms < arms_num)
{
if (gArmsData[gSelectedArms].code)
break;
++gSelectedArms;
}
if (gSelectedArms == arms_num)
gSelectedArms = 0;
gArmsEnergyX = 32;
PlaySoundObject(4, 1);
return gArmsData[gSelectedArms].code;
}
int RotationArmsRev()
{
int arms_num;
for (arms_num = 0; gArmsData[arms_num].code != 0; arms_num++);
if (!arms_num)
int arms_num = 0;
for (;gArmsData[arms_num].code != 0;)
++arms_num;
if (arms_num == 0)
return 0;
ResetSpurCharge();
if (--gSelectedArms < 0)
gSelectedArms = arms_num - 1;
while (gSelectedArms < arms_num && !gArmsData[gSelectedArms].code)
while (gSelectedArms < arms_num)
{
if (gArmsData[gSelectedArms].code)
break;
--gSelectedArms;
}
gArmsEnergyX = 0;
PlaySoundObject(4, 1);

View file

@ -1,4 +1,7 @@
#pragma once
#include "WindowsWrapper.h"
struct ARMS
{
int code;
@ -26,20 +29,20 @@ extern ITEM gItemData[ITEM_MAX];
extern int gSelectedArms;
extern int gSelectedItem;
extern int gCampTitleY;
extern bool gCampActive;
extern BOOL gCampActive;
void ClearArmsData();
void ClearItemData();
bool AddArmsData(int code, int max_num);
bool SubArmsData(int code);
bool TradeArms(int code1, int code2, int max_num);
bool AddItemData(int code);
bool SubItemData(int code);
BOOL AddArmsData(long code, long max_num);
BOOL SubArmsData(long code);
BOOL TradeArms(long code1, long code2, long max_num);
BOOL AddItemData(long code);
BOOL SubItemData(long code);
int CampLoop();
bool CheckItem(int a);
bool CheckArms(int a);
bool UseArmsEnergy(int num);
bool ChargeArmsEnergy(int num);
BOOL CheckItem(long a);
BOOL CheckArms(long a);
BOOL UseArmsEnergy(long num);
BOOL ChargeArmsEnergy(long num);
void FullArmsEnergy();
int RotationArms();
int RotationArmsRev();

View file

@ -1,51 +1,89 @@
#include <SDL_rwops.h>
#include "Back.h"
#include <stdio.h>
#include "WindowsWrapper.h"
#include "Tags.h"
#include "Back.h"
#include "Draw.h"
#include "File.h"
#include "Frame.h"
#include "Game.h"
#include "Draw.h"
#include "Stage.h"
#include "Map.h"
#include "Stage.h"
#include "Tags.h"
BACK gBack;
int gWaterY;
bool InitBack(char *fName, int type)
BOOL InitBack(const char *fName, int type)
{
//Get width and height
char path[PATH_LENGTH];
sprintf(path, "%s/%s.pbm", gDataPath, fName);
SDL_Surface *temp = SDL_LoadBMP(path);
if (!temp)
return false;
gBack.partsW = temp->w;
gBack.partsH = temp->h;
SDL_FreeSurface(temp);
FILE *fp = fopen(path, "rb");
if (fp == NULL)
{
sprintf(path, "%s/%s.bmp", gDataPath, fName);
fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
}
#ifdef FIX_BUGS // TODO: Maybe we need a 'BETTER_PORTABILITY' flag
if (fgetc(fp) != 'B' || fgetc(fp) != 'M')
{
fclose(fp);
return FALSE;
}
fseek(fp, 18, SEEK_SET);
gBack.partsW = File_ReadLE32(fp);
gBack.partsH = File_ReadLE32(fp);
fclose(fp);
#else
// This is ridiculously platform-dependant:
// It should break on big-endian CPUs, and platforms
// where short isn't 16-bit and long isn't 32-bit.
short bmp_header_buffer[7];
long bmp_header_buffer2[10];
fread(bmp_header_buffer, 14, 1, fp);
// Check if this is a valid bitmap file
if (bmp_header_buffer[0] != 0x4D42) // 'MB' (we use hex to prevent a compiler warning)
return FALSE; // The original game forgets to close fp
fread(bmp_header_buffer2, 40, 1, fp);
fclose(fp);
gBack.partsW = bmp_header_buffer2[1];
gBack.partsH = bmp_header_buffer2[2];
#endif
//Set background stuff and load texture
gBack.flag = 1;
if (!ReloadBitmap_File(fName, SURFACE_ID_LEVEL_BACKGROUND))
return false;
return FALSE;
gBack.type = type;
gWaterY = 0x1E0000;
return true;
return TRUE;
}
void ActBack()
{
if (gBack.type == 5)
switch (gBack.type)
{
gBack.fx += 0xC00;
}
else if (gBack.type >= 5 && gBack.type <= 7)
{
++gBack.fx;
gBack.fx %= 640;
case 5:
gBack.fx += 0xC00;
break;
case 6:
case 7:
++gBack.fx;
gBack.fx %= 640;
break;
}
}
@ -160,35 +198,35 @@ void PutBack(int fx, int fy)
void PutFront(int fx, int fy)
{
RECT rcWater[2];
rcWater[0] = {0, 0, 32, 16};
rcWater[1] = {0, 16, 32, 48};
RECT rcWater[2] = {{0, 0, 32, 16}, {0, 16, 32, 48}};
if (gBack.type == 3)
switch (gBack.type)
{
int x_1 = fx / 0x4000;
int x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1);
int y_1 = 0;
int y_2 = y_1 + 32;
for (int y = y_1; y < y_2; y++)
{
int ypos = (y << 14) / 0x200 - fy / 0x200 + gWaterY / 0x200;
case 3:
int x_1 = fx / 0x4000;
int x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1);
int y_1 = 0;
int y_2 = y_1 + 32;
if (ypos >= -32)
for (int y = y_1; y < y_2; y++)
{
int ypos = (y * 0x20 * 0x200) / 0x200 - fy / 0x200 + gWaterY / 0x200;
if (ypos < -32)
break;
if (ypos > WINDOW_HEIGHT)
break;
for (int x = x_1; x < x_2; x++)
{
int xpos = (x << 14) / 0x200 - fx / 0x200;
int xpos = (x * 0x20 * 0x200) / 0x200 - fx / 0x200;
PutBitmap3(&grcGame, xpos, ypos, &rcWater[1], SURFACE_ID_LEVEL_BACKGROUND);
if (!y)
PutBitmap3(&grcGame, xpos, ypos, rcWater, SURFACE_ID_LEVEL_BACKGROUND);
}
}
}
}
//Draw black bars

View file

@ -1,5 +1,7 @@
#pragma once
#include "WindowsWrapper.h"
struct BACK
{
int flag;
@ -14,7 +16,7 @@ struct BACK
extern BACK gBack;
extern int gWaterY;
bool InitBack(char *fName, int type);
BOOL InitBack(const char *fName, int type);
void ActBack();
void PutBack(int fx, int fy);
void PutFront(int fx, int fy);

View file

@ -1,9 +1,10 @@
#include "Boss.h"
#include <stdint.h>
#include <string.h>
#include "WindowsWrapper.h"
#include "Boss.h"
#include "BossAlmo1.h"
#include "BossAlmo2.h"
#include "BossBallos.h"
@ -13,16 +14,16 @@
#include "BossPress.h"
#include "BossTwinD.h"
#include "BossX.h"
#include "NpChar.h"
#include "MyChar.h"
#include "Sound.h"
#include "NpcHit.h"
#include "Bullet.h"
#include "Caret.h"
#include "TextScr.h"
#include "ValueView.h"
#include "Draw.h"
#include "Map.h"
#include "Bullet.h"
#include "MyChar.h"
#include "NpChar.h"
#include "NpcHit.h"
#include "Sound.h"
#include "TextScr.h"
#include "ValueView.h"
NPCHAR gBoss[BOSS_MAX];
@ -66,7 +67,7 @@ void PutBossChar(int fx, int fy)
(gBoss[b].x - side) / 0x200 - fx / 0x200 + a,
(gBoss[b].y - gBoss[b].view.top) / 0x200 - fy / 0x200,
&gBoss[b].rect,
22);
SURFACE_ID_LEVEL_SPRITESET_2);
}
}
}
@ -208,8 +209,7 @@ void ActBossChar()
{
if (gBoss[0].cond & 0x80)
{
if (gpBossFuncTbl[gBoss[0].code_char] != nullptr)
gpBossFuncTbl[gBoss[0].code_char]();
gpBossFuncTbl[gBoss[0].code_char]();
for (int bos = 0; bos < BOSS_MAX; bos++)
{

View file

@ -1,4 +1,5 @@
#pragma once
#include "NpChar.h"
#define BOSS_MAX 20

View file

@ -1,5 +1,7 @@
#include "BossAlmo1.h"
#include "WindowsWrapper.h"
#include "Boss.h"
#include "Frame.h"
#include "Game.h"

View file

@ -1,5 +1,7 @@
#include "BossAlmo2.h"
#include "WindowsWrapper.h"
#include "Boss.h"
#include "Flash.h"
#include "Frame.h"
@ -9,7 +11,6 @@
#include "NpChar.h"
#include "Sound.h"
#include "Triangle.h"
#include "WindowsWrapper.h"
static void ActBossCharA_Head(NPCHAR *npc)
{

View file

@ -1,5 +1,7 @@
#include "BossBallos.h"
#include "WindowsWrapper.h"
#include "Boss.h"
#include "Flash.h"
#include "Frame.h"

View file

@ -1,5 +1,7 @@
#include "BossFrog.h"
#include "WindowsWrapper.h"
#include "Boss.h"
#include "Frame.h"
#include "Game.h"
@ -7,7 +9,6 @@
#include "NpChar.h"
#include "Sound.h"
#include "Triangle.h"
#include "WindowsWrapper.h"
static void ActBossChar02_01(void)
{

View file

@ -1,11 +1,12 @@
#include "BossIronH.h"
#include "WindowsWrapper.h"
#include "Boss.h"
#include "Frame.h"
#include "Game.h"
#include "MyChar.h"
#include "Sound.h"
#include "WindowsWrapper.h"
void ActBossChar_Ironhead(void)
{

View file

@ -1,10 +1,11 @@
#include "BossLife.h"
#include "WindowsWrapper.h"
#include "CommonDefines.h"
#include "BossLife.h"
#include "Boss.h"
#include "Draw.h"
#include "NpChar.h"
#include "Boss.h"
static struct
{

View file

@ -1,15 +1,17 @@
#include "BossOhm.h"
#include <string.h>
#include "WindowsWrapper.h"
#include "Boss.h"
#include "NpChar.h"
#include "MyChar.h"
#include "Sound.h"
#include "Frame.h"
#include "Bullet.h"
#include "Flash.h"
#include "Frame.h"
#include "Game.h"
#include "MyChar.h"
#include "NpChar.h"
#include "Sound.h"
void ActBoss01_12()
{

View file

@ -1,2 +1,3 @@
#pragma once
void ActBossChar_Omega();

View file

@ -1,10 +1,11 @@
#include "BossPress.h"
#include "WindowsWrapper.h"
#include "Boss.h"
#include "Game.h"
#include "Map.h"
#include "Sound.h"
#include "WindowsWrapper.h"
void ActBossChar_Press(void)
{

View file

@ -1,5 +1,7 @@
#include "BossTwinD.h"
#include "WindowsWrapper.h"
#include "Boss.h"
#include "Flash.h"
#include "Game.h"
@ -7,7 +9,6 @@
#include "NpChar.h"
#include "Sound.h"
#include "Triangle.h"
#include "WindowsWrapper.h"
static void ActBossCharT_DragonBody(NPCHAR *npc)
{

View file

@ -1,5 +1,7 @@
#include "BossX.h"
#include "WindowsWrapper.h"
#include "Boss.h"
#include "Flash.h"
#include "Frame.h"
@ -8,7 +10,6 @@
#include "NpChar.h"
#include "Sound.h"
#include "Triangle.h"
#include "WindowsWrapper.h"
static void ActBossChar03_01(NPCHAR *npc)
{

View file

@ -1,13 +1,15 @@
#include "BulHit.h"
#include <stdio.h>
#include <string.h>
#include "Bullet.h"
#include "NpChar.h"
#include "Caret.h"
#include "Sound.h"
#include "MyChar.h"
#include "Game.h"
#include "Map.h"
#include "MyChar.h"
#include "NpChar.h"
#include "Sound.h"
void Vanish(BULLET *bul)
{

View file

@ -1,2 +1,3 @@
#pragma once
void HitBulletMap();

View file

@ -1,11 +1,14 @@
#include "Bullet.h"
#include <string.h>
#include "Draw.h"
#include "Caret.h"
#include "NpChar.h"
#include "MyChar.h"
#include "Sound.h"
#include "Game.h"
#include "KeyControl.h"
#include "MyChar.h"
#include "NpChar.h"
#include "Sound.h"
BULLET_TABLE gBulTbl[46] =
{
@ -135,7 +138,7 @@ void PutBullet(int fx, int fy)
break;
}
PutBitmap3(&grcGame, x / 0x200 - fx / 0x200, y / 0x200 - fy / 0x200, &gBul[i].rect, 17);
PutBitmap3(&grcGame, x / 0x200 - fx / 0x200, y / 0x200 - fy / 0x200, &gBul[i].rect, SURFACE_ID_BULLET);
}
}
}

View file

@ -1,5 +1,7 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
struct BULLET

View file

@ -1,11 +1,12 @@
#include <string>
#include "Caret.h"
#include <string.h>
#include "WindowsWrapper.h"
#include "Caret.h"
#include "Draw.h"
#include "Triangle.h"
#include "Game.h"
#include "Triangle.h"
#define CARET_MAX 0x40
CARET gCrt[CARET_MAX];
@ -539,7 +540,7 @@ void PutCaret(int fx, int fy)
(gCrt[i].x - gCrt[i].view_left) / 0x200 - fx / 0x200,
(gCrt[i].y - gCrt[i].view_top) / 0x200 - fy / 0x200,
&gCrt[i].rect,
19);
SURFACE_ID_CARET);
}
}
}

View file

@ -1,4 +1,5 @@
#pragma once
#include "WindowsWrapper.h"
struct CARET_TABLE

View file

@ -1,4 +1,5 @@
#pragma once
#define PATH_LENGTH 260 //Pixel had the path size locked to 260 (dangerously low), if you tried to open the executable in a path with more than around 220 characters, it'd crash.
#define WINDOW_WIDTH 320

View file

@ -1,15 +1,15 @@
#include <stddef.h>
#include "Types.h"
#include "CommonDefines.h"
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <SDL_rwops.h>
#include "WindowsWrapper.h"
#include "Tags.h"
#include "CommonDefines.h"
#include "Config.h"
#include "File.h"
#include "Tags.h"
#include "Types.h"
bool LoadConfigData(CONFIG *conf)
{
@ -21,30 +21,30 @@ bool LoadConfigData(CONFIG *conf)
sprintf(path, "%s/%s", gModulePath, "Config.dat");
//Open file
SDL_RWops *fp = SDL_RWFromFile(path, "rb");
if (!fp)
FILE *fp = fopen(path, "rb");
if (fp == NULL)
return false;
//Read data (we're using SDL_RWops so we can load it with the specific endianness expected)
//Read data
//Read the version id and font name
fp->read(fp, conf->proof, sizeof(conf->proof), 1);
fp->read(fp, conf->font_name, sizeof(conf->font_name), 1);
fread(conf->proof, sizeof(conf->proof), 1, fp);
fread(conf->font_name, sizeof(conf->font_name), 1, fp);
//Read control settings
conf->move_button_mode = SDL_ReadLE32(fp);
conf->attack_button_mode = SDL_ReadLE32(fp);
conf->ok_button_mode = SDL_ReadLE32(fp);
conf->move_button_mode = File_ReadLE32(fp);
conf->attack_button_mode = File_ReadLE32(fp);
conf->ok_button_mode = File_ReadLE32(fp);
//Read display mode (320x240, 640x480, 24-bit fullscreen, 32-bit fullscreen) TODO: add more things?
conf->display_mode = SDL_ReadLE32(fp);
conf->display_mode = File_ReadLE32(fp);
//Read joystick configuration (if enabled, and mappings)
conf->bJoystick = SDL_ReadLE32(fp);
conf->bJoystick = File_ReadLE32(fp);
for (int button = 0; button < 8; button++)
conf->joystick_button[button] = SDL_ReadLE32(fp);
conf->joystick_button[button] = File_ReadLE32(fp);
//Close file
fp->close(fp);
fclose(fp);
//Check if version is correct, return that it succeeded
if (!strcmp(conf->proof, "DOUKUTSU20041206"))

View file

@ -1,4 +1,5 @@
#pragma once
#include <stdint.h>
struct CONFIG

View file

@ -1,8 +1,6 @@
#include <stddef.h>
#include "Types.h"
#include "CommonDefines.h"
#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#ifdef WINDOWS
#define RECT WINRECT
@ -22,10 +20,23 @@
#include "WindowsWrapper.h"
#include "CommonDefines.h"
#include "Draw.h"
#include "Font.h"
#include "Tags.h"
#include "Resource.h"
#include "Tags.h"
#include "Types.h"
struct SURFACE
{
bool in_use;
bool needs_updating;
SDL_Surface *surface;
SDL_Texture *texture;
};
SDL_Window *gWindow;
SDL_Renderer *gRenderer;
RECT grcGame = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
@ -39,12 +50,12 @@ FontObject *gFont;
#define FRAMERATE 20
bool Flip_SystemTask()
BOOL Flip_SystemTask()
{
while (true)
{
if (!SystemTask())
return false;
return FALSE;
//Framerate limiter
static uint32_t timePrev;
@ -64,10 +75,10 @@ bool Flip_SystemTask()
}
SDL_RenderPresent(gRenderer);
return true;
return TRUE;
}
bool StartDirectDraw(int lMagnification, int lColourDepth)
BOOL StartDirectDraw(int lMagnification, int lColourDepth)
{
//Initialize rendering
SDL_InitSubSystem(SDL_INIT_VIDEO);
@ -96,7 +107,7 @@ bool StartDirectDraw(int lMagnification, int lColourDepth)
}
return true;
return TRUE;
}
void EndDirectDraw()
@ -133,9 +144,9 @@ void ReleaseSurface(int s)
}
}
bool MakeSurface_Generic(int bxsize, int bysize, int surf_no)
BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no)
{
bool success = false;
BOOL success = FALSE;
#ifdef FIX_BUGS
if (surf_no >= SURFACE_ID_MAX)
@ -155,6 +166,7 @@ bool MakeSurface_Generic(int bxsize, int bysize, int surf_no)
{
//Create surface
surf[surf_no].surface = SDL_CreateRGBSurfaceWithFormat(0, bxsize * magnification, bysize * magnification, 0, SDL_PIXELFORMAT_RGBA32);
SDL_SetSurfaceBlendMode(surf[surf_no].surface, SDL_BLENDMODE_NONE);
if (surf[surf_no].surface == NULL)
{
@ -172,7 +184,7 @@ bool MakeSurface_Generic(int bxsize, int bysize, int surf_no)
else
{
surf[surf_no].in_use = true;
success = true;
success = TRUE;
}
}
}
@ -181,7 +193,7 @@ bool MakeSurface_Generic(int bxsize, int bysize, int surf_no)
return success;
}
static void FlushSurface(int surf_no)
static void FlushSurface(Surface_Ids surf_no)
{
unsigned char *raw_pixels;
int pitch;
@ -208,7 +220,7 @@ static void FlushSurface(int surf_no)
SDL_UnlockTexture(surf[surf_no].texture);
}
static bool LoadBitmap(SDL_RWops *fp, int surf_no, bool create_surface)
static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface)
{
bool success = false;
@ -224,7 +236,7 @@ static bool LoadBitmap(SDL_RWops *fp, int surf_no, bool create_surface)
}
else
{
SDL_Surface *surface = SDL_LoadBMP_RW(fp, 1);
SDL_Surface *surface = SDL_LoadBMP_RW(fp, 0);
if (surface == NULL)
{
@ -238,7 +250,6 @@ static bool LoadBitmap(SDL_RWops *fp, int surf_no, bool create_surface)
{
SDL_Rect dst_rect = {0, 0, surface->w, surface->h};
SDL_BlitSurface(surface, NULL, surf[surf_no].surface, &dst_rect);
SDL_FreeSurface(surface);
surf[surf_no].needs_updating = true;
printf(" ^ Successfully loaded\n");
success = true;
@ -287,10 +298,12 @@ static bool LoadBitmap(SDL_RWops *fp, int surf_no, bool create_surface)
}
}
fp->close(fp);
return success;
}
static bool LoadBitmap_File(const char *name, int surf_no, bool create_surface)
static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_surface)
{
char path[PATH_LENGTH];
SDL_RWops *fp;
@ -303,12 +316,13 @@ static bool LoadBitmap_File(const char *name, int surf_no, bool create_surface)
if (!IsEnableBitmap(fp))
{
printf("Tried to load bitmap to surface %d, but it's missing the '(C)Pixel' string\n", surf_no);
fp->close(fp);
}
else
{
printf("Loading surface (as .pbm) from %s for surface id %d\n", path, surf_no);
if (LoadBitmap(fp, surf_no, create_surface))
return true;
return TRUE;
}
}
@ -319,14 +333,14 @@ static bool LoadBitmap_File(const char *name, int surf_no, bool create_surface)
{
printf("Loading surface (as .bmp) from %s for surface id %d\n", path, surf_no);
if (LoadBitmap(fp, surf_no, create_surface))
return true;
return TRUE;
}
printf("Failed to open file %s\n", name);
return false;
return FALSE;
}
static bool LoadBitmap_Resource(const char *res, int surf_no, bool create_surface)
static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool create_surface)
{
SDL_RWops *fp = FindResource(res);
@ -334,29 +348,29 @@ static bool LoadBitmap_Resource(const char *res, int surf_no, bool create_surfac
{
printf("Loading surface from resource %s for surface id %d\n", res, surf_no);
if (LoadBitmap(fp, surf_no, create_surface))
return true;
return TRUE;
}
printf("Failed to open resource %s\n", res);
return false;
return FALSE;
}
bool MakeSurface_File(const char *name, int surf_no)
BOOL MakeSurface_File(const char *name, Surface_Ids surf_no)
{
return LoadBitmap_File(name, surf_no, true);
}
bool MakeSurface_Resource(const char *res, int surf_no)
BOOL MakeSurface_Resource(const char *res, Surface_Ids surf_no)
{
return LoadBitmap_Resource(res, surf_no, true);
}
bool ReloadBitmap_File(const char *name, int surf_no)
BOOL ReloadBitmap_File(const char *name, Surface_Ids surf_no)
{
return LoadBitmap_File(name, surf_no, false);
}
bool ReloadBitmap_Resource(const char *res, int surf_no)
BOOL ReloadBitmap_Resource(const char *res, Surface_Ids surf_no)
{
return LoadBitmap_Resource(res, surf_no, false);
}
@ -371,7 +385,7 @@ SDL_Rect RectToSDLRect(RECT *rect)
return SDLRect;
}
void BackupSurface(int surf_no, RECT *rect)
void BackupSurface(Surface_Ids surf_no, RECT *rect)
{
//Get renderer size
int w, h;
@ -379,6 +393,7 @@ void BackupSurface(int surf_no, RECT *rect)
//Get texture of what's currently rendered on screen
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, SDL_PIXELFORMAT_RGBA32);
SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
SDL_RenderReadPixels(gRenderer, NULL, SDL_PIXELFORMAT_RGBA32, surface->pixels, surface->pitch);
//Get rects
@ -392,7 +407,7 @@ void BackupSurface(int surf_no, RECT *rect)
SDL_FreeSurface(surface);
}
static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, int surf_no, bool transparent)
static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no, bool transparent)
{
if (surf[surf_no].needs_updating)
{
@ -423,12 +438,12 @@ static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, int surf_no, bool
SDL_RenderSetClipRect(gRenderer, NULL);
}
void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, int surf_no) //Transparency
void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) //Transparency
{
DrawBitmap(rcView, x, y, rect, surf_no, true);
}
void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, int surf_no) //No Transparency
void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no) //No Transparency
{
DrawBitmap(rcView, x, y, rect, surf_no, false);
}
@ -455,7 +470,7 @@ void CortBox(RECT *rect, uint32_t col)
SDL_RenderFillRect(gRenderer, &destRect);
}
void CortBox2(RECT *rect, uint32_t col, int surf_no)
void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no)
{
//Get rect
SDL_Rect destRect = RectToSDLRect(rect);
@ -577,7 +592,7 @@ void PutText(int x, int y, const char *text, uint32_t color)
SDL_DestroyTexture(screen_texture);
}
void PutText2(int x, int y, const char *text, uint32_t color, int surf_no)
void PutText2(int x, int y, const char *text, uint32_t color, Surface_Ids surf_no)
{
DrawText(gFont, surf[surf_no].surface, x * magnification, y * magnification, color, text, strlen(text));
surf[surf_no].needs_updating = true;

View file

@ -1,10 +1,8 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
#include <SDL_render.h>
extern SDL_Window *gWindow;
extern SDL_Renderer *gRenderer;
#include <stdint.h>
#include "WindowsWrapper.h"
extern RECT grcGame;
extern RECT grcFull;
@ -12,63 +10,62 @@ extern RECT grcFull;
extern int magnification;
extern bool fullscreen;
enum Surface_Ids
typedef enum Surface_Ids
{
SURFACE_ID_TITLE = 0x0,
SURFACE_ID_PIXEL = 0x1,
SURFACE_ID_LEVEL_TILESET = 0x2,
SURFACE_ID_FADE = 0x6,
SURFACE_ID_ITEM_IMAGE = 0x8,
SURFACE_ID_MAP = 0x9,
SURFACE_ID_SCREEN_GRAB = 0xA,
SURFACE_ID_ARMS = 0xB,
SURFACE_ID_ARMS_IMAGE = 0xC,
SURFACE_ID_ROOM_NAME = 0xD,
SURFACE_ID_STAGE_ITEM = 0xE,
SURFACE_ID_LOADING = 0xF,
SURFACE_ID_MY_CHAR = 0x10,
SURFACE_ID_BULLET = 0x11,
SURFACE_ID_CARET = 0x13,
SURFACE_ID_NPC_SYM = 0x14,
SURFACE_ID_LEVEL_SPRITESET_1 = 0x15,
SURFACE_ID_LEVEL_SPRITESET_2 = 0x16,
SURFACE_ID_NPC_REGU = 0x17,
SURFACE_ID_TEXT_BOX = 0x1A,
SURFACE_ID_FACE = 0x1B,
SURFACE_ID_LEVEL_BACKGROUND = 0x1C,
SURFACE_ID_CREDIT_CAST = 0x23,
SURFACE_ID_CREDITS_IMAGE = 0x24,
SURFACE_ID_CASTS = 0x25,
SURFACE_ID_MAX = 0x28,
};
SURFACE_ID_TITLE = 0,
SURFACE_ID_PIXEL = 1,
SURFACE_ID_LEVEL_TILESET = 2,
SURFACE_ID_FADE = 6,
SURFACE_ID_ITEM_IMAGE = 8,
SURFACE_ID_MAP = 9,
SURFACE_ID_SCREEN_GRAB = 10,
SURFACE_ID_ARMS = 11,
SURFACE_ID_ARMS_IMAGE = 12,
SURFACE_ID_ROOM_NAME = 13,
SURFACE_ID_STAGE_ITEM = 14,
SURFACE_ID_LOADING = 15,
SURFACE_ID_MY_CHAR = 16,
SURFACE_ID_BULLET = 17,
SURFACE_ID_CARET = 19,
SURFACE_ID_NPC_SYM = 20,
SURFACE_ID_LEVEL_SPRITESET_1 = 21,
SURFACE_ID_LEVEL_SPRITESET_2 = 22,
SURFACE_ID_NPC_REGU = 23,
SURFACE_ID_TEXT_BOX = 26,
SURFACE_ID_FACE = 27,
SURFACE_ID_LEVEL_BACKGROUND = 28,
SURFACE_ID_VALUE_VIEW = 29,
SURFACE_ID_TEXT_LINE1 = 30,
SURFACE_ID_TEXT_LINE2 = 31,
SURFACE_ID_TEXT_LINE3 = 32,
SURFACE_ID_TEXT_LINE4 = 33,
SURFACE_ID_TEXT_LINE5 = 34,
SURFACE_ID_CREDIT_CAST = 35,
SURFACE_ID_CREDITS_IMAGE = 36,
SURFACE_ID_CASTS = 37,
SURFACE_ID_MAX = 40,
} Surface_Ids;
struct SURFACE
{
bool in_use;
bool needs_updating;
SDL_Surface *surface;
SDL_Texture *texture;
};
struct SURFACE;
extern SURFACE surf[SURFACE_ID_MAX];
bool Flip_SystemTask();
bool StartDirectDraw(int lMagnification, int lColourDepth);
BOOL Flip_SystemTask();
BOOL StartDirectDraw(int lMagnification, int lColourDepth);
void EndDirectDraw();
void ReleaseSurface(int s);
bool MakeSurface(SDL_RWops *rw, int surf_no);
bool MakeSurface_File(const char *name, int surf_no);
bool MakeSurface_Resource(const char *res, int surf_no);
bool ReloadBitmap_File(const char *name, int surf_no);
bool ReloadBitmap_Resource(const char *res, int surf_no);
bool MakeSurface_Generic(int bxsize, int bysize, int surf_no);
void BackupSurface(int surf_no, RECT *rect);
void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, int surf_no);
void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, int surf_no);
BOOL MakeSurface_File(const char *name, Surface_Ids surf_no);
BOOL MakeSurface_Resource(const char *res, Surface_Ids surf_no);
BOOL ReloadBitmap_File(const char *name, Surface_Ids surf_no);
BOOL ReloadBitmap_Resource(const char *res, Surface_Ids surf_no);
BOOL MakeSurface_Generic(int bxsize, int bysize, Surface_Ids surf_no);
void BackupSurface(Surface_Ids surf_no, RECT *rect);
void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no);
void PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no);
void Surface2Surface(int x, int y, RECT *rect, int to, int from);
void CortBox(RECT *rect, uint32_t col);
void CortBox2(RECT *rect, uint32_t col, int surf_no);
void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no);
void InitTextObject(const char *font_name);
void PutText(int x, int y, const char *text, uint32_t color);
void PutText2(int x, int y, const char *text, uint32_t color, int surf_no);
void PutText2(int x, int y, const char *text, uint32_t color, Surface_Ids surf_no);
void EndTextObject();

View file

@ -1,21 +1,23 @@
#include <stdint.h>
#include <string>
#include "Ending.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <SDL_rwops.h>
#include "WindowsWrapper.h"
#include "Tags.h"
#include "Generic.h"
#include "Ending.h"
#include "Flags.h"
#include "KeyControl.h"
#include "Escape.h"
#include "Organya.h"
#include "MycParam.h"
#include "Main.h"
#include "Stage.h"
#include "Draw.h"
#include "Escape.h"
#include "Flags.h"
#include "Generic.h"
#include "KeyControl.h"
#include "Main.h"
#include "MycParam.h"
#include "Organya.h"
#include "Stage.h"
#include "TextScr.h"
#include "Tags.h"
CREDIT Credit;
STRIP Strip[MAX_STRIP];
@ -163,25 +165,31 @@ bool StartCreditScript()
//Open file
char path[PATH_LENGTH];
sprintf(path, "%s/%s", gDataPath, "Credit.tsc");
SDL_RWops *fp = SDL_RWFromFile(path, "rb");
if (!fp)
Credit.size = GetFileSizeLong(path);
if (Credit.size == -1)
return false;
//Allcoate buffer data
Credit.pData = (char*)malloc(Credit.size);
if (Credit.pData == NULL)
return false;
FILE *fp = fopen(path, "rb");
if (fp == NULL)
{
printf("Couldn't open %s", path);
return false;
}
//Allcoate buffer data
Credit.size = SDL_RWsize(fp);
Credit.pData = (char*)malloc(Credit.size);
if (!Credit.pData)
return false;
//Read data
SDL_RWread(fp, Credit.pData, 1, Credit.size);
SDL_RWclose(fp);
fread(Credit.pData, 1, Credit.size, fp);
EncryptionBinaryData2((uint8_t*)Credit.pData, Credit.size);
#ifdef FIX_BUGS
// The original game forgot to close the file
fclose(fp);
#endif
//Reset credits
Credit.offset = 0;
@ -192,16 +200,15 @@ bool StartCreditScript()
//Modify cliprect
grcGame.left = WINDOW_WIDTH / 2;
// These three are non-vanilla: for wide/tallscreen support
grcGame.right = ((WINDOW_WIDTH - 320) / 2) + 320;
grcGame.top = (WINDOW_HEIGHT - 240) / 2;
grcGame.bottom = ((WINDOW_HEIGHT - 240) / 2) + 240;
//Reload casts
if (!ReloadBitmap_File("casts", SURFACE_ID_CASTS))
{
return false;
}
//Clear casts
memset(Strip, 0, sizeof(Strip));
return true;
@ -451,9 +458,9 @@ int Scene_DownIsland(int mode)
//Draw scene
CortBox(&grcFull, 0);
PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 80 + (WINDOW_HEIGHT - 240) / 2, &rc_sky, 21);
PutBitmap3(&rc_frame, sprite.x / 0x200 - 20 + (WINDOW_WIDTH - 320) / 2, sprite.y / 512 - 12 + (WINDOW_HEIGHT - 240) / 2, &rc_sprite, 21);
PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 128 + (WINDOW_HEIGHT - 240) / 2, &rc_ground, 21);
PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 80 + (WINDOW_HEIGHT - 240) / 2, &rc_sky, SURFACE_ID_LEVEL_SPRITESET_1);
PutBitmap3(&rc_frame, sprite.x / 0x200 - 20 + (WINDOW_WIDTH - 320) / 2, sprite.y / 512 - 12 + (WINDOW_HEIGHT - 240) / 2, &rc_sprite, SURFACE_ID_LEVEL_SPRITESET_1);
PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 128 + (WINDOW_HEIGHT - 240) / 2, &rc_ground, SURFACE_ID_LEVEL_SPRITESET_1);
PutTimeCounter(16, 8);
//Draw window

View file

@ -1,4 +1,5 @@
#pragma once
#include <stdint.h>
struct CREDIT

View file

@ -1,7 +1,8 @@
#include "Escape.h"
#include "WindowsWrapper.h"
#include "CommonDefines.h"
#include "Escape.h"
#include "Draw.h"
#include "KeyControl.h"
#include "Main.h"
@ -33,7 +34,7 @@ int Call_Escape()
//Draw screen
CortBox(&grcFull, 0x000000);
PutBitmap3(&grcFull, (WINDOW_WIDTH - 208) / 2, (WINDOW_HEIGHT - 16) / 2, &rc, 26);
PutBitmap3(&grcFull, (WINDOW_WIDTH - 208) / 2, (WINDOW_HEIGHT - 16) / 2, &rc, SURFACE_ID_TEXT_BOX);
PutFramePerSecound();
if (!Flip_SystemTask())

View file

@ -1,2 +1,3 @@
#pragma once
int Call_Escape();

View file

@ -1,10 +1,11 @@
#include <string>
#include "Fade.h"
#include <string.h>
#include "WindowsWrapper.h"
#include "Fade.h"
#include "Game.h"
#include "Draw.h"
#include "Game.h"
FADE gFade;
@ -283,7 +284,7 @@ void PutFade()
{
rect.left = 16 * gFade.ani_no[y][x];
rect.right = rect.left + 16;
PutBitmap3(&grcGame, 16 * x, 16 * y, &rect, 6);
PutBitmap3(&grcGame, 16 * x, 16 * y, &rect, SURFACE_ID_FADE);
}
}
}

View file

@ -1,4 +1,5 @@
#pragma once
#include "CommonDefines.h"
#define FADE_WIDTH (((WINDOW_WIDTH - 1) >> 4) + 1)

96
src/File.cpp Normal file
View file

@ -0,0 +1,96 @@
#include "File.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
long LoadFileToMemory(const char *file_path, unsigned char **file_buffer)
{
long returned_size = -1;
FILE *file = fopen(file_path, "rb");
if (file != NULL)
{
if (!fseek(file, 0, SEEK_END))
{
const long file_size = ftell(file);
if (file_size >= 0)
{
rewind(file);
*file_buffer = (unsigned char*)malloc(file_size);
if (*file_buffer != NULL)
{
if (fread(*file_buffer, file_size, 1, file) == 1)
returned_size = file_size;
}
}
}
fclose(file);
}
return returned_size;
}
unsigned short File_ReadBE16(FILE *stream)
{
unsigned char bytes[2];
fread(bytes, 2, 1, stream);
return (bytes[0] << 8) | bytes[1];
}
unsigned long File_ReadBE32(FILE *stream)
{
unsigned char bytes[4];
fread(bytes, 4, 1, stream);
return (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3];
}
unsigned short File_ReadLE16(FILE *stream)
{
unsigned char bytes[2];
fread(bytes, 2, 1, stream);
return (bytes[1] << 8) | bytes[0];
}
unsigned long File_ReadLE32(FILE *stream)
{
unsigned char bytes[4];
fread(bytes, 4, 1, stream);
return (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];
}
void File_WriteBE16(unsigned short value, FILE *stream)
{
for (unsigned int i = 2; i-- != 0;)
fputc(value >> (8 * i), stream);
}
void File_WriteBE32(unsigned long value, FILE *stream)
{
for (unsigned int i = 4; i-- != 0;)
fputc(value >> (8 * i), stream);
}
void File_WriteLE16(unsigned short value, FILE *stream)
{
for (unsigned int i = 0; i < 2; ++i)
fputc(value >> (8 * i), stream);
}
void File_WriteLE32(unsigned long value, FILE *stream)
{
for (unsigned int i = 0; i < 4; ++i)
fputc(value >> (8 * i), stream);
}

15
src/File.h Normal file
View file

@ -0,0 +1,15 @@
#pragma once
#include <stdio.h>
long LoadFileToMemory(const char *file_path, unsigned char **file_buffer);
unsigned short File_ReadBE16(FILE *stream);
unsigned long File_ReadBE32(FILE *stream);
unsigned short File_ReadLE16(FILE *stream);
unsigned long File_ReadLE32(FILE *stream);
void File_WriteBE16(unsigned short value, FILE *stream);
void File_WriteBE32(unsigned long value, FILE *stream);
void File_WriteLE16(unsigned short value, FILE *stream);
void File_WriteLE32(unsigned long value, FILE *stream);

View file

@ -1,7 +1,7 @@
#include "Flags.h"
#include <cstring>
#include <stdint.h>
#include <string.h>
uint8_t gFlagNPC[1000];
uint8_t gSkipFlag[0x40];

View file

@ -1,5 +1,7 @@
#pragma once
#include <stdint.h>
extern uint8_t gFlagNPC[1000];
extern uint8_t gSkipFlag[0x40];

View file

@ -17,6 +17,8 @@
#include "SDL.h"
#include "File.h"
// Uncomment for that authentic pre-Windows Vista feel
//#define DISABLE_FONT_ANTIALIASING
@ -156,19 +158,12 @@ FontObject* LoadFont(const char *font_filename, unsigned int cell_width, unsigne
{
FontObject *font_object = NULL;
FILE *file = fopen(font_filename, "rb");
unsigned char *file_buffer;
const long file_size = LoadFileToMemory(font_filename, &file_buffer);
if (file != NULL)
if (file_size != -1)
{
fseek(file, 0, SEEK_END);
const size_t file_size = ftell(file);
rewind(file);
unsigned char *file_buffer = (unsigned char*)malloc(file_size);
fread(file_buffer, 1, file_size, file);
fclose(file);
font_object = LoadFontFromData(file_buffer, file_size, cell_width, cell_height);
free(file_buffer);
}

View file

@ -1,12 +1,13 @@
#include "Frame.h"
#include <string.h>
#include "Frame.h"
#include "Boss.h"
#include "CommonDefines.h"
#include "Game.h"
#include "Map.h"
#include "MyChar.h"
#include "NpChar.h"
#include "Game.h"
#include "CommonDefines.h"
#include "Boss.h"
FRAME gFrame;

View file

@ -1,4 +1,5 @@
#pragma once
struct FRAME
{
int x;

View file

@ -1,47 +1,49 @@
#include <string>
#include "Game.h"
#include <stdlib.h>
#include <string.h>
#include <SDL_timer.h>
#include "WindowsWrapper.h"
#include "Tags.h"
#include "NpcTbl.h"
#include "NpChar.h"
#include "NpcHit.h"
#include "MiniMap.h"
#include "Generic.h"
#include "Boss.h"
#include "GenericLoad.h"
#include "ArmsItem.h"
#include "TextScr.h"
#include "Bullet.h"
#include "BulHit.h"
#include "Shoot.h"
#include "Star.h"
#include "Fade.h"
#include "Frame.h"
#include "Flags.h"
#include "Escape.h"
#include "Stage.h"
#include "MyChar.h"
#include "MycHit.h"
#include "Caret.h"
#include "Map.h"
#include "Main.h"
#include "MycParam.h"
#include "MapName.h"
#include "Sound.h"
#include "Organya.h"
#include "Profile.h"
#include "MycParam.h"
#include "Back.h"
#include "KeyControl.h"
#include "ValueView.h"
#include "Boss.h"
#include "BossLife.h"
#include "BulHit.h"
#include "Bullet.h"
#include "Caret.h"
#include "Draw.h"
#include "Ending.h"
#include "Escape.h"
#include "Fade.h"
#include "Flags.h"
#include "Flash.h"
#include "BossLife.h"
#include "Frame.h"
#include "Generic.h"
#include "GenericLoad.h"
#include "KeyControl.h"
#include "Main.h"
#include "Map.h"
#include "MapName.h"
#include "MiniMap.h"
#include "MyChar.h"
#include "MycHit.h"
#include "MycParam.h"
#include "NpChar.h"
#include "NpcHit.h"
#include "NpcTbl.h"
#include "Organya.h"
#include "Profile.h"
#include "SelStage.h"
#include "Shoot.h"
#include "Sound.h"
#include "Stage.h"
#include "Star.h"
#include "Tags.h"
#include "TextScr.h"
#include "ValueView.h"
int g_GameFlags;
int gCounter;
@ -352,14 +354,14 @@ int ModeTitle()
PutNumber4((WINDOW_WIDTH + 56) / 2, WINDOW_HEIGHT - 24, v4, 0);
//Draw main title
PutBitmap3(&grcGame, (WINDOW_WIDTH - 144) / 2, 40, &rcTitle, 0);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 16) / 2, &rcNew, 0);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 56) / 2, &rcContinue, 0);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 160) / 2, WINDOW_HEIGHT - 48, &rcPixel, 1);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 144) / 2, 40, &rcTitle, SURFACE_ID_TITLE);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 16) / 2, &rcNew, SURFACE_ID_TITLE);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 56) / 2, &rcContinue, SURFACE_ID_TITLE);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 160) / 2, WINDOW_HEIGHT - 48, &rcPixel, SURFACE_ID_PIXEL);
//Draw character cursor
RECT char_rc;
int char_surf;
Surface_Ids char_surf;
switch ( char_type )
{
@ -530,7 +532,7 @@ int ModeAction()
//Open inventory
if (gKeyTrg & gKeyItem)
{
BackupSurface(10, &grcGame);
BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcGame);
switch (CampLoop())
{
@ -544,7 +546,7 @@ int ModeAction()
}
else if (gMC.equip & 2 && gKeyTrg & gKeyMap)
{
BackupSurface(10, &grcGame);
BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcGame);
switch (MiniMapLoop())
{

View file

@ -1,4 +1,5 @@
#pragma once
extern int g_GameFlags;
extern int gCounter;

View file

@ -1,3 +1,5 @@
#include "Generic.h"
#include <stdint.h>
#include <stdio.h>
@ -13,6 +15,21 @@ bool GetCompileVersion(int *v1, int *v2, int *v3, int *v4)
return true;
}
long GetFileSizeLong(const char *path)
{
long len = -1;
FILE *fp = fopen(path, "rb");
if (fp != NULL)
{
fseek(fp, 0, SEEK_END);
len = ftell(fp);
fclose(fp);
}
return len;
}
bool CheckFileExists(const char *name)
{
char path[PATH_LENGTH];

View file

@ -1,6 +1,8 @@
#pragma once
#include <stdint.h>
bool GetCompileVersion(int *v1, int *v2, int *v3, int *v4);
long GetFileSizeLong(const char *path);
bool CheckFileExists(const char *name);
bool IsShiftJIS(uint8_t c);

View file

@ -1,8 +1,10 @@
#include "GenericLoad.h"
#include "CommonDefines.h"
#include "Draw.h"
#include "Sound.h"
#include "PixTone.h"
#include "Ending.h"
#include "PixTone.h"
#include "Sound.h"
static const PIXTONEPARAMETER gPtpTable[139] =
{
@ -149,37 +151,37 @@ static const PIXTONEPARAMETER gPtpTable[139] =
bool LoadGenericData()
{
MakeSurface_Resource("PIXEL", 1);
MakeSurface_Resource("PIXEL", SURFACE_ID_PIXEL);
bool bError = false;
if (!MakeSurface_File("MyChar", 16))
if (!MakeSurface_File("MyChar", SURFACE_ID_MY_CHAR))
bError = true;
if (!MakeSurface_File("Title", 0))
if (!MakeSurface_File("Title", SURFACE_ID_TITLE))
bError = true;
if (!MakeSurface_File("ArmsImage", 12))
if (!MakeSurface_File("ArmsImage", SURFACE_ID_ARMS_IMAGE))
bError = true;
if (!MakeSurface_File("Arms", 11))
if (!MakeSurface_File("Arms", SURFACE_ID_ARMS))
bError = true;
if (!MakeSurface_File("ItemImage", 8))
if (!MakeSurface_File("ItemImage", SURFACE_ID_ITEM_IMAGE))
bError = true;
if (!MakeSurface_File("StageImage", 14))
if (!MakeSurface_File("StageImage", SURFACE_ID_STAGE_ITEM))
bError = true;
if (!MakeSurface_File("Npc/NpcSym", 20))
if (!MakeSurface_File("Npc/NpcSym", SURFACE_ID_NPC_SYM))
bError = true;
if (!MakeSurface_File("Npc/NpcRegu", 23))
if (!MakeSurface_File("Npc/NpcRegu", SURFACE_ID_NPC_REGU))
bError = true;
if (!MakeSurface_File("TextBox", 26))
if (!MakeSurface_File("TextBox", SURFACE_ID_TEXT_BOX))
bError = true;
if (!MakeSurface_File("Caret", 19))
if (!MakeSurface_File("Caret", SURFACE_ID_CARET))
bError = true;
if (!MakeSurface_File("Bullet", 17))
if (!MakeSurface_File("Bullet", SURFACE_ID_BULLET))
bError = true;
if (!MakeSurface_File("Face", 27))
if (!MakeSurface_File("Face", SURFACE_ID_FACE))
bError = true;
if (!MakeSurface_File("Fade", 6))
if (!MakeSurface_File("Fade", SURFACE_ID_FADE))
bError = true;
MakeSurface_Resource("CREDIT01", 36);
MakeSurface_Resource("CREDIT01", SURFACE_ID_CREDITS_IMAGE);
if (bError)
{
@ -190,10 +192,10 @@ bool LoadGenericData()
MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_SCREEN_GRAB);
MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_LEVEL_BACKGROUND);
MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_MAP);
MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, 37); //Unknown?
MakeSurface_Generic(WINDOW_WIDTH, WINDOW_HEIGHT, SURFACE_ID_CASTS);
MakeSurface_Generic(256, 256, SURFACE_ID_LEVEL_TILESET);
MakeSurface_Generic(160, 16, SURFACE_ID_ROOM_NAME);
MakeSurface_Generic(40, 240, 29); //Unknown?
MakeSurface_Generic(40, 240, SURFACE_ID_VALUE_VIEW);
MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_1);
MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_2);
MakeSurface_Generic(WINDOW_WIDTH, 16 * MAX_STRIP, SURFACE_ID_CREDIT_CAST);

View file

@ -1,2 +1,3 @@
#pragma once
bool LoadGenericData();

View file

@ -1,12 +1,14 @@
#include "Types.h"
#include "CommonDefines.h"
#include "Input.h"
#include <stdint.h>
#include <SDL.h>
#include "WindowsWrapper.h"
#include "Input.h"
#include "CommonDefines.h"
#include "Tags.h"
#include "Types.h"
#define JOYSTICK_DEADZONE 10000

View file

@ -1,4 +1,5 @@
#pragma once
extern bool gbUseJoystick;
extern int gJoystickButtonTable[8];

View file

@ -1,4 +1,5 @@
#include "KeyControl.h"
int gKey;
int gKeyTrg;

View file

@ -1,4 +1,5 @@
#pragma once
enum KEYBIND
{
//The movement keys go in the order of left, right, up and down

View file

@ -1,34 +1,37 @@
#include "Main.h"
#include <stddef.h>
#include "Types.h"
#include "CommonDefines.h"
#include <stdint.h>
#include <string>
#include <string.h>
#include <SDL.h>
#include "WindowsWrapper.h"
#include "CommonDefines.h"
#include "Config.h"
#include "Draw.h"
#include "Input.h"
#include "Profile.h"
#include "Organya.h"
#include "Sound.h"
#include "Game.h"
#include "Generic.h"
#include "MyChar.h"
#include "Main.h"
#include "Config.h"
#include "Input.h"
#include "KeyControl.h"
#include "Triangle.h"
#include "MyChar.h"
#include "Organya.h"
#include "Profile.h"
#include "Resource.h"
#include "Sound.h"
#include "Triangle.h"
#include "Types.h"
// These two are defined in Draw.cpp. This is a bit of a hack.
extern SDL_Window *gWindow;
extern SDL_Renderer *gRenderer;
char gModulePath[PATH_LENGTH];
char gDataPath[PATH_LENGTH];
int gJoystickButtonTable[8];
SDL_Window *gWindow;
SDL_Renderer *gRenderer;
bool gbUseJoystick = false;
bool bFps = false;
@ -430,6 +433,13 @@ void JoystickProc()
}
}
#define DO_KEY_PRESS(key) \
if (event.type == SDL_KEYDOWN) \
gKey |= key; \
else \
gKey &= ~key; \
break;
bool SystemTask()
{
//Handle window events
@ -470,186 +480,145 @@ bool SystemTask()
break;
case SDL_KEYDOWN:
case SDL_KEYUP:
#ifdef FIX_BUGS
//BUG FIX: Pixel relied on key codes for input, but these differ based on keyboard layout.
//This would break the alternate movement keys on typical English keyboards, since the '=' key
//is in a completely different place to where it is on a Japanese keyboard.
//To solve this, we use scancodes instead, which are based on the physical location of keys,
//rather than their meaning.
switch (event.key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
DO_KEY_PRESS(KEY_ESCAPE)
case SDL_SCANCODE_W:
DO_KEY_PRESS(KEY_MAP)
case SDL_SCANCODE_LEFT:
DO_KEY_PRESS(KEY_LEFT)
case SDL_SCANCODE_RIGHT:
DO_KEY_PRESS(KEY_RIGHT)
case SDL_SCANCODE_UP:
DO_KEY_PRESS(KEY_UP)
case SDL_SCANCODE_DOWN:
DO_KEY_PRESS(KEY_DOWN)
case SDL_SCANCODE_X:
DO_KEY_PRESS(KEY_X)
case SDL_SCANCODE_Z:
DO_KEY_PRESS(KEY_Z)
case SDL_SCANCODE_S:
DO_KEY_PRESS(KEY_ARMS)
case SDL_SCANCODE_A:
DO_KEY_PRESS(KEY_ARMSREV)
case SDL_SCANCODE_RSHIFT:
case SDL_SCANCODE_LSHIFT:
DO_KEY_PRESS(KEY_SHIFT)
case SDL_SCANCODE_F1:
DO_KEY_PRESS(KEY_F1)
case SDL_SCANCODE_F2:
DO_KEY_PRESS(KEY_F2)
case SDL_SCANCODE_Q:
DO_KEY_PRESS(KEY_ITEM)
case SDL_SCANCODE_COMMA:
DO_KEY_PRESS(KEY_ALT_LEFT)
case SDL_SCANCODE_PERIOD:
DO_KEY_PRESS(KEY_ALT_DOWN)
case SDL_SCANCODE_SLASH:
DO_KEY_PRESS(KEY_ALT_RIGHT)
case SDL_SCANCODE_L:
DO_KEY_PRESS(KEY_ALT_UP)
case SDL_SCANCODE_SEMICOLON:
DO_KEY_PRESS(KEY_PLUS)
case SDL_SCANCODE_F5:
gbUseJoystick = false;
break;
}
break;
#else
switch (event.key.keysym.sym)
{
case SDLK_ESCAPE:
gKey |= KEY_ESCAPE;
break;
DO_KEY_PRESS(KEY_ESCAPE)
case SDLK_w:
gKey |= KEY_MAP;
break;
DO_KEY_PRESS(KEY_MAP)
case SDLK_LEFT:
gKey |= KEY_LEFT;
break;
DO_KEY_PRESS(KEY_LEFT)
case SDLK_RIGHT:
gKey |= KEY_RIGHT;
break;
DO_KEY_PRESS(KEY_RIGHT)
case SDLK_UP:
gKey |= KEY_UP;
break;
DO_KEY_PRESS(KEY_UP)
case SDLK_DOWN:
gKey |= KEY_DOWN;
break;
DO_KEY_PRESS(KEY_DOWN)
case SDLK_x:
gKey |= KEY_X;
break;
DO_KEY_PRESS(KEY_X)
case SDLK_z:
gKey |= KEY_Z;
break;
DO_KEY_PRESS(KEY_Z)
case SDLK_s:
gKey |= KEY_ARMS;
break;
DO_KEY_PRESS(KEY_ARMS)
case SDLK_a:
gKey |= KEY_ARMSREV;
break;
DO_KEY_PRESS(KEY_ARMSREV)
case SDLK_RSHIFT:
case SDLK_LSHIFT:
gKey |= KEY_SHIFT;
break;
DO_KEY_PRESS(KEY_SHIFT)
case SDLK_F1:
gKey |= KEY_F1;
break;
DO_KEY_PRESS(KEY_F1)
case SDLK_F2:
gKey |= KEY_F2;
break;
DO_KEY_PRESS(KEY_F2)
case SDLK_q:
gKey |= KEY_ITEM;
break;
DO_KEY_PRESS(KEY_ITEM)
case SDLK_COMMA:
gKey |= KEY_ALT_LEFT;
break;
DO_KEY_PRESS(KEY_ALT_LEFT)
case SDLK_PERIOD:
gKey |= KEY_ALT_DOWN;
break;
DO_KEY_PRESS(KEY_ALT_DOWN)
case SDLK_SLASH:
gKey |= KEY_ALT_RIGHT;
break;
DO_KEY_PRESS(KEY_ALT_RIGHT)
case SDLK_l:
gKey |= KEY_ALT_UP;
break;
#ifdef FIX_BUGS //BUG FIX: Pixel intended for the second alternate up key to be the plus key, Japanese keyboards have the plus key where the semi-colon key is, causing errors on other keyboard layouts)
case SDLK_PLUS:
#else
DO_KEY_PRESS(KEY_ALT_UP)
case SDLK_SEMICOLON:
#endif
gKey |= KEY_PLUS;
break;
DO_KEY_PRESS(KEY_PLUS)
case SDLK_F5:
gbUseJoystick = false;
break;
default:
break;
}
break;
case SDL_KEYUP:
switch (event.key.keysym.sym)
{
case SDLK_ESCAPE:
gKey &= ~KEY_ESCAPE;
break;
case SDLK_w:
gKey &= ~KEY_MAP;
break;
case SDLK_LEFT:
gKey &= ~KEY_LEFT;
break;
case SDLK_RIGHT:
gKey &= ~KEY_RIGHT;
break;
case SDLK_UP:
gKey &= ~KEY_UP;
break;
case SDLK_DOWN:
gKey &= ~KEY_DOWN;
break;
case SDLK_x:
gKey &= ~KEY_X;
break;
case SDLK_z:
gKey &= ~KEY_Z;
break;
case SDLK_s:
gKey &= ~KEY_ARMS;
break;
case SDLK_a:
gKey &= ~KEY_ARMSREV;
break;
case SDLK_RSHIFT:
case SDLK_LSHIFT:
gKey &= ~KEY_SHIFT;
break;
case SDLK_F1:
gKey &= ~KEY_F1;
break;
case SDLK_F2:
gKey &= ~KEY_F2;
break;
case SDLK_q:
gKey &= ~KEY_ITEM;
break;
case SDLK_COMMA:
gKey &= ~KEY_ALT_LEFT;
break;
case SDLK_PERIOD:
gKey &= ~KEY_ALT_DOWN;
break;
case SDLK_SLASH:
gKey &= ~KEY_ALT_RIGHT;
break;
case SDLK_l:
gKey &= ~KEY_ALT_UP;
break;
#ifdef FIX_BUGS //BUG FIX: Pixel intended for the second alternate up key to be the plus key, Japanese keyboards have the plus key where the semi-colon key is, causing errors on other keyboard layouts)
case SDLK_PLUS:
#else
case SDLK_SEMICOLON:
#endif
gKey &= ~KEY_PLUS;
break;
default:
break;
}
break;
#endif
}
}

View file

@ -1,3 +1,4 @@
#pragma once
void PutFramePerSecound();
int GetFramePerSecound();

View file

@ -1,14 +1,17 @@
#include <stdint.h>
#include <string>
#include "Map.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <SDL_rwops.h>
#include "WindowsWrapper.h"
#include "CommonDefines.h"
#include "Map.h"
#include "Tags.h"
#include "Draw.h"
#include "File.h"
#include "NpChar.h"
#include "Tags.h"
#define PXM_BUFFER_SIZE 0x4B000
@ -27,39 +30,39 @@ bool LoadMapData2(char *path_map)
sprintf(path, "%s/%s", gDataPath, path_map);
//Open file
SDL_RWops *fp = SDL_RWFromFile(path, "rb");
if (!fp)
FILE *fp = fopen(path, "rb");
if (fp == NULL)
return false;
//Make sure file begins with "PXM"
char check[3];
fp->read(fp, check, 1, 3);
fread(check, 1, 3, fp);
if (!memcmp(check, "PXM", 3))
{
uint8_t nul;
fp->read(fp, &nul, 1, 1);
fread(&nul, 1, 1, fp);
//Get width and height
gMap.width = SDL_ReadLE16(fp);
gMap.length = SDL_ReadLE16(fp);
gMap.width = File_ReadLE16(fp);
gMap.length = File_ReadLE16(fp);
if (gMap.data)
{
//Read tiledata
fp->read(fp, gMap.data, 1, gMap.length * gMap.width);
SDL_RWclose(fp);
fread(gMap.data, 1, gMap.length * gMap.width, fp);
fclose(fp);
return true;
}
else
{
SDL_RWclose(fp);
fclose(fp);
return false;
}
}
else
{
SDL_RWclose(fp);
fclose(fp);
return false;
}
@ -72,13 +75,13 @@ bool LoadAttributeData(char *path_atrb)
char path[260];
sprintf(path, "%s/%s", gDataPath, path_atrb);
SDL_RWops *fp = SDL_RWFromFile(path, "rb");
if (!fp)
FILE *fp = fopen(path, "rb");
if (fp == NULL)
return false;
//Read data
fp->read(fp, gMap.atrb, 1, 0x100);
SDL_RWclose(fp);
fread(gMap.atrb, 1, 0x100, fp);
fclose(fp);
return true;
}

View file

@ -1,4 +1,5 @@
#pragma once
#include <stdint.h>
struct MAP_DATA

View file

@ -1,8 +1,9 @@
#include "MapName.h"
#include <stdint.h>
#include <string>
#include <string.h>
#include "CommonDefines.h"
#include "MapName.h"
#include "Draw.h"
MAP_NAME gMapName;

View file

@ -1,4 +1,5 @@
#pragma once
struct MAP_NAME
{
int flag;

Some files were not shown because too many files have changed in this diff Show more