Merge pull request #70 from Clownacy/master

Bugfixes
This commit is contained in:
Cucky 2019-02-22 16:16:13 -05:00 committed by GitHub
commit 68895b1597
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 433 additions and 350 deletions

View file

@ -35,14 +35,16 @@ ifeq ($(WINDOWS), 1)
endif endif
CXXFLAGS += -std=c++98 `sdl2-config --cflags` `pkg-config freetype2 --cflags` -MMD -MP -MF $@.d CXXFLAGS += -std=c++98 `sdl2-config --cflags` `pkg-config freetype2 --cflags` -MMD -MP -MF $@.d
LIBS += `sdl2-config --static-libs` `pkg-config freetype2 --libs` LIBS += `pkg-config freetype2 --libs`
ifeq ($(STATIC), 1) ifeq ($(STATIC), 1)
CXXFLAGS += -static CXXFLAGS += `sdl2-config --static-libs` -static
LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2 LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2
ifeq ($(WINDOWS), 1) ifeq ($(WINDOWS), 1)
LIBS += -lRpcrt4 -lDwrite -lusp10 LIBS += -lRpcrt4 -lDwrite -lusp10
endif endif
else
CXXFLAGS += `sdl2-config --libs`
endif endif
# For an accurate result to the original's code, compile in alphabetical order # For an accurate result to the original's code, compile in alphabetical order

View file

@ -14,9 +14,13 @@
BACK gBack; BACK gBack;
int gWaterY; int gWaterY;
static unsigned long color_black;
BOOL InitBack(const char *fName, int type) BOOL InitBack(const char *fName, int type)
{ {
// Unused, hilariously
color_black = GetCortBoxColor(RGB(0, 0, 0x10));
//Get width and height //Get width and height
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s.pbm", gDataPath, fName); sprintf(path, "%s/%s.pbm", gDataPath, fName);
@ -46,8 +50,10 @@ BOOL InitBack(const char *fName, int type)
// This is ridiculously platform-dependant: // This is ridiculously platform-dependant:
// It should break on big-endian CPUs, and platforms // It should break on big-endian CPUs, and platforms
// where short isn't 16-bit and long isn't 32-bit. // where short isn't 16-bit and long isn't 32-bit.
short bmp_header_buffer[7]; // short bmp_header_buffer[7];
long bmp_header_buffer2[10]; // long bmp_header_buffer2[10];
int16_t bmp_header_buffer[7];
int32_t bmp_header_buffer2[10]; // We'll need a better solution when we stop using stdint.h
fread(bmp_header_buffer, 14, 1, fp); fread(bmp_header_buffer, 14, 1, fp);

View file

@ -291,7 +291,7 @@ static bool LoadBitmap(SDL_RWops *fp, Surface_Ids surf_no, bool create_surface)
} }
for (int i = 1; i < magnification; ++i) for (int i = 1; i < magnification; ++i)
memcpy(dst_row + i * surf[surf_no].surface->pitch, dst_row, surf[surf_no].surface->w * sizeof(unsigned long)); memcpy(dst_row + i * surf[surf_no].surface->pitch, dst_row, surf[surf_no].surface->w * 4);
} }
SDL_FreeSurface(converted_surface); SDL_FreeSurface(converted_surface);
@ -474,13 +474,22 @@ void Surface2Surface(int x, int y, RECT *rect, int to, int from)
surf[to].needs_updating = true; surf[to].needs_updating = true;
} }
unsigned long GetCortBoxColor(unsigned long col)
{
// This comes in BGR, and goes out BGR
return col;
}
void CortBox(RECT *rect, uint32_t col) void CortBox(RECT *rect, uint32_t col)
{ {
//Get rect //Get rect
SDL_Rect destRect = RectToSDLRectScaled(rect); SDL_Rect destRect = RectToSDLRectScaled(rect);
//Set colour and draw //Set colour and draw
SDL_SetRenderDrawColor(gRenderer, (col & 0xFF0000) >> 16, (col & 0x00FF00) >> 8, col & 0x0000FF, 0xFF); const unsigned char col_red = col & 0x0000FF;
const unsigned char col_green = (col & 0x00FF00) >> 8;
const unsigned char col_blue = (col & 0xFF0000) >> 16;
SDL_SetRenderDrawColor(gRenderer, col_red, col_green, col_blue, 0xFF);
SDL_RenderFillRect(gRenderer, &destRect); SDL_RenderFillRect(gRenderer, &destRect);
} }
@ -489,9 +498,10 @@ void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no)
//Get rect //Get rect
SDL_Rect destRect = RectToSDLRectScaled(rect); SDL_Rect destRect = RectToSDLRectScaled(rect);
const unsigned char col_red = (col & 0xFF0000) >> 16; //Set colour and draw
const unsigned char col_red = col & 0x0000FF;
const unsigned char col_green = (col & 0x00FF00) >> 8; const unsigned char col_green = (col & 0x00FF00) >> 8;
const unsigned char col_blue = col & 0x0000FF; const unsigned char col_blue = (col & 0xFF0000) >> 16;
SDL_FillRect(surf[surf_no].surface, &destRect, SDL_MapRGB(surf[surf_no].surface->format, col_red, col_green, col_blue)); SDL_FillRect(surf[surf_no].surface, &destRect, SDL_MapRGB(surf[surf_no].surface->format, col_red, col_green, col_blue));
surf[surf_no].needs_updating = true; surf[surf_no].needs_updating = true;
} }

View file

@ -4,6 +4,10 @@
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#ifndef RGB
#define RGB(r,g,b) ((r) | ((g) << 8) | ((b) << 16))
#endif
extern RECT grcGame; extern RECT grcGame;
extern RECT grcFull; extern RECT grcFull;
@ -63,6 +67,7 @@ void BackupSurface(Surface_Ids surf_no, RECT *rect);
void PutBitmap3(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no); 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 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 Surface2Surface(int x, int y, RECT *rect, int to, int from);
unsigned long GetCortBoxColor(unsigned long col);
void CortBox(RECT *rect, uint32_t col); void CortBox(RECT *rect, uint32_t col);
void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no); void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no);
void InitTextObject(const char *font_name); void InitTextObject(const char *font_name);

View file

@ -75,7 +75,7 @@ void SetStripper(int x, int y, char *text, int cast)
//Draw text //Draw text
RECT rc = {0, 16 * s, 320, 16 * s + 16}; RECT rc = {0, 16 * s, 320, 16 * s + 16};
CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST); CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST);
PutText2(0, 16 * s, text, 0xFFFFFE, SURFACE_ID_CREDIT_CAST); PutText2(0, 16 * s, text, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_CREDIT_CAST);
break; break;
} }
} }
@ -90,7 +90,7 @@ void RestoreStripper()
{ {
RECT rc = {0, 16 * s, 320, 16 * s + 16}; RECT rc = {0, 16 * s, 320, 16 * s + 16};
CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST); CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST);
PutText2(0, rc.top, Strip[s].str, 0xFFFFFE, SURFACE_ID_CREDIT_CAST); PutText2(0, rc.top, Strip[s].str, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_CREDIT_CAST);
} }
} }
} }

View file

@ -2,26 +2,42 @@
#include <string.h> #include <string.h>
#include "CommonDefines.h"
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#include "Draw.h" #include "Draw.h"
#include "Game.h" #include "Game.h"
FADE gFade; #define FADE_WIDTH (((WINDOW_WIDTH - 1) / 16) + 1)
#define FADE_HEIGHT (((WINDOW_HEIGHT - 1) / 16) + 1)
struct FADE
{
int mode;
BOOL bMask;
int count;
char ani_no[FADE_HEIGHT][FADE_WIDTH];
BOOLEAN flag[FADE_HEIGHT][FADE_WIDTH];
char dir;
};
static FADE gFade;
static unsigned long mask_color;
void InitFade() void InitFade()
{ {
memset(&gFade, 0, sizeof(FADE)); memset(&gFade, 0, sizeof(FADE));
mask_color = GetCortBoxColor(RGB(0, 0, 0x20));
} }
void SetFadeMask() void SetFadeMask()
{ {
gFade.bMask = true; gFade.bMask = TRUE;
} }
void ClearFade() void ClearFade()
{ {
gFade.bMask = false; gFade.bMask = FALSE;
gFade.mode = 0; gFade.mode = 0;
} }
@ -30,239 +46,248 @@ void StartFadeOut(char dir)
gFade.mode = 2; gFade.mode = 2;
gFade.count = 0; gFade.count = 0;
gFade.dir = dir; gFade.dir = dir;
gFade.bMask = false; gFade.bMask = FALSE;
for (int y = 0; y < FADE_HEIGHT; y++) for (int y = 0; y < FADE_HEIGHT; y++)
{ {
for (int x = 0; x < FADE_WIDTH; x++) for (int x = 0; x < FADE_WIDTH; x++)
{ {
gFade.ani_no[y][x] = 0; gFade.ani_no[y][x] = 0;
gFade.flag[y][x] = 0; gFade.flag[y][x] = FALSE;
} }
} }
} }
void StartFadeIn(char dir) void StartFadeIn(char dir)
{ {
int x;
int y;
gFade.mode = 1; gFade.mode = 1;
gFade.count = 0; gFade.count = 0;
gFade.dir = dir; gFade.dir = dir;
gFade.bMask = true; gFade.bMask = TRUE;
for (int y = 0; y < FADE_HEIGHT; y++) for (y = 0; y < FADE_HEIGHT; y++)
{ {
for (int x = 0; x < FADE_WIDTH; x++) for (x = 0; x < FADE_WIDTH; x++)
{ {
gFade.ani_no[y][x] = 15; gFade.ani_no[y][x] = 15;
gFade.flag[y][x] = 0; gFade.flag[y][x] = FALSE;
} }
} }
x = x; // What
} }
void ProcFade() void ProcFade()
{ {
if (gFade.mode == 1) int x;
int y;
switch (gFade.mode)
{ {
gFade.bMask = false; case 2:
switch (gFade.dir)
switch (gFade.dir)
{
case 0:
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x <= FADE_WIDTH; x++)
{
if ((FADE_WIDTH - 1) - gFade.count == x)
gFade.flag[y][x] = 1;
}
}
break;
case 1:
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x < FADE_WIDTH; x++)
{
if ((FADE_HEIGHT - 1) - gFade.count == y)
gFade.flag[y][x] = 1;
}
}
break;
case 2:
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x < FADE_WIDTH; x++)
{
if (gFade.count == x)
gFade.flag[y][x] = 1;
}
}
break;
case 3:
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x < FADE_WIDTH; x++)
{
if (gFade.count == y)
gFade.flag[y][x] = 1;
}
}
break;
case 4:
for (int y = 0; y < (FADE_HEIGHT / 2); y++)
{
for (int x = 0; x < (FADE_WIDTH / 2); x++)
{
if ((FADE_WIDTH - 1) - gFade.count == x + y)
gFade.flag[y][x] = 1;
}
}
for (int y = 0; y < (FADE_HEIGHT / 2); y++)
{
for (int x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
{
if ((FADE_WIDTH - 1) - gFade.count == y + ((FADE_WIDTH - 1) - x))
gFade.flag[y][x] = 1;
}
}
for (int y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
{
for (int x = 0; x < (FADE_WIDTH / 2); x++)
{
if ((FADE_WIDTH - 1) - gFade.count == x + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = 1;
}
}
for (int y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
{
for (int x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
{
if ((FADE_WIDTH - 1) - gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = 1;
}
}
break;
default:
break;
}
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x < FADE_WIDTH; x++)
{ {
if (gFade.ani_no[y][x] > 0 && gFade.flag[y][x]) case 0:
--gFade.ani_no[y][x]; for (y = 0; y < FADE_HEIGHT; y++)
{
for (x = 0; x < FADE_WIDTH; x++)
{
if ((FADE_WIDTH - 1) - gFade.count == x)
gFade.flag[y][x] = TRUE;
}
}
break;
case 2:
for (y = 0; y < FADE_HEIGHT; y++)
{
for (x = 0; x < FADE_WIDTH; x++)
{
if (gFade.count == x)
gFade.flag[y][x] = TRUE;
}
}
break;
case 1:
for (y = 0; y < FADE_HEIGHT; y++)
{
for (x = 0; x < FADE_WIDTH; x++)
{
if ((FADE_HEIGHT - 1) - gFade.count == y)
gFade.flag[y][x] = TRUE;
}
}
break;
case 3:
for (y = 0; y < FADE_HEIGHT; y++)
{
for (x = 0; x < FADE_WIDTH; x++)
{
if (gFade.count == y)
gFade.flag[y][x] = TRUE;
}
}
break;
case 4:
for (y = 0; y < (FADE_HEIGHT / 2); y++)
{
for (x = 0; x < (FADE_WIDTH / 2); x++)
{
if (gFade.count == x + y)
gFade.flag[y][x] = TRUE;
}
}
for (y = 0; y < (FADE_HEIGHT / 2); y++)
{
for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
{
if (gFade.count == y + ((FADE_WIDTH - 1) - x))
gFade.flag[y][x] = TRUE;
}
}
for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
{
for (x = 0; x < (FADE_WIDTH / 2); x++)
{
if (gFade.count == x + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = TRUE;
}
}
for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
{
for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
{
if (gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = TRUE;
}
}
break;
} }
}
for (y = 0; y < FADE_HEIGHT; y++)
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
gFade.mode = 0;
}
else if (gFade.mode == 2)
{
switch (gFade.dir)
{
case 0:
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x <= FADE_WIDTH; x++)
{
if ((FADE_WIDTH - 1) - gFade.count == x)
gFade.flag[y][x] = 1;
}
}
break;
case 1:
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x < FADE_WIDTH; x++)
{
if ((FADE_HEIGHT - 1) - gFade.count == y)
gFade.flag[y][x] = 1;
}
}
break;
case 2:
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x < FADE_WIDTH; x++)
{
if (gFade.count == x)
gFade.flag[y][x] = 1;
}
}
break;
case 3:
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x < FADE_WIDTH; x++)
{
if (gFade.count == y)
gFade.flag[y][x] = 1;
}
}
break;
case 4:
for (int y = 0; y < (FADE_HEIGHT / 2); y++)
{
for (int x = 0; x < (FADE_WIDTH / 2); x++)
{
if (gFade.count == x + y)
gFade.flag[y][x] = 1;
}
}
for (int y = 0; y < (FADE_HEIGHT / 2); y++)
{
for (int x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
{
if (gFade.count == y + ((FADE_WIDTH - 1) - x))
gFade.flag[y][x] = 1;
}
}
for (int y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
{
for (int x = 0; x < (FADE_WIDTH / 2); x++)
{
if (gFade.count == x + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = 1;
}
}
for (int y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
{
for (int x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
{
if (gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = 1;
}
}
break;
default:
break;
}
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x < FADE_WIDTH; x++)
{ {
if (gFade.ani_no[y][x] < 15 && gFade.flag[y][x]) for (x = 0; x < FADE_WIDTH; x++)
++gFade.ani_no[y][x]; {
if (gFade.ani_no[y][x] < 15 && gFade.flag[y][x])
++gFade.ani_no[y][x];
}
} }
}
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16) {
{ gFade.bMask = TRUE;
gFade.bMask = true; gFade.mode = 0;
gFade.mode = 0; }
}
break;
case 1:
gFade.bMask = FALSE;
switch (gFade.dir)
{
case 0:
for (y = 0; y < FADE_HEIGHT; y++)
{
for (x = 0; x < FADE_WIDTH; x++)
{
if ((FADE_WIDTH - 1) - gFade.count == x)
gFade.flag[y][x] = TRUE;
}
}
break;
case 2:
for (y = 0; y < FADE_HEIGHT; y++)
{
for (x = 0; x < FADE_WIDTH; x++)
{
if (gFade.count == x)
gFade.flag[y][x] = TRUE;
}
}
break;
case 1:
for (y = 0; y < FADE_HEIGHT; y++)
{
for (x = 0; x < FADE_WIDTH; x++)
{
if ((FADE_HEIGHT - 1) - gFade.count == y)
gFade.flag[y][x] = TRUE;
}
}
break;
case 3:
for (y = 0; y < FADE_HEIGHT; y++)
{
for (x = 0; x < FADE_WIDTH; x++)
{
if (gFade.count == y)
gFade.flag[y][x] = TRUE;
}
}
break;
case 4:
for (y = 0; y < (FADE_HEIGHT / 2); y++)
{
for (x = 0; x < (FADE_WIDTH / 2); x++)
{
if ((FADE_WIDTH - 1) - gFade.count == x + y)
gFade.flag[y][x] = TRUE;
}
}
for (y = 0; y < (FADE_HEIGHT / 2); y++)
{
for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
{
if ((FADE_WIDTH - 1) - gFade.count == y + ((FADE_WIDTH - 1) - x))
gFade.flag[y][x] = TRUE;
}
}
for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
{
for (x = 0; x < (FADE_WIDTH / 2); x++)
{
if ((FADE_WIDTH - 1) - gFade.count == x + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = TRUE;
}
}
for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
{
for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
{
if ((FADE_WIDTH - 1) - gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = TRUE;
}
}
break;
default:
break;
}
for (y = 0; y < FADE_HEIGHT; y++)
{
for (x = 0; x < FADE_WIDTH; x++)
{
if (gFade.ani_no[y][x] > 0 && gFade.flag[y][x])
--gFade.ani_no[y][x];
}
}
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
gFade.mode = 0;
break;
} }
} }
@ -274,23 +299,28 @@ void PutFade()
if (gFade.bMask) if (gFade.bMask)
{ {
CortBox(&grcGame, 0x000020); CortBox(&grcGame, mask_color);
return;
} }
else if (gFade.mode)
if (gFade.mode == 0)
return;
for (int y = 0; y < FADE_HEIGHT; y++)
{ {
for (int y = 0; y < FADE_HEIGHT; y++) for (int x = 0; x < FADE_WIDTH; x++)
{ {
for (int x = 0; x < FADE_WIDTH; x++) rect.left = 16 * gFade.ani_no[y][x];
{ rect.right = rect.left + 16;
rect.left = 16 * gFade.ani_no[y][x]; PutBitmap3(&grcGame, 16 * x, 16 * y, &rect, SURFACE_ID_FADE);
rect.right = rect.left + 16;
PutBitmap3(&grcGame, 16 * x, 16 * y, &rect, SURFACE_ID_FADE);
}
} }
} }
} }
bool GetFadeActive() BOOL GetFadeActive()
{ {
return gFade.mode != 0; if (gFade.mode == 0)
return FALSE;
else
return TRUE;
} }

View file

@ -1,19 +1,6 @@
#pragma once #pragma once
#include "CommonDefines.h" #include "WindowsWrapper.h"
#define FADE_WIDTH (((WINDOW_WIDTH - 1) >> 4) + 1)
#define FADE_HEIGHT (((WINDOW_HEIGHT - 1) >> 4) + 1)
struct FADE
{
int mode;
bool bMask;
int count;
char ani_no[FADE_HEIGHT][FADE_WIDTH];
char flag[FADE_HEIGHT][FADE_WIDTH];
char dir;
};
void InitFade(); void InitFade();
void SetFadeMask(); void SetFadeMask();
@ -22,4 +9,4 @@ void StartFadeOut(char dir);
void StartFadeIn(char dir); void StartFadeIn(char dir);
void ProcFade(); void ProcFade();
void PutFade(); void PutFade();
bool GetFadeActive(); BOOL GetFadeActive();

View file

@ -1,10 +1,11 @@
#include "Flags.h" #include "Flags.h"
#include <stdint.h>
#include <string.h> #include <string.h>
uint8_t gFlagNPC[1000]; #include "WindowsWrapper.h"
uint8_t gSkipFlag[0x40];
unsigned char gFlagNPC[1000];
unsigned char gSkipFlag[0x40];
//Flag inits //Flag inits
void InitFlags() void InitFlags()
@ -18,33 +19,39 @@ void InitSkipFlags()
} }
//NPC flags //NPC flags
void SetNPCFlag(int a) void SetNPCFlag(long a)
{ {
gFlagNPC[a / 8] |= 1 << a % 8; gFlagNPC[a / 8] |= 1 << a % 8;
} }
void CutNPCFlag(int a) void CutNPCFlag(long a)
{ {
gFlagNPC[a / 8] &= ~(1 << a % 8); gFlagNPC[a / 8] &= ~(1 << a % 8);
} }
bool GetNPCFlag(int a) BOOL GetNPCFlag(long a)
{ {
return ((gFlagNPC[a / 8] >> a % 8) & 1) != 0; if (gFlagNPC[a / 8] & (1 << a % 8))
return TRUE;
else
return FALSE;
} }
//Skip flags //Skip flags
void SetSkipFlag(int a) void SetSkipFlag(long a)
{ {
gSkipFlag[a / 8] |= 1 << a % 8; gSkipFlag[a / 8] |= 1 << a % 8;
} }
void CutSkipFlag(int a) void CutSkipFlag(long a)
{ {
gSkipFlag[a / 8] &= ~(1 << a % 8); gSkipFlag[a / 8] &= ~(1 << a % 8);
} }
bool GetSkipFlag(int a) BOOL GetSkipFlag(long a)
{ {
return ((gSkipFlag[a / 8] >> a % 8) & 1) != 0; if (gSkipFlag[a / 8] & (1 << a % 8))
return TRUE;
else
return FALSE;
} }

View file

@ -1,15 +1,15 @@
#pragma once #pragma once
#include <stdint.h> #include "WindowsWrapper.h"
extern uint8_t gFlagNPC[1000]; extern unsigned char gFlagNPC[1000];
extern uint8_t gSkipFlag[0x40]; extern unsigned char gSkipFlag[0x40];
void InitFlags(); void InitFlags();
void InitSkipFlags(); void InitSkipFlags();
void SetNPCFlag(int a); void SetNPCFlag(long a);
void CutNPCFlag(int a); void CutNPCFlag(long a);
bool GetNPCFlag(int a); BOOL GetNPCFlag(long a);
void SetSkipFlag(int a); void SetSkipFlag(long a);
void CutSkipFlag(int a); void CutSkipFlag(long a);
bool GetSkipFlag(int a); BOOL GetSkipFlag(long a);

View file

@ -21,7 +21,7 @@ static unsigned long gFlashColor;
void InitFlash(void) void InitFlash(void)
{ {
gFlashColor = 0xFEFFFF; gFlashColor = GetCortBoxColor(RGB(0xFF, 0xFF, 0xFE));
} }
void SetFlash(int x, int y, int mode) void SetFlash(int x, int y, int mode)
@ -137,34 +137,26 @@ void ActFlash_Flash(void)
void ActFlash(int flx, int fly) void ActFlash(int flx, int fly)
{ {
if (flash.flag == FALSE) if (flash.flag == FALSE)
return;
switch (flash.mode)
{ {
// Do nothing case 1:
} ActFlash_Explosion(flx, fly);
else break;
{ case 2:
switch (flash.mode) ActFlash_Flash();
{ break;
case 1:
ActFlash_Explosion(flx, fly);
break;
case 2:
ActFlash_Flash();
break;
}
} }
} }
void PutFlash(void) void PutFlash(void)
{ {
if (flash.flag == FALSE) if (flash.flag == FALSE)
{ return;
// Do nothing
} CortBox(&flash.rect1, gFlashColor);
else CortBox(&flash.rect2, gFlashColor);
{
CortBox(&flash.rect1, gFlashColor);
CortBox(&flash.rect2, gFlashColor);
}
} }
void ResetFlash(void) void ResetFlash(void)

View file

@ -1,6 +1,5 @@
#include "Font.h" #include "Font.h"
#include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View file

@ -1,6 +1,7 @@
#include "Game.h" #include "Game.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <string.h> #include <string.h>
#include <SDL_timer.h> #include <SDL_timer.h>
@ -266,6 +267,7 @@ int ModeTitle()
int anime = 0; int anime = 0;
int char_type = 0; int char_type = 0;
int time_counter = 0; int time_counter = 0;
unsigned long back_color = GetCortBoxColor(RGB(0x20, 0x20, 0x20));
//Set state //Set state
bContinue = IsProfile(); bContinue = IsProfile();
@ -355,7 +357,7 @@ int ModeTitle()
anime = 0; anime = 0;
//Draw title //Draw title
CortBox(&grcGame, 0x202020); CortBox(&grcGame, back_color);
//Draw version //Draw version
PutBitmap3(&grcGame, (WINDOW_WIDTH - 120) / 2, WINDOW_HEIGHT - 24, &rcVersion, SURFACE_ID_TEXT_BOX); PutBitmap3(&grcGame, (WINDOW_WIDTH - 120) / 2, WINDOW_HEIGHT - 24, &rcVersion, SURFACE_ID_TEXT_BOX);
@ -442,7 +444,9 @@ int ModeAction()
{ {
int frame_x = 0; int frame_x = 0;
int frame_y = 0; int frame_y = 0;
unsigned long color = GetCortBoxColor(RGB(0, 0, 0x20));
bool swPlay = true; bool swPlay = true;
//Reset stuff //Reset stuff
@ -524,7 +528,7 @@ int ModeAction()
} }
ProcFade(); ProcFade();
CortBox(&grcFull, 0x000020); CortBox(&grcFull, color);
GetFramePosition(&frame_x, &frame_y); GetFramePosition(&frame_x, &frame_y);
PutBack(frame_x, frame_y); PutBack(frame_x, frame_y);
PutStage_Back(frame_x, frame_y); PutStage_Back(frame_x, frame_y);

View file

@ -2,6 +2,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include <SDL.h> #include <SDL.h>

View file

@ -36,8 +36,8 @@ void ReadyMapName(const char *str)
int len = strlen(gMapName.name); int len = strlen(gMapName.name);
CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
PutText2((-6 * len + 160) / 2 + 6, 1, gMapName.name, 0x110022, SURFACE_ID_ROOM_NAME); PutText2((-6 * len + 160) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
PutText2((-6 * len + 160) / 2 + 6, 0, gMapName.name, 0xFFFFFE, SURFACE_ID_ROOM_NAME); PutText2((-6 * len + 160) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
} }
void PutMapName(bool bMini) void PutMapName(bool bMini)
@ -69,6 +69,6 @@ void RestoreMapName()
int len = strlen(gMapName.name); int len = strlen(gMapName.name);
CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
PutText2((-6 * len + 160) / 2 + 6, 1, gMapName.name, 0x110022, SURFACE_ID_ROOM_NAME); PutText2((-6 * len + 160) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
PutText2((-6 * len + 160) / 2 + 6, 0, gMapName.name, 0xFFFFFE, SURFACE_ID_ROOM_NAME); PutText2((-6 * len + 160) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
} }

View file

@ -239,9 +239,10 @@ bool SetBulletObject(int x, int y, int val)
{ {
int tamakazu_ari[10]; int tamakazu_ari[10];
int n;
int t = 0; int t = 0;
memset(tamakazu_ari, 0, sizeof(tamakazu_ari)); memset(tamakazu_ari, 0, sizeof(tamakazu_ari));
for (int n = 0; n < 8; n++) for (n = 0; n < 8; n++)
{ {
int code = gArmsData[n].code; int code = gArmsData[n].code;
if (code == 5) if (code == 5)
@ -255,7 +256,7 @@ bool SetBulletObject(int x, int y, int val)
if (!t) if (!t)
return false; return false;
int n = Random(1, 10 * t); n = Random(1, 10 * t);
int bullet_no = tamakazu_ari[n % t]; int bullet_no = tamakazu_ari[n % t];
for (n = 0x100; n < NPC_MAX; n++) for (n = 0x100; n < NPC_MAX; n++)
{ {

View file

@ -2,6 +2,7 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <string.h>
#include <SDL_rwops.h> #include <SDL_rwops.h>
#include <SDL_thread.h> #include <SDL_thread.h>

View file

@ -1,7 +1,7 @@
#include "Sound.h" #include "Sound.h"
#include <algorithm> #include <algorithm>
#include <math.h> #include <cmath>
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>

View file

@ -46,9 +46,17 @@ char text[0x100];
RECT gRect_line = {0, 0, 216, 16}; RECT gRect_line = {0, 0, 216, 16};
#ifdef FIX_BUGS
static unsigned long nod_color;
#endif
//Initialize and end tsc //Initialize and end tsc
BOOL InitTextScript2() BOOL InitTextScript2()
{ {
#ifdef FIX_BUGS
nod_color = GetCortBoxColor(RGB(0xFF, 0xFF, 0xFE));
#endif
//Clear flags //Clear flags
gTS.mode = 0; gTS.mode = 0;
g_GameFlags &= ~0x04; g_GameFlags &= ~0x04;
@ -359,7 +367,7 @@ void SetNumberTextScript(int index)
str[offset + 1] = 0; str[offset + 1] = 0;
//Append number to line //Append number to line
PutText2(6 * gTS.p_write, 0, str, 0xFFFFFE, (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1)); PutText2(6 * gTS.p_write, 0, str, RGB(0xFF, 0xFF, 0xFE), (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1));
strcat(&text[gTS.line % 4 * 0x40], str); strcat(&text[gTS.line % 4 * 0x40], str);
//Play sound and reset blinking cursor //Play sound and reset blinking cursor
@ -456,7 +464,17 @@ void PutTextScript()
rect.top = gTS.ypos_line[gTS.line % 4] + gTS.rcText.top + gTS.offsetY; rect.top = gTS.ypos_line[gTS.line % 4] + gTS.rcText.top + gTS.offsetY;
rect.right = rect.left + 5; rect.right = rect.left + 5;
rect.bottom = rect.top + 11; rect.bottom = rect.top + 11;
CortBox(&rect, 0xFFFFFE); #ifdef FIX_BUGS
CortBox(&rect, nod_color);
// This is how the Linux port fixed this, but it isn't done
// the way Pixel would do it (he only calls GetCortBoxColor
// once, during init functions, so our fix does it that way
// instead).
//CortBox(&rect, GetCortBoxColor(RGB(0xFF, 0xFF, 0xFE));
#else
CortBox(&rect, RGB(0xFF, 0xFF, 0xFE));
#endif
} }
//Draw GIT //Draw GIT
@ -1235,7 +1253,7 @@ int TextScriptProc()
gTS.p_write = x; gTS.p_write = x;
//Print text //Print text
PutText2(0, 0, str, 0xFFFFFE, (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1)); PutText2(0, 0, str, RGB(0xFF, 0xFF, 0xFE), (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1));
sprintf(&text[gTS.line % 4 * 0x40], str); sprintf(&text[gTS.line % 4 * 0x40], str);
//Check if should move to next line (prevent a memory overflow, come on guys, this isn't a leftover of pixel trying to make text wrapping) //Check if should move to next line (prevent a memory overflow, come on guys, this isn't a leftover of pixel trying to make text wrapping)
@ -1269,7 +1287,7 @@ int TextScriptProc()
} }
else else
{ {
PutText2(6 * gTS.p_write, 0, c, 0xFFFFFE, (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1)); PutText2(6 * gTS.p_write, 0, c, RGB(0xFF, 0xFF, 0xFE), (Surface_Ids)(gTS.line % 4 + SURFACE_ID_TEXT_LINE1));
} }
strcat(&text[gTS.line % 4 * 0x40], c); strcat(&text[gTS.line % 4 * 0x40], c);

View file

@ -8,19 +8,19 @@ int16_t gTan[0x21];
void InitTriangleTable() void InitTriangleTable()
{ {
int i;
//Sine //Sine
for (int i = 0; i < 0x100; ++i ) for (i = 0; i < 0x100; ++i)
{ {
float v0 = i * 6.2831998 / 256.0; gSin[i] = (int)(sin(i * 6.2831998 / 256.0) * 512.0);
gSin[i] = (int)(sinf(v0) * 512.0);
} }
//Tangent //Tangent
for (int i = 0; i < 0x21; ++i ) for (i = 0; i < 0x21; ++i)
{ {
float a = i * 6.2831855 / 256.0; float a = i * 6.2831855 / 256.0;
float v2 = sinf(a); float b = sinf(a) / cosf(a);
float b = v2 / cosf(a);
gTan[i] = (int16_t)(b * 8192.0); gTan[i] = (int16_t)(b * 8192.0);
} }
} }
@ -32,70 +32,89 @@ int GetSin(uint8_t deg)
int GetCos(uint8_t deg) int GetCos(uint8_t deg)
{ {
return gSin[(uint8_t)(deg + 0x40)]; deg += 0x40;
return gSin[deg];
} }
int GetArktan(int x, int y) uint8_t GetArktan(int x, int y)
{ {
int xa = -x; x *= -1;
int ya = -y; y *= -1;
uint8_t a = 0; uint8_t a = 0;
int16_t k;
if (xa <= 0)
if (x > 0)
{ {
if (ya <= 0) if (y > 0)
{ {
if (-xa <= -ya) if (x > y)
{ {
while (gTan[a] < (int16_t)(-0x2000 * xa / -ya)) k = (y * 0x2000) / x;
while (k > gTan[a])
++a; ++a;
a = -0x40 - a;
} }
else else
{ {
while (gTan[a] < (int16_t)(-0x2000 * ya / -xa)) k = (x * 0x2000) / y;
while (k > gTan[a])
++a; ++a;
a += -0x80; a = 0x40 - a;
} }
} }
else if (-xa <= ya)
{
while (gTan[a] < (int16_t)(-0x2000 * xa / ya))
++a;
a += 0x40;
}
else else
{ {
while (gTan[a] < (int16_t)((ya << 13) / -xa)) if (-y < x)
++a; {
a = -0x80 - a; k = (-y * 0x2000) / x;
while (k > gTan[a])
++a;
a = 0x100 - a;
}
else
{
k = (x * 0x2000) / -y;
while (k > gTan[a])
++a;
a = 0x100 - 0x40 + a;
}
} }
} }
else if (ya <= 0)
{
if (-ya >= xa)
{
while (gTan[a] < (int16_t)((xa << 13) / -ya))
++a;
a -= 0x40;
}
else
{
while (gTan[a] < (int16_t)(-0x2000 * ya / xa))
++a;
a = -a;
}
}
else if (xa <= ya)
{
while (gTan[a] < (int16_t)((xa << 13) / ya))
++a;
a = 0x40 - a;
}
else else
{ {
while (gTan[a] < (int16_t)((ya << 13) / xa)) if (y > 0)
++a; {
if (-x > y)
{
k = (y * 0x2000) / -x;
while (k > gTan[a])
++a;
a = 0x80 - a;
}
else
{
k = (-x * 0x2000) / y;
while (k > gTan[a])
++a;
a = 0x40 + a;
}
}
else
{
if (-x > -y)
{
k = (-y * 0x2000) / -x;
while (k > gTan[a])
++a;
a = 0x80 + a;
}
else
{
k = (-x * 0x2000) / -y;
while (k > gTan[a])
++a;
a = 0x100 - 0x40 - a;
}
}
} }
return a; return a;

View file

@ -5,4 +5,4 @@
void InitTriangleTable(); void InitTriangleTable();
int GetSin(uint8_t deg); int GetSin(uint8_t deg);
int GetCos(uint8_t deg); int GetCos(uint8_t deg);
int GetArktan(int x, int y); uint8_t GetArktan(int x, int y);

View file

@ -4,6 +4,7 @@ int rep_rand();
void rep_srand(unsigned int seed); void rep_srand(unsigned int seed);
typedef int BOOL; typedef int BOOL;
typedef unsigned char BOOLEAN;
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0