Merge branch 'accurate' into portable

This commit is contained in:
Clownacy 2019-11-10 12:17:40 +00:00
commit 531a6a0aeb
22 changed files with 48 additions and 40 deletions

View file

@ -766,7 +766,7 @@ void ActBossChar_MonstX(void)
gBoss[1].act_no = 20; gBoss[1].act_no = 20;
gBoss[2].act_no = 20; gBoss[2].act_no = 20;
// Fallthrough // Fallthrough
case 503: case 503: // Exactly identical to case 603
if (++npc->act_wait > 50) if (++npc->act_wait > 50)
{ {
if (npc->x > gMC.x) if (npc->x > gMC.x)
@ -803,7 +803,7 @@ void ActBossChar_MonstX(void)
gBoss[2].act_no = 40; gBoss[2].act_no = 40;
// Fallthrough // Fallthrough
case 603: case 603: // Exactly identical to case 503
if (++npc->act_wait > 50) if (++npc->act_wait > 50)
{ {
if (npc->x > gMC.x) if (npc->x > gMC.x)

View file

@ -66,6 +66,7 @@ BULLET gBul[BULLET_MAX];
void InitBullet() void InitBullet()
{ {
// Identical to ClearBullet
for (int i = 0; i < BULLET_MAX; i++) for (int i = 0; i < BULLET_MAX; i++)
gBul[i].cond = 0; gBul[i].cond = 0;
} }
@ -110,6 +111,7 @@ void DeleteBullet(int code)
void ClearBullet() void ClearBullet()
{ {
// Identical to InitBullet
for (int i = 0; i < BULLET_MAX; i++) for (int i = 0; i < BULLET_MAX; i++)
gBul[i].cond = 0; gBul[i].cond = 0;
} }
@ -2352,7 +2354,7 @@ void ActBullet()
case 33: case 33:
ActBullet_SuperBom(&gBul[i], 3); ActBullet_SuperBom(&gBul[i], 3);
break; break;
case 34: case 34: // Identical to case 43
ActBullet_Nemesis(&gBul[i], 1); ActBullet_Nemesis(&gBul[i], 1);
break; break;
case 35: case 35:
@ -2379,7 +2381,7 @@ void ActBullet()
case 42: case 42:
ActBullet_SpurTail(&gBul[i], 3); ActBullet_SpurTail(&gBul[i], 3);
break; break;
case 43: case 43: // Identical to case 34
ActBullet_Nemesis(&gBul[i], 1); ActBullet_Nemesis(&gBul[i], 1);
break; break;
case 44: case 44:

View file

@ -76,7 +76,7 @@ void StartFadeIn(signed char dir)
} }
} }
x = x; // What x = x; // x is assigned to itself. Thanks, Pixel. (Most likely, the original code wasn't written the exact same way)
} }
void ProcFade() void ProcFade()

View file

@ -535,7 +535,7 @@ int ModeAction(void)
} }
} }
if (swPlay % 2 && g_GameFlags & 1) if (swPlay % 2 && g_GameFlags & 1) // The "swPlay % 2" part is always true
{ {
if (g_GameFlags & 2) if (g_GameFlags & 2)
ActMyChar(TRUE); ActMyChar(TRUE);
@ -638,7 +638,7 @@ int ModeAction(void)
RotationArmsRev(); RotationArmsRev();
} }
if (swPlay % 2) if (swPlay % 2) // This is always true
{ {
switch (TextScriptProc()) switch (TextScriptProc())
{ {

View file

@ -27,7 +27,7 @@ void GetCompileDate(int *year, int *month, int *day)
months[10] = "Oct"; months[10] = "Oct";
months[11] = "Nov"; months[11] = "Nov";
months[12] = "Dec"; months[12] = "Dec";
sscanf(__DATE__, "%s %d %d", month_string, day, year); sscanf(__DATE__, "%s %d %d", month_string, day, year); // The expansion of __DATE__ is not reproductible. TODO : Think about changing this to be reproductible
for (i = 0; i < 12; ++i) // This being 12 instead of 13 might be a bug, but it works anyway by accident for (i = 0; i < 12; ++i) // This being 12 instead of 13 might be a bug, but it works anyway by accident
if (!memcmp(&month_string, months[i], 3)) if (!memcmp(&month_string, months[i], 3))

View file

@ -64,7 +64,7 @@ void WriteMiniMapLine(int line)
a == 83 || a == 83 ||
a == 84 || a == 84 ||
a == 87 || a == 87 ||
a == 96 || // This is already listed above a == 96 || // This is already listed above, so that part of the expression is always false
a == 112 || a == 112 ||
a == 115 || a == 115 ||
a == 116 || a == 116 ||

View file

@ -680,7 +680,7 @@ void ActMyChar_Normal(BOOL bKey)
// Change position // Change position
if (gMC.xm <= resist && gMC.xm >= -resist) if (gMC.xm <= resist && gMC.xm >= -resist)
{ {
// Okay, this is getting stupid. Why the HELL is the code written like this? // This case is completely empty. This is most likely the result of commented-out code or some other change (so this is most likely inaccurate to the original source code)
} }
else else
{ {

View file

@ -507,7 +507,7 @@ void HitMyCharMap()
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break; break;
// Water and water blocks // Water and water blocks (same as the previous case)
case 0x60: case 0x60:
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]); gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break; break;

View file

@ -138,7 +138,7 @@ void DamageMyChar(int 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 = (short)gMC.star - 1; // Why the hell is it written this way? gMC.star = (short)gMC.star - 1; // For some reason, this does a cast to short. Might not be accurate to the original source code (possibly, Pixel was just being careful about int size/conversion, or this is from some weird macro)
// Lose experience // Lose experience
if (gMC.equip & 4) if (gMC.equip & 4)

View file

@ -306,7 +306,7 @@ void ActNpc025(NPCHAR *npc)
break; break;
case 2: case 2: // Identical to case 4
if (++npc->act_wait <= 0x40) if (++npc->act_wait <= 0x40)
{ {
npc->y -= 0x200; npc->y -= 0x200;
@ -328,7 +328,7 @@ void ActNpc025(NPCHAR *npc)
break; break;
case 4: case 4: // Identical to case 2
if (++npc->act_wait <= 0x40) if (++npc->act_wait <= 0x40)
{ {
npc->y -= 0x200; npc->y -= 0x200;

View file

@ -1122,7 +1122,7 @@ void ActNpc051(NPCHAR *npc)
npc->tgt_x = npc->x; npc->tgt_x = npc->x;
npc->tgt_y = npc->y; npc->tgt_y = npc->y;
if (npc->direct == 0) if (npc->direct == 0) // Completely redundant as both the conditions are the same
npc->ym = 0x400; npc->ym = 0x400;
else else
npc->ym = 0x400; npc->ym = 0x400;
@ -1895,7 +1895,7 @@ void ActNpc058(NPCHAR *npc)
break; break;
} }
if (npc->act_no) if (npc->act_no) // This is always true
{ {
if (npc->act_wait < 150) if (npc->act_wait < 150)
++npc->act_wait; ++npc->act_wait;

View file

@ -991,6 +991,7 @@ void ActNpc088(NPCHAR *npc)
npc->act_wait = 0; npc->act_wait = 0;
npc->xm = 3 * npc->xm / 2; npc->xm = 3 * npc->xm / 2;
npc->damage = 2; npc->damage = 2;
break;
} }
else else
{ {
@ -1081,11 +1082,11 @@ void ActNpc088(NPCHAR *npc)
if (++npc->act_wait > 100 && npc->act_wait % 6 == 1) if (++npc->act_wait > 100 && npc->act_wait % 6 == 1)
{ {
if (npc->direct == 0) if (npc->direct == 0)
deg = -120; deg = 0x88;
else else
deg = -8; deg = 0xF8;
deg += (unsigned char)Random(-16, 16); deg += (unsigned char)Random(-0x10, 0x10);
ym = 3 * GetSin(deg); ym = 3 * GetSin(deg);
xm = 3 * GetCos(deg); xm = 3 * GetCos(deg);
SetNpChar(11, npc->x, npc->y + 0x800, xm, ym, 0, 0, 0x100); SetNpChar(11, npc->x, npc->y + 0x800, xm, ym, 0, 0, 0x100);

View file

@ -671,7 +671,7 @@ void ActNpc110(NPCHAR *npc)
if (npc->act_wait > 18) if (npc->act_wait > 18)
{ {
npc->act_no = 1; npc->act_no = 1;
npc->act_no = 1; npc->act_no = 1; // Duplicate line
} }
break; break;

View file

@ -69,8 +69,8 @@ void ActNpc160(NPCHAR *npc)
break; break;
case 3: case 3:
npc->damage = 20; npc->damage = 20; // Overriden by the following line
npc->damage = 0; // Smart code npc->damage = 0;
if (++npc->act_wait > 24) if (++npc->act_wait > 24)
{ {
@ -426,10 +426,10 @@ void ActNpc165(NPCHAR *npc)
{ {
case 0: case 0:
npc->act_no = 1; npc->act_no = 1;
npc->y += 0x1400; npc->y += 10 * 0x200;
// Fallthrough // Fallthrough
case 1: case 1:
if (npc->direct == 2 && gMC.x > npc->x - 0x4000 && gMC.x < npc->x + 0x4000 && gMC.y > npc->y - 0x2000 && gMC.y < npc->y + 0x2000) if (npc->direct == 2 && gMC.x > npc->x - (0x20 * 0x200) && gMC.x < npc->x + (0x20 * 0x200) && gMC.y > npc->y - (0x10 * 0x200) && gMC.y < npc->y + (0x10 * 0x200))
npc->ani_no = 1; npc->ani_no = 1;
else else
npc->ani_no = 0; npc->ani_no = 0;

View file

@ -985,8 +985,10 @@ void ActNpc190(NPCHAR *npc)
case 10: case 10:
PlaySoundObject(72, 1); PlaySoundObject(72, 1);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
SetNpChar(4, npc->x, npc->y + (Random(-8, 8) << 9), Random(-8, -2) << 9, Random(-3, 3) << 9, 0, 0, 0x100); SetNpChar(4, npc->x, npc->y + (Random(-8, 8) * 0x200), Random(-8, -2) * 0x200, Random(-3, 3) * 0x200, 0, 0, 0x100);
npc->cond = 0; npc->cond = 0;
break; break;
@ -996,8 +998,10 @@ void ActNpc190(NPCHAR *npc)
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;
} }
@ -1172,9 +1176,9 @@ void ActNpc192(NPCHAR *npc)
PlaySoundObject(34, 1); PlaySoundObject(34, 1);
if (npc->direct == 0) if (npc->direct == 0)
SetCaret(npc->x + 5120, npc->y + 5120, 7, 2); SetCaret(npc->x + (10 * 0x200), npc->y + (10 * 0x200), 7, 2);
else else
SetCaret(npc->x - 5120, npc->y + 5120, 7, 0); SetCaret(npc->x - (10 * 0x200), npc->y + (10 * 0x200), 7, 0);
} }
RECT rcLeft[2] = { RECT rcLeft[2] = {

View file

@ -1292,9 +1292,9 @@ void ActNpc268(NPCHAR *npc)
if (++npc->act_wait > 30 && npc->act_wait % 4 == 1) if (++npc->act_wait > 30 && npc->act_wait % 4 == 1)
{ {
if (npc->direct == 0) if (npc->direct == 0)
deg = -120; deg = 0x88;
else else
deg = -8; deg = 0xF8;
deg += (unsigned char)Random(-0x10, 0x10); deg += (unsigned char)Random(-0x10, 0x10);
ym = 5 * GetSin(deg); ym = 5 * GetSin(deg);

View file

@ -747,11 +747,11 @@ void ActNpc284(NPCHAR *npc)
npc->act_no = 34; npc->act_no = 34;
break; break;
case 0: case 0: // Identical to case 2
npc->act_no = 32; npc->act_no = 32;
break; break;
case 2: case 2: // Identical to case 0
npc->act_no = 32; npc->act_no = 32;
break; break;
} }

View file

@ -142,20 +142,20 @@ void ActNpc321(NPCHAR *npc)
break; break;
case 1: case 1:
if (gMC.direct == 0) if (gMC.direct == 0) // Does the same thing whether this is false or true
npc->x = npc->pNpc->x; npc->x = npc->pNpc->x;
else else
npc->x = npc->pNpc->x; // Duplicate derp npc->x = npc->pNpc->x;
direct = 1; direct = 1;
npc->y = npc->pNpc->y - 0x1400; npc->y = npc->pNpc->y - 0x1400;
break; break;
case 2: case 2:
if (gMC.direct == 0) if (gMC.direct == 0) // Does the same thing whether this is false or true
npc->x = npc->pNpc->x; npc->x = npc->pNpc->x;
else else
npc->x = npc->pNpc->x; // Duplicate derp npc->x = npc->pNpc->x;
direct = 3; direct = 3;
npc->y = npc->pNpc->y + 0x1400; npc->y = npc->pNpc->y + 0x1400;

View file

@ -520,7 +520,7 @@ void LoseNpChar(NPCHAR *npc, BOOL bVanish)
// Create value view // Create value view
if (npc->bits & NPC_SHOW_DAMAGE) if (npc->bits & NPC_SHOW_DAMAGE)
{ {
if ((npc->bits & NPC_SHOW_DAMAGE) && npc->damage_view) if ((npc->bits & NPC_SHOW_DAMAGE) && npc->damage_view) // npc->bits & NPC_SHOW_DAMAGE is already verified at this point, so this is redundant
SetValueView(&npc->x, &npc->y, npc->damage_view); SetValueView(&npc->x, &npc->y, npc->damage_view);
if (bVanish) if (bVanish)
VanishNpChar(npc); VanishNpChar(npc);

View file

@ -463,7 +463,7 @@ BOOL OrgData::SetMusicInfo(MUSICINFO *mi, unsigned long flag)
for (i = 0; i < MAXMELODY; i++) for (i = 0; i < MAXMELODY; i++)
{ {
info.tdata[i].freq = mi->tdata[i].freq; info.tdata[i].freq = mi->tdata[i].freq;
info.tdata[i].pipi = info.tdata[i].pipi; info.tdata[i].pipi = info.tdata[i].pipi; // info.tdata[i].pipi is assigned to itself. Thanks, Pixel. (Most likely, the original code wasn't written the exact same way)
} }
} }

View file

@ -304,10 +304,10 @@ int MakePixToneObject(const PIXTONEPARAMETER *ptp, int ptp_num, int no)
{ {
if (!MakePixelWaveData(ptp_pointer, pcm_buffer)) if (!MakePixelWaveData(ptp_pointer, pcm_buffer))
{ {
if (pcm_buffer) if (pcm_buffer != NULL) // This is always true
free(pcm_buffer); free(pcm_buffer);
if (mixed_pcm_buffer) if (mixed_pcm_buffer != NULL) // This is always true
free(mixed_pcm_buffer); free(mixed_pcm_buffer);
return -1; return -1;
@ -326,7 +326,7 @@ int MakePixToneObject(const PIXTONEPARAMETER *ptp, int ptp_num, int no)
++ptp_pointer; ++ptp_pointer;
} }
// Maybe this used to be something to prevent audio popping? // This is self-assignment, so redundant. Maybe this used to be something to prevent audio popping ?
mixed_pcm_buffer[0] = mixed_pcm_buffer[0]; mixed_pcm_buffer[0] = mixed_pcm_buffer[0];
mixed_pcm_buffer[sample_count - 1] = mixed_pcm_buffer[sample_count - 1]; mixed_pcm_buffer[sample_count - 1] = mixed_pcm_buffer[sample_count - 1];

View file

@ -96,6 +96,7 @@ void ActStar()
if (star[i].ym < -0xA00) if (star[i].ym < -0xA00)
star[i].ym = -0xA00; star[i].ym = -0xA00;
// Duplicate of the past 8 lines of code
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)