Merge branch 'master' of https://github.com/cuckydev/Cave-Story-Engine-2
This commit is contained in:
commit
03e0034bca
11 changed files with 107 additions and 55 deletions
0
build/fps
Normal file
0
build/fps
Normal file
40
src/Back.cpp
40
src/Back.cpp
|
@ -52,6 +52,7 @@ void ActBack()
|
|||
void PutBack(int fx, int fy)
|
||||
{
|
||||
RECT rect = {0, 0, gBack.partsW, gBack.partsH};
|
||||
RECT rcSkyFiller = {106, 0, 255, 88};
|
||||
|
||||
switch (gBack.type)
|
||||
{
|
||||
|
@ -90,63 +91,66 @@ void PutBack(int fx, int fy)
|
|||
case 6:
|
||||
case 7:
|
||||
//Sky
|
||||
static unsigned int fillNext;
|
||||
fillNext = 0;
|
||||
for (int y = 0; y < WINDOW_HEIGHT - 240 + 88; y += 88)
|
||||
{
|
||||
fillNext = ((fillNext) * 214013 + 2531011);
|
||||
for (int x = -(fillNext % 149); x < WINDOW_WIDTH; x += 149)
|
||||
{
|
||||
PutBitmap4(&grcGame, x, y, &rcSkyFiller, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
}
|
||||
}
|
||||
|
||||
rect.top = 0;
|
||||
rect.bottom = 88;
|
||||
rect.left = 0;
|
||||
rect.right = 320;
|
||||
PutBitmap4(&grcGame, (WINDOW_WIDTH - 320) / 2, 0, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
|
||||
rect.left = 106;
|
||||
rect.right = 255;
|
||||
for (int i = 0; i < ((WINDOW_WIDTH + 329) / 320); i++)
|
||||
{
|
||||
PutBitmap4(&grcGame, (WINDOW_WIDTH - 320) / 2 - (149 * (i + 1)), 0, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
PutBitmap4(&grcGame, (WINDOW_WIDTH - 320) / 2 + 320 + (149 * i), 0, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
}
|
||||
|
||||
PutBitmap4(&grcGame, (WINDOW_WIDTH - 320) / 2, WINDOW_HEIGHT - 240, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
|
||||
//Cloud layer 1
|
||||
rect.top = 88;
|
||||
rect.bottom = 123;
|
||||
rect.left = gBack.fx / 2;
|
||||
rect.right = 320;
|
||||
PutBitmap4(&grcGame, 0, 88, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
PutBitmap4(&grcGame, 0, 88 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
|
||||
rect.left = 0;
|
||||
for (int i = 0; i < ((WINDOW_WIDTH + 329) / 320) + 1; i++)
|
||||
PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx / 2 % 320, 88, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx / 2 % 320, 88 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
|
||||
//Cloud layer 2
|
||||
rect.top = 123;
|
||||
rect.bottom = 146;
|
||||
rect.left = gBack.fx % 320;
|
||||
rect.right = 320;
|
||||
PutBitmap4(&grcGame, 0, 123, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
PutBitmap4(&grcGame, 0, 123 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
|
||||
rect.left = 0;
|
||||
for (int i = 0; i < ((WINDOW_WIDTH + 329) / 320) + 1; i++)
|
||||
PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx % 320, 123, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx % 320, 123 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
|
||||
//Cloud layer 3
|
||||
rect.top = 146;
|
||||
rect.bottom = 176;
|
||||
rect.left = 2 * gBack.fx % 320;
|
||||
rect.right = 320;
|
||||
PutBitmap4(&grcGame, 0, 146, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
PutBitmap4(&grcGame, 0, 146 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
|
||||
rect.left = 0;
|
||||
for (int i = 0; i < ((WINDOW_WIDTH + 329) / 320) + 1; i++)
|
||||
PutBitmap4(&grcGame, (320 * (i + 1)) - 2 * gBack.fx % 320, 146, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
PutBitmap4(&grcGame, (320 * (i + 1)) - 2 * gBack.fx % 320, 146 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
|
||||
//Cloud layer 4
|
||||
rect.top = 176;
|
||||
rect.bottom = 240;
|
||||
rect.left = 4 * gBack.fx % 320;
|
||||
rect.right = 320;
|
||||
PutBitmap4(&grcGame, 0, 176, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
PutBitmap4(&grcGame, 0, 176 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
|
||||
rect.left = 0;
|
||||
for (int i = 0; i < ((WINDOW_WIDTH + 329) / 320) + 1; i++)
|
||||
PutBitmap4(&grcGame, (320 * (i + 1)) - 4 * gBack.fx % 320, 176, &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
PutBitmap4(&grcGame, (320 * (i + 1)) - 4 * gBack.fx % 320, 176 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -66,6 +66,8 @@ bool Flip_SystemTask()
|
|||
|
||||
static bool IsEnableBitmap(SDL_RWops *fp)
|
||||
{
|
||||
return true;
|
||||
/*
|
||||
char str[16];
|
||||
const char *extra_text = "(C)Pixel";
|
||||
|
||||
|
@ -75,6 +77,7 @@ static bool IsEnableBitmap(SDL_RWops *fp)
|
|||
fp->read(fp, str, 1, len);
|
||||
fp->seek(fp, 0, RW_SEEK_SET);
|
||||
return memcmp(str, extra_text, len) == 0;
|
||||
*/
|
||||
}
|
||||
|
||||
void ReleaseSurface(int s)
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#include "Draw.h"
|
||||
#include "TextScr.h"
|
||||
|
||||
#define MAX_STRIP 0x10
|
||||
|
||||
CREDIT Credit;
|
||||
STRIP Strip[MAX_STRIP];
|
||||
ILLUSTRATION Illust;
|
||||
|
@ -100,6 +98,10 @@ void ActionIllust()
|
|||
{
|
||||
switch (Illust.act_no)
|
||||
{
|
||||
case 0: //Off-screen to the left
|
||||
Illust.x = -0x14000;
|
||||
break;
|
||||
|
||||
case 1: //Move in from the left
|
||||
Illust.x += 0x5000;
|
||||
if (Illust.x > 0)
|
||||
|
@ -111,10 +113,6 @@ void ActionIllust()
|
|||
if (Illust.x < -0x14000)
|
||||
Illust.x = -0x14000;
|
||||
break;
|
||||
|
||||
case 0: //Off-screen to the left
|
||||
Illust.x = -0x14000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,6 +135,7 @@ void ReloadIllust(int a)
|
|||
//Initialize and release credits
|
||||
void InitCreditScript()
|
||||
{
|
||||
//Clear script state and casts
|
||||
memset(&Credit, 0, sizeof(CREDIT));
|
||||
memset(Strip, 0, sizeof(Strip));
|
||||
}
|
||||
|
@ -145,6 +144,7 @@ void ReleaseCreditScript()
|
|||
{
|
||||
if (Credit.pData)
|
||||
{
|
||||
//Free script data
|
||||
free(Credit.pData);
|
||||
Credit.pData = NULL;
|
||||
}
|
||||
|
@ -179,7 +179,8 @@ bool StartCreditScript()
|
|||
return false;
|
||||
|
||||
//Read data
|
||||
fp->read(fp, Credit.pData, 1, Credit.size);
|
||||
SDL_RWread(fp, Credit.pData, 1, Credit.size);
|
||||
SDL_RWclose(fp);
|
||||
EncryptionBinaryData2((uint8_t*)Credit.pData, Credit.size);
|
||||
|
||||
//Reset credits
|
||||
|
@ -203,14 +204,16 @@ bool StartCreditScript()
|
|||
|
||||
//Clear casts
|
||||
memset(Strip, 0, sizeof(Strip));
|
||||
SDL_RWclose(fp);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Get number from text (4 digit)
|
||||
int GetScriptNumber(const char *text)
|
||||
{
|
||||
return 1000 * *text - 48000 + 100 * text[1] - 4800 + 10 * text[2] - 480 + text[3] - 48;
|
||||
return 1000 * text[0] - 48000 +
|
||||
100 * text[1] - 4800 +
|
||||
10 * text[2] - 480 +
|
||||
text[3] - 48;
|
||||
}
|
||||
|
||||
//Parse credits
|
||||
|
@ -218,6 +221,7 @@ void ActionCredit_Read()
|
|||
{
|
||||
while (Credit.offset < Credit.size)
|
||||
{
|
||||
//Get character
|
||||
uint8_t character = Credit.pData[Credit.offset];
|
||||
|
||||
int a, b, len;
|
||||
|
@ -352,6 +356,7 @@ void ActionCredit()
|
|||
{
|
||||
if (Credit.offset < Credit.size)
|
||||
{
|
||||
//Update script, or if waiting, decrement the wait value
|
||||
if (Credit.mode == 1)
|
||||
{
|
||||
ActionCredit_Read();
|
||||
|
@ -379,23 +384,24 @@ void CutCreditIllust()
|
|||
//Scene of the island falling
|
||||
int Scene_DownIsland(int mode)
|
||||
{
|
||||
RECT rc_sprite;
|
||||
RECT rc_ground;
|
||||
RECT rc_sky;
|
||||
RECT rc_frame;
|
||||
//Setup background
|
||||
RECT rc_frame = {(WINDOW_WIDTH - 160) / 2, (WINDOW_HEIGHT - 80) / 2, (WINDOW_WIDTH + 160) / 2, (WINDOW_HEIGHT + 80) / 2};
|
||||
RECT rc_sky = {0, 0, 160, 80};
|
||||
RECT rc_ground = {160, 48, 320, 80};
|
||||
|
||||
//Setup island
|
||||
RECT rc_sprite = {160, 0, 200, 24};
|
||||
|
||||
ISLAND_SPRITE sprite;
|
||||
|
||||
rc_frame = {(WINDOW_WIDTH - 160) / 2, (WINDOW_HEIGHT - 80) / 2, (WINDOW_WIDTH + 160) / 2, (WINDOW_HEIGHT + 80) / 2};
|
||||
rc_sky = {0, 0, 160, 80};
|
||||
rc_ground = {160, 48, 320, 80};
|
||||
rc_sprite = {160, 0, 200, 24};
|
||||
sprite.x = 0x15000;
|
||||
sprite.y = 0x8000;
|
||||
|
||||
for (int wait = 0; wait < 900; wait++)
|
||||
{
|
||||
//Get pressed keys
|
||||
GetTrg();
|
||||
|
||||
//Escape menu
|
||||
if (gKey & 0x8000)
|
||||
{
|
||||
int escRet = Call_Escape();
|
||||
|
@ -408,6 +414,7 @@ int Scene_DownIsland(int mode)
|
|||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
//Move down
|
||||
sprite.y += 0x33;
|
||||
break;
|
||||
|
||||
|
@ -418,33 +425,38 @@ int Scene_DownIsland(int mode)
|
|||
{
|
||||
if (wait >= 600)
|
||||
{
|
||||
//End scene
|
||||
if (wait == 750)
|
||||
wait = 900;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Move down slow
|
||||
sprite.y += 0xC;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Move down slower
|
||||
sprite.y += 0x19;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Move down at normal speed
|
||||
sprite.y += 0x33;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//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);
|
||||
PutTimeCounter(16, 8);
|
||||
|
||||
//Draw window
|
||||
PutFramePerSecound();
|
||||
if (!Flip_SystemTask())
|
||||
return 0;
|
||||
|
|
|
@ -32,6 +32,8 @@ struct ISLAND_SPRITE
|
|||
int y;
|
||||
};
|
||||
|
||||
#define MAX_STRIP (WINDOW_HEIGHT / 16) + 1
|
||||
|
||||
void ActionStripper();
|
||||
void PutStripper();
|
||||
void SetStripper(int x, int y, char *text, int cast);
|
||||
|
|
|
@ -22,30 +22,24 @@ void MoveFrame3()
|
|||
const int num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1;
|
||||
const int num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1;
|
||||
|
||||
if (map_w >= num_x || g_GameFlags & 8)
|
||||
if (map_w >= num_x)
|
||||
{
|
||||
if (gFrame.x <= -0x200)
|
||||
gFrame.x = 0;
|
||||
if (gFrame.x > ((((map_w - 1) << 4) - ((g_GameFlags & 8) ? 320 : WINDOW_WIDTH))) << 9)
|
||||
gFrame.x = (((map_w - 1) << 4) - ((g_GameFlags & 8) ? 320 : WINDOW_WIDTH)) << 9;
|
||||
|
||||
if (g_GameFlags & 8)
|
||||
gFrame.x -= ((WINDOW_WIDTH - 320) / 2) << 9;
|
||||
}
|
||||
else
|
||||
{
|
||||
gFrame.x = (((map_w - 1) << 4) - WINDOW_WIDTH) << 8;
|
||||
}
|
||||
|
||||
if (map_l >= num_y || g_GameFlags & 8)
|
||||
if (map_l >= num_y)
|
||||
{
|
||||
if (gFrame.y <= -0x200)
|
||||
gFrame.y = 0;
|
||||
if (gFrame.y > ((((map_l - 1) << 4) - ((g_GameFlags & 8) ? 240 : WINDOW_HEIGHT))) << 9)
|
||||
gFrame.y = (((map_l - 1) << 4) - ((g_GameFlags & 8) ? 240 : WINDOW_HEIGHT)) << 9;
|
||||
|
||||
if (g_GameFlags & 8)
|
||||
gFrame.y += ((WINDOW_HEIGHT - 240) / 2) << 9;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ bool bContinue;
|
|||
|
||||
int Random(int min, int max)
|
||||
{
|
||||
return min + rand() % (max - min + 1);
|
||||
return min + rep_rand() % (max - min + 1);
|
||||
}
|
||||
|
||||
void PutNumber4(int x, int y, int value, bool bZero)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "Draw.h"
|
||||
#include "Sound.h"
|
||||
#include "PixTone.h"
|
||||
#include "Ending.h"
|
||||
|
||||
static const PIXTONEPARAMETER gPtpTable[139] =
|
||||
{
|
||||
|
@ -195,7 +196,7 @@ bool LoadGenericData()
|
|||
MakeSurface_Generic(40, 240, 29); //Unknown?
|
||||
MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_1);
|
||||
MakeSurface_Generic(320, 240, SURFACE_ID_LEVEL_SPRITESET_2);
|
||||
MakeSurface_Generic(WINDOW_WIDTH, 240, SURFACE_ID_CREDIT_CAST);
|
||||
MakeSurface_Generic(WINDOW_WIDTH, 16 * MAX_STRIP, SURFACE_ID_CREDIT_CAST);
|
||||
|
||||
size_t pixtone_bytes = MakePixToneObject(&gPtpTable[0], 2, 32);
|
||||
pixtone_bytes += MakePixToneObject(&gPtpTable[2], 2, 33);
|
||||
|
|
15
src/Main.cpp
15
src/Main.cpp
|
@ -44,6 +44,21 @@ const char *lpWindowName = "洞窟物語エンジン2";
|
|||
const char *lpWindowName = "Cave Story Engine 2 ~ Doukutsu Monogatari Enjin 2";
|
||||
#endif
|
||||
|
||||
//A replication of MSVC's rand algorithm
|
||||
static unsigned long int next = 1;
|
||||
|
||||
int rep_rand()
|
||||
{
|
||||
next = ((next) * 214013 + 2531011);
|
||||
return ((next) >> 16) & 0x7FFF;
|
||||
}
|
||||
|
||||
void rep_srand(unsigned int seed)
|
||||
{
|
||||
next = seed;
|
||||
}
|
||||
|
||||
//Framerate stuff
|
||||
void PutFramePerSecound()
|
||||
{
|
||||
if (bFps)
|
||||
|
|
|
@ -43,7 +43,7 @@ void SetValueView(int *px, int *py, int value)
|
|||
|
||||
//Get if negative or not
|
||||
bool minus;
|
||||
if ( value >= 0 )
|
||||
if (value >= 0)
|
||||
{
|
||||
minus = false;
|
||||
}
|
||||
|
@ -85,6 +85,28 @@ void SetValueView(int *px, int *py, int value)
|
|||
gVV[index].rect.right = 40;
|
||||
gVV[index].rect.bottom = 8 * (index + 1);
|
||||
|
||||
RECT rect[20];
|
||||
rect[0] = {0, 56, 8, 64};
|
||||
rect[1] = {8, 56, 16, 64};
|
||||
rect[2] = {16, 56, 24, 64};
|
||||
rect[3] = {24, 56, 32, 64};
|
||||
rect[4] = {32, 56, 40, 64};
|
||||
rect[5] = {40, 56, 48, 64};
|
||||
rect[6] = {48, 56, 56, 64};
|
||||
rect[7] = {56, 56, 64, 64};
|
||||
rect[8] = {64, 56, 72, 64};
|
||||
rect[9] = {72, 56, 80, 64};
|
||||
rect[10] = {0, 64, 8, 72};
|
||||
rect[11] = {8, 64, 16, 72};
|
||||
rect[12] = {16, 64, 24, 72};
|
||||
rect[13] = {24, 64, 32, 72};
|
||||
rect[14] = {32, 64, 40, 72};
|
||||
rect[15] = {40, 64, 48, 72};
|
||||
rect[16] = {48, 64, 56, 72};
|
||||
rect[17] = {56, 64, 64, 72};
|
||||
rect[18] = {64, 64, 72, 72};
|
||||
rect[19] = {72, 64, 80, 72};
|
||||
|
||||
//Get digits
|
||||
int dig[4];
|
||||
dig[0] = 1;
|
||||
|
@ -103,7 +125,7 @@ void SetValueView(int *px, int *py, int value)
|
|||
}
|
||||
}
|
||||
|
||||
int sw = 0;
|
||||
bool sw = false;
|
||||
|
||||
RECT rcPlus = {32, 48, 40, 56};
|
||||
RECT rcMinus = {40, 48, 48, 56};
|
||||
|
@ -120,15 +142,12 @@ void SetValueView(int *px, int *py, int value)
|
|||
{
|
||||
if (sw || !i || fig[i])
|
||||
{
|
||||
sw = 1;
|
||||
sw = true;
|
||||
|
||||
RECT rect;
|
||||
if (minus)
|
||||
rect = {fig[i] << 3, 64, (fig[i] + 1) << 3, 72};
|
||||
else
|
||||
rect = {fig[i] << 3, 56, (fig[i] + 1) << 3, 64};
|
||||
fig[i] += 10;
|
||||
|
||||
Surface2Surface(8 * (4 - i), gVV[index].rect.top, &rect, 29, 26);
|
||||
Surface2Surface(8 * (4 - i), gVV[index].rect.top, &rect[fig[i]], 29, 26);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#pragma once
|
||||
int rep_rand();
|
||||
void rep_srand(unsigned int seed);
|
||||
|
||||
typedef int BOOL;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue