Merge pull request #18 from Clownacy/master

Merge Clownacy/master into master
This commit is contained in:
Gabriel Ravier 2019-05-13 19:17:40 +02:00 committed by GitHub
commit 11f6bf9f16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 2334 additions and 1888 deletions

View file

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

View file

@ -515,6 +515,190 @@ addr = 0x414B20
name = "SetMapping" name = "SetMapping"
addr = 0x414B40 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]] [[func]]
name = "AddExpMyChar" name = "AddExpMyChar"
addr = 0x4196F0 addr = 0x4196F0
@ -2202,6 +2386,150 @@ addr = 0x46E9E0
name = "ActNpc360" name = "ActNpc360"
addr = 0x46EA90 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]] [[func]]
name = "LoadNpcTable" name = "LoadNpcTable"
addr = 0x472400 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 #ifdef NONPORTABLE
// This is ridiculously platform-dependant: // This is ridiculously platform-dependant:
// It should break on big-endian CPUs, and platforms // It should break on big-endian CPUs, and platforms where short isn't 16-bit and long isn't 32-bit.
// where short isn't 16-bit and long isn't 32-bit.
unsigned short bmp_header_buffer[7]; // These names aren't the original. This ruins the stack frame layout. unsigned short bmp_header_buffer[7]; // These names aren't the original. This ruins the stack frame layout.
unsigned long bmp_header_buffer2[10]; unsigned long bmp_header_buffer2[10];

View file

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

View file

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

View file

@ -10,6 +10,7 @@
#include "Sound.h" #include "Sound.h"
#include "Triangle.h" #include "Triangle.h"
// Balfrog's mouth
static void ActBossChar02_01(void) static void ActBossChar02_01(void)
{ {
NPCHAR *boss; NPCHAR *boss;
@ -84,6 +85,7 @@ static void ActBossChar02_02(void)
} }
} }
// Main boss AI
void ActBossChar_Frog(void) void ActBossChar_Frog(void)
{ {
int i; int i;
@ -91,6 +93,7 @@ void ActBossChar_Frog(void)
int ym; int ym;
int xm; 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] = { RECT rcLeft[9] = {
{0, 0, 0, 0}, {0, 0, 0, 0},
{0, 48, 80, 112}, {0, 48, 80, 112},

View file

@ -523,7 +523,7 @@ void ActBossChar_MonstX(void)
gBoss[2].direct = 2; gBoss[2].direct = 2;
gBoss[3].cond = 0x80; gBoss[3].cond = 0x80;
gBoss[3].life = 60; 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].hit_voice = 54;
gBoss[3].destroy_voice = 71; gBoss[3].destroy_voice = 71;
gBoss[3].size = 2; gBoss[3].size = 2;

View file

@ -45,7 +45,7 @@ int JudgeHitBulletBlock(int x, int y, BULLET *bul)
return hit; 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 i;
int workX; int workX;

View file

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

View file

@ -1,5 +1,4 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -16,44 +15,44 @@ static const char* const config_magic = "DOUKUTSU20041206"; // Not the original
BOOL LoadConfigData(CONFIG *conf) BOOL LoadConfigData(CONFIG *conf)
{ {
//Clear old config data // Clear old configuration data
memset(conf, 0, sizeof(CONFIG)); memset(conf, 0, sizeof(CONFIG));
//Get path // Get path
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s", gModulePath, config_filename); sprintf(path, "%s/%s", gModulePath, config_filename);
//Open file // Open file
FILE *fp = fopen(path, "rb"); FILE *fp = fopen(path, "rb");
if (fp == NULL) if (fp == NULL)
return FALSE; return FALSE;
//Read data // Read data
#ifdef NONPORTABLE #ifdef NONPORTABLE
size_t fread_result = fread(conf, sizeof(CONFIG), 1, fp); // Not the original name size_t fread_result = fread(conf, sizeof(CONFIG), 1, fp); // Not the original name
#else #else
//Read the version id and font name // Read the version id and font name
fread(conf->proof, sizeof(conf->proof), 1, fp); fread(conf->proof, sizeof(conf->proof), 1, fp);
fread(conf->font_name, sizeof(conf->font_name), 1, fp); fread(conf->font_name, sizeof(conf->font_name), 1, fp);
//Read control settings // Read control settings
conf->move_button_mode = File_ReadLE32(fp); conf->move_button_mode = File_ReadLE32(fp);
conf->attack_button_mode = File_ReadLE32(fp); conf->attack_button_mode = File_ReadLE32(fp);
conf->ok_button_mode = File_ReadLE32(fp); conf->ok_button_mode = File_ReadLE32(fp);
//Read display mode (320x240, 640x480, 24-bit fullscreen, 32-bit fullscreen) TODO: add more things? // Read display mode (320x240, 640x480, 24-bit fullscreen, 32-bit fullscreen) TODO: add more things?
conf->display_mode = File_ReadLE32(fp); conf->display_mode = File_ReadLE32(fp);
//Read joystick configuration (if enabled, and mappings) // Read joystick configuration (if enabled, and mappings)
conf->bJoystick = File_ReadLE32(fp); conf->bJoystick = File_ReadLE32(fp);
for (int button = 0; button < 8; button++) for (int button = 0; button < 8; button++)
conf->joystick_button[button] = File_ReadLE32(fp); conf->joystick_button[button] = File_ReadLE32(fp);
#endif #endif
//Close file // Close file
fclose(fp); fclose(fp);
//Check if version is not correct, and return if it failed // Check if version is not correct, and return if it failed
#ifdef NONPORTABLE #ifdef NONPORTABLE
if (fread_result != 1 || strcmp(conf->proof, config_magic)) if (fread_result != 1 || strcmp(conf->proof, config_magic))
#else #else
@ -69,13 +68,13 @@ BOOL LoadConfigData(CONFIG *conf)
void DefaultConfigData(CONFIG *conf) void DefaultConfigData(CONFIG *conf)
{ {
//Clear old config data // Clear old configuration data
memset(conf, 0, sizeof(CONFIG)); memset(conf, 0, sizeof(CONFIG));
//Fun fact: The Linux port added this line: // Fun fact: The Linux port added this line:
//conf->display_mode = 1; // conf->display_mode = 1;
//Reset joystick settings (as these can't simply be set to 0) // Reset joystick settings (as these can't simply be set to 0)
conf->bJoystick = 1; conf->bJoystick = 1;
conf->joystick_button[0] = 2; conf->joystick_button[0] = 2;
conf->joystick_button[1] = 1; conf->joystick_button[1] = 1;

View file

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

View file

@ -1,5 +1,4 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -57,8 +56,8 @@ BOOL Flip_SystemTask()
return FALSE; return FALSE;
// Framerate limiter // Framerate limiter
static uint32_t timePrev; static Uint32 timePrev;
const uint32_t timeNow = SDL_GetTicks(); const Uint32 timeNow = SDL_GetTicks();
if (timeNow >= timePrev + FRAMERATE) if (timeNow >= timePrev + FRAMERATE)
{ {
@ -359,6 +358,9 @@ static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool creat
if (data) 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); SDL_RWops *fp = SDL_RWFromConstMem(data, size);
printf("Loading surface from resource %s for surface id %d\n", res, surf_no); 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 clipRect = RectToSDLRectScaled(rcView);
SDL_Rect frameRect = RectToSDLRectScaled(rect); SDL_Rect frameRect = RectToSDLRectScaled(rect);
// Get dest rect // Get destination rect
SDL_Rect destRect = {x * magnification, y * magnification, frameRect.w, frameRect.h}; SDL_Rect destRect = {x * magnification, y * magnification, frameRect.w, frameRect.h};
// Set cliprect // Set cliprect
@ -485,28 +487,28 @@ unsigned long GetCortBoxColor(unsigned long col)
return col; return col;
} }
void CortBox(RECT *rect, uint32_t col) void CortBox(RECT *rect, unsigned long col)
{ {
// Get rect // Get rect
SDL_Rect destRect = RectToSDLRectScaled(rect); SDL_Rect destRect = RectToSDLRectScaled(rect);
// Set colour and draw // Set colour and draw
const unsigned char col_red = col & 0x0000FF; const unsigned char col_red = (unsigned char)(col & 0xFF);
const unsigned char col_green = (col & 0x00FF00) >> 8; const unsigned char col_green = (unsigned char)((col >> 8) & 0xFF);
const unsigned char col_blue = (col & 0xFF0000) >> 16; const unsigned char col_blue = (unsigned char)((col >> 16) & 0xFF);
SDL_SetRenderDrawColor(gRenderer, col_red, col_green, col_blue, 0xFF); SDL_SetRenderDrawColor(gRenderer, col_red, col_green, col_blue, 0xFF);
SDL_RenderFillRect(gRenderer, &destRect); 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 // Get rect
SDL_Rect destRect = RectToSDLRectScaled(rect); SDL_Rect destRect = RectToSDLRectScaled(rect);
// Set colour and draw // Set colour and draw
const unsigned char col_red = col & 0x0000FF; const unsigned char col_red = (unsigned char)(col & 0xFF);
const unsigned char col_green = (col & 0x00FF00) >> 8; const unsigned char col_green = (unsigned char)((col >> 8) & 0xFF);
const unsigned char col_blue = (col & 0xFF0000) >> 16; 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)); SDL_FillRect(surf[surf_no].surface, &destRect, SDL_MapRGB(surf[surf_no].surface->format, col_red, col_green, col_blue));
surf[surf_no].needs_updating = true; surf[surf_no].needs_updating = true;
} }
@ -610,7 +612,7 @@ void InitTextObject(const char *font_name)
gFont = LoadFontFromData(res_data, data_size, fontWidth, fontHeight); 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; int surface_width, surface_height;
SDL_GetRendererOutputSize(gRenderer, &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); 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)); 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; surf[surf_no].needs_updating = true;

View file

@ -1,7 +1,5 @@
#pragma once #pragma once
#include <stdint.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#ifndef RGB #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 PutBitmap4(RECT *rcView, int x, int y, RECT *rect, Surface_Ids surf_no);
void Surface2Surface(int x, int y, RECT *rect, int to, int from); void Surface2Surface(int x, int y, RECT *rect, int to, int from);
unsigned long GetCortBoxColor(unsigned long col); unsigned long GetCortBoxColor(unsigned long col);
void CortBox(RECT *rect, uint32_t col); void CortBox(RECT *rect, unsigned long col);
void CortBox2(RECT *rect, uint32_t col, Surface_Ids surf_no); void CortBox2(RECT *rect, unsigned long col, Surface_Ids surf_no);
void InitTextObject(const char *font_name); void InitTextObject(const char *font_name);
void PutText(int x, int y, const char *text, uint32_t color); void PutText(int x, int y, const char *text, unsigned long color);
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);
void EndTextObject(); void EndTextObject();

View file

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

View file

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

View file

@ -13,7 +13,7 @@ FRAME gFrame;
void MoveFrame3() void MoveFrame3()
{ {
int16_t map_w, map_l; short map_w, map_l;
GetMapData(0, &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 #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; gFrame.quake2 = 0;
//Move frame position //Move frame position
int16_t map_w, map_l; short map_w, map_l;
GetMapData(0, &map_w, &map_l); GetMapData(0, &map_w, &map_l);
gFrame.x = fx; gFrame.x = fx;
@ -143,7 +143,7 @@ void SetFrameMyChar()
int mc_x, mc_y; int mc_x, mc_y;
GetMyCharPosition(&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); GetMapData(0, &map_w, &map_l);
gFrame.x = mc_x - (WINDOW_WIDTH << 8); gFrame.x = mc_x - (WINDOW_WIDTH << 8);

View file

@ -58,7 +58,7 @@ int Random(int min, int max)
void PutNumber4(int x, int y, int value, bool bZero) void PutNumber4(int x, int y, int value, bool bZero)
{ {
//Define rects // Define rects
RECT rcClient = grcFull; RECT rcClient = grcFull;
RECT rect[10] = { RECT rect[10] = {
@ -74,19 +74,19 @@ void PutNumber4(int x, int y, int value, bool bZero)
{72, 56, 80, 64}, {72, 56, 80, 64},
}; };
//Digits // Digits
int tbl[4] = {1000, 100, 10, 1}; int tbl[4] = {1000, 100, 10, 1};
//Limit value // Limit value
if ( value > 9999 ) if (value > 9999)
value = 9999; value = 9999;
//Go through number and draw digits // Go through number and draw digits
int offset = 0; int offset = 0;
int sw = 0; int sw = 0;
while (offset < 4) while (offset < 4)
{ {
//Get the digit that this is // Get the digit that this is
int a = 0; int a = 0;
while (tbl[offset] <= value) while (tbl[offset] <= value)
@ -96,11 +96,11 @@ void PutNumber4(int x, int y, int value, bool bZero)
++sw; ++sw;
} }
//Draw digit // Draw digit
if ((bZero && offset == 2) || sw != 0 || offset == 3 ) if ((bZero && offset == 2) || sw != 0 || offset == 3)
PutBitmap3(&rcClient, x + 8 * offset, y, &rect[a], SURFACE_ID_TEXT_BOX); PutBitmap3(&rcClient, x + 8 * offset, y, &rect[a], SURFACE_ID_TEXT_BOX);
//Go to next digit // Go to next digit
++offset; ++offset;
} }
} }
@ -118,9 +118,9 @@ int ModeOpening()
SetFrameTargetMyChar(16); SetFrameTargetMyChar(16);
SetFadeMask(); SetFadeMask();
//Reset cliprect and flags // Reset cliprect and flags
grcGame.left = 0; grcGame.left = 0;
//Non-vanilla: these three lines are widescreen-related(?) // Non-vanilla: these three lines are widescreen-related(?)
grcGame.top = 0; grcGame.top = 0;
grcGame.right = WINDOW_WIDTH; grcGame.right = WINDOW_WIDTH;
grcGame.bottom = WINDOW_HEIGHT; grcGame.bottom = WINDOW_HEIGHT;
@ -132,13 +132,13 @@ int ModeOpening()
unsigned int wait = 0; unsigned int wait = 0;
while (wait < 500) while (wait < 500)
{ {
//Increase timer // Increase timer
++wait; ++wait;
//Get pressed keys // Get pressed keys
GetTrg(); GetTrg();
//Escape menu // Escape menu
if (gKey & KEY_ESCAPE) if (gKey & KEY_ESCAPE)
{ {
int escRet = Call_Escape(); int escRet = Call_Escape();
@ -148,11 +148,11 @@ int ModeOpening()
return 1; return 1;
} }
//Skip intro if OK is pressed // Skip intro if OK is pressed
if (gKey & gKeyOk) if (gKey & gKeyOk)
break; break;
//Update everything // Update everything
ActNpChar(); ActNpChar();
ActBossChar(); ActBossChar();
ActBack(); ActBack();
@ -167,7 +167,7 @@ int ModeOpening()
MoveFrame3(); MoveFrame3();
ProcFade(); ProcFade();
//Draw everything // Draw everything
CortBox(&grcFull, 0x000000); CortBox(&grcFull, 0x000000);
int frame_x, frame_y; int frame_x, frame_y;
@ -182,7 +182,7 @@ int ModeOpening()
PutCaret(frame_x, frame_y); PutCaret(frame_x, frame_y);
PutFade(); PutFade();
//Update Text Script // Update Text Script
int tscRet = TextScriptProc(); int tscRet = TextScriptProc();
if (tscRet == 0) if (tscRet == 0)
return 0; return 0;
@ -212,7 +212,7 @@ int ModeOpening()
int ModeTitle() int ModeTitle()
{ {
//Set rects // Set rects
RECT rcTitle = {0, 0, 144, 32}; RECT rcTitle = {0, 0, 144, 32};
RECT rcPixel = {0, 0, 160, 16}; RECT rcPixel = {0, 0, 160, 16};
@ -222,7 +222,7 @@ int ModeTitle()
RECT rcVersion = {152, 80, 208, 88}; RECT rcVersion = {152, 80, 208, 88};
RECT rcPeriod = {152, 88, 208, 96}; RECT rcPeriod = {152, 88, 208, 96};
//Character rects // Character rects
RECT rcMyChar[4] = { RECT rcMyChar[4] = {
{0, 16, 16, 32}, {0, 16, 16, 32},
{16, 16, 32, 32}, {16, 16, 32, 32},
@ -258,21 +258,21 @@ int ModeTitle()
{48, 16, 64, 32}, {48, 16, 64, 32},
}; };
//Reset everything // Reset everything
InitCaret(); InitCaret();
InitStar(); InitStar();
CutNoise(); CutNoise();
//Create variables // Create variables
int anime = 0; int anime = 0;
int char_type = 0; int char_type = 0;
int time_counter = 0; int time_counter = 0;
unsigned long back_color = GetCortBoxColor(RGB(0x20, 0x20, 0x20)); unsigned long back_color = GetCortBoxColor(RGB(0x20, 0x20, 0x20));
//Set state // Set state
bContinue = IsProfile(); bContinue = IsProfile();
//Set character // Set character
time_counter = LoadTimeCounter(); time_counter = LoadTimeCounter();
if (time_counter && time_counter < 6 * 60 * 50) // 6 minutes if (time_counter && time_counter < 6 * 60 * 50) // 6 minutes
@ -284,7 +284,7 @@ int ModeTitle()
if (time_counter && time_counter < 3 * 60 * 50) // 3 minutes if (time_counter && time_counter < 3 * 60 * 50) // 3 minutes
char_type = 4; char_type = 4;
//Set music to character's specific music // Set music to character's specific music
switch (char_type) switch (char_type)
{ {
case 1: case 1:
@ -304,9 +304,9 @@ int ModeTitle()
break; break;
} }
//Reset cliprect, flags, and give the player the nikumaru counter // Reset cliprect, flags, and give the player the Nikumaru counter
grcGame.left = 0; grcGame.left = 0;
//Non-vanilla: these three lines are widescreen-related(?) // Non-vanilla: these three lines are widescreen-related(?)
grcGame.top = 0; grcGame.top = 0;
grcGame.right = WINDOW_WIDTH; grcGame.right = WINDOW_WIDTH;
grcGame.bottom = WINDOW_HEIGHT; grcGame.bottom = WINDOW_HEIGHT;
@ -314,19 +314,19 @@ int ModeTitle()
g_GameFlags = 0; g_GameFlags = 0;
gMC.equip |= 0x100; gMC.equip |= 0x100;
//Start loop // Start loop
unsigned int wait = 0; unsigned int wait = 0;
while (true) while (true)
{ {
//Don't accept selection for 10 frames // Don't accept selection for 10 frames
if (wait < 10) if (wait < 10)
++wait; ++wait;
//Get pressed keys // Get pressed keys
GetTrg(); GetTrg();
//Quit when OK is pressed // Quit when OK is pressed
if (wait >= 10) if (wait >= 10)
{ {
if (gKeyTrg & gKeyOk) if (gKeyTrg & gKeyOk)
@ -342,24 +342,24 @@ int ModeTitle()
return 1; return 1;
} }
//Move cursor // Move cursor
if ((gKeyDown | gKeyUp) & gKeyTrg) if ((gKeyDown | gKeyUp) & gKeyTrg)
{ {
PlaySoundObject(1, 1); PlaySoundObject(1, 1);
bContinue = !bContinue; bContinue = !bContinue;
} }
//Update carets // Update carets
ActCaret(); ActCaret();
//Animate character cursor // Animate character cursor
if ( ++anime >= 40 ) if (++anime >= 40)
anime = 0; anime = 0;
//Draw title // Draw title
CortBox(&grcGame, back_color); CortBox(&grcGame, back_color);
//Draw version // Draw version
PutBitmap3(&grcGame, (WINDOW_WIDTH - 120) / 2, WINDOW_HEIGHT - 24, &rcVersion, SURFACE_ID_TEXT_BOX); PutBitmap3(&grcGame, (WINDOW_WIDTH - 120) / 2, WINDOW_HEIGHT - 24, &rcVersion, SURFACE_ID_TEXT_BOX);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 8) / 2, WINDOW_HEIGHT - 24, &rcPeriod, SURFACE_ID_TEXT_BOX); PutBitmap3(&grcGame, (WINDOW_WIDTH - 8) / 2, WINDOW_HEIGHT - 24, &rcPeriod, SURFACE_ID_TEXT_BOX);
@ -370,17 +370,17 @@ int ModeTitle()
PutNumber4((WINDOW_WIDTH + 24) / 2, WINDOW_HEIGHT - 24, v3, 0); PutNumber4((WINDOW_WIDTH + 24) / 2, WINDOW_HEIGHT - 24, v3, 0);
PutNumber4((WINDOW_WIDTH + 56) / 2, WINDOW_HEIGHT - 24, v4, 0); PutNumber4((WINDOW_WIDTH + 56) / 2, WINDOW_HEIGHT - 24, v4, 0);
//Draw main title // Draw main title
PutBitmap3(&grcGame, (WINDOW_WIDTH - 144) / 2, 40, &rcTitle, SURFACE_ID_TITLE); PutBitmap3(&grcGame, (WINDOW_WIDTH - 144) / 2, 40, &rcTitle, SURFACE_ID_TITLE);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 16) / 2, &rcNew, SURFACE_ID_TITLE); PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 16) / 2, &rcNew, SURFACE_ID_TITLE);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 56) / 2, &rcContinue, SURFACE_ID_TITLE); PutBitmap3(&grcGame, (WINDOW_WIDTH - 48) / 2, (WINDOW_HEIGHT + 56) / 2, &rcContinue, SURFACE_ID_TITLE);
PutBitmap3(&grcGame, (WINDOW_WIDTH - 160) / 2, WINDOW_HEIGHT - 48, &rcPixel, SURFACE_ID_PIXEL); PutBitmap3(&grcGame, (WINDOW_WIDTH - 160) / 2, WINDOW_HEIGHT - 48, &rcPixel, SURFACE_ID_PIXEL);
//Draw character cursor // Draw character cursor
RECT char_rc; RECT char_rc;
Surface_Ids char_surf; Surface_Ids char_surf;
switch ( char_type ) switch (char_type)
{ {
case 0: case 0:
char_rc = rcMyChar[anime / 10 % 4]; char_rc = rcMyChar[anime / 10 % 4];
@ -412,7 +412,7 @@ int ModeTitle()
PutBitmap3(&grcGame, (WINDOW_WIDTH - 88) / 2, char_y, &char_rc, char_surf); PutBitmap3(&grcGame, (WINDOW_WIDTH - 88) / 2, char_y, &char_rc, char_surf);
//Draw carets // Draw carets
PutCaret(0, 0); PutCaret(0, 0);
if (time_counter) if (time_counter)
@ -427,7 +427,7 @@ int ModeTitle()
PlaySoundObject(18, 1); PlaySoundObject(18, 1);
ChangeMusic(0); ChangeMusic(0);
//Black screen when option is selected // Black screen when option is selected
wait = SDL_GetTicks(); wait = SDL_GetTicks();
while (SDL_GetTicks() < wait + 1000) while (SDL_GetTicks() < wait + 1000)
{ {
@ -449,12 +449,12 @@ int ModeAction()
bool swPlay = true; bool swPlay = true;
//Reset stuff // Reset stuff
gCounter = 0; gCounter = 0;
grcGame.left = 0; grcGame.left = 0;
g_GameFlags = 3; g_GameFlags = 3;
//Initialize everything // Initialize everything
InitMyChar(); InitMyChar();
InitNpChar(); InitNpChar();
InitBullet(); InitBullet();
@ -473,10 +473,10 @@ int ModeAction()
{ {
while (true) while (true)
{ {
//Get pressed keys // Get pressed keys
GetTrg(); GetTrg();
//Escape menu // Escape menu
if (gKey & KEY_ESCAPE) if (gKey & KEY_ESCAPE)
{ {
int escRet = Call_Escape(); int escRet = Call_Escape();
@ -548,7 +548,7 @@ int ModeAction()
if (!(g_GameFlags & 4)) if (!(g_GameFlags & 4))
{ {
//Open inventory // Open inventory
if (gKeyTrg & gKeyItem) if (gKeyTrg & gKeyItem)
{ {
BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcGame); BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcGame);
@ -607,15 +607,15 @@ int ModeAction()
if (g_GameFlags & 8) if (g_GameFlags & 8)
{ {
PutIllust(); PutIllust();
PutStripper(); PutStripper();
} }
PutTextScript(); PutTextScript();
PutFramePerSecound(); PutFramePerSecound();
if (!Flip_SystemTask()) if (!Flip_SystemTask())
break; break;
++gCounter; ++gCounter;
} }
} }

View file

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

View file

@ -1,8 +1,6 @@
#pragma once #pragma once
#include <stdint.h>
bool GetCompileVersion(int *v1, int *v2, int *v3, int *v4); bool GetCompileVersion(int *v1, int *v2, int *v3, int *v4);
long GetFileSizeLong(const char *path); long GetFileSizeLong(const char *path);
bool CheckFileExists(const char *name); bool CheckFileExists(const char *name);
bool IsShiftJIS(uint8_t c); bool IsShiftJIS(unsigned char c);

View file

@ -12,145 +12,145 @@
static const PIXTONEPARAMETER gPtpTable[139] = static const PIXTONEPARAMETER gPtpTable[139] =
{ {
{1, 5000, {5, 10.0, 32, 0}, {4, 4.0, 32, 0}, {0, 0.0, 63, 0}, 63, 6, 63, 45, 8, 119, 46}, {1, 5000, {5, 10.0, 32, 0}, {4, 4.0, 32, 0}, {0, 0.0, 63, 0}, 63, 6, 63, 45, 8, 119, 46},
{1, 1000, {0, 4.0, 32, 0}, {3, 1.0, 63, 0}, {0, 0.0, 63, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 1000, {0, 4.0, 32, 0}, {3, 1.0, 63, 0}, {0, 0.0, 63, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 10000, {0, 30.0, 32, 0}, {3, 1.0, 32, 0}, {0, 0.0, 63, 0}, 0, 19, 44, 111, 13, 198, 9}, {1, 10000, {0, 30.0, 32, 0}, {3, 1.0, 32, 0}, {0, 0.0, 63, 0}, 0, 19, 44, 111, 13, 198, 9},
{1, 10000, {5, 2.0, 31, 0}, {3, 1.0, 57, 219}, {0, 2.0, 32, 0}, 0, 19, 44, 111, 13, 198, 9}, {1, 10000, {5, 2.0, 31, 0}, {3, 1.0, 57, 219}, {0, 2.0, 32, 0}, 0, 19, 44, 111, 13, 198, 9},
{1, 4000, {5, 0.4, 32, 0}, {3, 1.0, 53, 0}, {0, 0.0, 63, 0}, 12, 19, 63, 111, 21, 198, 18}, {1, 4000, {5, 0.4, 32, 0}, {3, 1.0, 53, 0}, {0, 0.0, 63, 0}, 12, 19, 63, 111, 21, 198, 18},
{1, 1000, {1, 12.0, 32, 0}, {2, 1.0, 63, 0}, {0, 0.0, 63, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 1000, {1, 12.0, 32, 0}, {2, 1.0, 63, 0}, {0, 0.0, 63, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 1000, {5, 1.0, 32, 0}, {3, 1.0, 63, 0}, {0, 0.0, 63, 0}, 0, 28, 63, 53, 31, 210, 31}, {1, 1000, {5, 1.0, 32, 0}, {3, 1.0, 63, 0}, {0, 0.0, 63, 0}, 0, 28, 63, 53, 31, 210, 31},
{1, 1000, {1, 5.0, 32, 0}, {3, 1.0, 63, 0}, {0, 0.0, 0, 0}, 63, 64, 63, 128, 31, 255, 0}, {1, 1000, {1, 5.0, 32, 0}, {3, 1.0, 63, 0}, {0, 0.0, 0, 0}, 63, 64, 63, 128, 31, 255, 0},
{1, 3000, {1, 17.0, 34, 0}, {3, 2.0, 40, 0}, {4, 1.0, 31, 0}, 63, 64, 63, 225, 63, 255, 0}, {1, 3000, {1, 17.0, 34, 0}, {3, 2.0, 40, 0}, {4, 1.0, 31, 0}, 63, 64, 63, 225, 63, 255, 0},
{1, 6000, {1, 930.0, 22, 0}, {0, 0.7, 53, 0}, {0, 7.0, 32, 0}, 63, 64, 63, 202, 63, 255, 0}, {1, 6000, {1, 930.0, 22, 0}, {0, 0.7, 53, 0}, {0, 7.0, 32, 0}, 63, 64, 63, 202, 63, 255, 0},
{1, 6000, {1, 918.0, 23, 0}, {0, 0.7, 53, 0}, {0, 7.0, 32, 0}, 63, 64, 63, 202, 63, 255, 0}, {1, 6000, {1, 918.0, 23, 0}, {0, 0.7, 53, 0}, {0, 7.0, 32, 0}, 63, 64, 63, 202, 63, 255, 0},
{1, 10000, {2, 200.0, 32, 0}, {0, 1.0, 51, 0}, {1, 20.0, 31, 0}, 63, 64, 63, 89, 30, 208, 28}, {1, 10000, {2, 200.0, 32, 0}, {0, 1.0, 51, 0}, {1, 20.0, 31, 0}, 63, 64, 63, 89, 30, 208, 28},
{1, 10000, {5, 23.0, 16, 0}, {0, 1.0, 58, 0}, {1, 17.0, 32, 0}, 63, 64, 63, 96, 51, 202, 31}, {1, 10000, {5, 23.0, 16, 0}, {0, 1.0, 58, 0}, {1, 17.0, 32, 0}, 63, 64, 63, 96, 51, 202, 31},
{1, 20000, {2, 100.0, 21, 0}, {0, 1.0, 46, 0}, {1, 40.0, 32, 0}, 63, 64, 63, 128, 63, 162, 0}, {1, 20000, {2, 100.0, 21, 0}, {0, 1.0, 46, 0}, {1, 40.0, 32, 0}, 63, 64, 63, 128, 63, 162, 0},
{1, 20000, {5, 5.0, 21, 0}, {0, 1.0, 51, 0}, {1, 40.0, 32, 0}, 63, 64, 63, 128, 63, 162, 28}, {1, 20000, {5, 5.0, 21, 0}, {0, 1.0, 51, 0}, {1, 40.0, 32, 0}, 63, 64, 63, 128, 63, 162, 28},
{1, 10000, {5, 20.0, 23, 0}, {3, 0.7, 26, 235}, {5, 1.0, 9, 0}, 63, 38, 55, 87, 32, 98, 29}, {1, 10000, {5, 20.0, 23, 0}, {3, 0.7, 26, 235}, {5, 1.0, 9, 0}, 63, 38, 55, 87, 32, 98, 29},
{1, 2000, {1, 20.0, 32, 0}, {3, 2.0, 63, 0}, {4, 1.0, 29, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 2000, {1, 20.0, 32, 0}, {3, 2.0, 63, 0}, {4, 1.0, 29, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 15000, {5, 10.0, 32, 0}, {3, 0.7, 26, 235}, {0, 0.0, 63, 0}, 63, 38, 55, 187, 15, 255, 0}, {1, 15000, {5, 10.0, 32, 0}, {3, 0.7, 26, 235}, {0, 0.0, 63, 0}, 63, 38, 55, 187, 15, 255, 0},
{1, 4000, {1, 20.0, 32, 0}, {3, 2.0, 63, 0}, {4, 1.0, 29, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 4000, {1, 20.0, 32, 0}, {3, 2.0, 63, 0}, {4, 1.0, 29, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 22000, {5, 6.0, 32, 0}, {3, 0.7, 26, 246}, {0, 0.0, 63, 0}, 63, 38, 55, 187, 15, 255, 0}, {1, 22000, {5, 6.0, 32, 0}, {3, 0.7, 26, 246}, {0, 0.0, 63, 0}, 63, 38, 55, 187, 15, 255, 0},
{1, 8000, {0, 20.0, 32, 0}, {3, 2.0, 63, 0}, {4, 1.0, 29, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 8000, {0, 20.0, 32, 0}, {3, 2.0, 63, 0}, {4, 1.0, 29, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 10000, {4, 400.0, 13, 0}, {0, 0.8, 63, 0}, {4, 8.0, 31, 0}, 63, 64, 63, 191, 32, 255, 0}, {1, 10000, {4, 400.0, 13, 0}, {0, 0.8, 63, 0}, {4, 8.0, 31, 0}, 63, 64, 63, 191, 32, 255, 0},
{1, 10000, {4, 800.0, 14, 0}, {0, 0.8, 63, 0}, {4, 8.0, 30, 125}, 63, 64, 63, 128, 63, 166, 0}, {1, 10000, {4, 800.0, 14, 0}, {0, 0.8, 63, 0}, {4, 8.0, 30, 125}, 63, 64, 63, 128, 63, 166, 0},
{1, 5000, {2, 50.0, 39, 0}, {3, 0.5, 40, 217}, {1, 0.0, 32, 0}, 63, 64, 63, 128, 34, 198, 32}, {1, 5000, {2, 50.0, 39, 0}, {3, 0.5, 40, 217}, {1, 0.0, 32, 0}, 63, 64, 63, 128, 34, 198, 32},
{1, 5000, {5, 10.0, 39, 0}, {3, 0.5, 24, 217}, {1, 4.0, 32, 0}, 0, 4, 63, 128, 34, 198, 32}, {1, 5000, {5, 10.0, 39, 0}, {3, 0.5, 24, 217}, {1, 4.0, 32, 0}, 0, 4, 63, 128, 34, 198, 32},
{1, 40000, {5, 10.0, 32, 0}, {3, 1.0, 32, 241}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 40000, {5, 10.0, 32, 0}, {3, 1.0, 32, 241}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 40000, {5, 20.0, 32, 0}, {0, 0.0, 32, 0}, {5, 0.1, 32, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 40000, {5, 20.0, 32, 0}, {0, 0.0, 32, 0}, {5, 0.1, 32, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 30000, {2, 400.0, 32, 0}, {3, 0.3, 60, 250}, {0, 20.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 30000, {2, 400.0, 32, 0}, {3, 0.3, 60, 250}, {0, 20.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 10000, {4, 400.0, 13, 0}, {0, 0.8, 63, 0}, {4, 8.0, 50, 0}, 63, 64, 63, 191, 32, 255, 0}, {1, 10000, {4, 400.0, 13, 0}, {0, 0.8, 63, 0}, {4, 8.0, 50, 0}, 63, 64, 63, 191, 32, 255, 0},
{1, 10000, {4, 800.0, 5, 0}, {0, 0.8, 63, 0}, {4, 8.0, 63, 125}, 63, 64, 63, 128, 63, 166, 0}, {1, 10000, {4, 800.0, 5, 0}, {0, 0.8, 63, 0}, {4, 8.0, 63, 125}, 63, 64, 63, 128, 63, 166, 0},
{1, 6000, {3, 123.0, 32, 0}, {4, 1.0, 16, 222}, {4, 4.0, 37, 0}, 0, 6, 63, 104, 25, 255, 0}, {1, 6000, {3, 123.0, 32, 0}, {4, 1.0, 16, 222}, {4, 4.0, 37, 0}, 0, 6, 63, 104, 25, 255, 0},
{1, 4000, {5, 4.5, 32, 0}, {3, 1.0, 46, 102}, {3, 2.5, 47, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 4000, {5, 4.5, 32, 0}, {3, 1.0, 46, 102}, {3, 2.5, 47, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 5000, {4, 40.0, 52, 0}, {2, 1.0, 63, 0}, {3, 10.0, 63, 0}, 63, 47, 27, 47, 29, 255, 0}, {1, 5000, {4, 40.0, 52, 0}, {2, 1.0, 63, 0}, {3, 10.0, 63, 0}, 63, 47, 27, 47, 29, 255, 0},
{1, 3000, {0, 99.0, 32, 0}, {2, 1.0, 55, 197}, {5, 0.0, 0, 0}, 63, 0, 63, 164, 28, 255, 0}, {1, 3000, {0, 99.0, 32, 0}, {2, 1.0, 55, 197}, {5, 0.0, 0, 0}, 63, 0, 63, 164, 28, 255, 0},
{1, 10000, {1, 601.0, 32, 0}, {4, 0.5, 15, 235}, {0, 10.0, 54, 0}, 63, 0, 63, 0, 63, 255, 0}, {1, 10000, {1, 601.0, 32, 0}, {4, 0.5, 15, 235}, {0, 10.0, 54, 0}, 63, 0, 63, 0, 63, 255, 0},
{1, 8000, {5, 10.0, 15, 0}, {4, 0.5, 16, 239}, {4, 0.0, 50, 0}, 63, 0, 63, 96, 17, 255, 0}, {1, 8000, {5, 10.0, 15, 0}, {4, 0.5, 16, 239}, {4, 0.0, 50, 0}, 63, 0, 63, 96, 17, 255, 0},
{1, 20000, {1, 832.0, 32, 0}, {2, 1.0, 46, 0}, {0, 27.0, 63, 0}, 63, 0, 63, 140, 10, 255, 0}, {1, 20000, {1, 832.0, 32, 0}, {2, 1.0, 46, 0}, {0, 27.0, 63, 0}, 63, 0, 63, 140, 10, 255, 0},
{1, 20000, {1, 918.0, 32, 0}, {2, 1.0, 46, 0}, {0, 21.0, 63, 0}, 63, 0, 63, 140, 10, 255, 0}, {1, 20000, {1, 918.0, 32, 0}, {2, 1.0, 46, 0}, {0, 21.0, 63, 0}, 63, 0, 63, 140, 10, 255, 0},
{1, 4000, {1, 54.0, 32, 0}, {5, 0.1, 33, 0}, {0, 0.0, 32, 0}, 53, 57, 44, 128, 24, 255, 0}, {1, 4000, {1, 54.0, 32, 0}, {5, 0.1, 33, 0}, {0, 0.0, 32, 0}, 53, 57, 44, 128, 24, 255, 0},
{1, 10000, {1, 246.0, 23, 0}, {4, 0.6, 22, 239}, {4, 6.0, 63, 0}, 0, 11, 63, 13, 63, 255, 0}, {1, 10000, {1, 246.0, 23, 0}, {4, 0.6, 22, 239}, {4, 6.0, 63, 0}, 0, 11, 63, 13, 63, 255, 0},
{1, 10000, {1, 294.0, 23, 0}, {4, 0.6, 22, 247}, {4, 6.0, 63, 140}, 0, 15, 63, 17, 63, 255, 0}, {1, 10000, {1, 294.0, 23, 0}, {4, 0.6, 22, 247}, {4, 6.0, 63, 140}, 0, 15, 63, 17, 63, 255, 0},
{1, 22050, {0, 117.0, 63, 0}, {5, 2.0, 18, 0}, {5, 0.0, 0, 0}, 63, 0, 63, 64, 19, 255, 0}, {1, 22050, {0, 117.0, 63, 0}, {5, 2.0, 18, 0}, {5, 0.0, 0, 0}, 63, 0, 63, 64, 19, 255, 0},
{1, 5000, {0, 28.0, 32, 0}, {3, 3.0, 27, 0}, {5, 0.0, 0, 0}, 63, 0, 63, 0, 63, 255, 0}, {1, 5000, {0, 28.0, 32, 0}, {3, 3.0, 27, 0}, {5, 0.0, 0, 0}, 63, 0, 63, 0, 63, 255, 0},
{1, 10000, {0, 322.0, 32, 0}, {2, 8.0, 37, 0}, {2, 0.0, 0, 0}, 0, 13, 63, 106, 11, 255, 0}, {1, 10000, {0, 322.0, 32, 0}, {2, 8.0, 37, 0}, {2, 0.0, 0, 0}, 0, 13, 63, 106, 11, 255, 0},
{1, 10000, {5, 7.3, 32, 0}, {5, 0.2, 29, 0}, {0, 0.0, 32, 0}, 63, 91, 63, 149, 25, 255, 0}, {1, 10000, {5, 7.3, 32, 0}, {5, 0.2, 29, 0}, {0, 0.0, 32, 0}, 63, 91, 63, 149, 25, 255, 0},
{1, 1000, {0, 6.0, 32, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 1000, {0, 6.0, 32, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 20000, {2, 186.0, 32, 0}, {0, 4.0, 13, 98}, {3, 4.0, 5, 0}, 63, 64, 28, 255, 0, 255, 0}, {1, 20000, {2, 186.0, 32, 0}, {0, 4.0, 13, 98}, {3, 4.0, 5, 0}, 63, 64, 28, 255, 0, 255, 0},
{1, 20000, {2, 285.0, 19, 0}, {3, 4.0, 21, 0}, {3, 4.0, 33, 130}, 63, 64, 63, 255, 0, 255, 0}, {1, 20000, {2, 285.0, 19, 0}, {3, 4.0, 21, 0}, {3, 4.0, 33, 130}, 63, 64, 63, 255, 0, 255, 0},
{1, 10000, {0, 970.0, 32, 0}, {2, 1.0, 35, 195}, {0, 31.0, 31, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 10000, {0, 970.0, 32, 0}, {2, 1.0, 35, 195}, {0, 31.0, 31, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 20000, {5, 6.0, 32, 0}, {3, 1.0, 54, 239}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 35}, {1, 20000, {5, 6.0, 32, 0}, {3, 1.0, 54, 239}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 35},
{1, 40000, {5, 4.0, 32, 0}, {3, 0.0, 32, 230}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 40000, {5, 4.0, 32, 0}, {3, 0.0, 32, 230}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 40000, {1, 238.0, 32, 0}, {3, 1.0, 14, 0}, {4, 30.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 40000, {1, 238.0, 32, 0}, {3, 1.0, 14, 0}, {4, 30.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 3000, {2, 62.0, 32, 0}, {2, 3.0, 63, 0}, {3, 3.0, 14, 0}, 63, 0, 63, 210, 32, 255, 0}, {1, 3000, {2, 62.0, 32, 0}, {2, 3.0, 63, 0}, {3, 3.0, 14, 0}, 63, 0, 63, 210, 32, 255, 0},
{1, 5000, {2, 58.0, 32, 0}, {2, 3.0, 63, 0}, {2, 3.0, 32, 0}, 63, 0, 63, 49, 27, 255, 0}, {1, 5000, {2, 58.0, 32, 0}, {2, 3.0, 63, 0}, {2, 3.0, 32, 0}, 63, 0, 63, 49, 27, 255, 0},
{1, 3000, {0, 13.0, 24, 0}, {3, 2.0, 40, 0}, {4, 1.0, 31, 0}, 63, 64, 63, 225, 63, 255, 0}, {1, 3000, {0, 13.0, 24, 0}, {3, 2.0, 40, 0}, {4, 1.0, 31, 0}, 63, 64, 63, 225, 63, 255, 0},
{1, 3000, {5, 6.0, 32, 0}, {5, 1.0, 32, 0}, {3, 0.0, 0, 0}, 0, 0, 63, 45, 23, 255, 0}, {1, 3000, {5, 6.0, 32, 0}, {5, 1.0, 32, 0}, {3, 0.0, 0, 0}, 0, 0, 63, 45, 23, 255, 0},
{1, 20000, {1, 477.0, 40, 0}, {5, 93.0, 39, 0}, {4, 17.0, 19, 0}, 0, 64, 63, 128, 63, 255, 0}, {1, 20000, {1, 477.0, 40, 0}, {5, 93.0, 39, 0}, {4, 17.0, 19, 0}, 0, 64, 63, 128, 63, 255, 0},
{1, 6000, {5, 11.0, 32, 0}, {5, 1.0, 32, 0}, {3, 3.0, 32, 0}, 63, 0, 63, 0, 63, 255, 0}, {1, 6000, {5, 11.0, 32, 0}, {5, 1.0, 32, 0}, {3, 3.0, 32, 0}, 63, 0, 63, 0, 63, 255, 0},
{1, 6000, {1, 329.0, 20, 0}, {2, 2.0, 47, 77}, {3, 3.0, 63, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 6000, {1, 329.0, 20, 0}, {2, 2.0, 47, 77}, {3, 3.0, 63, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 8000, {4, 2000.0, 32, 0}, {2, 1.0, 0, 0}, {0, 0.0, 32, 0}, 43, 21, 7, 255, 0, 255, 0}, {1, 8000, {4, 2000.0, 32, 0}, {2, 1.0, 0, 0}, {0, 0.0, 32, 0}, 43, 21, 7, 255, 0, 255, 0},
{1, 5000, {1, 231.0, 32, 0}, {4, 1.0, 32, 65}, {3, 2.0, 32, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 5000, {1, 231.0, 32, 0}, {4, 1.0, 32, 65}, {3, 2.0, 32, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 3000, {0, 107.0, 32, 0}, {4, 1.0, 15, 0}, {0, 0.0, 17, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 3000, {0, 107.0, 32, 0}, {4, 1.0, 15, 0}, {0, 0.0, 17, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 20000, {5, 4.0, 32, 0}, {5, 1.0, 32, 170}, {5, 0.0, 32, 0}, 63, 38, 22, 255, 0, 255, 0}, {1, 20000, {5, 4.0, 32, 0}, {5, 1.0, 32, 170}, {5, 0.0, 32, 0}, 63, 38, 22, 255, 0, 255, 0},
{1, 5000, {1, 16.0, 32, 0}, {3, 1.0, 32, 238}, {0, 0.0, 0, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 5000, {1, 16.0, 32, 0}, {3, 1.0, 32, 238}, {0, 0.0, 0, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 20000, {5, 4.0, 32, 0}, {0, 0.7, 61, 43}, {3, 1.0, 22, 224}, 63, 64, 63, 204, 46, 255, 0}, {1, 20000, {5, 4.0, 32, 0}, {0, 0.7, 61, 43}, {3, 1.0, 22, 224}, 63, 64, 63, 204, 46, 255, 0},
{1, 5000, {0, 880.0, 19, 0}, {0, 0.0, 32, 0}, {0, 8.0, 32, 0}, 0, 11, 63, 34, 25, 255, 0}, {1, 5000, {0, 880.0, 19, 0}, {0, 0.0, 32, 0}, {0, 8.0, 32, 0}, 0, 11, 63, 34, 25, 255, 0},
{1, 2000, {5, 3.0, 16, 0}, {3, 2.0, 12, 0}, {3, 1.0, 37, 0}, 0, 51, 63, 132, 24, 255, 0}, {1, 2000, {5, 3.0, 16, 0}, {3, 2.0, 12, 0}, {3, 1.0, 37, 0}, 0, 51, 63, 132, 24, 255, 0},
{1, 22050, {1, 400.0, 32, 0}, {0, 20.0, 10, 0}, {3, 10.0, 8, 0}, 0, 6, 63, 60, 21, 255, 0}, {1, 22050, {1, 400.0, 32, 0}, {0, 20.0, 10, 0}, {3, 10.0, 8, 0}, 0, 6, 63, 60, 21, 255, 0},
{1, 2000, {5, 2.0, 32, 0}, {2, 3.0, 54, 0}, {0, 0.0, 32, 0}, 0, 17, 63, 98, 22, 255, 0}, {1, 2000, {5, 2.0, 32, 0}, {2, 3.0, 54, 0}, {0, 0.0, 32, 0}, 0, 17, 63, 98, 22, 255, 0},
{1, 8000, {1, 814.0, 32, 0}, {2, 11.0, 32, 0}, {3, 16.0, 32, 0}, 63, 23, 63, 74, 12, 255, 0}, {1, 8000, {1, 814.0, 32, 0}, {2, 11.0, 32, 0}, {3, 16.0, 32, 0}, 63, 23, 63, 74, 12, 255, 0},
{1, 10000, {5, 21.0, 21, 0}, {0, 5.0, 32, 178}, {0, 3.0, 33, 181}, 63, 38, 63, 104, 20, 255, 0}, {1, 10000, {5, 21.0, 21, 0}, {0, 5.0, 32, 178}, {0, 3.0, 33, 181}, 63, 38, 63, 104, 20, 255, 0},
{1, 6000, {5, 1.0, 28, 0}, {3, 6.0, 56, 0}, {0, 8.0, 32, 0}, 63, 57, 63, 98, 20, 255, 0}, {1, 6000, {5, 1.0, 28, 0}, {3, 6.0, 56, 0}, {0, 8.0, 32, 0}, 63, 57, 63, 98, 20, 255, 0},
{1, 4000, {5, 6.0, 32, 0}, {3, 2.0, 32, 0}, {3, 2.0, 32, 0}, 63, 26, 30, 66, 29, 255, 0}, {1, 4000, {5, 6.0, 32, 0}, {3, 2.0, 32, 0}, {3, 2.0, 32, 0}, 63, 26, 30, 66, 29, 255, 0},
{1, 22050, {5, 711.0, 32, 0}, {5, 7.0, 32, 0}, {0, 0.0, 32, 0}, 0, 13, 0, 17, 63, 255, 0}, {1, 22050, {5, 711.0, 32, 0}, {5, 7.0, 32, 0}, {0, 0.0, 32, 0}, 0, 13, 0, 17, 63, 255, 0},
{1, 2000, {5, 2.0, 32, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 2000, {5, 2.0, 32, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 62050, {5, 40.0, 32, 0}, {5, 1.0, 32, 0}, {5, 0.0, 0, 0}, 0, 17, 63, 36, 63, 255, 0}, {1, 62050, {5, 40.0, 32, 0}, {5, 1.0, 32, 0}, {5, 0.0, 0, 0}, 0, 17, 63, 36, 63, 255, 0},
{1, 8000, {0, 77.0, 32, 0}, {3, 3.0, 56, 189}, {0, 0.0, 17, 0}, 0, 38, 63, 140, 28, 255, 0}, {1, 8000, {0, 77.0, 32, 0}, {3, 3.0, 56, 189}, {0, 0.0, 17, 0}, 0, 38, 63, 140, 28, 255, 0},
{1, 8000, {5, 8.0, 32, 0}, {3, 3.0, 54, 189}, {3, 3.0, 32, 0}, 63, 38, 42, 140, 21, 255, 0}, {1, 8000, {5, 8.0, 32, 0}, {3, 3.0, 54, 189}, {3, 3.0, 32, 0}, 63, 38, 42, 140, 21, 255, 0},
{1, 9050, {5, 9.0, 26, 0}, {0, 1.0, 32, 209}, {0, 0.0, 32, 0}, 63, 64, 63, 132, 63, 255, 0}, {1, 9050, {5, 9.0, 26, 0}, {0, 1.0, 32, 209}, {0, 0.0, 32, 0}, 63, 64, 63, 132, 63, 255, 0},
{1, 9050, {2, 43.0, 32, 0}, {3, 1.0, 47, 172}, {0, 0.0, 32, 0}, 63, 64, 63, 198, 63, 255, 0}, {1, 9050, {2, 43.0, 32, 0}, {3, 1.0, 47, 172}, {0, 0.0, 32, 0}, 63, 64, 63, 198, 63, 255, 0},
{1, 22050, {1, 754.0, 32, 0}, {2, 0.5, 14, 126}, {4, 18.0, 17, 0}, 0, 64, 63, 128, 63, 255, 0}, {1, 22050, {1, 754.0, 32, 0}, {2, 0.5, 14, 126}, {4, 18.0, 17, 0}, 0, 64, 63, 128, 63, 255, 0},
{1, 22050, {0, 597.0, 12, 0}, {2, 0.5, 14, 126}, {4, 18.0, 17, 0}, 0, 64, 40, 128, 41, 255, 0}, {1, 22050, {0, 597.0, 12, 0}, {2, 0.5, 14, 126}, {4, 18.0, 17, 0}, 0, 64, 40, 128, 41, 255, 0},
{1, 6000, {2, 217.0, 32, 0}, {0, 0.7, 16, 0}, {3, 0.0, 32, 0}, 0, 32, 63, 49, 15, 255, 0}, {1, 6000, {2, 217.0, 32, 0}, {0, 0.7, 16, 0}, {3, 0.0, 32, 0}, 0, 32, 63, 49, 15, 255, 0},
{1, 5000, {5, 1.0, 32, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 0, 64, 63, 81, 28, 255, 0}, {1, 5000, {5, 1.0, 32, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 0, 64, 63, 81, 28, 255, 0},
{1, 10000, {5, 11.0, 32, 0}, {2, 4.0, 32, 0}, {0, 3.0, 32, 0}, 0, 64, 63, 128, 30, 255, 0}, {1, 10000, {5, 11.0, 32, 0}, {2, 4.0, 32, 0}, {0, 3.0, 32, 0}, 0, 64, 63, 128, 30, 255, 0},
{1, 10000, {5, 1.0, 32, 0}, {4, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 32, 128, 33, 255, 0}, {1, 10000, {5, 1.0, 32, 0}, {4, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 32, 128, 33, 255, 0},
{1, 10000, {2, 168.0, 32, 0}, {0, 0.5, 29, 173}, {0, 0.0, 32, 0}, 0, 13, 63, 68, 35, 255, 0}, {1, 10000, {2, 168.0, 32, 0}, {0, 0.5, 29, 173}, {0, 0.0, 32, 0}, 0, 13, 63, 68, 35, 255, 0},
{1, 10000, {2, 50.0, 32, 0}, {0, 0.5, 29, 173}, {2, 100.0, 32, 0}, 0, 13, 63, 68, 35, 255, 0}, {1, 10000, {2, 50.0, 32, 0}, {0, 0.5, 29, 173}, {2, 100.0, 32, 0}, 0, 13, 63, 68, 35, 255, 0},
{1, 4000, {5, 11.0, 25, 0}, {3, 3.0, 32, 0}, {0, 0.0, 32, 0}, 0, 9, 63, 128, 14, 255, 0}, {1, 4000, {5, 11.0, 25, 0}, {3, 3.0, 32, 0}, {0, 0.0, 32, 0}, 0, 9, 63, 128, 14, 255, 0},
{1, 4000, {5, 3.0, 27, 0}, {3, 3.0, 32, 0}, {0, 0.0, 32, 0}, 0, 9, 63, 128, 14, 255, 0}, {1, 4000, {5, 3.0, 27, 0}, {3, 3.0, 32, 0}, {0, 0.0, 32, 0}, 0, 9, 63, 128, 14, 255, 0},
{1, 3000, {4, 9.0, 20, 0}, {3, 3.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 3000, {4, 9.0, 20, 0}, {3, 3.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 3000, {4, 18.0, 20, 0}, {3, 3.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0}, {1, 3000, {4, 18.0, 20, 0}, {3, 3.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 0},
{1, 3000, {5, 4.0, 32, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 0, 64, 63, 128, 63, 255, 0}, {1, 3000, {5, 4.0, 32, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 0, 64, 63, 128, 63, 255, 0},
{1, 12000, {5, 2.0, 32, 0}, {3, 1.7, 53, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 162, 25, 255, 0}, {1, 12000, {5, 2.0, 32, 0}, {3, 1.7, 53, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 162, 25, 255, 0},
{1, 12000, {3, 77.0, 32, 0}, {3, 1.0, 61, 200}, {0, 19.0, 22, 0}, 63, 64, 63, 172, 25, 255, 0}, {1, 12000, {3, 77.0, 32, 0}, {3, 1.0, 61, 200}, {0, 19.0, 22, 0}, 63, 64, 63, 172, 25, 255, 0},
{1, 5000, {0, 16.0, 63, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 166, 35, 255, 0}, {1, 5000, {0, 16.0, 63, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 166, 35, 255, 0},
{1, 1000, {5, 1.0, 16, 0}, {0, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 91, 28, 255, 0}, {1, 1000, {5, 1.0, 16, 0}, {0, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 91, 28, 255, 0},
{1, 5000, {0, 20.0, 30, 0}, {3, 1.0, 44, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 111, 19, 255, 0}, {1, 5000, {0, 20.0, 30, 0}, {3, 1.0, 44, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 111, 19, 255, 0},
{1, 10000, {5, 14.0, 41, 0}, {5, 3.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 18, 91, 12, 255, 0}, {1, 10000, {5, 14.0, 41, 0}, {5, 3.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 18, 91, 12, 255, 0},
{1, 1000, {5, 48.0, 30, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 166, 27, 255, 0}, {1, 1000, {5, 48.0, 30, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 166, 27, 255, 0},
{1, 10000, {5, 48.0, 30, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 43, 166, 41, 255, 7}, {1, 10000, {5, 48.0, 30, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 43, 166, 41, 255, 7},
{1, 4000, {5, 35.0, 30, 0}, {3, 35.0, 32, 0}, {0, 0.0, 32, 0}, 63, 53, 21, 166, 13, 255, 0}, {1, 4000, {5, 35.0, 30, 0}, {3, 35.0, 32, 0}, {0, 0.0, 32, 0}, 63, 53, 21, 166, 13, 255, 0},
{1, 10000, {1, 63.0, 32, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 39, 91, 20, 255, 0}, {1, 10000, {1, 63.0, 32, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 39, 91, 20, 255, 0},
{1, 22050, {5, 52.0, 22, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 3, 23, 23, 57, 10, 255, 0}, {1, 22050, {5, 52.0, 22, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 3, 23, 23, 57, 10, 255, 0},
{1, 22050, {5, 80.0, 22, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 23, 23, 57, 10, 255, 0}, {1, 22050, {5, 80.0, 22, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 23, 23, 57, 10, 255, 0},
{1, 44100, {5, 54.0, 12, 0}, {5, 1.0, 32, 0}, {5, 1.0, 27, 0}, 40, 64, 63, 128, 38, 255, 63}, {1, 44100, {5, 54.0, 12, 0}, {5, 1.0, 32, 0}, {5, 1.0, 27, 0}, 40, 64, 63, 128, 38, 255, 63},
{1, 44100, {5, 119.0, 9, 0}, {5, 2.0, 32, 0}, {0, 0.0, 32, 0}, 61, 64, 39, 128, 60, 255, 28}, {1, 44100, {5, 119.0, 9, 0}, {5, 2.0, 32, 0}, {0, 0.0, 32, 0}, 61, 64, 39, 128, 60, 255, 28},
{1, 4000, {5, 11.0, 32, 0}, {5, 1.0, 17, 197}, {0, 0.0, 32, 0}, 51, 100, 63, 100, 0, 255, 0}, {1, 4000, {5, 11.0, 32, 0}, {5, 1.0, 17, 197}, {0, 0.0, 32, 0}, 51, 100, 63, 100, 0, 255, 0},
{1, 4000, {5, 21.0, 32, 0}, {5, 1.0, 17, 197}, {0, 0.0, 32, 0}, 0, 119, 0, 117, 63, 255, 0}, {1, 4000, {5, 21.0, 32, 0}, {5, 1.0, 17, 197}, {0, 0.0, 32, 0}, 0, 119, 0, 117, 63, 255, 0},
{1, 5000, {2, 143.0, 25, 0}, {3, 0.5, 40, 217}, {1, 0.0, 32, 0}, 63, 64, 63, 128, 34, 198, 32}, {1, 5000, {2, 143.0, 25, 0}, {3, 0.5, 40, 217}, {1, 0.0, 32, 0}, 63, 64, 63, 128, 34, 198, 32},
{1, 5000, {5, 10.0, 23, 0}, {3, 0.5, 24, 217}, {1, 4.0, 32, 0}, 0, 4, 63, 128, 34, 198, 32}, {1, 5000, {5, 10.0, 23, 0}, {3, 0.5, 24, 217}, {1, 4.0, 32, 0}, 0, 4, 63, 128, 34, 198, 32},
{1, 4000, {5, 6.0, 32, 0}, {3, 2.0, 32, 0}, {3, 2.0, 32, 0}, 63, 26, 30, 66, 29, 255, 0}, {1, 4000, {5, 6.0, 32, 0}, {3, 2.0, 32, 0}, {3, 2.0, 32, 0}, 63, 26, 30, 66, 29, 255, 0},
{1, 4000, {0, 150.0, 32, 0}, {0, 0.0, 32, 0}, {3, 2.0, 32, 0}, 63, 26, 30, 66, 29, 255, 0}, {1, 4000, {0, 150.0, 32, 0}, {0, 0.0, 32, 0}, {3, 2.0, 32, 0}, 63, 26, 30, 66, 29, 255, 0},
{1, 40050, {4, 100.0, 32, 0}, {3, 8.0, 22, 0}, {3, 8.0, 8, 0}, 63, 28, 44, 81, 23, 255, 0}, {1, 40050, {4, 100.0, 32, 0}, {3, 8.0, 22, 0}, {3, 8.0, 8, 0}, 63, 28, 44, 81, 23, 255, 0},
{1, 40050, {4, 150.0, 32, 0}, {3, 8.0, 22, 0}, {3, 8.0, 8, 0}, 63, 28, 44, 81, 23, 255, 0}, {1, 40050, {4, 150.0, 32, 0}, {3, 8.0, 22, 0}, {3, 8.0, 8, 0}, 63, 28, 44, 81, 23, 255, 0},
{1, 40050, {4, 294.0, 32, 0}, {3, 8.0, 22, 0}, {3, 8.0, 8, 0}, 63, 28, 44, 81, 23, 255, 0}, {1, 40050, {4, 294.0, 32, 0}, {3, 8.0, 22, 0}, {3, 8.0, 8, 0}, 63, 28, 44, 81, 23, 255, 0},
{1, 5000, {3, 621.0, 32, 0}, {2, 2.0, 22, 0}, {3, 6.0, 32, 0}, 0, 4, 63, 77, 30, 255, 0}, {1, 5000, {3, 621.0, 32, 0}, {2, 2.0, 22, 0}, {3, 6.0, 32, 0}, 0, 4, 63, 77, 30, 255, 0},
{1, 30000, {5, 28.0, 44, 0}, {3, 1.0, 45, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 208, 63, 255, 0}, {1, 30000, {5, 28.0, 44, 0}, {3, 1.0, 45, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 208, 63, 255, 0},
{1, 30000, {2, 101.0, 44, 0}, {2, 0.5, 63, 118}, {0, 0.0, 32, 0}, 63, 64, 63, 176, 63, 255, 0}, {1, 30000, {2, 101.0, 44, 0}, {2, 0.5, 63, 118}, {0, 0.0, 32, 0}, 63, 64, 63, 176, 63, 255, 0},
{1, 30000, {2, 86.0, 44, 0}, {2, 0.5, 63, 118}, {0, 0.0, 32, 0}, 63, 64, 63, 176, 63, 255, 0}, {1, 30000, {2, 86.0, 44, 0}, {2, 0.5, 63, 118}, {0, 0.0, 32, 0}, 63, 64, 63, 176, 63, 255, 0},
{1, 2000, {5, 1.0, 32, 0}, {0, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 2000, {5, 1.0, 32, 0}, {0, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 2000, {3, 99.0, 12, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 2000, {3, 99.0, 12, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 63, 64, 63, 128, 63, 255, 63},
{1, 6000, {3, 388.0, 22, 0}, {0, 0.7, 53, 0}, {0, 7.0, 32, 0}, 25, 64, 63, 202, 63, 255, 0}, {1, 6000, {3, 388.0, 22, 0}, {0, 0.7, 53, 0}, {0, 7.0, 32, 0}, 25, 64, 63, 202, 63, 255, 0},
{1, 6000, {1, 918.0, 23, 0}, {0, 0.7, 53, 0}, {0, 7.0, 32, 0}, 63, 64, 63, 202, 63, 255, 0}, {1, 6000, {1, 918.0, 23, 0}, {0, 0.7, 53, 0}, {0, 7.0, 32, 0}, 63, 64, 63, 202, 63, 255, 0},
{1, 10000, {5, 118.0, 19, 0}, {3, 1.0, 63, 0}, {0, 3.0, 32, 0}, 0, 19, 63, 66, 41, 255, 0}, {1, 10000, {5, 118.0, 19, 0}, {3, 1.0, 63, 0}, {0, 3.0, 32, 0}, 0, 19, 63, 66, 41, 255, 0},
{1, 10000, {5, 6.0, 24, 0}, {3, 1.0, 32, 208}, {2, 8.0, 12, 0}, 63, 64, 63, 128, 38, 255, 0}, {1, 10000, {5, 6.0, 24, 0}, {3, 1.0, 32, 208}, {2, 8.0, 12, 0}, 63, 64, 63, 128, 38, 255, 0},
{1, 400, {1, 20.0, 12, 0}, {0, 0.0, 32, 0}, {0, 0.0, 32, 0}, 0, 43, 63, 193, 63, 255, 0}, {1, 400, {1, 20.0, 12, 0}, {0, 0.0, 32, 0}, {0, 0.0, 32, 0}, 0, 43, 63, 193, 63, 255, 0},
{1, 400, {1, 30.0, 12, 0}, {0, 0.0, 32, 0}, {0, 0.0, 32, 0}, 0, 43, 63, 193, 63, 255, 0}, {1, 400, {1, 30.0, 12, 0}, {0, 0.0, 32, 0}, {0, 0.0, 32, 0}, 0, 43, 63, 193, 63, 255, 0},
{1, 400, {1, 40.0, 12, 0}, {0, 0.0, 32, 0}, {0, 0.0, 32, 0}, 0, 43, 63, 193, 63, 255, 0}, {1, 400, {1, 40.0, 12, 0}, {0, 0.0, 32, 0}, {0, 0.0, 32, 0}, 0, 43, 63, 193, 63, 255, 0},
{1, 8000, {3, 800.0, 24, 0}, {0, 8.0, 4, 0}, {0, 0.0, 32, 0}, 0, 13, 63, 138, 63, 255, 0}, {1, 8000, {3, 800.0, 24, 0}, {0, 8.0, 4, 0}, {0, 0.0, 32, 0}, 0, 13, 63, 138, 63, 255, 0},
{1, 8000, {5, 53.0, 12, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 0, 0, 63, 68, 63, 255, 0}, {1, 8000, {5, 53.0, 12, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 0, 0, 63, 68, 63, 255, 0},
{1, 8000, {3, 400.0, 24, 0}, {0, 8.0, 4, 0}, {0, 0.0, 32, 0}, 0, 13, 63, 138, 63, 255, 0}, {1, 8000, {3, 400.0, 24, 0}, {0, 8.0, 4, 0}, {0, 0.0, 32, 0}, 0, 13, 63, 138, 63, 255, 0},
{1, 8000, {5, 53.0, 12, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 0, 0, 63, 68, 63, 255, 0}, {1, 8000, {5, 53.0, 12, 0}, {5, 1.0, 32, 0}, {0, 0.0, 32, 0}, 0, 0, 63, 68, 63, 255, 0},
{1, 8000, {3, 200.0, 32, 0}, {0, 8.0, 4, 0}, {0, 0.0, 32, 0}, 0, 13, 63, 138, 63, 255, 0}, {1, 8000, {3, 200.0, 32, 0}, {0, 8.0, 4, 0}, {0, 0.0, 32, 0}, 0, 13, 63, 138, 63, 255, 0},
{1, 8000, {5, 25.0, 17, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 0, 0, 63, 68, 63, 255, 0}, {1, 8000, {5, 25.0, 17, 0}, {3, 1.0, 32, 0}, {0, 0.0, 32, 0}, 0, 0, 63, 68, 63, 255, 0},
{1, 8000, {4, 800.0, 32, 0}, {4, 2.0, 21, 0}, {4, 8.0, 32, 0}, 0, 106, 63, 130, 27, 255, 0}, {1, 8000, {4, 800.0, 32, 0}, {4, 2.0, 21, 0}, {4, 8.0, 32, 0}, 0, 106, 63, 130, 27, 255, 0},
{1, 3000, {4, 31.0, 10, 0}, {3, 2.0, 40, 0}, {4, 1.0, 31, 0}, 0, 9, 63, 94, 63, 255, 0}, {1, 3000, {4, 31.0, 10, 0}, {3, 2.0, 40, 0}, {4, 1.0, 31, 0}, 0, 9, 63, 94, 63, 255, 0},
{1, 5000, {2, 168.0, 32, 0}, {0, 0.5, 29, 173}, {0, 0.0, 32, 0}, 0, 13, 63, 68, 35, 255, 0}, {1, 5000, {2, 168.0, 32, 0}, {0, 0.5, 29, 173}, {0, 0.0, 32, 0}, 0, 13, 63, 68, 35, 255, 0},
{1, 1000, {0, 20.0, 0, 0}, {0, 0.0, 0, 0}, {0, 0.0, 0, 0}, 0, 64, 0, 128, 0, 255, 0} {1, 1000, {0, 20.0, 0, 0}, {0, 0.0, 0, 0}, {0, 0.0, 0, 0}, 0, 64, 0, 128, 0, 255, 0}
}; };
BOOL LoadGenericData() BOOL LoadGenericData()

View file

@ -1,7 +1,6 @@
#include "Input.h" #include "Input.h"
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <string.h> #include <string.h>
#include <SDL.h> #include <SDL.h>
@ -14,11 +13,11 @@
#define JOYSTICK_DEADZONE 10000 #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() void ReleaseDirectInput()
{ {
//Close opened joystick (if exists) // Close opened joystick (if exists)
if (joystick) if (joystick)
{ {
SDL_QuitSubSystem(SDL_INIT_JOYSTICK); SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
@ -29,14 +28,14 @@ void ReleaseDirectInput()
bool InitDirectInput() bool InitDirectInput()
{ {
//Open first available joystick // Open first available joystick
SDL_InitSubSystem(SDL_INIT_JOYSTICK); SDL_InitSubSystem(SDL_INIT_JOYSTICK);
for (int i = 0; i < SDL_NumJoysticks(); i++) for (int i = 0; i < SDL_NumJoysticks(); i++)
{ {
joystick = SDL_JoystickOpen(i); joystick = SDL_JoystickOpen(i);
//Break as soon as a joystick is properly opened // Break as soon as a joystick is properly opened
if (joystick) if (joystick)
break; break;
} }
@ -46,13 +45,13 @@ bool InitDirectInput()
bool GetJoystickStatus(JOYSTICK_STATUS *pStatus) bool GetJoystickStatus(JOYSTICK_STATUS *pStatus)
{ {
//Clear status // Clear status
memset(pStatus, 0, sizeof(JOYSTICK_STATUS)); memset(pStatus, 0, sizeof(JOYSTICK_STATUS));
if (joystick) if (joystick)
{ {
int32_t x = SDL_JoystickGetAxis(joystick, 0); Sint16 x = SDL_JoystickGetAxis(joystick, 0);
int32_t y = SDL_JoystickGetAxis(joystick, 1); Sint16 y = SDL_JoystickGetAxis(joystick, 1);
pStatus->bLeft = x <= -JOYSTICK_DEADZONE; pStatus->bLeft = x <= -JOYSTICK_DEADZONE;
pStatus->bRight = x >= JOYSTICK_DEADZONE; pStatus->bRight = x >= JOYSTICK_DEADZONE;
pStatus->bUp = y <= -JOYSTICK_DEADZONE; pStatus->bUp = y <= -JOYSTICK_DEADZONE;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

@ -1,7 +1,6 @@
#include "NpChar.h" #include "NpChar.h"
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -27,7 +26,7 @@ int gCurlyShoot_y;
int gSuperXpos; int gSuperXpos;
int gSuperYpos; int gSuperYpos;
const char *gPassPixEve = "PXE\0"; const char *gPassPixEve = "PXE";
void InitNpChar() void InitNpChar()
{ {
@ -55,10 +54,16 @@ void SetUniqueParameter(NPCHAR *npc)
BOOL LoadEvent(const char *path_event) BOOL LoadEvent(const char *path_event)
{ {
FILE *fp;
int count;
int i;
int n;
EVENT eve;
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s", gDataPath, path_event); sprintf(path, "%s/%s", gDataPath, path_event);
FILE *fp = fopen(path, "rb"); fp = fopen(path, "rb");
if (fp == NULL) if (fp == NULL)
return FALSE; return FALSE;
@ -75,33 +80,37 @@ BOOL LoadEvent(const char *path_event)
} }
//Get amount of NPCs //Get amount of NPCs
int count = File_ReadLE32(fp); #ifdef NONPORTABLE
fread(&count, 4, 1, fp);
#else
count = File_ReadLE32(fp);
#endif
//Load NPCs //Load NPCs
memset(gNPC, 0, sizeof(gNPC)); memset(gNPC, 0, sizeof(gNPC));
int n = 170; n = 170;
for (int i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
//Get data from file //Get data from file
EVENT eve; #ifdef NONPORTABLE
fread(&eve, sizeof(EVENT), 1, fp);
#else
eve.x = File_ReadLE16(fp); eve.x = File_ReadLE16(fp);
eve.y = File_ReadLE16(fp); eve.y = File_ReadLE16(fp);
eve.code_flag = File_ReadLE16(fp); eve.code_flag = File_ReadLE16(fp);
eve.code_event = File_ReadLE16(fp); eve.code_event = File_ReadLE16(fp);
eve.code_char = File_ReadLE16(fp); eve.code_char = File_ReadLE16(fp);
eve.bits = File_ReadLE16(fp); eve.bits = File_ReadLE16(fp);
#endif
//Set NPC parameters //Set NPC parameters
if (eve.bits & npc_altDir) gNPC[n].direct = (eve.bits & npc_altDir) ? 2 : 0;
gNPC[n].direct = 2;
else
gNPC[n].direct = 0;
gNPC[n].code_char = eve.code_char; gNPC[n].code_char = eve.code_char;
gNPC[n].code_event = eve.code_event; gNPC[n].code_event = eve.code_event;
gNPC[n].code_flag = eve.code_flag; gNPC[n].code_flag = eve.code_flag;
gNPC[n].x = eve.x << 13; gNPC[n].x = eve.x * 0x10 * 0x200;
gNPC[n].y = eve.y << 13; gNPC[n].y = eve.y * 0x10 * 0x200;
gNPC[n].bits = eve.bits; gNPC[n].bits = eve.bits;
gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits; gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp; gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
@ -110,13 +119,13 @@ BOOL LoadEvent(const char *path_event)
//Check flags //Check flags
if (gNPC[n].bits & npc_appearSet) if (gNPC[n].bits & npc_appearSet)
{ {
if (GetNPCFlag(gNPC[n].code_flag)) if (GetNPCFlag(gNPC[n].code_flag) == TRUE)
gNPC[n].cond |= 0x80u; gNPC[n].cond |= 0x80;
} }
else if (gNPC[n].bits & npc_hideSet) else if (gNPC[n].bits & npc_hideSet)
{ {
if (!GetNPCFlag(gNPC[n].code_flag)) if (GetNPCFlag(gNPC[n].code_flag) == FALSE)
gNPC[n].cond |= 0x80u; gNPC[n].cond |= 0x80;
} }
else else
{ {
@ -133,37 +142,37 @@ 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) 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++) int n = start_index;
{ while (n < NPC_MAX && gNPC[n].cond)
if (!gNPC[n].cond) ++n;
{
//Set NPC parameters if (n == NPC_MAX)
memset(&gNPC[n], 0, sizeof(NPCHAR)); return;
gNPC[n].cond |= 0x80u;
gNPC[n].direct = dir; //Set NPC parameters
gNPC[n].code_char = code_char; memset(&gNPC[n], 0, sizeof(NPCHAR));
gNPC[n].x = x; gNPC[n].cond |= 0x80u;
gNPC[n].y = y; gNPC[n].direct = dir;
gNPC[n].xm = xm; gNPC[n].code_char = code_char;
gNPC[n].ym = ym; gNPC[n].x = x;
gNPC[n].pNpc = npc; gNPC[n].y = y;
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits; gNPC[n].xm = xm;
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp; gNPC[n].ym = ym;
SetUniqueParameter(&gNPC[n]); gNPC[n].pNpc = npc;
break; gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
} gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
} SetUniqueParameter(&gNPC[n]);
} }
void SetDestroyNpChar(int x, int y, int w, int num) void SetDestroyNpChar(int x, int y, int w, int num)
{ {
//Create smoke //Create smoke
int wa = w / 0x200; w /= 0x200;
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
int offset_x = Random(-wa, wa) << 9; int offset_x = Random(-w, w) * 0x200;
int offset_y = Random(-wa, wa) << 9; int offset_y = Random(-w, w) * 0x200;
SetNpChar(4, x + offset_x, offset_y + y, 0, 0, 0, NULL, 0x100); SetNpChar(4, x + offset_x, y + offset_y, 0, 0, 0, NULL, 0x100);
} }
//Flash effect //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) void SetDestroyNpCharUp(int x, int y, int w, int num)
{ {
//Create smoke //Create smoke
int wa = w / 0x200; w /= 0x200;
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
{ {
int offset_x = Random(-wa, wa) << 9; int offset_x = Random(-w, w) * 0x200;
int offset_y = Random(-wa, wa) << 9; int offset_y = Random(-w, w) * 0x200;
SetNpChar(4, x + offset_x, offset_y + y, 0, 0, 1, NULL, 0x100); SetNpChar(4, x + offset_x, y + offset_y, 0, 0, 1, NULL, 0x100);
} }
//Flash effect //Flash effect
@ -188,117 +197,113 @@ void SetDestroyNpCharUp(int x, int y, int w, int num)
void SetExpObjects(int x, int y, int exp) void SetExpObjects(int x, int y, int exp)
{ {
int sub_exp; int sub_exp;
for (int n = 0x100; exp; SetUniqueParameter(&gNPC[n])) int n = 0x100;
while (exp)
{ {
while (true) while (n < NPC_MAX && gNPC[n].cond)
{
bool v3 = n < NPC_MAX && gNPC[n].cond;
if (!v3)
break;
++n; ++n;
}
if (n == NPC_MAX) if (n == NPC_MAX)
break; break;
memset(&gNPC[n], 0, sizeof(NPCHAR)); memset(&gNPC[n], 0, sizeof(NPCHAR));
if (exp < 20) if (exp >= 20)
{
if (exp < 5)
{
if (exp > 0)
{
--exp;
sub_exp = 1;
}
}
else
{
exp -= 5;
sub_exp = 5;
}
}
else
{ {
exp -= 20; exp -= 20;
sub_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].direct = 0;
gNPC[n].code_char = 1; gNPC[n].code_char = 1;
gNPC[n].x = x; gNPC[n].x = x;
gNPC[n].y = y; gNPC[n].y = y;
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits; gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = sub_exp; gNPC[n].exp = sub_exp;
SetUniqueParameter(&gNPC[n]);
} }
} }
BOOL SetBulletObject(int x, int y, int val) BOOL SetBulletObject(int x, int y, int val)
{ {
int tamakazu_ari[10];
int n;
int t = 0; int t = 0;
int bullet_no;
int tamakazu_ari[10];
int n;
memset(tamakazu_ari, 0, sizeof(tamakazu_ari)); memset(tamakazu_ari, 0, sizeof(tamakazu_ari));
for (n = 0; n < 8; n++) for (n = 0; n < 8; ++n)
{ {
int code = gArmsData[n].code; switch (gArmsData[n].code)
if (code == 5)
tamakazu_ari[t++] = 0;
else if (code == 10)
tamakazu_ari[t++] = 1;
else
tamakazu_ari[t] = 0;
}
if (!t)
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)
{ {
memset(&gNPC[n], 0, sizeof(NPCHAR)); case 5:
gNPC[n].cond |= 0x80u; tamakazu_ari[t++] = 0;
gNPC[n].direct = 0; break;
gNPC[n].code_event = bullet_no; case 10:
gNPC[n].code_char = 86; tamakazu_ari[t++] = 1;
gNPC[n].x = x; break;
gNPC[n].y = y; default:
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits; tamakazu_ari[t] = 0;
gNPC[n].exp = val; break;
SetUniqueParameter(&gNPC[n]);
return TRUE;
} }
} }
return FALSE; if (t == 0)
return FALSE;
n = Random(1, 10 * t);
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 |= 0x80;
gNPC[n].direct = 0;
gNPC[n].code_event = bullet_no;
gNPC[n].code_char = 86;
gNPC[n].x = x;
gNPC[n].y = y;
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = val;
SetUniqueParameter(&gNPC[n]);
return TRUE;
} }
BOOL SetLifeObject(int x, int y, int val) BOOL SetLifeObject(int x, int y, int val)
{ {
for (int n = 0x100; n < NPC_MAX; n++) int n = 0x100;
{ while (n < NPC_MAX && gNPC[n].cond)
if (!gNPC[n].cond) ++n;
{
memset(&gNPC[n], 0, sizeof(NPCHAR));
gNPC[n].cond |= 0x80u;
gNPC[n].direct = 0;
gNPC[n].code_char = 87;
gNPC[n].x = x;
gNPC[n].y = y;
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = val;
SetUniqueParameter(&gNPC[n]);
return TRUE;
}
}
return FALSE; if (n == NPC_MAX)
return FALSE;
memset(&gNPC[n], 0, sizeof(NPCHAR));
gNPC[n].cond |= 0x80;
gNPC[n].direct = 0;
gNPC[n].code_char = 87;
gNPC[n].x = x;
gNPC[n].y = y;
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = val;
SetUniqueParameter(&gNPC[n]);
return TRUE;
} }
void VanishNpChar(NPCHAR *npc) void VanishNpChar(NPCHAR *npc)
@ -309,7 +314,7 @@ void VanishNpChar(NPCHAR *npc)
npc->count1 = 0; npc->count1 = 0;
npc->x = x; npc->x = x;
npc->y = y; npc->y = y;
npc->cond |= 0x80u; npc->cond |= 0x80;
npc->direct = 0; npc->direct = 0;
npc->code_char = 3; npc->code_char = 3;
npc->bits = gNpcTable[npc->code_char].bits; npc->bits = gNpcTable[npc->code_char].bits;
@ -319,15 +324,15 @@ void VanishNpChar(NPCHAR *npc)
void PutNpChar(int fx, int fy) 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) if (gNPC[n].cond & 0x80)
{ {
int8_t a;
if (gNPC[n].shock) if (gNPC[n].shock)
{ {
a = 2 * ((gNPC[n].shock >> 1) & 1) - 1; a = 2 * ((gNPC[n].shock / 2) % 2) - 1;
} }
else else
{ {
@ -340,10 +345,10 @@ void PutNpChar(int fx, int fy)
} }
int side; int side;
if (gNPC[n].direct) if (gNPC[n].direct == 0)
side = gNPC[n].view.back;
else
side = gNPC[n].view.front; side = gNPC[n].view.front;
else
side = gNPC[n].view.back;
PutBitmap3( PutBitmap3(
&grcGame, &grcGame,
@ -357,11 +362,13 @@ void PutNpChar(int fx, int fy)
void ActNpChar() void ActNpChar()
{ {
for (int i = 0; i < NPC_MAX; i++) for (int i = 0; i < NPC_MAX; ++i)
{ {
if (gNPC[i].cond & 0x80) 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) if (gNPC[i].shock)
--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++) 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].bits &= (npc_eventTouch | npc_eventDie | 0x400 | npc_appearSet | npc_altDir | npc_interact | npc_hideSet);
gNPC[n].code_char = code_char; gNPC[n].code_char = code_char;
gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits; gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp; gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
SetUniqueParameter(&gNPC[n]); SetUniqueParameter(&gNPC[n]);
gNPC[n].cond |= 0x80u; gNPC[n].cond |= 0x80;
gNPC[n].act_no = 0; gNPC[n].act_no = 0;
gNPC[n].act_wait = 0; gNPC[n].act_wait = 0;
gNPC[n].count1 = 0; gNPC[n].count1 = 0;
@ -390,19 +397,20 @@ void ChangeNpCharByEvent(int code_event, int code_char, int dir)
gNPC[n].xm = 0; gNPC[n].xm = 0;
gNPC[n].ym = 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
{ }
if (gNPC[n].x >= gMC.x) else if (dir == 4)
gNPC[n].direct = 0; {
else if (gNPC[n].x < gMC.x)
gNPC[n].direct = 2; gNPC[n].direct = 2;
}
else else
{ gNPC[n].direct = 0;
gNPC[n].direct = dir; }
} else
{
gNPC[n].direct = dir;
} }
gpNpcFuncTbl[code_char](&gNPC[n]); 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++) 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].bits |= npc_interact;
gNPC[n].code_char = code_char; gNPC[n].code_char = code_char;
gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits; gNPC[n].bits |= gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp; gNPC[n].exp = gNpcTable[gNPC[n].code_char].exp;
SetUniqueParameter(&gNPC[n]); SetUniqueParameter(&gNPC[n]);
gNPC[n].cond |= 0x80u; gNPC[n].cond |= 0x80;
gNPC[n].act_no = 0; gNPC[n].act_no = 0;
gNPC[n].act_wait = 0; gNPC[n].act_wait = 0;
gNPC[n].count1 = 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].xm = 0;
gNPC[n].ym = 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
{ }
if (gNPC[n].x >= gMC.x) else if (dir == 4)
gNPC[n].direct = 0; {
else if (gNPC[n].x < gMC.x)
gNPC[n].direct = 2; gNPC[n].direct = 2;
}
else else
{ gNPC[n].direct = 0;
gNPC[n].direct = dir; }
} else
{
gNPC[n].direct = (signed char)dir;
} }
gpNpcFuncTbl[code_char](&gNPC[n]); 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) 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) if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
gNPC[n].act_no = act_no;
if (dir != 5)
{
if (dir == 4)
{
if (gNPC[n].x >= gMC.x)
gNPC[n].direct = 0;
else
gNPC[n].direct = 2;
}
else
{
gNPC[n].direct = dir;
}
}
break; break;
}
++n;
}
if (n == NPC_MAX)
return;
gNPC[n].act_no = act_no;
if (dir == 5)
{
// 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 = 2;
else
gNPC[n].direct = 0;
}
else
{
gNPC[n].direct = dir;
} }
} }
void MoveNpChar(int code_event, int x, int y, int dir) 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) if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
gNPC[n].x = x;
gNPC[n].y = y;
if (dir != 5)
{
if (dir == 4)
{
if (gNPC[n].x >= gMC.x)
gNPC[n].direct = 0;
else
gNPC[n].direct = 2;
}
else
{
gNPC[n].direct = dir;
}
}
break; break;
}
++n;
}
if (n == NPC_MAX)
return;
gNPC[n].x = x;
gNPC[n].y = y;
if (dir == 5)
{
// 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 = 2;
else
gNPC[n].direct = 0;
}
else
{
gNPC[n].direct = (signed char)dir;
} }
} }
void BackStepMyChar(int code_event) void BackStepMyChar(int code_event)
{ {
int n = 0;
gMC.cond &= ~1; gMC.cond &= ~1;
gMC.ym = -0x200; 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
{
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)
{
gMC.direct = 0;
gMC.xm = 0x200;
}
else
{ {
gMC.direct = 2; gMC.direct = 2;
gMC.xm = -0x200; gMC.xm = -0x200;
} }
else
{
for (int n = 0; n < NPC_MAX; n++)
{
if ((gNPC[n].cond & 0x80) && gNPC[n].code_event == code_event)
{
if (gNPC[n].x >= gMC.x)
{
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++) for (int n = 0; n < NPC_MAX; n++)
{ {
@ -573,15 +598,15 @@ void DeleteNpCharCode(int code, bool bSmoke)
switch (gNPC[n].size) switch (gNPC[n].size)
{ {
case 1:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 4);
break;
case 2: case 2:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 8); SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 8);
break; break;
case 3: case 3:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 16); SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 16);
break; break;
case 1:
SetDestroyNpChar(gNPC[n].x, gNPC[n].y, gNPC[n].view.back, 4);
break;
} }
} }
} }
@ -590,30 +615,30 @@ void DeleteNpCharCode(int code, bool bSmoke)
void GetNpCharPosition(int *x, int *y, int i) void GetNpCharPosition(int *x, int *y, int i)
{ {
*x = gNPC[i].x; *x = gNPC[i].x;
*y = gNPC[i].y; *y = gNPC[i].y;
} }
BOOL IsNpCharCode(int code) 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) if ((gNPC[i].cond & 0x80) && gNPC[i].code_char == code)
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} }
BOOL GetNpCharAlive(int code_event) 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) if ((gNPC[i].cond & 0x80) && gNPC[i].code_event == code_event)
return TRUE; break;
}
return FALSE; if (i < NPC_MAX)
return TRUE;
else
return FALSE;
} }
int CountAliveNpChar() int CountAliveNpChar()

View file

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

View file

@ -1352,8 +1352,18 @@ void ActNpc117(NPCHAR *npc)
break; break;
case 3: case 3:
// TODO: This code is being problematic, and if (0)
// assembling with the wrong registers. {
// 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->act_no = 4;
npc->ani_no = 1; npc->ani_no = 1;
npc->ani_wait = 0; npc->ani_wait = 0;
@ -1382,9 +1392,15 @@ void ActNpc117(NPCHAR *npc)
npc->ani_no = 5; npc->ani_no = 5;
SetDestroyNpChar(npc->x, npc->y, npc->view.back, 8); SetDestroyNpChar(npc->x, npc->y, npc->view.back, 8);
break; break;
// End of wrong-reg code
case 6: 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; npc->ani_no = 5;
break; break;

View file

@ -1,5 +1,7 @@
#include "NpcHit.h" #include "NpcHit.h"
#include "WindowsWrapper.h"
#include "Back.h" #include "Back.h"
#include "Bullet.h" #include "Bullet.h"
#include "Caret.h" #include "Caret.h"
@ -16,40 +18,40 @@ void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y)
{ {
int hit = 0; int hit = 0;
if (npc->y - npc->hit.top < ((2 * y + 1) << 12) - 0x600 if (npc->y - npc->hit.top < (y * 0x10 + 5) * 0x200
&& npc->y + npc->hit.bottom > ((2 * y - 1) << 12) + 0x600 && npc->y + npc->hit.bottom > (y * 0x10 - 5) * 0x200
&& npc->x - npc->hit.back < (2 * x + 1) << 12 && npc->x - npc->hit.back < (x * 0x10 + 8) * 0x200
&& npc->x - npc->hit.back > x << 13) && 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; hit |= 1;
} }
if (npc->y - npc->hit.top < ((2 * y + 1) << 12) - 0x600 if (npc->y - npc->hit.top < (y * 0x10 + 5) * 0x200
&& npc->y + npc->hit.bottom > ((2 * y - 1) << 12) + 0x600 && npc->y + npc->hit.bottom > (y * 0x10 - 5) * 0x200
&& npc->hit.back + npc->x > (2 * x - 1) << 12 && npc->x + npc->hit.back > (x * 0x10 - 8) * 0x200
&& npc->hit.back + npc->x < x << 13) && 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; hit |= 4;
} }
if (npc->x - npc->hit.back < ((2 * x + 1) << 12) - 0x600 if (npc->x - npc->hit.back < (x * 0x10 + 5) * 0x200
&& npc->hit.back + npc->x > ((2 * x - 1) << 12) + 0x600 && npc->x + npc->hit.back > (x * 0x10 - 5) * 0x200
&& npc->y - npc->hit.top < (2 * y + 1) << 12 && npc->y - npc->hit.top < (y * 0x10 + 8) * 0x200
&& npc->y - npc->hit.top > y << 13) && 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; npc->ym = 0;
hit |= 2; hit |= 2;
} }
if (npc->x - npc->hit.back < ((2 * x + 1) << 12) - 0x600 if (npc->x - npc->hit.back < (x * 0x10 + 5) * 0x200
&& npc->hit.back + npc->x > ((2 * x - 1) << 12) + 0x600 && npc->x + npc->hit.back > (x * 0x10 - 5) * 0x200
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12 && npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200
&& npc->y + npc->hit.bottom < y << 13) && 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; npc->ym = 0;
hit |= 8; hit |= 8;
} }
@ -61,20 +63,20 @@ void JudgeHitNpCharTriangleA(NPCHAR *npc, int x, int y)
{ {
int hit = 0; int hit = 0;
if (npc->x < (2 * x + 1) << 12 if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (2 * x - 1) << 12 && npc->x > (x * 0x10 - 8) * 0x200
&& npc->y - npc->hit.top < (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800 && npc->y - npc->hit.top < (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12) && npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
{ {
//Clip //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 //Halt momentum
if (npc->ym < 0) if (npc->ym < 0)
npc->ym = 0; npc->ym = 0;
//Set that hit a ceiling //Set that hit a ceiling
hit = 2; hit |= 2;
} }
npc->flag |= hit; npc->flag |= hit;
@ -84,20 +86,20 @@ void JudgeHitNpCharTriangleB(NPCHAR *npc, int x, int y)
{ {
int hit = 0; int hit = 0;
if (npc->x < (2 * x + 1) << 12 if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (2 * x - 1) << 12 && npc->x > (x * 0x10 - 8) * 0x200
&& npc->y - npc->hit.top < (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800 && npc->y - npc->hit.top < (y * 0x10 * 0x200) - ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12) && npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
{ {
//Clip //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 //Halt momentum
if (npc->ym < 0) if (npc->ym < 0)
npc->ym = 0; npc->ym = 0;
//Set that hit a ceiling //Set that hit a ceiling
hit = 2; hit |= 2;
} }
npc->flag |= hit; npc->flag |= hit;
@ -107,20 +109,20 @@ void JudgeHitNpCharTriangleC(NPCHAR *npc, int x, int y)
{ {
int hit = 0; int hit = 0;
if (npc->x < (2 * x + 1) << 12 if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (2 * x - 1) << 12 && npc->x > (x * 0x10 - 8) * 0x200
&& npc->y - npc->hit.top < (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800 && npc->y - npc->hit.top < (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) - 0x800
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12) && npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
{ {
//Clip //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 //Halt momentum
if (npc->ym < 0) if (npc->ym < 0)
npc->ym = 0; npc->ym = 0;
//Set that hit a ceiling //Set that hit a ceiling
hit = 2; hit |= 2;
} }
npc->flag |= hit; npc->flag |= hit;
@ -130,20 +132,20 @@ void JudgeHitNpCharTriangleD(NPCHAR *npc, int x, int y)
{ {
int hit = 0; int hit = 0;
if (npc->x < (2 * x + 1) << 12 if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->x > (2 * x - 1) << 12 && npc->x > (x * 0x10 - 8) * 0x200
&& npc->y - npc->hit.top < (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800 && npc->y - npc->hit.top < (y * 0x10 * 0x200) + ((npc->x - (x * 0x10 * 0x200)) / 2) + 0x800
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12) && npc->y + npc->hit.bottom > (y * 0x10 - 8) * 0x200)
{ {
//Clip //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 //Halt momentum
if (npc->ym < 0) if (npc->ym < 0)
npc->ym = 0; npc->ym = 0;
//Set that hit a ceiling //Set that hit a ceiling
hit = 2; hit |= 2;
} }
npc->flag |= hit; npc->flag |= hit;
@ -151,22 +153,24 @@ void JudgeHitNpCharTriangleD(NPCHAR *npc, int x, int y)
void JudgeHitNpCharTriangleE(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 hit |= 0x10000;
&& npc->x > (2 * x - 1) << 12
&& npc->y + npc->hit.bottom > (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800 if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->y - npc->hit.top < (2 * y + 1) << 12 ) && 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 //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 //Halt momentum
if (npc->ym > 0) if (npc->ym > 0)
npc->ym = 0; npc->ym = 0;
//Set that hit this slope //Set that hit this slope
hit = 0x10028; hit |= 0x28;
} }
npc->flag |= hit; npc->flag |= hit;
@ -174,22 +178,24 @@ void JudgeHitNpCharTriangleE(NPCHAR *npc, int x, int y)
void JudgeHitNpCharTriangleF(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 hit |= 0x20000;
&& npc->x > (2 * x - 1) << 12
&& npc->y + npc->hit.bottom > (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800 if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->y - npc->hit.top < (2 * y + 1) << 12 ) && 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 //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 //Halt momentum
if (npc->ym > 0) if (npc->ym > 0)
npc->ym = 0; npc->ym = 0;
//Set that hit this slope //Set that hit this slope
hit = 0x20028; hit |= 0x28;
} }
npc->flag |= hit; npc->flag |= hit;
@ -197,22 +203,24 @@ void JudgeHitNpCharTriangleF(NPCHAR *npc, int x, int y)
void JudgeHitNpCharTriangleG(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 hit |= 0x40000;
&& npc->x > (2 * x - 1) << 12
&& npc->y + npc->hit.bottom > (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800 if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->y - npc->hit.top < (2 * y + 1) << 12 ) && 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 //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 //Halt momentum
if (npc->ym > 0) if (npc->ym > 0)
npc->ym = 0; npc->ym = 0;
//Set that hit this slope //Set that hit this slope
hit = 0x40018; hit |= 0x18;
} }
npc->flag |= hit; npc->flag |= hit;
@ -220,22 +228,24 @@ void JudgeHitNpCharTriangleG(NPCHAR *npc, int x, int y)
void JudgeHitNpCharTriangleH(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 hit |= 0x80000;
&& npc->x > (2 * x - 1) << 12
&& npc->y + npc->hit.bottom > (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800 if (npc->x < (x * 0x10 + 8) * 0x200
&& npc->y - npc->hit.top < (2 * y + 1) << 12 ) && 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 //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 //Halt momentum
if (npc->ym > 0) if (npc->ym > 0)
npc->ym = 0; npc->ym = 0;
//Set that hit this slope //Set that hit this slope
hit = 0x80018; hit |= 0x18;
} }
npc->flag |= hit; npc->flag |= hit;
@ -245,19 +255,24 @@ void JudgeHitNpCharWater(NPCHAR *npc, int x, int y)
{ {
int hit = 0; int hit = 0;
if (npc->x - npc->hit.back < (4 * (2 * x + 1) - 1) << 10 if (npc->x - npc->hit.back < (x * 0x10 + 6) * 0x200
&& npc->hit.back + npc->x > (4 * (2 * x - 1) + 1) << 10 && npc->x + npc->hit.back > (x * 0x10 - 6) * 0x200
&& npc->y - npc->hit.top < (4 * (2 * y + 1) - 1) << 10 && npc->y - npc->hit.top < (y * 0x10 + 6) * 0x200
&& npc->y + npc->hit.bottom > (4 * (2 * y - 1) + 1) << 10) && npc->y + npc->hit.bottom > (y * 0x10 - 6) * 0x200)
hit = 0x100; hit |= 0x100;
npc->flag |= hit; npc->flag |= hit;
} }
void HitNpCharMap() void HitNpCharMap()
{ {
int offy[9]; int judg, x, y;
int offx[9]; int offx[9];
int offy[9];
int i;
int j;
offx[0] = 0; offx[0] = 0;
offx[1] = 1; offx[1] = 1;
@ -279,133 +294,162 @@ void HitNpCharMap()
offy[7] = 2; offy[7] = 2;
offy[8] = 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; judg = 9;
if (gNPC[i].size <= 2) x = (gNPC[i].x - 0x1000) / 0x10 / 0x200;
y = (gNPC[i].y - 0x1000) / 0x10 / 0x200;
}
else
{
judg = 4;
x = gNPC[i].x / 0x10 / 0x200;
y = gNPC[i].y / 0x10 / 0x200;
}
gNPC[i].flag = 0;
for (j = 0; j < judg; j++)
{
switch (GetAttribute(x + offx[j], y + offy[j]))
{ {
judg = 4; //No NPC block
x = gNPC[i].x / 0x2000; case 0x44:
y = gNPC[i].y / 0x2000; if (gNPC[i].bits & npc_ignore44)
}
else
{
judg = 9;
x = (gNPC[i].x - 0x1000) / 0x2000;
y = (gNPC[i].y - 0x1000) / 0x2000;
}
gNPC[i].flag = 0;
for (int 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]);
break; break;
// Fallthrough
//Block
case 0x03:
case 0x05:
case 0x41:
case 0x43:
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
break;
//Block //Slopes
case 0x03: case 0x50:
case 0x05: JudgeHitNpCharTriangleA(&gNPC[i], x + offx[j], y + offy[j]);
case 0x41: break;
case 0x43:
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
break;
//Water block case 0x51:
case 0x04: JudgeHitNpCharTriangleB(&gNPC[i], x + offx[j], y + offy[j]);
case 0x61: break;
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 0x52:
case 0x44: JudgeHitNpCharTriangleC(&gNPC[i], x + offx[j], y + offy[j]);
if (!(gNPC[i].bits & npc_ignore44)) break;
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
break;
//Slopes case 0x53:
case 0x50: JudgeHitNpCharTriangleD(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharTriangleA(&gNPC[i], x + offx[j], y + offy[j]); break;
break;
case 0x51: case 0x54:
JudgeHitNpCharTriangleB(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleE(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x52: case 0x55:
JudgeHitNpCharTriangleC(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleF(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x53: case 0x56:
JudgeHitNpCharTriangleD(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleG(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x54: case 0x57:
JudgeHitNpCharTriangleE(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleH(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x55: //Water
JudgeHitNpCharTriangleF(&gNPC[i], x + offx[j], y + offy[j]); case 0x02:
break; case 0x60:
case 0x62:
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break;
case 0x56: //Water block
JudgeHitNpCharTriangleG(&gNPC[i], x + offx[j], y + offy[j]); case 0x04:
break; case 0x61:
case 0x64:
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break;
case 0x57: //Water slopes
JudgeHitNpCharTriangleH(&gNPC[i], x + offx[j], y + offy[j]); case 0x70:
break; JudgeHitNpCharTriangleA(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break;
//Water slopes case 0x71:
case 0x70: JudgeHitNpCharTriangleB(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharTriangleA(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]); break;
break;
case 0x71: case 0x72:
JudgeHitNpCharTriangleB(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleC(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x72: case 0x73:
JudgeHitNpCharTriangleC(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleD(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x73: case 0x74:
JudgeHitNpCharTriangleD(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleE(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x74: case 0x75:
JudgeHitNpCharTriangleE(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleF(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x75: case 0x76:
JudgeHitNpCharTriangleF(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleG(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x76: case 0x77:
JudgeHitNpCharTriangleG(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleH(&gNPC[i], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x77: case 0xA0:
JudgeHitNpCharTriangleH(&gNPC[i], x + offx[j], y + offy[j]); gNPC[i].flag |= 0x100;
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]); // Fallthrough
break; 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) 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 //Play death sound
PlaySoundObject(npc->destroy_voice, 1); PlaySoundObject(npc->destroy_voice, 1);
@ -436,19 +480,35 @@ void LoseNpChar(NPCHAR *npc, bool bVanish)
//Create drop //Create drop
if (npc->exp) if (npc->exp)
{ {
int v3 = Random(1, 5); int val;
char v4;
if (v3 == 1) switch (Random(1, 5))
{ {
if (npc->exp <= 6) case 1:
SetLifeObject(npc->x, npc->y, 2); // Spawn health
else if (npc->exp > 6)
SetLifeObject(npc->x, npc->y, 6); val = 6;
} else
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;
{
SetExpObjects(npc->x, npc->y, npc->exp); 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,100 +516,113 @@ void LoseNpChar(NPCHAR *npc, bool bVanish)
SetNPCFlag(npc->code_flag); SetNPCFlag(npc->code_flag);
//Create value view //Create value view
if (!(npc->bits & npc_showDamage)) if (npc->bits & npc_showDamage)
{
npc->cond = 0;
}
else
{ {
if ((npc->bits & npc_showDamage) && npc->damage_view) if ((npc->bits & npc_showDamage) && npc->damage_view)
SetValueView(&npc->x, &npc->y, npc->damage_view); SetValueView(&npc->x, &npc->y, npc->damage_view);
if (bVanish) if (bVanish)
VanishNpChar(npc); VanishNpChar(npc);
} }
else
{
npc->cond = 0;
}
} }
void HitNpCharBullet() 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))) 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++)
{ {
for (int b = 0; b < BULLET_MAX; b++) if ((gBul[b].cond & 0x80) == 0)
continue;
if (gBul[b].damage == -1)
continue;
//Check if bullet touches npc
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;
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;
if (bHit)
{ {
if (gBul[b].cond & 0x80 && gBul[b].damage != -1) //Damage NPC
if (gNPC[n].bits & npc_shootable)
{ {
//Check if bullet touches npc gNPC[n].life -= gBul[b].damage;
bool 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;
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;
if (bHit) if (gNPC[n].life < 1)
{ {
//Damage NPC gNPC[n].life = 0;
if (gNPC[n].bits & npc_shootable)
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)
{ {
gNPC[n].life -= gBul[b].damage; SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0);
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0);
if (gNPC[n].life > 0) SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0);
{ PlaySoundObject(gNPC[n].hit_voice, 1);
if (gNPC[n].shock < 14) gNPC[n].shock = 16;
{
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0);
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0);
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 11, 0);
PlaySoundObject(gNPC[n].hit_voice, 1);
gNPC[n].shock = 16;
}
if (gNPC[n].bits & npc_showDamage)
gNPC[n].damage_view -= gBul[b].damage;
}
else
{
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;
}
}
//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;
continue;
} }
--gBul[b].life; if (gNPC[n].bits & npc_showDamage)
gNPC[n].damage_view -= gBul[b].damage;
} }
} }
} 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)
{
// Strange empty case that's needed for accurate assembly
}
else if ((gBul[b].bbits & 0x10) == 0)
{
//Hit invulnerable NPC
SetCaret((gBul[b].x + gNPC[n].x) / 2, (gBul[b].y + gNPC[n].y) / 2, 2, 2);
PlaySoundObject(31, 1);
gBul[b].life = 0;
continue;
}
if (gNPC[n].cond & 8) --gBul[b].life;
LoseNpChar(&gNPC[n], true); }
} }
if (gNPC[n].cond & 8)
LoseNpChar(&gNPC[n], TRUE);
} }
} }

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "WindowsWrapper.h"
#include "NpChar.h" #include "NpChar.h"
void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y); 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 JudgeHitNpCharTriangleH(NPCHAR *npc, int x, int y);
void JudgeHitNpCharWater(NPCHAR *npc, int x, int y); void JudgeHitNpCharWater(NPCHAR *npc, int x, int y);
void HitNpCharMap(); void HitNpCharMap();
void LoseNpChar(NPCHAR *npc, bool bVanish); void LoseNpChar(NPCHAR *npc, BOOL bVanish);
void HitNpCharBullet(); void HitNpCharBullet();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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