Removed all trailing spaces and added newline at EOF (when not present)

Also changed a "linux" to "Linux"

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
This commit is contained in:
Gabriel Ravier 2019-05-07 11:55:42 +02:00
parent 1f055ccfe8
commit 960fa6f456
53 changed files with 954 additions and 954 deletions

View file

@ -119,7 +119,7 @@ void read_Config(){
} }
if (CharsToLong(config.attack) == 0){ if (CharsToLong(config.attack) == 0){
buttonxz->setonly(); buttonxz->setonly();
} else { } else {
buttonzx->setonly(); buttonzx->setonly();
} }
if (CharsToLong(config.okay) == 0){ if (CharsToLong(config.okay) == 0){
@ -144,7 +144,7 @@ void write_Config(Fl_Widget*, void*){
LongToChars(movegt->value(), config.move); LongToChars(movegt->value(), config.move);
LongToChars(buttonzx->value(), config.attack); LongToChars(buttonzx->value(), config.attack);
LongToChars(okayattack->value(), config.okay); LongToChars(okayattack->value(), config.okay);
LongToChars(displaychoice->value(), config.display); LongToChars(displaychoice->value(), config.display);
LongToChars(joychoice->value(), config.useJoy); LongToChars(joychoice->value(), config.useJoy);
for(char i =0;i<8;i++){ for(char i =0;i<8;i++){
@ -158,28 +158,28 @@ void write_Config(Fl_Widget*, void*){
} }
int main(int argc, char* argv[]){ int main(int argc, char* argv[]){
Fl_Window *mainw = new Fl_Window(400, 380, "DoConfig - Doukutsu Monogatari Settings"); Fl_Window *mainw = new Fl_Window(400, 380, "DoConfig - Doukutsu Monogatari Settings");
Fl_Group *movegroup = new Fl_Group(10, 10, 185, 50); Fl_Group *movegroup = new Fl_Group(10, 10, 185, 50);
movegroup->box(FL_THIN_DOWN_BOX); movegroup->box(FL_THIN_DOWN_BOX);
movear = new Fl_Radio_Round_Button(10, 10, 185, 20, "Arrows for Movement"); movear = new Fl_Radio_Round_Button(10, 10, 185, 20, "Arrows for Movement");
movear->setonly(); movear->setonly();
movegt = new Fl_Radio_Round_Button(10, 40, 185, 20, "<>? for Movement"); movegt = new Fl_Radio_Round_Button(10, 40, 185, 20, "<>? for Movement");
movegroup->end(); movegroup->end();
Fl_Group *buttongroup = new Fl_Group(10, 70, 185, 50); Fl_Group *buttongroup = new Fl_Group(10, 70, 185, 50);
buttongroup->box(FL_THIN_DOWN_BOX); buttongroup->box(FL_THIN_DOWN_BOX);
buttonxz = new Fl_Radio_Round_Button(10, 70, 185, 20, "Z=Jump; X=Attack"); buttonxz = new Fl_Radio_Round_Button(10, 70, 185, 20, "Z=Jump; X=Attack");
buttonxz->setonly(); buttonxz->setonly();
buttonzx = new Fl_Radio_Round_Button(10, 100, 185, 20, "X=Jump; Z=Attack"); buttonzx = new Fl_Radio_Round_Button(10, 100, 185, 20, "X=Jump; Z=Attack");
buttongroup->end(); buttongroup->end();
Fl_Group *okaygroup = new Fl_Group(205, 10, 185, 50); Fl_Group *okaygroup = new Fl_Group(205, 10, 185, 50);
okaygroup->box(FL_THIN_DOWN_BOX); okaygroup->box(FL_THIN_DOWN_BOX);
okayjump = new Fl_Radio_Round_Button(205, 10, 185, 20, "Jump=Okay"); okayjump = new Fl_Radio_Round_Button(205, 10, 185, 20, "Jump=Okay");
okayjump->setonly(); okayjump->setonly();
okayattack = new Fl_Radio_Round_Button(205, 40, 185, 20, "Attack=Okay"); okayattack = new Fl_Radio_Round_Button(205, 40, 185, 20, "Attack=Okay");
okaygroup->end(); okaygroup->end();
displaychoice = new Fl_Choice(205, 70, 185, 20); displaychoice = new Fl_Choice(205, 70, 185, 20);
Fl_Menu_Item screens[] = { Fl_Menu_Item screens[] = {
{"Fullscreen 16-bit"}, {"Fullscreen 16-bit"},
@ -191,7 +191,7 @@ int main(int argc, char* argv[]){
displaychoice->menu(screens); displaychoice->menu(screens);
joychoice = new Fl_Check_Button(205, 100, 185, 20, "Use Joypad"); joychoice = new Fl_Check_Button(205, 100, 185, 20, "Use Joypad");
joychoice->callback(&activatejoy); joychoice->callback(&activatejoy);
joystuffcontainer = new Fl_Group(10, 130, 380, 200); joystuffcontainer = new Fl_Group(10, 130, 380, 200);
joystuffcontainer->box(FL_THIN_DOWN_BOX); joystuffcontainer->box(FL_THIN_DOWN_BOX);
for(char i=0;i<8;i++){ for(char i=0;i<8;i++){
@ -222,17 +222,17 @@ int main(int argc, char* argv[]){
labelmap->label("Map:"); labelmap->label("Map:");
labelmap->align(FL_ALIGN_RIGHT); labelmap->align(FL_ALIGN_RIGHT);
labelmap->end(); labelmap->end();
joystuffcontainer->end(); joystuffcontainer->end();
Fl_Button *okaybutton = new Fl_Button(10, 340, 185, 30, "Okay"); Fl_Button *okaybutton = new Fl_Button(10, 340, 185, 30, "Okay");
okaybutton->callback(&write_Config); okaybutton->callback(&write_Config);
Fl_Button *cancelbutton = new Fl_Button(205, 340, 185, 30, "Cancel"); Fl_Button *cancelbutton = new Fl_Button(205, 340, 185, 30, "Cancel");
cancelbutton->callback(&quit); cancelbutton->callback(&quit);
mainw->end(); mainw->end();
mainw->show(argc, argv); mainw->show(argc, argv);
read_Config(); read_Config();
Fl::option(Fl::OPTION_VISIBLE_FOCUS, false); Fl::option(Fl::OPTION_VISIBLE_FOCUS, false);
return Fl::run(); return Fl::run();

View file

@ -101,7 +101,7 @@ void PutBack(int fx, int fy)
{ {
RECT rect = {0, 0, gBack.partsW, gBack.partsH}; RECT rect = {0, 0, gBack.partsW, gBack.partsH};
RECT rcSkyFiller = {106, 0, 255, 88}; RECT rcSkyFiller = {106, 0, 255, 88};
switch (gBack.type) switch (gBack.type)
{ {
case 0: case 0:
@ -111,7 +111,7 @@ void PutBack(int fx, int fy)
PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND);
} }
break; break;
case 1: case 1:
for (int y = -(fy / 0x400 % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH) for (int y = -(fy / 0x400 % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH)
{ {
@ -119,7 +119,7 @@ void PutBack(int fx, int fy)
PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND);
} }
break; break;
case 2: case 2:
for (int y = -(fy / 0x200 % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH) for (int y = -(fy / 0x200 % gBack.partsH); y < WINDOW_HEIGHT; y += gBack.partsH)
{ {
@ -127,7 +127,7 @@ void PutBack(int fx, int fy)
PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND);
} }
break; break;
case 5: case 5:
for (int y = -gBack.partsH; y < WINDOW_HEIGHT; y += gBack.partsH) for (int y = -gBack.partsH; y < WINDOW_HEIGHT; y += gBack.partsH)
{ {
@ -135,7 +135,7 @@ void PutBack(int fx, int fy)
PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, x, y, &rect, SURFACE_ID_LEVEL_BACKGROUND);
} }
break; break;
case 6: case 6:
case 7: case 7:
//Sky //Sky
@ -149,7 +149,7 @@ void PutBack(int fx, int fy)
PutBitmap4(&grcGame, x, y, &rcSkyFiller, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, x, y, &rcSkyFiller, SURFACE_ID_LEVEL_BACKGROUND);
} }
} }
rect.top = 0; rect.top = 0;
rect.bottom = 88; rect.bottom = 88;
rect.left = 0; rect.left = 0;
@ -162,45 +162,45 @@ void PutBack(int fx, int fy)
rect.left = gBack.fx / 2; rect.left = gBack.fx / 2;
rect.right = 320; rect.right = 320;
PutBitmap4(&grcGame, 0, 88 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 0, 88 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0; rect.left = 0;
for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++) for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++)
PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx / 2 % 320, 88 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx / 2 % 320, 88 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
//Cloud layer 2 //Cloud layer 2
rect.top = 123; rect.top = 123;
rect.bottom = 146; rect.bottom = 146;
rect.left = gBack.fx % 320; rect.left = gBack.fx % 320;
rect.right = 320; rect.right = 320;
PutBitmap4(&grcGame, 0, 123 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 0, 123 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0; rect.left = 0;
for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++) for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++)
PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx % 320, 123 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, (320 * (i + 1)) - gBack.fx % 320, 123 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
//Cloud layer 3 //Cloud layer 3
rect.top = 146; rect.top = 146;
rect.bottom = 176; rect.bottom = 176;
rect.left = 2 * gBack.fx % 320; rect.left = 2 * gBack.fx % 320;
rect.right = 320; rect.right = 320;
PutBitmap4(&grcGame, 0, 146 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 0, 146 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0; rect.left = 0;
for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++) for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++)
PutBitmap4(&grcGame, (320 * (i + 1)) - 2 * gBack.fx % 320, 146 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, (320 * (i + 1)) - 2 * gBack.fx % 320, 146 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
//Cloud layer 4 //Cloud layer 4
rect.top = 176; rect.top = 176;
rect.bottom = 240; rect.bottom = 240;
rect.left = 4 * gBack.fx % 320; rect.left = 4 * gBack.fx % 320;
rect.right = 320; rect.right = 320;
PutBitmap4(&grcGame, 0, 176 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, 0, 176 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
rect.left = 0; rect.left = 0;
for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++) for (int i = 0; i < ((WINDOW_WIDTH - 1) / 320) + 1; i++)
PutBitmap4(&grcGame, (320 * (i + 1)) - 4 * gBack.fx % 320, 176 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND); PutBitmap4(&grcGame, (320 * (i + 1)) - 4 * gBack.fx % 320, 176 + (WINDOW_HEIGHT - 240), &rect, SURFACE_ID_LEVEL_BACKGROUND);
break; break;
default: default:
return; return;
} }
@ -226,17 +226,17 @@ void PutFront(int fx, int fy)
x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1); x_2 = x_1 + (((WINDOW_WIDTH + 31) >> 5) + 1);
y_1 = 0; y_1 = 0;
y_2 = y_1 + 32; y_2 = y_1 + 32;
for (y = y_1; y < y_2; y++) for (y = y_1; y < y_2; y++)
{ {
ypos = (y * 0x20 * 0x200) / 0x200 - fy / 0x200 + gWaterY / 0x200; ypos = (y * 0x20 * 0x200) / 0x200 - fy / 0x200 + gWaterY / 0x200;
if (ypos < -32) if (ypos < -32)
continue; continue;
if (ypos > WINDOW_HEIGHT) if (ypos > WINDOW_HEIGHT)
break; break;
for (x = x_1; x < x_2; x++) for (x = x_1; x < x_2; x++)
{ {
xpos = (x * 0x20 * 0x200) / 0x200 - fx / 0x200; xpos = (x * 0x20 * 0x200) / 0x200 - fx / 0x200;
@ -247,49 +247,49 @@ void PutFront(int fx, int fy)
} }
} }
//Draw black bars //Draw black bars
if (!(g_GameFlags & 8)) //Detect if credits are running if (!(g_GameFlags & 8)) //Detect if credits are running
{ {
const bool fromFocus = (gStageNo == 31); //Get if we should only draw around a 320x240 area of the focus point const bool fromFocus = (gStageNo == 31); //Get if we should only draw around a 320x240 area of the focus point
//Get focus rect //Get focus rect
int focusX = gFrame.x + (WINDOW_WIDTH << 8) - (320 << 8); int focusX = gFrame.x + (WINDOW_WIDTH << 8) - (320 << 8);
int focusY = gFrame.y + (WINDOW_HEIGHT << 8) - (240 << 8); int focusY = gFrame.y + (WINDOW_HEIGHT << 8) - (240 << 8);
int focusR = focusX + (320 << 9); int focusR = focusX + (320 << 9);
int focusB = focusY + (240 << 9); int focusB = focusY + (240 << 9);
//Get borders //Get borders
const int barLeft = fromFocus ? focusX : -0x1000; const int barLeft = fromFocus ? focusX : -0x1000;
const int barTop = fromFocus ? focusY : -0x1000; const int barTop = fromFocus ? focusY : -0x1000;
const int barRight = fromFocus ? focusR : (gMap.width << 13) - 0x1000; const int barRight = fromFocus ? focusR : (gMap.width << 13) - 0x1000;
const int barBottom = fromFocus ? focusB : (gMap.length << 13) - 0x1000; const int barBottom = fromFocus ? focusB : (gMap.length << 13) - 0x1000;
//Draw bars //Draw bars
RECT barRect; RECT barRect;
//Left //Left
barRect.left = 0; barRect.left = 0;
barRect.top = 0; barRect.top = 0;
barRect.right = (barLeft - gFrame.x) >> 9; barRect.right = (barLeft - gFrame.x) >> 9;
barRect.bottom = WINDOW_HEIGHT; barRect.bottom = WINDOW_HEIGHT;
CortBox(&barRect, 0x000000); CortBox(&barRect, 0x000000);
//Top //Top
barRect.left = 0; barRect.left = 0;
barRect.top = 0; barRect.top = 0;
barRect.right = WINDOW_WIDTH; barRect.right = WINDOW_WIDTH;
barRect.bottom = (barTop - gFrame.y) >> 9; barRect.bottom = (barTop - gFrame.y) >> 9;
CortBox(&barRect, 0x000000); CortBox(&barRect, 0x000000);
//Right //Right
barRect.left = (barRight - gFrame.x) >> 9; barRect.left = (barRight - gFrame.x) >> 9;
barRect.top = 0; barRect.top = 0;
barRect.right = WINDOW_WIDTH; barRect.right = WINDOW_WIDTH;
barRect.bottom = WINDOW_HEIGHT; barRect.bottom = WINDOW_HEIGHT;
CortBox(&barRect, 0x000000); CortBox(&barRect, 0x000000);
//Bottom //Bottom
barRect.left = 0; barRect.left = 0;
barRect.top = (barBottom - gFrame.y) >> 9; barRect.top = (barBottom - gFrame.y) >> 9;

View file

@ -48,20 +48,20 @@ void PutBossChar(int fx, int fy)
else else
{ {
a = 0; a = 0;
if (gBoss[b].bits & npc_showDamage && gBoss[b].damage_view) if (gBoss[b].bits & npc_showDamage && gBoss[b].damage_view)
{ {
SetValueView(&gBoss[b].x, &gBoss[b].y, gBoss[b].damage_view); SetValueView(&gBoss[b].x, &gBoss[b].y, gBoss[b].damage_view);
gBoss[b].damage_view = 0; gBoss[b].damage_view = 0;
} }
} }
int side; int side;
if (gBoss[b].direct == 0) if (gBoss[b].direct == 0)
side = gBoss[b].view.front; side = gBoss[b].view.front;
else else
side = gBoss[b].view.back; side = gBoss[b].view.back;
PutBitmap3( PutBitmap3(
&grcGame, &grcGame,
(gBoss[b].x - side) / 0x200 - fx / 0x200 + a, (gBoss[b].x - side) / 0x200 - fx / 0x200 + a,
@ -111,7 +111,7 @@ void HitBossBullet()
&& gBoss[bos].y - gBoss[bos].hit.top < gBul[bul].y + gBul[bul].blockYL && gBoss[bos].y - gBoss[bos].hit.top < gBul[bul].y + gBul[bul].blockYL
&& gBoss[bos].y + gBoss[bos].hit.bottom > gBul[bul].y - gBul[bul].blockYL) && gBoss[bos].y + gBoss[bos].hit.bottom > gBul[bul].y - gBul[bul].blockYL)
bHit = TRUE; bHit = TRUE;
if (bHit) if (bHit)
{ {
//Damage boss //Damage boss
@ -121,13 +121,13 @@ void HitBossBullet()
bos_ = 0; bos_ = 0;
else else
bos_ = bos; bos_ = bos;
gBoss[bos_].life -= gBul[bul].damage; gBoss[bos_].life -= gBul[bul].damage;
if (gBoss[bos_].life < 1) if (gBoss[bos_].life < 1)
{ {
gBoss[bos_].life = bos_; gBoss[bos_].life = bos_;
if ((gMC.cond & 0x80) && gBoss[bos_].bits & npc_eventDie) if ((gMC.cond & 0x80) && gBoss[bos_].bits & npc_eventDie)
{ {
StartTextScript(gBoss[bos_].code_event); StartTextScript(gBoss[bos_].code_event);
@ -135,7 +135,7 @@ void HitBossBullet()
else else
{ {
PlaySoundObject(gBoss[bos_].destroy_voice, 1); PlaySoundObject(gBoss[bos_].destroy_voice, 1);
switch (gBoss[bos_].size) switch (gBoss[bos_].size)
{ {
case 1: case 1:
@ -148,7 +148,7 @@ void HitBossBullet()
SetDestroyNpChar(gBoss[bos_].x, gBoss[bos_].y, gBoss[bos_].view.back, 16); SetDestroyNpChar(gBoss[bos_].x, gBoss[bos_].y, gBoss[bos_].view.back, 16);
break; break;
} }
gBoss[bos_].cond = 0; gBoss[bos_].cond = 0;
} }
} }
@ -161,12 +161,12 @@ void HitBossBullet()
SetCaret(gBul[bul].x, gBul[bul].y, 11, 0); SetCaret(gBul[bul].x, gBul[bul].y, 11, 0);
PlaySoundObject(gBoss[bos_].hit_voice, 1); PlaySoundObject(gBoss[bos_].hit_voice, 1);
} }
gBoss[bos].shock = 8; gBoss[bos].shock = 8;
gBoss[bos_].shock = 8; gBoss[bos_].shock = 8;
gBoss[bos_].damage_view -= gBul[bul].damage; gBoss[bos_].damage_view -= gBul[bul].damage;
} }
if (--gBul[bul].life < 1) if (--gBul[bul].life < 1)
gBul[bul].cond = 0; gBul[bul].cond = 0;
} }
@ -224,7 +224,7 @@ void ActBossChar()
code_char = gBoss[0].code_char; code_char = gBoss[0].code_char;
gpBossFuncTbl[code_char](); gpBossFuncTbl[code_char]();
for (bos = 0; bos < BOSS_MAX; bos++) for (bos = 0; bos < BOSS_MAX; bos++)
{ {
if (gBoss[bos].shock) if (gBoss[bos].shock)
@ -258,7 +258,7 @@ void HitBossMap()
offx[13] = 0; offx[13] = 0;
offx[14] = 1; offx[14] = 1;
offx[15] = 2; offx[15] = 2;
offy[0] = 0; offy[0] = 0;
offy[1] = 0; offy[1] = 0;
offy[2] = 1; offy[2] = 1;
@ -275,7 +275,7 @@ void HitBossMap()
offy[13] = -1; offy[13] = -1;
offy[14] = -1; offy[14] = -1;
offy[15] = -1; offy[15] = -1;
for (b = 0; b < BOSS_MAX; b++) for (b = 0; b < BOSS_MAX; b++)
{ {
int judg; int judg;
@ -288,7 +288,7 @@ void HitBossMap()
if (gBoss[b].size >= 3) if (gBoss[b].size >= 3)
{ {
judg = 16; judg = 16;
x = gBoss[b].x / 0x10 / 0x200; x = gBoss[b].x / 0x10 / 0x200;
y = gBoss[b].y / 0x10 / 0x200; y = gBoss[b].y / 0x10 / 0x200;
} }
@ -298,12 +298,12 @@ void HitBossMap()
x = gBoss[b].x / 0x10 / 0x200; x = gBoss[b].x / 0x10 / 0x200;
y = gBoss[b].y / 0x10 / 0x200; y = gBoss[b].y / 0x10 / 0x200;
} }
gBoss[b].flag = 0; gBoss[b].flag = 0;
for (j = 0; j < judg; j++) for (j = 0; j < judg; j++)
{ {
atrb[j] = GetAttribute(x + offx[j], y + offy[j]); atrb[j] = GetAttribute(x + offx[j], y + offy[j]);
switch (atrb[j]) switch (atrb[j])
{ {
case 0x44: case 0x44:
@ -381,4 +381,4 @@ void HitBossMap()
} }
} }
} }
} }

View file

@ -720,4 +720,4 @@ void ActBossChar_Ballos(void)
ActBossChar_Body(&gBoss[3]); ActBossChar_Body(&gBoss[3]);
ActBossChar_HITAI(&gBoss[4]); ActBossChar_HITAI(&gBoss[4]);
ActBossChar_HARA(&gBoss[5]); ActBossChar_HARA(&gBoss[5]);
} }

View file

@ -209,4 +209,4 @@ void ActBossChar_Ironhead(void)
{ {
npc->rect = rc[npc->ani_no]; npc->rect = rc[npc->ani_no];
} }
} }

View file

@ -23,7 +23,7 @@ static void ActBoss01_12()
for (i = 1; i < 3; ++i) for (i = 1; i < 3; ++i)
{ {
gBoss[i].y = (gBoss[0].y + gBoss[i + 2].y - 0x1000) / 2; gBoss[i].y = (gBoss[0].y + gBoss[i + 2].y - 0x1000) / 2;
if (gBoss[i].direct == 0) if (gBoss[i].direct == 0)
{ {
gBoss[i].x = gBoss[0].x - 0x2000; gBoss[i].x = gBoss[0].x - 0x2000;

View file

@ -229,4 +229,4 @@ void ActBossChar_Press(void)
{ {
npc->rect = rc[npc->ani_no]; npc->rect = rc[npc->ani_no];
} }
} }

View file

@ -561,4 +561,4 @@ void ActBossChar_Twin(void)
RECT rc = {0, 0, 0, 0}; RECT rc = {0, 0, 0, 0};
npc->rect = rc; npc->rect = rc;
} }

View file

@ -864,4 +864,4 @@ void ActBossChar_MonstX(void)
gBoss[11].act_no = 300; gBoss[11].act_no = 300;
gBoss[12].act_no = 300; gBoss[12].act_no = 300;
} }
} }

View file

@ -30,7 +30,7 @@ int JudgeHitBulletBlock(int x, int y, BULLET *bul)
&& bul->y - bul->blockYL < (0x10 * y + 8) * 0x200 && bul->y - bul->blockYL < (0x10 * y + 8) * 0x200
&& bul->y + bul->blockYL> (0x10 * y - 8) * 0x200) && bul->y + bul->blockYL> (0x10 * y - 8) * 0x200)
hit |= 0x200; hit |= 0x200;
if (hit && (bul->bbits & 0x60) && GetAttribute(x, y) == 0x43) if (hit && (bul->bbits & 0x60) && GetAttribute(x, y) == 0x43)
{ {
if (!(bul->bbits & 0x40)) if (!(bul->bbits & 0x40))
@ -41,7 +41,7 @@ int JudgeHitBulletBlock(int x, int y, BULLET *bul)
SetNpChar(4, x * 0x200 * 0x10, y * 0x200 * 0x10, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, 0, 256); SetNpChar(4, x * 0x200 * 0x10, y * 0x200 * 0x10, Random(-0x200, 0x200), Random(-0x200, 0x200), 0, 0, 256);
ShiftMapParts(x, y); ShiftMapParts(x, y);
} }
return hit; return hit;
} }
@ -51,7 +51,7 @@ int JudgeHitBulletBlock2(int x, int y, uint8_t *atrb, BULLET *bul)
int workX; int workX;
int workY; int workY;
int hit = 0; int hit = 0;
int block[4]; int block[4];
if (bul->bbits & 0x40) if (bul->bbits & 0x40)
{ {
@ -77,10 +77,10 @@ int JudgeHitBulletBlock2(int x, int y, uint8_t *atrb, BULLET *bul)
++atrb; ++atrb;
} }
} }
workX = (0x10 * x + 8) * 0x200; workX = (0x10 * x + 8) * 0x200;
workY = (0x10 * y + 8) * 0x200; workY = (0x10 * y + 8) * 0x200;
//Left wall //Left wall
if (block[0] && block[2]) if (block[0] && block[2])
{ {
@ -97,7 +97,7 @@ int JudgeHitBulletBlock2(int x, int y, uint8_t *atrb, BULLET *bul)
if (bul->x - bul->blockXL < workX && bul->y + bul->blockYL > workY + 0x600) if (bul->x - bul->blockXL < workX && bul->y + bul->blockYL > workY + 0x600)
hit |= 1; hit |= 1;
} }
//Right wall //Right wall
if (block[1] && block[3]) if (block[1] && block[3])
{ {
@ -131,7 +131,7 @@ int JudgeHitBulletBlock2(int x, int y, uint8_t *atrb, BULLET *bul)
if (bul->y - bul->blockYL < workY && bul->x + bul->blockXL > workX + 0x600) if (bul->y - bul->blockYL < workY && bul->x + bul->blockXL > workX + 0x600)
hit |= 2; hit |= 2;
} }
//Ground //Ground
if (block[2] && block[3]) if (block[2] && block[3])
{ {
@ -148,7 +148,7 @@ int JudgeHitBulletBlock2(int x, int y, uint8_t *atrb, BULLET *bul)
if (bul->y + bul->blockYL > workY && bul->x + bul->blockXL > workX + 0x600) if (bul->y + bul->blockYL > workY && bul->x + bul->blockXL > workX + 0x600)
hit |= 8; hit |= 8;
} }
//Clip //Clip
if (bul->bbits & 8) if (bul->bbits & 8)
{ {
@ -165,7 +165,7 @@ int JudgeHitBulletBlock2(int x, int y, uint8_t *atrb, BULLET *bul)
{ {
Vanish(bul); Vanish(bul);
} }
return hit; return hit;
} }
@ -323,7 +323,7 @@ void HitBulletMap()
x = gBul[i].x / 0x10 / 0x200; x = gBul[i].x / 0x10 / 0x200;
y = gBul[i].y / 0x10 / 0x200; y = gBul[i].y / 0x10 / 0x200;
//Get surrounding tiles //Get surrounding tiles
offx[0] = 0; offx[0] = 0;
offx[1] = 1; offx[1] = 1;
@ -333,15 +333,15 @@ void HitBulletMap()
offy[1] = 0; offy[1] = 0;
offy[2] = 1; offy[2] = 1;
offy[3] = 1; offy[3] = 1;
atrb[0] = GetAttribute(x, y); atrb[0] = GetAttribute(x, y);
atrb[1] = GetAttribute(x + 1, y); atrb[1] = GetAttribute(x + 1, y);
atrb[2] = GetAttribute(x, y + 1); atrb[2] = GetAttribute(x, y + 1);
atrb[3] = GetAttribute(x + 1, y + 1); atrb[3] = GetAttribute(x + 1, y + 1);
//Clear hit tiles //Clear hit tiles
gBul[i].flag = 0; gBul[i].flag = 0;
if (gBul[i].bbits & 4) if (gBul[i].bbits & 4)
{ {
// For some reason a 'continue' just doesn't produce the same assembly // For some reason a 'continue' just doesn't produce the same assembly
@ -396,7 +396,7 @@ void HitBulletMap()
break; break;
} }
} }
gBul[i].flag |= JudgeHitBulletBlock2(x, y, atrb, &gBul[i]); gBul[i].flag |= JudgeHitBulletBlock2(x, y, atrb, &gBul[i]);
} }
} }

View file

@ -78,7 +78,7 @@ int CountArmsBullet(int arms_code)
if (gBul[i].cond & 0x80 && (gBul[i].code_bullet + 2) / 3 == arms_code) if (gBul[i].cond & 0x80 && (gBul[i].code_bullet + 2) / 3 == arms_code)
++count; ++count;
} }
return count; return count;
} }
@ -90,7 +90,7 @@ int CountBulletNum(int bullet_code)
if (gBul[i].cond & 0x80 && gBul[i].code_bullet == bullet_code) if (gBul[i].cond & 0x80 && gBul[i].code_bullet == bullet_code)
++count; ++count;
} }
return count; return count;
} }
@ -122,7 +122,7 @@ void PutBullet(int fx, int fy)
for (i = 0; i < BULLET_MAX; i++) for (i = 0; i < BULLET_MAX; i++)
{ {
if (gBul[i].cond & 0x80) if (gBul[i].cond & 0x80)
{ {
switch (gBul[i].direct) switch (gBul[i].direct)
{ {
case 0: case 0:
@ -142,7 +142,7 @@ void PutBullet(int fx, int fy)
y = gBul[i].y - gBul[i].view.back; y = gBul[i].y - gBul[i].view.back;
break; break;
} }
PutBitmap3(&grcGame, x / 0x200 - fx / 0x200, y / 0x200 - fy / 0x200, &gBul[i].rect, SURFACE_ID_BULLET); PutBitmap3(&grcGame, x / 0x200 - fx / 0x200, y / 0x200 - fy / 0x200, &gBul[i].rect, SURFACE_ID_BULLET);
} }
} }
@ -386,7 +386,7 @@ void ActBullet_PoleStar(BULLET *bul, int level)
if (bul->act_no == 0) if (bul->act_no == 0)
{ {
bul->act_no = 1; bul->act_no = 1;
//Set speed //Set speed
switch (bul->direct) switch (bul->direct)
{ {
@ -403,7 +403,7 @@ void ActBullet_PoleStar(BULLET *bul, int level)
bul->ym = 0x1000; bul->ym = 0x1000;
break; break;
} }
//Set hitbox //Set hitbox
switch (level) switch (level)
{ {
@ -507,12 +507,12 @@ void ActBullet_FireBall(BULLET *bul, int level)
bBreak = TRUE; bBreak = TRUE;
if (bul->flag & 1 && bul->flag & 4) if (bul->flag & 1 && bul->flag & 4)
bBreak = TRUE; bBreak = TRUE;
if (!bul->direct && bul->flag & 1) if (!bul->direct && bul->flag & 1)
bul->direct = 2; bul->direct = 2;
if (bul->direct == 2 && bul->flag & 4) if (bul->direct == 2 && bul->flag & 4)
bul->direct = 0; bul->direct = 0;
if (bBreak) if (bBreak)
{ {
bul->cond = 0; bul->cond = 0;
@ -524,7 +524,7 @@ void ActBullet_FireBall(BULLET *bul, int level)
if (bul->act_no == 0) if (bul->act_no == 0)
{ {
bul->act_no = 1; bul->act_no = 1;
switch (bul->direct) switch (bul->direct)
{ {
case 0: case 0:
@ -532,17 +532,17 @@ void ActBullet_FireBall(BULLET *bul, int level)
break; break;
case 1: case 1:
bul->xm = gMC.xm; bul->xm = gMC.xm;
if (gMC.xm < 0) if (gMC.xm < 0)
bul->direct = 0; bul->direct = 0;
else else
bul->direct = 2; bul->direct = 2;
if (gMC.direct == 0) if (gMC.direct == 0)
bul->xm -= 0x80; bul->xm -= 0x80;
else else
bul->xm += 0x80; bul->xm += 0x80;
bul->ym = -0x5FF; bul->ym = -0x5FF;
break; break;
case 2: case 2:
@ -569,14 +569,14 @@ void ActBullet_FireBall(BULLET *bul, int level)
bul->xm = 0x400; bul->xm = 0x400;
else if (bul->flag & 4) else if (bul->flag & 4)
bul->xm = -0x400; bul->xm = -0x400;
bul->ym += 85; bul->ym += 85;
if (bul->ym > 0x3FF) if (bul->ym > 0x3FF)
bul->ym = 0x3FF; bul->ym = 0x3FF;
bul->x += bul->xm; bul->x += bul->xm;
bul->y += bul->ym; bul->y += bul->ym;
if (bul->flag & 0xD) if (bul->flag & 0xD)
PlaySoundObject(34, 1); PlaySoundObject(34, 1);
} }
@ -598,14 +598,14 @@ void ActBullet_FireBall(BULLET *bul, int level)
SET_RECT(rect_right2[0], 224, 16, 240, 32) SET_RECT(rect_right2[0], 224, 16, 240, 32)
SET_RECT(rect_right2[1], 208, 16, 224, 32) SET_RECT(rect_right2[1], 208, 16, 224, 32)
SET_RECT(rect_right2[2], 192, 16, 208, 32) SET_RECT(rect_right2[2], 192, 16, 208, 32)
bul->ani_no++; bul->ani_no++;
if (level == 1) if (level == 1)
{ {
if (bul->ani_no > 3) if (bul->ani_no > 3)
bul->ani_no = 0; bul->ani_no = 0;
if (bul->direct == 0) if (bul->direct == 0)
bul->rect = rect_left1[bul->ani_no]; bul->rect = rect_left1[bul->ani_no];
else else
@ -615,12 +615,12 @@ void ActBullet_FireBall(BULLET *bul, int level)
{ {
if (bul->ani_no > 2) if (bul->ani_no > 2)
bul->ani_no = 0; bul->ani_no = 0;
if (bul->direct == 0) if (bul->direct == 0)
bul->rect = rect_left2[bul->ani_no]; bul->rect = rect_left2[bul->ani_no];
else else
bul->rect = rect_right2[bul->ani_no]; bul->rect = rect_right2[bul->ani_no];
if (level == 2) if (level == 2)
SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, 0, 0x100); SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, 0, 0x100);
else else
@ -676,9 +676,9 @@ void ActBullet_MachineGun(BULLET *bul, int level)
move = 0x1000; move = 0x1000;
break; break;
} }
bul->act_no = 1; bul->act_no = 1;
switch (bul->direct) switch (bul->direct)
{ {
case 0: case 0:
@ -703,7 +703,7 @@ void ActBullet_MachineGun(BULLET *bul, int level)
{ {
bul->x += bul->xm; bul->x += bul->xm;
bul->y += bul->ym; bul->y += bul->ym;
switch (level) switch (level)
{ {
case 1: case 1:
@ -808,7 +808,7 @@ void ActBullet_Missile(BULLET *bul, int level)
} }
static unsigned int inc; static unsigned int inc;
switch (++inc % 3) switch (++inc % 3)
{ {
case 0: case 0:
@ -945,7 +945,7 @@ void ActBullet_Bom(BULLET *bul, int level)
{ {
case 0: case 0:
bul->act_no = 1; bul->act_no = 1;
switch (level) switch (level)
{ {
case 1: case 1:
@ -958,7 +958,7 @@ void ActBullet_Bom(BULLET *bul, int level)
bul->act_wait = 5; bul->act_wait = 5;
break; break;
} }
PlaySoundObject(44, 1); PlaySoundObject(44, 1);
// Fallthrough // Fallthrough
case 1: case 1:
@ -979,7 +979,7 @@ void ActBullet_Bom(BULLET *bul, int level)
SetDestroyNpCharUp(bul->x + (Random(-40, 40) << 9), bul->y + (Random(-40, 40) << 9), bul->enemyXL, 2); SetDestroyNpCharUp(bul->x + (Random(-40, 40) << 9), bul->y + (Random(-40, 40) << 9), bul->enemyXL, 2);
break; break;
} }
if (--bul->act_wait < 0) if (--bul->act_wait < 0)
bul->cond = 0; bul->cond = 0;
break; break;
@ -2424,4 +2424,4 @@ BOOL IsActiveSomeBullet(void)
} }
return FALSE; return FALSE;
} }

View file

@ -36,25 +36,25 @@ void ActCaret01(CARET *crt)
{80, 24, 88, 32}, {80, 24, 88, 32},
{88, 24, 96, 32}, {88, 24, 96, 32},
}; };
if (!crt->act_no) if (!crt->act_no)
{ {
crt->act_no = 1; crt->act_no = 1;
crt->xm = Random(-0x400, 0x400); crt->xm = Random(-0x400, 0x400);
crt->ym = Random(-0x400, 0); crt->ym = Random(-0x400, 0);
} }
crt->ym += 0x40; crt->ym += 0x40;
crt->x += crt->xm; crt->x += crt->xm;
crt->y += crt->ym; crt->y += crt->ym;
if (++crt->ani_wait > 5) if (++crt->ani_wait > 5)
{ {
crt->ani_wait = 0; crt->ani_wait = 0;
if (++crt->ani_no > 3) if (++crt->ani_no > 3)
crt->cond = 0; crt->cond = 0;
} }
if (crt->direct == 0) if (crt->direct == 0)
crt->rect = rcLeft[crt->ani_no]; crt->rect = rcLeft[crt->ani_no];
else else
@ -100,7 +100,7 @@ void ActCaret02(CARET *crt)
crt->rect = rect_left[crt->ani_no]; crt->rect = rect_left[crt->ani_no];
break; break;
case 2: case 2:
if (++crt->ani_wait > 2) if (++crt->ani_wait > 2)
{ {
@ -113,7 +113,7 @@ void ActCaret02(CARET *crt)
crt->rect = rect_right[crt->ani_no]; crt->rect = rect_right[crt->ani_no];
break; break;
case 1: case 1:
crt->rect = rect_up[++crt->ani_wait / 2 % 3]; crt->rect = rect_up[++crt->ani_wait / 2 % 3];
@ -132,14 +132,14 @@ void ActCaret03(CARET *crt)
{32, 48, 48, 64}, {32, 48, 48, 64},
{48, 48, 64, 64}, {48, 48, 64, 64},
}; };
if (++crt->ani_wait > 2) if (++crt->ani_wait > 2)
{ {
crt->ani_wait = 0; crt->ani_wait = 0;
if (++crt->ani_no > 3) if (++crt->ani_no > 3)
crt->cond = 0; crt->cond = 0;
} }
crt->rect = rect[crt->ani_no]; crt->rect = rect[crt->ani_no];
} }
@ -255,7 +255,7 @@ void ActCaret09(CARET *crt)
if (crt->ani_wait == 32) if (crt->ani_wait == 32)
crt->cond = 0; crt->cond = 0;
if (crt->direct == 0) if (crt->direct == 0)
crt->rect = rcLeft; crt->rect = rcLeft;
else else
@ -275,7 +275,7 @@ void ActCaret10(CARET *crt)
}; };
++crt->ani_wait; ++crt->ani_wait;
if (crt->direct == 0) if (crt->direct == 0)
{ {
if (crt->ani_wait < 20) if (crt->ani_wait < 20)
@ -292,7 +292,7 @@ void ActCaret10(CARET *crt)
if (crt->ani_wait == 80) if (crt->ani_wait == 80)
crt->cond = 0; crt->cond = 0;
} }
if (crt->direct == 0) if (crt->direct == 0)
crt->rect = rcLeft[crt->ani_wait / 2 % 2]; crt->rect = rcLeft[crt->ani_wait / 2 % 2];
else else
@ -310,10 +310,10 @@ void ActCaret11(CARET *crt)
crt->xm = 2 * GetCos(deg); crt->xm = 2 * GetCos(deg);
crt->ym = 2 * GetSin(deg); crt->ym = 2 * GetSin(deg);
} }
crt->x += crt->xm; crt->x += crt->xm;
crt->y += crt->ym; crt->y += crt->ym;
RECT rcRight[7] = { RECT rcRight[7] = {
{56, 8, 64, 16}, {56, 8, 64, 16},
{64, 8, 72, 16}, {64, 8, 72, 16},
@ -330,7 +330,7 @@ void ActCaret11(CARET *crt)
if (++crt->ani_no > 6) if (++crt->ani_no > 6)
crt->cond = 0; crt->cond = 0;
} }
crt->rect = rcRight[crt->ani_no]; crt->rect = rcRight[crt->ani_no];
} }
@ -340,14 +340,14 @@ void ActCaret12(CARET *crt)
{112, 0, 144, 32}, {112, 0, 144, 32},
{144, 0, 176, 32}, {144, 0, 176, 32},
}; };
if (++crt->ani_wait > 2) if (++crt->ani_wait > 2)
{ {
crt->ani_wait = 0; crt->ani_wait = 0;
if (++crt->ani_no > 1) if (++crt->ani_no > 1)
crt->cond = 0; crt->cond = 0;
} }
crt->rect = rcLeft[crt->ani_no]; crt->rect = rcLeft[crt->ani_no];
} }
@ -357,24 +357,24 @@ void ActCaret13(CARET *crt)
{56, 24, 64, 32}, {56, 24, 64, 32},
{0, 0, 0, 0}, {0, 0, 0, 0},
}; };
if (crt->act_no == 0) if (crt->act_no == 0)
{ {
crt->act_no = 1; crt->act_no = 1;
switch (crt->direct) switch (crt->direct)
{ {
case 0: case 0:
crt->xm = Random(-0x600, 0x600); crt->xm = Random(-0x600, 0x600);
crt->ym = Random(-0x200, 0x200); crt->ym = Random(-0x200, 0x200);
break; break;
case 1: case 1:
crt->ym = -0x200 * Random(1, 3); crt->ym = -0x200 * Random(1, 3);
break; break;
} }
} }
switch (crt->direct) switch (crt->direct)
{ {
case 0: case 0:
@ -382,15 +382,15 @@ void ActCaret13(CARET *crt)
crt->ym = 4 * crt->ym / 5; crt->ym = 4 * crt->ym / 5;
break; break;
} }
crt->x += crt->xm; crt->x += crt->xm;
crt->y += crt->ym; crt->y += crt->ym;
if (++crt->ani_wait > 20) if (++crt->ani_wait > 20)
crt->cond = 0; crt->cond = 0;
crt->rect = rcLeft[crt->ani_wait / 2 % 2]; crt->rect = rcLeft[crt->ani_wait / 2 % 2];
if (crt->direct == 5) if (crt->direct == 5)
crt->x -= 0x800; crt->x -= 0x800;
} }

View file

@ -15,41 +15,41 @@ bool LoadConfigData(CONFIG *conf)
{ {
//Clear old config data //Clear old config 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.dat"); sprintf(path, "%s/%s", gModulePath, "Config.dat");
//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
//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);
//Close file //Close file
fclose(fp); fclose(fp);
//Check if version is correct, return that it succeeded //Check if version is correct, return that it succeeded
if (!strcmp(conf->proof, "DOUKUTSU20041206")) if (!strcmp(conf->proof, "DOUKUTSU20041206"))
return true; return true;
//If not, return that it failed //If not, return that it failed
return false; return false;
} }
@ -58,7 +58,7 @@ void DefaultConfigData(CONFIG *conf)
{ {
//Claer old config data //Claer old config data
memset(conf, 0, sizeof(CONFIG)); memset(conf, 0, sizeof(CONFIG));
//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;

View file

@ -100,21 +100,21 @@ BOOL StartDirectDraw(int lMagnification, int lColourDepth)
magnification = 1; magnification = 1;
fullscreen = false; fullscreen = false;
break; break;
case 1: case 1:
magnification = 2; magnification = 2;
fullscreen = false; fullscreen = false;
break; break;
case 2: case 2:
magnification = 2; magnification = 2;
fullscreen = true; fullscreen = true;
SDL_SetWindowFullscreen(gWindow, SDL_WINDOW_FULLSCREEN); SDL_SetWindowFullscreen(gWindow, SDL_WINDOW_FULLSCREEN);
break; break;
} }
} }
return TRUE; return TRUE;
} }
@ -122,7 +122,7 @@ void EndDirectDraw()
{ {
//Quit sub-system //Quit sub-system
SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_QuitSubSystem(SDL_INIT_VIDEO);
//Release all surfaces //Release all surfaces
for (int i = 0; i < SURFACE_ID_MAX; i++) for (int i = 0; i < SURFACE_ID_MAX; i++)
ReleaseSurface(i); ReleaseSurface(i);
@ -319,7 +319,7 @@ static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s
{ {
char path[PATH_LENGTH]; char path[PATH_LENGTH];
SDL_RWops *fp; SDL_RWops *fp;
//Attempt to load PBM //Attempt to load PBM
sprintf(path, "%s/%s.pbm", gDataPath, name); sprintf(path, "%s/%s.pbm", gDataPath, name);
fp = SDL_RWFromFile(path, "rb"); fp = SDL_RWFromFile(path, "rb");
@ -337,7 +337,7 @@ static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s
return TRUE; return TRUE;
} }
} }
//Attempt to load BMP //Attempt to load BMP
sprintf(path, "%s/%s.bmp", gDataPath, name); sprintf(path, "%s/%s.bmp", gDataPath, name);
fp = SDL_RWFromFile(path, "rb"); fp = SDL_RWFromFile(path, "rb");
@ -347,7 +347,7 @@ static BOOL LoadBitmap_File(const char *name, Surface_Ids surf_no, bool create_s
if (LoadBitmap(fp, surf_no, create_surface)) if (LoadBitmap(fp, surf_no, create_surface))
return TRUE; return TRUE;
} }
printf("Failed to open file %s\n", name); printf("Failed to open file %s\n", name);
return FALSE; return FALSE;
} }
@ -356,7 +356,7 @@ static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool creat
{ {
size_t size; size_t size;
const unsigned char *data = FindResource(res, "BITMAP", &size); const unsigned char *data = FindResource(res, "BITMAP", &size);
if (data) if (data)
{ {
SDL_RWops *fp = SDL_RWFromConstMem(data, size); SDL_RWops *fp = SDL_RWFromConstMem(data, size);
@ -365,7 +365,7 @@ static BOOL LoadBitmap_Resource(const char *res, Surface_Ids surf_no, bool creat
if (LoadBitmap(fp, surf_no, create_surface)) if (LoadBitmap(fp, surf_no, create_surface))
return TRUE; return TRUE;
} }
printf("Failed to open resource %s\n", res); printf("Failed to open resource %s\n", res);
return FALSE; return FALSE;
} }
@ -443,19 +443,19 @@ 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 dest 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
SDL_RenderSetClipRect(gRenderer, &clipRect); SDL_RenderSetClipRect(gRenderer, &clipRect);
SDL_SetTextureBlendMode(surf[surf_no].texture, transparent ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE); SDL_SetTextureBlendMode(surf[surf_no].texture, transparent ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE);
//Draw to screen //Draw to screen
if (SDL_RenderCopy(gRenderer, surf[surf_no].texture, &frameRect, &destRect) < 0) if (SDL_RenderCopy(gRenderer, surf[surf_no].texture, &frameRect, &destRect) < 0)
printf("Failed to draw texture %d\nSDL Error: %s\n", surf_no, SDL_GetError()); printf("Failed to draw texture %d\nSDL Error: %s\n", surf_no, SDL_GetError());
//Undo cliprect //Undo cliprect
SDL_RenderSetClipRect(gRenderer, NULL); SDL_RenderSetClipRect(gRenderer, NULL);
} }
@ -490,7 +490,7 @@ void CortBox(RECT *rect, uint32_t col)
{ {
//Get rect //Get rect
SDL_Rect destRect = RectToSDLRectScaled(rect); SDL_Rect destRect = RectToSDLRectScaled(rect);
//Set colour and draw //Set colour and draw
const unsigned char col_red = col & 0x0000FF; const unsigned char col_red = col & 0x0000FF;
const unsigned char col_green = (col & 0x00FF00) >> 8; const unsigned char col_green = (col & 0x00FF00) >> 8;

View file

@ -47,7 +47,7 @@ void PutStripper()
//Draw text //Draw text
RECT rc = {0, 16 * s, 320, 16 * s + 16}; RECT rc = {0, 16 * s, 320, 16 * s + 16};
PutBitmap3(&grcFull, (Strip[s].x + ((WINDOW_WIDTH - 320) << 8)) / 0x200, Strip[s].y / 0x200, &rc, SURFACE_ID_CREDIT_CAST); PutBitmap3(&grcFull, (Strip[s].x + ((WINDOW_WIDTH - 320) << 8)) / 0x200, Strip[s].y / 0x200, &rc, SURFACE_ID_CREDIT_CAST);
//Draw character //Draw character
rc.left = 24 * (Strip[s].cast % 13); rc.left = 24 * (Strip[s].cast % 13);
rc.right = rc.left + 24; rc.right = rc.left + 24;
@ -71,7 +71,7 @@ void SetStripper(int x, int y, const char *text, int cast)
Strip[s].y = y; Strip[s].y = y;
Strip[s].cast = cast; Strip[s].cast = cast;
strcpy(Strip[s].str, text); strcpy(Strip[s].str, text);
//Draw text //Draw text
RECT rc = {0, 16 * s, 320, 16 * s + 16}; RECT rc = {0, 16 * s, 320, 16 * s + 16};
CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST); CortBox2(&rc, 0, SURFACE_ID_CREDIT_CAST);
@ -103,13 +103,13 @@ void ActionIllust()
case 0: //Off-screen to the left case 0: //Off-screen to the left
Illust.x = -0x14000; Illust.x = -0x14000;
break; break;
case 1: //Move in from the left case 1: //Move in from the left
Illust.x += 0x5000; Illust.x += 0x5000;
if (Illust.x > 0) if (Illust.x > 0)
Illust.x = 0; Illust.x = 0;
break; break;
case 2: //Move out from the right case 2: //Move out from the right
Illust.x -= 0x5000; Illust.x -= 0x5000;
if (Illust.x < -0x14000) if (Illust.x < -0x14000)
@ -161,7 +161,7 @@ bool StartCreditScript()
free(Credit.pData); free(Credit.pData);
Credit.pData = NULL; Credit.pData = NULL;
} }
//Open file //Open file
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s", gDataPath, "Credit.tsc"); sprintf(path, "%s/%s", gDataPath, "Credit.tsc");
@ -190,21 +190,21 @@ bool StartCreditScript()
// The original game forgot to close the file // The original game forgot to close the file
fclose(fp); fclose(fp);
#endif #endif
//Reset credits //Reset credits
Credit.offset = 0; Credit.offset = 0;
Credit.wait = 0; Credit.wait = 0;
Credit.mode = 1; Credit.mode = 1;
Illust.x = -0x14000; Illust.x = -0x14000;
Illust.act_no = 0; Illust.act_no = 0;
//Modify cliprect //Modify cliprect
grcGame.left = WINDOW_WIDTH / 2; grcGame.left = WINDOW_WIDTH / 2;
// These three are non-vanilla: for wide/tallscreen support // These three are non-vanilla: for wide/tallscreen support
grcGame.right = ((WINDOW_WIDTH - 320) / 2) + 320; grcGame.right = ((WINDOW_WIDTH - 320) / 2) + 320;
grcGame.top = (WINDOW_HEIGHT - 240) / 2; grcGame.top = (WINDOW_HEIGHT - 240) / 2;
grcGame.bottom = ((WINDOW_HEIGHT - 240) / 2) + 240; grcGame.bottom = ((WINDOW_HEIGHT - 240) / 2) + 240;
//Reload casts //Reload casts
if (!ReloadBitmap_File("casts", SURFACE_ID_CASTS)) if (!ReloadBitmap_File("casts", SURFACE_ID_CASTS))
return false; return false;
@ -230,14 +230,14 @@ void ActionCredit_Read()
{ {
//Get character //Get character
uint8_t character = Credit.pData[Credit.offset]; uint8_t character = Credit.pData[Credit.offset];
int a, b, len; int a, b, len;
switch (character) switch (character)
{ {
case '[': //Create cast case '[': //Create cast
//Get the range for the cast text //Get the range for the cast text
a = ++Credit.offset; a = ++Credit.offset;
while (Credit.pData[a] != ']') while (Credit.pData[a] != ']')
{ {
if (IsShiftJIS(Credit.pData[a])) if (IsShiftJIS(Credit.pData[a]))
@ -245,32 +245,32 @@ void ActionCredit_Read()
else else
a++; a++;
} }
len = a - Credit.offset; len = a - Credit.offset;
//Copy the text to the cast text //Copy the text to the cast text
char text[40]; char text[40];
memcpy(text, &Credit.pData[Credit.offset], a - Credit.offset); memcpy(text, &Credit.pData[Credit.offset], a - Credit.offset);
text[len] = 0; text[len] = 0;
//Get cast id //Get cast id
Credit.offset = a + 1; Credit.offset = a + 1;
len = GetScriptNumber(&Credit.pData[a + 1]); len = GetScriptNumber(&Credit.pData[a + 1]);
//Create cast object //Create cast object
SetStripper(Credit.start_x, (WINDOW_HEIGHT << 9) + 0x1000, text, len); SetStripper(Credit.start_x, (WINDOW_HEIGHT << 9) + 0x1000, text, len);
//Change offset //Change offset
Credit.offset += 4; Credit.offset += 4;
return; return;
case 'j': //Jump to label case 'j': //Jump to label
//Get number //Get number
b = GetScriptNumber(&Credit.pData[++Credit.offset]); b = GetScriptNumber(&Credit.pData[++Credit.offset]);
//Change offset //Change offset
Credit.offset += 4; Credit.offset += 4;
//Jump to specific label //Jump to specific label
while (Credit.offset < Credit.size) while (Credit.offset < Credit.size)
{ {
@ -291,21 +291,21 @@ void ActionCredit_Read()
++Credit.offset; ++Credit.offset;
} }
} }
return; return;
case '~': //Start fading out music case '~': //Start fading out music
++Credit.offset; ++Credit.offset;
SetOrganyaFadeout(); SetOrganyaFadeout();
return; return;
case 'f': //Flag jump case 'f': //Flag jump
//Read numbers XXXX:YYYY //Read numbers XXXX:YYYY
a = GetScriptNumber(&Credit.pData[++Credit.offset]); a = GetScriptNumber(&Credit.pData[++Credit.offset]);
Credit.offset += 5; Credit.offset += 5;
b = GetScriptNumber(&Credit.pData[Credit.offset]); b = GetScriptNumber(&Credit.pData[Credit.offset]);
Credit.offset += 4; Credit.offset += 4;
//If flag is set //If flag is set
if (GetNPCFlag(a)) if (GetNPCFlag(a))
{ {
@ -330,29 +330,29 @@ void ActionCredit_Read()
} }
} }
return; return;
case '+': //Change casts x-position case '+': //Change casts x-position
Credit.start_x = GetScriptNumber(&Credit.pData[++Credit.offset]) << 9; Credit.start_x = GetScriptNumber(&Credit.pData[++Credit.offset]) << 9;
Credit.offset += 4; Credit.offset += 4;
return; return;
case '-': //Wait for X amount of frames case '-': //Wait for X amount of frames
Credit.wait = GetScriptNumber(&Credit.pData[++Credit.offset]); Credit.wait = GetScriptNumber(&Credit.pData[++Credit.offset]);
Credit.offset += 4; Credit.offset += 4;
Credit.mode = 2; Credit.mode = 2;
return; return;
case '/': //Stop credits case '/': //Stop credits
Credit.mode = 0; Credit.mode = 0;
return; return;
case '!': //Change music case '!': //Change music
a = GetScriptNumber(&Credit.pData[++Credit.offset]); a = GetScriptNumber(&Credit.pData[++Credit.offset]);
Credit.offset += 4; Credit.offset += 4;
ChangeMusic(a); ChangeMusic(a);
return; return;
} }
//Progress through file //Progress through file
++Credit.offset; ++Credit.offset;
} }
@ -395,19 +395,19 @@ int Scene_DownIsland(int mode)
RECT rc_frame = {(WINDOW_WIDTH - 160) / 2, (WINDOW_HEIGHT - 80) / 2, (WINDOW_WIDTH + 160) / 2, (WINDOW_HEIGHT + 80) / 2}; RECT rc_frame = {(WINDOW_WIDTH - 160) / 2, (WINDOW_HEIGHT - 80) / 2, (WINDOW_WIDTH + 160) / 2, (WINDOW_HEIGHT + 80) / 2};
RECT rc_sky = {0, 0, 160, 80}; RECT rc_sky = {0, 0, 160, 80};
RECT rc_ground = {160, 48, 320, 80}; RECT rc_ground = {160, 48, 320, 80};
//Setup island //Setup island
RECT rc_sprite = {160, 0, 200, 24}; RECT rc_sprite = {160, 0, 200, 24};
ISLAND_SPRITE sprite; ISLAND_SPRITE sprite;
sprite.x = 0x15000; sprite.x = 0x15000;
sprite.y = 0x8000; sprite.y = 0x8000;
for (int wait = 0; wait < 900; wait++) for (int wait = 0; wait < 900; wait++)
{ {
//Get pressed keys //Get pressed keys
GetTrg(); GetTrg();
//Escape menu //Escape menu
if (gKey & 0x8000) if (gKey & 0x8000)
{ {
@ -417,14 +417,14 @@ int Scene_DownIsland(int mode)
if (escRet == 2) if (escRet == 2)
return 2; return 2;
} }
switch (mode) switch (mode)
{ {
case 0: case 0:
//Move down //Move down
sprite.y += 0x33; sprite.y += 0x33;
break; break;
case 1: case 1:
if (wait >= 350) if (wait >= 350)
{ {
@ -455,19 +455,19 @@ int Scene_DownIsland(int mode)
} }
break; break;
} }
//Draw scene //Draw scene
CortBox(&grcFull, 0); CortBox(&grcFull, 0);
PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 80 + (WINDOW_HEIGHT - 240) / 2, &rc_sky, SURFACE_ID_LEVEL_SPRITESET_1); PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 80 + (WINDOW_HEIGHT - 240) / 2, &rc_sky, SURFACE_ID_LEVEL_SPRITESET_1);
PutBitmap3(&rc_frame, sprite.x / 0x200 - 20 + (WINDOW_WIDTH - 320) / 2, sprite.y / 512 - 12 + (WINDOW_HEIGHT - 240) / 2, &rc_sprite, SURFACE_ID_LEVEL_SPRITESET_1); PutBitmap3(&rc_frame, sprite.x / 0x200 - 20 + (WINDOW_WIDTH - 320) / 2, sprite.y / 512 - 12 + (WINDOW_HEIGHT - 240) / 2, &rc_sprite, SURFACE_ID_LEVEL_SPRITESET_1);
PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 128 + (WINDOW_HEIGHT - 240) / 2, &rc_ground, SURFACE_ID_LEVEL_SPRITESET_1); PutBitmap3(&rc_frame, 80 + (WINDOW_WIDTH - 320) / 2, 128 + (WINDOW_HEIGHT - 240) / 2, &rc_ground, SURFACE_ID_LEVEL_SPRITESET_1);
PutTimeCounter(16, 8); PutTimeCounter(16, 8);
//Draw window //Draw window
PutFramePerSecound(); PutFramePerSecound();
if (!Flip_SystemTask()) if (!Flip_SystemTask())
return 0; return 0;
} }
return 1; return 1;
} }

View file

@ -10,12 +10,12 @@
int Call_Escape() int Call_Escape()
{ {
RECT rc = {0, 128, 208, 144}; RECT rc = {0, 128, 208, 144};
while (1) while (1)
{ {
//Get pressed keys //Get pressed keys
GetTrg(); GetTrg();
if (gKeyTrg & KEY_ESCAPE) //Escape is pressed, quit game if (gKeyTrg & KEY_ESCAPE) //Escape is pressed, quit game
{ {
gKeyTrg = 0; gKeyTrg = 0;
@ -31,7 +31,7 @@ int Call_Escape()
gKeyTrg = 0; gKeyTrg = 0;
return 2; return 2;
} }
//Draw screen //Draw screen
CortBox(&grcFull, 0x000000); CortBox(&grcFull, 0x000000);
PutBitmap3(&grcFull, (WINDOW_WIDTH - 208) / 2, (WINDOW_HEIGHT - 16) / 2, &rc, SURFACE_ID_TEXT_BOX); PutBitmap3(&grcFull, (WINDOW_WIDTH - 208) / 2, (WINDOW_HEIGHT - 16) / 2, &rc, SURFACE_ID_TEXT_BOX);
@ -44,6 +44,6 @@ int Call_Escape()
return 0; return 0;
} }
} }
return 0; return 0;
} }

View file

@ -47,7 +47,7 @@ void StartFadeOut(signed char dir)
gFade.count = 0; gFade.count = 0;
gFade.dir = dir; gFade.dir = dir;
gFade.bMask = FALSE; gFade.bMask = FALSE;
for (int y = 0; y < FADE_HEIGHT; y++) for (int y = 0; y < FADE_HEIGHT; y++)
{ {
for (int x = 0; x < FADE_WIDTH; x++) for (int x = 0; x < FADE_WIDTH; x++)
@ -67,7 +67,7 @@ void StartFadeIn(signed char dir)
gFade.count = 0; gFade.count = 0;
gFade.dir = dir; gFade.dir = dir;
gFade.bMask = TRUE; gFade.bMask = TRUE;
for (y = 0; y < FADE_HEIGHT; y++) for (y = 0; y < FADE_HEIGHT; y++)
{ {
for (x = 0; x < FADE_WIDTH; x++) for (x = 0; x < FADE_WIDTH; x++)
@ -100,7 +100,7 @@ void ProcFade()
} }
} }
break; break;
case 2: case 2:
for (y = 0; y < FADE_HEIGHT; y++) for (y = 0; y < FADE_HEIGHT; y++)
{ {
@ -111,7 +111,7 @@ void ProcFade()
} }
} }
break; break;
case 1: case 1:
for (y = 0; y < FADE_HEIGHT; y++) for (y = 0; y < FADE_HEIGHT; y++)
{ {
@ -122,7 +122,7 @@ void ProcFade()
} }
} }
break; break;
case 3: case 3:
for (y = 0; y < FADE_HEIGHT; y++) for (y = 0; y < FADE_HEIGHT; y++)
{ {
@ -133,7 +133,7 @@ void ProcFade()
} }
} }
break; break;
case 4: case 4:
for (y = 0; y < (FADE_HEIGHT / 2); y++) for (y = 0; y < (FADE_HEIGHT / 2); y++)
{ {
@ -169,7 +169,7 @@ void ProcFade()
} }
break; break;
} }
for (y = 0; y < FADE_HEIGHT; y++) for (y = 0; y < FADE_HEIGHT; y++)
{ {
for (x = 0; x < FADE_WIDTH; x++) for (x = 0; x < FADE_WIDTH; x++)
@ -178,7 +178,7 @@ void ProcFade()
++gFade.ani_no[y][x]; ++gFade.ani_no[y][x];
} }
} }
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16) if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
{ {
gFade.bMask = TRUE; gFade.bMask = TRUE;
@ -189,7 +189,7 @@ void ProcFade()
case 1: case 1:
gFade.bMask = FALSE; gFade.bMask = FALSE;
switch (gFade.dir) switch (gFade.dir)
{ {
case 0: case 0:
@ -202,7 +202,7 @@ void ProcFade()
} }
} }
break; break;
case 2: case 2:
for (y = 0; y < FADE_HEIGHT; y++) for (y = 0; y < FADE_HEIGHT; y++)
{ {
@ -213,7 +213,7 @@ void ProcFade()
} }
} }
break; break;
case 1: case 1:
for (y = 0; y < FADE_HEIGHT; y++) for (y = 0; y < FADE_HEIGHT; y++)
{ {
@ -224,7 +224,7 @@ void ProcFade()
} }
} }
break; break;
case 3: case 3:
for (y = 0; y < FADE_HEIGHT; y++) for (y = 0; y < FADE_HEIGHT; y++)
{ {
@ -235,7 +235,7 @@ void ProcFade()
} }
} }
break; break;
case 4: case 4:
for (y = 0; y < (FADE_HEIGHT / 2); y++) for (y = 0; y < (FADE_HEIGHT / 2); y++)
{ {
@ -271,7 +271,7 @@ void ProcFade()
} }
break; break;
} }
for (y = 0; y < FADE_HEIGHT; y++) for (y = 0; y < FADE_HEIGHT; y++)
{ {
for (x = 0; x < FADE_WIDTH; x++) for (x = 0; x < FADE_WIDTH; x++)
@ -280,7 +280,7 @@ void ProcFade()
--gFade.ani_no[y][x]; --gFade.ani_no[y][x];
} }
} }
if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16) if (++gFade.count > ((FADE_WIDTH > FADE_HEIGHT) ? FADE_WIDTH : FADE_HEIGHT) + 16)
gFade.mode = 0; gFade.mode = 0;
@ -293,7 +293,7 @@ void PutFade()
RECT rect; RECT rect;
rect.top = 0; rect.top = 0;
rect.bottom = 16; rect.bottom = 16;
if (gFade.bMask) if (gFade.bMask)
{ {
CortBox(&grcGame, mask_color); CortBox(&grcGame, mask_color);

View file

@ -121,10 +121,10 @@ void SetFramePosition(int fx, int fy)
//Move frame position //Move frame position
int16_t map_w, map_l; int16_t map_w, map_l;
GetMapData(0, &map_w, &map_l); GetMapData(0, &map_w, &map_l);
gFrame.x = fx; gFrame.x = fx;
gFrame.y = fy; gFrame.y = fy;
//Keep in bounds //Keep in bounds
if (gFrame.x / 0x200 < 0) if (gFrame.x / 0x200 < 0)
gFrame.x = 0; gFrame.x = 0;
@ -142,19 +142,19 @@ void SetFrameMyChar()
//Move frame position //Move frame position
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; int16_t 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);
gFrame.y = mc_y - (WINDOW_HEIGHT << 8); gFrame.y = mc_y - (WINDOW_HEIGHT << 8);
//Keep in bounds //Keep in bounds
if (gFrame.x / 0x200 < 0) if (gFrame.x / 0x200 < 0)
gFrame.x = 0; gFrame.x = 0;
if (gFrame.y / 0x200 < 0) if (gFrame.y / 0x200 < 0)
gFrame.y = 0; gFrame.y = 0;
if (gFrame.x > ((((map_w - 1) * 0x10) - WINDOW_WIDTH)) * 0x200) if (gFrame.x > ((((map_w - 1) * 0x10) - WINDOW_WIDTH)) * 0x200)
gFrame.x = (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200; gFrame.x = (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200;
if (gFrame.y > ((((map_l - 1) * 0x10) - WINDOW_HEIGHT)) * 0x200) if (gFrame.y > ((((map_l - 1) * 0x10) - WINDOW_HEIGHT)) * 0x200)

View file

@ -60,7 +60,7 @@ 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] = {
{0, 56, 8, 64}, {0, 56, 8, 64},
{8, 56, 16, 64}, {8, 56, 16, 64},
@ -73,14 +73,14 @@ void PutNumber4(int x, int y, int value, bool bZero)
{64, 56, 72, 64}, {64, 56, 72, 64},
{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;
@ -88,18 +88,18 @@ void PutNumber4(int x, int y, int value, bool bZero)
{ {
//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)
{ {
value -= tbl[offset]; value -= tbl[offset];
++a; ++a;
++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;
} }
@ -117,7 +117,7 @@ int ModeOpening()
TransferStage(72, 100, 3, 3); TransferStage(72, 100, 3, 3);
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(?)
@ -126,18 +126,18 @@ int ModeOpening()
grcGame.bottom = WINDOW_HEIGHT; grcGame.bottom = WINDOW_HEIGHT;
g_GameFlags = 3; g_GameFlags = 3;
CutNoise(); CutNoise();
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)
{ {
@ -147,11 +147,11 @@ int ModeOpening()
if (escRet == 2) if (escRet == 2)
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();
@ -166,10 +166,10 @@ int ModeOpening()
ActCaret(); ActCaret();
MoveFrame3(); MoveFrame3();
ProcFade(); ProcFade();
//Draw everything //Draw everything
CortBox(&grcFull, 0x000000); CortBox(&grcFull, 0x000000);
int frame_x, frame_y; int frame_x, frame_y;
GetFramePosition(&frame_x, &frame_y); GetFramePosition(&frame_x, &frame_y);
PutBack(frame_x, frame_y); PutBack(frame_x, frame_y);
@ -181,24 +181,24 @@ int ModeOpening()
PutFront(frame_x, frame_y); PutFront(frame_x, frame_y);
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;
if (tscRet == 2) if (tscRet == 2)
return 1; return 1;
PutMapName(false); PutMapName(false);
PutTextScript(); PutTextScript();
PutFramePerSecound(); PutFramePerSecound();
if (!Flip_SystemTask()) if (!Flip_SystemTask())
return 0; return 0;
++gCounter; ++gCounter;
} }
wait = SDL_GetTicks(); wait = SDL_GetTicks();
while (SDL_GetTicks() < wait + 500) while (SDL_GetTicks() < wait + 500)
{ {
@ -215,13 +215,13 @@ 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};
RECT rcNew = {144, 0, 192, 16}; RECT rcNew = {144, 0, 192, 16};
RECT rcContinue = {144, 16, 192, 32}; RECT rcContinue = {144, 16, 192, 32};
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},
@ -236,45 +236,45 @@ int ModeTitle()
{0, 112, 16, 128}, {0, 112, 16, 128},
{32, 112, 48, 128}, {32, 112, 48, 128},
}; };
RECT rcToroko[4] = { RECT rcToroko[4] = {
{64, 80, 80, 96}, {64, 80, 80, 96},
{80, 80, 96, 96}, {80, 80, 96, 96},
{64, 80, 80, 96}, {64, 80, 80, 96},
{96, 80, 112, 96}, {96, 80, 112, 96},
}; };
RECT rcKing[4] = { RECT rcKing[4] = {
{224, 48, 240, 64}, {224, 48, 240, 64},
{288, 48, 304, 64}, {288, 48, 304, 64},
{224, 48, 240, 64}, {224, 48, 240, 64},
{304, 48, 320, 64}, {304, 48, 320, 64},
}; };
RECT rcSu[4] = { RECT rcSu[4] = {
{0, 16, 16, 32}, {0, 16, 16, 32},
{32, 16, 48, 32}, {32, 16, 48, 32},
{0, 16, 16, 32}, {0, 16, 16, 32},
{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 < 18000) if (time_counter && time_counter < 18000)
char_type = 1; char_type = 1;
if (time_counter && time_counter < 15000) if (time_counter && time_counter < 15000)
@ -283,7 +283,7 @@ int ModeTitle()
char_type = 3; char_type = 3;
if (time_counter && time_counter < 9000) if (time_counter && time_counter < 9000)
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)
{ {
@ -303,7 +303,7 @@ int ModeTitle()
ChangeMusic(mus_CaveStory); ChangeMusic(mus_CaveStory);
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(?)
@ -313,26 +313,26 @@ 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)
break; break;
} }
if (gKey & KEY_ESCAPE) if (gKey & KEY_ESCAPE)
{ {
int escRet = Call_Escape(); int escRet = Call_Escape();
@ -341,45 +341,45 @@ int ModeTitle()
if (escRet == 2) if (escRet == 2)
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);
int v1, v2, v3, v4; int v1, v2, v3, v4;
GetCompileVersion(&v1, &v2, &v3, &v4); GetCompileVersion(&v1, &v2, &v3, &v4);
PutNumber4((WINDOW_WIDTH - 40) / 2, WINDOW_HEIGHT - 24, v1, 0); PutNumber4((WINDOW_WIDTH - 40) / 2, WINDOW_HEIGHT - 24, v1, 0);
PutNumber4((WINDOW_WIDTH - 8) / 2, WINDOW_HEIGHT - 24, v2, 0); PutNumber4((WINDOW_WIDTH - 8) / 2, WINDOW_HEIGHT - 24, v2, 0);
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:
@ -403,30 +403,30 @@ int ModeTitle()
char_surf = SURFACE_ID_NPC_REGU; char_surf = SURFACE_ID_NPC_REGU;
break; break;
} }
int char_y; int char_y;
if (bContinue == 1) if (bContinue == 1)
char_y = (WINDOW_HEIGHT + 54) / 2; char_y = (WINDOW_HEIGHT + 54) / 2;
else else
char_y = (WINDOW_HEIGHT + 14) / 2; char_y = (WINDOW_HEIGHT + 14) / 2;
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)
PutTimeCounter(16, 8); PutTimeCounter(16, 8);
PutFramePerSecound(); PutFramePerSecound();
if (!Flip_SystemTask()) if (!Flip_SystemTask())
return 0; return 0;
} }
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)
@ -436,7 +436,7 @@ int ModeTitle()
if (!Flip_SystemTask()) if (!Flip_SystemTask())
return 0; return 0;
} }
return 3; return 3;
} }
@ -448,12 +448,12 @@ int ModeAction()
unsigned long color = GetCortBoxColor(RGB(0, 0, 0x20)); unsigned long color = GetCortBoxColor(RGB(0, 0, 0x20));
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();
@ -468,14 +468,14 @@ int ModeAction()
StartMapping(); StartMapping();
InitFlags(); InitFlags();
InitBossLife(); InitBossLife();
if ((bContinue && LoadProfile(NULL)) || InitializeGame()) if ((bContinue && LoadProfile(NULL)) || InitializeGame())
{ {
while (true) while (true)
{ {
//Get pressed keys //Get pressed keys
GetTrg(); GetTrg();
//Escape menu //Escape menu
if (gKey & KEY_ESCAPE) if (gKey & KEY_ESCAPE)
{ {
@ -485,14 +485,14 @@ int ModeAction()
if (escRet == 2) if (escRet == 2)
return 1; return 1;
} }
if (swPlay & 1 && g_GameFlags & 1) if (swPlay & 1 && g_GameFlags & 1)
{ {
if (g_GameFlags & 2) if (g_GameFlags & 2)
ActMyChar(true); ActMyChar(true);
else else
ActMyChar(false); ActMyChar(false);
ActStar(); ActStar();
ActNpChar(); ActNpChar();
ActBossChar(); ActBossChar();
@ -513,20 +513,20 @@ int ModeAction()
ActCaret(); ActCaret();
MoveFrame3(); MoveFrame3();
ActFlash(frame_x, frame_y); ActFlash(frame_x, frame_y);
if (g_GameFlags & 2) if (g_GameFlags & 2)
AnimationMyChar(true); AnimationMyChar(true);
else else
AnimationMyChar(false); AnimationMyChar(false);
} }
if (g_GameFlags & 8) if (g_GameFlags & 8)
{ {
ActionCredit(); ActionCredit();
ActionIllust(); ActionIllust();
ActionStripper(); ActionStripper();
} }
ProcFade(); ProcFade();
CortBox(&grcFull, color); CortBox(&grcFull, color);
GetFramePosition(&frame_x, &frame_y); GetFramePosition(&frame_x, &frame_y);
@ -545,14 +545,14 @@ int ModeAction()
PutValueView(frame_x, frame_y); PutValueView(frame_x, frame_y);
PutBossLife(); PutBossLife();
PutFade(); PutFade();
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);
switch (CampLoop()) switch (CampLoop())
{ {
case 0: case 0:
@ -560,13 +560,13 @@ int ModeAction()
case 2: case 2:
return 1; return 1;
} }
gMC.cond &= ~1; gMC.cond &= ~1;
} }
else if (gMC.equip & 2 && gKeyTrg & gKeyMap) else if (gMC.equip & 2 && gKeyTrg & gKeyMap)
{ {
BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcGame); BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcGame);
switch (MiniMapLoop()) switch (MiniMapLoop())
{ {
case 0: case 0:
@ -576,7 +576,7 @@ int ModeAction()
} }
} }
} }
if (g_GameFlags & 2) if (g_GameFlags & 2)
{ {
if (gKeyTrg & gKeyArms) if (gKeyTrg & gKeyArms)
@ -593,10 +593,10 @@ int ModeAction()
if (tscRet == 2) if (tscRet == 2)
return 1; return 1;
} }
PutMapName(false); PutMapName(false);
PutTimeCounter(16, 8); PutTimeCounter(16, 8);
if (g_GameFlags & 2) if (g_GameFlags & 2)
{ {
PutMyLife(true); PutMyLife(true);
@ -604,22 +604,22 @@ int ModeAction()
PutMyAir((WINDOW_WIDTH - 80) / 2, (WINDOW_HEIGHT - 32) / 2); PutMyAir((WINDOW_WIDTH - 80) / 2, (WINDOW_HEIGHT - 32) / 2);
PutActiveArmsList(); PutActiveArmsList();
} }
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;
} }
} }
return 0; return 0;
} }
@ -629,14 +629,14 @@ bool Game()
{ {
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/npc.tbl", gDataPath); sprintf(path, "%s/npc.tbl", gDataPath);
if (LoadNpcTable(path)) if (LoadNpcTable(path))
{ {
InitTextScript2(); InitTextScript2();
InitSkipFlags(); InitSkipFlags();
InitMapData2(); InitMapData2();
InitCreditScript(); InitCreditScript();
int mode = 1; int mode = 1;
while (mode) while (mode)
{ {
@ -647,7 +647,7 @@ bool Game()
if (mode == 3) if (mode == 3)
mode = ModeAction(); mode = ModeAction();
} }
EndMapData(); EndMapData();
EndTextScript(); EndTextScript();
ReleaseNpcTable(); ReleaseNpcTable();
@ -658,6 +658,6 @@ bool Game()
return false; return false;
} }
} }
return true; return true;
} }

View file

@ -34,14 +34,14 @@ bool CheckFileExists(const char *name)
{ {
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s", gModulePath, name); sprintf(path, "%s/%s", gModulePath, name);
FILE *file = fopen(path, "rb"); FILE *file = fopen(path, "rb");
if (file) if (file)
{ {
fclose(file); fclose(file);
return true; return true;
} }
return false; return false;
} }

View file

@ -160,7 +160,7 @@ BOOL LoadGenericData()
int pt_size; int pt_size;
MakeSurface_Resource("PIXEL", SURFACE_ID_PIXEL); MakeSurface_Resource("PIXEL", SURFACE_ID_PIXEL);
bError = FALSE; bError = FALSE;
if (!MakeSurface_File("MyChar", SURFACE_ID_MY_CHAR)) if (!MakeSurface_File("MyChar", SURFACE_ID_MY_CHAR))
bError = TRUE; bError = TRUE;
@ -188,9 +188,9 @@ BOOL LoadGenericData()
bError = TRUE; bError = TRUE;
if (!MakeSurface_File("Fade", SURFACE_ID_FADE)) if (!MakeSurface_File("Fade", SURFACE_ID_FADE))
bError = TRUE; bError = TRUE;
MakeSurface_Resource("CREDIT01", SURFACE_ID_CREDITS_IMAGE); MakeSurface_Resource("CREDIT01", SURFACE_ID_CREDITS_IMAGE);
if (bError) if (bError)
{ {
return FALSE; return FALSE;

View file

@ -31,16 +31,16 @@ 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;
} }
return true; return true;
} }
@ -48,7 +48,7 @@ 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); int32_t x = SDL_JoystickGetAxis(joystick, 0);
@ -57,17 +57,17 @@ bool GetJoystickStatus(JOYSTICK_STATUS *pStatus)
pStatus->bRight = x >= JOYSTICK_DEADZONE; pStatus->bRight = x >= JOYSTICK_DEADZONE;
pStatus->bUp = y <= -JOYSTICK_DEADZONE; pStatus->bUp = y <= -JOYSTICK_DEADZONE;
pStatus->bDown = y >= JOYSTICK_DEADZONE; pStatus->bDown = y >= JOYSTICK_DEADZONE;
int numButtons = SDL_JoystickNumButtons(joystick); int numButtons = SDL_JoystickNumButtons(joystick);
if (numButtons > 32) if (numButtons > 32)
numButtons = 32; numButtons = 32;
for (int button = 0; button < numButtons; button++) for (int button = 0; button < numButtons; button++)
pStatus->bButton[button] = SDL_JoystickGetButton(joystick, button) != 0; pStatus->bButton[button] = SDL_JoystickGetButton(joystick, button) != 0;
return true; return true;
} }
return false; return false;
} }

View file

@ -78,17 +78,17 @@ int GetFramePerSecound()
base_tick = SDL_GetTicks(); base_tick = SDL_GetTicks();
need_new_base_tick = false; need_new_base_tick = false;
} }
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;
current_frame = 0; current_frame = 0;
} }
return frames_this_second; return frames_this_second;
} }
@ -98,7 +98,7 @@ int main(int argc, char *argv[])
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");
@ -114,10 +114,10 @@ int main(int argc, char *argv[])
{ {
//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)
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
gKeyJump = KEY_Z; gKeyJump = KEY_Z;
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)
{ {
@ -148,14 +148,14 @@ int main(int argc, char *argv[])
gKeyOk = gKeyJump; gKeyOk = gKeyJump;
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)
{ {
@ -174,7 +174,7 @@ int main(int argc, char *argv[])
gKeyRight = KEY_RIGHT; gKeyRight = KEY_RIGHT;
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++)
{ {
@ -183,38 +183,38 @@ int main(int argc, char *argv[])
case 1: case 1:
gJoystickButtonTable[i] = gKeyJump; gJoystickButtonTable[i] = gKeyJump;
break; break;
case 2: case 2:
gJoystickButtonTable[i] = gKeyShot; gJoystickButtonTable[i] = gKeyShot;
break; break;
case 3: case 3:
gJoystickButtonTable[i] = gKeyArms; gJoystickButtonTable[i] = gKeyArms;
break; break;
case 6: case 6:
gJoystickButtonTable[i] = gKeyArmsRev; gJoystickButtonTable[i] = gKeyArmsRev;
break; break;
case 4: case 4:
gJoystickButtonTable[i] = gKeyItem; gJoystickButtonTable[i] = gKeyItem;
break; break;
case 5: case 5:
gJoystickButtonTable[i] = gKeyMap; gJoystickButtonTable[i] = gKeyMap;
break; break;
default: default:
continue; continue;
} }
} }
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);
if (data) if (data)
{ {
SDL_RWops *fp = SDL_RWFromConstMem(data, size); SDL_RWops *fp = SDL_RWFromConstMem(data, size);
@ -240,7 +240,7 @@ int main(int argc, char *argv[])
int windowWidth; int windowWidth;
int windowHeight; int windowHeight;
int colourDepth; int colourDepth;
switch (config.display_mode) switch (config.display_mode)
{ {
case 1: case 1:
@ -256,10 +256,10 @@ int main(int argc, char *argv[])
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)
{ {
if (config.display_mode == 1) if (config.display_mode == 1)
@ -268,19 +268,19 @@ int main(int argc, char *argv[])
StartDirectDraw(1, 0); StartDirectDraw(1, 0);
break; break;
} }
break; break;
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
@ -296,30 +296,30 @@ int main(int argc, char *argv[])
colourDepth = 32; colourDepth = 32;
break; break;
} }
StartDirectDraw(2, colourDepth); StartDirectDraw(2, colourDepth);
fullscreen = true; fullscreen = true;
SDL_ShowCursor(0); SDL_ShowCursor(0);
break; break;
} }
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);
if (data) if (data)
{ {
SDL_RWops *fp = SDL_RWFromConstMem(data, size); SDL_RWops *fp = SDL_RWFromConstMem(data, size);
@ -341,34 +341,34 @@ int main(int argc, char *argv[])
//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();
@ -381,7 +381,7 @@ int main(int argc, char *argv[])
SDL_Quit(); SDL_Quit();
return -1; return -1;
} }
SDL_Quit(); SDL_Quit();
return 0; return 0;
} }
@ -394,7 +394,7 @@ void InactiveWindow()
StopOrganyaMusic(); StopOrganyaMusic();
SleepNoise(); SleepNoise();
} }
PlaySoundObject(7, 0); PlaySoundObject(7, 0);
} }
@ -414,12 +414,12 @@ void ActiveWindow()
void JoystickProc() void JoystickProc()
{ {
JOYSTICK_STATUS status; JOYSTICK_STATUS status;
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;
@ -429,7 +429,7 @@ void JoystickProc()
gKey |= gKeyUp; gKey |= gKeyUp;
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++)
{ {
@ -450,18 +450,18 @@ bool SystemTask()
{ {
//Handle window events //Handle window events
bool focusGained = true; bool focusGained = true;
while (SDL_PollEvent(NULL) || !focusGained) while (SDL_PollEvent(NULL) || !focusGained)
{ {
SDL_Event event; SDL_Event event;
SDL_WaitEvent(&event); SDL_WaitEvent(&event);
switch (event.type) switch (event.type)
{ {
case SDL_QUIT: case SDL_QUIT:
return false; return false;
break; break;
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
switch (event.window.event) switch (event.window.event)
{ {
@ -469,22 +469,22 @@ bool SystemTask()
focusGained = true; focusGained = true;
ActiveWindow(); ActiveWindow();
break; break;
case SDL_WINDOWEVENT_FOCUS_LOST: case SDL_WINDOWEVENT_FOCUS_LOST:
focusGained = false; focusGained = false;
InactiveWindow(); InactiveWindow();
break; break;
default: default:
break; break;
} }
break; break;
case SDL_DROPFILE: case SDL_DROPFILE:
LoadProfile(event.drop.file); LoadProfile(event.drop.file);
SDL_free(event.drop.file); SDL_free(event.drop.file);
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
case SDL_KEYUP: case SDL_KEYUP:
#ifdef FIX_BUGS #ifdef FIX_BUGS
@ -552,7 +552,7 @@ bool SystemTask()
case SDL_SCANCODE_SEMICOLON: case SDL_SCANCODE_SEMICOLON:
DO_KEY_PRESS(KEY_PLUS) DO_KEY_PRESS(KEY_PLUS)
case SDL_SCANCODE_F5: case SDL_SCANCODE_F5:
gbUseJoystick = false; gbUseJoystick = false;
break; break;
@ -621,7 +621,7 @@ bool SystemTask()
case SDLK_SEMICOLON: case SDLK_SEMICOLON:
DO_KEY_PRESS(KEY_PLUS) DO_KEY_PRESS(KEY_PLUS)
case SDLK_F5: case SDLK_F5:
gbUseJoystick = false; gbUseJoystick = false;
break; break;
@ -630,10 +630,10 @@ bool SystemTask()
#endif #endif
} }
} }
//Run joystick code //Run joystick code
if (gbUseJoystick) if (gbUseJoystick)
JoystickProc(); JoystickProc();
return true; return true;
} }

View file

@ -78,10 +78,10 @@ void ReadyMapName(const char *str)
str = (char*)presentText; str = (char*)presentText;
} }
//Copy map's name to the MapName //Copy map's name to the MapName
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);
@ -125,7 +125,7 @@ void StartMapName()
void RestoreMapName() void RestoreMapName()
{ {
int len = (int)strlen(gMapName.name); int len = (int)strlen(gMapName.name);
CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME); CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
PutText2((160 - 6 * len) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME); PutText2((160 - 6 * len) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
PutText2((160 - 6 * len) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME); PutText2((160 - 6 * len) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);

View file

@ -29,7 +29,7 @@ void WriteMiniMapLine(int line)
{242, 24, 243, 25}, {242, 24, 243, 25},
{243, 24, 244, 25}, {243, 24, 244, 25},
}; };
for (x = 0; x < gMap.width; x++) for (x = 0; x < gMap.width; x++)
{ {
a = GetAttribute(x, line); a = GetAttribute(x, line);
@ -84,12 +84,12 @@ int MiniMapLoop()
RECT my_rect = {0, 57, 1, 58}; RECT my_rect = {0, 57, 1, 58};
int my_x = (gMC.x / 0x200 + 8) / 16; int my_x = (gMC.x / 0x200 + 8) / 16;
int my_y = (gMC.y / 0x200 + 8) / 16; int my_y = (gMC.y / 0x200 + 8) / 16;
RECT rcView; RECT rcView;
for (f = 0; f <= 8; f++) for (f = 0; f <= 8; f++)
{ {
GetTrg(); GetTrg();
if (gKey & KEY_ESCAPE) if (gKey & KEY_ESCAPE)
{ {
switch (Call_Escape()) switch (Call_Escape())
@ -100,9 +100,9 @@ int MiniMapLoop()
return 2; return 2;
} }
} }
PutBitmap4(&grcGame, 0, 0, &grcGame, SURFACE_ID_SCREEN_GRAB); PutBitmap4(&grcGame, 0, 0, &grcGame, SURFACE_ID_SCREEN_GRAB);
rcView.left = (WINDOW_WIDTH / 2) - gMap.width * f / 8 / 2; rcView.left = (WINDOW_WIDTH / 2) - gMap.width * f / 8 / 2;
rcView.right = (WINDOW_WIDTH / 2) + gMap.width * f / 8 / 2; rcView.right = (WINDOW_WIDTH / 2) + gMap.width * f / 8 / 2;
rcView.top = (WINDOW_HEIGHT / 2) - gMap.length * f / 8 / 2; rcView.top = (WINDOW_HEIGHT / 2) - gMap.length * f / 8 / 2;
@ -110,12 +110,12 @@ int MiniMapLoop()
PutMapName(true); PutMapName(true);
CortBox(&rcView, 0); CortBox(&rcView, 0);
PutFramePerSecound(); PutFramePerSecound();
if (!Flip_SystemTask()) if (!Flip_SystemTask())
return 0; return 0;
} }
RECT rcMiniMap; RECT rcMiniMap;
rcMiniMap.left = 0; rcMiniMap.left = 0;
rcMiniMap.right = gMap.width; rcMiniMap.right = gMap.width;
@ -125,16 +125,16 @@ int MiniMapLoop()
rcView.right = --rcView.left + gMap.width + 2; rcView.right = --rcView.left + gMap.width + 2;
rcView.bottom = --rcView.top + gMap.length + 2; rcView.bottom = --rcView.top + gMap.length + 2;
CortBox2(&rcMiniMap, 0, SURFACE_ID_MAP); CortBox2(&rcMiniMap, 0, SURFACE_ID_MAP);
int line = 0; int line = 0;
uint8_t my_wait = 0; uint8_t my_wait = 0;
while (true) while (true)
{ {
GetTrg(); GetTrg();
if ((gKeyCancel | gKeyOk) & gKeyTrg) if ((gKeyCancel | gKeyOk) & gKeyTrg)
break; break;
if (gKey & KEY_ESCAPE) if (gKey & KEY_ESCAPE)
{ {
switch (Call_Escape()) switch (Call_Escape())
@ -145,10 +145,10 @@ int MiniMapLoop()
return 2; return 2;
} }
} }
PutBitmap4(&grcGame, 0, 0, &grcGame, SURFACE_ID_SCREEN_GRAB); PutBitmap4(&grcGame, 0, 0, &grcGame, SURFACE_ID_SCREEN_GRAB);
CortBox(&rcView, 0); CortBox(&rcView, 0);
if (line < gMap.length) if (line < gMap.length)
{ {
WriteMiniMapLine(line); WriteMiniMapLine(line);
@ -161,17 +161,17 @@ int MiniMapLoop()
} }
PutBitmap3(&grcGame, rcView.left + 1, rcView.top + 1, &rcMiniMap, SURFACE_ID_MAP); PutBitmap3(&grcGame, rcView.left + 1, rcView.top + 1, &rcMiniMap, SURFACE_ID_MAP);
PutMapName(true); PutMapName(true);
if (++my_wait / 8 % 2) if (++my_wait / 8 % 2)
PutBitmap3(&grcGame, my_x + rcView.left + 1, my_y + rcView.top + 1, &my_rect, SURFACE_ID_TEXT_BOX); PutBitmap3(&grcGame, my_x + rcView.left + 1, my_y + rcView.top + 1, &my_rect, SURFACE_ID_TEXT_BOX);
PutFramePerSecound(); PutFramePerSecound();
if (!Flip_SystemTask()) if (!Flip_SystemTask())
return 0; return 0;
} }
for (f = 8; f >= -1; --f) for (f = 8; f >= -1; --f)
{ {
GetTrg(); GetTrg();

View file

@ -87,28 +87,28 @@ void AnimationMyChar(bool bKey)
else if (gKey & gKeyUp && (gKeyRight | gKeyLeft) & gKey && bKey) else if (gKey & gKeyUp && (gKeyRight | gKeyLeft) & gKey && bKey)
{ {
gMC.cond |= 4; gMC.cond |= 4;
if (++gMC.ani_wait > 4) if (++gMC.ani_wait > 4)
{ {
gMC.ani_wait = 0; gMC.ani_wait = 0;
if (++gMC.ani_no == 7 || gMC.ani_no == 9) if (++gMC.ani_no == 7 || gMC.ani_no == 9)
PlaySoundObject(24, 1); PlaySoundObject(24, 1);
} }
if (gMC.ani_no > 9 || gMC.ani_no < 6) if (gMC.ani_no > 9 || gMC.ani_no < 6)
gMC.ani_no = 6; gMC.ani_no = 6;
} }
else if ((gKeyRight | gKeyLeft) & gKey && bKey) else if ((gKeyRight | gKeyLeft) & gKey && bKey)
{ {
gMC.cond |= 4; gMC.cond |= 4;
if (++gMC.ani_wait > 4) if (++gMC.ani_wait > 4)
{ {
gMC.ani_wait = 0; gMC.ani_wait = 0;
if (++gMC.ani_no == 2 || gMC.ani_no == 4) if (++gMC.ani_no == 2 || gMC.ani_no == 4)
PlaySoundObject(24, 1); PlaySoundObject(24, 1);
} }
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;
} }
@ -116,7 +116,7 @@ void AnimationMyChar(bool bKey)
{ {
if (gMC.cond & 4) if (gMC.cond & 4)
PlaySoundObject(24, 1); PlaySoundObject(24, 1);
gMC.cond &= ~4; gMC.cond &= ~4;
gMC.ani_no = 5; gMC.ani_no = 5;
} }
@ -124,7 +124,7 @@ void AnimationMyChar(bool bKey)
{ {
if (gMC.cond & 4) if (gMC.cond & 4)
PlaySoundObject(24, 1); PlaySoundObject(24, 1);
gMC.cond &= ~4; gMC.cond &= ~4;
gMC.ani_no = 0; gMC.ani_no = 0;
} }
@ -145,7 +145,7 @@ void AnimationMyChar(bool bKey)
{ {
gMC.ani_no = 1; gMC.ani_no = 1;
} }
if (gMC.direct) if (gMC.direct)
gMC.rect = rcRight[gMC.ani_no]; gMC.rect = rcRight[gMC.ani_no];
else else
@ -170,13 +170,13 @@ void PutMyChar(int fx, int fy)
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);
gMC.rect_arms.bottom = gMC.rect_arms.top + 16; gMC.rect_arms.bottom = gMC.rect_arms.top + 16;
if (gMC.direct == 2) if (gMC.direct == 2)
{ {
gMC.rect_arms.top += 16; gMC.rect_arms.top += 16;
gMC.rect_arms.bottom += 16; gMC.rect_arms.bottom += 16;
} }
int arms_offset_y; int arms_offset_y;
if (gMC.up) if (gMC.up)
{ {
@ -194,10 +194,10 @@ void PutMyChar(int fx, int fy)
{ {
arms_offset_y = 0; arms_offset_y = 0;
} }
if (gMC.ani_no == 1 || gMC.ani_no == 3 || gMC.ani_no == 6 || gMC.ani_no == 8) if (gMC.ani_no == 1 || gMC.ani_no == 3 || gMC.ani_no == 6 || gMC.ani_no == 8)
++gMC.rect_arms.top; ++gMC.rect_arms.top;
if (gMC.direct) if (gMC.direct)
PutBitmap3( PutBitmap3(
&grcGame, &grcGame,
@ -212,7 +212,7 @@ void PutMyChar(int fx, int fy)
(gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200 + arms_offset_y,
&gMC.rect_arms, &gMC.rect_arms,
SURFACE_ID_ARMS); SURFACE_ID_ARMS);
if (!((gMC.shock >> 1) & 1)) if (!((gMC.shock >> 1) & 1))
{ {
//Draw player //Draw player
@ -222,15 +222,15 @@ void PutMyChar(int fx, int fy)
rect.top += 32; rect.top += 32;
rect.bottom += 32; rect.bottom += 32;
} }
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 airtank
RECT rcBubble[2] = { RECT rcBubble[2] = {
{56, 96, 80, 120}, {56, 96, 80, 120},
{80, 96, 104, 120}, {80, 96, 104, 120},
}; };
++gMC.bubble; ++gMC.bubble;
if (gMC.equip & 0x10 && gMC.flag & 0x100) if (gMC.equip & 0x10 && gMC.flag & 0x100)
PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble >> 1) & 1], SURFACE_ID_CARET); PutBitmap3(&grcGame, gMC.x / 0x200 - 12 - fx / 0x200, gMC.y / 0x200 - 12 - fy / 0x200, &rcBubble[(gMC.bubble >> 1) & 1], SURFACE_ID_CARET);
@ -252,7 +252,7 @@ void ActMyChar_Normal(bool bKey)
int dash1; int dash1;
int dash2; int dash2;
int resist; int resist;
if (gMC.flag & 0x100) if (gMC.flag & 0x100)
{ {
max_dash = 0x196; max_dash = 0x196;
@ -273,20 +273,20 @@ void ActMyChar_Normal(bool bKey)
dash2 = 0x20; dash2 = 0x20;
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)
{ {
gMC.boost_cnt = 50; gMC.boost_cnt = 50;
@ -299,7 +299,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)
{ {
@ -311,7 +311,7 @@ void ActMyChar_Normal(bool bKey)
gMC.xm -= dash1; gMC.xm -= dash1;
if (gKey & gKeyRight && gMC.xm < max_dash) if (gKey & gKeyRight && gMC.xm < max_dash)
gMC.xm += dash1; gMC.xm += dash1;
if (gKey & gKeyLeft) if (gKey & gKeyLeft)
gMC.direct = 0; gMC.direct = 0;
if (gKey & gKeyRight) if (gKey & gKeyRight)
@ -324,7 +324,7 @@ void ActMyChar_Normal(bool bKey)
gMC.ques = 1; gMC.ques = 1;
} }
} }
//Friction //Friction
if (!(gMC.cond & 0x20)) if (!(gMC.cond & 0x20))
{ {
@ -358,7 +358,7 @@ void ActMyChar_Normal(bool bKey)
if (gMC.ym > 0x100) if (gMC.ym > 0x100)
gMC.ym /= 2; gMC.ym /= 2;
} }
//Booster 2.0 //Booster 2.0
if (gMC.equip & 0x20) if (gMC.equip & 0x20)
{ {
@ -394,19 +394,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))
{ {
@ -415,19 +415,19 @@ void ActMyChar_Normal(bool bKey)
else if (gMC.boost_sw == 2) else if (gMC.boost_sw == 2)
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);
if (gKeyTrg & gKeyJump if (gKeyTrg & gKeyJump
&& (gMC.flag & 8 || gMC.flag & 0x10 || gMC.flag & 0x20) && (gMC.flag & 8 || gMC.flag & 0x10 || gMC.flag & 0x20)
&& !(gMC.flag & 0x2000)) && !(gMC.flag & 0x2000))
@ -436,15 +436,15 @@ void ActMyChar_Normal(bool bKey)
PlaySoundObject(15, 1); PlaySoundObject(15, 1);
} }
} }
//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;
@ -454,7 +454,7 @@ void ActMyChar_Normal(bool bKey)
gMC.xm += 0x88; gMC.xm += 0x88;
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)
{ {
@ -463,13 +463,13 @@ void ActMyChar_Normal(bool bKey)
//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)
{ {
@ -477,7 +477,7 @@ void ActMyChar_Normal(bool bKey)
SetCaret(gMC.x + 0x400, gMC.y + 0x400, 7, 2); SetCaret(gMC.x + 0x400, gMC.y + 0x400, 7, 2);
if (gMC.direct == 2) if (gMC.direct == 2)
SetCaret(gMC.x - 0x400, gMC.y + 0x400, 7, 0); SetCaret(gMC.x - 0x400, gMC.y + 0x400, 7, 0);
PlaySoundObject(113, 1); PlaySoundObject(113, 1);
} }
} }
@ -485,7 +485,7 @@ void ActMyChar_Normal(bool bKey)
{ {
//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)
{ {
@ -510,13 +510,13 @@ void ActMyChar_Normal(bool bKey)
{ {
//Upwards force //Upwards force
gMC.ym -= 0x20; gMC.ym -= 0x20;
if (!(gMC.boost_cnt % 3)) if (!(gMC.boost_cnt % 3))
{ {
SetCaret(gMC.x, gMC.hit.bottom / 2 + gMC.y, 7, 3); SetCaret(gMC.x, gMC.hit.bottom / 2 + gMC.y, 7, 3);
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;
@ -531,7 +531,7 @@ void ActMyChar_Normal(bool bKey)
{ {
gMC.ym += gravity1; gMC.ym += gravity1;
} }
//Keep player on slopes //Keep player on slopes
if (bKey && !(gKeyTrg & gKeyJump)) if (bKey && !(gKeyTrg & gKeyJump))
{ {
@ -546,7 +546,7 @@ void ActMyChar_Normal(bool bKey)
if (gMC.flag & 8 && gMC.flag & 0x20000 && gMC.flag & 0x40000) if (gMC.flag & 8 && gMC.flag & 0x20000 && gMC.flag & 0x40000)
gMC.ym = 0x400; gMC.ym = 0x400;
} }
//Limit speed //Limit speed
if (!(gMC.flag & 0x100) || gMC.flag & 0xF000) if (!(gMC.flag & 0x100) || gMC.flag & 0xF000)
{ {
@ -570,7 +570,7 @@ void ActMyChar_Normal(bool bKey)
if (gMC.ym > 0x2FF) if (gMC.ym > 0x2FF)
gMC.ym = 0x2FF; gMC.ym = 0x2FF;
} }
//Water splashing //Water splashing
if (!gMC.sprash && gMC.flag & 0x100) if (!gMC.sprash && gMC.flag & 0x100)
{ {
@ -579,14 +579,14 @@ void ActMyChar_Normal(bool bKey)
dir = 2; dir = 2;
else else
dir = 0; dir = 0;
if (gMC.flag & 8 || gMC.ym <= 0x200) if (gMC.flag & 8 || gMC.ym <= 0x200)
{ {
if (gMC.xm > 0x200 || gMC.xm < -0x200) if (gMC.xm > 0x200 || gMC.xm < -0x200)
{ {
for (int a = 0; a < 8; a++) for (int a = 0; a < 8; a++)
SetNpChar(73, gMC.x + (Random(-8, 8) << 9), gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80), dir, 0, 0); SetNpChar(73, gMC.x + (Random(-8, 8) << 9), gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80), dir, 0, 0);
PlaySoundObject(56, 1); PlaySoundObject(56, 1);
} }
} }
@ -594,20 +594,20 @@ void ActMyChar_Normal(bool bKey)
{ {
for (int a = 0; a < 8; a++) for (int a = 0; a < 8; a++)
SetNpChar(73, gMC.x + (Random(-8, 8) << 9), gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80) - gMC.ym / 2, dir, 0, 0); SetNpChar(73, gMC.x + (Random(-8, 8) << 9), gMC.y, gMC.xm + Random(-0x200, 0x200), Random(-0x200, 0x80) - gMC.ym / 2, dir, 0, 0);
PlaySoundObject(56, 1); PlaySoundObject(56, 1);
} }
gMC.sprash = 1; gMC.sprash = 1;
} }
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)
{ {
@ -640,10 +640,10 @@ void ActMyChar_Normal(bool bKey)
if (gMC.index_y < -0x200) if (gMC.index_y < -0x200)
gMC.index_y += 0x200; gMC.index_y += 0x200;
} }
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;
@ -798,12 +798,12 @@ void AirProcess()
{ {
//Drown //Drown
StartTextScript(41); StartTextScript(41);
if (gMC.direct) if (gMC.direct)
SetCaret(gMC.x, gMC.y, 8, 2); SetCaret(gMC.x, gMC.y, 8, 2);
else else
SetCaret(gMC.x, gMC.y, 8, 0); SetCaret(gMC.x, gMC.y, 8, 0);
gMC.cond &= ~0x80; gMC.cond &= ~0x80;
} }
} }
@ -812,7 +812,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;
@ -830,7 +830,7 @@ void ActMyChar(bool bKey)
{ {
if (gMC.exp_wait) if (gMC.exp_wait)
--gMC.exp_wait; --gMC.exp_wait;
if (gMC.shock) if (gMC.shock)
{ {
--gMC.shock; --gMC.shock;
@ -840,7 +840,7 @@ void ActMyChar(bool bKey)
SetValueView(&gMC.x, &gMC.y, gMC.exp_count); SetValueView(&gMC.x, &gMC.y, gMC.exp_count);
gMC.exp_count = 0; gMC.exp_count = 0;
} }
switch (gMC.unit) switch (gMC.unit)
{ {
case 0: case 0:
@ -848,15 +848,15 @@ void ActMyChar(bool bKey)
AirProcess(); AirProcess();
ActMyChar_Normal(bKey); ActMyChar_Normal(bKey);
break; break;
case 1: case 1:
ActMyChar_Stream(bKey); ActMyChar_Stream(bKey);
break; break;
default: default:
break; break;
} }
gMC.cond &= ~0x20; gMC.cond &= ~0x20;
} }
} }
@ -904,16 +904,16 @@ void SetMyCharDirect(uint8_t dir)
case 3: case 3:
gMC.cond |= 1; gMC.cond |= 1;
break; break;
default: default:
gMC.cond &= ~1; gMC.cond &= ~1;
if (dir < 10) if (dir < 10)
{ {
gMC.direct = dir; gMC.direct = dir;
break; break;
} }
for (int i = 0; i < NPC_MAX; i++) for (int i = 0; i < NPC_MAX; i++)
{ {
if (gNPC[i].code_event == dir) if (gNPC[i].code_event == dir)
@ -927,7 +927,7 @@ void SetMyCharDirect(uint8_t dir)
} }
break; break;
} }
gMC.xm = 0; gMC.xm = 0;
AnimationMyChar(false); AnimationMyChar(false);
} }
@ -959,7 +959,7 @@ void SetNoise(int no, int freq)
{ {
noise_freq = freq; noise_freq = freq;
noise_no = no; noise_no = no;
if (no == 1) if (no == 1)
{ {
ChangeSoundFrequency(40, noise_freq); ChangeSoundFrequency(40, noise_freq);
@ -1001,4 +1001,4 @@ void SleepNoise()
PlaySoundObject(40, 0); PlaySoundObject(40, 0);
PlaySoundObject(41, 0); PlaySoundObject(41, 0);
PlaySoundObject(58, 0); PlaySoundObject(58, 0);
} }

View file

@ -34,7 +34,7 @@ void PutlittleStar()
int JudgeHitMyCharBlock(int x, int y) 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
@ -43,17 +43,17 @@ int JudgeHitMyCharBlock(int x, int y)
{ {
//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
@ -62,17 +62,17 @@ int JudgeHitMyCharBlock(int x, int y)
{ {
//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
@ -81,17 +81,17 @@ int JudgeHitMyCharBlock(int x, int y)
{ {
//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
@ -100,24 +100,24 @@ int JudgeHitMyCharBlock(int x, int y)
{ {
//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;
} }
return hit; return hit;
} }
int JudgeHitMyCharTriangleA(int x, int y) int JudgeHitMyCharTriangleA(int x, int y)
{ {
int hit = 0; int hit = 0;
if (gMC.x < (2 * x + 1) << 12 if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12 && gMC.x > (2 * x - 1) << 12
&& gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 && gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800
@ -125,24 +125,24 @@ int JudgeHitMyCharTriangleA(int x, int y)
{ {
//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;
} }
return hit; return hit;
} }
int JudgeHitMyCharTriangleB(int x, int y) int JudgeHitMyCharTriangleB(int x, int y)
{ {
int hit = 0; int hit = 0;
if (gMC.x < (2 * x + 1) << 12 if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12 && gMC.x > (2 * x - 1) << 12
&& gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 && gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800
@ -150,24 +150,24 @@ int JudgeHitMyCharTriangleB(int x, int y)
{ {
//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;
} }
return hit; return hit;
} }
int JudgeHitMyCharTriangleC(int x, int y) int JudgeHitMyCharTriangleC(int x, int y)
{ {
int hit = 0; int hit = 0;
if (gMC.x < (2 * x + 1) << 12 if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12 && gMC.x > (2 * x - 1) << 12
&& gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 && gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800
@ -175,24 +175,24 @@ int JudgeHitMyCharTriangleC(int x, int y)
{ {
//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;
} }
return hit; return hit;
} }
int JudgeHitMyCharTriangleD(int x, int y) int JudgeHitMyCharTriangleD(int x, int y)
{ {
int hit = 0; int hit = 0;
if (gMC.x < (2 * x + 1) << 12 if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12 && gMC.x > (2 * x - 1) << 12
&& gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 && gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800
@ -200,24 +200,24 @@ int JudgeHitMyCharTriangleD(int x, int y)
{ {
//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;
} }
return hit; return hit;
} }
int JudgeHitMyCharTriangleE(int x, int y) int JudgeHitMyCharTriangleE(int x, int y)
{ {
int hit = 0x10000; int hit = 0x10000;
if (gMC.x < (2 * x + 1) << 12 if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12 && gMC.x > (2 * x - 1) << 12
&& gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 && gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800
@ -225,24 +225,24 @@ int JudgeHitMyCharTriangleE(int x, int y)
{ {
//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;
} }
return hit; return hit;
} }
int JudgeHitMyCharTriangleF(int x, int y) int JudgeHitMyCharTriangleF(int x, int y)
{ {
int hit = 0x20000; int hit = 0x20000;
if (gMC.x < (2 * x + 1) << 12 if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12 && gMC.x > (2 * x - 1) << 12
&& gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 && gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800
@ -250,24 +250,24 @@ int JudgeHitMyCharTriangleF(int x, int y)
{ {
//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;
} }
return hit; return hit;
} }
int JudgeHitMyCharTriangleG(int x, int y) int JudgeHitMyCharTriangleG(int x, int y)
{ {
int hit = 0x40000; int hit = 0x40000;
if (gMC.x < (2 * x + 1) << 12 if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12 && gMC.x > (2 * x - 1) << 12
&& gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 && gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800
@ -275,24 +275,24 @@ int JudgeHitMyCharTriangleG(int x, int y)
{ {
//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;
} }
return hit; return hit;
} }
int JudgeHitMyCharTriangleH(int x, int y) int JudgeHitMyCharTriangleH(int x, int y)
{ {
int hit = 0x80000; int hit = 0x80000;
if (gMC.x < (2 * x + 1) << 12 if (gMC.x < (2 * x + 1) << 12
&& gMC.x > (2 * x - 1) << 12 && gMC.x > (2 * x - 1) << 12
&& gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 && gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800
@ -300,56 +300,56 @@ int JudgeHitMyCharTriangleH(int x, int y)
{ {
//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;
} }
return hit; return hit;
} }
int JudgeHitMyCharWater(int x, int y) 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 < ((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) - 0x600 && gMC.y - gMC.hit.top < ((2 * y + 1) << 12) - 0x600
&& gMC.y + gMC.hit.bottom > y << 13) && gMC.y + gMC.hit.bottom > y << 13)
hit = 0x100; hit = 0x100;
return hit; return hit;
} }
int JudgeHitMyCharDamage(int x, int y) int JudgeHitMyCharDamage(int x, int y)
{ {
int hit = 0; int hit = 0;
if (gMC.x - 0x800 < (4 * x + 1) << 11 if (gMC.x - 0x800 < (4 * x + 1) << 11
&& gMC.x + 0x800 > (4 * x - 1) << 11 && gMC.x + 0x800 > (4 * x - 1) << 11
&& gMC.y - 0x800 < (y << 13) + 0x600 && gMC.y - 0x800 < (y << 13) + 0x600
&& gMC.y + 0x800 > (y << 13) - 0x600) && gMC.y + 0x800 > (y << 13) - 0x600)
hit = 0x400; hit = 0x400;
return hit; return hit;
} }
int JudgeHitMyCharDamageW(int x, int y) int JudgeHitMyCharDamageW(int x, int y)
{ {
int hit = 0; int hit = 0;
if (gMC.x - 0x800 < (4 * x + 1) << 11 if (gMC.x - 0x800 < (4 * x + 1) << 11
&& gMC.x + 0x800 > (4 * x - 1) << 11 && gMC.x + 0x800 > (4 * x - 1) << 11
&& gMC.y - 0x800 < (y << 13) + 0x600 && gMC.y - 0x800 < (y << 13) + 0x600
&& gMC.y + 0x800 > (y << 13) - 0x600) && gMC.y + 0x800 > (y << 13) - 0x600)
hit = 0xD00; hit = 0xD00;
return hit; return hit;
} }
@ -361,7 +361,7 @@ int JudgeHitMyCharVectLeft(int x, int y)
&& gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10 && gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10
&& gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10) && gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10)
hit = 0x1000; hit = 0x1000;
return hit; return hit;
} }
@ -373,7 +373,7 @@ int JudgeHitMyCharVectUp(int x, int y)
&& gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10 && gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10
&& gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10) && gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10)
hit = 0x2000; hit = 0x2000;
return hit; return hit;
} }
@ -385,7 +385,7 @@ int JudgeHitMyCharVectRight(int x, int y)
&& gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10 && gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10
&& gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10) && gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10)
hit = 0x4000; hit = 0x4000;
return hit; return hit;
} }
@ -397,7 +397,7 @@ int JudgeHitMyCharVectDown(int x, int y)
&& gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10 && gMC.y - gMC.hit.top < (4 * (2 * y + 1) - 1) << 10
&& gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10) && gMC.y + gMC.hit.bottom > (4 * (2 * y - 1) + 1) << 10)
hit = 0x8000; hit = 0x8000;
return hit; return hit;
} }
@ -405,7 +405,7 @@ void HitMyCharMap()
{ {
int x = gMC.x / 0x2000; int x = gMC.x / 0x2000;
int y = gMC.y / 0x2000; int y = gMC.y / 0x2000;
int offy[4]; int offy[4];
int offx[4]; int offx[4];
offx[0] = 0; offx[0] = 0;
@ -416,19 +416,19 @@ void HitMyCharMap()
offy[1] = 0; offy[1] = 0;
offy[2] = 1; offy[2] = 1;
offy[3] = 1; offy[3] = 1;
uint8_t atrb[4]; uint8_t atrb[4];
for (int i = 0; i < 4; i++) for (int 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 //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:
@ -436,144 +436,144 @@ void HitMyCharMap()
case 0x46: case 0x46:
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;
case 0x51: case 0x51:
gMC.flag |= JudgeHitMyCharTriangleB(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleB(x + offx[i], y + offy[i]);
break; break;
case 0x52: case 0x52:
gMC.flag |= JudgeHitMyCharTriangleC(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleC(x + offx[i], y + offy[i]);
break; break;
case 0x53: case 0x53:
gMC.flag |= JudgeHitMyCharTriangleD(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleD(x + offx[i], y + offy[i]);
break; break;
case 0x54: case 0x54:
gMC.flag |= JudgeHitMyCharTriangleE(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleE(x + offx[i], y + offy[i]);
break; break;
case 0x55: case 0x55:
gMC.flag |= JudgeHitMyCharTriangleF(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleF(x + offx[i], y + offy[i]);
break; break;
case 0x56: case 0x56:
gMC.flag |= JudgeHitMyCharTriangleG(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharTriangleG(x + offx[i], y + offy[i]);
break; break;
case 0x57: case 0x57:
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;
case 0x61: case 0x61:
gMC.flag |= JudgeHitMyCharBlock(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharBlock(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;
//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;
case 0x81: case 0x81:
gMC.flag |= JudgeHitMyCharVectUp(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharVectUp(x + offx[i], y + offy[i]);
break; break;
case 0x82: case 0x82:
gMC.flag |= JudgeHitMyCharVectRight(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharVectRight(x + offx[i], y + offy[i]);
break; break;
case 0x83: case 0x83:
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]);
break; break;
case 0xA1: case 0xA1:
gMC.flag |= JudgeHitMyCharVectUp(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharVectUp(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 0xA2: case 0xA2:
gMC.flag |= JudgeHitMyCharVectRight(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharVectRight(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 0xA3: case 0xA3:
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: default:
break; break;
} }
} }
if (gMC.y > gWaterY + 0x800) if (gMC.y > gWaterY + 0x800)
gMC.flag |= 0x100; gMC.flag |= 0x100;
} }
@ -581,7 +581,7 @@ void HitMyCharMap()
int JudgeHitMyCharNPC(NPCHAR *npc) int JudgeHitMyCharNPC(NPCHAR *npc)
{ {
int hit = 0; int hit = 0;
if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom - 0x600 if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom - 0x600
&& gMC.y + gMC.hit.bottom > npc->y - npc->hit.top + 0x600 && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top + 0x600
&& gMC.x - gMC.hit.right < npc->x + npc->hit.back && gMC.x - gMC.hit.right < npc->x + npc->hit.back
@ -591,7 +591,7 @@ int JudgeHitMyCharNPC(NPCHAR *npc)
gMC.xm += 0x200; gMC.xm += 0x200;
hit |= 1; hit |= 1;
} }
if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom - 0x600 if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom - 0x600
&& gMC.y + gMC.hit.bottom > npc->y - npc->hit.top + 0x600 && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top + 0x600
&& gMC.x + gMC.hit.right - 0x200 > npc->x - npc->hit.back && gMC.x + gMC.hit.right - 0x200 > npc->x - npc->hit.back
@ -601,7 +601,7 @@ int JudgeHitMyCharNPC(NPCHAR *npc)
gMC.xm -= 0x200; gMC.xm -= 0x200;
hit |= 4; hit |= 4;
} }
if (gMC.x - gMC.hit.right < npc->x + npc->hit.back - 0x600 if (gMC.x - gMC.hit.right < npc->x + npc->hit.back - 0x600
&& gMC.x + gMC.hit.right > npc->x - npc->hit.back + 0x600 && gMC.x + gMC.hit.right > npc->x - npc->hit.back + 0x600
&& gMC.y - gMC.hit.top < npc->y + npc->hit.bottom && gMC.y - gMC.hit.top < npc->y + npc->hit.bottom
@ -611,7 +611,7 @@ int JudgeHitMyCharNPC(NPCHAR *npc)
gMC.ym = 0; gMC.ym = 0;
hit |= 2; hit |= 2;
} }
if (gMC.x - gMC.hit.right < npc->x + npc->hit.back - 0x600 if (gMC.x - gMC.hit.right < npc->x + npc->hit.back - 0x600
&& gMC.x + gMC.hit.right > npc->x - npc->hit.back + 0x600 && gMC.x + gMC.hit.right > npc->x - npc->hit.back + 0x600
&& gMC.y + gMC.hit.bottom > npc->y - npc->hit.top && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top
@ -651,7 +651,7 @@ int JudgeHitMyCharNPC3(NPCHAR *npc)
&& gMC.y - 0x400 < npc->y + npc->hit.bottom) && gMC.y - 0x400 < npc->y + npc->hit.bottom)
return 1; return 1;
} }
return 0; return 0;
} }
@ -660,28 +660,28 @@ int JudgeHitMyCharNPC4(NPCHAR *npc)
//TODO: comment this //TODO: comment this
int hit = 0; int hit = 0;
long double v1, v2; long double v1, v2;
if (npc->x <= gMC.x) if (npc->x <= gMC.x)
v1 = (long double)(gMC.x - npc->x); v1 = (long double)(gMC.x - npc->x);
else else
v1 = (long double)(npc->x - gMC.x); v1 = (long double)(npc->x - gMC.x);
float fx1 = (float)v1; float fx1 = (float)v1;
if (npc->y <= gMC.y) if (npc->y <= gMC.y)
v2 = (long double)(gMC.y - npc->y); v2 = (long double)(gMC.y - npc->y);
else else
v2 = (long double)(npc->y - gMC.y); v2 = (long double)(npc->y - gMC.y);
float fx2 = (float)npc->hit.back; float fx2 = (float)npc->hit.back;
if (0.0 == fx1) if (0.0 == fx1)
fx1 = 1.0; fx1 = 1.0;
if (0.0 == fx2) if (0.0 == fx2)
fx2 = 1.0; fx2 = 1.0;
float fy1 = (float)v2; float fy1 = (float)v2;
float fy2 = (float)npc->hit.top; float fy2 = (float)npc->hit.top;
if (fy1 / fx1 <= fy2 / fx2) if (fy1 / fx1 <= fy2 / fx2)
{ {
if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top) if (gMC.y - gMC.hit.top < npc->y + npc->hit.bottom && gMC.y + gMC.hit.bottom > npc->y - npc->hit.top)
@ -693,7 +693,7 @@ int JudgeHitMyCharNPC4(NPCHAR *npc)
gMC.x = npc->hit.back + npc->x + gMC.hit.right; gMC.x = npc->hit.back + npc->x + gMC.hit.right;
hit |= 1; hit |= 1;
} }
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 )
@ -717,15 +717,15 @@ int JudgeHitMyCharNPC4(NPCHAR *npc)
gMC.y = npc->hit.bottom + npc->y + gMC.hit.top + 0x200; gMC.y = npc->hit.bottom + npc->y + gMC.hit.top + 0x200;
gMC.ym = npc->ym; gMC.ym = npc->ym;
} }
hit |= 2; hit |= 2;
} }
if (gMC.y + gMC.hit.bottom > npc->y - npc->hit.top && gMC.hit.bottom + gMC.y < npc->y + 0x600) 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) if (gMC.ym - npc->ym > 0x400)
PlaySoundObject(23, 1); PlaySoundObject(23, 1);
if (gMC.unit == 1) if (gMC.unit == 1)
{ {
gMC.y = npc->y - npc->hit.top - gMC.hit.bottom + 0x200; gMC.y = npc->y - npc->hit.top - gMC.hit.bottom + 0x200;
@ -745,7 +745,7 @@ int JudgeHitMyCharNPC4(NPCHAR *npc)
} }
} }
} }
return hit; return hit;
} }
@ -754,7 +754,7 @@ void HitMyCharNpChar()
if ((gMC.cond & 0x80) && !(gMC.cond & 2)) if ((gMC.cond & 0x80) && !(gMC.cond & 2))
{ {
int hit; int hit;
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)
@ -773,7 +773,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)
{ {
@ -781,25 +781,25 @@ void HitMyCharNpChar()
AddExpMyChar(gNPC[i].exp); AddExpMyChar(gNPC[i].exp);
gNPC[i].cond = 0; gNPC[i].cond = 0;
} }
if (hit && gNPC[i].code_char == 86) if (hit && gNPC[i].code_char == 86)
{ {
PlaySoundObject(42, 1); PlaySoundObject(42, 1);
AddBulletMyChar(gNPC[i].code_event, gNPC[i].exp); AddBulletMyChar(gNPC[i].code_event, gNPC[i].exp);
gNPC[i].cond = 0; gNPC[i].cond = 0;
} }
if (hit && gNPC[i].code_char == 87) if (hit && gNPC[i].code_char == 87)
{ {
PlaySoundObject(20, 1); PlaySoundObject(20, 1);
AddLifeMyChar(gNPC[i].exp); AddLifeMyChar(gNPC[i].exp);
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))
{ {
@ -819,7 +819,7 @@ void HitMyCharNpChar()
DamageMyChar(gNPC[i].damage); DamageMyChar(gNPC[i].damage);
} }
} }
//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)
{ {
@ -829,7 +829,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);
@ -859,13 +859,13 @@ void HitMyCharBoss()
{ {
hit = JudgeHitMyCharNPC3(&gBoss[b]); hit = JudgeHitMyCharNPC3(&gBoss[b]);
} }
if (!(g_GameFlags & 4) && hit && gBoss[b].bits & npc_eventTouch) if (!(g_GameFlags & 4) && hit && gBoss[b].bits & npc_eventTouch)
{ {
StartTextScript(gBoss[b].code_event); StartTextScript(gBoss[b].code_event);
gMC.ques = 0; gMC.ques = 0;
} }
if (gBoss[b].bits & npc_rearTop) if (gBoss[b].bits & npc_rearTop)
{ {
if (hit & 4 && gBoss[b].xm < 0) if (hit & 4 && gBoss[b].xm < 0)
@ -877,7 +877,7 @@ void HitMyCharBoss()
{ {
DamageMyChar(gBoss[b].damage); DamageMyChar(gBoss[b].damage);
} }
if (!(g_GameFlags & 4) && hit && (gMC.cond & 1) && gBoss[b].bits & npc_interact) if (!(g_GameFlags & 4) && hit && (gMC.cond & 1) && gBoss[b].bits & npc_interact)
{ {
StartTextScript(gBoss[b].code_event); StartTextScript(gBoss[b].code_event);
@ -886,8 +886,8 @@ void HitMyCharBoss()
} }
} }
} }
if (gMC.ques) if (gMC.ques)
SetCaret(gMC.x, gMC.y, 9, 0); SetCaret(gMC.x, gMC.y, 9, 0);
} }
} }

View file

@ -41,15 +41,15 @@ void AddExpMyChar(int x)
{ {
int lv = gArmsData[gSelectedArms].level - 1; int lv = gArmsData[gSelectedArms].level - 1;
int arms_code = gArmsData[gSelectedArms].code; int arms_code = gArmsData[gSelectedArms].code;
gArmsData[gSelectedArms].exp += x; gArmsData[gSelectedArms].exp += x;
if (lv == 2) if (lv == 2)
{ {
if (gArmsData[gSelectedArms].exp >= gArmsLevelTable[0].exp[3 * arms_code + 2]) if (gArmsData[gSelectedArms].exp >= gArmsLevelTable[0].exp[3 * arms_code + 2])
{ {
gArmsData[gSelectedArms].exp = gArmsLevelTable[0].exp[3 * arms_code + 2]; gArmsData[gSelectedArms].exp = gArmsLevelTable[0].exp[3 * arms_code + 2];
if (gMC.equip & 0x80) if (gMC.equip & 0x80)
{ {
if (gMC.star < 3) if (gMC.star < 3)
@ -65,18 +65,18 @@ void AddExpMyChar(int x)
{ {
++gArmsData[gSelectedArms].level; ++gArmsData[gSelectedArms].level;
gArmsData[gSelectedArms].exp = 0; gArmsData[gSelectedArms].exp = 0;
if (gArmsData[gSelectedArms].code != 13) if (gArmsData[gSelectedArms].code != 13)
{ {
PlaySoundObject(27, 1); PlaySoundObject(27, 1);
SetCaret(gMC.x, gMC.y, 10, 0); SetCaret(gMC.x, gMC.y, 10, 0);
} }
} }
++lv; ++lv;
} }
} }
if (gArmsData[gSelectedArms].code == 13) if (gArmsData[gSelectedArms].code == 13)
{ {
gMC.exp_wait = 10; gMC.exp_wait = 10;
@ -111,17 +111,17 @@ void DamageMyChar(int damage)
if (gMC.unit != 1) if (gMC.unit != 1)
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
gArmsData[gSelectedArms].exp -= 2 * damage; gArmsData[gSelectedArms].exp -= 2 * damage;
while (gArmsData[gSelectedArms].exp < 0) while (gArmsData[gSelectedArms].exp < 0)
{ {
if (gArmsData[gSelectedArms].level <= 1) if (gArmsData[gSelectedArms].level <= 1)
@ -135,10 +135,10 @@ void DamageMyChar(int damage)
SetCaret(gMC.x, gMC.y, 10, 2); SetCaret(gMC.x, gMC.y, 10, 2);
} }
} }
//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)
{ {
@ -172,7 +172,7 @@ void AddBulletMyChar(int no, int val)
break; break;
} }
} }
//Super Missile Launcher //Super Missile Launcher
for (int a = 0; a < ARMS_MAX; a++) for (int a = 0; a < ARMS_MAX; a++)
{ {
@ -209,12 +209,12 @@ void PutArmsEnergy(bool flash)
RECT rcLv = {80, 80, 96, 88}; RECT rcLv = {80, 80, 96, 88};
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
RECT rcNone = {80, 48, 96, 56}; RECT rcNone = {80, 48, 96, 56};
if (gArmsEnergyX > 16) if (gArmsEnergyX > 16)
gArmsEnergyX -= 2; gArmsEnergyX -= 2;
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)
{ {
@ -226,40 +226,40 @@ void PutArmsEnergy(bool flash)
PutBitmap3(&rcView, gArmsEnergyX + 48, 16, &rcNone, SURFACE_ID_TEXT_BOX); PutBitmap3(&rcView, gArmsEnergyX + 48, 16, &rcNone, SURFACE_ID_TEXT_BOX);
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);
PutBitmap3(&rcView, gArmsEnergyX, 32, &rcLv, SURFACE_ID_TEXT_BOX); PutBitmap3(&rcView, gArmsEnergyX, 32, &rcLv, SURFACE_ID_TEXT_BOX);
PutNumber4(gArmsEnergyX - 8, 32, gArmsData[gSelectedArms].level, 0); PutNumber4(gArmsEnergyX - 8, 32, gArmsData[gSelectedArms].level, 0);
RECT rcExpBox = {0, 72, 40, 80}; RECT rcExpBox = {0, 72, 40, 80};
RECT rcExpVal = {0, 80, 0, 88}; RECT rcExpVal = {0, 80, 0, 88};
RECT rcExpMax = {40, 72, 80, 80}; RECT rcExpMax = {40, 72, 80, 80};
RECT rcExpFlash = {40, 80, 80, 88}; RECT rcExpFlash = {40, 80, 80, 88};
int lv = gArmsData[gSelectedArms].level - 1; int lv = gArmsData[gSelectedArms].level - 1;
int arms_code = gArmsData[gSelectedArms].code; int arms_code = gArmsData[gSelectedArms].code;
int exp_now = gArmsData[gSelectedArms].exp; int exp_now = gArmsData[gSelectedArms].exp;
int exp_next = gArmsLevelTable[0].exp[lv + 3 * arms_code]; int exp_next = gArmsLevelTable[0].exp[lv + 3 * arms_code];
PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpBox, SURFACE_ID_TEXT_BOX); PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpBox, SURFACE_ID_TEXT_BOX);
if (lv != 2 || gArmsData[gSelectedArms].exp != gArmsLevelTable[0].exp[3 * arms_code + 2]) if (lv != 2 || gArmsData[gSelectedArms].exp != gArmsLevelTable[0].exp[3 * arms_code + 2])
{ {
if (exp_next) if (exp_next)
rcExpVal.right += 40 * exp_now / exp_next; rcExpVal.right += 40 * exp_now / exp_next;
else else
rcExpVal.right = 0; rcExpVal.right = 0;
PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpVal, SURFACE_ID_TEXT_BOX); PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpVal, SURFACE_ID_TEXT_BOX);
} }
else else
{ {
PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpMax, SURFACE_ID_TEXT_BOX); PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpMax, SURFACE_ID_TEXT_BOX);
} }
static int add_flash = true; static int add_flash = true;
if (gMC.exp_wait && ((add_flash++ >> 1) & 1)) if (gMC.exp_wait && ((add_flash++ >> 1) & 1))
PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpFlash, SURFACE_ID_TEXT_BOX); PutBitmap3(&rcView, gArmsEnergyX + 24, 32, &rcExpFlash, SURFACE_ID_TEXT_BOX);
@ -272,14 +272,14 @@ void PutActiveArmsList()
int arms_num; int arms_num;
for (arms_num = 0; gArmsData[arms_num].code != 0; ++arms_num); for (arms_num = 0; gArmsData[arms_num].code != 0; ++arms_num);
if (arms_num) if (arms_num)
{ {
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)
{ {
if (x >= 24) if (x >= 24)
@ -289,12 +289,12 @@ void PutActiveArmsList()
{ {
x += 16 * (arms_num + 3); x += 16 * (arms_num + 3);
} }
if (8 * (2 * (arms_num + 3) + 1) <= x) if (8 * (2 * (arms_num + 3) + 1) <= x)
x += 16 * (-3 - arms_num); x += 16 * (-3 - arms_num);
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;
@ -308,22 +308,22 @@ void PutMyLife(bool flash)
RECT rcCase = {0, 40, 232, 48}; RECT rcCase = {0, 40, 232, 48};
RECT rcLife = {0, 24, 232, 32}; RECT rcLife = {0, 24, 232, 32};
RECT rcBr = {0, 32, 232, 40}; RECT rcBr = {0, 32, 232, 40};
if (!flash || !((gMC.shock >> 1) & 1)) if (!flash || !((gMC.shock >> 1) & 1))
{ {
if (gMC.lifeBr < gMC.life) if (gMC.lifeBr < gMC.life)
gMC.lifeBr = gMC.life; gMC.lifeBr = gMC.life;
if (gMC.lifeBr <= gMC.life) if (gMC.lifeBr <= gMC.life)
gMC.lifeBr_count = 0; gMC.lifeBr_count = 0;
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;
PutBitmap3(&grcGame, 16, 40, &rcCase, SURFACE_ID_TEXT_BOX); PutBitmap3(&grcGame, 16, 40, &rcCase, SURFACE_ID_TEXT_BOX);
PutBitmap3(&grcGame, 40, 40, &rcBr, SURFACE_ID_TEXT_BOX); PutBitmap3(&grcGame, 40, 40, &rcBr, SURFACE_ID_TEXT_BOX);
PutBitmap3(&grcGame, 40, 40, &rcLife, SURFACE_ID_TEXT_BOX); PutBitmap3(&grcGame, 40, 40, &rcLife, SURFACE_ID_TEXT_BOX);
@ -343,7 +343,7 @@ void PutMyAir(int x, int y)
//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);
@ -367,7 +367,7 @@ void PutTimeCounter(int x, int y)
{ {
if (time_count < 300000) if (time_count < 300000)
++time_count; ++time_count;
if (time_count % 30 <= 10) if (time_count % 30 <= 10)
PutBitmap3(&grcGame, x, y, &rcTime[1], SURFACE_ID_TEXT_BOX); PutBitmap3(&grcGame, x, y, &rcTime[1], SURFACE_ID_TEXT_BOX);
else else
@ -377,7 +377,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);
@ -397,11 +397,11 @@ bool SaveTimeCounter()
//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)
{ {
@ -421,25 +421,25 @@ bool SaveTimeCounter()
p[1] -= rec.random[0]; p[1] -= rec.random[0];
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;
rec.random[i] = Random(0, 250) + i; rec.random[i] = Random(0, 250) + i;
uint8_t *p = (uint8_t*)&rec.counter[i]; uint8_t *p = (uint8_t*)&rec.counter[i];
p[0] += (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i]) : (rec.random[i] >> 1); p[0] += (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i]) : (rec.random[i] >> 1);
p[1] += rec.random[i]; p[1] += rec.random[i];
p[2] += rec.random[i]; p[2] += rec.random[i];
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]);
} }
fp = fopen(path, "wb"); fp = fopen(path, "wb");
if (fp == NULL) if (fp == NULL)
return false; return false;
@ -460,13 +460,13 @@ 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);
FILE *fp = fopen(path, "rb"); FILE *fp = fopen(path, "rb");
if (!fp) if (!fp)
return 0; return 0;
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);
@ -477,7 +477,7 @@ int LoadTimeCounter()
rec.random[2] = fgetc(fp); rec.random[2] = fgetc(fp);
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++)
{ {
@ -487,7 +487,7 @@ int LoadTimeCounter()
p[2] -= rec.random[i]; p[2] -= rec.random[i];
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])
{ {

View file

@ -197,10 +197,10 @@ void SetExpObjects(int x, int y, int exp)
break; 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)
@ -389,7 +389,7 @@ void ChangeNpCharByEvent(int code_event, int code_char, int dir)
gNPC[n].ani_wait = 0; gNPC[n].ani_wait = 0;
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) if (dir == 4)
@ -404,7 +404,7 @@ void ChangeNpCharByEvent(int code_event, int code_char, int dir)
gNPC[n].direct = dir; gNPC[n].direct = dir;
} }
} }
gpNpcFuncTbl[code_char](&gNPC[n]); gpNpcFuncTbl[code_char](&gNPC[n]);
} }
} }
@ -431,7 +431,7 @@ void ChangeCheckableNpCharByEvent(int code_event, int code_char, int dir)
gNPC[n].ani_wait = 0; gNPC[n].ani_wait = 0;
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) if (dir == 4)
@ -446,7 +446,7 @@ void ChangeCheckableNpCharByEvent(int code_event, int code_char, int dir)
gNPC[n].direct = dir; gNPC[n].direct = dir;
} }
} }
gpNpcFuncTbl[code_char](&gNPC[n]); gpNpcFuncTbl[code_char](&gNPC[n]);
} }
} }
@ -459,7 +459,7 @@ void SetNpCharActionNo(int code_event, int act_no, int dir)
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; gNPC[n].act_no = act_no;
if (dir != 5) if (dir != 5)
{ {
if (dir == 4) if (dir == 4)
@ -487,7 +487,7 @@ void MoveNpChar(int code_event, int x, int y, int dir)
{ {
gNPC[n].x = x; gNPC[n].x = x;
gNPC[n].y = y; gNPC[n].y = y;
if (dir != 5) if (dir != 5)
{ {
if (dir == 4) if (dir == 4)
@ -511,7 +511,7 @@ void BackStepMyChar(int code_event)
{ {
gMC.cond &= ~1; gMC.cond &= ~1;
gMC.ym = -0x200; gMC.ym = -0x200;
if (code_event) if (code_event)
{ {
if (code_event == 2) if (code_event == 2)
@ -566,11 +566,11 @@ void DeleteNpCharCode(int code, bool bSmoke)
{ {
gNPC[n].cond = 0; gNPC[n].cond = 0;
SetNPCFlag(gNPC[n].code_flag); SetNPCFlag(gNPC[n].code_flag);
if (bSmoke) if (bSmoke)
{ {
PlaySoundObject(gNPC[n].destroy_voice, 1); PlaySoundObject(gNPC[n].destroy_voice, 1);
switch (gNPC[n].size) switch (gNPC[n].size)
{ {
case 2: case 2:
@ -601,7 +601,7 @@ BOOL IsNpCharCode(int code)
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;
} }
@ -612,7 +612,7 @@ BOOL GetNpCharAlive(int code_event)
if ((gNPC[i].cond & 0x80) && gNPC[i].code_event == code_event) if ((gNPC[i].cond & 0x80) && gNPC[i].code_event == code_event)
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
@ -624,6 +624,6 @@ int CountAliveNpChar()
if (gNPC[n].cond & 0x80) if (gNPC[n].cond & 0x80)
++count; ++count;
} }
return count; return count;
} }

View file

@ -542,35 +542,35 @@ void ActNpc006(NPCHAR *npc)
{ {
case 0: //Init case 0: //Init
npc->act_no = 1; npc->act_no = 1;
if (npc->direct == 0) if (npc->direct == 0)
npc->act_no = 1; npc->act_no = 1;
else else
npc->act_no = 3; npc->act_no = 3;
break; break;
case 1: case 1:
//Accelerate to the left //Accelerate to the left
npc->xm -= 0x10; npc->xm -= 0x10;
if (npc->xm < -0x400) if (npc->xm < -0x400)
npc->xm = -0x400; npc->xm = -0x400;
//Move //Move
if (npc->shock) if (npc->shock)
npc->x += npc->xm / 2; npc->x += npc->xm / 2;
else else
npc->x += npc->xm; npc->x += npc->xm;
//Animate //Animate
if (++npc->ani_wait > 1) if (++npc->ani_wait > 1)
{ {
npc->ani_wait = 0; npc->ani_wait = 0;
++npc->ani_no; ++npc->ani_no;
} }
if (npc->ani_no > 2) if (npc->ani_no > 2)
npc->ani_no = 1; npc->ani_no = 1;
//Stop when hitting a wall //Stop when hitting a wall
if (npc->flag & 1) if (npc->flag & 1)
{ {
@ -581,7 +581,7 @@ void ActNpc006(NPCHAR *npc)
npc->direct = 2; npc->direct = 2;
} }
break; break;
case 2: case 2:
//Wait 60 frames then move to the right //Wait 60 frames then move to the right
if (++npc->act_wait > 60) if (++npc->act_wait > 60)
@ -591,29 +591,29 @@ void ActNpc006(NPCHAR *npc)
npc->ani_no = 1; npc->ani_no = 1;
} }
break; break;
case 3: case 3:
//Accelerate to the right //Accelerate to the right
npc->xm += 0x10; npc->xm += 0x10;
if (npc->xm > 0x400) if (npc->xm > 0x400)
npc->xm = 0x400; npc->xm = 0x400;
//Move //Move
if (npc->shock) if (npc->shock)
npc->x += npc->xm / 2; npc->x += npc->xm / 2;
else else
npc->x += npc->xm; npc->x += npc->xm;
//Animate //Animate
if (++npc->ani_wait > 1) if (++npc->ani_wait > 1)
{ {
npc->ani_wait = 0; npc->ani_wait = 0;
++npc->ani_no; ++npc->ani_no;
} }
if (npc->ani_no > 2) if (npc->ani_no > 2)
npc->ani_no = 1; npc->ani_no = 1;
//Stop when hitting a wall //Stop when hitting a wall
if (npc->flag & 4) if (npc->flag & 4)
{ {
@ -624,7 +624,7 @@ void ActNpc006(NPCHAR *npc)
npc->direct = 0; npc->direct = 0;
} }
break; break;
case 4: case 4:
//Wait 60 frames then move to the left //Wait 60 frames then move to the left
if (++npc->act_wait > 60) if (++npc->act_wait > 60)
@ -635,7 +635,7 @@ void ActNpc006(NPCHAR *npc)
} }
break; break;
} }
//Set framerect //Set framerect
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];

View file

@ -93,7 +93,7 @@ void ActNpc040(NPCHAR *npc)
npc->ani_no = 6; npc->ani_no = 6;
break; break;
} }
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
else else
@ -825,17 +825,17 @@ void ActNpc048(NPCHAR *npc)
npc->ym = -0x100; npc->ym = -0x100;
} }
} }
if (npc->direct == 2) if (npc->direct == 2)
{ {
npc->bits &= ~npc_shootable; npc->bits &= ~npc_shootable;
npc->bits |= npc_invulnerable; npc->bits |= npc_invulnerable;
} }
npc->ym += 5; npc->ym += 5;
npc->y += npc->ym; npc->y += npc->ym;
npc->x += npc->xm; npc->x += npc->xm;
RECT rcLeft[2] = { RECT rcLeft[2] = {
{288, 88, 304, 104}, {288, 88, 304, 104},
{304, 88, 320, 104}, {304, 88, 320, 104},
@ -845,20 +845,20 @@ void ActNpc048(NPCHAR *npc)
{288, 104, 304, 120}, {288, 104, 304, 120},
{304, 104, 320, 120}, {304, 104, 320, 120},
}; };
if (++npc->ani_wait > 2) if (++npc->ani_wait > 2)
{ {
npc->ani_wait = 0; npc->ani_wait = 0;
if (++npc->ani_no > 1) if (++npc->ani_no > 1)
npc->ani_no = 0; npc->ani_no = 0;
} }
if (++npc->act_wait > 750) if (++npc->act_wait > 750)
{ {
SetCaret(npc->x, npc->y, 2, 0); SetCaret(npc->x, npc->y, 2, 0);
npc->cond = 0; npc->cond = 0;
} }
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
else else

View file

@ -577,7 +577,7 @@ void ActNpc127(NPCHAR *npc)
if (++npc->ani_no > 2) if (++npc->ani_no > 2)
npc->cond = 0; npc->cond = 0;
} }
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rcH[npc->ani_no]; npc->rect = rcH[npc->ani_no];
else else
@ -618,11 +618,11 @@ void ActNpc128(NPCHAR *npc)
{224, 32, 232, 40}, {224, 32, 232, 40},
{224, 40, 232, 48}, {224, 40, 232, 48},
}; };
if (npc->act_no == 0) if (npc->act_no == 0)
{ {
npc->act_no = 1; npc->act_no = 1;
if (npc->direct == 0 || npc->direct == 2) if (npc->direct == 0 || npc->direct == 2)
{ {
npc->view.front = 0x800; npc->view.front = 0x800;
@ -634,10 +634,10 @@ void ActNpc128(NPCHAR *npc)
npc->view.top = 0x800; npc->view.top = 0x800;
} }
} }
if (++npc->ani_no > 4) if (++npc->ani_no > 4)
npc->cond = 0; npc->cond = 0;
switch (npc->direct) switch (npc->direct)
{ {
case 0: case 0:
@ -678,16 +678,16 @@ void ActNpc129(NPCHAR *npc)
{0xC0, 0x50, 0xD0, 0x60}, {0xC0, 0x50, 0xD0, 0x60},
{0xD0, 0x50, 0xE0, 0x60}, {0xD0, 0x50, 0xE0, 0x60},
}; };
if (++npc->ani_wait > 1) if (++npc->ani_wait > 1)
{ {
npc->ani_wait = 0; npc->ani_wait = 0;
if (++npc->ani_no > 2) if (++npc->ani_no > 2)
npc->cond = 0; npc->cond = 0;
} }
npc->y += npc->ym; npc->y += npc->ym;
npc->rect = rect[3 * npc->direct + npc->ani_no]; npc->rect = rect[3 * npc->direct + npc->ani_no];
} }

View file

@ -1115,13 +1115,13 @@ void ActNpc150(NPCHAR *npc)
{160, 16, 176, 32}, {160, 16, 176, 32},
{112, 16, 128, 32}, {112, 16, 128, 32},
}; };
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
npc->act_no = 1; npc->act_no = 1;
npc->ani_no = 0; npc->ani_no = 0;
if (npc->direct > 10) if (npc->direct > 10)
{ {
npc->x = gMC.x; npc->x = gMC.x;
@ -1171,7 +1171,7 @@ void ActNpc150(NPCHAR *npc)
if (npc->ani_no > 6) if (npc->ani_no > 6)
npc->ani_no = 3; npc->ani_no = 3;
if (npc->direct == 0) if (npc->direct == 0)
npc->x -= 0x200; npc->x -= 0x200;
else else
@ -1202,7 +1202,7 @@ void ActNpc150(NPCHAR *npc)
npc->x += 0x100; npc->x += 0x100;
else else
npc->x -= 0x100; npc->x -= 0x100;
if (++npc->ani_wait > 8) if (++npc->ani_wait > 8)
{ {
npc->ani_wait = 0; npc->ani_wait = 0;
@ -1250,12 +1250,12 @@ void ActNpc150(NPCHAR *npc)
break; break;
} }
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
else else
npc->rect = rcRight[npc->ani_no]; npc->rect = rcRight[npc->ani_no];
if (npc->act_no == 21) if (npc->act_no == 21)
{ {
npc->rect.bottom = npc->act_wait / 4 + npc->rect.top; npc->rect.bottom = npc->act_wait / 4 + npc->rect.top;
@ -1263,7 +1263,7 @@ void ActNpc150(NPCHAR *npc)
if (npc->act_wait / 2 % 2) if (npc->act_wait / 2 % 2)
++npc->rect.left; ++npc->rect.left;
} }
if (gMC.equip & 0x40) if (gMC.equip & 0x40)
{ {
npc->rect.top += 32; npc->rect.top += 32;

View file

@ -573,7 +573,7 @@ void ActNpc184(NPCHAR *npc)
{64, 64, 96, 96}, {64, 64, 96, 96},
{32, 64, 64, 96}, {32, 64, 64, 96},
}; };
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -618,16 +618,16 @@ void ActNpc184(NPCHAR *npc)
npc->act_no = 1; npc->act_no = 1;
break; break;
} }
if (++npc->ani_wait > 10) if (++npc->ani_wait > 10)
{ {
npc->ani_wait = 0; npc->ani_wait = 0;
++npc->ani_no; ++npc->ani_no;
} }
if (npc->ani_no > 3) if (npc->ani_no > 3)
npc->ani_no = 0; npc->ani_no = 0;
npc->rect = rc[npc->ani_no]; npc->rect = rc[npc->ani_no];
} }
@ -684,7 +684,7 @@ void ActNpc186(NPCHAR *npc)
{80, 48, 96, 64}, {80, 48, 96, 64},
{64, 48, 80, 64}, {64, 48, 80, 64},
}; };
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -717,16 +717,16 @@ void ActNpc186(NPCHAR *npc)
++npc->act_wait; ++npc->act_wait;
break; break;
} }
if (++npc->ani_wait > 10) if (++npc->ani_wait > 10)
{ {
npc->ani_wait = 0; npc->ani_wait = 0;
++npc->ani_no; ++npc->ani_no;
} }
if (npc->ani_no > 3) if (npc->ani_no > 3)
npc->ani_no = 0; npc->ani_no = 0;
npc->rect = rc[npc->ani_no]; npc->rect = rc[npc->ani_no];
} }
@ -962,7 +962,7 @@ void ActNpc190(NPCHAR *npc)
{192, 32, 208, 48}, {192, 32, 208, 48},
{208, 32, 224, 48}, {208, 32, 224, 48},
}; };
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -984,7 +984,7 @@ void ActNpc190(NPCHAR *npc)
npc->ani_no = 0; npc->ani_no = 0;
break; break;
} }
npc->rect = rect[npc->ani_no]; npc->rect = rect[npc->ani_no];
} }
@ -1067,7 +1067,7 @@ void ActNpc191(NPCHAR *npc)
npc->y += npc->ym; npc->y += npc->ym;
break; break;
} }
gWaterY = npc->y; gWaterY = npc->y;
npc->rect.right = 0; npc->rect.right = 0;
npc->rect.bottom = 0; npc->rect.bottom = 0;

View file

@ -1086,7 +1086,7 @@ void ActNpc267(NPCHAR *npc)
if (npc->act_no >= 512) if (npc->act_no >= 512)
{ {
} }
else else
{ {
@ -1095,7 +1095,7 @@ void ActNpc267(NPCHAR *npc)
if (npc->act_no != 102 && npc->act_no != 103 && Random(0, 3) == 2) if (npc->act_no != 102 && npc->act_no != 103 && Random(0, 3) == 2)
SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y + (Random(-8, 4) * 0x200), npc->xm, 0, 3, 0, 0x100); SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y + (Random(-8, 4) * 0x200), npc->xm, 0, 3, 0, 0x100);
} }
else else
{ {
SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - (((336 - npc->act_wait) / 8) * 0x200), Random(-0x200, 0x200), 2 * Random(-0x200, 0), 3, 0, 0xAA); SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - (((336 - npc->act_wait) / 8) * 0x200), Random(-0x200, 0x200), 2 * Random(-0x200, 0), 3, 0, 0xAA);
SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - ((336 - npc->act_wait) / 8 * 0x200), Random(-0x200, 0x200), 2 * Random(-0x200, 0), 3, 0, 0xAA); SetNpChar(270, npc->x + (Random(-0x10, 0x10) * 0x200), npc->y - ((336 - npc->act_wait) / 8 * 0x200), Random(-0x200, 0x200), 2 * Random(-0x200, 0), 3, 0, 0xAA);
@ -2130,7 +2130,7 @@ void ActNpc278(NPCHAR *npc)
npc->x += npc->xm; npc->x += npc->xm;
npc->y += npc->ym; npc->y += npc->ym;
switch (npc->code_event) switch (npc->code_event)
{ {
case 200: case 200:

View file

@ -1475,7 +1475,7 @@ void ActNpc295(NPCHAR *npc)
{32, 96, 104, 0x80}, {32, 96, 104, 0x80},
{104, 96, 144, 0x80}, {104, 96, 144, 0x80},
}; };
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:

View file

@ -150,7 +150,7 @@ void ActNpc302(NPCHAR *npc)
break; break;
} }
} }
if (i == 0x200) if (i == 0x200)
{ {
npc->cond = 0; npc->cond = 0;
@ -181,7 +181,7 @@ void ActNpc303(NPCHAR *npc)
{216, 168, 232, 184}, {216, 168, 232, 184},
{232, 168, 248, 184}, {232, 168, 248, 184},
}; };
if (npc->pNpc == NULL) if (npc->pNpc == NULL)
return; return;
@ -198,12 +198,12 @@ void ActNpc303(NPCHAR *npc)
} }
npc->y = npc->pNpc->y; npc->y = npc->pNpc->y;
//Animation //Animation
npc->ani_no = 0; npc->ani_no = 0;
if (npc->pNpc->ani_no == 3 || npc->pNpc->ani_no == 5) if (npc->pNpc->ani_no == 3 || npc->pNpc->ani_no == 5)
npc->y -= 0x200; npc->y -= 0x200;
//Set framerect //Set framerect
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
@ -220,7 +220,7 @@ void ActNpc304(NPCHAR *npc)
{48, 176, 72, 192}, {48, 176, 72, 192},
{72, 176, 96, 192}, {72, 176, 96, 192},
}; };
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -243,14 +243,14 @@ void ActNpc304(NPCHAR *npc)
npc->ani_wait = 0; npc->ani_wait = 0;
++npc->ani_no; ++npc->ani_no;
} }
if (npc->ani_no > 3) if (npc->ani_no > 3)
npc->ani_no = 2; npc->ani_no = 2;
break; break;
default: default:
break; break;
} }
npc->rect = rc[npc->ani_no]; npc->rect = rc[npc->ani_no];
} }
@ -266,7 +266,7 @@ void ActNpc305(NPCHAR *npc)
{160, 160, 176, 176}, {160, 160, 176, 176},
{176, 160, 192, 176}, {176, 160, 192, 176},
}; };
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -274,19 +274,19 @@ void ActNpc305(NPCHAR *npc)
npc->y -= 0x2000; npc->y -= 0x2000;
npc->ani_wait = Random(0, 6); npc->ani_wait = Random(0, 6);
//Fallthrough //Fallthrough
case 1: case 1:
if (++npc->ani_wait > 6) if (++npc->ani_wait > 6)
{ {
npc->ani_wait = 0; npc->ani_wait = 0;
++npc->ani_no; ++npc->ani_no;
} }
if (npc->ani_no > 1) if (npc->ani_no > 1)
npc->ani_no = 0; npc->ani_no = 0;
break; break;
} }
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
else else
@ -305,7 +305,7 @@ void ActNpc306(NPCHAR *npc)
{160, 152, 200, 184}, {160, 152, 200, 184},
{200, 152, 240, 184}, {200, 152, 240, 184},
}; };
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -330,7 +330,7 @@ void ActNpc306(NPCHAR *npc)
} }
break; break;
} }
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
else else
@ -349,7 +349,7 @@ void ActNpc307(NPCHAR *npc)
{0, 48, 16, 64}, {0, 48, 16, 64},
{16, 48, 32, 64}, {16, 48, 32, 64},
}; };
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -375,12 +375,12 @@ void ActNpc307(NPCHAR *npc)
} }
break; break;
} }
if (gMC.x < npc->x) if (gMC.x < npc->x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
else else

View file

@ -371,7 +371,7 @@ void ActNpc324(NPCHAR *npc)
npc->act_no = 0; npc->act_no = 0;
break; break;
} }
} }
//Heavy Press lightning //Heavy Press lightning
@ -508,15 +508,15 @@ void ActNpc326(NPCHAR *npc)
npc->ym += 0x40; npc->ym += 0x40;
if (npc->ym > 0x5FF) if (npc->ym > 0x5FF)
npc->ym = 0x5FF; npc->ym = 0x5FF;
npc->y += npc->ym; npc->y += npc->ym;
if (++npc->act_wait > 50) if (++npc->act_wait > 50)
{ {
npc->act_no = 30; npc->act_no = 30;
npc->act_wait = 0; npc->act_wait = 0;
npc->ani_no = 6; npc->ani_no = 6;
if (npc->direct == 0) if (npc->direct == 0)
SetNpChar(327, npc->x, npc->y - 0x2000, 0, 0, 0, npc, 0x100); SetNpChar(327, npc->x, npc->y - 0x2000, 0, 0, 0, npc, 0x100);
else else
@ -550,7 +550,7 @@ void ActNpc326(NPCHAR *npc)
break; break;
} }
RECT rcItoh[8] = { RECT rcItoh[8] = {
{0, 128, 16, 152}, {0, 128, 16, 152},
{16, 128, 32, 152}, {16, 128, 32, 152},
@ -572,7 +572,7 @@ void ActNpc326(NPCHAR *npc)
{224, 128, 240, 152}, {224, 128, 240, 152},
{32, 152, 48, 176}, {32, 152, 48, 176},
}; };
if (npc->direct == 0) if (npc->direct == 0)
npc->rect = rcItoh[npc->ani_no]; npc->rect = rcItoh[npc->ani_no];
else else
@ -586,15 +586,15 @@ void ActNpc327(NPCHAR *npc)
{240, 80, 256, 96}, {240, 80, 256, 96},
{256, 80, 272, 96}, {256, 80, 272, 96},
}; };
++npc->act_wait; ++npc->act_wait;
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
if (npc->act_wait < 4) if (npc->act_wait < 4)
npc->y -= 0x400; npc->y -= 0x400;
if (npc->pNpc->ani_no == 7) if (npc->pNpc->ani_no == 7)
{ {
npc->ani_no = 1; npc->ani_no = 1;
@ -603,7 +603,7 @@ void ActNpc327(NPCHAR *npc)
npc->tgt_y = npc->y; npc->tgt_y = npc->y;
} }
break; break;
case 1: case 1:
if (npc->act_wait < 48) if (npc->act_wait < 48)
{ {
@ -617,10 +617,10 @@ void ActNpc327(NPCHAR *npc)
} }
break; break;
} }
if (npc->act_wait > 70) if (npc->act_wait > 70)
npc->cond = 0; npc->cond = 0;
npc->rect = rc[npc->ani_no]; npc->rect = rc[npc->ani_no];
} }
@ -638,7 +638,7 @@ void ActNpc329(NPCHAR *npc)
{48, 0, 64, 16}, {48, 0, 64, 16},
{64, 0, 80, 16}, {64, 0, 80, 16},
}; };
if (++npc->ani_wait / 2 % 2) if (++npc->ani_wait / 2 % 2)
npc->rect = rc[0]; npc->rect = rc[0];
else else
@ -1136,5 +1136,5 @@ void ActNpc339(NPCHAR *npc)
} }
break; break;
} }
} }

View file

@ -1489,7 +1489,7 @@ void ActNpc352(NPCHAR *npc)
npc->ani_no = 0; npc->ani_no = 0;
npc->count1 = npc->direct / 100; npc->count1 = npc->direct / 100;
npc->direct %= 100; npc->direct %= 100;
//Set surfaces / offset //Set surfaces / offset
switch (npc->count1) switch (npc->count1)
{ {
@ -1503,7 +1503,7 @@ void ActNpc352(NPCHAR *npc)
default: default:
break; break;
} }
switch (npc->count1) switch (npc->count1)
{ {
case 2: case 2:
@ -1515,7 +1515,7 @@ void ActNpc352(NPCHAR *npc)
default: default:
break; break;
} }
//Balrog //Balrog
if (npc->count1 == 9) if (npc->count1 == 9)
{ {
@ -1523,7 +1523,7 @@ void ActNpc352(NPCHAR *npc)
npc->view.front = 0x2800; npc->view.front = 0x2800;
npc->x -= 0x200; npc->x -= 0x200;
} }
//Spawn King's sword //Spawn King's sword
if (!npc->count1) if (!npc->count1)
SetNpChar(145, 0, 0, 0, 0, 2, npc, 0x100); SetNpChar(145, 0, 0, 0, 0, 2, npc, 0x100);
@ -1532,18 +1532,18 @@ void ActNpc352(NPCHAR *npc)
npc->ym += 0x40; npc->ym += 0x40;
if (npc->ym > 0x5FF) if (npc->ym > 0x5FF)
npc->ym = 0x5FF; npc->ym = 0x5FF;
if (npc->flag & 8) if (npc->flag & 8)
{ {
npc->ym = 0; npc->ym = 0;
npc->act_no = 2; npc->act_no = 2;
npc->ani_no = 1; npc->ani_no = 1;
} }
npc->y += npc->ym; npc->y += npc->ym;
break; break;
} }
RECT rc[28] = { RECT rc[28] = {
{304, 48, 320, 64}, {304, 48, 320, 64},
{224, 48, 240, 64}, {224, 48, 240, 64},
@ -1574,7 +1574,7 @@ void ActNpc352(NPCHAR *npc)
{48, 16, 64, 32}, {48, 16, 64, 32},
{48, 0, 64, 16} {48, 0, 64, 16}
}; };
npc->rect = rc[npc->ani_no + 2 * npc->count1]; npc->rect = rc[npc->ani_no + 2 * npc->count1];
} }
@ -1981,6 +1981,6 @@ void ActNpc360(NPCHAR *npc)
npc->x -= 0x1000; npc->x -= 0x1000;
npc->y -= 0x1000; npc->y -= 0x1000;
} }
npc->rect = rc; npc->rect = rc;
} }

View file

@ -24,7 +24,7 @@ void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y)
npc->x = ((2 * x + 1) << 12) + npc->hit.back; npc->x = ((2 * x + 1) << 12) + npc->hit.back;
hit |= 1; hit |= 1;
} }
if (npc->y - npc->hit.top < ((2 * y + 1) << 12) - 0x600 if (npc->y - npc->hit.top < ((2 * y + 1) << 12) - 0x600
&& npc->y + npc->hit.bottom > ((2 * y - 1) << 12) + 0x600 && npc->y + npc->hit.bottom > ((2 * y - 1) << 12) + 0x600
&& npc->hit.back + npc->x > (2 * x - 1) << 12 && npc->hit.back + npc->x > (2 * x - 1) << 12
@ -33,7 +33,7 @@ void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y)
npc->x = ((2 * x - 1) << 12) - npc->hit.back; npc->x = ((2 * x - 1) << 12) - npc->hit.back;
hit |= 4; hit |= 4;
} }
if (npc->x - npc->hit.back < ((2 * x + 1) << 12) - 0x600 if (npc->x - npc->hit.back < ((2 * x + 1) << 12) - 0x600
&& npc->hit.back + npc->x > ((2 * x - 1) << 12) + 0x600 && npc->hit.back + npc->x > ((2 * x - 1) << 12) + 0x600
&& npc->y - npc->hit.top < (2 * y + 1) << 12 && npc->y - npc->hit.top < (2 * y + 1) << 12
@ -43,7 +43,7 @@ void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y)
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 < ((2 * x + 1) << 12) - 0x600
&& npc->hit.back + npc->x > ((2 * x - 1) << 12) + 0x600 && npc->hit.back + npc->x > ((2 * x - 1) << 12) + 0x600
&& npc->y + npc->hit.bottom > (2 * y - 1) << 12 && npc->y + npc->hit.bottom > (2 * y - 1) << 12
@ -53,14 +53,14 @@ void JadgeHitNpCharBlock(NPCHAR *npc, int x, int y)
npc->ym = 0; npc->ym = 0;
hit |= 8; hit |= 8;
} }
npc->flag |= hit; npc->flag |= hit;
} }
void JudgeHitNpCharTriangleA(NPCHAR *npc, int x, int y) void JudgeHitNpCharTriangleA(NPCHAR *npc, int x, int y)
{ {
int hit = 0; int hit = 0;
if (npc->x < (2 * x + 1) << 12 if (npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12 && npc->x > (2 * x - 1) << 12
&& npc->y - npc->hit.top < (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800 && npc->y - npc->hit.top < (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800
@ -68,22 +68,22 @@ void JudgeHitNpCharTriangleA(NPCHAR *npc, int x, int y)
{ {
//Clip //Clip
npc->y = npc->hit.top + (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800; npc->y = npc->hit.top + (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800;
//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;
} }
void JudgeHitNpCharTriangleB(NPCHAR *npc, int x, int y) void JudgeHitNpCharTriangleB(NPCHAR *npc, int x, int y)
{ {
int hit = 0; int hit = 0;
if (npc->x < (2 * x + 1) << 12 if (npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12 && npc->x > (2 * x - 1) << 12
&& npc->y - npc->hit.top < (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800 && npc->y - npc->hit.top < (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800
@ -91,22 +91,22 @@ void JudgeHitNpCharTriangleB(NPCHAR *npc, int x, int y)
{ {
//Clip //Clip
npc->y = npc->hit.top + (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800; npc->y = npc->hit.top + (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800;
//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;
} }
void JudgeHitNpCharTriangleC(NPCHAR *npc, int x, int y) void JudgeHitNpCharTriangleC(NPCHAR *npc, int x, int y)
{ {
int hit = 0; int hit = 0;
if (npc->x < (2 * x + 1) << 12 if (npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12 && npc->x > (2 * x - 1) << 12
&& npc->y - npc->hit.top < (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800 && npc->y - npc->hit.top < (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800
@ -114,22 +114,22 @@ void JudgeHitNpCharTriangleC(NPCHAR *npc, int x, int y)
{ {
//Clip //Clip
npc->y = npc->hit.top + (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800; npc->y = npc->hit.top + (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800;
//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;
} }
void JudgeHitNpCharTriangleD(NPCHAR *npc, int x, int y) void JudgeHitNpCharTriangleD(NPCHAR *npc, int x, int y)
{ {
int hit = 0; int hit = 0;
if (npc->x < (2 * x + 1) << 12 if (npc->x < (2 * x + 1) << 12
&& npc->x > (2 * x - 1) << 12 && npc->x > (2 * x - 1) << 12
&& npc->y - npc->hit.top < (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800 && npc->y - npc->hit.top < (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800
@ -137,15 +137,15 @@ void JudgeHitNpCharTriangleD(NPCHAR *npc, int x, int y)
{ {
//Clip //Clip
npc->y = npc->hit.top + (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800; npc->y = npc->hit.top + (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800;
//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;
} }
@ -160,15 +160,15 @@ void JudgeHitNpCharTriangleE(NPCHAR *npc, int x, int y)
{ {
//Clip //Clip
npc->y = (y << 13) + (-0x2000 * x + npc->x) / 2 - 0x800 - npc->hit.bottom; npc->y = (y << 13) + (-0x2000 * x + npc->x) / 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 = 0x10028;
} }
npc->flag |= hit; npc->flag |= hit;
} }
@ -183,15 +183,15 @@ void JudgeHitNpCharTriangleF(NPCHAR *npc, int x, int y)
{ {
//Clip //Clip
npc->y = (y << 13) + (-0x2000 * x + npc->x) / 2 + 0x800 - npc->hit.bottom; npc->y = (y << 13) + (-0x2000 * x + npc->x) / 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 = 0x20028;
} }
npc->flag |= hit; npc->flag |= hit;
} }
@ -206,15 +206,15 @@ void JudgeHitNpCharTriangleG(NPCHAR *npc, int x, int y)
{ {
//Clip //Clip
npc->y = (y << 13) - (-0x2000 * x + npc->x) / 2 + 0x800 - npc->hit.bottom; npc->y = (y << 13) - (-0x2000 * x + npc->x) / 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 = 0x40018;
} }
npc->flag |= hit; npc->flag |= hit;
} }
@ -229,28 +229,28 @@ void JudgeHitNpCharTriangleH(NPCHAR *npc, int x, int y)
{ {
//Clip //Clip
npc->y = (y << 13) - (-0x2000 * x + npc->x) / 2 - 0x800 - npc->hit.bottom; npc->y = (y << 13) - (-0x2000 * x + npc->x) / 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 = 0x80018;
} }
npc->flag |= hit; npc->flag |= hit;
} }
void JudgeHitNpCharWater(NPCHAR *npc, int x, int y) 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 < (4 * (2 * x + 1) - 1) << 10
&& npc->hit.back + npc->x > (4 * (2 * x - 1) + 1) << 10 && npc->hit.back + npc->x > (4 * (2 * x - 1) + 1) << 10
&& npc->y - npc->hit.top < (4 * (2 * y + 1) - 1) << 10 && npc->y - npc->hit.top < (4 * (2 * y + 1) - 1) << 10
&& npc->y + npc->hit.bottom > (4 * (2 * y - 1) + 1) << 10) && npc->y + npc->hit.bottom > (4 * (2 * y - 1) + 1) << 10)
hit = 0x100; hit = 0x100;
npc->flag |= hit; npc->flag |= hit;
} }
@ -258,7 +258,7 @@ void HitNpCharMap()
{ {
int offy[9]; int offy[9];
int offx[9]; int offx[9];
offx[0] = 0; offx[0] = 0;
offx[1] = 1; offx[1] = 1;
offx[2] = 0; offx[2] = 0;
@ -268,7 +268,7 @@ void HitNpCharMap()
offx[6] = 2; offx[6] = 2;
offx[7] = 0; offx[7] = 0;
offx[8] = 1; offx[8] = 1;
offy[0] = 0; offy[0] = 0;
offy[1] = 0; offy[1] = 0;
offy[2] = 1; offy[2] = 1;
@ -278,7 +278,7 @@ void HitNpCharMap()
offy[6] = 2; offy[6] = 2;
offy[7] = 2; offy[7] = 2;
offy[8] = 2; offy[8] = 2;
for (int i = 0; i < NPC_MAX; i++) for (int i = 0; i < NPC_MAX; i++)
{ {
if ((gNPC[i].cond & 0x80) && !(gNPC[i].bits & 8)) if ((gNPC[i].cond & 0x80) && !(gNPC[i].bits & 8))
@ -296,9 +296,9 @@ void HitNpCharMap()
x = (gNPC[i].x - 0x1000) / 0x2000; x = (gNPC[i].x - 0x1000) / 0x2000;
y = (gNPC[i].y - 0x1000) / 0x2000; y = (gNPC[i].y - 0x1000) / 0x2000;
} }
gNPC[i].flag = 0; gNPC[i].flag = 0;
for (int j = 0; j < judg; j++) for (int j = 0; j < judg; j++)
{ {
switch (GetAttribute(x + offx[j], y + offy[j])) switch (GetAttribute(x + offx[j], y + offy[j]))
@ -309,7 +309,7 @@ void HitNpCharMap()
case 0x62: case 0x62:
JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharWater(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
//Block //Block
case 0x03: case 0x03:
case 0x05: case 0x05:
@ -317,7 +317,7 @@ void HitNpCharMap()
case 0x43: case 0x43:
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]); JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
//Water block //Water block
case 0x04: case 0x04:
case 0x61: case 0x61:
@ -325,89 +325,89 @@ void HitNpCharMap()
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]); JadgeHitNpCharBlock(&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;
//No NPC block //No NPC block
case 0x44: case 0x44:
if (!(gNPC[i].bits & npc_ignore44)) if (!(gNPC[i].bits & npc_ignore44))
JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]); JadgeHitNpCharBlock(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
//Slopes //Slopes
case 0x50: case 0x50:
JudgeHitNpCharTriangleA(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleA(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x51: case 0x51:
JudgeHitNpCharTriangleB(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleB(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x52: case 0x52:
JudgeHitNpCharTriangleC(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleC(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x53: case 0x53:
JudgeHitNpCharTriangleD(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleD(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x54: case 0x54:
JudgeHitNpCharTriangleE(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleE(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x55: case 0x55:
JudgeHitNpCharTriangleF(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleF(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x56: case 0x56:
JudgeHitNpCharTriangleG(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleG(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
case 0x57: case 0x57:
JudgeHitNpCharTriangleH(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleH(&gNPC[i], x + offx[j], y + offy[j]);
break; break;
//Water slopes //Water slopes
case 0x70: case 0x70:
JudgeHitNpCharTriangleA(&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 0x71:
JudgeHitNpCharTriangleB(&gNPC[i], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleB(&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 0x72:
JudgeHitNpCharTriangleC(&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 0x73: case 0x73:
JudgeHitNpCharTriangleD(&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 0x74: case 0x74:
JudgeHitNpCharTriangleE(&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 0x75: case 0x75:
JudgeHitNpCharTriangleF(&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 0x76: case 0x76:
JudgeHitNpCharTriangleG(&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 0x77: case 0x77:
JudgeHitNpCharTriangleH(&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;
} }
} }
if (gNPC[i].y > gWaterY + 0x800) if (gNPC[i].y > gWaterY + 0x800)
gNPC[i].flag |= 0x100; gNPC[i].flag |= 0x100;
} }
@ -418,7 +418,7 @@ void LoseNpChar(NPCHAR *npc, bool bVanish)
{ {
//Play death sound //Play death sound
PlaySoundObject(npc->destroy_voice, 1); PlaySoundObject(npc->destroy_voice, 1);
//Create smoke //Create smoke
switch (npc->size) switch (npc->size)
{ {
@ -432,13 +432,13 @@ void LoseNpChar(NPCHAR *npc, bool bVanish)
SetDestroyNpChar(npc->x, npc->y, npc->view.back, 12); SetDestroyNpChar(npc->x, npc->y, npc->view.back, 12);
break; break;
} }
//Create drop //Create drop
if (npc->exp) if (npc->exp)
{ {
int v3 = Random(1, 5); int v3 = Random(1, 5);
char v4; char v4;
if (v3 == 1) if (v3 == 1)
{ {
if (npc->exp <= 6) if (npc->exp <= 6)
@ -451,10 +451,10 @@ void LoseNpChar(NPCHAR *npc, bool bVanish)
SetExpObjects(npc->x, npc->y, npc->exp); SetExpObjects(npc->x, npc->y, npc->exp);
} }
} }
//Set flag //Set flag
SetNPCFlag(npc->code_flag); SetNPCFlag(npc->code_flag);
//Create value view //Create value view
if (!(npc->bits & npc_showDamage)) if (!(npc->bits & npc_showDamage))
{ {
@ -493,14 +493,14 @@ void HitNpCharBullet()
&& gNPC[n].y - gNPC[n].hit.top < gBul[b].y + gBul[b].blockYL && 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) && gNPC[n].y + gNPC[n].hit.bottom > gBul[b].y - gBul[b].blockYL)
bHit = true; bHit = true;
if (bHit) if (bHit)
{ {
//Damage NPC //Damage NPC
if (gNPC[n].bits & npc_shootable) if (gNPC[n].bits & npc_shootable)
{ {
gNPC[n].life -= gBul[b].damage; gNPC[n].life -= gBul[b].damage;
if (gNPC[n].life > 0) if (gNPC[n].life > 0)
{ {
if (gNPC[n].shock < 14) if (gNPC[n].shock < 14)
@ -511,17 +511,17 @@ void HitNpCharBullet()
PlaySoundObject(gNPC[n].hit_voice, 1); PlaySoundObject(gNPC[n].hit_voice, 1);
gNPC[n].shock = 16; gNPC[n].shock = 16;
} }
if (gNPC[n].bits & npc_showDamage) if (gNPC[n].bits & npc_showDamage)
gNPC[n].damage_view -= gBul[b].damage; gNPC[n].damage_view -= gBul[b].damage;
} }
else else
{ {
gNPC[n].life = 0; gNPC[n].life = 0;
if (gNPC[n].bits & npc_showDamage) if (gNPC[n].bits & npc_showDamage)
gNPC[n].damage_view -= gBul[b].damage; gNPC[n].damage_view -= gBul[b].damage;
if ((gMC.cond & 0x80) && gNPC[n].bits & npc_eventDie) if ((gMC.cond & 0x80) && gNPC[n].bits & npc_eventDie)
StartTextScript(gNPC[n].code_event); StartTextScript(gNPC[n].code_event);
else else
@ -542,12 +542,12 @@ void HitNpCharBullet()
gBul[b].life = 0; gBul[b].life = 0;
continue; continue;
} }
--gBul[b].life; --gBul[b].life;
} }
} }
} }
if (gNPC[n].cond & 8) if (gNPC[n].cond & 8)
LoseNpChar(&gNPC[n], true); LoseNpChar(&gNPC[n], true);
} }

View file

@ -46,7 +46,7 @@ bool LoadNpcTable(const char *path)
fread(&gNpcTable[n].hit, 4, 1, fp); fread(&gNpcTable[n].hit, 4, 1, fp);
for (long n = 0; n < num; n++) //view for (long n = 0; n < num; n++) //view
fread(&gNpcTable[n].view, 4, 1, fp); fread(&gNpcTable[n].view, 4, 1, fp);
fclose(fp); fclose(fp);
return true; return true;
} }

View file

@ -41,7 +41,7 @@ bool OrganyaNoteAlloc(uint16_t alloc)
info.tdata[j].wave_no = 0; info.tdata[j].wave_no = 0;
info.tdata[j].note_list = NULL; info.tdata[j].note_list = NULL;
info.tdata[j].note_p = new NOTELIST[alloc]; info.tdata[j].note_p = new NOTELIST[alloc];
if(info.tdata[j].note_p == NULL) if(info.tdata[j].note_p == NULL)
{ {
for(int i = 0; i < MAXTRACK; i++) for(int i = 0; i < MAXTRACK; i++)
@ -66,7 +66,7 @@ bool OrganyaNoteAlloc(uint16_t alloc)
(info.tdata[j].note_p + i)->y = KEYDUMMY; (info.tdata[j].note_p + i)->y = KEYDUMMY;
} }
} }
for(int j = 0; j < MAXMELODY; j++) for(int j = 0; j < MAXMELODY; j++)
MakeOrganyaWave(j, info.tdata[j].wave_no, info.tdata[j].pipi); MakeOrganyaWave(j, info.tdata[j].wave_no, info.tdata[j].pipi);
//for(int j = 0; j < MAXDRAM; j++) //for(int j = 0; j < MAXDRAM; j++)
@ -119,29 +119,29 @@ bool MakeSoundObject8(int8_t *wavep, int8_t track, int8_t pipi)
{ {
size_t wave_size = oct_wave[j].wave_size; size_t wave_size = oct_wave[j].wave_size;
size_t data_size = pipi ? wave_size * oct_wave[j].oct_size : wave_size; size_t data_size = pipi ? wave_size * oct_wave[j].oct_size : wave_size;
//Create sound buffer //Create sound buffer
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]; uint8_t *wp = new uint8_t[data_size];
uint8_t *wp_sub = wp; uint8_t *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); uint8_t work = *(wavep+wav_tp);
work += 0x80; work += 0x80;
*wp_sub = work; *wp_sub = work;
wav_tp += 0x100 / wave_size; wav_tp += 0x100 / wave_size;
if (wav_tp >= 0x100) if (wav_tp >= 0x100)
wav_tp -= 0x100; wav_tp -= 0x100;
wp_sub++; wp_sub++;
} }
//Copy wave data to sound buffer //Copy wave data to sound buffer
uint8_t *buf; uint8_t *buf;
lpORGANBUFFER[track][j][k]->Lock(&buf, NULL); lpORGANBUFFER[track][j][k]->Lock(&buf, NULL);
@ -151,7 +151,7 @@ bool MakeSoundObject8(int8_t *wavep, int8_t track, int8_t pipi)
delete[] wp; delete[] wp;
} }
} }
return true; return true;
} }
@ -167,7 +167,7 @@ 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}; int16_t pan_tbl[13] = {0, 43, 86, 129, 172, 215, 256, 297, 340, 383, 426, 469, 512};
uint8_t old_key[MAXTRACK] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; uint8_t old_key[MAXTRACK] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
uint8_t key_on[MAXTRACK] = {0}; uint8_t key_on[MAXTRACK] = {0};
uint8_t key_twin[MAXTRACK] = {0}; uint8_t key_twin[MAXTRACK] = {0};
@ -197,10 +197,10 @@ void PlayOrganObject(uint8_t key, int mode, int8_t track, int32_t freq)
lpORGANBUFFER[track][old_key[track] / 12][key_twin[track]]->SetCurrentPosition(0); lpORGANBUFFER[track][old_key[track] / 12][key_twin[track]]->SetCurrentPosition(0);
} }
break; break;
case 1: case 1:
break; break;
case 2: case 2:
if (old_key[track] != 0xFF) if (old_key[track] != 0xFF)
{ {
@ -208,7 +208,7 @@ void PlayOrganObject(uint8_t key, int mode, int8_t track, int32_t freq)
old_key[track] = 0xFF; old_key[track] = 0xFF;
} }
break; break;
case -1: case -1:
if (old_key[track] == 0xFF) if (old_key[track] == 0xFF)
{ {
@ -222,7 +222,7 @@ void PlayOrganObject(uint8_t key, int mode, int8_t track, int32_t freq)
lpORGANBUFFER[track][old_key[track] / 12][key_twin[track]]->Play(false); lpORGANBUFFER[track][old_key[track] / 12][key_twin[track]]->Play(false);
key_twin[track]++; key_twin[track]++;
if(key_twin[track] == 2) if(key_twin[track] == 2)
key_twin[track] = 0; key_twin[track] = 0;
lpORGANBUFFER[track][key / 12][key_twin[track]]->Play(true); lpORGANBUFFER[track][key / 12][key_twin[track]]->Play(true);
} }
else else
@ -230,7 +230,7 @@ void PlayOrganObject(uint8_t key, int mode, int8_t track, int32_t freq)
lpORGANBUFFER[track][old_key[track]/12][key_twin[track]]->Play(false); lpORGANBUFFER[track][old_key[track]/12][key_twin[track]]->Play(false);
key_twin[track]++; key_twin[track]++;
if(key_twin[track] == 2) if(key_twin[track] == 2)
key_twin[track] = 0; key_twin[track] = 0;
ChangeOrganFrequency(key % 12, track, freq); ChangeOrganFrequency(key % 12, track, freq);
lpORGANBUFFER[track][key / 12][key_twin[track]]->Play(true); lpORGANBUFFER[track][key / 12][key_twin[track]]->Play(true);
old_key[track] = key; old_key[track] = key;
@ -281,7 +281,7 @@ bool MakeOrganyaWave(int8_t track, int8_t wave_no, int8_t pipi)
printf("WARNING: track %d has out-of-range wave_no %d\n", track, wave_no); printf("WARNING: track %d has out-of-range wave_no %d\n", track, wave_no);
return false; return false;
} }
ReleaseOrganyaObject(track); ReleaseOrganyaObject(track);
MakeSoundObject8(wave_data[wave_no], track, pipi); MakeSoundObject8(wave_data[wave_no], track, pipi);
return true; return true;
@ -347,44 +347,44 @@ void OrganyaPlayData()
PlayOrganObject(play_np[i]->y,-1,i,info.tdata[i].freq); PlayOrganObject(play_np[i]->y,-1,i,info.tdata[i].freq);
now_leng[i] = play_np[i]->length; now_leng[i] = play_np[i]->length;
} }
if(play_np[i]->pan != PANDUMMY) if(play_np[i]->pan != PANDUMMY)
ChangeOrganPan(play_np[i]->y,play_np[i]->pan, i); ChangeOrganPan(play_np[i]->y,play_np[i]->pan, i);
if(play_np[i]->volume != VOLDUMMY) if(play_np[i]->volume != VOLDUMMY)
gTrackVol[i] = play_np[i]->volume; gTrackVol[i] = play_np[i]->volume;
play_np[i] = play_np[i]->to; play_np[i] = play_np[i]->to;
} }
if (now_leng[i] == 0 ) if (now_leng[i] == 0 )
PlayOrganObject(0, 2, i, info.tdata[i].freq); PlayOrganObject(0, 2, i, info.tdata[i].freq);
if (now_leng[i] > 0) if (now_leng[i] > 0)
now_leng[i]--; now_leng[i]--;
if (play_np[i]) if (play_np[i])
ChangeOrganVolume(play_np[i]->y, gOrgVolume * gTrackVol[i] / 0x7F, i); ChangeOrganVolume(play_np[i]->y, gOrgVolume * gTrackVol[i] / 0x7F, i);
} }
for(int i = MAXMELODY; i < MAXTRACK; i++) for(int i = MAXMELODY; i < MAXTRACK; i++)
{ {
if (play_np[i] != NULL && play_p == play_np[i]->x) if (play_np[i] != NULL && play_p == play_np[i]->x)
{ {
if (play_np[i]->y != KEYDUMMY) if (play_np[i]->y != KEYDUMMY)
PlayDramObject(play_np[i]->y,1,i-MAXMELODY); PlayDramObject(play_np[i]->y,1,i-MAXMELODY);
if(play_np[i]->pan != PANDUMMY) if(play_np[i]->pan != PANDUMMY)
ChangeDramPan(play_np[i]->pan,i-MAXMELODY); ChangeDramPan(play_np[i]->pan,i-MAXMELODY);
if(play_np[i]->volume != VOLDUMMY) if(play_np[i]->volume != VOLDUMMY)
gTrackVol[i] = play_np[i]->volume; gTrackVol[i] = play_np[i]->volume;
play_np[i] = play_np[i]->to; play_np[i] = play_np[i]->to;
} }
if (play_np[i]) if (play_np[i])
ChangeDramVolume(gOrgVolume * gTrackVol[i] / 0x7F, i - MAXMELODY); ChangeDramVolume(gOrgVolume * gTrackVol[i] / 0x7F, i - MAXMELODY);
} }
//Looping //Looping
play_p++; play_p++;
if(play_p >= info.end_x) if(play_p >= info.end_x)
@ -402,7 +402,7 @@ void SetPlayPointer(int32_t x)
while (play_np[i] != NULL && play_np[i]->x < x) while (play_np[i] != NULL && play_np[i]->x < x)
play_np[i] = play_np[i]->to; play_np[i] = play_np[i]->to;
} }
play_p = x; play_p = x;
} }
@ -444,14 +444,14 @@ void LoadOrganya(const char *name)
printf("Failed to open .org, invalid version %s", pass_check); printf("Failed to open .org, invalid version %s", pass_check);
return; return;
} }
//Set song information //Set song information
info.wait = READ_LE16(p); info.wait = READ_LE16(p);
info.line = *p++; info.line = *p++;
info.dot = *p++; info.dot = *p++;
info.repeat_x = READ_LE32(p); info.repeat_x = READ_LE32(p);
info.end_x = READ_LE32(p); info.end_x = READ_LE32(p);
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++;
@ -525,7 +525,7 @@ void LoadOrganya(const char *name)
//Reset position //Reset position
SetPlayPointer(0); SetPlayPointer(0);
//Set as loaded //Set as loaded
info.loaded = true; info.loaded = true;
} }
@ -555,7 +555,7 @@ bool ChangeOrganyaVolume(signed int volume)
gOrgVolume = volume; gOrgVolume = volume;
return true; return true;
} }
return false; return false;
} }
@ -563,11 +563,11 @@ void StopOrganyaMusic()
{ {
//Stop timer //Stop timer
OrganyaEndTimer(); OrganyaEndTimer();
//Stop notes //Stop notes
for (int i = 0; i < MAXMELODY; i++) for (int i = 0; i < MAXMELODY; i++)
PlayOrganObject(0, 2, i, 0); PlayOrganObject(0, 2, i, 0);
memset(old_key, 255, sizeof(old_key)); memset(old_key, 255, sizeof(old_key));
memset(key_on, 0, sizeof(key_on)); memset(key_on, 0, sizeof(key_on));
memset(key_twin, 0, sizeof(key_twin)); memset(key_twin, 0, sizeof(key_twin));
@ -585,21 +585,21 @@ bool bEndTimer = false;
int OrganyaPlayTimer(void *ptr) 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_t NextTick = SDL_GetTicks() + info.wait;
while (bEndTimer == false) while (bEndTimer == false)
{ {
if (info.loaded) if (info.loaded)
{ {
//Play music //Play music
OrganyaPlayData(); OrganyaPlayData();
//Wait until this step is over //Wait until this step is over
while (NextTick > SDL_GetTicks()) while (NextTick > SDL_GetTicks())
SDL_Delay(1); SDL_Delay(1);
//Get time for next step to play //Get time for next step to play
while (NextTick <= SDL_GetTicks()) while (NextTick <= SDL_GetTicks())
NextTick += info.wait; NextTick += info.wait;
@ -610,7 +610,7 @@ int OrganyaPlayTimer(void *ptr)
SDL_Delay(1); SDL_Delay(1);
} }
} }
return 0; return 0;
} }
@ -639,10 +639,10 @@ void EndOrganya()
{ {
//End timer //End timer
OrganyaEndTimer(); OrganyaEndTimer();
//Release everything related to org //Release everything related to org
OrganyaReleaseNote(); OrganyaReleaseNote();
for (int i = 0; i < MAXMELODY; i++) for (int i = 0; i < MAXMELODY; i++)
ReleaseOrganyaObject(i); ReleaseOrganyaObject(i);
} }

View file

@ -31,11 +31,11 @@ bool IsProfile()
{ {
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/%s", gModulePath, gDefaultName); sprintf(path, "%s/%s", gModulePath, gDefaultName);
FILE *fp = fopen(path, "rb"); FILE *fp = fopen(path, "rb");
if (fp == NULL) if (fp == NULL)
return false; return false;
fclose(fp); fclose(fp);
return true; return true;
} }
@ -44,19 +44,19 @@ bool SaveProfile(const char *name)
{ {
//Get path //Get path
char path[PATH_LENGTH]; char path[PATH_LENGTH];
if (name) if (name)
sprintf(path, "%s/%s", gModulePath, name); sprintf(path, "%s/%s", gModulePath, name);
else else
sprintf(path, "%s/%s", gModulePath, gDefaultName); sprintf(path, "%s/%s", gModulePath, gDefaultName);
//Open file //Open file
PROFILE profile; PROFILE profile;
FILE *fp = fopen(path, "wb"); FILE *fp = fopen(path, "wb");
if (fp == NULL) if (fp == NULL)
return false; return false;
//Set up profile //Set up profile
memset(&profile, 0, sizeof(PROFILE)); memset(&profile, 0, sizeof(PROFILE));
memcpy(profile.code, gProfileCode, sizeof(profile.code)); memcpy(profile.code, gProfileCode, sizeof(profile.code));
@ -79,7 +79,7 @@ bool SaveProfile(const char *name)
memcpy(profile.permitstage, gPermitStage, sizeof(profile.permitstage)); memcpy(profile.permitstage, gPermitStage, sizeof(profile.permitstage));
memcpy(profile.permit_mapping, gMapping, sizeof(profile.permit_mapping)); memcpy(profile.permit_mapping, gMapping, sizeof(profile.permit_mapping));
memcpy(profile.flags, gFlagNPC, sizeof(profile.flags)); memcpy(profile.flags, gFlagNPC, sizeof(profile.flags));
//Write to file //Write to file
fwrite(profile.code, 8, 1, fp); fwrite(profile.code, 8, 1, fp);
File_WriteLE32(profile.stage, fp); File_WriteLE32(profile.stage, fp);
@ -114,7 +114,7 @@ bool SaveProfile(const char *name)
fwrite(profile.permit_mapping, 0x80, 1, fp); fwrite(profile.permit_mapping, 0x80, 1, fp);
fwrite("FLAG", 4, 1, fp); fwrite("FLAG", 4, 1, fp);
fwrite(profile.flags, 1000, 1, fp); fwrite(profile.flags, 1000, 1, fp);
fclose(fp); fclose(fp);
return true; return true;
} }
@ -123,19 +123,19 @@ bool LoadProfile(const char *name)
{ {
//Get path //Get path
char path[PATH_LENGTH]; char path[PATH_LENGTH];
if (name) if (name)
strcpy(path, name); strcpy(path, name);
else else
sprintf(path, "%s/%s", gModulePath, gDefaultName); sprintf(path, "%s/%s", gModulePath, gDefaultName);
//Open file //Open file
PROFILE profile; PROFILE profile;
FILE *fp = fopen(path, "rb"); FILE *fp = fopen(path, "rb");
if (fp == NULL) if (fp == NULL)
return false; return false;
//Check header code //Check header code
fread(profile.code, 8, 1, fp); fread(profile.code, 8, 1, fp);
if (memcmp(profile.code, gProfileCode, 8)) if (memcmp(profile.code, gProfileCode, 8))
@ -145,7 +145,7 @@ bool LoadProfile(const char *name)
#endif #endif
return false; return false;
} }
//Read data //Read data
fseek(fp, 0, SEEK_SET); //Pixel epic redundant code 😎😎😎 fseek(fp, 0, SEEK_SET); //Pixel epic redundant code 😎😎😎
fread(profile.code, 8, 1, fp); fread(profile.code, 8, 1, fp);
@ -182,7 +182,7 @@ bool LoadProfile(const char *name)
fread(profile.FLAG, 4, 1, fp); fread(profile.FLAG, 4, 1, fp);
fread(profile.flags, 1000, 1, fp); fread(profile.flags, 1000, 1, fp);
fclose(fp); fclose(fp);
//Set things //Set things
gSelectedArms = profile.select_arms; gSelectedArms = profile.select_arms;
gSelectedItem = profile.select_item; gSelectedItem = profile.select_item;
@ -193,13 +193,13 @@ bool LoadProfile(const char *name)
memcpy(gPermitStage, profile.permitstage, sizeof(gPermitStage)); memcpy(gPermitStage, profile.permitstage, sizeof(gPermitStage));
memcpy(gMapping, profile.permit_mapping, sizeof(gMapping)); memcpy(gMapping, profile.permit_mapping, sizeof(gMapping));
memcpy(gFlagNPC, profile.flags, sizeof(gFlagNPC)); memcpy(gFlagNPC, profile.flags, sizeof(gFlagNPC));
//Load stage //Load stage
ChangeMusic(profile.music); ChangeMusic(profile.music);
InitMyChar(); InitMyChar();
if (!TransferStage(profile.stage, 0, 0, 1)) if (!TransferStage(profile.stage, 0, 0, 1))
return false; return false;
//Set character properties //Set character properties
gMC.equip = profile.equip; gMC.equip = profile.equip;
gMC.unit = profile.unit; gMC.unit = profile.unit;
@ -212,12 +212,12 @@ bool LoadProfile(const char *name)
gMC.lifeBr = profile.life; gMC.lifeBr = profile.life;
gMC.x = profile.x; gMC.x = profile.x;
gMC.y = profile.y; gMC.y = profile.y;
gMC.rect_arms.left = 24 * (gArmsData[gSelectedArms].code % 10); gMC.rect_arms.left = 24 * (gArmsData[gSelectedArms].code % 10);
gMC.rect_arms.right = gMC.rect_arms.left + 24; gMC.rect_arms.right = gMC.rect_arms.left + 24;
gMC.rect_arms.top = 32 * (gArmsData[gSelectedArms].code / 10); gMC.rect_arms.top = 32 * (gArmsData[gSelectedArms].code / 10);
gMC.rect_arms.bottom = gMC.rect_arms.top + 16; gMC.rect_arms.bottom = gMC.rect_arms.top + 16;
//Reset stuff //Reset stuff
ClearFade(); ClearFade();
SetFrameMyChar(); SetFrameMyChar();

View file

@ -196,4 +196,4 @@ int StageSelectLoop(int *p_event)
while (Flip_SystemTask()); while (Flip_SystemTask());
return 0; return 0;
} }

View file

@ -99,7 +99,7 @@ void ShootBullet_PoleStar(int level)
bul_no = 6; bul_no = 6;
break; break;
} }
if (CountArmsBullet(2) > 1) if (CountArmsBullet(2) > 1)
return; return;
@ -150,7 +150,7 @@ void ShootBullet_PoleStar(int level)
SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0); SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0);
} }
} }
if (level == 3) if (level == 3)
PlaySoundObject(49, 1); PlaySoundObject(49, 1);
else else
@ -181,7 +181,7 @@ void ShootBullet_FireBall(int level)
bul_no = 9; bul_no = 9;
break; break;
} }
if (gKeyTrg & gKeyShot) if (gKeyTrg & gKeyShot)
{ {
if (!UseArmsEnergy(1)) if (!UseArmsEnergy(1))
@ -229,7 +229,7 @@ void ShootBullet_FireBall(int level)
SetCaret(gMC.x + 0x1800, gMC.y + 0x400, 3, 0); SetCaret(gMC.x + 0x1800, gMC.y + 0x400, 3, 0);
} }
} }
PlaySoundObject(34, 1); PlaySoundObject(34, 1);
} }
} }
@ -254,10 +254,10 @@ void ShootBullet_Machinegun1(int level)
bul_no = 12; bul_no = 12;
break; break;
} }
if (!(gKey & gKeyShot)) if (!(gKey & gKeyShot))
gMC.rensha = 6; gMC.rensha = 6;
if (gKey & gKeyShot) if (gKey & gKeyShot)
{ {
if (++gMC.rensha < 6) if (++gMC.rensha < 6)
@ -268,7 +268,7 @@ void ShootBullet_Machinegun1(int level)
if (!UseArmsEnergy(1)) if (!UseArmsEnergy(1))
{ {
PlaySoundObject(37, 1); PlaySoundObject(37, 1);
if (empty == 0) if (empty == 0)
{ {
SetCaret(gMC.x, gMC.y, 16, 0); SetCaret(gMC.x, gMC.y, 16, 0);
@ -283,7 +283,7 @@ void ShootBullet_Machinegun1(int level)
{ {
if (level == 3) if (level == 3)
gMC.ym += 0x100; gMC.ym += 0x100;
if (gMC.direct == 0) if (gMC.direct == 0)
{ {
SetBullet(bul_no, gMC.x - 0x600, gMC.y - 0x1000, 1); SetBullet(bul_no, gMC.x - 0x600, gMC.y - 0x1000, 1);
@ -301,7 +301,7 @@ void ShootBullet_Machinegun1(int level)
{ {
if (gMC.ym > 0) if (gMC.ym > 0)
gMC.ym /= 2; gMC.ym /= 2;
if (gMC.ym > -0x400) if (gMC.ym > -0x400)
{ {
gMC.ym -= 0x200; gMC.ym -= 0x200;
@ -309,7 +309,7 @@ void ShootBullet_Machinegun1(int level)
gMC.ym = -0x400; gMC.ym = -0x400;
} }
} }
if (gMC.direct == 0) if (gMC.direct == 0)
{ {
SetBullet(bul_no, gMC.x - 0x600, gMC.y + 0x1000, 3); SetBullet(bul_no, gMC.x - 0x600, gMC.y + 0x1000, 3);
@ -334,7 +334,7 @@ void ShootBullet_Machinegun1(int level)
SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0); SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0);
} }
} }
if (level == 3) if (level == 3)
PlaySoundObject(49, 1); PlaySoundObject(49, 1);
else else
@ -344,7 +344,7 @@ void ShootBullet_Machinegun1(int level)
else else
{ {
static int wait = 0; static int wait = 0;
++wait; ++wait;
if (gMC.equip & 8) if (gMC.equip & 8)
{ {
@ -354,7 +354,7 @@ void ShootBullet_Machinegun1(int level)
ChargeArmsEnergy(1); ChargeArmsEnergy(1);
} }
} }
else else
{ {
if (wait > 4) if (wait > 4)
{ {
@ -383,7 +383,7 @@ void ShootBullet_Missile(int level, BOOL bSuper)
bul_no = 30; bul_no = 30;
break; break;
} }
switch (level) switch (level)
{ {
case 1: case 1:
@ -413,7 +413,7 @@ void ShootBullet_Missile(int level, BOOL bSuper)
break; break;
} }
} }
else else
{ {
@ -429,7 +429,7 @@ void ShootBullet_Missile(int level, BOOL bSuper)
bul_no = 15; bul_no = 15;
break; break;
} }
switch (level) switch (level)
{ {
case 1: case 1:
@ -460,7 +460,7 @@ void ShootBullet_Missile(int level, BOOL bSuper)
break; break;
} }
} }
if (gKeyTrg & gKeyShot) if (gKeyTrg & gKeyShot)
{ {
if (level < 3) if (level < 3)
@ -1037,19 +1037,19 @@ void ShootBullet()
{ {
if (empty) if (empty)
--empty; --empty;
//Only let the player shoot every 4 frames //Only let the player shoot every 4 frames
static int soft_rensha; static int soft_rensha;
if (soft_rensha) if (soft_rensha)
--soft_rensha; --soft_rensha;
if (gKeyTrg & gKeyShot) if (gKeyTrg & gKeyShot)
{ {
if (soft_rensha) if (soft_rensha)
return; return;
soft_rensha = 4; soft_rensha = 4;
} }
//Run functions //Run functions
if (gMC.cond & 2) if (gMC.cond & 2)
return; return;

View file

@ -33,28 +33,28 @@ SOUNDBUFFER::SOUNDBUFFER(size_t bufSize)
{ {
//Lock audio buffer //Lock audio buffer
SDL_LockAudioDevice(audioDevice); SDL_LockAudioDevice(audioDevice);
//Set parameters //Set parameters
size = bufSize; size = bufSize;
playing = false; playing = false;
looping = false; looping = false;
looped = false; looped = false;
frequency = 0.0; frequency = 0.0;
volume = 1.0; volume = 1.0;
volume_l = 1.0; volume_l = 1.0;
volume_r = 1.0; volume_r = 1.0;
samplePosition = 0.0; samplePosition = 0.0;
//Create waveform buffer //Create waveform buffer
data = new uint8_t[bufSize]; data = new uint8_t[bufSize];
memset(data, 0x80, bufSize); memset(data, 0x80, bufSize);
//Add to buffer list //Add to buffer list
this->next = soundBuffers; this->next = soundBuffers;
soundBuffers = this; soundBuffers = this;
//Unlock audio buffer //Unlock audio buffer
SDL_UnlockAudioDevice(audioDevice); SDL_UnlockAudioDevice(audioDevice);
} }
@ -63,11 +63,11 @@ SOUNDBUFFER::~SOUNDBUFFER()
{ {
//Lock audio buffer //Lock audio buffer
SDL_LockAudioDevice(audioDevice); SDL_LockAudioDevice(audioDevice);
//Free buffer //Free buffer
if (data) if (data)
delete[] data; delete[] data;
//Remove from buffer list //Remove from buffer list
for (SOUNDBUFFER **soundBuffer = &soundBuffers; *soundBuffer != NULL; soundBuffer = &(*soundBuffer)->next) for (SOUNDBUFFER **soundBuffer = &soundBuffers; *soundBuffer != NULL; soundBuffer = &(*soundBuffer)->next)
{ {
@ -77,7 +77,7 @@ SOUNDBUFFER::~SOUNDBUFFER()
break; break;
} }
} }
//Unlock audio buffer //Unlock audio buffer
SDL_UnlockAudioDevice(audioDevice); SDL_UnlockAudioDevice(audioDevice);
} }
@ -163,25 +163,25 @@ void SOUNDBUFFER::Mix(float *buffer, size_t frames)
for (size_t i = 0; i < frames; ++i) for (size_t i = 0; i < frames; ++i)
{ {
const double freqPosition = frequency / FREQUENCY; //This is added to position at the end const double freqPosition = frequency / FREQUENCY; //This is added to position at the end
//Get the in-between sample this is (linear interpolation) //Get the in-between sample this is (linear interpolation)
const float sample1 = ((looped || ((size_t)samplePosition) >= 1) ? data[(size_t)samplePosition] : 128.0f); const float sample1 = ((looped || ((size_t)samplePosition) >= 1) ? data[(size_t)samplePosition] : 128.0f);
const float sample2 = ((looping || (((size_t)samplePosition) + 1) < size) ? data[(((size_t)samplePosition) + 1) % size] : 128.0f); const float sample2 = ((looping || (((size_t)samplePosition) + 1) < size) ? data[(((size_t)samplePosition) + 1) % size] : 128.0f);
//Interpolate sample //Interpolate sample
const float subPos = (float)std::fmod(samplePosition, 1.0); const float subPos = (float)std::fmod(samplePosition, 1.0);
const float sampleA = sample1 + (sample2 - sample1) * subPos; const float sampleA = sample1 + (sample2 - sample1) * subPos;
//Convert sample to float32 //Convert sample to float32
const float sampleConvert = (sampleA - 128.0f) / 128.0f; const float sampleConvert = (sampleA - 128.0f) / 128.0f;
//Mix //Mix
*buffer++ += (float)(sampleConvert * volume * volume_l); *buffer++ += (float)(sampleConvert * volume * volume_l);
*buffer++ += (float)(sampleConvert * volume * volume_r); *buffer++ += (float)(sampleConvert * volume * volume_r);
//Increment position //Increment position
samplePosition += freqPosition; samplePosition += freqPosition;
if (samplePosition >= size) if (samplePosition >= size)
{ {
if (looping) if (looping)
@ -211,7 +211,7 @@ void AudioCallback(void *userdata, Uint8 *stream, int len)
//Clear stream //Clear stream
for (size_t i = 0; i < frames * 2; ++i) for (size_t i = 0; i < frames * 2; ++i)
buffer[i] = 0.0f; buffer[i] = 0.0f;
//Mix sounds to primary buffer //Mix sounds to primary buffer
for (SOUNDBUFFER *sound = soundBuffers; sound != NULL; sound = sound->next) for (SOUNDBUFFER *sound = soundBuffers; sound != NULL; sound = sound->next)
sound->Mix(buffer, frames); sound->Mix(buffer, frames);
@ -224,10 +224,10 @@ bool InitDirectSound()
{ {
//Init sound //Init sound
SDL_InitSubSystem(SDL_INIT_AUDIO); SDL_InitSubSystem(SDL_INIT_AUDIO);
//Open audio device //Open audio device
SDL_AudioSpec want, have; SDL_AudioSpec want, have;
//Set specifications we want //Set specifications we want
SDL_memset(&want, 0, sizeof(want)); SDL_memset(&want, 0, sizeof(want));
want.freq = FREQUENCY; want.freq = FREQUENCY;
@ -237,16 +237,16 @@ bool InitDirectSound()
want.callback = AudioCallback; want.callback = AudioCallback;
audioDevice = SDL_OpenAudioDevice(NULL, 0, &want, &have, 0); audioDevice = SDL_OpenAudioDevice(NULL, 0, &want, &have, 0);
if (audioDevice == 0) if (audioDevice == 0)
{ {
printf("Failed to open audio device\nSDL Error: %s\n", SDL_GetError()); printf("Failed to open audio device\nSDL Error: %s\n", SDL_GetError());
return false; return false;
} }
//Unpause audio device //Unpause audio device
SDL_PauseAudioDevice(audioDevice, 0); SDL_PauseAudioDevice(audioDevice, 0);
//Start organya //Start organya
StartOrganya(); StartOrganya();
return true; return true;
@ -256,10 +256,10 @@ void EndDirectSound()
{ {
//Quit sub-system //Quit sub-system
SDL_QuitSubSystem(SDL_INIT_AUDIO); SDL_QuitSubSystem(SDL_INIT_AUDIO);
//Close audio device //Close audio device
SDL_CloseAudioDevice(audioDevice); SDL_CloseAudioDevice(audioDevice);
//End organya //End organya
EndOrganya(); EndOrganya();
} }

View file

@ -10,31 +10,31 @@ class SOUNDBUFFER
public: public:
SOUNDBUFFER(size_t bufSize); SOUNDBUFFER(size_t bufSize);
~SOUNDBUFFER(); ~SOUNDBUFFER();
void Release(); void Release();
void Lock(uint8_t **buffer, size_t *size); void Lock(uint8_t **buffer, size_t *size);
void Unlock(); void Unlock();
void SetCurrentPosition(uint32_t dwNewPosition); void SetCurrentPosition(uint32_t dwNewPosition);
void SetFrequency(uint32_t dwFrequency); void SetFrequency(uint32_t dwFrequency);
void SetVolume(int32_t lVolume); void SetVolume(int32_t lVolume);
void SetPan(int32_t lPan); void SetPan(int32_t lPan);
void Play(bool bLooping); void Play(bool bLooping);
void Stop(); void Stop();
void Mix(float *buffer, size_t frames); void Mix(float *buffer, size_t frames);
SOUNDBUFFER *next; SOUNDBUFFER *next;
private: private:
uint8_t *data; uint8_t *data;
size_t size; size_t size;
bool playing; bool playing;
bool looping; bool looping;
bool looped; bool looped;
double frequency; double frequency;
double volume; double volume;
double volume_l; double volume_l;

View file

@ -133,13 +133,13 @@ BOOL TransferStage(int no, int w, int x, int y)
{ {
//Move character //Move character
SetMyCharPosition(x << 13, y << 13); SetMyCharPosition(x << 13, y << 13);
BOOL bError = FALSE; BOOL bError = FALSE;
//Get path //Get path
char path_dir[20]; char path_dir[20];
strcpy(path_dir, "Stage"); strcpy(path_dir, "Stage");
//Load tileset //Load tileset
char path[PATH_LENGTH]; char path[PATH_LENGTH];
sprintf(path, "%s/Prt%s", path_dir, gTMT[no].parts); sprintf(path, "%s/Prt%s", path_dir, gTMT[no].parts);
@ -149,7 +149,7 @@ BOOL TransferStage(int no, int w, int x, int y)
sprintf(path, "%s/%s.pxa", path_dir, gTMT[no].parts); sprintf(path, "%s/%s.pxa", path_dir, gTMT[no].parts);
if (!LoadAttributeData(path)) if (!LoadAttributeData(path))
bError = TRUE; bError = TRUE;
//Load tilemap //Load tilemap
sprintf(path, "%s/%s.pxm", path_dir, gTMT[no].map); sprintf(path, "%s/%s.pxm", path_dir, gTMT[no].map);
if (!LoadMapData2(path)) if (!LoadMapData2(path))
@ -164,24 +164,24 @@ BOOL TransferStage(int no, int w, int x, int y)
sprintf(path, "%s/%s.tsc", path_dir, gTMT[no].map); sprintf(path, "%s/%s.tsc", path_dir, gTMT[no].map);
if (!LoadTextScript_Stage(path)) if (!LoadTextScript_Stage(path))
bError = TRUE; bError = TRUE;
//Load background //Load background
strcpy(path, gTMT[no].back); strcpy(path, gTMT[no].back);
if (!InitBack(path, gTMT[no].bkType)) if (!InitBack(path, gTMT[no].bkType))
bError = TRUE; bError = TRUE;
//Get path //Get path
strcpy(path_dir, "Npc"); strcpy(path_dir, "Npc");
//Load NPC sprite sheets //Load NPC sprite sheets
sprintf(path, "%s/Npc%s", path_dir, gTMT[no].npc); sprintf(path, "%s/Npc%s", path_dir, gTMT[no].npc);
if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_SPRITESET_1)) if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_SPRITESET_1))
bError = TRUE; bError = TRUE;
sprintf(path, "%s/Npc%s", path_dir, gTMT[no].boss); sprintf(path, "%s/Npc%s", path_dir, gTMT[no].boss);
if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_SPRITESET_2)) if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_SPRITESET_2))
bError = TRUE; bError = TRUE;
if (bError) if (bError)
{ {
printf("Failed to load stage %d\n", no); printf("Failed to load stage %d\n", no);
@ -191,7 +191,7 @@ BOOL TransferStage(int no, int w, int x, int y)
{ {
//Load map name //Load map name
ReadyMapName(gTMT[no].name); ReadyMapName(gTMT[no].name);
StartTextScript(w); StartTextScript(w);
SetFrameMyChar(); SetFrameMyChar();
ClearBullet(); ClearBullet();
@ -203,7 +203,7 @@ BOOL TransferStage(int no, int w, int x, int y)
gStageNo = no; gStageNo = no;
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
@ -270,10 +270,10 @@ void ChangeMusic(int no)
gOldPos = GetOrganyaPosition(); gOldPos = GetOrganyaPosition();
gOldNo = gMusicNo; gOldNo = gMusicNo;
StopOrganyaMusic(); StopOrganyaMusic();
//Load .org //Load .org
LoadOrganya(gMusicTable[no]); LoadOrganya(gMusicTable[no]);
//Reset position, volume, and then play the song //Reset position, volume, and then play the song
ChangeOrganyaVolume(100); ChangeOrganyaVolume(100);
SetOrganyaPosition(0); SetOrganyaPosition(0);
@ -286,10 +286,10 @@ void ReCallMusic()
{ {
//Stop old song //Stop old song
StopOrganyaMusic(); StopOrganyaMusic();
//Load .org that was playing before //Load .org that was playing before
LoadOrganya(gMusicTable[gOldNo]); LoadOrganya(gMusicTable[gOldNo]);
//Reset position, volume, and then play the song //Reset position, volume, and then play the song
SetOrganyaPosition(gOldPos); SetOrganyaPosition(gOldPos);
ChangeOrganyaVolume(100); ChangeOrganyaVolume(100);

View file

@ -31,24 +31,24 @@ void InitStar()
{ {
//Clear stars //Clear stars
memset(star, 0, sizeof(star)); memset(star, 0, sizeof(star));
//Position //Position
star[0].x = gMC.x; star[0].x = gMC.x;
star[0].y = gMC.y; star[0].y = gMC.y;
star[1].x = gMC.x; star[1].x = gMC.x;
star[1].y = gMC.y; star[1].y = gMC.y;
star[2].x = gMC.x; star[2].x = gMC.x;
star[2].y = gMC.y; star[2].y = gMC.y;
//Speed //Speed
star[0].xm = 0x400; star[0].xm = 0x400;
star[0].ym = -0x200; star[0].ym = -0x200;
star[1].xm = -0x200; star[1].xm = -0x200;
star[1].ym = 0x400; star[1].ym = 0x400;
star[2].xm = 0x200; star[2].xm = 0x200;
star[2].ym = 0x200; star[2].ym = 0x200;
} }
@ -58,7 +58,7 @@ void ActStar()
static int a; static int a;
a++; a++;
a %= 3; a %= 3;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
if (i) if (i)
@ -67,7 +67,7 @@ void ActStar()
star[i].xm -= 0x80; star[i].xm -= 0x80;
else else
star[i].xm += 0x80; star[i].xm += 0x80;
if (star[i - 1].y < star[i].y) if (star[i - 1].y < star[i].y)
star[i].ym -= 0xAA; star[i].ym -= 0xAA;
else else
@ -85,7 +85,7 @@ void ActStar()
else else
star[i].ym += 0xAA; star[i].ym += 0xAA;
} }
if (star[i].xm > 0xA00) if (star[i].xm > 0xA00)
star[i].xm = 0xA00; star[i].xm = 0xA00;
if (star[i].xm < -0xA00) if (star[i].xm < -0xA00)
@ -105,10 +105,10 @@ void ActStar()
star[i].ym = 0xA00; star[i].ym = 0xA00;
if (star[i].ym < -0xA00) if (star[i].ym < -0xA00)
star[i].ym = -0xA00; star[i].ym = -0xA00;
star[i].x += star[i].xm; star[i].x += star[i].xm;
star[i].y += star[i].ym; star[i].y += star[i].ym;
if (i < gMC.star && (gMC.equip & 0x80) && (g_GameFlags & 2) && a == i) if (i < gMC.star && (gMC.equip & 0x80) && (g_GameFlags & 2) && a == i)
SetBullet(45, star[a].x, star[a].y, 0); SetBullet(45, star[a].x, star[a].y, 0);
} }
@ -121,7 +121,7 @@ void PutStar(int fx, int fy)
{192, 8, 200, 16}, {192, 8, 200, 16},
{192, 16, 200, 24}, {192, 16, 200, 24},
}; };
if (gMC.cond & 2) if (gMC.cond & 2)
return; return;

View file

@ -10,49 +10,49 @@ struct TEXT_SCRIPT
{ {
//Path (reload when exit teleporter menu/inventory) //Path (reload when exit teleporter menu/inventory)
char path[PATH_LENGTH]; char path[PATH_LENGTH];
//Script buffer //Script buffer
int size; int size;
char *data; char *data;
//Mode (ex. NOD, WAI) //Mode (ex. NOD, WAI)
signed char mode; signed char mode;
//Flags //Flags
signed char flags; signed char flags;
//Current positions (read position in buffer, x position in line) //Current positions (read position in buffer, x position in line)
unsigned int p_read; unsigned int p_read;
unsigned int p_write; unsigned int p_write;
//Current line to write to //Current line to write to
int line; int line;
//Line y positions //Line y positions
int ypos_line[4]; int ypos_line[4];
//Event stuff //Event stuff
int wait; int wait;
int wait_next; int wait_next;
int next_event; int next_event;
//Yes/no selected //Yes/no selected
signed char select; signed char select;
//Current face //Current face
int face; int face;
int face_x; int face_x;
//Current item //Current item
int item; int item;
int item_y; int item_y;
//Text rect //Text rect
RECT rcText; RECT rcText;
//..? //..?
int offsetY; int offsetY;
//NOD cursor blink //NOD cursor blink
uint8_t wait_beam; uint8_t wait_beam;
}; };
@ -66,4 +66,4 @@ void GetTextScriptPath(char *path);
BOOL StartTextScript(int no); BOOL StartTextScript(int no);
void StopTextScript(); void StopTextScript();
void PutTextScript(); void PutTextScript();
int TextScriptProc(); int TextScriptProc();

View file

@ -17,7 +17,7 @@ void InitTriangleTable()
{ {
gSin[i] = (int)(sin(i * 6.2831998 / 256.0) * 512.0); gSin[i] = (int)(sin(i * 6.2831998 / 256.0) * 512.0);
} }
//Tangent //Tangent
for (i = 0; i < 0x21; ++i) for (i = 0; i < 0x21; ++i)
{ {
@ -118,6 +118,6 @@ uint8_t GetArktan(int x, int y)
} }
} }
} }
return a; return a;
} }

View file

@ -1,3 +1,3 @@
#pragma once #pragma once
//This was originally some sort of POSIX standard thing? leftover from the linux port //This was originally some sort of POSIX standard thing? leftover from the Linux port

View file

@ -38,7 +38,7 @@ void SetValueView(int *px, int *py, int value)
break; break;
} }
} }
if (i == VALUEVIEW_MAX) if (i == VALUEVIEW_MAX)
{ {
index = gVVIndex++; index = gVVIndex++;
@ -55,7 +55,7 @@ void SetValueView(int *px, int *py, int value)
gVV[index].value += value; gVV[index].value += value;
value = gVV[index].value; value = gVV[index].value;
} }
//Get if negative or not //Get if negative or not
if (value < 0) if (value < 0)
{ {
@ -66,10 +66,10 @@ void SetValueView(int *px, int *py, int value)
{ {
minus = FALSE; minus = FALSE;
} }
//Get width //Get width
v = value; v = value;
if (value > 999) if (value > 999)
width = 40; width = 40;
else if (value > 99) else if (value > 99)
@ -78,7 +78,7 @@ void SetValueView(int *px, int *py, int value)
width = 24; width = 24;
else else
width = 16; width = 16;
//Set properties //Set properties
gVV[index].flag = TRUE; gVV[index].flag = TRUE;
gVV[index].px = px; gVV[index].px = px;
@ -87,7 +87,7 @@ void SetValueView(int *px, int *py, int value)
gVV[index].rect.top = 8 * index; gVV[index].rect.top = 8 * index;
gVV[index].rect.right = 40; gVV[index].rect.right = 40;
gVV[index].rect.bottom = 8 * (index + 1); gVV[index].rect.bottom = 8 * (index + 1);
RECT rect[20] = { RECT rect[20] = {
{0, 56, 8, 64}, {0, 56, 8, 64},
{8, 56, 16, 64}, {8, 56, 16, 64},
@ -110,13 +110,13 @@ void SetValueView(int *px, int *py, int value)
{64, 64, 72, 72}, {64, 64, 72, 72},
{72, 64, 80, 72}, {72, 64, 80, 72},
}; };
//Get digits //Get digits
dig[0] = 1; dig[0] = 1;
dig[1] = 10; dig[1] = 10;
dig[2] = 100; dig[2] = 100;
dig[3] = 1000; dig[3] = 1000;
for (i = 3; i >= 0; i--) for (i = 3; i >= 0; i--)
{ {
fig[i] = 0; fig[i] = 0;
@ -126,20 +126,20 @@ void SetValueView(int *px, int *py, int value)
++fig[i]; ++fig[i];
} }
} }
sw = FALSE; sw = FALSE;
RECT rcPlus = {32, 48, 40, 56}; RECT rcPlus = {32, 48, 40, 56};
RECT rcMinus = {40, 48, 48, 56}; RECT rcMinus = {40, 48, 48, 56};
//Draw value //Draw value
CortBox2(&gVV[index].rect, 0x000000, SURFACE_ID_VALUE_VIEW); CortBox2(&gVV[index].rect, 0x000000, SURFACE_ID_VALUE_VIEW);
if (minus) if (minus)
Surface2Surface(gVV[index].rect.left, gVV[index].rect.top, &rcMinus, SURFACE_ID_VALUE_VIEW, SURFACE_ID_TEXT_BOX); Surface2Surface(gVV[index].rect.left, gVV[index].rect.top, &rcMinus, SURFACE_ID_VALUE_VIEW, SURFACE_ID_TEXT_BOX);
else else
Surface2Surface(gVV[index].rect.left, gVV[index].rect.top, &rcPlus, SURFACE_ID_VALUE_VIEW, SURFACE_ID_TEXT_BOX); Surface2Surface(gVV[index].rect.left, gVV[index].rect.top, &rcPlus, SURFACE_ID_VALUE_VIEW, SURFACE_ID_TEXT_BOX);
for (i = 3; i >= 0; i--) for (i = 3; i >= 0; i--)
{ {
if (sw == FALSE && i != 0 && fig[i] == 0) if (sw == FALSE && i != 0 && fig[i] == 0)