commit
cd9df8ec47
7 changed files with 33 additions and 41 deletions
|
@ -21,7 +21,7 @@ Just run 'make' in the base directory, preferably with some of the following set
|
|||
* RELEASE=1 to compile a release build (optimised, stripped, etc.)
|
||||
* STATIC=1 to produce a statically-linked executable (good for Windows builds)
|
||||
* JAPANESE=1 to enable the Japanese-language build (instead of the unofficial Aeon Genesis English translation)
|
||||
* FIX_BUGS=1 to fix certain bugs (see [src/Bug Fixes.txt](https://github.com/cuckydev/Cave-Story-Engine-2/blob/master/src/Bug%20Fixes.txt))
|
||||
* FIX_BUGS=1 to fix certain bugs (see [src/Bug Fixes.txt](src/Bug%20Fixes.txt))
|
||||
* WINDOWS=1 to enable Windows-only features like a unique file/taskbar icon, and system font loading (needed for the font setting in Config.dat to do anything)
|
||||
|
||||
## Running
|
||||
|
|
|
@ -167,11 +167,11 @@ void PutFront(int fx, int fy)
|
|||
if (gBack.type == 3)
|
||||
{
|
||||
int x_1 = fx / 0x4000;
|
||||
int x_2 = fx / 0x4000 + (((WINDOW_WIDTH + 31) >> 5) + 1);
|
||||
int x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1);
|
||||
int y_1 = 0;
|
||||
int y_2 = 32;
|
||||
int y_2 = y_1 + 32;
|
||||
|
||||
for (int y = 0; y < y_2; y++)
|
||||
for (int y = y_1; y < y_2; y++)
|
||||
{
|
||||
int ypos = (y << 14) / 0x200 - fy / 0x200 + gWaterY / 0x200;
|
||||
|
||||
|
|
34
src/Draw.cpp
34
src/Draw.cpp
|
@ -187,21 +187,21 @@ static void FlushSurface(int surf_no)
|
|||
int pitch;
|
||||
SDL_LockTexture(surf[surf_no].texture, NULL, (void**)&raw_pixels, &pitch);
|
||||
|
||||
unsigned char (*src_pixels)[surf[surf_no].surface->pitch / 4][4] = (unsigned char (*)[surf[surf_no].surface->pitch/ 4][4])surf[surf_no].surface->pixels;
|
||||
unsigned char (*dst_pixels)[pitch / 4][4] = (unsigned char (*)[pitch/ 4][4])raw_pixels;
|
||||
|
||||
for (int h = 0; h < surf[surf_no].surface->h; ++h)
|
||||
{
|
||||
for (int w = 0; w < surf[surf_no].surface->w; ++w)
|
||||
{
|
||||
dst_pixels[h][w][0] = src_pixels[h][w][0];
|
||||
dst_pixels[h][w][1] = src_pixels[h][w][1];
|
||||
dst_pixels[h][w][2] = src_pixels[h][w][2];
|
||||
unsigned char *src_pixel = (unsigned char*)surf[surf_no].surface->pixels + (h * surf[surf_no].surface->pitch) + (w * 4);
|
||||
unsigned char *dst_pixel = (unsigned char*)raw_pixels + (h * pitch) + (w * 4);
|
||||
|
||||
if (src_pixels[h][w][0] || src_pixels[h][w][1] || src_pixels[h][w][2]) // Colour-key
|
||||
dst_pixels[h][w][3] = 0xFF;
|
||||
dst_pixel[0] = src_pixel[0];
|
||||
dst_pixel[1] = src_pixel[1];
|
||||
dst_pixel[2] = src_pixel[2];
|
||||
|
||||
if (src_pixel[0] || src_pixel[1] || src_pixel[2]) // Colour-key
|
||||
dst_pixel[3] = 0xFF;
|
||||
else
|
||||
dst_pixels[h][w][3] = 0;
|
||||
dst_pixel[3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,24 +254,24 @@ static bool LoadBitmap(SDL_RWops *fp, int surf_no, bool create_surface)
|
|||
else
|
||||
{
|
||||
// Upscale the bitmap to the game's native resolution (SDL_BlitScaled is buggy, so we have to do it on our own)
|
||||
const unsigned char (*src_pixels)[converted_surface->pitch] = (unsigned char(*)[converted_surface->pitch])converted_surface->pixels;
|
||||
unsigned char (*dst_pixels)[surf[surf_no].surface->pitch] = (unsigned char(*)[surf[surf_no].surface->pitch])surf[surf_no].surface->pixels;
|
||||
|
||||
for (int h = 0; h < converted_surface->h; ++h)
|
||||
{
|
||||
const unsigned long *src_row = (unsigned long*)src_pixels[h];
|
||||
unsigned long *dst_row = (unsigned long*)dst_pixels[h * magnification];
|
||||
const unsigned char *src_row = (unsigned char*)converted_surface->pixels + h * converted_surface->pitch;
|
||||
unsigned char *dst_row = (unsigned char*)surf[surf_no].surface->pixels + h * surf[surf_no].surface->pitch * magnification;
|
||||
|
||||
const unsigned long *src_ptr = (unsigned long*)src_row;
|
||||
unsigned long *dst_ptr = (unsigned long*)dst_row;
|
||||
|
||||
for (int w = 0; w < converted_surface->w; ++w)
|
||||
{
|
||||
const unsigned long src_pixel = *src_row++;
|
||||
const unsigned long src_pixel = *src_ptr++;
|
||||
|
||||
for (int i = 0; i < magnification; ++i)
|
||||
*dst_row++ = src_pixel;
|
||||
*dst_ptr++ = src_pixel;
|
||||
}
|
||||
|
||||
for (int i = 1; i < magnification; ++i)
|
||||
memcpy(dst_pixels[(h * magnification) + i], dst_pixels[h * magnification], surf[surf_no].surface->w * sizeof(unsigned long));
|
||||
memcpy(dst_row + i * surf[surf_no].surface->pitch, dst_row, surf[surf_no].surface->w * sizeof(unsigned long));
|
||||
}
|
||||
|
||||
SDL_FreeSurface(converted_surface);
|
||||
|
|
22
src/Font.cpp
22
src/Font.cpp
|
@ -58,7 +58,7 @@ static unsigned long UTF8ToCode(const unsigned char *string, unsigned int *bytes
|
|||
case 3:
|
||||
case 4:
|
||||
length = zero_bit;
|
||||
charcode = string[0] & ((1 << (8 - zero_bit))) - 1;
|
||||
charcode = string[0] & ((1 << (8 - zero_bit)) - 1);
|
||||
|
||||
for (unsigned int i = 1; i < zero_bit; ++i)
|
||||
{
|
||||
|
@ -181,8 +181,6 @@ void DrawText(FontObject *font_object, SDL_Surface *surface, int x, int y, unsig
|
|||
{
|
||||
const unsigned char colours[3] = {(unsigned char)(colour >> 16), (unsigned char)(colour >> 8), (unsigned char)colour};
|
||||
|
||||
unsigned char (*surface_buffer)[surface->pitch / 4][4] = (unsigned char (*)[surface->pitch / 4][4])surface->pixels;
|
||||
|
||||
FT_Face face = font_object->face;
|
||||
|
||||
unsigned int pen_x = 0;
|
||||
|
@ -236,10 +234,8 @@ void DrawText(FontObject *font_object, SDL_Surface *surface, int x, int y, unsig
|
|||
{
|
||||
for (int ix = MAX(-letter_x, 0); letter_x + ix < MIN(letter_x + (int)converted.width / 3, surface->w); ++ix)
|
||||
{
|
||||
const unsigned char (*font_buffer)[converted.pitch / 3][3] = (unsigned char (*)[converted.pitch / 3][3])converted.buffer;
|
||||
|
||||
const unsigned char *font_pixel = font_buffer[iy][ix];
|
||||
unsigned char *surface_pixel = surface_buffer[letter_y + iy][letter_x + ix];
|
||||
const unsigned char *font_pixel = converted.buffer + iy * converted.pitch + ix * 3;
|
||||
unsigned char *surface_pixel = (unsigned char*)surface->pixels + (letter_y + iy) * surface->pitch + (letter_x + ix) * 4;
|
||||
|
||||
if (font_pixel[0] || font_pixel[1] || font_pixel[2])
|
||||
{
|
||||
|
@ -257,11 +253,11 @@ void DrawText(FontObject *font_object, SDL_Surface *surface, int x, int y, unsig
|
|||
{
|
||||
for (int ix = MAX(-letter_x, 0); letter_x + ix < MIN(letter_x + (int)converted.width, surface->w); ++ix)
|
||||
{
|
||||
unsigned char (*font_buffer)[converted.pitch] = (unsigned char (*)[converted.pitch])converted.buffer;
|
||||
const unsigned char font_pixel = converted.buffer[iy * converted.pitch + ix];
|
||||
|
||||
const double alpha = pow((double)font_buffer[iy][ix] / (converted.num_grays - 1), 1.0 / 1.8); // Gamma-corrected
|
||||
const double alpha = pow((double)font_pixel / (converted.num_grays - 1), 1.0 / 1.8); // Gamma-corrected
|
||||
|
||||
unsigned char *surface_pixel = surface_buffer[letter_y + iy][letter_x + ix];
|
||||
unsigned char *surface_pixel = (unsigned char*)surface->pixels + (letter_y + iy) * surface->pitch + (letter_x + ix) * 4;
|
||||
|
||||
if (alpha)
|
||||
{
|
||||
|
@ -276,11 +272,11 @@ void DrawText(FontObject *font_object, SDL_Surface *surface, int x, int y, unsig
|
|||
{
|
||||
for (int ix = MAX(-letter_x, 0); letter_x + ix < MIN(letter_x + (int)converted.width, surface->w); ++ix)
|
||||
{
|
||||
unsigned char (*font_buffer)[converted.pitch] = (unsigned char (*)[converted.pitch])converted.buffer;
|
||||
const unsigned char font_pixel = converted.buffer[iy * converted.pitch + ix];
|
||||
|
||||
unsigned char *surface_pixel = surface_buffer[letter_y + iy][letter_x + ix];
|
||||
unsigned char *surface_pixel = (unsigned char*)surface->pixels + (letter_y + iy) * surface->pitch + (letter_x + ix) * 4;
|
||||
|
||||
if (font_buffer[iy][ix])
|
||||
if (font_pixel)
|
||||
{
|
||||
for (unsigned int j = 0; j < 3; ++j)
|
||||
surface_pixel[j] = colours[j];
|
||||
|
|
|
@ -1178,7 +1178,7 @@ void ActNpc173(NPCHAR *npc)
|
|||
|
||||
if (npc->ym > 0x5FF)
|
||||
npc->ym = 0x5FF;
|
||||
if ( npc->ym < -0x5FFu )
|
||||
if (npc->ym < -0x5FF)
|
||||
npc->ym = 0x5FF;
|
||||
|
||||
npc->x += npc->xm;
|
||||
|
|
|
@ -564,6 +564,7 @@ void ActNpc184(NPCHAR *npc)
|
|||
npc->ani_no = 1;
|
||||
npc->act_wait = 0;
|
||||
npc->bits |= npc_ignoreSolid;
|
||||
// Fallthrough
|
||||
case 11:
|
||||
switch (npc->direct)
|
||||
{
|
||||
|
@ -960,11 +961,6 @@ void ActNpc190(NPCHAR *npc)
|
|||
//Water level
|
||||
void ActNpc191(NPCHAR *npc)
|
||||
{
|
||||
int v1; // edx
|
||||
int v2; // edx
|
||||
int v3; // edx
|
||||
int v4; // edx
|
||||
|
||||
switch ( npc->act_no )
|
||||
{
|
||||
case 0:
|
||||
|
|
|
@ -515,7 +515,7 @@ void ActNpc326(NPCHAR *npc)
|
|||
npc->act_no = 41;
|
||||
npc->act_wait = 0;
|
||||
npc->ani_no = 0;
|
||||
//Fallthorugh
|
||||
//Fallthrough
|
||||
case 41:
|
||||
if (++npc->act_wait == 30)
|
||||
npc->ani_no = 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue