Merge branch 'develop' into feature/makeFlagsMacros

This commit is contained in:
Gabriel Ravier 2019-05-13 19:41:44 +02:00
commit 2cd6692a00
No known key found for this signature in database
GPG key ID: 1E75F156884F3DCE
49 changed files with 2334 additions and 1888 deletions

View file

@ -21,7 +21,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="SDL2/include;freetype/include;./"
AdditionalIncludeDirectories="SDL2/include;freetype/include"
PreprocessorDefinitions="WIN32;_DEBUG;WINDOWS;NONPORTABLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="0"
@ -73,7 +73,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="SDL2/include;freetype/include;./"
AdditionalIncludeDirectories="SDL2/include;freetype/include"
PreprocessorDefinitions="WIN32;NDEBUG;WINDOWS;NONPORTABLE"
MinimalRebuild="TRUE"
RuntimeLibrary="0"
@ -123,7 +123,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="SDL2/include;freetype/include;./"
AdditionalIncludeDirectories="SDL2/include;freetype/include"
PreprocessorDefinitions="WIN32;NDEBUG;WINDOWS;NONPORTABLE;JAPANESE"
MinimalRebuild="TRUE"
RuntimeLibrary="0"
@ -173,7 +173,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="SDL2/include;freetype/include;./"
AdditionalIncludeDirectories="SDL2/include;freetype/include"
PreprocessorDefinitions="WIN32;_DEBUG;WINDOWS;NONPORTABLE;JAPANESE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="0"

View file

@ -515,6 +515,190 @@ addr = 0x414B20
name = "SetMapping"
addr = 0x414B40
[[func]]
name = "InitMyChar"
addr = 0x414B50
[[func]]
name = "AnimationMyChar"
addr = 0x414BF0
[[func]]
name = "ShowMyChar"
addr = 0x415220
[[func]]
name = "PutMyChar"
addr = 0x415250
[[func]]
name = "ActMyChar_Normal"
addr = 0x4156C0
[[func]]
name = "ActMyChar_Stream"
addr = 0x416470
[[func]]
name = "ActMyChar"
addr = 0x4168C0
[[func]]
name = "AirProcess"
addr = 0x416990
[[func]]
name = "GetMyCharPosition"
addr = 0x416AA0
[[func]]
name = "SetMyCharPosition"
addr = 0x416AC0
[[func]]
name = "MoveMyChar"
addr = 0x416B30
[[func]]
name = "ZeroMyCharXMove"
addr = 0x416B50
[[func]]
name = "GetUnitMyChar"
addr = 0x416B60
[[func]]
name = "SetMyCharDirect"
addr = 0x416B70
[[func]]
name = "ChangeMyUnit"
addr = 0x416C40
[[func]]
name = "PitMyChar"
addr = 0x416C50
[[func]]
name = "EquipItem"
addr = 0x416C70
[[func]]
name = "ResetCheck"
addr = 0x416CA0
[[func]]
name = "SetNoise"
addr = 0x416CC0
[[func]]
name = "CutNoise"
addr = 0x416D40
[[func]]
name = "ResetNoise"
addr = 0x416D80
[[func]]
name = "SleepNoise"
addr = 0x416DF0
[[func]]
name = "ResetMyCharFlag"
addr = 0x416E20
[[func]]
name = "JudgeHitMyCharBlock"
addr = 0x416E30
[[func]]
name = "PutlittleStar"
addr = 0x417160
[[func]]
name = "JudgeHitMyCharTriangleA"
addr = 0x4171D0
[[func]]
name = "JudgeHitMyCharTriangleB"
addr = 0x4172E0
[[func]]
name = "JudgeHitMyCharTriangleC"
addr = 0x4173F0
[[func]]
name = "JudgeHitMyCharTriangleD"
addr = 0x417500
[[func]]
name = "JudgeHitMyCharTriangleE"
addr = 0x417610
[[func]]
name = "JudgeHitMyCharTriangleF"
addr = 0x417720
[[func]]
name = "JudgeHitMyCharTriangleG"
addr = 0x417830
[[func]]
name = "JudgeHitMyCharTriangleH"
addr = 0x417940
[[func]]
name = "JudgeHitMyCharWater"
addr = 0x417A50
[[func]]
name = "JudgeHitMyCharDamage"
addr = 0x417AE0
[[func]]
name = "JudgeHitMyCharDamageW"
addr = 0x417B70
[[func]]
name = "JudgeHitMyCharVectLeft"
addr = 0x417C00
[[func]]
name = "JudgeHitMyCharVectUp"
addr = 0x417C90
[[func]]
name = "JudgeHitMyCharVectRight"
addr = 0x417D20
[[func]]
name = "JudgeHitMyCharVectDown"
addr = 0x417DB0
[[func]]
name = "HitMyCharMap"
addr = 0x417E40
[[func]]
name = "JudgeHitMyCharNPC"
addr = 0x4187F0
[[func]]
name = "JudgeHitMyCharNPC3"
addr = 0x418B10
[[func]]
name = "JudgeHitMyCharNPC4"
addr = 0x418C20
[[func]]
name = "HitMyCharNpChar"
addr = 0x419030
[[func]]
name = "HitMyCharBoss"
addr = 0x419450
[[func]]
name = "AddExpMyChar"
addr = 0x4196F0
@ -2202,6 +2386,150 @@ addr = 0x46E9E0
name = "ActNpc360"
addr = 0x46EA90
[[func]]
name = "InitNpChar"
addr = 0x46EB30
[[func]]
name = "LoadEvent"
addr = 0x46EB50
[[func]]
name = "SetUniqueParameter"
addr = 0x46EE50
[[func]]
name = "SetNpChar"
addr = 0x46EFD0
[[func]]
name = "SetDestroyNpChar"
addr = 0x46F150
[[func]]
name = "SetDestroyNpCharUp"
addr = 0x46F200
[[func]]
name = "SetExpObjects"
addr = 0x46F2B0
[[func]]
name = "SetBulletObject"
addr = 0x46F430
[[func]]
name = "SetLifeObject"
addr = 0x46F630
[[func]]
name = "VanishNpChar"
addr = 0x46F760
[[func]]
name = "PutNpChar"
addr = 0x46F810
[[func]]
name = "ActNpChar"
addr = 0x46FA00
[[func]]
name = "ChangeNpCharByEvent"
addr = 0x46FAB0
[[func]]
name = "ChangeCheckableNpCharByEvent"
addr = 0x46FD10
[[func]]
name = "SetNpCharActionNo"
addr = 0x46FF90
[[func]]
name = "MoveNpChar"
addr = 0x470060
[[func]]
name = "BackStepMyChar"
addr = 0x470150
[[func]]
name = "DeleteNpCharEvent"
addr = 0x470250
[[func]]
name = "DeleteNpCharCode"
addr = 0x4702D0
[[func]]
name = "GetNpCharPosition"
addr = 0x470460
[[func]]
name = "IsNpCharCode"
addr = 0x470490
[[func]]
name = "GetNpCharAlive"
addr = 0x4704F0
[[func]]
name = "CountAliveNpChar"
addr = 0x470560
[[func]]
name = "JadgeHitNpCharBlock"
addr = 0x4705C0
[[func]]
name = "JudgeHitNpCharTriangleA"
addr = 0x470870
[[func]]
name = "JudgeHitNpCharTriangleB"
addr = 0x470970
[[func]]
name = "JudgeHitNpCharTriangleC"
addr = 0x470A70
[[func]]
name = "JudgeHitNpCharTriangleD"
addr = 0x470B70
[[func]]
name = "JudgeHitNpCharTriangleE"
addr = 0x470C70
[[func]]
name = "JudgeHitNpCharTriangleF"
addr = 0x470D80
[[func]]
name = "JudgeHitNpCharTriangleG"
addr = 0x470E90
[[func]]
name = "JudgeHitNpCharTriangleH"
addr = 0x470FA0
[[func]]
name = "JudgeHitNpCharWater"
addr = 0x4710B0
[[func]]
name = "HitNpCharMap"
addr = 0x471160
[[func]]
name = "LoseNpChar"
addr = 0x471B80
[[func]]
name = "HitNpCharBullet"
addr = 0x471D50
[[func]]
name = "LoadNpcTable"
addr = 0x472400

View file

@ -1,13 +0,0 @@
#ifndef _STDINT_H_
#define _STDINT_H_
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#endif /*_STDINT_H_*/

View file

@ -36,8 +36,7 @@ BOOL InitBack(const char *fName, int type)
#ifdef NONPORTABLE
// 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.
// It should break on big-endian CPUs, and platforms where short isn't 16-bit and long isn't 32-bit.
unsigned short bmp_header_buffer[7]; // These names aren't the original. This ruins the stack frame layout.
unsigned long bmp_header_buffer2[10];

View file

@ -1,6 +1,5 @@
#include "Boss.h"
#include <stdint.h>
#include <string.h>
#include "WindowsWrapper.h"

View file

@ -142,6 +142,7 @@ void ActBossChar_Ballos(void)
switch (npc->act_no)
{
case 0:
// Initialize main boss
npc->act_no = 1;
npc->cond = 0x80;
npc->exp = 1;
@ -159,6 +160,7 @@ void ActBossChar_Ballos(void)
npc->code_event = 1000;
npc->life = 800;
// Initialize eyes
gBoss[1].cond = 0x90;
gBoss[1].direct = 0;
gBoss[1].bits = 8;
@ -175,6 +177,7 @@ void ActBossChar_Ballos(void)
gBoss[2] = gBoss[1];
gBoss[2].direct = 2;
// Initialize the body
gBoss[3].cond = 0x90;
gBoss[3].bits = 0xD;
gBoss[3].view.front = 0x7800;

View file

@ -10,6 +10,7 @@
#include "Sound.h"
#include "Triangle.h"
// Balfrog's mouth
static void ActBossChar02_01(void)
{
NPCHAR *boss;
@ -84,6 +85,7 @@ static void ActBossChar02_02(void)
}
}
// Main boss AI
void ActBossChar_Frog(void)
{
int i;
@ -91,6 +93,7 @@ void ActBossChar_Frog(void)
int ym;
int xm;
// Rects 1-4 are for when Balfrog is a frog, 5-8 for when he reverts and goes into the ceiling
RECT rcLeft[9] = {
{0, 0, 0, 0},
{0, 48, 80, 112},

View file

@ -523,7 +523,7 @@ void ActBossChar_MonstX(void)
gBoss[2].direct = 2;
gBoss[3].cond = 0x80;
gBoss[3].life = 60;
gBoss[3].size = 3; // Redundant: this get overwriten a few lines later
gBoss[3].size = 3; // Redundant: this get overwritten a few lines later
gBoss[3].hit_voice = 54;
gBoss[3].destroy_voice = 71;
gBoss[3].size = 2;

View file

@ -45,7 +45,7 @@ int JudgeHitBulletBlock(int x, int y, BULLET *bul)
return hit;
}
int JudgeHitBulletBlock2(int x, int y, uint8_t *atrb, BULLET *bul)
int JudgeHitBulletBlock2(int x, int y, unsigned char *atrb, BULLET *bul)
{
int i;
int workX;

View file

@ -1,7 +1,5 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
struct BULLET
@ -20,7 +18,7 @@ struct BULLET
int act_wait;
int ani_wait;
int ani_no;
uint8_t direct;
unsigned char direct;
RECT rect;
int count1;
int count2;
@ -36,8 +34,8 @@ struct BULLET
struct BULLET_TABLE
{
int8_t damage;
int8_t life;
signed char damage;
signed char life;
int life_count;
int bbits;
int enemyXL;

View file

@ -1,5 +1,4 @@
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@ -16,7 +15,7 @@ static const char* const config_magic = "DOUKUTSU20041206"; // Not the original
BOOL LoadConfigData(CONFIG *conf)
{
//Clear old config data
// Clear old configuration data
memset(conf, 0, sizeof(CONFIG));
// Get path
@ -69,7 +68,7 @@ BOOL LoadConfigData(CONFIG *conf)
void DefaultConfigData(CONFIG *conf)
{
//Clear old config data
// Clear old configuration data
memset(conf, 0, sizeof(CONFIG));
// Fun fact: The Linux port added this line:

View file

@ -1,19 +1,17 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
struct CONFIG
{
char proof[0x20];
char font_name[0x40];
int32_t move_button_mode;
int32_t attack_button_mode;
int32_t ok_button_mode;
int32_t display_mode;
int32_t bJoystick;
int32_t joystick_button[8];
long move_button_mode;
long attack_button_mode;
long ok_button_mode;
long display_mode;
long bJoystick;
long joystick_button[8];
};
BOOL LoadConfigData(CONFIG *conf);

View file

@ -1,5 +1,4 @@
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@ -57,8 +56,8 @@ BOOL Flip_SystemTask()
return FALSE;
// Framerate limiter
static uint32_t timePrev;
const uint32_t timeNow = SDL_GetTicks();
static Uint32 timePrev;
const Uint32 timeNow = SDL_GetTicks();
if (timeNow >= timePrev + FRAMERATE)
{
@ -359,6 +358,9 @@ static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool creat
if (data)
{
// For some dumbass reason, SDL2 measures size with a signed int.
// Has anyone ever told the devs that an int can be as little as 16 bits long? Real portable.
// But hey, if I ever need to create an RWops from an array that's -32768 bytes long, they've got me covered!
SDL_RWops *fp = SDL_RWFromConstMem(data, size);
printf("Loading surface from resource %s for surface id %d\n", res, surf_no);
@ -443,7 +445,7 @@ static void DrawBitmap(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_
SDL_Rect clipRect = RectToSDLRectScaled(rcView);
SDL_Rect frameRect = RectToSDLRectScaled(rect);
// Get dest rect
// Get destination rect
SDL_Rect destRect = {x * magnification, y * magnification, frameRect.w, frameRect.h};
// Set cliprect
@ -485,28 +487,28 @@ unsigned long GetCortBoxColor(unsigned long col)
return col;
}
void CortBox(RECT *rect, uint32_t col)
void CortBox(RECT *rect, unsigned long col)
{
// Get rect
SDL_Rect destRect = RectToSDLRectScaled(rect);
// 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 & 0xFF0000) >> 16;
const unsigned char col_red = (unsigned char)(col & 0xFF);
const unsigned char col_green = (unsigned char)((col >> 8) & 0xFF);
const unsigned char col_blue = (unsigned char)((col >> 16) & 0xFF);
SDL_SetRenderDrawColor(gRenderer, col_red, col_green, col_blue, 0xFF);
SDL_RenderFillRect(gRenderer, &destRect);
}
void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no)
void CortBox2(RECT *rect, unsigned long col, Surface_Ids surf_no)
{
// Get rect
SDL_Rect destRect = RectToSDLRectScaled(rect);
// 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 & 0xFF0000) >> 16;
const unsigned char col_red = (unsigned char)(col & 0xFF);
const unsigned char col_green = (unsigned char)((col >> 8) & 0xFF);
const unsigned char col_blue = (unsigned char)((col >> 16) & 0xFF);
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;
}
@ -610,7 +612,7 @@ void InitTextObject(const char *font_name)
gFont = LoadFontFromData(res_data, data_size, fontWidth, fontHeight);
}
void PutText(int x, int y, const char *text, uint32_t color)
void PutText(int x, int y, const char *text, unsigned long color)
{
int surface_width, surface_height;
SDL_GetRendererOutputSize(gRenderer, &surface_width, &surface_height);
@ -626,7 +628,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, Surface_Ids surf_no)
void PutText2(int x, int y, const char *text, unsigned long color, Surface_Ids surf_no)
{
DrawText(gFont, (unsigned char*)surf[surf_no].surface->pixels, surf[surf_no].surface->pitch, surf[surf_no].surface->w, surf[surf_no].surface->h, x * magnification, y * magnification, color, text, strlen(text));
surf[surf_no].needs_updating = true;

View file

@ -1,7 +1,5 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
#ifndef RGB
@ -68,9 +66,9 @@ 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 CortBox(RECT *rect, unsigned long col);
void CortBox2(RECT *rect, unsigned long 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, Surface_Ids surf_no);
void PutText(int x, int y, const char *text, unsigned long color);
void PutText2(int x, int y, const char *text, unsigned long color, Surface_Ids surf_no);
void EndTextObject();

View file

@ -1,6 +1,5 @@
#include "Ending.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -184,7 +183,7 @@ bool StartCreditScript()
// Read data
fread(Credit.pData, 1, Credit.size, fp);
EncryptionBinaryData2((uint8_t*)Credit.pData, Credit.size);
EncryptionBinaryData2((unsigned char*)Credit.pData, Credit.size);
#ifdef FIX_BUGS
// The original game forgot to close the file
@ -229,7 +228,7 @@ void ActionCredit_Read()
while (Credit.offset < Credit.size)
{
// Get character
uint8_t character = Credit.pData[Credit.offset];
unsigned char character = Credit.pData[Credit.offset];
int a, b, len;
switch (character)

View file

@ -1,7 +1,5 @@
#pragma once
#include <stdint.h>
struct CREDIT
{
int size;

View file

@ -13,7 +13,7 @@ FRAME gFrame;
void MoveFrame3()
{
int16_t map_w, map_l;
short map_w, map_l;
GetMapData(0, &map_w, &map_l);
#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240 // TODO - Really need to make this a compiler flag
@ -119,7 +119,7 @@ void SetFramePosition(int fx, int fy)
gFrame.quake2 = 0;
//Move frame position
int16_t map_w, map_l;
short map_w, map_l;
GetMapData(0, &map_w, &map_l);
gFrame.x = fx;
@ -143,7 +143,7 @@ void SetFrameMyChar()
int mc_x, mc_y;
GetMyCharPosition(&mc_x, &mc_y);
int16_t map_w, map_l;
short map_w, map_l;
GetMapData(0, &map_w, &map_l);
gFrame.x = mc_x - (WINDOW_WIDTH << 8);

View file

@ -304,7 +304,7 @@ int ModeTitle()
break;
}
//Reset cliprect, flags, and give the player the nikumaru counter
// Reset cliprect, flags, and give the player the Nikumaru counter
grcGame.left = 0;
// Non-vanilla: these three lines are widescreen-related(?)
grcGame.top = 0;

View file

@ -1,6 +1,5 @@
#include "Generic.h"
#include <stdint.h>
#include <stdio.h>
#include "CommonDefines.h"
@ -45,7 +44,7 @@ bool CheckFileExists(const char *name)
return false;
}
bool IsShiftJIS(uint8_t c)
bool IsShiftJIS(unsigned char c)
{
if (c > 0x80 && c < 0xA0)
return true;

View file

@ -1,8 +1,6 @@
#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);
bool IsShiftJIS(unsigned char c);

View file

@ -1,7 +1,6 @@
#include "Input.h"
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <SDL.h>
@ -14,7 +13,7 @@
#define JOYSTICK_DEADZONE 10000
SDL_Joystick *joystick; //This may be a name that was given by Simon, but it fits the rest of Pixel's names so it's fine.
SDL_Joystick *joystick; // This was probably a name that was given by Simon, but it fits the rest of Pixel's names so it's fine.
void ReleaseDirectInput()
{
@ -51,8 +50,8 @@ bool GetJoystickStatus(JOYSTICK_STATUS *pStatus)
if (joystick)
{
int32_t x = SDL_JoystickGetAxis(joystick, 0);
int32_t y = SDL_JoystickGetAxis(joystick, 1);
Sint16 x = SDL_JoystickGetAxis(joystick, 0);
Sint16 y = SDL_JoystickGetAxis(joystick, 1);
pStatus->bLeft = x <= -JOYSTICK_DEADZONE;
pStatus->bRight = x >= JOYSTICK_DEADZONE;
pStatus->bUp = y <= -JOYSTICK_DEADZONE;

View file

@ -1,7 +1,6 @@
#include "Main.h"
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

View file

@ -1,7 +1,6 @@
#include "Map.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@ -21,7 +20,7 @@ static const char *code_pxma = "PXM";
BOOL InitMapData2()
{
gMap.data = (uint8_t*)malloc(PXM_BUFFER_SIZE);
gMap.data = (unsigned char*)malloc(PXM_BUFFER_SIZE);
return TRUE;
}
@ -103,7 +102,7 @@ void ReleasePartsImage()
ReleaseSurface(SURFACE_ID_LEVEL_TILESET);
}
void GetMapData(uint8_t **data, int16_t *mw, int16_t *ml)
void GetMapData(unsigned char **data, short *mw, short *ml)
{
if (data)
*data = gMap.data;
@ -132,7 +131,7 @@ void ShiftMapParts(int x, int y)
*(gMap.data + x + gMap.width * y) -= 1;
}
BOOL ChangeMapParts(int x, int y, uint8_t no)
BOOL ChangeMapParts(int x, int y, unsigned char no)
{
if (*(gMap.data + x + gMap.width * y) == no)
return FALSE;

View file

@ -1,15 +1,13 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
struct MAP_DATA
{
uint8_t *data;
uint8_t atrb[0x101]; //Why is this 257 bytes?
int16_t width;
int16_t length;
unsigned char *data;
unsigned char atrb[0x101]; //Why is this 257 bytes?
short width;
short length;
};
extern MAP_DATA gMap;
@ -19,11 +17,11 @@ BOOL LoadMapData2(const char *path_map);
BOOL LoadAttributeData(const char *path_atrb);
void EndMapData();
void ReleasePartsImage();
void GetMapData(uint8_t **data, int16_t *mw, int16_t *ml);
void GetMapData(unsigned char **data, short *mw, short *ml);
unsigned char GetAttribute(int x, int y);
void DeleteMapParts(int x, int y);
void ShiftMapParts(int x, int y);
BOOL ChangeMapParts(int x, int y, uint8_t no);
BOOL ChangeMapParts(int x, int y, unsigned char no);
void PutStage_Back(int fx, int fy);
void PutStage_Front(int fx, int fy);
void PutMapDataVector(int fx, int fy);

View file

@ -1,6 +1,5 @@
#include "MapName.h"
#include <stdint.h>
#include <string.h>
#include "CommonDefines.h"

View file

@ -1,6 +1,5 @@
#include "MiniMap.h"
#include <stdint.h>
#include <string.h>
#include "WindowsWrapper.h"
@ -127,7 +126,7 @@ int MiniMapLoop()
CortBox2(&rcMiniMap, 0, SURFACE_ID_MAP);
int line = 0;
uint8_t my_wait = 0;
unsigned char my_wait = 0;
while (true)
{
GetTrg();

View file

@ -1,7 +1,5 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
extern char gMapping[0x80];

View file

@ -1,6 +1,5 @@
#include "MyChar.h"
#include <stdint.h>
#include <string.h>
#include "WindowsWrapper.h"
@ -44,7 +43,7 @@ void InitMyChar()
gMC.unit = 0;
}
void AnimationMyChar(bool bKey)
void AnimationMyChar(BOOL bKey)
{
RECT rcLeft[12] = {
{0, 0, 16, 16},
@ -76,8 +75,9 @@ void AnimationMyChar(bool bKey)
{112, 16, 128, 32},
};
if (!(gMC.cond & 2))
{
if (gMC.cond & 2)
return;
if (gMC.flag & 8)
{
if (gMC.cond & 1)
@ -137,23 +137,21 @@ void AnimationMyChar(bool bKey)
{
gMC.ani_no = 10;
}
else if (gMC.ym <= 0)
else
{
if (gMC.ym > 0)
gMC.ani_no = 1;
else
gMC.ani_no = 3;
}
else
{
gMC.ani_no = 1;
}
if (gMC.direct)
gMC.rect = rcRight[gMC.ani_no];
else
if (gMC.direct == 0)
gMC.rect = rcLeft[gMC.ani_no];
}
else
gMC.rect = rcRight[gMC.ani_no];
}
void ShowMyChar(bool bShow)
void ShowMyChar(BOOL bShow)
{
if (bShow)
gMC.cond &= ~2;
@ -163,8 +161,11 @@ void ShowMyChar(bool bShow)
void PutMyChar(int fx, int fy)
{
if ((gMC.cond & 0x80) && !(gMC.cond & 2))
{
int arms_offset_y;
if ((gMC.cond & 0x80) == 0 || (gMC.cond & 2))
return;
// Draw weapon
gMC.rect_arms.left = 24 * (gArmsData[gSelectedArms].code % 13);
gMC.rect_arms.right = gMC.rect_arms.left + 24;
@ -177,7 +178,6 @@ void PutMyChar(int fx, int fy)
gMC.rect_arms.bottom += 16;
}
int arms_offset_y;
if (gMC.up)
{
arms_offset_y = -4;
@ -198,23 +198,24 @@ void PutMyChar(int fx, int fy)
if (gMC.ani_no == 1 || gMC.ani_no == 3 || gMC.ani_no == 6 || gMC.ani_no == 8)
++gMC.rect_arms.top;
if (gMC.direct)
PutBitmap3(
&grcGame,
(gMC.x - gMC.view.left) / 0x200 - fx / 0x200,
(gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y,
&gMC.rect_arms,
SURFACE_ID_ARMS);
else
if (gMC.direct == 0)
PutBitmap3(
&grcGame,
(gMC.x - gMC.view.left) / 0x200 - fx / 0x200 - 8,
(gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y,
&gMC.rect_arms,
SURFACE_ID_ARMS);
else
PutBitmap3(
&grcGame,
(gMC.x - gMC.view.left) / 0x200 - fx / 0x200,
(gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y,
&gMC.rect_arms,
SURFACE_ID_ARMS);
if ((gMC.shock / 2) % 2)
return;
if (!((gMC.shock >> 1) & 1))
{
// Draw player
RECT rect = gMC.rect;
if (gMC.equip & 0x40)
@ -233,18 +234,15 @@ void PutMyChar(int fx, int fy)
++gMC.bubble;
if (gMC.equip & 0x10 && gMC.flag & 0x100)
PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble >> 1) & 1], SURFACE_ID_CARET);
PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble / 2) % 2], SURFACE_ID_CARET);
else if (gMC.unit == 1)
PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble >> 1) & 1], SURFACE_ID_CARET);
}
}
PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble / 2) % 2], SURFACE_ID_CARET);
}
void ActMyChar_Normal(bool bKey)
{
if (!(gMC.cond & 2))
void ActMyChar_Normal(BOOL bKey)
{
// Get speeds and accelerations
int max_move; // Unused
int max_dash;
int gravity1;
int gravity2;
@ -253,9 +251,16 @@ void ActMyChar_Normal(bool bKey)
int dash2;
int resist;
int a;
int x;
if (gMC.cond & 2)
return;
if (gMC.flag & 0x100)
{
max_dash = 0x196;
max_move = 0x2FF;
gravity1 = 0x28;
gravity2 = 0x10;
jump = 0x280;
@ -266,6 +271,7 @@ void ActMyChar_Normal(bool bKey)
else
{
max_dash = 0x32C;
max_move = 0x5FF;
gravity1 = 0x50;
gravity2 = 0x20;
jump = 0x500;
@ -303,9 +309,16 @@ void ActMyChar_Normal(bool bKey)
// Move in direction held
if (bKey)
{
if (gKeyTrg != gKeyDown || gKey != gKeyDown || (gMC.cond & 1) || g_GameFlags & 4)
if (gKeyTrg == gKeyDown && gKey == gKeyDown && (gMC.cond & 1) == 0 && (g_GameFlags & 4) == 0)
{
if (gKey != gKeyDown)
gMC.cond |= 1;
gMC.ques = 1;
}
else if (gKey == gKeyDown)
{
}
else
{
if (gKey & gKeyLeft && gMC.xm > -max_dash)
gMC.xm -= dash1;
@ -318,29 +331,23 @@ void ActMyChar_Normal(bool bKey)
gMC.direct = 2;
}
}
else
{
gMC.cond |= 1;
gMC.ques = 1;
}
}
// Friction
if (!(gMC.cond & 0x20))
{
if (gMC.xm < 0)
{
if (gMC.xm <= -resist)
gMC.xm += resist;
else
if (gMC.xm > -resist)
gMC.xm = 0;
else
gMC.xm += resist;
}
if (gMC.xm > 0)
{
if (gMC.xm >= resist)
gMC.xm -= resist;
else
if (gMC.xm < resist)
gMC.xm = 0;
else
gMC.xm -= resist;
}
}
}
@ -425,17 +432,30 @@ void ActMyChar_Normal(bool bKey)
if (bKey)
{
// Look up and down
gMC.up = (gKey & gKeyUp) != 0;
gMC.down = gKey & gKeyDown && !(gMC.flag & 8);
if (gKey & gKeyUp)
gMC.up = TRUE;
else
gMC.up = FALSE;
if (gKey & gKeyDown && (gMC.flag & 8) == 0)
gMC.down = TRUE;
else
gMC.down = FALSE;
if (gKeyTrg & gKeyJump
&& (gMC.flag & 8 || gMC.flag & 0x10 || gMC.flag & 0x20)
&& !(gMC.flag & 0x2000))
&& (gMC.flag & 8 || gMC.flag & 0x10 || gMC.flag & 0x20))
{
if (gMC.flag & 0x2000)
{
// Another weird empty case needed for accurate assembly
}
else
{
gMC.ym = -jump;
PlaySoundObject(15, 1);
}
}
}
// Stop interacting when moved
if (bKey && (gKeyShot | gKeyJump | gKeyUp | gKeyRight | gKeyLeft) & gKey)
@ -533,7 +553,7 @@ void ActMyChar_Normal(bool bKey)
}
// Keep player on slopes
if (bKey && !(gKeyTrg & gKeyJump))
if (!bKey || !(gKeyTrg & gKeyJump))
{
if (gMC.flag & 0x10 && gMC.xm < 0)
gMC.ym = -gMC.xm;
@ -547,19 +567,15 @@ void ActMyChar_Normal(bool bKey)
gMC.ym = 0x400;
}
// Limit speed
if (!(gMC.flag & 0x100) || gMC.flag & 0xF000)
if (0)
{
if (gMC.xm < -0x5FF)
gMC.xm = -0x5FF;
if (gMC.xm > 0x5FF)
gMC.xm = 0x5FF;
if (gMC.ym < -0x5FF)
gMC.ym = -0x5FF;
if (gMC.ym > 0x5FF)
gMC.ym = 0x5FF;
// There used to be an if here that didn't do anything, but the compiler optimised it out.
// We only know this was here because empty ifs mess with the register usage.
// Since there's no code, we have no idea what the original condition actually was.
}
else
// Limit speed
if ((gMC.flag & 0x100) && (gMC.flag & 0xF000) == 0)
{
if (gMC.xm < -0x2FF)
gMC.xm = -0x2FF;
@ -570,6 +586,17 @@ void ActMyChar_Normal(bool bKey)
if (gMC.ym > 0x2FF)
gMC.ym = 0x2FF;
}
else
{
if (gMC.xm < -0x5FF)
gMC.xm = -0x5FF;
if (gMC.xm > 0x5FF)
gMC.xm = 0x5FF;
if (gMC.ym < -0x5FF)
gMC.ym = -0x5FF;
if (gMC.ym > 0x5FF)
gMC.ym = 0x5FF;
}
// Water splashing
if (!gMC.sprash && gMC.flag & 0x100)
@ -580,23 +607,29 @@ void ActMyChar_Normal(bool bKey)
else
dir = 0;
if (gMC.flag & 8 || gMC.ym <= 0x200)
if ((gMC.flag & 8) == 0 && gMC.ym > 0x200)
{
if (gMC.xm > 0x200 || gMC.xm < -0x200)
for (a = 0; a < 8; a++)
{
for (int a = 0; a < 8; a++)
SetNpChar(73, gMC.x + (Random(-8, 8) << 9), gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80), dir, 0, 0);
x = gMC.x + (Random(-8, 8) * 0x200);
SetNpChar(73, x, gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80) - gMC.ym / 2, dir, 0, 0);
}
PlaySoundObject(56, 1);
}
}
else
{
for (int a = 0; a < 8; a++)
SetNpChar(73, gMC.x + (Random(-8, 8) << 9), gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80) - gMC.ym / 2, dir, 0, 0);
if (gMC.xm > 0x200 || gMC.xm < -0x200)
{
for (a = 0; a < 8; a++)
{
x = gMC.x + (Random(-8, 8) * 0x200);
SetNpChar(73, x, gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80), dir, 0, 0);
}
PlaySoundObject(56, 1);
}
}
gMC.sprash = 1;
}
@ -609,18 +642,18 @@ void ActMyChar_Normal(bool bKey)
DamageMyChar(10);
// Camera
if (gMC.direct)
{
gMC.index_x += 0x200;
if (gMC.index_x > 0x8000)
gMC.index_x = 0x8000;
}
else
if (gMC.direct == 0)
{
gMC.index_x -= 0x200;
if (gMC.index_x < -0x8000)
gMC.index_x = -0x8000;
}
else
{
gMC.index_x += 0x200;
if (gMC.index_x > 0x8000)
gMC.index_x = 0x8000;
}
if (gKey & gKeyUp && bKey)
{
gMC.index_y -= 0x200;
@ -645,16 +678,22 @@ void ActMyChar_Normal(bool bKey)
gMC.tgt_y = gMC.y + gMC.index_y;
// Change position
if (gMC.xm > resist || gMC.xm < -resist)
gMC.x += gMC.xm;
gMC.y += gMC.ym;
if (gMC.xm <= resist && gMC.xm >= -resist)
{
// Okay, this is getting stupid. Why the HELL is the code written like this?
}
else
{
gMC.x += gMC.xm;
}
void ActMyChar_Stream(bool bKey)
gMC.y += gMC.ym;
}
void ActMyChar_Stream(BOOL bKey)
{
gMC.up = false;
gMC.down = false;
gMC.up = FALSE;
gMC.down = FALSE;
if (bKey)
{
@ -666,17 +705,18 @@ void ActMyChar_Stream(bool bKey)
if (gKey & gKeyRight)
gMC.xm += 0x100;
}
else if (gMC.xm > 0x7F || gMC.xm < -0x7F)
{
if (gMC.xm > 0)
gMC.xm -= 0x80;
else if (gMC.xm < 0)
gMC.xm += 0x80;
}
else
else if (gMC.xm < 0x80 && gMC.xm > -0x80)
{
gMC.xm = 0;
}
else if (gMC.xm > 0)
{
gMC.xm -= 0x80;
}
else if (gMC.xm < 0)
{
gMC.xm += 0x80;
}
if (gKey & (gKeyDown | gKeyUp))
{
@ -686,44 +726,35 @@ void ActMyChar_Stream(bool bKey)
if (gKey & gKeyDown)
gMC.ym += 0x100;
}
else if (gMC.ym > 0x7F || gMC.ym < -0x7F)
{
if (gMC.ym > 0)
gMC.ym -= 0x80;
else if (gMC.ym < 0)
gMC.ym += 0x80;
}
else
else if (gMC.ym < 0x80 && gMC.ym > -0x80)
{
gMC.ym = 0;
}
else if (gMC.ym > 0)
{
gMC.ym -= 0x80;
}
else if (gMC.ym < 0)
{
gMC.ym += 0x80;
}
}
else
{
if (gMC.xm > 0x7F || gMC.xm < -0x3F)
{
if (gMC.xm > 0)
if (gMC.xm < 0x80 && gMC.xm > -0x40)
gMC.xm = 0;
else if (gMC.xm > 0)
gMC.xm -= 0x80;
else if (gMC.xm < 0)
gMC.xm += 0x80;
}
else
{
gMC.xm = 0;
}
if (gMC.ym > 0x7F || gMC.ym < -0x3F)
{
if (gMC.ym > 0)
if (gMC.ym < 0x80 && gMC.ym > -0x40)
gMC.ym = 0;
else if (gMC.ym > 0)
gMC.ym -= 0x80;
else if (gMC.ym < 0)
gMC.ym += 0x80;
}
else
{
gMC.ym = 0;
}
}
if (gMC.ym < -0x200 && gMC.flag & 2)
SetCaret(gMC.x, gMC.y - gMC.hit.top, 13, 5);
@ -785,7 +816,11 @@ void AirProcess()
}
else
{
if (gMC.flag & 0x100)
if ((gMC.flag & 0x100) == 0)
{
gMC.air = 1000;
}
else
{
if (--gMC.air <= 0)
{
@ -799,19 +834,15 @@ void AirProcess()
// Drown
StartTextScript(41);
if (gMC.direct)
SetCaret(gMC.x, gMC.y, 8, 2);
else
if (gMC.direct == 0)
SetCaret(gMC.x, gMC.y, 8, 0);
else
SetCaret(gMC.x, gMC.y, 8, 2);
gMC.cond &= ~0x80;
}
}
}
else
{
gMC.air = 1000;
}
if (gMC.flag & 0x100)
{
@ -824,10 +855,11 @@ void AirProcess()
}
}
void ActMyChar(bool bKey)
{
if (gMC.cond & 0x80)
void ActMyChar(BOOL bKey)
{
if ((gMC.cond & 0x80) == 0)
return;
if (gMC.exp_wait)
--gMC.exp_wait;
@ -852,14 +884,10 @@ void ActMyChar(bool bKey)
case 1:
ActMyChar_Stream(bKey);
break;
default:
break;
}
gMC.cond &= ~0x20;
}
}
void GetMyCharPosition(int *x, int *y)
{
@ -871,8 +899,8 @@ void SetMyCharPosition(int x, int y)
{
gMC.x = x;
gMC.y = y;
gMC.tgt_x = x;
gMC.tgt_y = y;
gMC.tgt_x = gMC.x;
gMC.tgt_y = gMC.y;
gMC.index_x = 0;
gMC.index_y = 0;
gMC.xm = 0;
@ -897,42 +925,42 @@ int GetUnitMyChar()
return gMC.unit;
}
void SetMyCharDirect(uint8_t dir)
void SetMyCharDirect(unsigned char dir)
{
switch (dir)
if (dir == 3)
{
case 3:
gMC.cond |= 1;
break;
default:
}
else
{
gMC.cond &= ~1;
if (dir < 10)
{
gMC.direct = dir;
break;
}
for (int i = 0; i < NPC_MAX; i++)
{
if (gNPC[i].code_event == dir)
{
if (gMC.x <= gNPC[i].x)
gMC.direct = 2;
else
{
int i;
for (i = 0; i < NPC_MAX; i++)
if (gNPC[i].code_event == dir)
break;
if (i == NPC_MAX)
return;
if (gMC.x > gNPC[i].x)
gMC.direct = 0;
break;
else
gMC.direct = 2;
}
}
break;
}
gMC.xm = 0;
AnimationMyChar(false);
AnimationMyChar(FALSE);
}
void ChangeMyUnit(uint8_t a)
void ChangeMyUnit(unsigned char a)
{
gMC.unit = a;
}
@ -942,7 +970,7 @@ void PitMyChar()
gMC.y += 0x4000;
}
void EquipItem(int flag, bool b)
void EquipItem(int flag, BOOL b)
{
if (b)
gMC.equip |= flag;
@ -960,16 +988,18 @@ void SetNoise(int no, int freq)
noise_freq = freq;
noise_no = no;
if (no == 1)
switch (noise_no)
{
case 1:
ChangeSoundFrequency(40, noise_freq);
ChangeSoundFrequency(41, noise_freq + 100);
PlaySoundObject(40, -1);
PlaySoundObject(41, -1);
}
else if (no == 2)
{
break;
case 2:
PlaySoundObject(58, -1);
break;
}
}
@ -983,16 +1013,18 @@ void CutNoise()
void ResetNoise()
{
if (noise_no == 1)
switch (noise_no)
{
case 1:
ChangeSoundFrequency(40, noise_freq);
ChangeSoundFrequency(41, noise_freq + 100);
PlaySoundObject(40, -1);
PlaySoundObject(41, -1);
}
else if (noise_no == 2)
{
break;
case 2:
PlaySoundObject(58, -1);
break;
}
}

View file

@ -1,16 +1,14 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
struct MYCHAR
{
uint8_t cond;
unsigned char cond;
unsigned int flag;
int direct;
int up;
int down;
BOOL up;
BOOL down;
int unit;
int equip;
int x;
@ -30,41 +28,41 @@ struct MYCHAR
int level;
int exp_wait;
int exp_count;
uint8_t shock;
uint8_t no_life;
uint8_t rensha;
uint8_t bubble;
int16_t life;
int16_t star;
int16_t max_life;
int16_t a;
unsigned char shock;
unsigned char no_life;
unsigned char rensha;
unsigned char bubble;
short life;
short star;
short max_life;
short a;
int lifeBr;
int lifeBr_count;
int air;
int air_get;
int8_t sprash;
int8_t ques;
int8_t boost_sw;
signed char sprash;
signed char ques;
signed char boost_sw;
int boost_cnt;
};
extern MYCHAR gMC;
void InitMyChar();
void AnimationMyChar(bool bKey);
void ShowMyChar(bool bShow);
void AnimationMyChar(BOOL bKey);
void ShowMyChar(BOOL bShow);
void PutMyChar(int fx, int fy);
void ActMyChar_Normal(bool bKey);
void ActMyChar(bool bKey);
void ActMyChar_Normal(BOOL bKey);
void ActMyChar(BOOL bKey);
void GetMyCharPosition(int *x, int *y);
void SetMyCharPosition(int x, int y);
void MoveMyChar(int x, int y);
void ZeroMyCharXMove();
int GetUnitMyChar();
void SetMyCharDirect(uint8_t dir);
void ChangeMyUnit(uint8_t a);
void SetMyCharDirect(unsigned char dir);
void ChangeMyUnit(unsigned char a);
void PitMyChar();
void EquipItem(int flag, bool b);
void EquipItem(int flag, BOOL b);
void ResetCheck();
void SetNoise(int no, int freq);
void CutNoise();

View file

@ -1,7 +1,5 @@
#include "MycHit.h"
#include <stdint.h>
#include "WindowsWrapper.h"
#include "Back.h"
@ -36,13 +34,13 @@ int JudgeHitMyCharBlock(int x, int y)
int hit = 0;
// Left wall
if (gMC.y - gMC.hit.top < (2 * (2 * y + 1) - 1) << 11
&& gMC.y + gMC.hit.bottom > (2 * (2 * y - 1) + 1) << 11
&& gMC.x - gMC.hit.left < (2 * x + 1) << 12
&& gMC.x - gMC.hit.left > x << 13)
if (gMC.y - gMC.hit.top < (y * 0x10 + 4) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 4) * 0x200
&& gMC.x - gMC.hit.left < (x * 0x10 + 8) * 0x200
&& gMC.x - gMC.hit.left > x * 0x10 * 0x200)
{
// Clip
gMC.x = ((2 * x + 1) << 12) + gMC.hit.left;
gMC.x = ((x * 0x10 + 8) * 0x200) + gMC.hit.left;
// Halt momentum
if (gMC.xm < -0x180)
@ -55,13 +53,13 @@ int JudgeHitMyCharBlock(int x, int y)
}
// Right wall
if (gMC.y - gMC.hit.top < (2 * (2 * y + 1) - 1) << 11
&& gMC.y + gMC.hit.bottom > (2 * (2 * y - 1) + 1) << 11
&& gMC.x + gMC.hit.right > (2 * x - 1) << 12
&& gMC.x + gMC.hit.left < x << 13)
if (gMC.y - gMC.hit.top < (y * 0x10 + 4) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 4) * 0x200
&& gMC.x + gMC.hit.right > (x * 0x10 - 8) * 0x200
&& gMC.x + gMC.hit.left < x * 0x10 * 0x200)
{
// Clip
gMC.x = ((2 * x - 1) << 12) - gMC.hit.right;
gMC.x = ((x * 0x10 - 8) * 0x200) - gMC.hit.right;
// Halt momentum
if (gMC.xm > 0x180)
@ -74,13 +72,13 @@ int JudgeHitMyCharBlock(int x, int y)
}
// Ceiling
if (gMC.x - gMC.hit.right < ((2 * x + 1) << 12) - 0x600
&& gMC.x + gMC.hit.right > ((2 * x - 1) << 12) + 0x600
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12
&& gMC.y - gMC.hit.top > y << 13)
if (gMC.x - gMC.hit.right < (x * 0x10 + 5) * 0x200
&& gMC.x + gMC.hit.right > (x * 0x10 - 5) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 + 8) * 0x200
&& gMC.y - gMC.hit.top > y * 0x10 * 0x200)
{
// Clip
gMC.y = ((2 * y + 1) << 12) + gMC.hit.top;
gMC.y = ((y * 0x10 + 8) * 0x200) + gMC.hit.top;
// Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)
@ -93,13 +91,13 @@ int JudgeHitMyCharBlock(int x, int y)
}
// Floor
if (gMC.x - gMC.hit.right < ((2 * x + 1) << 12) - 0x600
&& gMC.x + gMC.hit.right > ((2 * x - 1) << 12) + 0x600
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12
&& gMC.y + gMC.hit.bottom < y << 13)
if (gMC.x - gMC.hit.right < (x * 0x10 + 5) * 0x200
&& gMC.x + gMC.hit.right > ((x * 0x10 - 5) * 0x200)
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 8) * 0x200
&& gMC.y + gMC.hit.bottom < y * 0x10 * 0x200)
{
// Clip
gMC.y = ((2 * y - 1) << 12) - gMC.hit.bottom;
gMC.y = ((y * 0x10 - 8) * 0x200) - gMC.hit.bottom;
// Halt momentum
if (gMC.ym > 0x400)
@ -118,13 +116,13 @@ int JudgeHitMyCharTriangleA(int x, int y)
{
int hit = 0;
if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12
&& gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
if (gMC.x < (x * 0x10 + 8) * 0x200
&& gMC.x > (x * 0x10 - 8) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 * 0x200) - (gMC.x - x * 0x10 * 0x200) / 2 + 0x800
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 8) * 0x200)
{
// Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 + gMC.hit.top;
gMC.y = (y * 0x10 * 0x200) - ((gMC.x - x * 0x10 * 0x200) / 2) + 0x800 + gMC.hit.top;
// Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)
@ -143,13 +141,13 @@ int JudgeHitMyCharTriangleB(int x, int y)
{
int hit = 0;
if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12
&& gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
if (gMC.x < (x * 0x10 + 8) * 0x200
&& gMC.x > (x * 0x10 - 8) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 * 0x200) - ((gMC.x - x * 0x10 * 0x200) / 2) - 0x800
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 8) * 0x200)
{
// Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 + gMC.hit.top;
gMC.y = (y * 0x10 * 0x200) - ((gMC.x - x * 0x10 * 0x200) / 2) - 0x800 + gMC.hit.top;
// Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)
@ -168,13 +166,13 @@ int JudgeHitMyCharTriangleC(int x, int y)
{
int hit = 0;
if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12
&& gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
if (gMC.x < (x * 0x10 + 8) * 0x200
&& gMC.x > (x * 0x10 - 8) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 * 0x200) + ((gMC.x - x * 0x10 * 0x200) / 2) - 0x800
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 8) * 0x200)
{
// Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 + gMC.hit.top;
gMC.y = (y * 0x10 * 0x200) + ((gMC.x - x * 0x10 * 0x200) / 2) - 0x800 + gMC.hit.top;
// Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)
@ -193,13 +191,13 @@ int JudgeHitMyCharTriangleD(int x, int y)
{
int hit = 0;
if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12
&& gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
if (gMC.x < (x * 0x10 + 8) * 0x200
&& gMC.x > (x * 0x10 - 8) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 * 0x200) + ((gMC.x - x * 0x10 * 0x200) / 2) + 0x800
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 8) * 0x200)
{
// Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 + gMC.hit.top;
gMC.y = (y * 0x10 * 0x200) + ((gMC.x - x * 0x10 * 0x200) / 2) + 0x800 + gMC.hit.top;
// Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)
@ -216,15 +214,17 @@ int JudgeHitMyCharTriangleD(int x, int y)
int JudgeHitMyCharTriangleE(int x, int y)
{
int hit = 0x10000;
int hit = 0;
if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12
&& gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12)
hit |= 0x10000;
if (gMC.x < (x * 0x10 + 8) * 0x200
&& gMC.x > (x * 0x10 - 8) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 * 0x200) + ((gMC.x - x * 0x10 * 0x200) / 2) - 0x800
&& gMC.y - gMC.hit.top < (y * 0x10 + 8) * 0x200)
{
// Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 - gMC.hit.bottom;
gMC.y = (y * 0x10 * 0x200) + ((gMC.x - x * 0x10 * 0x200) / 2) - 0x800 - gMC.hit.bottom;
// Halt momentum
if (gMC.ym > 0x400)
@ -233,7 +233,7 @@ int JudgeHitMyCharTriangleE(int x, int y)
gMC.ym = 0;
// Set that hit this slope
hit = 0x10028;
hit |= 0x28;
}
return hit;
@ -241,15 +241,17 @@ int JudgeHitMyCharTriangleE(int x, int y)
int JudgeHitMyCharTriangleF(int x, int y)
{
int hit = 0x20000;
int hit = 0;
if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12
&& gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12)
hit |= 0x20000;
if (gMC.x < (x * 0x10 + 8) * 0x200
&& gMC.x > (x * 0x10 - 8) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 * 0x200) + ((gMC.x - x * 0x10 * 0x200) / 2) + 0x800
&& gMC.y - gMC.hit.top < (y * 0x10 + 8) * 0x200)
{
// Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 - gMC.hit.bottom;
gMC.y = (y * 0x10 * 0x200) + ((gMC.x - x * 0x10 * 0x200) / 2) + 0x800 - gMC.hit.bottom;
// Halt momentum
if (gMC.ym > 0x400)
@ -258,7 +260,7 @@ int JudgeHitMyCharTriangleF(int x, int y)
gMC.ym = 0;
// Set that hit this slope
hit = 0x20028;
hit |= 0x28;
}
return hit;
@ -266,15 +268,17 @@ int JudgeHitMyCharTriangleF(int x, int y)
int JudgeHitMyCharTriangleG(int x, int y)
{
int hit = 0x40000;
int hit = 0;
if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12
&& gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12)
hit |= 0x40000;
if (gMC.x < (x * 0x10 + 8) * 0x200
&& gMC.x > (x * 0x10 - 8) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 * 0x200) - ((gMC.x - x * 0x10 * 0x200) / 2) + 0x800
&& gMC.y - gMC.hit.top < (y * 0x10 + 8) * 0x200)
{
// Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 - gMC.hit.bottom;
gMC.y = (y * 0x10 * 0x200) - ((gMC.x - x * 0x10 * 0x200) / 2) + 0x800 - gMC.hit.bottom;
// Halt momentum
if (gMC.ym > 0x400)
@ -283,7 +287,7 @@ int JudgeHitMyCharTriangleG(int x, int y)
gMC.ym = 0;
// Set that hit this slope
hit = 0x40018;
hit |= 0x18;
}
return hit;
@ -291,15 +295,17 @@ int JudgeHitMyCharTriangleG(int x, int y)
int JudgeHitMyCharTriangleH(int x, int y)
{
int hit = 0x80000;
int hit = 0;
if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12
&& gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12)
hit |= 0x80000;
if (gMC.x < (x * 0x10 + 8) * 0x200
&& gMC.x > (x * 0x10 - 8) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 * 0x200) - ((gMC.x - x * 0x10 * 0x200) / 2) - 0x800
&& gMC.y - gMC.hit.top < (y * 0x10 + 8) * 0x200)
{
// Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 - gMC.hit.bottom;
gMC.y = (y * 0x10 * 0x200) - ((gMC.x - x * 0x10 * 0x200) / 2) - 0x800 - gMC.hit.bottom;
// Halt momentum
if (gMC.ym > 0x400)
@ -308,7 +314,7 @@ int JudgeHitMyCharTriangleH(int x, int y)
gMC.ym = 0;
// Set that hit this slope
hit = 0x80018;
hit |= 0x18;
}
return hit;
@ -318,11 +324,11 @@ int JudgeHitMyCharWater(int x, int y)
{
int hit = 0;
if (gMC.x - gMC.hit.right < ((2 * x + 1) << 12) - 0x600
&& gMC.x + gMC.hit.right > ((2 * x - 1) << 12) + 0x600
&& gMC.y - gMC.hit.top < ((2 * y + 1) << 12) - 0x600
&& gMC.y + gMC.hit.bottom > y << 13)
hit = 0x100;
if (gMC.x - gMC.hit.right < (x * 0x10 + 5) * 0x200
&& gMC.x + gMC.hit.right > ((x * 0x10 - 5) * 0x200)
&& gMC.y - gMC.hit.top < ((y * 0x10 + 5) * 0x200)
&& gMC.y + gMC.hit.bottom > y * 0x10 * 0x200)
hit |= 0x100;
return hit;
}
@ -331,11 +337,11 @@ int JudgeHitMyCharDamage(int x, int y)
{
int hit = 0;
if (gMC.x - 0x800 < (4 * x + 1) << 11
&& gMC.x + 0x800 > (4 * x - 1) << 11
&& gMC.y - 0x800 < (y << 13) + 0x600
&& gMC.y + 0x800 > (y << 13) - 0x600)
hit = 0x400;
if (gMC.x - 0x800 < (x * 0x10 + 4) * 0x200
&& gMC.x + 0x800 > (x * 0x10 - 4) * 0x200
&& gMC.y - 0x800 < (y * 0x10 + 3) * 0x200
&& gMC.y + 0x800 > (y * 0x10 - 3) * 0x200)
hit |= 0x400;
return hit;
}
@ -344,11 +350,11 @@ int JudgeHitMyCharDamageW(int x, int y)
{
int hit = 0;
if (gMC.x - 0x800 < (4 * x + 1) << 11
&& gMC.x + 0x800 > (4 * x - 1) << 11
&& gMC.y - 0x800 < (y << 13) + 0x600
&& gMC.y + 0x800 > (y << 13) - 0x600)
hit = 0xD00;
if (gMC.x - 0x800 < (x * 0x10 + 4) * 0x200
&& gMC.x + 0x800 > (x * 0x10 - 4) * 0x200
&& gMC.y - 0x800 < (y * 0x10 + 3) * 0x200
&& gMC.y + 0x800 > (y * 0x10 - 3) * 0x200)
hit |= 0xD00;
return hit;
}
@ -356,11 +362,11 @@ int JudgeHitMyCharDamageW(int x, int y)
int JudgeHitMyCharVectLeft(int x, int y)
{
int hit = 0;
if (gMC.x - gMC.hit.right < (4 * (2 * x + 1) - 1) << 10
&& gMC.x + gMC.hit.right > (4 * (2 * x - 1) + 1) << 10
&& gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10
&& gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10)
hit = 0x1000;
if (gMC.x - gMC.hit.right < (x * 0x10 + 6) * 0x200
&& gMC.x + gMC.hit.right > (x * 0x10 - 6) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 + 6) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 6) * 0x200)
hit |= 0x1000;
return hit;
}
@ -368,11 +374,11 @@ int JudgeHitMyCharVectLeft(int x, int y)
int JudgeHitMyCharVectUp(int x, int y)
{
int hit = 0;
if (gMC.x - gMC.hit.right < (4 * (2 * x + 1) - 1) << 10
&& gMC.x + gMC.hit.right > (4 * (2 * x - 1) + 1) << 10
&& gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10
&& gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10)
hit = 0x2000;
if (gMC.x - gMC.hit.right < (x * 0x10 + 6) * 0x200
&& gMC.x + gMC.hit.right > (x * 0x10 - 6) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 + 6) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 6) * 0x200)
hit |= 0x2000;
return hit;
}
@ -380,11 +386,11 @@ int JudgeHitMyCharVectUp(int x, int y)
int JudgeHitMyCharVectRight(int x, int y)
{
int hit = 0;
if (gMC.x - gMC.hit.right < (4 * (2 * x + 1) - 1) << 10
&& gMC.x + gMC.hit.right > (4 * (2 * x - 1) + 1) << 10
&& gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10
&& gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10)
hit = 0x4000;
if (gMC.x - gMC.hit.right < (x * 0x10 + 6) * 0x200
&& gMC.x + gMC.hit.right > (x * 0x10 - 6) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 + 6) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 6) * 0x200)
hit |= 0x4000;
return hit;
}
@ -392,43 +398,42 @@ int JudgeHitMyCharVectRight(int x, int y)
int JudgeHitMyCharVectDown(int x, int y)
{
int hit = 0;
if (gMC.x - gMC.hit.right < (4 * (2 * x + 1) - 1) << 10
&& gMC.x + gMC.hit.right > (4 * (2 * x - 1) + 1) << 10
&& gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10
&& gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10)
hit = 0x8000;
if (gMC.x - gMC.hit.right < (x * 0x10 + 6) * 0x200
&& gMC.x + gMC.hit.right > (x * 0x10 - 6) * 0x200
&& gMC.y - gMC.hit.top < (y * 0x10 + 6) * 0x200
&& gMC.y + gMC.hit.bottom > (y * 0x10 - 6) * 0x200)
hit |= 0x8000;
return hit;
}
void HitMyCharMap()
{
int x = gMC.x / 0x2000;
int y = gMC.y / 0x2000;
int i;
int x = gMC.x / 0x10 / 0x200;
int y = gMC.y / 0x10 / 0x200;
int offy[4];
int offx[4];
int offy[4];
offx[0] = 0;
offx[1] = 1;
offx[2] = 0;
offx[3] = 1;
offy[0] = 0;
offy[1] = 0;
offy[2] = 1;
offy[3] = 1;
uint8_t atrb[4];
for (int i = 0; i < 4; i++)
unsigned char atrb[4];
for (i = 0; i < 4; i++)
{
atrb[i] = GetAttribute(x + offx[i], y + offy[i]);
switch (atrb[i])
{
// Water
case 0x02:
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
// Block
case 0x05:
case 0x41:
@ -437,11 +442,6 @@ void HitMyCharMap()
gMC.flag |= JudgeHitMyCharBlock(x + offx[i], y + offy[i]);
break;
// Spikes
case 0x42:
gMC.flag |= JudgeHitMyCharDamage(x + offx[i], y + offy[i]);
break;
// Slopes
case 0x50:
gMC.flag |= JudgeHitMyCharTriangleA(x + offx[i], y + offy[i]);
@ -475,6 +475,38 @@ void HitMyCharMap()
gMC.flag |= JudgeHitMyCharTriangleH(x + offx[i], y + offy[i]);
break;
// Spikes
case 0x42:
gMC.flag |= JudgeHitMyCharDamage(x + offx[i], y + offy[i]);
break;
// Water spikes
case 0x62:
gMC.flag |= JudgeHitMyCharDamageW(x + offx[i], y + offy[i]);
break;
// Wind
case 0x80:
gMC.flag |= JudgeHitMyCharVectLeft(x + offx[i], y + offy[i]);
break;
case 0x81:
gMC.flag |= JudgeHitMyCharVectUp(x + offx[i], y + offy[i]);
break;
case 0x82:
gMC.flag |= JudgeHitMyCharVectRight(x + offx[i], y + offy[i]);
break;
case 0x83:
gMC.flag |= JudgeHitMyCharVectDown(x + offx[i], y + offy[i]);
break;
// Water
case 0x02:
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
// Water and water blocks
case 0x60:
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
@ -485,11 +517,6 @@ void HitMyCharMap()
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
// Water spikes
case 0x62:
gMC.flag |= JudgeHitMyCharDamageW(x + offx[i], y + offy[i]);
break;
// Water slopes
case 0x70:
gMC.flag |= JudgeHitMyCharTriangleA(x + offx[i], y + offy[i]);
@ -531,23 +558,6 @@ void HitMyCharMap()
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
// Wind
case 0x80:
gMC.flag |= JudgeHitMyCharVectLeft(x + offx[i], y + offy[i]);
break;
case 0x81:
gMC.flag |= JudgeHitMyCharVectUp(x + offx[i], y + offy[i]);
break;
case 0x82:
gMC.flag |= JudgeHitMyCharVectRight(x + offx[i], y + offy[i]);
break;
case 0x83:
gMC.flag |= JudgeHitMyCharVectDown(x + offx[i], y + offy[i]);
break;
// Water current
case 0xA0:
gMC.flag |= JudgeHitMyCharVectLeft(x + offx[i], y + offy[i]);
@ -568,9 +578,6 @@ void HitMyCharMap()
gMC.flag |= JudgeHitMyCharVectDown(x + offx[i], y + offy[i]);
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
default:
break;
}
}
@ -633,20 +640,20 @@ int JudgeHitMyCharNPC(NPCHAR *npc)
return hit;
}
int JudgeHitMyCharNPC3(NPCHAR *npc)
unsigned char JudgeHitMyCharNPC3(NPCHAR *npc)
{
if (npc->direct)
if (npc->direct == 0)
{
if (gMC.x + 0x400 > npc->x - npc->hit.back
&& gMC.x - 0x400 < npc->x + npc->hit.front
if (gMC.x + 0x400 > npc->x - npc->hit.front
&& gMC.x - 0x400 < npc->x + npc->hit.back
&& gMC.y + 0x400 > npc->y - npc->hit.top
&& gMC.y - 0x400 < npc->y + npc->hit.bottom)
return 1;
}
else
{
if (gMC.x + 0x400 > npc->x - npc->hit.front
&& gMC.x - 0x400 < npc->x + npc->hit.back
if (gMC.x + 0x400 > npc->x - npc->hit.back
&& gMC.x - 0x400 < npc->x + npc->hit.front
&& gMC.y + 0x400 > npc->y - npc->hit.top
&& gMC.y - 0x400 < npc->y + npc->hit.bottom)
return 1;
@ -658,65 +665,47 @@ int JudgeHitMyCharNPC3(NPCHAR *npc)
int JudgeHitMyCharNPC4(NPCHAR *npc)
{
// TODO: comment this
float fx1;
float fx2;
float fy1;
float fy2;
int hit = 0;
long double v1, v2;
if (npc->x <= gMC.x)
v1 = (long double)(gMC.x - npc->x);
if (npc->x > gMC.x)
fx1 = (float)(npc->x - gMC.x);
else
v1 = (long double)(npc->x - gMC.x);
fx1 = (float)(gMC.x - npc->x);
float fx1 = (float)v1;
if (npc->y <= gMC.y)
v2 = (long double)(gMC.y - npc->y);
if (npc->y > gMC.y)
fy1 = (float)(npc->y - gMC.y);
else
v2 = (long double)(npc->y - gMC.y);
fy1 = (float)(gMC.y - npc->y);
float fx2 = (float)npc->hit.back;
if (0.0 == fx1)
fx1 = 1.0;
if (0.0 == fx2)
fx2 = 1.0;
fx2 = (float)npc->hit.back;
fy2 = (float)npc->hit.top;
float fy1 = (float)v2;
float fy2 = (float)npc->hit.top;
if (fx1 == 0.0f)
fx1 = 1.0f;
if (fx2 == 0.0f)
fx2 = 1.0f;
if (fy1 / fx1 <= fy2 / fx2)
if (fy1 / fx1 > fy2 / fx2)
{
if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top)
{
if (gMC.x - gMC.hit.right < npc->x + npc->hit.back && gMC.x - gMC.hit.right > npc->x)
{
if (gMC.xm < npc->xm)
gMC.xm = npc->xm;
gMC.x = npc->hit.back + npc->x + gMC.hit.right;
hit |= 1;
}
if (gMC.x + gMC.hit.right > npc->x - npc->hit.back && gMC.hit.right + gMC.x < npc->x)
{
if (gMC.xm > npc->xm)
gMC.xm = npc->xm;
gMC.x = npc->x - npc->hit.back - gMC.hit.right;
hit |= 4;
}
}
}
else if (gMC.x - gMC.hit.right < npc->x + npc->hit.back && gMC.x + gMC.hit.right > npc->x - npc->hit.back)
if (gMC.x - gMC.hit.right < npc->x + npc->hit.back && gMC.x + gMC.hit.right > npc->x - npc->hit.back)
{
if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom && gMC.y - gMC.hit.top > npc->y)
{
if (gMC.ym >= npc->ym)
{
if (gMC.ym < 0)
gMC.ym = 0;
}
else
if (gMC.ym < npc->ym)
{
gMC.y = npc->hit.bottom + npc->y + gMC.hit.top + 0x200;
gMC.ym = npc->ym;
}
else
{
if (gMC.ym < 0)
gMC.ym = 0;
}
hit |= 2;
}
@ -745,20 +734,52 @@ int JudgeHitMyCharNPC4(NPCHAR *npc)
}
}
}
}
else
{
if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top)
{
if (gMC.x - gMC.hit.right < npc->x + npc->hit.back && gMC.x - gMC.hit.right > npc->x)
{
if (gMC.xm < npc->xm)
gMC.xm = npc->xm;
gMC.x = npc->hit.back + npc->x + gMC.hit.right;
hit |= 1;
}
if (gMC.x + gMC.hit.right > npc->x - npc->hit.back && gMC.hit.right + gMC.x < npc->x)
{
if (gMC.xm > npc->xm)
gMC.xm = npc->xm;
gMC.x = npc->x - npc->hit.back - gMC.hit.right;
hit |= 4;
}
}
}
return hit;
}
void HitMyCharNpChar()
{
if ((gMC.cond & 0x80) && !(gMC.cond & 2))
{
int hit;
int i;
for (int i = 0; i < NPC_MAX; i++)
{
if (gNPC[i].cond & 0x80)
int hit = 0;
if ((gMC.cond & 0x80) == 0 || (gMC.cond & 2))
return;
for (i = 0; i < NPC_MAX; i++)
{
if ((gNPC[i].cond & 0x80) == 0)
continue;
hit = 0;
if (gNPC[i].bits & npc_solidSoft)
{
hit = JudgeHitMyCharNPC(&gNPC[i]);
@ -797,11 +818,11 @@ void HitMyCharNpChar()
}
// Run event on contact
if (!(g_GameFlags & 4) && hit && gNPC[i].bits & npc_eventTouch)
if ((g_GameFlags & 4) == 0 && hit && gNPC[i].bits & npc_eventTouch)
StartTextScript(gNPC[i].code_event);
// NPC damage
if (g_GameFlags & 2 && !(gNPC[i].bits & npc_interact))
if (g_GameFlags & 2 && (gNPC[i].bits & npc_interact) == 0)
{
if (gNPC[i].bits & npc_rearTop)
{
@ -821,30 +842,33 @@ void HitMyCharNpChar()
}
// Interaction
if (!(g_GameFlags & 4) && hit && gMC.cond & 1 && gNPC[i].bits & npc_interact)
if ((g_GameFlags & 4) == 0 && hit && gMC.cond & 1 && gNPC[i].bits & npc_interact)
{
StartTextScript(gNPC[i].code_event);
gMC.xm = 0;
gMC.ques = 0;
}
}
}
// Create question mark when NPC hasn't been interacted with
if (gMC.ques)
SetCaret(gMC.x, gMC.y, 9, 0);
}
}
void HitMyCharBoss()
{
if ((gMC.cond & 0x80) && !(gMC.cond & 2))
{
int hit = 0;
if ((gMC.cond & 0x80) == 0 || (gMC.cond & 2))
return;
for (int b = 0; b < BOSS_MAX; b++)
{
if (gBoss[b].cond & 0x80)
{
int hit;
if ((gBoss[b].cond & 0x80) == 0)
continue;
hit = 0;
if (gBoss[b].bits & npc_solidSoft)
{
hit = JudgeHitMyCharNPC(&gBoss[b]);
@ -885,9 +909,7 @@ void HitMyCharBoss()
gMC.ques = 0;
}
}
}
if (gMC.ques)
SetCaret(gMC.x, gMC.y, 9, 0);
}
}

View file

@ -1,7 +1,5 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
struct ARMS_LEVEL
@ -11,8 +9,8 @@ struct ARMS_LEVEL
struct REC
{
int32_t counter[4];
uint8_t random[4];
long counter[4];
unsigned char random[4];
};
extern ARMS_LEVEL gArmsLevelTable[14];

View file

@ -1,7 +1,6 @@
#include "NpChar.h"
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@ -27,7 +26,7 @@ int gCurlyShoot_y;
int gSuperXpos;
int gSuperYpos;
const char *gPassPixEve = "PXE\0";
const char *gPassPixEve = "PXE";
void InitNpChar()
{
@ -55,10 +54,16 @@ void SetUniqueParameter(NPCHAR *npc)
BOOL LoadEvent(const char *path_event)
{
FILE *fp;
int count;
int i;
int n;
EVENT eve;
char path[PATH_LENGTH];
sprintf(path, "%s/%s", gDataPath, path_event);
FILE *fp = fopen(path, "rb");
fp = fopen(path, "rb");
if (fp == NULL)
return FALSE;
@ -75,33 +80,37 @@ BOOL LoadEvent(const char *path_event)
}
//Get amount of NPCs
int count = File_ReadLE32(fp);
#ifdef NONPORTABLE
fread(&count, 4, 1, fp);
#else
count = File_ReadLE32(fp);
#endif
//Load NPCs
memset(gNPC, 0, sizeof(gNPC));
int n = 170;
for (int i = 0; i < count; i++)
n = 170;
for (i = 0; i < count; i++)
{
//Get data from file
EVENT eve;
#ifdef NONPORTABLE
fread(&eve, sizeof(EVENT), 1, fp);
#else
eve.x = File_ReadLE16(fp);
eve.y = File_ReadLE16(fp);
eve.code_flag = File_ReadLE16(fp);
eve.code_event = File_ReadLE16(fp);
eve.code_char = File_ReadLE16(fp);
eve.bits = File_ReadLE16(fp);
#endif
//Set NPC parameters
if (eve.bits & npc_altDir)
gNPC[n].direct = 2;
else
gNPC[n].direct = 0;
gNPC[n].direct = (eve.bits & npc_altDir) ? 2 : 0;
gNPC[n].code_char = eve.code_char;
gNPC[n].code_event = eve.code_event;
gNPC[n].code_flag = eve.code_flag;
gNPC[n].x = eve.x << 13;
gNPC[n].y = eve.y << 13;
gNPC[n].x = eve.x * 0x10 * 0x200;
gNPC[n].y = eve.y * 0x10 * 0x200;
gNPC[n].bits = eve.bits;
gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
@ -110,13 +119,13 @@ BOOL LoadEvent(const char *path_event)
//Check flags
if (gNPC[n].bits & npc_appearSet)
{
if (GetNPCFlag(gNPC[n].code_flag))
gNPC[n].cond |= 0x80u;
if (GetNPCFlag(gNPC[n].code_flag) == TRUE)
gNPC[n].cond |= 0x80;
}
else if (gNPC[n].bits & npc_hideSet)
{
if (!GetNPCFlag(gNPC[n].code_flag))
gNPC[n].cond |= 0x80u;
if (GetNPCFlag(gNPC[n].code_flag) == FALSE)
gNPC[n].cond |= 0x80;
}
else
{
@ -133,10 +142,13 @@ BOOL LoadEvent(const char *path_event)
void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index)
{
for (int n = start_index; n < NPC_MAX; n++)
{
if (!gNPC[n].cond)
{
int n = start_index;
while (n < NPC_MAX && gNPC[n].cond)
++n;
if (n == NPC_MAX)
return;
//Set NPC parameters
memset(&gNPC[n], 0, sizeof(NPCHAR));
gNPC[n].cond |= 0x80u;
@ -150,20 +162,17 @@ void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
SetUniqueParameter(&gNPC[n]);
break;
}
}
}
void SetDestroyNpChar(int x, int y, int w, int num)
{
//Create smoke
int wa = w / 0x200;
w /= 0x200;
for (int i = 0; i < num; i++)
{
int offset_x = Random(-wa, wa) << 9;
int offset_y = Random(-wa, wa) << 9;
SetNpChar(4, x + offset_x, offset_y + y, 0, 0, 0, NULL, 0x100);
int offset_x = Random(-w, w) * 0x200;
int offset_y = Random(-w, w) * 0x200;
SetNpChar(4, x + offset_x, y + offset_y, 0, 0, 0, NULL, 0x100);
}
//Flash effect
@ -173,12 +182,12 @@ void SetDestroyNpChar(int x, int y, int w, int num)
void SetDestroyNpCharUp(int x, int y, int w, int num)
{
//Create smoke
int wa = w / 0x200;
w /= 0x200;
for (int i = 0; i < num; i++)
{
int offset_x = Random(-wa, wa) << 9;
int offset_y = Random(-wa, wa) << 9;
SetNpChar(4, x + offset_x, offset_y + y, 0, 0, 1, NULL, 0x100);
int offset_x = Random(-w, w) * 0x200;
int offset_y = Random(-w, w) * 0x200;
SetNpChar(4, x + offset_x, y + offset_y, 0, 0, 1, NULL, 0x100);
}
//Flash effect
@ -188,82 +197,83 @@ void SetDestroyNpCharUp(int x, int y, int w, int num)
void SetExpObjects(int x, int y, int exp)
{
int sub_exp;
for (int n = 0x100; exp; SetUniqueParameter(&gNPC[n]))
int n = 0x100;
while (exp)
{
while (true)
{
bool v3 = n < NPC_MAX && gNPC[n].cond;
if (!v3)
break;
while (n < NPC_MAX && gNPC[n].cond)
++n;
}
if (n == NPC_MAX)
break;
memset(&gNPC[n], 0, sizeof(NPCHAR));
if (exp < 20)
{
if (exp < 5)
{
if (exp > 0)
{
--exp;
sub_exp = 1;
}
}
else
{
exp -= 5;
sub_exp = 5;
}
}
else
if (exp >= 20)
{
exp -= 20;
sub_exp = 20;
}
else if (exp >= 5)
{
exp -= 5;
sub_exp = 5;
}
else if (exp >= 1)
{
exp -= 1;
sub_exp = 1;
}
gNPC[n].cond |= 0x80u;
gNPC[n].cond |= 0x80;
gNPC[n].direct = 0;
gNPC[n].code_char = 1;
gNPC[n].x = x;
gNPC[n].y = y;
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = sub_exp;
SetUniqueParameter(&gNPC[n]);
}
}
BOOL SetBulletObject(int x, int y, int val)
{
int tamakazu_ari[10];
int n;
int t = 0;
int bullet_no;
int tamakazu_ari[10];
int n;
memset(tamakazu_ari, 0, sizeof(tamakazu_ari));
for (n = 0; n < 8; n++)
for (n = 0; n < 8; ++n)
{
int code = gArmsData[n].code;
if (code == 5)
switch (gArmsData[n].code)
{
case 5:
tamakazu_ari[t++] = 0;
else if (code == 10)
break;
case 10:
tamakazu_ari[t++] = 1;
else
break;
default:
tamakazu_ari[t] = 0;
break;
}
}
if (!t)
if (t == 0)
return FALSE;
n = Random(1, 10 * t);
int bullet_no = tamakazu_ari[n % t];
for (n = 0x100; n < NPC_MAX; n++)
{
if (!gNPC[n].cond)
{
bullet_no = tamakazu_ari[n % t];
n = 0x100;
while (n < NPC_MAX && gNPC[n].cond)
++n;
if (n == NPC_MAX)
return FALSE;
memset(&gNPC[n], 0, sizeof(NPCHAR));
gNPC[n].cond |= 0x80u;
gNPC[n].cond |= 0x80;
gNPC[n].direct = 0;
gNPC[n].code_event = bullet_no;
gNPC[n].code_char = 86;
@ -274,19 +284,18 @@ BOOL SetBulletObject(int x, int y, int val)
SetUniqueParameter(&gNPC[n]);
return TRUE;
}
}
return FALSE;
}
BOOL SetLifeObject(int x, int y, int val)
{
for (int n = 0x100; n < NPC_MAX; n++)
{
if (!gNPC[n].cond)
{
int n = 0x100;
while (n < NPC_MAX && gNPC[n].cond)
++n;
if (n == NPC_MAX)
return FALSE;
memset(&gNPC[n], 0, sizeof(NPCHAR));
gNPC[n].cond |= 0x80u;
gNPC[n].cond |= 0x80;
gNPC[n].direct = 0;
gNPC[n].code_char = 87;
gNPC[n].x = x;
@ -296,10 +305,6 @@ BOOL SetLifeObject(int x, int y, int val)
SetUniqueParameter(&gNPC[n]);
return TRUE;
}
}
return FALSE;
}
void VanishNpChar(NPCHAR *npc)
{
@ -309,7 +314,7 @@ void VanishNpChar(NPCHAR *npc)
npc->count1 = 0;
npc->x = x;
npc->y = y;
npc->cond |= 0x80u;
npc->cond |= 0x80;
npc->direct = 0;
npc->code_char = 3;
npc->bits = gNpcTable[npc->code_char].bits;
@ -319,15 +324,15 @@ void VanishNpChar(NPCHAR *npc)
void PutNpChar(int fx, int fy)
{
for (int n = 0; n < NPC_MAX; n++)
signed char a = 0;
for (int n = 0; n < NPC_MAX; ++n)
{
if (gNPC[n].cond & 0x80)
{
int8_t a;
if (gNPC[n].shock)
{
a = 2 * ((gNPC[n].shock >> 1) & 1) - 1;
a = 2 * ((gNPC[n].shock / 2) % 2) - 1;
}
else
{
@ -340,10 +345,10 @@ void PutNpChar(int fx, int fy)
}
int side;
if (gNPC[n].direct)
side = gNPC[n].view.back;
else
if (gNPC[n].direct == 0)
side = gNPC[n].view.front;
else
side = gNPC[n].view.back;
PutBitmap3(
&grcGame,
@ -357,11 +362,13 @@ void PutNpChar(int fx, int fy)
void ActNpChar()
{
for (int i = 0; i < NPC_MAX; i++)
for (int i = 0; i < NPC_MAX; ++i)
{
if (gNPC[i].cond & 0x80)
{
gpNpcFuncTbl[gNPC[i].code_char](&gNPC[i]);
int code_char = gNPC[i].code_char;
gpNpcFuncTbl[code_char](&gNPC[i]);
if (gNPC[i].shock)
--gNPC[i].shock;
@ -373,14 +380,14 @@ void ChangeNpCharByEvent(int code_event, int code_char, int dir)
{
for (int n = 0; n < NPC_MAX; n++)
{
if ((gNPC[n].cond & 0x80u) && gNPC[n].code_event == code_event)
if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
gNPC[n].bits &= (npc_eventTouch | npc_eventDie | 0x400 | npc_appearSet | npc_altDir | npc_interact | npc_hideSet);
gNPC[n].code_char = code_char;
gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
SetUniqueParameter(&gNPC[n]);
gNPC[n].cond |= 0x80u;
gNPC[n].cond |= 0x80;
gNPC[n].act_no = 0;
gNPC[n].act_wait = 0;
gNPC[n].count1 = 0;
@ -390,20 +397,21 @@ void ChangeNpCharByEvent(int code_event, int code_char, int dir)
gNPC[n].xm = 0;
gNPC[n].ym = 0;
if (dir != 5)
if (dir == 5)
{
if (dir == 4)
// Another empty case that has to exist for the same assembly to be generated
}
else if (dir == 4)
{
if (gNPC[n].x >= gMC.x)
gNPC[n].direct = 0;
else
if (gNPC[n].x < gMC.x)
gNPC[n].direct = 2;
else
gNPC[n].direct = 0;
}
else
{
gNPC[n].direct = dir;
}
}
gpNpcFuncTbl[code_char](&gNPC[n]);
}
@ -414,15 +422,15 @@ void ChangeCheckableNpCharByEvent(int code_event, int code_char, int dir)
{
for (int n = 0; n < NPC_MAX; n++)
{
if ((gNPC[n].cond & 0x80u) != 0 && gNPC[n].code_event == code_event)
if ((gNPC[n].cond & 0x80) != 0 && gNPC[n].code_event == code_event)
{
gNPC[n].bits &= (npc_eventTouch | npc_eventDie | 0x400 | npc_appearSet | npc_altDir | npc_interact | npc_hideSet);
gNPC[n].bits &= ~(npc_showDamage | npc_rearTop | npc_solidHard | npc_shootable | npc_bouncy | npc_ignoreSolid | npc_invulnerable | npc_ignore44 | npc_solidSoft);
gNPC[n].bits |= npc_interact;
gNPC[n].code_char = code_char;
gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
SetUniqueParameter(&gNPC[n]);
gNPC[n].cond |= 0x80u;
gNPC[n].cond |= 0x80;
gNPC[n].act_no = 0;
gNPC[n].act_wait = 0;
gNPC[n].count1 = 0;
@ -432,19 +440,20 @@ void ChangeCheckableNpCharByEvent(int code_event, int code_char, int dir)
gNPC[n].xm = 0;
gNPC[n].ym = 0;
if (dir != 5)
if (dir == 5)
{
if (dir == 4)
// Another empty case that has to exist for the same assembly to be generated
}
else if (dir == 4)
{
if (gNPC[n].x >= gMC.x)
gNPC[n].direct = 0;
else
if (gNPC[n].x < gMC.x)
gNPC[n].direct = 2;
else
gNPC[n].direct = 0;
}
else
{
gNPC[n].direct = dir;
}
gNPC[n].direct = (signed char)dir;
}
gpNpcFuncTbl[code_char](&gNPC[n]);
@ -454,95 +463,111 @@ void ChangeCheckableNpCharByEvent(int code_event, int code_char, int dir)
void SetNpCharActionNo(int code_event, int act_no, int dir)
{
for (int n = 0; n < NPC_MAX; n++)
int n = 0;
while (n < NPC_MAX)
{
if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
break;
++n;
}
if (n == NPC_MAX)
return;
gNPC[n].act_no = act_no;
if (dir != 5)
if (dir == 5)
{
if (dir == 4)
// Another empty case that has to exist for the same assembly to be generated
}
else if (dir == 4)
{
if (gNPC[n].x >= gMC.x)
gNPC[n].direct = 0;
else
if (gNPC[n].x < gMC.x)
gNPC[n].direct = 2;
else
gNPC[n].direct = 0;
}
else
{
gNPC[n].direct = dir;
}
}
break;
}
}
}
void MoveNpChar(int code_event, int x, int y, int dir)
{
for (int n = 0; n < NPC_MAX; n++)
int n = 0;
while (n < NPC_MAX)
{
if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
break;
++n;
}
if (n == NPC_MAX)
return;
gNPC[n].x = x;
gNPC[n].y = y;
if (dir != 5)
if (dir == 5)
{
if (dir == 4)
// Another empty case that has to exist for the same assembly to be generated
}
else if (dir == 4)
{
if (gNPC[n].x >= gMC.x)
gNPC[n].direct = 0;
else
if (gNPC[n].x < gMC.x)
gNPC[n].direct = 2;
else
gNPC[n].direct = 0;
}
else
{
gNPC[n].direct = dir;
}
}
break;
}
gNPC[n].direct = (signed char)dir;
}
}
void BackStepMyChar(int code_event)
{
int n = 0;
gMC.cond &= ~1;
gMC.ym = -0x200;
if (code_event)
if (code_event == 0)
{
if (code_event == 2)
gMC.direct = 0;
gMC.xm = 0x200;
}
else if (code_event == 2)
{
gMC.direct = 2;
gMC.xm = -0x200;
}
else
{
for (int n = 0; n < NPC_MAX; n++)
while (n < NPC_MAX)
{
if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
break;
++n;
}
if (n == NPC_MAX)
return;
if (gNPC[n].x < gMC.x)
{
if (gNPC[n].x >= gMC.x)
gMC.direct = 0;
gMC.xm = 0x200;
}
else
{
gMC.direct = 2;
gMC.xm = -0x200;
}
else
{
gMC.direct = 0;
gMC.xm = 0x200;
}
}
}
}
}
else
{
gMC.direct = 0;
gMC.xm = 0x200;
}
}
@ -558,7 +583,7 @@ void DeleteNpCharEvent(int code)
}
}
void DeleteNpCharCode(int code, bool bSmoke)
void DeleteNpCharCode(int code, BOOL bSmoke)
{
for (int n = 0; n < NPC_MAX; n++)
{
@ -573,15 +598,15 @@ void DeleteNpCharCode(int code, bool bSmoke)
switch (gNPC[n].size)
{
case 1:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 4);
break;
case 2:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 8);
break;
case 3:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 16);
break;
case 1:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 4);
break;
}
}
}
@ -596,23 +621,23 @@ void GetNpCharPosition(int *x, int *y, int i)
BOOL IsNpCharCode(int code)
{
for (int i = 0; i < NPC_MAX; i++)
{
for (int i = 0; i < NPC_MAX; ++i)
if ((gNPC[i].cond & 0x80) && gNPC[i].code_char == code)
return TRUE;
}
return FALSE;
}
BOOL GetNpCharAlive(int code_event)
{
for (int i = 0; i < NPC_MAX; i++)
{
int i;
for (i = 0; i < NPC_MAX; ++i)
if ((gNPC[i].cond & 0x80) && gNPC[i].code_event == code_event)
return TRUE;
}
break;
if (i < NPC_MAX)
return TRUE;
else
return FALSE;
}

View file

@ -1,7 +1,5 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
#include "Draw.h"
@ -29,7 +27,7 @@ enum NPC_flags
struct NPCHAR
{
uint8_t cond;
unsigned char cond;
int flag;
int x;
int y;
@ -49,7 +47,7 @@ struct NPCHAR
int exp;
int size;
int direct;
uint16_t bits;
unsigned short bits;
RECT rect;
int ani_wait;
int ani_no;
@ -59,7 +57,7 @@ struct NPCHAR
int act_wait;
RECT hit;
RECT view;
uint8_t shock;
unsigned char shock;
int damage_view;
int damage;
NPCHAR *pNpc;
@ -67,12 +65,12 @@ struct NPCHAR
struct EVENT
{
int16_t x;
int16_t y;
int16_t code_flag;
int16_t code_event;
int16_t code_char;
uint16_t bits;
short x;
short y;
short code_flag;
short code_event;
short code_char;
unsigned short bits;
};
extern NPCHAR gNPC[NPC_MAX];
@ -99,7 +97,7 @@ void SetNpCharActionNo(int code_event, int act_no, int dir);
void MoveNpChar(int code_event, int x, int y, int dir);
void BackStepMyChar(int code_event);
void DeleteNpCharEvent(int code);
void DeleteNpCharCode(int code, bool bSmoke);
void DeleteNpCharCode(int code, BOOL bSmoke);
void GetNpCharPosition(int *x, int *y, int i);
BOOL IsNpCharCode(int code);
BOOL GetNpCharAlive(int code_event);

View file

@ -1352,8 +1352,18 @@ void ActNpc117(NPCHAR *npc)
break;
case 3:
// TODO: This code is being problematic, and
// assembling with the wrong registers.
if (0)
{
// There used to be an if here that didn't do anything, but the compiler optimised it out.
// We only know this was here because empty ifs mess with the register usage.
// Since there's no code, we have no idea what the original condition actually was.
}
if (0)
{
// Another empty if
}
npc->act_no = 4;
npc->ani_no = 1;
npc->ani_wait = 0;
@ -1382,9 +1392,15 @@ void ActNpc117(NPCHAR *npc)
npc->ani_no = 5;
SetDestroyNpChar(npc->x, npc->y, npc->view.back, 8);
break;
// End of wrong-reg code
case 6:
if (0)
{
// There used to be an if here that didn't do anything, but the compiler optimised it out.
// We only know this was here because empty ifs mess with the register usage.
// Since there's no code, we have no idea what the original condition actually was.
}
npc->ani_no = 5;
break;

View file

@ -1,5 +1,7 @@
#include "NpcHit.h"
#include "WindowsWrapper.h"
#include "Back.h"
#include "Bullet.h"
#include "Caret.h"
@ -16,40 +18,40 @@ void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y)
{
int hit = 0;
if (npc->y - npc->hit.top < ((2 * y + 1) << 12) - 0x600
&& npc->y + npc->hit.bottom > ((2 * y - 1) << 12) + 0x600
&& npc->x - npc->hit.back < (2 * x + 1) << 12
&& npc->x - npc->hit.back > x << 13)
if (npc->y - npc->hit.top < (y * 0x10 + 5) * 0x200
&& npc->y + npc->hit.bottom > (y * 0x10 - 5) * 0x200
&& npc->x - npc->hit.back < (x * 0x10 + 8) * 0x200
&& npc->x - npc->hit.back > x * 0x10 * 0x200)
{
npc->x = ((2 * x + 1) << 12) + npc->hit.back;
npc->x = ((x * 0x10 + 8) * 0x200) + npc->hit.back;
hit |= 1;
}
if (npc->y - npc->hit.top < ((2 * y + 1) << 12) - 0x600
&& npc->y + npc->hit.bottom > ((2 * y - 1) << 12) + 0x600
&& npc->hit.back + npc->x > (2 * x - 1) << 12
&& npc->hit.back + npc->x < x << 13)
if (npc->y - npc->hit.top < (y * 0x10 + 5) * 0x200
&& npc->y + npc->hit.bottom > (y * 0x10 - 5) * 0x200
&& npc->x + npc->hit.back > (x * 0x10 - 8) * 0x200
&& npc->x + npc->hit.back < x * 0x10 * 0x200)
{
npc->x = ((2 * x - 1) << 12) - npc->hit.back;
npc->x = ((x * 0x10 - 8) * 0x200) - npc->hit.back;
hit |= 4;
}
if (npc->x - npc->hit.back < ((2 * x + 1) << 12) - 0x600
&& npc->hit.back + npc->x > ((2 * x - 1) << 12) + 0x600
&& npc->y - npc->hit.top < (2 * y + 1) << 12
&& npc->y - npc->hit.top > y << 13)
if (npc->x - npc->hit.back < (x * 0x10 + 5) * 0x200
&& npc->x + npc->hit.back > (x * 0x10 - 5) * 0x200
&& npc->y - npc->hit.top < (y * 0x10 + 8) * 0x200
&& npc->y - npc->hit.top > y * 0x10 * 0x200)
{
npc->y = ((2 * y + 1) << 12) + npc->hit.top;
npc->y = ((y * 0x10 + 8) * 0x200) + npc->hit.top;
npc->ym = 0;
hit |= 2;
}
if (npc->x - npc->hit.back < ((2 * x + 1) << 12) - 0x600
&& npc->hit.back + npc->x > ((2 * x - 1) << 12) + 0x600
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12
&& npc->y + npc->hit.bottom < y << 13)
if (npc->x - npc->hit.back < (x * 0x10 + 5) * 0x200
&& npc->x + npc->hit.back > (x * 0x10 - 5) * 0x200
&& npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200
&& npc->y + npc->hit.bottom < y * 0x10 * 0x200)
{
npc->y = ((2 * y - 1) << 12) - npc->hit.bottom;
npc->y = ((y * 0x10 - 8) * 0x200) - npc->hit.bottom;
npc->ym = 0;
hit |= 8;
}
@ -61,20 +63,20 @@ void JudgeHitNpCharTriangleA(NPCHAR *npc, int x, int y)
{
int hit = 0;
if (npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12
&& npc->y - npc->hit.top < (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12)
if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (x * 0x10 - 8) * 0x200
&& npc->y - npc->hit.top < (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800
&& npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
{
//Clip
npc->y = npc->hit.top + (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800;
npc->y = (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800 + npc->hit.top;
//Halt momentum
if (npc->ym < 0)
npc->ym = 0;
//Set that hit a ceiling
hit = 2;
hit |= 2;
}
npc->flag |= hit;
@ -84,20 +86,20 @@ void JudgeHitNpCharTriangleB(NPCHAR *npc, int x, int y)
{
int hit = 0;
if (npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12
&& npc->y - npc->hit.top < (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12)
if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (x * 0x10 - 8) * 0x200
&& npc->y - npc->hit.top < (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800
&& npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
{
//Clip
npc->y = npc->hit.top + (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800;
npc->y = (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800 + npc->hit.top;
//Halt momentum
if (npc->ym < 0)
npc->ym = 0;
//Set that hit a ceiling
hit = 2;
hit |= 2;
}
npc->flag |= hit;
@ -107,20 +109,20 @@ void JudgeHitNpCharTriangleC(NPCHAR *npc, int x, int y)
{
int hit = 0;
if (npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12
&& npc->y - npc->hit.top < (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12)
if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (x * 0x10 - 8) * 0x200
&& npc->y - npc->hit.top < (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800
&& npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
{
//Clip
npc->y = npc->hit.top + (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800;
npc->y = (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800 + npc->hit.top;
//Halt momentum
if (npc->ym < 0)
npc->ym = 0;
//Set that hit a ceiling
hit = 2;
hit |= 2;
}
npc->flag |= hit;
@ -130,20 +132,20 @@ void JudgeHitNpCharTriangleD(NPCHAR *npc, int x, int y)
{
int hit = 0;
if (npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12
&& npc->y - npc->hit.top < (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12)
if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (x * 0x10 - 8) * 0x200
&& npc->y - npc->hit.top < (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800
&& npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
{
//Clip
npc->y = npc->hit.top + (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800;
npc->y = (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800 + npc->hit.top;
//Halt momentum
if (npc->ym < 0)
npc->ym = 0;
//Set that hit a ceiling
hit = 2;
hit |= 2;
}
npc->flag |= hit;
@ -151,22 +153,24 @@ void JudgeHitNpCharTriangleD(NPCHAR *npc, int x, int y)
void JudgeHitNpCharTriangleE(NPCHAR *npc, int x, int y)
{
int hit = 0x10000;
int hit = 0;
if ( npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12
&& npc->y + npc->hit.bottom > (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800
&& npc->y - npc->hit.top < (2 * y + 1) << 12 )
hit |= 0x10000;
if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (x * 0x10 - 8) * 0x200
&& npc->y + npc->hit.bottom > (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800
&& npc->y - npc->hit.top < (y * 0x10 + 8) * 0x200)
{
//Clip
npc->y = (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800 - npc->hit.bottom;
npc->y = (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800 - npc->hit.bottom;
//Halt momentum
if (npc->ym > 0)
npc->ym = 0;
//Set that hit this slope
hit = 0x10028;
hit |= 0x28;
}
npc->flag |= hit;
@ -174,22 +178,24 @@ void JudgeHitNpCharTriangleE(NPCHAR *npc, int x, int y)
void JudgeHitNpCharTriangleF(NPCHAR *npc, int x, int y)
{
int hit = 0x20000;
int hit = 0;
if ( npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12
&& npc->y + npc->hit.bottom > (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800
&& npc->y - npc->hit.top < (2 * y + 1) << 12 )
hit |= 0x20000;
if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x >= (x * 0x10 - 8) * 0x200 // Note that this function uses '>='. I'm not sure if this is a bug.
&& npc->y + npc->hit.bottom > (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800
&& npc->y - npc->hit.top < (y * 0x10 + 8) * 0x200)
{
//Clip
npc->y = (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800 - npc->hit.bottom;
npc->y = (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800 - npc->hit.bottom;
//Halt momentum
if (npc->ym > 0)
npc->ym = 0;
//Set that hit this slope
hit = 0x20028;
hit |= 0x28;
}
npc->flag |= hit;
@ -197,22 +203,24 @@ void JudgeHitNpCharTriangleF(NPCHAR *npc, int x, int y)
void JudgeHitNpCharTriangleG(NPCHAR *npc, int x, int y)
{
int hit = 0x40000;
int hit = 0;
if ( npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12
&& npc->y + npc->hit.bottom > (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800
&& npc->y - npc->hit.top < (2 * y + 1) << 12 )
hit |= 0x40000;
if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (x * 0x10 - 8) * 0x200
&& npc->y + npc->hit.bottom > (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800
&& npc->y - npc->hit.top < (y * 0x10 + 8) * 0x200)
{
//Clip
npc->y = (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800 - npc->hit.bottom;
npc->y = (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800 - npc->hit.bottom;
//Halt momentum
if (npc->ym > 0)
npc->ym = 0;
//Set that hit this slope
hit = 0x40018;
hit |= 0x18;
}
npc->flag |= hit;
@ -220,22 +228,24 @@ void JudgeHitNpCharTriangleG(NPCHAR *npc, int x, int y)
void JudgeHitNpCharTriangleH(NPCHAR *npc, int x, int y)
{
int hit = 0x80000;
int hit = 0;
if ( npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12
&& npc->y + npc->hit.bottom > (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800
&& npc->y - npc->hit.top < (2 * y + 1) << 12 )
hit |= 0x80000;
if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (x * 0x10 - 8) * 0x200
&& npc->y + npc->hit.bottom > (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800
&& npc->y - npc->hit.top < (y * 0x10 + 8) * 0x200)
{
//Clip
npc->y = (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800 - npc->hit.bottom;
npc->y = (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800 - npc->hit.bottom;
//Halt momentum
if (npc->ym > 0)
npc->ym = 0;
//Set that hit this slope
hit = 0x80018;
hit |= 0x18;
}
npc->flag |= hit;
@ -245,19 +255,24 @@ void JudgeHitNpCharWater(NPCHAR *npc, int x, int y)
{
int hit = 0;
if (npc->x - npc->hit.back < (4 * (2 * x + 1) - 1) << 10
&& npc->hit.back + npc->x > (4 * (2 * x - 1) + 1) << 10
&& npc->y - npc->hit.top < (4 * (2 * y + 1) - 1) << 10
&& npc->y + npc->hit.bottom > (4 * (2 * y - 1) + 1) << 10)
hit = 0x100;
if (npc->x - npc->hit.back < (x * 0x10 + 6) * 0x200
&& npc->x + npc->hit.back > (x * 0x10 - 6) * 0x200
&& npc->y - npc->hit.top < (y * 0x10 + 6) * 0x200
&& npc->y + npc->hit.bottom > (y * 0x10 - 6) * 0x200)
hit |= 0x100;
npc->flag |= hit;
}
void HitNpCharMap()
{
int offy[9];
int judg, x, y;
int offx[9];
int offy[9];
int i;
int j;
offx[0] = 0;
offx[1] = 1;
@ -279,37 +294,38 @@ void HitNpCharMap()
offy[7] = 2;
offy[8] = 2;
for (int i = 0; i < NPC_MAX; i++)
for (i = 0; i < NPC_MAX; i++)
{
if ((gNPC[i].cond & 0x80) && !(gNPC[i].bits & 8))
if ((gNPC[i].cond & 0x80) == 0)
continue;
if (gNPC[i].bits & 8)
continue;
if (gNPC[i].size >= 3)
{
int judg, x, y;
if (gNPC[i].size <= 2)
{
judg = 4;
x = gNPC[i].x / 0x2000;
y = gNPC[i].y / 0x2000;
judg = 9;
x = (gNPC[i].x - 0x1000) / 0x10 / 0x200;
y = (gNPC[i].y - 0x1000) / 0x10 / 0x200;
}
else
{
judg = 9;
x = (gNPC[i].x - 0x1000) / 0x2000;
y = (gNPC[i].y - 0x1000) / 0x2000;
judg = 4;
x = gNPC[i].x / 0x10 / 0x200;
y = gNPC[i].y / 0x10 / 0x200;
}
gNPC[i].flag = 0;
for (int j = 0; j < judg; j++)
for (j = 0; j < judg; j++)
{
switch (GetAttribute(x + offx[j], y + offy[j]))
{
//Water
case 0x02:
case 0x60:
case 0x62:
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
//No NPC block
case 0x44:
if (gNPC[i].bits & npc_ignore44)
break;
// Fallthrough
//Block
case 0x03:
case 0x05:
@ -318,20 +334,6 @@ void HitNpCharMap()
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
break;
//Water block
case 0x04:
case 0x61:
case 0x64:
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break;
//No NPC block
case 0x44:
if (!(gNPC[i].bits & npc_ignore44))
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
break;
//Slopes
case 0x50:
JudgeHitNpCharTriangleA(&gNPC[i], x + offx[j], y + offy[j]);
@ -365,6 +367,21 @@ void HitNpCharMap()
JudgeHitNpCharTriangleH(&gNPC[i], x + offx[j], y + offy[j]);
break;
//Water
case 0x02:
case 0x60:
case 0x62:
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break;
//Water block
case 0x04:
case 0x61:
case 0x64:
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break;
//Water slopes
case 0x70:
JudgeHitNpCharTriangleA(&gNPC[i], x + offx[j], y + offy[j]);
@ -405,7 +422,34 @@ void HitNpCharMap()
JudgeHitNpCharTriangleH(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break;
}
case 0xA0:
gNPC[i].flag |= 0x100;
// Fallthrough
case 0x80:
gNPC[i].flag |= 0x1000;
break;
case 0xA1:
gNPC[i].flag |= 0x100;
// Fallthrough
case 0x81:
gNPC[i].flag |= 0x2000;
break;
case 0xA2:
gNPC[i].flag |= 0x100;
// Fallthrough
case 0x82:
gNPC[i].flag |= 0x4000;
break;
case 0xA3:
gNPC[i].flag |= 0x100;
// Fallthrough
case 0x83:
gNPC[i].flag |= 0x8000;
break;
}
if (gNPC[i].y > gWaterY + 0x800)
@ -414,7 +458,7 @@ void HitNpCharMap()
}
}
void LoseNpChar(NPCHAR *npc, bool bVanish)
void LoseNpChar(NPCHAR *npc, BOOL bVanish)
{
//Play death sound
PlaySoundObject(npc->destroy_voice, 1);
@ -436,18 +480,34 @@ void LoseNpChar(NPCHAR *npc, bool bVanish)
//Create drop
if (npc->exp)
{
int v3 = Random(1, 5);
char v4;
int val;
if (v3 == 1)
switch (Random(1, 5))
{
if (npc->exp <= 6)
SetLifeObject(npc->x, npc->y, 2);
case 1:
// Spawn health
if (npc->exp > 6)
val = 6;
else
SetLifeObject(npc->x, npc->y, 6);
}
else if (v3 != 2 || (npc->exp <= 6 ? (v4 = SetBulletObject(npc->x, npc->y, 1)) : (v4 = SetBulletObject(npc->x, npc->y, 3)), !v4)) //TODO: what the FUCK
{
val = 2;
SetLifeObject(npc->x, npc->y, val);
break;
case 2:
// Spawn missile launcher ammo
if (npc->exp > 6)
val = 3;
else
val = 1;
if (SetBulletObject(npc->x, npc->y, val))
break;
// Fallthrough
default:
// Spawn weapon energy
SetExpObjects(npc->x, npc->y, npc->exp);
}
}
@ -456,43 +516,55 @@ void LoseNpChar(NPCHAR *npc, bool bVanish)
SetNPCFlag(npc->code_flag);
//Create value view
if (!(npc->bits & npc_showDamage))
{
npc->cond = 0;
}
else
if (npc->bits & npc_showDamage)
{
if ((npc->bits & npc_showDamage) && npc->damage_view)
SetValueView(&npc->x, &npc->y, npc->damage_view);
if (bVanish)
VanishNpChar(npc);
}
else
{
npc->cond = 0;
}
}
void HitNpCharBullet()
{
for (int n = 0; n < NPC_MAX; n++)
int n;
int b;
BOOL bHit;
for (n = 0; n < NPC_MAX; n++)
{
if ((gNPC[n].cond & 0x80) && (!(gNPC[n].bits & npc_shootable) || !(gNPC[n].bits & npc_interact)))
{
for (int b = 0; b < BULLET_MAX; b++)
{
if (gBul[b].cond & 0x80 && gBul[b].damage != -1)
if ((gNPC[n].cond & 0x80) == 0)
continue;
if (gNPC[n].bits & npc_shootable && gNPC[n].bits & npc_interact)
continue;
for (b = 0; b < BULLET_MAX; b++)
{
if ((gBul[b].cond & 0x80) == 0)
continue;
if (gBul[b].damage == -1)
continue;
//Check if bullet touches npc
bool bHit = false;
bHit = FALSE;
if (gNPC[n].bits & npc_shootable
&& gNPC[n].x - gNPC[n].hit.back < gBul[b].x + gBul[b].enemyXL
&& gNPC[n].x + gNPC[n].hit.back > gBul[b].x - gBul[b].enemyXL
&& gNPC[n].y - gNPC[n].hit.top < gBul[b].y + gBul[b].enemyYL
&& gNPC[n].y + gNPC[n].hit.bottom > gBul[b].y - gBul[b].enemyYL)
bHit = true;
bHit = TRUE;
else if (gNPC[n].bits & npc_invulnerable
&& gNPC[n].x - gNPC[n].hit.back < gBul[b].x + gBul[b].blockXL
&& gNPC[n].x + gNPC[n].hit.back > gBul[b].x - gBul[b].blockXL
&& gNPC[n].y - gNPC[n].hit.top < gBul[b].y + gBul[b].blockYL
&& gNPC[n].y + gNPC[n].hit.bottom > gBul[b].y - gBul[b].blockYL)
bHit = true;
bHit = TRUE;
if (bHit)
{
@ -501,7 +573,19 @@ void HitNpCharBullet()
{
gNPC[n].life -= gBul[b].damage;
if (gNPC[n].life > 0)
if (gNPC[n].life < 1)
{
gNPC[n].life = 0;
if (gNPC[n].bits & npc_showDamage)
gNPC[n].damage_view -= gBul[b].damage;
if ((gMC.cond & 0x80) && gNPC[n].bits & npc_eventDie)
StartTextScript(gNPC[n].code_event);
else
gNPC[n].cond |= 8;
}
else
{
if (gNPC[n].shock < 14)
{
@ -515,28 +599,19 @@ void HitNpCharBullet()
if (gNPC[n].bits & npc_showDamage)
gNPC[n].damage_view -= gBul[b].damage;
}
else
}
else if (gBul[b].code_bullet == 13
|| gBul[b].code_bullet == 14
|| gBul[b].code_bullet == 15
|| gBul[b].code_bullet == 28
|| gBul[b].code_bullet == 29
|| gBul[b].code_bullet == 30)
{
gNPC[n].life = 0;
if (gNPC[n].bits & npc_showDamage)
gNPC[n].damage_view -= gBul[b].damage;
if ((gMC.cond & 0x80) && gNPC[n].bits & npc_eventDie)
StartTextScript(gNPC[n].code_event);
else
gNPC[n].cond |= 8;
}
// Strange empty case that's needed for accurate assembly
}
else if ((gBul[b].bbits & 0x10) == 0)
{
//Hit invulnerable NPC
else if (gBul[b].code_bullet != 13
&& gBul[b].code_bullet != 14
&& gBul[b].code_bullet != 15
&& gBul[b].code_bullet != 28
&& gBul[b].code_bullet != 29
&& gBul[b].code_bullet != 30
&& !(gBul[b].bbits & 0x10))
{
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 2, 2);
PlaySoundObject(31, 1);
gBul[b].life = 0;
@ -546,10 +621,8 @@ void HitNpCharBullet()
--gBul[b].life;
}
}
}
if (gNPC[n].cond & 8)
LoseNpChar(&gNPC[n], true);
}
LoseNpChar(&gNPC[n], TRUE);
}
}

View file

@ -1,5 +1,7 @@
#pragma once
#include "WindowsWrapper.h"
#include "NpChar.h"
void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y);
@ -13,5 +15,5 @@ void JudgeHitNpCharTriangleG(NPCHAR *npc, int x, int y);
void JudgeHitNpCharTriangleH(NPCHAR *npc, int x, int y);
void JudgeHitNpCharWater(NPCHAR *npc, int x, int y);
void HitNpCharMap();
void LoseNpChar(NPCHAR *npc, bool bVanish);
void LoseNpChar(NPCHAR *npc, BOOL bVanish);
void HitNpCharBullet();

View file

@ -1,7 +1,5 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
#include "Draw.h"
@ -9,22 +7,22 @@
struct NPC_TBL_RECT
{
uint8_t front;
uint8_t top;
uint8_t back;
uint8_t bottom;
unsigned char front;
unsigned char top;
unsigned char back;
unsigned char bottom;
};
struct NPC_TABLE
{
uint16_t bits;
uint16_t life;
uint8_t surf;
uint8_t hit_voice;
uint8_t destroy_voice;
uint8_t size;
int32_t exp;
int32_t damage;
unsigned short bits;
unsigned short life;
unsigned char surf;
unsigned char hit_voice;
unsigned char destroy_voice;
unsigned char size;
long exp;
long damage;
NPC_TBL_RECT hit;
NPC_TBL_RECT view;
};

View file

@ -1,7 +1,6 @@
#include "Organya.h"
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
@ -33,7 +32,7 @@ int gTrackVol[MAXTRACK];
int gOrgVolume = 100;
bool bFadeout = false;
bool OrganyaNoteAlloc(uint16_t alloc)
bool OrganyaNoteAlloc(unsigned short alloc)
{
for(int j = 0; j < MAXTRACK; j++)
{
@ -110,7 +109,7 @@ OCTWAVE oct_wave[8] = {
{ 8,128, 32 }, //7 Oct
};
bool MakeSoundObject8(int8_t *wavep, int8_t track, int8_t pipi)
bool MakeSoundObject8(signed char *wavep, signed char track, signed char pipi)
{
for (int j = 0; j < 8; j++)
{
@ -123,13 +122,13 @@ bool MakeSoundObject8(int8_t *wavep, int8_t track, int8_t pipi)
lpORGANBUFFER[track][j][k] = new SOUNDBUFFER(data_size);
//Get wave data
uint8_t *wp = new uint8_t[data_size];
uint8_t *wp_sub = wp;
unsigned char *wp = new unsigned char[data_size];
unsigned char *wp_sub = wp;
size_t wav_tp = 0;
for (size_t i = 0; i < data_size; i++)
{
uint8_t work = *(wavep+wav_tp);
unsigned char work = *(wavep+wav_tp);
work += 0x80;
*wp_sub = work;
@ -142,7 +141,7 @@ bool MakeSoundObject8(int8_t *wavep, int8_t track, int8_t pipi)
}
//Copy wave data to sound buffer
uint8_t *buf;
unsigned char *buf;
lpORGANBUFFER[track][j][k]->Lock(&buf, NULL);
memcpy(buf, wp, data_size);
lpORGANBUFFER[track][j][k]->Unlock();
@ -157,7 +156,7 @@ bool MakeSoundObject8(int8_t *wavep, int8_t track, int8_t pipi)
//Playing melody tracks
short freq_tbl[12] = { 262,277,294,311,330,349,370,392,415,440,466,494 };
void ChangeOrganFrequency(uint8_t key, int8_t track, int32_t a)
void ChangeOrganFrequency(unsigned char key, signed char track, long a)
{
for (int j = 0; j < 8; j++) {
for (int i = 0; i < 2; i++) {
@ -166,24 +165,24 @@ void ChangeOrganFrequency(uint8_t key, int8_t track, int32_t a)
}
}
int16_t pan_tbl[13] = {0, 43, 86, 129, 172, 215, 256, 297, 340, 383, 426, 469, 512};
uint8_t old_key[MAXTRACK] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t key_on[MAXTRACK] = {0};
uint8_t key_twin[MAXTRACK] = {0};
short pan_tbl[13] = {0, 43, 86, 129, 172, 215, 256, 297, 340, 383, 426, 469, 512};
unsigned char old_key[MAXTRACK] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
unsigned char key_on[MAXTRACK] = {0};
unsigned char key_twin[MAXTRACK] = {0};
void ChangeOrganPan(uint8_t key, uint8_t pan, int8_t track)
void ChangeOrganPan(unsigned char key, unsigned char pan, signed char track)
{
if(old_key[track] != PANDUMMY)
lpORGANBUFFER[track][old_key[track]/12][key_twin[track]]->SetPan((pan_tbl[pan] - 0x100) * 10);
}
void ChangeOrganVolume(int no, int32_t volume, int8_t track)
void ChangeOrganVolume(int no, long volume, signed char track)
{
if(old_key[track] != VOLDUMMY)
lpORGANBUFFER[track][old_key[track]/12][key_twin[track]]->SetVolume((volume - 0xFF) * 8);
}
void PlayOrganObject(uint8_t key, int mode, int8_t track, int32_t freq)
void PlayOrganObject(unsigned char key, int mode, signed char track, long freq)
{
if (lpORGANBUFFER[track][key/12][key_twin[track]] != NULL)
{
@ -240,7 +239,7 @@ void PlayOrganObject(uint8_t key, int mode, int8_t track, int32_t freq)
}
//Release tracks
void ReleaseOrganyaObject(int8_t track)
void ReleaseOrganyaObject(signed char track)
{
for(int i = 0; i < 8; i++)
{
@ -258,7 +257,7 @@ void ReleaseOrganyaObject(int8_t track)
}
//Handling WAVE100
int8_t wave_data[100][0x100];
signed char wave_data[100][0x100];
BOOL InitWaveData100()
{
@ -273,7 +272,7 @@ BOOL InitWaveData100()
}
//Create org wave
bool MakeOrganyaWave(int8_t track, int8_t wave_no, int8_t pipi)
bool MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi)
{
if(wave_no > 99)
{
@ -287,17 +286,17 @@ bool MakeOrganyaWave(int8_t track, int8_t wave_no, int8_t pipi)
}
//Dram
void ChangeDramFrequency(uint8_t key, int8_t track)
void ChangeDramFrequency(unsigned char key, signed char track)
{
lpDRAMBUFFER[track]->SetFrequency(key * 800 + 100);
}
void ChangeDramPan(uint8_t pan, int8_t track)
void ChangeDramPan(unsigned char pan, signed char track)
{
lpDRAMBUFFER[track]->SetPan((pan_tbl[pan] - 0x100) * 10);
}
void ChangeDramVolume(int32_t volume, int8_t track)
void ChangeDramVolume(long volume, signed char track)
{
lpDRAMBUFFER[track]->SetVolume((volume - 0xFF) * 8);
}
@ -324,9 +323,9 @@ void PlayDramObject(unsigned char key, int mode, signed char track)
}
//Play data
int32_t play_p;
long play_p;
NOTELIST *play_np[MAXTRACK];
int32_t now_leng[MAXMELODY] = {0};
long now_leng[MAXMELODY] = {0};
void OrganyaPlayData()
{
@ -393,7 +392,7 @@ void OrganyaPlayData()
}
}
void SetPlayPointer(int32_t x)
void SetPlayPointer(long x)
{
for (int i = 0; i < MAXTRACK; i++)
{
@ -428,7 +427,7 @@ void LoadOrganya(const char *name)
const unsigned char *p = FindResource(name, "ORG", NULL);
//Version Check
uint8_t ver = 0;
unsigned char ver = 0;
char pass_check[6];
memcpy(pass_check, p, 6);
@ -454,7 +453,7 @@ void LoadOrganya(const char *name)
for (int i = 0; i < 16; i++) {
info.tdata[i].freq = READ_LE16(p);
info.tdata[i].wave_no = *p++;
const int8_t pipi = *p++;
const signed char pipi = *p++;
info.tdata[i].pipi = ver == 1 ? 0 : pipi;
info.tdata[i].note_num = READ_LE16(p);
}
@ -586,7 +585,7 @@ int OrganyaPlayTimer(void *ptr)
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
//Set time for next step to play
uint32_t NextTick = SDL_GetTicks() + info.wait;
Uint32 NextTick = SDL_GetTicks() + info.wait;
while (bEndTimer == false)
{

View file

@ -1,13 +1,11 @@
#pragma once
#include <stdint.h>
//Below are Organya song data structures
struct NOTELIST {
NOTELIST *from; //Previous address
NOTELIST *to; //Next address
int32_t x; //Position
long x; //Position
unsigned char length; //Sound length
unsigned char y; //Sound height
unsigned char volume; //Volume
@ -16,10 +14,10 @@ struct NOTELIST {
//Track data * 8
struct TRACKDATA {
uint16_t freq; //Frequency (1000 is default)
uint8_t wave_no; //Waveform No.
int8_t pipi;
uint16_t note_num; //Number of notes
unsigned short freq; //Frequency (1000 is default)
unsigned char wave_no; //Waveform No.
signed char pipi;
unsigned short note_num; //Number of notes
NOTELIST *note_p;
NOTELIST *note_list;
@ -27,20 +25,20 @@ struct TRACKDATA {
//Unique information held in songs
struct MUSICINFO {
uint16_t wait;
unsigned short wait;
bool loaded;
bool playing;
unsigned char line; //Number of lines in one measure
unsigned char dot; //Number of dots per line
uint16_t alloc_note; //Number of allocated notes
int32_t repeat_x; //Repeat
int32_t end_x; //End of song (Return to repeat)
unsigned short alloc_note; //Number of allocated notes
long repeat_x; //Repeat
long end_x; //End of song (Return to repeat)
TRACKDATA tdata[16];
};
bool MakeOrganyaWave(int8_t track, int8_t wave_no, int8_t pipi);
bool MakeOrganyaWave(signed char track, signed char wave_no, signed char pipi);
void OrganyaPlayData();
void SetPlayPointer(int32_t x);
void SetPlayPointer(long x);
void LoadOrganya(const char *name);
void SetOrganyaPosition(unsigned int x);
unsigned int GetOrganyaPosition();

View file

@ -1,7 +1,6 @@
#include "Profile.h"
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

View file

@ -1,7 +1,5 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
#include "ArmsItem.h"
@ -15,10 +13,10 @@ struct PROFILE
int x;
int y;
int direct;
int16_t max_life;
int16_t star;
int16_t life;
int16_t a;
short max_life;
short star;
short life;
short a;
int select_arms;
int select_item;
int equip;
@ -29,7 +27,7 @@ struct PROFILE
PERMIT_STAGE permitstage[8];
signed char permit_mapping[0x80];
char FLAG[4];
uint8_t flags[1000];
unsigned char flags[1000];
};
BOOL IsProfile();

View file

@ -2,7 +2,6 @@
#include <algorithm>
#include <cmath>
#include <stdint.h>
#include <stdio.h>
#include <string>
#include <cstring>
@ -48,7 +47,7 @@ SOUNDBUFFER::SOUNDBUFFER(size_t bufSize)
samplePosition = 0.0;
//Create waveform buffer
data = new uint8_t[bufSize];
data = new unsigned char[bufSize];
memset(data, 0x80, bufSize);
//Add to buffer list
@ -88,7 +87,7 @@ void SOUNDBUFFER::Release()
delete this;
}
void SOUNDBUFFER::Lock(uint8_t **outBuffer, size_t *outSize)
void SOUNDBUFFER::Lock(unsigned char **outBuffer, size_t *outSize)
{
SDL_LockAudioDevice(audioDevice);
@ -104,35 +103,35 @@ void SOUNDBUFFER::Unlock()
SDL_UnlockAudioDevice(audioDevice);
}
void SOUNDBUFFER::SetCurrentPosition(uint32_t dwNewPosition)
void SOUNDBUFFER::SetCurrentPosition(unsigned long dwNewPosition)
{
SDL_LockAudioDevice(audioDevice);
samplePosition = dwNewPosition;
SDL_UnlockAudioDevice(audioDevice);
}
void SOUNDBUFFER::SetFrequency(uint32_t dwFrequency)
void SOUNDBUFFER::SetFrequency(unsigned long dwFrequency)
{
SDL_LockAudioDevice(audioDevice);
frequency = (double)dwFrequency;
SDL_UnlockAudioDevice(audioDevice);
}
float MillibelToVolume(int32_t lVolume)
float MillibelToVolume(long lVolume)
{
//Volume is in hundredths of decibels, from 0 to -10000
lVolume = clamp(lVolume, (int32_t)-10000, (int32_t)0);
lVolume = clamp(lVolume, (long)-10000, (long)0);
return (float)pow(10.0, lVolume / 2000.0);
}
void SOUNDBUFFER::SetVolume(int32_t lVolume)
void SOUNDBUFFER::SetVolume(long lVolume)
{
SDL_LockAudioDevice(audioDevice);
volume = MillibelToVolume(lVolume);
SDL_UnlockAudioDevice(audioDevice);
}
void SOUNDBUFFER::SetPan(int32_t lPan)
void SOUNDBUFFER::SetPan(long lPan)
{
SDL_LockAudioDevice(audioDevice);
volume_l = MillibelToVolume(-lPan);
@ -288,19 +287,19 @@ void PlaySoundObject(int no, int mode)
}
}
void ChangeSoundFrequency(int no, uint32_t rate)
void ChangeSoundFrequency(int no, unsigned long rate)
{
if (lpSECONDARYBUFFER[no])
lpSECONDARYBUFFER[no]->SetFrequency(10 * rate + 100);
}
void ChangeSoundVolume(int no, int32_t volume)
void ChangeSoundVolume(int no, long volume)
{
if (lpSECONDARYBUFFER[no])
lpSECONDARYBUFFER[no]->SetVolume(8 * volume - 2400);
}
void ChangeSoundPan(int no, int32_t pan)
void ChangeSoundPan(int no, long pan)
{
if (lpSECONDARYBUFFER[no])
lpSECONDARYBUFFER[no]->SetPan(10 * (pan - 256));

View file

@ -1,7 +1,6 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
#include "PixTone.h"
@ -13,13 +12,13 @@ class SOUNDBUFFER
void Release();
void Lock(uint8_t **buffer, size_t *size);
void Lock(unsigned char **buffer, size_t *size);
void Unlock();
void SetCurrentPosition(uint32_t dwNewPosition);
void SetFrequency(uint32_t dwFrequency);
void SetVolume(int32_t lVolume);
void SetPan(int32_t lPan);
void SetCurrentPosition(unsigned long dwNewPosition);
void SetFrequency(unsigned long dwFrequency);
void SetVolume(long lVolume);
void SetPan(long lPan);
void Play(bool bLooping);
void Stop();
@ -28,7 +27,7 @@ class SOUNDBUFFER
SOUNDBUFFER *next;
private:
uint8_t *data;
unsigned char *data;
size_t size;
bool playing;
@ -95,7 +94,7 @@ extern SOUNDBUFFER* lpSECONDARYBUFFER[SOUND_NO];
bool InitDirectSound();
void EndDirectSound();
void PlaySoundObject(int no, int mode);
void ChangeSoundFrequency(int no, uint32_t rate);
void ChangeSoundVolume(int no, int32_t volume);
void ChangeSoundPan(int no, int32_t pan);
void ChangeSoundFrequency(int no, unsigned long rate);
void ChangeSoundVolume(int no, long volume);
void ChangeSoundPan(int no, long pan);
int MakePixToneObject(const PIXTONEPARAMETER *ptp, int ptp_num, int no);

View file

@ -1,6 +1,5 @@
#include "Stage.h"
#include <stdint.h>
#include <stdio.h>
#include <string.h>

View file

@ -1,6 +1,5 @@
#include "TextScr.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -91,7 +90,7 @@ void EndTextScript()
}
//Decrypt .tsc
void EncryptionBinaryData2(uint8_t *pData, int size)
void EncryptionBinaryData2(unsigned char *pData, int size)
{
int val1;
@ -136,7 +135,7 @@ BOOL LoadTextScript2(const char *name)
strcpy(gTS.path, name);
//Decrypt data
EncryptionBinaryData2((uint8_t*)gTS.data, gTS.size);
EncryptionBinaryData2((unsigned char*)gTS.data, gTS.size);
return TRUE;
}
@ -157,7 +156,7 @@ BOOL LoadTextScript_Stage(const char *name)
//Read Head.tsc
fread(gTS.data, 1, head_size, fp);
EncryptionBinaryData2((uint8_t*)gTS.data, head_size);
EncryptionBinaryData2((unsigned char*)gTS.data, head_size);
gTS.data[head_size] = 0;
fclose(fp);
@ -174,7 +173,7 @@ BOOL LoadTextScript_Stage(const char *name)
//Read stage's tsc
fread(&gTS.data[head_size], 1, body_size, fp);
EncryptionBinaryData2((uint8_t*)&gTS.data[head_size], body_size);
EncryptionBinaryData2((unsigned char*)&gTS.data[head_size], body_size);
gTS.data[head_size + body_size] = 0;
fclose(fp);

View file

@ -1,7 +1,5 @@
#pragma once
#include <stdint.h>
#include "WindowsWrapper.h"
#include "CommonDefines.h"
@ -54,12 +52,12 @@ struct TEXT_SCRIPT
int offsetY;
//NOD cursor blink
uint8_t wait_beam;
unsigned char wait_beam;
};
BOOL InitTextScript2();
void EndTextScript();
void EncryptionBinaryData2(uint8_t *pData, int size);
void EncryptionBinaryData2(unsigned char *pData, int size);
BOOL LoadTextScript2(const char *name);
BOOL LoadTextScript_Stage(const char *name);
void GetTextScriptPath(char *path);

View file

@ -1,10 +1,9 @@
#include "Triangle.h"
#include <stdint.h>
#include <math.h>
int gSin[0x100];
int16_t gTan[0x21];
short gTan[0x21];
void InitTriangleTable()
{
@ -23,27 +22,27 @@ void InitTriangleTable()
{
a = (float)(i * 6.2831855f / 256.0f);
b = sinf(a) / cosf(a);
gTan[i] = (int16_t)(b * 8192.0f);
gTan[i] = (short)(b * 8192.0f);
}
}
int GetSin(uint8_t deg)
int GetSin(unsigned char deg)
{
return gSin[deg];
}
int GetCos(uint8_t deg)
int GetCos(unsigned char deg)
{
deg += 0x40;
return gSin[deg];
}
uint8_t GetArktan(int x, int y)
unsigned char GetArktan(int x, int y)
{
x *= -1;
y *= -1;
uint8_t a = 0;
int16_t k;
unsigned char a = 0;
short k;
if (x > 0)
{

View file

@ -1,8 +1,6 @@
#pragma once
#include <stdint.h>
void InitTriangleTable();
int GetSin(uint8_t deg);
int GetCos(uint8_t deg);
uint8_t GetArktan(int x, int y);
int GetSin(unsigned char deg);
int GetCos(unsigned char deg);
unsigned char GetArktan(int x, int y);