Merge pull request #25 from GabrielRavier/improveM

Improve files starting with M
This commit is contained in:
Clownacy 2019-05-08 18:40:00 +00:00 committed by GitHub
commit 9f181c1864
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 224 additions and 228 deletions

View file

@ -44,21 +44,21 @@ const char *lpWindowName = "洞窟物語エンジン2";
const char *lpWindowName = "Cave Story Engine 2 ~ Doukutsu Monogatari Enjin 2"; const char *lpWindowName = "Cave Story Engine 2 ~ Doukutsu Monogatari Enjin 2";
#endif #endif
//A replication of MSVC's rand algorithm // A replication of MSVC's rand algorithm
static unsigned long int next = 1; static unsigned long int next = 1;
int rep_rand() int rep_rand()
{ {
next = ((next) * 214013 + 2531011); next = ((next) * 214013 + 2531011);
return ((next) >> 16) & 0x7FFF; return ((next) >> 16) & 0x7FFF;
} }
void rep_srand(unsigned int seed) void rep_srand(unsigned int seed)
{ {
next = seed; next = seed;
} }
//Framerate stuff // Framerate stuff
void PutFramePerSecound() void PutFramePerSecound()
{ {
if (bFps) if (bFps)
@ -82,7 +82,7 @@ int GetFramePerSecound()
current_tick = SDL_GetTicks(); current_tick = SDL_GetTicks();
++current_frame; ++current_frame;
if ( base_tick + 1000 <= current_tick ) if (base_tick + 1000 <= current_tick)
{ {
base_tick += 1000; base_tick += 1000;
frames_this_second = current_frame; frames_this_second = current_frame;
@ -94,12 +94,12 @@ int GetFramePerSecound()
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
//Get executable's path // Get executable's path
strcpy(gModulePath, SDL_GetBasePath()); strcpy(gModulePath, SDL_GetBasePath());
if (gModulePath[strlen(gModulePath) - 1] == '/' || gModulePath[strlen(gModulePath) - 1] == '\\') if (gModulePath[strlen(gModulePath) - 1] == '/' || gModulePath[strlen(gModulePath) - 1] == '\\')
gModulePath[strlen(gModulePath) - 1] = '\0'; //String cannot end in slash or stuff will probably break (original does this through a windows.h provided function) gModulePath[strlen(gModulePath) - 1] = '\0'; // String cannot end in slash or stuff will probably break (original does this through a windows.h provided function)
//Get path of the data folder // Get path of the data folder
strcpy(gDataPath, gModulePath); strcpy(gDataPath, gModulePath);
strcat(gDataPath, "/data"); strcat(gDataPath, "/data");
@ -109,17 +109,17 @@ int main(int argc, char *argv[])
SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL, "102"); SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL, "102");
#endif #endif
//Initialize SDL // Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) >= 0) if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) >= 0)
{ {
//Load configuration // Load configuration
CONFIG config; CONFIG config;
if (!LoadConfigData(&config)) if (!LoadConfigData(&config))
DefaultConfigData(&config); DefaultConfigData(&config);
//Apply keybinds // Apply keybinds
//Swap X and Z buttons // Swap X and Z buttons
if (config.attack_button_mode) if (config.attack_button_mode)
{ {
if (config.attack_button_mode == 1) if (config.attack_button_mode == 1)
@ -134,7 +134,7 @@ int main(int argc, char *argv[])
gKeyShot = KEY_X; gKeyShot = KEY_X;
} }
//Swap Okay and Cancel buttons // Swap Okay and Cancel buttons
if (config.ok_button_mode) if (config.ok_button_mode)
{ {
if (config.ok_button_mode == 1) if (config.ok_button_mode == 1)
@ -149,14 +149,14 @@ int main(int argc, char *argv[])
gKeyCancel = gKeyShot; gKeyCancel = gKeyShot;
} }
//Swap left and right weapon switch keys // Swap left and right weapon switch keys
if (CheckFileExists("s_reverse")) if (CheckFileExists("s_reverse"))
{ {
gKeyArms = KEY_ARMSREV; gKeyArms = KEY_ARMSREV;
gKeyArmsRev = KEY_ARMS; gKeyArmsRev = KEY_ARMS;
} }
//Alternate movement keys // Alternate movement keys
if (config.move_button_mode) if (config.move_button_mode)
{ {
if (config.move_button_mode == 1) if (config.move_button_mode == 1)
@ -175,7 +175,7 @@ int main(int argc, char *argv[])
gKeyDown = KEY_DOWN; gKeyDown = KEY_DOWN;
} }
//Set gamepad inputs // Set gamepad inputs
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
switch (config.joystick_button[i]) switch (config.joystick_button[i])
@ -211,7 +211,7 @@ int main(int argc, char *argv[])
RECT unused_rect = {0, 0, 320, 240}; RECT unused_rect = {0, 0, 320, 240};
//Load cursor // Load cursor
size_t size; size_t size;
const unsigned char *data = FindResource("CURSOR_NORMAL", "CURSOR", &size); const unsigned char *data = FindResource("CURSOR_NORMAL", "CURSOR", &size);
@ -236,7 +236,7 @@ int main(int argc, char *argv[])
printf("Failed to load cursor\n"); printf("Failed to load cursor\n");
} }
//Get window dimensions and colour depth // Get window dimensions and colour depth
int windowWidth; int windowWidth;
int windowHeight; int windowHeight;
int colourDepth; int colourDepth;
@ -245,7 +245,7 @@ int main(int argc, char *argv[])
{ {
case 1: case 1:
case 2: case 2:
//Set window dimensions // Set window dimensions
if (config.display_mode == 1) if (config.display_mode == 1)
{ {
windowWidth = WINDOW_WIDTH; windowWidth = WINDOW_WIDTH;
@ -257,7 +257,7 @@ int main(int argc, char *argv[])
windowHeight = WINDOW_HEIGHT * 2; windowHeight = WINDOW_HEIGHT * 2;
} }
//Create window // Create window
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0); gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0);
if (gWindow) if (gWindow)
@ -274,16 +274,16 @@ int main(int argc, char *argv[])
case 0: case 0:
case 3: case 3:
case 4: case 4:
//Set window dimensions // Set window dimensions
windowWidth = WINDOW_WIDTH * 2; windowWidth = WINDOW_WIDTH * 2;
windowHeight = WINDOW_HEIGHT * 2; windowHeight = WINDOW_HEIGHT * 2;
//Create window // Create window
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0); gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0);
if (gWindow) if (gWindow)
{ {
//Set colour depth // Set colour depth
switch (config.display_mode) switch (config.display_mode)
{ {
case 0: case 0:
@ -306,17 +306,17 @@ int main(int argc, char *argv[])
break; break;
} }
//Create window // Create window
if (gWindow) if (gWindow)
{ {
//Check debug things // Check debug things
if (CheckFileExists("fps")) if (CheckFileExists("fps"))
bFps = true; bFps = true;
#ifndef WINDOWS #ifndef WINDOWS
//Load icon // Load icon
size_t size; size_t size;
const unsigned char *data = FindResource("ICON_MINI", "ICON", &size); const unsigned char *data = FindResource("ICON_MINI", "ICON", &size);
@ -338,38 +338,38 @@ int main(int argc, char *argv[])
} }
#endif #endif
//Set rects // Set rects
RECT loading_rect = {0, 0, 64, 8}; RECT loading_rect = {0, 0, 64, 8};
RECT clip_rect = {0, 0, windowWidth, windowHeight}; RECT clip_rect = {0, 0, windowWidth, windowHeight};
//Load the "LOADING" text // Load the "LOADING" text
MakeSurface_File("Loading", SURFACE_ID_LOADING); MakeSurface_File("Loading", SURFACE_ID_LOADING);
//Draw loading screen // Draw loading screen
CortBox(&clip_rect, 0x000000); CortBox(&clip_rect, 0x000000);
PutBitmap3(&clip_rect, (WINDOW_WIDTH - 64) / 2, (WINDOW_HEIGHT - 8) / 2, &loading_rect, SURFACE_ID_LOADING); PutBitmap3(&clip_rect, (WINDOW_WIDTH - 64) / 2, (WINDOW_HEIGHT - 8) / 2, &loading_rect, SURFACE_ID_LOADING);
//Draw to screen // Draw to screen
if (Flip_SystemTask()) if (Flip_SystemTask())
{ {
//Initialize sound // Initialize sound
InitDirectSound(); InitDirectSound();
//Initialize joystick // Initialize joystick
if (config.bJoystick && InitDirectInput()) if (config.bJoystick && InitDirectInput())
{ {
ResetJoystickStatus(); ResetJoystickStatus();
gbUseJoystick = true; gbUseJoystick = true;
} }
//Initialize stuff // Initialize stuff
InitTextObject(config.font_name); InitTextObject(config.font_name);
InitTriangleTable(); InitTriangleTable();
//Run game code // Run game code
Game(); Game();
//End stuff // End stuff
EndDirectSound(); EndDirectSound();
EndTextObject(); EndTextObject();
EndDirectDraw(); EndDirectDraw();
@ -417,10 +417,10 @@ void JoystickProc()
if (GetJoystickStatus(&status)) if (GetJoystickStatus(&status))
{ {
//Clear held buttons // Clear held buttons
gKey &= (KEY_ESCAPE | KEY_F2 | KEY_F1); gKey &= (KEY_ESCAPE | KEY_F2 | KEY_F1);
//Set movement buttons // Set movement buttons
if (status.bLeft) if (status.bLeft)
gKey |= gKeyLeft; gKey |= gKeyLeft;
if (status.bRight) if (status.bRight)
@ -430,7 +430,7 @@ void JoystickProc()
if (status.bDown) if (status.bDown)
gKey |= gKeyDown; gKey |= gKeyDown;
//Set held buttons // Set held buttons
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
if (status.bButton[i]) if (status.bButton[i])
@ -448,7 +448,7 @@ void JoystickProc()
bool SystemTask() bool SystemTask()
{ {
//Handle window events // Handle window events
bool focusGained = true; bool focusGained = true;
while (SDL_PollEvent(NULL) || !focusGained) while (SDL_PollEvent(NULL) || !focusGained)
@ -487,12 +487,10 @@ bool SystemTask()
case SDL_KEYDOWN: case SDL_KEYDOWN:
case SDL_KEYUP: case SDL_KEYUP:
#ifdef FIX_BUGS #ifdef FIX_BUGS
//BUG FIX: Pixel relied on key codes for input, but these differ based on keyboard layout. // BUG FIX: Pixel relied on key codes for input, but these differ based on keyboard layout.
//This would break the alternate movement keys on typical English keyboards, since the '=' key // This would break the alternate movement keys on typical English keyboards, since the '=' key is in a completely different place to where it is on a Japanese keyboard.
//is in a completely different place to where it is on a Japanese keyboard. // To solve this, we use scan codes instead, which are based on the physical location of keys, rather than their meaning.
//To solve this, we use scancodes instead, which are based on the physical location of keys,
//rather than their meaning.
switch (event.key.keysym.scancode) switch (event.key.keysym.scancode)
{ {
case SDL_SCANCODE_ESCAPE: case SDL_SCANCODE_ESCAPE:
@ -561,7 +559,7 @@ bool SystemTask()
break; break;
} }
break; break;
#else #else
switch (event.key.keysym.sym) switch (event.key.keysym.sym)
{ {
case SDLK_ESCAPE: case SDLK_ESCAPE:
@ -627,11 +625,11 @@ bool SystemTask()
break; break;
} }
break; break;
#endif #endif
} }
} }
//Run joystick code // Run joystick code
if (gbUseJoystick) if (gbUseJoystick)
JoystickProc(); JoystickProc();

View file

@ -29,16 +29,16 @@ BOOL LoadMapData2(const char *path_map)
{ {
unsigned char dum; unsigned char dum;
//Get path // Get path
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s", gDataPath, path_map); sprintf(path, "%s/%s", gDataPath, path_map);
//Open file // Open file
FILE *fp = fopen(path, "rb"); FILE *fp = fopen(path, "rb");
if (fp == NULL) if (fp == NULL)
return FALSE; return FALSE;
//Make sure file begins with "PXM" // Make sure file begins with "PXM"
char check[3]; char check[3];
fread(check, 1, 3, fp); fread(check, 1, 3, fp);
@ -50,10 +50,9 @@ BOOL LoadMapData2(const char *path_map)
else else
{ {
fread(&dum, 1, 1, fp); fread(&dum, 1, 1, fp);
//Get width and height // Get width and height
#ifdef NONPORTABLE #ifdef NONPORTABLE
// This fails on big-endian hardware, and platforms // This fails on big-endian hardware, and platforms where short is not two bytes long.
// where short is not two bytes long.
fread(&gMap.width, 2, 1, fp); fread(&gMap.width, 2, 1, fp);
fread(&gMap.length, 2, 1, fp); fread(&gMap.length, 2, 1, fp);
#else #else
@ -68,7 +67,7 @@ BOOL LoadMapData2(const char *path_map)
} }
else else
{ {
//Read tiledata // Read tile data
fread(gMap.data, 1, gMap.length * gMap.width, fp); fread(gMap.data, 1, gMap.length * gMap.width, fp);
fclose(fp); fclose(fp);
return TRUE; return TRUE;
@ -80,7 +79,7 @@ BOOL LoadMapData2(const char *path_map)
BOOL LoadAttributeData(const char *path_atrb) BOOL LoadAttributeData(const char *path_atrb)
{ {
//Open file // Open file
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s", gDataPath, path_atrb); sprintf(path, "%s/%s", gDataPath, path_atrb);
@ -88,7 +87,7 @@ BOOL LoadAttributeData(const char *path_atrb)
if (fp == NULL) if (fp == NULL)
return FALSE; return FALSE;
//Read data // Read data
fread(gMap.atrb, 1, 0x100, fp); fread(gMap.atrb, 1, 0x100, fp);
fclose(fp); fclose(fp);
return TRUE; return TRUE;
@ -158,7 +157,7 @@ void PutStage_Back(int fx, int fy)
RECT rect; RECT rect;
int num_x; int num_x;
//Get range to draw // Get range to draw
num_x = ((WINDOW_WIDTH + 0xF) / 0x10) + 1; num_x = ((WINDOW_WIDTH + 0xF) / 0x10) + 1;
num_y = ((WINDOW_HEIGHT + 0xF) / 0x10) + 1; num_y = ((WINDOW_HEIGHT + 0xF) / 0x10) + 1;
put_x = (fx / 0x200 + 8) / 0x10; put_x = (fx / 0x200 + 8) / 0x10;
@ -168,14 +167,14 @@ void PutStage_Back(int fx, int fy)
{ {
for (i = put_x; i < put_x + num_x; i++) for (i = put_x; i < put_x + num_x; i++)
{ {
//Get attribute // Get attribute
offset = i + j * gMap.width; offset = i + j * gMap.width;
atrb = GetAttribute(i, j); atrb = GetAttribute(i, j);
if (atrb >= 0x20) if (atrb >= 0x20)
continue; continue;
//Draw tile // Draw tile
rect.left = 16 * (gMap.data[offset] % 0x10); rect.left = 16 * (gMap.data[offset] % 0x10);
rect.top = 16 * (gMap.data[offset] / 0x10); rect.top = 16 * (gMap.data[offset] / 0x10);
rect.right = rect.left + 16; rect.right = rect.left + 16;
@ -199,7 +198,7 @@ void PutStage_Front(int fx, int fy)
RECT rect; RECT rect;
int num_x; int num_x;
//Get range to draw // Get range to draw
num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1; num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1;
num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1; num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1;
put_x = (fx / 0x200 + 8) / 16; put_x = (fx / 0x200 + 8) / 16;
@ -209,14 +208,14 @@ void PutStage_Front(int fx, int fy)
{ {
for (i = put_x; i < put_x + num_x; i++) for (i = put_x; i < put_x + num_x; i++)
{ {
//Get attribute // Get attribute
offset = i + j * gMap.width; offset = i + j * gMap.width;
atrb = GetAttribute(i, j); atrb = GetAttribute(i, j);
if (atrb < 0x40 || atrb >= 0x80) if (atrb < 0x40 || atrb >= 0x80)
continue; continue;
//Draw tile // Draw tile
rect.left = 16 * (gMap.data[offset] % 0x10); rect.left = 16 * (gMap.data[offset] % 0x10);
rect.top = 16 * (gMap.data[offset] / 0x10); rect.top = 16 * (gMap.data[offset] / 0x10);
rect.right = rect.left + 16; rect.right = rect.left + 16;
@ -242,11 +241,11 @@ void PutMapDataVector(int fx, int fy)
RECT rect; RECT rect;
int num_x; int num_x;
//Animate the wind // Animate the wind
static unsigned char count = 0; static unsigned char count = 0;
count += 2; count += 2;
//Get range to draw // Get range to draw
num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1; num_x = ((WINDOW_WIDTH + 0xF) >> 4) + 1;
num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1; num_y = ((WINDOW_HEIGHT + 0xF) >> 4) + 1;
put_x = (fx / 0x200 + 8) / 16; put_x = (fx / 0x200 + 8) / 16;
@ -256,7 +255,7 @@ void PutMapDataVector(int fx, int fy)
{ {
for (i = put_x; i < put_x + num_x; i++) for (i = put_x; i < put_x + num_x; i++)
{ {
//Get attribute // Get attribute
offset = i + j * gMap.width; offset = i + j * gMap.width;
atrb = GetAttribute(i, j); atrb = GetAttribute(i, j);

View file

@ -14,9 +14,9 @@ void ReadyMapName(const char *str)
{ {
int a; int a;
//Handle "Studio Pixel presents" text in the intro // Handle "Studio Pixel presents" text in the intro, using an obfuscated string
unsigned char presentText[24] = { unsigned char presentText[24] = {
#ifdef JAPANESE #ifdef JAPANESE
// "ŠJ”­ŽºPixel presents" // "ŠJ”­ŽºPixel presents"
0x8A - 1, // ŠJ 0x8A - 1, // ŠJ
0x4A - 1, 0x4A - 1,
@ -38,7 +38,7 @@ void ReadyMapName(const char *str)
'n' - 1, 'n' - 1,
't' - 1, 't' - 1,
's' - 1, 's' - 1,
#else #else
// " Studio Pixel presents" // " Studio Pixel presents"
' ' - 1, ' ' - 1,
' ' - 1, ' ' - 1,
@ -63,11 +63,11 @@ void ReadyMapName(const char *str)
'n' - 1, 'n' - 1,
't' - 1, 't' - 1,
's' - 1, 's' - 1,
#endif #endif
0xFF 0xFF
}; };
//Reset map name flags // Reset map name flags
gMapName.flag = 0; gMapName.flag = 0;
gMapName.wait = 0; gMapName.wait = 0;
@ -79,12 +79,11 @@ void ReadyMapName(const char *str)
str = (char*)presentText; str = (char*)presentText;
} }
//Copy map's name to the MapName // Copy map's name to the global map name
strcpy(gMapName.name, str); strcpy(gMapName.name, str);
//Draw the text to the surface // Draw the text to the surface
a = (int)strlen(gMapName.name); a = (int)strlen(gMapName.name);
CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
PutText2((160 - 6 * a) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); PutText2((160 - 6 * a) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
PutText2((160 - 6 * a) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); PutText2((160 - 6 * a) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
@ -97,7 +96,7 @@ void PutMapName(BOOL bMini)
if (bMini) if (bMini)
{ {
//Map system // Map system
RECT rcBack; RECT rcBack;
rcBack.left = 0; rcBack.left = 0;
rcBack.right = WINDOW_WIDTH; rcBack.right = WINDOW_WIDTH;
@ -109,7 +108,7 @@ void PutMapName(BOOL bMini)
} }
else if (gMapName.flag) else if (gMapName.flag)
{ {
//MNA // MNA
PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, (WINDOW_HEIGHT - 80) / 2, &rc, SURFACE_ID_ROOM_NAME); PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, (WINDOW_HEIGHT - 80) / 2, &rc, SURFACE_ID_ROOM_NAME);
if (++gMapName.wait > 160) if (++gMapName.wait > 160)
gMapName.flag = 0; gMapName.flag = 0;

View file

@ -112,7 +112,7 @@ void AnimationMyChar(bool bKey)
if (gMC.ani_no > 4 || gMC.ani_no < 1) if (gMC.ani_no > 4 || gMC.ani_no < 1)
gMC.ani_no = 1; gMC.ani_no = 1;
} }
else if ( gKey & gKeyUp && bKey ) else if (gKey & gKeyUp && bKey)
{ {
if (gMC.cond & 4) if (gMC.cond & 4)
PlaySoundObject(24, 1); PlaySoundObject(24, 1);
@ -137,7 +137,7 @@ void AnimationMyChar(bool bKey)
{ {
gMC.ani_no = 10; gMC.ani_no = 10;
} }
else if ( gMC.ym <= 0 ) else if (gMC.ym <= 0)
{ {
gMC.ani_no = 3; gMC.ani_no = 3;
} }
@ -165,7 +165,7 @@ void PutMyChar(int fx, int fy)
{ {
if ((gMC.cond & 0x80) && !(gMC.cond & 2)) if ((gMC.cond & 0x80) && !(gMC.cond & 2))
{ {
//Draw weapon // Draw weapon
gMC.rect_arms.left = 24 * (gArmsData[gSelectedArms].code % 13); gMC.rect_arms.left = 24 * (gArmsData[gSelectedArms].code % 13);
gMC.rect_arms.right = gMC.rect_arms.left + 24; gMC.rect_arms.right = gMC.rect_arms.left + 24;
gMC.rect_arms.top = 96 * (gArmsData[gSelectedArms].code / 13); gMC.rect_arms.top = 96 * (gArmsData[gSelectedArms].code / 13);
@ -215,7 +215,7 @@ void PutMyChar(int fx, int fy)
if (!((gMC.shock >> 1) & 1)) if (!((gMC.shock >> 1) & 1))
{ {
//Draw player // Draw player
RECT rect = gMC.rect; RECT rect = gMC.rect;
if (gMC.equip & 0x40) if (gMC.equip & 0x40)
{ {
@ -225,7 +225,7 @@ void PutMyChar(int fx, int fy)
PutBitmap3(&grcGame, (gMC.x - gMC.view.left) / 0x200 - fx / 0x200, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200, &rect, SURFACE_ID_MY_CHAR); PutBitmap3(&grcGame, (gMC.x - gMC.view.left) / 0x200 - fx / 0x200, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200, &rect, SURFACE_ID_MY_CHAR);
//Draw airtank // Draw air tank
RECT rcBubble[2] = { RECT rcBubble[2] = {
{56, 96, 80, 120}, {56, 96, 80, 120},
{80, 96, 104, 120}, {80, 96, 104, 120},
@ -244,7 +244,7 @@ void ActMyChar_Normal(bool bKey)
{ {
if (!(gMC.cond & 2)) if (!(gMC.cond & 2))
{ {
//Get speeds and accelerations // Get speeds and accelerations
int max_dash; int max_dash;
int gravity1; int gravity1;
int gravity2; int gravity2;
@ -274,17 +274,17 @@ void ActMyChar_Normal(bool bKey)
resist = 0x33; resist = 0x33;
} }
//Don't create "?" effect // Don't create "?" effect
gMC.ques = 0; gMC.ques = 0;
//If can't control player, stop boosting // If can't control player, stop boosting
if (!bKey) if (!bKey)
gMC.boost_sw = 0; gMC.boost_sw = 0;
//Movement on the ground // Movement on the ground
if (gMC.flag & 8 || gMC.flag & 0x10 || gMC.flag & 0x20) if (gMC.flag & 8 || gMC.flag & 0x10 || gMC.flag & 0x20)
{ {
//Stop boosting and refuel // Stop boosting and refuel
gMC.boost_sw = 0; gMC.boost_sw = 0;
if (gMC.equip & 1) if (gMC.equip & 1)
@ -300,7 +300,7 @@ void ActMyChar_Normal(bool bKey)
gMC.boost_cnt = 0; gMC.boost_cnt = 0;
} }
//Move in direction held // Move in direction held
if (bKey) if (bKey)
{ {
if (gKeyTrg != gKeyDown || gKey != gKeyDown || (gMC.cond & 1) || g_GameFlags & 4) if (gKeyTrg != gKeyDown || gKey != gKeyDown || (gMC.cond & 1) || g_GameFlags & 4)
@ -325,7 +325,7 @@ void ActMyChar_Normal(bool bKey)
} }
} }
//Friction // Friction
if (!(gMC.cond & 0x20)) if (!(gMC.cond & 0x20))
{ {
if (gMC.xm < 0) if (gMC.xm < 0)
@ -346,12 +346,12 @@ void ActMyChar_Normal(bool bKey)
} }
else else
{ {
//Start boosting // Start boosting
if (bKey) if (bKey)
{ {
if (gMC.equip & 0x21 && gKeyTrg & gKeyJump && gMC.boost_cnt) if (gMC.equip & 0x21 && gKeyTrg & gKeyJump && gMC.boost_cnt)
{ {
//Booster 0.8 // Booster 0.8
if (gMC.equip & 1) if (gMC.equip & 1)
{ {
gMC.boost_sw = 1; gMC.boost_sw = 1;
@ -359,7 +359,7 @@ void ActMyChar_Normal(bool bKey)
gMC.ym /= 2; gMC.ym /= 2;
} }
//Booster 2.0 // Booster 2.0
if (gMC.equip & 0x20) if (gMC.equip & 0x20)
{ {
if (gKey & gKeyUp) if (gKey & gKeyUp)
@ -368,19 +368,19 @@ void ActMyChar_Normal(bool bKey)
gMC.xm = 0; gMC.xm = 0;
gMC.ym = -0x5FF; gMC.ym = -0x5FF;
} }
else if ( gKey & gKeyLeft ) else if (gKey & gKeyLeft)
{ {
gMC.boost_sw = 1; gMC.boost_sw = 1;
gMC.ym = 0; gMC.ym = 0;
gMC.xm = -0x5FF; gMC.xm = -0x5FF;
} }
else if ( gKey & gKeyRight ) else if (gKey & gKeyRight)
{ {
gMC.boost_sw = 1; gMC.boost_sw = 1;
gMC.ym = 0; gMC.ym = 0;
gMC.xm = 0x5FF; gMC.xm = 0x5FF;
} }
else if ( gKey & gKeyDown ) else if (gKey & gKeyDown)
{ {
gMC.boost_sw = 3; gMC.boost_sw = 3;
gMC.xm = 0; gMC.xm = 0;
@ -395,19 +395,19 @@ void ActMyChar_Normal(bool bKey)
} }
} }
//Move left and right // Move left and right
if ( gKey & gKeyLeft && gMC.xm > -max_dash ) if (gKey & gKeyLeft && gMC.xm > -max_dash)
gMC.xm -= dash2; gMC.xm -= dash2;
if ( gKey & gKeyRight && gMC.xm < max_dash ) if (gKey & gKeyRight && gMC.xm < max_dash)
gMC.xm += dash2; gMC.xm += dash2;
if ( gKey & gKeyLeft ) if (gKey & gKeyLeft)
gMC.direct = 0; gMC.direct = 0;
if ( gKey & gKeyRight ) if (gKey & gKeyRight)
gMC.direct = 2; gMC.direct = 2;
} }
//Slow down when stopped boosting (Booster 2.0) // Slow down when stopped boosting (Booster 2.0)
if (gMC.equip & 0x20 && gMC.boost_sw && (!(gKey & gKeyJump) || !gMC.boost_cnt)) if (gMC.equip & 0x20 && gMC.boost_sw && (!(gKey & gKeyJump) || !gMC.boost_cnt))
{ {
if (gMC.boost_sw == 1) if (gMC.boost_sw == 1)
@ -416,15 +416,15 @@ void ActMyChar_Normal(bool bKey)
gMC.ym /= 2; gMC.ym /= 2;
} }
//Stop boosting // Stop boosting
if (!gMC.boost_cnt || !(gKey & gKeyJump)) if (!gMC.boost_cnt || !(gKey & gKeyJump))
gMC.boost_sw = 0; gMC.boost_sw = 0;
} }
//Jumping // Jumping
if ( bKey ) if (bKey)
{ {
//Look up and down // Look up and down
gMC.up = (gKey & gKeyUp) != 0; gMC.up = (gKey & gKeyUp) != 0;
gMC.down = gKey & gKeyDown && !(gMC.flag & 8); gMC.down = gKey & gKeyDown && !(gMC.flag & 8);
@ -437,15 +437,15 @@ void ActMyChar_Normal(bool bKey)
} }
} }
//Stop interacting when moved // Stop interacting when moved
if (bKey && (gKeyShot | gKeyJump | gKeyUp | gKeyRight | gKeyLeft) & gKey) if (bKey && (gKeyShot | gKeyJump | gKeyUp | gKeyRight | gKeyLeft) & gKey)
gMC.cond &= ~1; gMC.cond &= ~1;
//Booster losing fuel // Booster losing fuel
if (gMC.boost_sw && gMC.boost_cnt) if (gMC.boost_sw && gMC.boost_cnt)
--gMC.boost_cnt; --gMC.boost_cnt;
//Wind / current forces // Wind / current forces
if (gMC.flag & 0x1000) if (gMC.flag & 0x1000)
gMC.xm -= 0x88; gMC.xm -= 0x88;
if (gMC.flag & 0x2000) if (gMC.flag & 0x2000)
@ -455,22 +455,22 @@ void ActMyChar_Normal(bool bKey)
if (gMC.flag & 0x8000) if (gMC.flag & 0x8000)
gMC.ym += 0x55; gMC.ym += 0x55;
//Booster 2.0 forces and effects // Booster 2.0 forces and effects
if (gMC.equip & 0x20 && gMC.boost_sw) if (gMC.equip & 0x20 && gMC.boost_sw)
{ {
if (gMC.boost_sw == 1) if (gMC.boost_sw == 1)
{ {
//Go up when going into a wall // Go up when going into a wall
if (gMC.flag & 5) if (gMC.flag & 5)
gMC.ym = -0x100; gMC.ym = -0x100;
//Move in direction facing // Move in direction facing
if (!gMC.direct) if (!gMC.direct)
gMC.xm -= 0x20; gMC.xm -= 0x20;
if (gMC.direct == 2) if (gMC.direct == 2)
gMC.xm += 0x20; gMC.xm += 0x20;
//Boost particles (and sound) // Boost particles (and sound)
if (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1) if (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1)
{ {
if (!gMC.direct) if (!gMC.direct)
@ -483,10 +483,10 @@ void ActMyChar_Normal(bool bKey)
} }
else if (gMC.boost_sw == 2) else if (gMC.boost_sw == 2)
{ {
//Move upwards // Move upwards
gMC.ym -= 0x20; gMC.ym -= 0x20;
//Boost particles (and sound) // Boost particles (and sound)
if (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1) if (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1)
{ {
SetCaret(gMC.x, gMC.y + 0xC00, 7, 3); SetCaret(gMC.x, gMC.y + 0xC00, 7, 3);
@ -495,20 +495,20 @@ void ActMyChar_Normal(bool bKey)
} }
else if (gMC.boost_sw == 3 && (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1)) else if (gMC.boost_sw == 3 && (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1))
{ {
//Boost particles (and sound) // Boost particles (and sound)
SetCaret(gMC.x, gMC.y - 0xC00, 7, 1); SetCaret(gMC.x, gMC.y - 0xC00, 7, 1);
PlaySoundObject(113, 1); PlaySoundObject(113, 1);
} }
} }
//Upwards wind/current // Upwards wind/current
else if (gMC.flag & 0x2000) else if (gMC.flag & 0x2000)
{ {
gMC.ym += gravity1; gMC.ym += gravity1;
} }
//Booster 0.8 // Booster 0.8
else if (gMC.equip & 1 && gMC.boost_sw && gMC.ym > -0x400) else if (gMC.equip & 1 && gMC.boost_sw && gMC.ym > -0x400)
{ {
//Upwards force // Upwards force
gMC.ym -= 0x20; gMC.ym -= 0x20;
if (!(gMC.boost_cnt % 3)) if (!(gMC.boost_cnt % 3))
@ -517,22 +517,22 @@ void ActMyChar_Normal(bool bKey)
PlaySoundObject(113, 1); PlaySoundObject(113, 1);
} }
//Bounce off of ceiling // Bounce off of ceiling
if (gMC.flag & 2) if (gMC.flag & 2)
gMC.ym = 0x200; gMC.ym = 0x200;
} }
//Gravity while jump is held // Gravity while jump is held
else if (gMC.ym < 0 && bKey && gKey & gKeyJump) else if (gMC.ym < 0 && bKey && gKey & gKeyJump)
{ {
gMC.ym += gravity2; gMC.ym += gravity2;
} }
//Normal gravity // Normal gravity
else else
{ {
gMC.ym += gravity1; gMC.ym += gravity1;
} }
//Keep player on slopes // Keep player on slopes
if (bKey && !(gKeyTrg & gKeyJump)) if (bKey && !(gKeyTrg & gKeyJump))
{ {
if (gMC.flag & 0x10 && gMC.xm < 0) if (gMC.flag & 0x10 && gMC.xm < 0)
@ -547,7 +547,7 @@ void ActMyChar_Normal(bool bKey)
gMC.ym = 0x400; gMC.ym = 0x400;
} }
//Limit speed // Limit speed
if (!(gMC.flag & 0x100) || gMC.flag & 0xF000) if (!(gMC.flag & 0x100) || gMC.flag & 0xF000)
{ {
if (gMC.xm < -0x5FF) if (gMC.xm < -0x5FF)
@ -571,7 +571,7 @@ void ActMyChar_Normal(bool bKey)
gMC.ym = 0x2FF; gMC.ym = 0x2FF;
} }
//Water splashing // Water splashing
if (!gMC.sprash && gMC.flag & 0x100) if (!gMC.sprash && gMC.flag & 0x100)
{ {
int dir; int dir;
@ -604,11 +604,11 @@ void ActMyChar_Normal(bool bKey)
if (!(gMC.flag & 0x100)) if (!(gMC.flag & 0x100))
gMC.sprash = 0; gMC.sprash = 0;
//Spike damage // Spike damage
if (gMC.flag & 0x400) if (gMC.flag & 0x400)
DamageMyChar(10); DamageMyChar(10);
//Camera // Camera
if (gMC.direct) if (gMC.direct)
{ {
gMC.index_x += 0x200; gMC.index_x += 0x200;
@ -644,7 +644,7 @@ void ActMyChar_Normal(bool bKey)
gMC.tgt_x = gMC.x + gMC.index_x; gMC.tgt_x = gMC.x + gMC.index_x;
gMC.tgt_y = gMC.y + gMC.index_y; gMC.tgt_y = gMC.y + gMC.index_y;
//Change position // Change position
if (gMC.xm > resist || gMC.xm < -resist) if (gMC.xm > resist || gMC.xm < -resist)
gMC.x += gMC.xm; gMC.x += gMC.xm;
gMC.y += gMC.ym; gMC.y += gMC.ym;
@ -791,12 +791,12 @@ void AirProcess()
{ {
if (GetNPCFlag(4000)) if (GetNPCFlag(4000))
{ {
//Core cutscene // Core cutscene
StartTextScript(1100); StartTextScript(1100);
} }
else else
{ {
//Drown // Drown
StartTextScript(41); StartTextScript(41);
if (gMC.direct) if (gMC.direct)
@ -813,7 +813,7 @@ void AirProcess()
gMC.air = 1000; gMC.air = 1000;
} }
if ( gMC.flag & 0x100 ) if (gMC.flag & 0x100)
{ {
gMC.air_get = 60; gMC.air_get = 60;
} }
@ -889,7 +889,7 @@ void MoveMyChar(int x, int y)
void ZeroMyCharXMove() void ZeroMyCharXMove()
{ {
gMC.xm = 0; gMC.xm = 0;
} }
int GetUnitMyChar() int GetUnitMyChar()

View file

@ -35,79 +35,79 @@ 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 < (2 * (2 * y + 1) - 1) << 11
&& gMC.y + gMC.hit.bottom > (2 * (2 * y - 1) + 1) << 11 && gMC.y + gMC.hit.bottom > (2 * (2 * y - 1) + 1) << 11
&& gMC.x - gMC.hit.left < (2 * x + 1) << 12 && gMC.x - gMC.hit.left < (2 * x + 1) << 12
&& gMC.x - gMC.hit.left > x << 13) && gMC.x - gMC.hit.left > x << 13)
{ {
//Clip // Clip
gMC.x = ((2 * x + 1) << 12) + gMC.hit.left; gMC.x = ((2 * x + 1) << 12) + gMC.hit.left;
//Halt momentum // Halt momentum
if (gMC.xm < -0x180) if (gMC.xm < -0x180)
gMC.xm = -0x180; gMC.xm = -0x180;
if (!(gKey & gKeyLeft) && gMC.xm < 0) if (!(gKey & gKeyLeft) && gMC.xm < 0)
gMC.xm = 0; gMC.xm = 0;
//Set that a left wall was hit // Set that a left wall was hit
hit |= 1; hit |= 1;
} }
//Right wall // Right wall
if (gMC.y - gMC.hit.top < (2 * (2 * y + 1) - 1) << 11 if (gMC.y - gMC.hit.top < (2 * (2 * y + 1) - 1) << 11
&& gMC.y + gMC.hit.bottom > (2 * (2 * y - 1) + 1) << 11 && gMC.y + gMC.hit.bottom > (2 * (2 * y - 1) + 1) << 11
&& gMC.x + gMC.hit.right > (2 * x - 1) << 12 && gMC.x + gMC.hit.right > (2 * x - 1) << 12
&& gMC.x + gMC.hit.left < x << 13) && gMC.x + gMC.hit.left < x << 13)
{ {
//Clip // Clip
gMC.x = ((2 * x - 1) << 12) - gMC.hit.right; gMC.x = ((2 * x - 1) << 12) - gMC.hit.right;
//Halt momentum // Halt momentum
if (gMC.xm > 0x180) if (gMC.xm > 0x180)
gMC.xm = 0x180; gMC.xm = 0x180;
if (!(gKey & gKeyRight) && gMC.xm > 0) if (!(gKey & gKeyRight) && gMC.xm > 0)
gMC.xm = 0; gMC.xm = 0;
//Set that a right wall was hit // Set that a right wall was hit
hit |= 4; hit |= 4;
} }
//Ceiling // Ceiling
if (gMC.x - gMC.hit.right < ((2 * x + 1) << 12) - 0x600 if (gMC.x - gMC.hit.right < ((2 * x + 1) << 12) - 0x600
&& gMC.x + gMC.hit.right > ((2 * x - 1) << 12) + 0x600 && gMC.x + gMC.hit.right > ((2 * x - 1) << 12) + 0x600
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12 && gMC.y - gMC.hit.top < (2 * y + 1) << 12
&& gMC.y - gMC.hit.top > y << 13) && gMC.y - gMC.hit.top > y << 13)
{ {
//Clip // Clip
gMC.y = ((2 * y + 1) << 12) + gMC.hit.top; gMC.y = ((2 * y + 1) << 12) + gMC.hit.top;
//Halt momentum // Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200) if (!(gMC.cond & 2) && gMC.ym < -0x200)
PutlittleStar(); PutlittleStar();
if (gMC.ym < 0) if (gMC.ym < 0)
gMC.ym = 0; gMC.ym = 0;
//Set that a ceiling was hit // Set that a ceiling was hit
hit |= 2; hit |= 2;
} }
//Floor // Floor
if (gMC.x - gMC.hit.right < ((2 * x + 1) << 12) - 0x600 if (gMC.x - gMC.hit.right < ((2 * x + 1) << 12) - 0x600
&& gMC.x + gMC.hit.right > ((2 * x - 1) << 12) + 0x600 && gMC.x + gMC.hit.right > ((2 * x - 1) << 12) + 0x600
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12 && gMC.y + gMC.hit.bottom > (2 * y - 1) << 12
&& gMC.y + gMC.hit.bottom < y << 13) && gMC.y + gMC.hit.bottom < y << 13)
{ {
//Clip // Clip
gMC.y = ((2 * y - 1) << 12) - gMC.hit.bottom; gMC.y = ((2 * y - 1) << 12) - gMC.hit.bottom;
//Halt momentum // Halt momentum
if (gMC.ym > 0x400) if (gMC.ym > 0x400)
PlaySoundObject(23, 1); PlaySoundObject(23, 1);
if (gMC.ym > 0) if (gMC.ym > 0)
gMC.ym = 0; gMC.ym = 0;
//Set that a floor was hit // Set that a floor was hit
hit |= 8; hit |= 8;
} }
@ -123,16 +123,16 @@ int JudgeHitMyCharTriangleA(int x, int y)
&& gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 && gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12) && gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
{ {
//Clip // Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 + gMC.hit.top; gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 + gMC.hit.top;
//Halt momentum // Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200) if (!(gMC.cond & 2) && gMC.ym < -0x200)
PutlittleStar(); PutlittleStar();
if (gMC.ym < 0) if (gMC.ym < 0)
gMC.ym = 0; gMC.ym = 0;
//Set that hit a ceiling // Set that hit a ceiling
hit |= 2; hit |= 2;
} }
@ -148,16 +148,16 @@ int JudgeHitMyCharTriangleB(int x, int y)
&& gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 && gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12) && gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
{ {
//Clip // Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 + gMC.hit.top; gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 + gMC.hit.top;
//Halt momentum // Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200) if (!(gMC.cond & 2) && gMC.ym < -0x200)
PutlittleStar(); PutlittleStar();
if (gMC.ym < 0) if (gMC.ym < 0)
gMC.ym = 0; gMC.ym = 0;
//Set that hit a ceiling // Set that hit a ceiling
hit |= 2; hit |= 2;
} }
@ -173,16 +173,16 @@ int JudgeHitMyCharTriangleC(int x, int y)
&& gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 && gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12) && gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
{ {
//Clip // Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 + gMC.hit.top; gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 + gMC.hit.top;
//Halt momentum // Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200) if (!(gMC.cond & 2) && gMC.ym < -0x200)
PutlittleStar(); PutlittleStar();
if (gMC.ym < 0) if (gMC.ym < 0)
gMC.ym = 0; gMC.ym = 0;
//Set that hit a ceiling // Set that hit a ceiling
hit |= 2; hit |= 2;
} }
@ -198,16 +198,16 @@ int JudgeHitMyCharTriangleD(int x, int y)
&& gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 && gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12) && gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
{ {
//Clip // Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 + gMC.hit.top; gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 + gMC.hit.top;
//Halt momentum // Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200) if (!(gMC.cond & 2) && gMC.ym < -0x200)
PutlittleStar(); PutlittleStar();
if (gMC.ym < 0) if (gMC.ym < 0)
gMC.ym = 0; gMC.ym = 0;
//Set that hit a ceiling // Set that hit a ceiling
hit |= 2; hit |= 2;
} }
@ -223,16 +223,16 @@ int JudgeHitMyCharTriangleE(int x, int y)
&& gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 && gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12) && gMC.y - gMC.hit.top < (2 * y + 1) << 12)
{ {
//Clip // Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 - gMC.hit.bottom; gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 - gMC.hit.bottom;
//Halt momentum // Halt momentum
if (gMC.ym > 0x400) if (gMC.ym > 0x400)
PlaySoundObject(23, 1); PlaySoundObject(23, 1);
if (gMC.ym > 0) if (gMC.ym > 0)
gMC.ym = 0; gMC.ym = 0;
//Set that hit this slope // Set that hit this slope
hit = 0x10028; hit = 0x10028;
} }
@ -248,16 +248,16 @@ int JudgeHitMyCharTriangleF(int x, int y)
&& gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 && gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12) && gMC.y - gMC.hit.top < (2 * y + 1) << 12)
{ {
//Clip // Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 - gMC.hit.bottom; gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 - gMC.hit.bottom;
//Halt momentum // Halt momentum
if (gMC.ym > 0x400) if (gMC.ym > 0x400)
PlaySoundObject(23, 1); PlaySoundObject(23, 1);
if (gMC.ym > 0) if (gMC.ym > 0)
gMC.ym = 0; gMC.ym = 0;
//Set that hit this slope // Set that hit this slope
hit = 0x20028; hit = 0x20028;
} }
@ -273,16 +273,16 @@ int JudgeHitMyCharTriangleG(int x, int y)
&& gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 && gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12) && gMC.y - gMC.hit.top < (2 * y + 1) << 12)
{ {
//Clip // Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 - gMC.hit.bottom; gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 - gMC.hit.bottom;
//Halt momentum // Halt momentum
if (gMC.ym > 0x400) if (gMC.ym > 0x400)
PlaySoundObject(23, 1); PlaySoundObject(23, 1);
if (gMC.ym > 0) if (gMC.ym > 0)
gMC.ym = 0; gMC.ym = 0;
//Set that hit this slope // Set that hit this slope
hit = 0x40018; hit = 0x40018;
} }
@ -298,16 +298,16 @@ int JudgeHitMyCharTriangleH(int x, int y)
&& gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 && gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12) && gMC.y - gMC.hit.top < (2 * y + 1) << 12)
{ {
//Clip // Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 - gMC.hit.bottom; gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 - gMC.hit.bottom;
//Halt momentum // Halt momentum
if (gMC.ym > 0x400) if (gMC.ym > 0x400)
PlaySoundObject(23, 1); PlaySoundObject(23, 1);
if (gMC.ym > 0) if (gMC.ym > 0)
gMC.ym = 0; gMC.ym = 0;
//Set that hit this slope // Set that hit this slope
hit = 0x80018; hit = 0x80018;
} }
@ -424,12 +424,12 @@ void HitMyCharMap()
switch (atrb[i]) switch (atrb[i])
{ {
//Water // Water
case 0x02: case 0x02:
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break; break;
//Block // Block
case 0x05: case 0x05:
case 0x41: case 0x41:
case 0x43: case 0x43:
@ -437,12 +437,12 @@ void HitMyCharMap()
gMC.flag |= JudgeHitMyCharBlock(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharBlock(x + offx[i], y + offy[i]);
break; break;
//Spikes // Spikes
case 0x42: case 0x42:
gMC.flag |= JudgeHitMyCharDamage(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharDamage(x + offx[i], y + offy[i]);
break; 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]);
break; break;
@ -475,7 +475,7 @@ void HitMyCharMap()
gMC.flag |= JudgeHitMyCharTriangleH(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleH(x + offx[i], y + offy[i]);
break; 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]);
break; break;
@ -485,53 +485,53 @@ void HitMyCharMap()
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break; break;
//Water spikes // Water spikes
case 0x62: case 0x62:
gMC.flag |= JudgeHitMyCharDamageW(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharDamageW(x + offx[i], y + offy[i]);
break; 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]);
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break; break;
case 0x71: case 0x71:
gMC.flag |= JudgeHitMyCharTriangleB(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleB(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;
case 0x72: case 0x72:
gMC.flag |= JudgeHitMyCharTriangleC(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleC(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;
case 0x73: case 0x73:
gMC.flag |= JudgeHitMyCharTriangleD(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleD(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;
case 0x74: case 0x74:
gMC.flag |= JudgeHitMyCharTriangleE(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleE(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;
case 0x75: case 0x75:
gMC.flag |= JudgeHitMyCharTriangleF(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleF(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;
case 0x76: case 0x76:
gMC.flag |= JudgeHitMyCharTriangleG(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleG(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;
case 0x77: case 0x77:
gMC.flag |= JudgeHitMyCharTriangleH(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleH(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;
//Wind // Wind
case 0x80: case 0x80:
gMC.flag |= JudgeHitMyCharVectLeft(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharVectLeft(x + offx[i], y + offy[i]);
break; break;
@ -548,7 +548,7 @@ void HitMyCharMap()
gMC.flag |= JudgeHitMyCharVectDown(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharVectDown(x + offx[i], y + offy[i]);
break; 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]);
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
@ -657,7 +657,7 @@ int JudgeHitMyCharNPC3(NPCHAR *npc)
int JudgeHitMyCharNPC4(NPCHAR *npc) int JudgeHitMyCharNPC4(NPCHAR *npc)
{ {
//TODO: comment this // TODO: comment this
int hit = 0; int hit = 0;
long double v1, v2; long double v1, v2;
@ -688,7 +688,7 @@ int JudgeHitMyCharNPC4(NPCHAR *npc)
{ {
if (gMC.x - gMC.hit.right < npc->x + npc->hit.back && gMC.x - gMC.hit.right > npc->x) if (gMC.x - gMC.hit.right < npc->x + npc->hit.back && gMC.x - gMC.hit.right > npc->x)
{ {
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;
@ -696,7 +696,7 @@ int JudgeHitMyCharNPC4(NPCHAR *npc)
if (gMC.x + gMC.hit.right > npc->x - npc->hit.back && gMC.hit.right + gMC.x < npc->x) if (gMC.x + gMC.hit.right > npc->x - npc->hit.back && gMC.hit.right + gMC.x < npc->x)
{ {
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;
@ -774,7 +774,7 @@ void HitMyCharNpChar()
hit = JudgeHitMyCharNPC3(&gNPC[i]); hit = JudgeHitMyCharNPC3(&gNPC[i]);
} }
//Special NPCs (pickups) // Special NPCs (pickups)
if (hit && gNPC[i].code_char == 1) if (hit && gNPC[i].code_char == 1)
{ {
PlaySoundObject(14, 1); PlaySoundObject(14, 1);
@ -796,11 +796,11 @@ void HitMyCharNpChar()
gNPC[i].cond = 0; gNPC[i].cond = 0;
} }
//Run event on contact // Run event on contact
if (!(g_GameFlags & 4) && hit && gNPC[i].bits & npc_eventTouch) if (!(g_GameFlags & 4) && hit && gNPC[i].bits & npc_eventTouch)
StartTextScript(gNPC[i].code_event); StartTextScript(gNPC[i].code_event);
//NPC damage // NPC damage
if (g_GameFlags & 2 && !(gNPC[i].bits & npc_interact)) if (g_GameFlags & 2 && !(gNPC[i].bits & npc_interact))
{ {
if (gNPC[i].bits & npc_rearTop) if (gNPC[i].bits & npc_rearTop)
@ -820,7 +820,7 @@ void HitMyCharNpChar()
} }
} }
//Interaction // Interaction
if (!(g_GameFlags & 4) && hit && gMC.cond & 1 && gNPC[i].bits & npc_interact) if (!(g_GameFlags & 4) && hit && gMC.cond & 1 && gNPC[i].bits & npc_interact)
{ {
StartTextScript(gNPC[i].code_event); StartTextScript(gNPC[i].code_event);
@ -830,7 +830,7 @@ void HitMyCharNpChar()
} }
} }
//Create question mark when NPC hasn't been interacted with // Create question mark when NPC hasn't been interacted with
if (gMC.ques) if (gMC.ques)
SetCaret(gMC.x, gMC.y, 9, 0); SetCaret(gMC.x, gMC.y, 9, 0);
} }

View file

@ -104,7 +104,7 @@ void DamageMyChar(int damage)
{ {
if (!gMC.shock) if (!gMC.shock)
{ {
//Damage player // Damage player
PlaySoundObject(16, 1); PlaySoundObject(16, 1);
gMC.cond &= ~1; gMC.cond &= ~1;
gMC.shock = 128; gMC.shock = 128;
@ -112,11 +112,11 @@ void DamageMyChar(int damage)
gMC.ym = -0x400; gMC.ym = -0x400;
gMC.life -= damage; gMC.life -= damage;
//Lose a whimsical star // Lose a whimsical star
if (gMC.equip & 0x80 && gMC.star > 0) if (gMC.equip & 0x80 && gMC.star > 0)
--gMC.star; --gMC.star;
//Lose experience // Lose experience
if (gMC.equip & 4) if (gMC.equip & 4)
gArmsData[gSelectedArms].exp -= damage; gArmsData[gSelectedArms].exp -= damage;
else else
@ -136,10 +136,10 @@ void DamageMyChar(int damage)
} }
} }
//Tell player how much damage was taken // Tell player how much damage was taken
SetValueView(&gMC.x, &gMC.y, -damage); SetValueView(&gMC.x, &gMC.y, -damage);
//Death // Death
if (gMC.life <= 0) if (gMC.life <= 0)
{ {
PlaySoundObject(17, 1); PlaySoundObject(17, 1);
@ -161,7 +161,7 @@ void ZeroArmsEnergy_All()
void AddBulletMyChar(int no, int val) void AddBulletMyChar(int no, int val)
{ {
//Missile Launcher // Missile Launcher
for (int a = 0; a < ARMS_MAX; a++) for (int a = 0; a < ARMS_MAX; a++)
{ {
if (gArmsData[a].code == 5) if (gArmsData[a].code == 5)
@ -173,7 +173,7 @@ void AddBulletMyChar(int no, int val)
} }
} }
//Super Missile Launcher // Super Missile Launcher
for (int a = 0; a < ARMS_MAX; a++) for (int a = 0; a < ARMS_MAX; a++)
{ {
if (gArmsData[a].code == 10) if (gArmsData[a].code == 10)
@ -215,7 +215,7 @@ void PutArmsEnergy(bool flash)
if (gArmsEnergyX < 16) if (gArmsEnergyX < 16)
gArmsEnergyX += 2; gArmsEnergyX += 2;
//Draw max ammo // Draw max ammo
if (gArmsData[gSelectedArms].max_num) if (gArmsData[gSelectedArms].max_num)
{ {
PutNumber4(gArmsEnergyX + 32, 16, gArmsData[gSelectedArms].num, 0); PutNumber4(gArmsEnergyX + 32, 16, gArmsData[gSelectedArms].num, 0);
@ -227,7 +227,7 @@ void PutArmsEnergy(bool flash)
PutBitmap3(&rcView, gArmsEnergyX + 48, 24, &rcNone, SURFACE_ID_TEXT_BOX); PutBitmap3(&rcView, gArmsEnergyX + 48, 24, &rcNone, SURFACE_ID_TEXT_BOX);
} }
//Draw experience and ammo // Draw experience and ammo
if (!flash || !((gMC.shock >> 1) & 1)) if (!flash || !((gMC.shock >> 1) & 1))
{ {
PutBitmap3(&rcView, gArmsEnergyX + 32, 24, &rcPer, SURFACE_ID_TEXT_BOX); PutBitmap3(&rcView, gArmsEnergyX + 32, 24, &rcPer, SURFACE_ID_TEXT_BOX);
@ -277,7 +277,7 @@ void PutActiveArmsList()
{ {
for (int a = 0; a < arms_num; a++) for (int a = 0; a < arms_num; a++)
{ {
//Get X position to draw at // Get X position to draw at
int x = 16 * (a - gSelectedArms) + gArmsEnergyX; int x = 16 * (a - gSelectedArms) + gArmsEnergyX;
if (x >= 8) if (x >= 8)
@ -295,7 +295,7 @@ void PutActiveArmsList()
if (x < 72 && x >= 24) if (x < 72 && x >= 24)
x -= 48; x -= 48;
//Draw icon // Draw icon
rect.left = 16 * gArmsData[a].code; rect.left = 16 * gArmsData[a].code;
rect.right = rect.left + 16; rect.right = rect.left + 16;
PutBitmap3(&grcGame, x, 16, &rect, SURFACE_ID_ARMS_IMAGE); PutBitmap3(&grcGame, x, 16, &rect, SURFACE_ID_ARMS_IMAGE);
@ -319,7 +319,7 @@ void PutMyLife(bool flash)
else if (++gMC.lifeBr_count > 30) else if (++gMC.lifeBr_count > 30)
--gMC.lifeBr; --gMC.lifeBr;
//Draw bar // Draw bar
rcCase.right = 64; rcCase.right = 64;
rcLife.right = 40 * gMC.life / gMC.max_life - 1; rcLife.right = 40 * gMC.life / gMC.max_life - 1;
rcBr.right = 40 * gMC.lifeBr / gMC.max_life - 1; rcBr.right = 40 * gMC.lifeBr / gMC.max_life - 1;
@ -340,11 +340,11 @@ void PutMyAir(int x, int y)
if (!(gMC.equip & 0x10) && gMC.air_get) if (!(gMC.equip & 0x10) && gMC.air_get)
{ {
//Draw how much air is left // Draw how much air is left
if (gMC.air_get % 6 <= 3) if (gMC.air_get % 6 <= 3)
PutNumber4(x + 32, y, gMC.air / 10, 0); PutNumber4(x + 32, y, gMC.air / 10, 0);
//Draw "AIR" text // Draw "AIR" text
if (gMC.air % 30 <= 10) if (gMC.air % 30 <= 10)
PutBitmap3(&grcGame, x, y, &rcAir[1], SURFACE_ID_TEXT_BOX); PutBitmap3(&grcGame, x, y, &rcAir[1], SURFACE_ID_TEXT_BOX);
else else
@ -362,7 +362,7 @@ void PutTimeCounter(int x, int y)
if (gMC.equip & 0x100) if (gMC.equip & 0x100)
{ {
//Draw clock and increase time // Draw clock and increase time
if (g_GameFlags & 2) if (g_GameFlags & 2)
{ {
if (time_count < 300000) if (time_count < 300000)
@ -378,7 +378,7 @@ void PutTimeCounter(int x, int y)
PutBitmap3(&grcGame, x, y, &rcTime[0], SURFACE_ID_TEXT_BOX); PutBitmap3(&grcGame, x, y, &rcTime[0], SURFACE_ID_TEXT_BOX);
} }
//Draw time // Draw time
PutNumber4(x, y, time_count / 3000, false); PutNumber4(x, y, time_count / 3000, false);
PutNumber4(x + 20, y, time_count / 50 % 60, true); PutNumber4(x + 20, y, time_count / 50 % 60, true);
PutNumber4(x + 32, y, time_count / 5 % 10, false); PutNumber4(x + 32, y, time_count / 5 % 10, false);
@ -394,18 +394,18 @@ bool SaveTimeCounter()
{ {
REC rec; REC rec;
//Quit if player doesn't have the Nikumaru Counter // Quit if player doesn't have the Nikumaru Counter
if (!(gMC.equip & 0x100)) if (!(gMC.equip & 0x100))
return true; return true;
//Get last time // Get last time
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/290.rec", gModulePath); sprintf(path, "%s/290.rec", gModulePath);
FILE *fp = fopen(path, "rb"); FILE *fp = fopen(path, "rb");
if (fp) if (fp)
{ {
//Read data // Read data
rec.counter[0] = File_ReadLE32(fp); rec.counter[0] = File_ReadLE32(fp);
rec.counter[1] = File_ReadLE32(fp); rec.counter[1] = File_ReadLE32(fp);
rec.counter[2] = File_ReadLE32(fp); rec.counter[2] = File_ReadLE32(fp);
@ -422,12 +422,12 @@ bool SaveTimeCounter()
p[2] -= rec.random[0]; p[2] -= rec.random[0];
p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[0] >> 1) : (rec.random[0]); p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[0] >> 1) : (rec.random[0]);
//If this is faster than our new time, quit // If this is faster than our new time, quit
if (rec.counter[0] < time_count) if (rec.counter[0] < time_count)
return true; return true;
} }
//Save new time // Save new time
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
rec.counter[i] = time_count; rec.counter[i] = time_count;
@ -457,7 +457,7 @@ bool SaveTimeCounter()
int LoadTimeCounter() int LoadTimeCounter()
{ {
//Open file // Open file
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/290.rec", gModulePath); sprintf(path, "%s/290.rec", gModulePath);
@ -467,7 +467,7 @@ int LoadTimeCounter()
REC rec; REC rec;
//Read data // Read data
rec.counter[0] = File_ReadLE32(fp); rec.counter[0] = File_ReadLE32(fp);
rec.counter[1] = File_ReadLE32(fp); rec.counter[1] = File_ReadLE32(fp);
rec.counter[2] = File_ReadLE32(fp); rec.counter[2] = File_ReadLE32(fp);
@ -478,7 +478,7 @@ int LoadTimeCounter()
rec.random[3] = fgetc(fp); rec.random[3] = fgetc(fp);
fclose(fp); fclose(fp);
//Decode from checksum // Decode from checksum
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
uint8_t *p = (uint8_t*)&rec.counter[i]; uint8_t *p = (uint8_t*)&rec.counter[i];
@ -488,7 +488,7 @@ int LoadTimeCounter()
p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i] >> 1) : (rec.random[i]); p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i] >> 1) : (rec.random[i]);
} }
//Verify checksum's result // Verify checksum's result
if (rec.counter[0] == rec.counter[1] && rec.counter[0] == rec.counter[2]) if (rec.counter[0] == rec.counter[1] && rec.counter[0] == rec.counter[2])
{ {
time_count = rec.counter[0]; time_count = rec.counter[0];