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
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)
CXXFLAGS += -static
CXXFLAGS += `sdl2-config --static-libs` -static
LIBS += -lharfbuzz -lfreetype -lbz2 -lpng -lz -lgraphite2
ifeq ($(WINDOWS), 1)
LIBS += -lRpcrt4 -lDwrite -lusp10
endif
else
CXXFLAGS += `sdl2-config --libs`
endif
# For an accurate result to the original's code, compile in alphabetical order

View file

@ -14,9 +14,13 @@
BACK gBack;
int gWaterY;
static unsigned long color_black;
BOOL InitBack(const char *fName, int type)
{
// Unused, hilariously
color_black = GetCortBoxColor(RGB(0, 0, 0x10));
//Get width and height
char path[PATH_LENGTH];
sprintf(path, "%s/%s.pbm", gDataPath, fName);
@ -46,8 +50,10 @@ BOOL InitBack(const char *fName, int type)
// 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];
// short bmp_header_buffer[7];
// 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);

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)
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);
@ -474,13 +474,22 @@ void Surface2Surface(int x, int y, RECT *rect, int to, int from)
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)
{
//Get rect
SDL_Rect destRect = RectToSDLRectScaled(rect);
//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);
}
@ -489,9 +498,10 @@ void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no)
//Get 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_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));
surf[surf_no].needs_updating = true;
}

View file

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

View file

@ -75,7 +75,7 @@ void SetStripper(int x, int y, char *text, int cast)
//Draw text
RECT rc = {0, 16 * s, 320, 16 * s + 16};
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;
}
}
@ -90,7 +90,7 @@ void RestoreStripper()
{
RECT rc = {0, 16 * s, 320, 16 * s + 16};
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 "CommonDefines.h"
#include "WindowsWrapper.h"
#include "Draw.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()
{
memset(&gFade, 0, sizeof(FADE));
mask_color = GetCortBoxColor(RGB(0, 0, 0x20));
}
void SetFadeMask()
{
gFade.bMask = true;
gFade.bMask = TRUE;
}
void ClearFade()
{
gFade.bMask = false;
gFade.bMask = FALSE;
gFade.mode = 0;
}
@ -30,228 +46,133 @@ void StartFadeOut(char dir)
gFade.mode = 2;
gFade.count = 0;
gFade.dir = dir;
gFade.bMask = false;
gFade.bMask = FALSE;
for (int y = 0; y < FADE_HEIGHT; y++)
{
for (int x = 0; x < FADE_WIDTH; x++)
{
gFade.ani_no[y][x] = 0;
gFade.flag[y][x] = 0;
gFade.flag[y][x] = FALSE;
}
}
}
void StartFadeIn(char dir)
{
int x;
int y;
gFade.mode = 1;
gFade.count = 0;
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.flag[y][x] = 0;
gFade.flag[y][x] = FALSE;
}
}
x = x; // What
}
void ProcFade()
{
if (gFade.mode == 1)
{
gFade.bMask = false;
int x;
int y;
switch (gFade.mode)
{
case 2:
switch (gFade.dir)
{
case 0:
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++)
{
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;
gFade.flag[y][x] = TRUE;
}
}
break;
case 2:
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++)
{
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])
--gFade.ani_no[y][x];
}
}
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;
gFade.flag[y][x] = TRUE;
}
}
break;
case 1:
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++)
{
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;
gFade.flag[y][x] = TRUE;
}
}
break;
case 3:
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++)
{
if (gFade.count == y)
gFade.flag[y][x] = 1;
gFade.flag[y][x] = TRUE;
}
}
break;
case 4:
for (int y = 0; y < (FADE_HEIGHT / 2); y++)
for (y = 0; y < (FADE_HEIGHT / 2); y++)
{
for (int x = 0; x < (FADE_WIDTH / 2); x++)
for (x = 0; x < (FADE_WIDTH / 2); x++)
{
if (gFade.count == x + y)
gFade.flag[y][x] = 1;
gFade.flag[y][x] = TRUE;
}
}
for (int y = 0; y < (FADE_HEIGHT / 2); y++)
for (y = 0; y < (FADE_HEIGHT / 2); y++)
{
for (int x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
{
if (gFade.count == y + ((FADE_WIDTH - 1) - x))
gFade.flag[y][x] = 1;
gFade.flag[y][x] = TRUE;
}
}
for (int y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
{
for (int x = 0; x < (FADE_WIDTH / 2); x++)
for (x = 0; x < (FADE_WIDTH / 2); x++)
{
if (gFade.count == x + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = 1;
gFade.flag[y][x] = TRUE;
}
}
for (int y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
for (y = (FADE_HEIGHT / 2); y < FADE_HEIGHT; y++)
{
for (int x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
for (x = (FADE_WIDTH / 2); x < FADE_WIDTH; x++)
{
if (gFade.count == ((FADE_WIDTH - 1) - x) + ((FADE_HEIGHT - 1) - y))
gFade.flag[y][x] = 1;
gFade.flag[y][x] = TRUE;
}
}
break;
default:
break;
}
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++)
{
if (gFade.ani_no[y][x] < 15 && gFade.flag[y][x])
++gFade.ani_no[y][x];
@ -260,9 +181,113 @@ void ProcFade()
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
{
gFade.bMask = true;
gFade.bMask = TRUE;
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,10 +299,13 @@ void PutFade()
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 x = 0; x < FADE_WIDTH; x++)
@ -287,10 +315,12 @@ void PutFade()
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
#include "CommonDefines.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;
};
#include "WindowsWrapper.h"
void InitFade();
void SetFadeMask();
@ -22,4 +9,4 @@ void StartFadeOut(char dir);
void StartFadeIn(char dir);
void ProcFade();
void PutFade();
bool GetFadeActive();
BOOL GetFadeActive();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -36,8 +36,8 @@ void ReadyMapName(const char *str)
int len = strlen(gMapName.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, 0, gMapName.name, 0xFFFFFE, 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, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
}
void PutMapName(bool bMini)
@ -69,6 +69,6 @@ void RestoreMapName()
int len = strlen(gMapName.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, 0, gMapName.name, 0xFFFFFE, 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, 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 n;
int t = 0;
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;
if (code == 5)
@ -255,7 +256,7 @@ bool SetBulletObject(int x, int y, int val)
if (!t)
return false;
int n = Random(1, 10 * t);
n = Random(1, 10 * t);
int bullet_no = tamakazu_ari[n % t];
for (n = 0x100; n < NPC_MAX; n++)
{

View file

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

View file

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

View file

@ -46,9 +46,17 @@ char text[0x100];
RECT gRect_line = {0, 0, 216, 16};
#ifdef FIX_BUGS
static unsigned long nod_color;
#endif
//Initialize and end tsc
BOOL InitTextScript2()
{
#ifdef FIX_BUGS
nod_color = GetCortBoxColor(RGB(0xFF, 0xFF, 0xFE));
#endif
//Clear flags
gTS.mode = 0;
g_GameFlags &= ~0x04;
@ -359,7 +367,7 @@ void SetNumberTextScript(int index)
str[offset + 1] = 0;
//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);
//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.right = rect.left + 5;
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
@ -1235,7 +1253,7 @@ int TextScriptProc()
gTS.p_write = x;
//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);
//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
{
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);

View file

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

View file

@ -5,4 +5,4 @@
void InitTriangleTable();
int GetSin(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);
typedef int BOOL;
typedef unsigned char BOOLEAN;
#ifndef FALSE
#define FALSE 0