diff --git a/msvc2003/devilution/comparer-config.toml b/msvc2003/devilution/comparer-config.toml index 1be2088f..9b675d93 100644 --- a/msvc2003/devilution/comparer-config.toml +++ b/msvc2003/devilution/comparer-config.toml @@ -59,6 +59,218 @@ addr = 0x403650 name = "HitBulletMap" addr = 0x403740 +[[func]] +name = "InitBullet" +addr = 0x403C00 + +[[func]] +name = "CountArmsBullet" +addr = 0x403C40 + +[[func]] +name = "CountBulletNum" +addr = 0x403CB0 + +[[func]] +name = "DeleteBullet" +addr = 0x403D10 + +[[func]] +name = "ClearBullet" +addr = 0x403D80 + +[[func]] +name = "PutBullet" +addr = 0x403DC0 + +[[func]] +name = "SetBullet" +addr = 0x403F80 + +[[func]] +name = "ActBullet_Frontia1" +addr = 0x404160 + +[[func]] +name = "ActBullet_Frontia2" +addr = 0x4043F0 + +[[func]] +name = "ActBullet_PoleStar" +addr = 0x4047B0 + +[[func]] +name = "ActBullet_FireBall" +addr = 0x404B30 + +[[func]] +name = "ActBullet_MachineGun" +addr = 0x405120 + +[[func]] +name = "ActBullet_Missile" +addr = 0x4055A0 + +[[func]] +name = "ActBullet_Bom" +addr = 0x405D80 + +[[func]] +name = "ActBullet_Bubblin1" +addr = 0x405F30 + +[[func]] +name = "ActBullet_Bubblin2" +addr = 0x406190 + +[[func]] +name = "ActBullet_Bubblin3" +addr = 0x4064D0 + +[[func]] +name = "ActBullet_Spine" +addr = 0x4068B0 + +[[func]] +name = "ActBullet_Sword1" +addr = 0x406BB0 + +[[func]] +name = "ActBullet_Sword2" +addr = 0x406E60 + +[[func]] +name = "ActBullet_Sword3" +addr = 0x407110 + +[[func]] +name = "ActBullet_Edge" +addr = 0x4075E0 + +[[func]] +name = "ActBullet_Drop" +addr = 0x4078A0 + +[[func]] +name = "ActBullet_SuperMissile" +addr = 0x407910 + +[[func]] +name = "ActBullet_SuperBom" +addr = 0x408080 + +[[func]] +name = "ActBullet_Nemesis" +addr = 0x408230 + +[[func]] +name = "ActBullet_Spur" +addr = 0x408710 + +[[func]] +name = "ActBullet_SpurTail" +addr = 0x408AE0 + +[[func]] +name = "ActBullet_EnemyClear" +addr = 0x408F40 + +[[func]] +name = "ActBullet_Star" +addr = 0x408F90 + +[[func]] +name = "ActBullet" +addr = 0x408FC0 + +[[func]] +name = "IsActiveSomeBullet" +addr = 0x4095C0 + +[[func]] +name = "InitCaret" +addr = 0x409650 + +[[func]] +name = "ActCaret00" +addr = 0x409670 + +[[func]] +name = "ActCaret01" +addr = 0x409680 + +[[func]] +name = "ActCaret02" +addr = 0x409880 + +[[func]] +name = "ActCaret03" +addr = 0x409B80 + +[[func]] +name = "ActCaret04" +addr = 0x409C70 + +[[func]] +name = "ActCaret05" +addr = 0x409E00 + +[[func]] +name = "ActCaret07" +addr = 0x409F60 + +[[func]] +name = "ActCaret08" +addr = 0x40A120 + +[[func]] +name = "ActCaret09" +addr = 0x40A1B0 + +[[func]] +name = "ActCaret10" +addr = 0x40A280 + +[[func]] +name = "ActCaret11" +addr = 0x40A3F0 + +[[func]] +name = "ActCaret12" +addr = 0x40A5A0 + +[[func]] +name = "ActCaret13" +addr = 0x40A650 + +[[func]] +name = "ActCaret14" +addr = 0x40A7E0 + +[[func]] +name = "ActCaret15" +addr = 0x40A8F0 + +[[func]] +name = "ActCaret16" +addr = 0x40A9E0 + +[[func]] +name = "ActCaret17" +addr = 0x40AAA0 + +[[func]] +name = "ActCaret" +addr = 0x40AB50 + +[[func]] +name = "PutCaret" +addr = 0x40ABC0 + +[[func]] +name = "SetCaret" +addr = 0x40AC90 + [[func]] name = "Call_Escape" addr = 0x40DD70 @@ -342,6 +554,54 @@ addr = 0x41C8F0 name = "MakePixelWaveData" addr = 0x41CB10 +[[func]] +name = "ShootBullet_Frontia1" +addr = 0x41DBD0 + +[[func]] +name = "ShootBullet_PoleStar" +addr = 0x41DE60 + +[[func]] +name = "ShootBullet_FireBall" +addr = 0x41E110 + +[[func]] +name = "ShootBullet_Machinegun1" +addr = 0x41E3D0 + +[[func]] +name = "ShootBullet_Missile" +addr = 0x41E7B0 + +[[func]] +name = "ShootBullet_Bubblin1" +addr = 0x41EFD0 + +[[func]] +name = "ShootBullet_Bubblin2" +addr = 0x41F280 + +[[func]] +name = "ShootBullet_Sword" +addr = 0x41F580 + +[[func]] +name = "ShootBullet_Nemesis" +addr = 0x41F710 + +[[func]] +name = "ResetSpurCharge" +addr = 0x41F9E0 + +[[func]] +name = "ShootBullet_Spur" +addr = 0x41FA10 + +[[func]] +name = "ShootBullet" +addr = 0x41FE70 + [[func]] name = "PlaySoundObject" addr = 0x420640 diff --git a/src/Bullet.cpp b/src/Bullet.cpp index 886b158f..13bc94a3 100644 --- a/src/Bullet.cpp +++ b/src/Bullet.cpp @@ -96,7 +96,9 @@ int CountBulletNum(int bullet_code) void DeleteBullet(int code) { - for (int i = 0; i < BULLET_MAX; i++) + int i; + int unknown = 0; // Not the original name + for (i = 0; i < BULLET_MAX; i++) { if (gBul[i].cond & 0x80) { @@ -114,12 +116,13 @@ void ClearBullet() void PutBullet(int fx, int fy) { - for (int i = 0; i < BULLET_MAX; i++) + int i; + int x, y; + + for (i = 0; i < BULLET_MAX; i++) { if (gBul[i].cond & 0x80) - { - int x, y; - + { switch (gBul[i].direct) { case 0: @@ -147,31 +150,31 @@ void PutBullet(int fx, int fy) void SetBullet(int no, int x, int y, int dir) { - for (int i = 0; i < BULLET_MAX; i++) - { - if (!(gBul[i].cond & 0x80)) - { - memset(&gBul[i], 0, sizeof(BULLET)); - gBul[i].code_bullet = no; - gBul[i].cond = 0x80; - gBul[i].direct = dir; - gBul[i].damage = gBulTbl[no].damage; - gBul[i].life = gBulTbl[no].life; - gBul[i].life_count = gBulTbl[no].life_count; - gBul[i].bbits = gBulTbl[no].bbits; - gBul[i].enemyXL = gBulTbl[no].enemyXL << 9; - gBul[i].enemyYL = gBulTbl[no].enemyYL << 9; - gBul[i].blockXL = gBulTbl[no].blockXL << 9; - gBul[i].blockYL = gBulTbl[no].blockYL << 9; - gBul[i].view.back = gBulTbl[no].view.back << 9; - gBul[i].view.front = gBulTbl[no].view.front << 9; - gBul[i].view.top = gBulTbl[no].view.top << 9; - gBul[i].view.bottom = gBulTbl[no].view.bottom << 9; - gBul[i].x = x; - gBul[i].y = y; - break; - } - } + int i = 0; + while (i < BULLET_MAX && gBul[i].cond & 0x80) + ++i; + + if (i >= BULLET_MAX) + return; + + memset(&gBul[i], 0, sizeof(BULLET)); + gBul[i].code_bullet = no; + gBul[i].cond = 0x80; + gBul[i].direct = dir; + gBul[i].damage = gBulTbl[no].damage; + gBul[i].life = gBulTbl[no].life; + gBul[i].life_count = gBulTbl[no].life_count; + gBul[i].bbits = gBulTbl[no].bbits; + gBul[i].enemyXL = gBulTbl[no].enemyXL << 9; + gBul[i].enemyYL = gBulTbl[no].enemyYL << 9; + gBul[i].blockXL = gBulTbl[no].blockXL << 9; + gBul[i].blockYL = gBulTbl[no].blockYL << 9; + gBul[i].view.back = gBulTbl[no].view.back << 9; + gBul[i].view.front = gBulTbl[no].view.front << 9; + gBul[i].view.top = gBulTbl[no].view.top << 9; + gBul[i].view.bottom = gBulTbl[no].view.bottom << 9; + gBul[i].x = x; + gBul[i].y = y; } void ActBullet_Frontia1(BULLET *bul) @@ -183,12 +186,7 @@ void ActBullet_Frontia1(BULLET *bul) } else { - if (bul->act_no) - { - bul->x += bul->xm; - bul->y += bul->ym; - } - else + if (bul->act_no == 0) { bul->ani_no = Random(0, 2); bul->act_no = 1; @@ -209,6 +207,11 @@ void ActBullet_Frontia1(BULLET *bul) break; } } + else + { + bul->x += bul->xm; + bul->y += bul->ym; + } if (++bul->ani_wait > 0) { @@ -249,7 +252,52 @@ void ActBullet_Frontia2(BULLET *bul, int level) } else { - if (bul->act_no) + if (bul->act_no == 0) + { + bul->ani_no = Random(0, 2); + bul->act_no = 1; + + switch (bul->direct) + { + case 0: + bul->xm = -0x200; + break; + case 1: + bul->ym = -0x200; + break; + case 2: + bul->xm = 0x200; + break; + case 3: + bul->ym = 0x200; + break; + } + + static unsigned int inc; + ++inc; + + switch (bul->direct) + { + case 0: + case 2: + if (inc % 2) + bul->ym = 0x400; + else + bul->ym = -0x400; + + break; + + case 1: + case 3: + if (inc % 2) + bul->xm = 0x400; + else + bul->xm = -0x400; + + break; + } + } + else { switch (bul->direct) { @@ -297,51 +345,6 @@ void ActBullet_Frontia2(BULLET *bul, int level) bul->x += bul->xm; bul->y += bul->ym; } - else - { - bul->ani_no = Random(0, 2); - bul->act_no = 1; - - switch (bul->direct) - { - case 0: - bul->xm = -0x200; - break; - case 1: - bul->ym = -0x200; - break; - case 2: - bul->xm = 0x200; - break; - case 3: - bul->ym = 0x200; - break; - } - - static unsigned int inc; - ++inc; - - switch (bul->direct) - { - case 0: - case 2: - if (inc % 2) - bul->ym = 0x400; - else - bul->ym = -0x400; - - break; - - case 1: - case 3: - if (inc % 2) - bul->xm = -0x400; - else - bul->xm = 0x400; - - break; - } - } if ( ++bul->ani_wait > 0 ) { @@ -369,15 +372,18 @@ void ActBullet_Frontia2(BULLET *bul, int level) void ActBullet_PoleStar(BULLET *bul, int level) { - if (++bul->count1 <= bul->life_count) + RECT rect1[2]; + RECT rect2[2]; + RECT rect3[2]; + + if (++bul->count1 > bul->life_count) { - if (bul->act_no) - { - //Move - bul->x += bul->xm; - bul->y += bul->ym; - } - else + bul->cond = 0; + SetCaret(bul->x, bul->y, 3, 0); + } + else + { + if (bul->act_no == 0) { bul->act_no = 1; @@ -399,114 +405,108 @@ void ActBullet_PoleStar(BULLET *bul, int level) } //Set hitbox - if (level == 1) - { - switch (bul->direct) - { - case 0: - bul->enemyYL = 0x400; - break; - case 1: - bul->enemyXL = 0x400; - break; - case 2: - bul->enemyYL = 0x400; - break; - case 3: - bul->enemyXL = 0x400; - break; - } - } - else if (level == 2) - { - switch (bul->direct) - { - case 0: - bul->enemyYL = 0x800; - break; - case 1: - bul->enemyXL = 0x800; - break; - case 2: - bul->enemyYL = 0x800; - break; - case 3: - bul->enemyXL = 0x800; - break; - } - } - - //Set framerect switch (level) { case 1: - if (bul->direct != 1 && bul->direct != 3) + switch (bul->direct) { - bul->rect.left = 128; - bul->rect.top = 32; - bul->rect.right = 144; - bul->rect.bottom = 48; - } - else - { - bul->rect.left = 144; - bul->rect.top = 32; - bul->rect.right = 160; - bul->rect.bottom = 48; + case 0: + bul->enemyYL = 0x400; + break; + case 1: + bul->enemyXL = 0x400; + break; + case 2: + bul->enemyYL = 0x400; + break; + case 3: + bul->enemyXL = 0x400; + break; } break; case 2: - if (bul->direct != 1 && bul->direct != 3) + switch (bul->direct) { - bul->rect.left = 160; - bul->rect.top = 32; - bul->rect.right = 176; - bul->rect.bottom = 48; - } - else - { - bul->rect.left = 176; - bul->rect.top = 32; - bul->rect.right = 192; - bul->rect.bottom = 48; - - } - break; - case 3: - if (bul->direct != 1 && bul->direct != 3) - { - bul->rect.left = 128; - bul->rect.top = 48; - bul->rect.right = 144; - bul->rect.bottom = 64; - } - else - { - bul->rect.left = 144; - bul->rect.top = 48; - bul->rect.right = 160; - bul->rect.bottom = 64; + case 0: + bul->enemyYL = 0x800; + break; + case 1: + bul->enemyXL = 0x800; + break; + case 2: + bul->enemyYL = 0x800; + break; + case 3: + bul->enemyXL = 0x800; + break; } break; } } - } - else - { - bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); + else + { + //Move + bul->x += bul->xm; + bul->y += bul->ym; + } + + SET_RECT(rect1[0], 128, 32, 144, 48) + SET_RECT(rect1[1], 144, 32, 160, 48) + + SET_RECT(rect2[0], 160, 32, 176, 48) + SET_RECT(rect2[1], 176, 32, 192, 48) + + SET_RECT(rect3[0], 128, 48, 144, 64) + SET_RECT(rect3[1], 144, 48, 160, 64) + + //Set framerect + switch (level) + { + case 1: + if (bul->direct == 1 || bul->direct == 3) + bul->rect = rect1[1]; + else + bul->rect = rect1[0]; + + break; + case 2: + if (bul->direct == 1 || bul->direct == 3) + bul->rect = rect2[1]; + else + bul->rect = rect2[0]; + + break; + case 3: + if (bul->direct == 1 || bul->direct == 3) + bul->rect = rect3[1]; + else + bul->rect = rect3[0]; + + break; + } } } void ActBullet_FireBall(BULLET *bul, int level) { - if (++bul->count1 <= bul->life_count) + BOOL bBreak; + RECT rect_left1[4]; + RECT rect_right1[4]; + RECT rect_left2[3]; + RECT rect_right2[3]; + + if (++bul->count1 > bul->life_count) { - bool bBreak = false; + bul->cond = 0; + SetCaret(bul->x, bul->y, 3, 0); + } + else + { + bBreak = FALSE; if (bul->flag & 2 && bul->flag & 8) - bBreak = true; + bBreak = TRUE; if (bul->flag & 1 && bul->flag & 4) - bBreak = true; + bBreak = TRUE; if (!bul->direct && bul->flag & 1) bul->direct = 2; @@ -521,26 +521,7 @@ void ActBullet_FireBall(BULLET *bul, int level) } else { - if (bul->act_no) - { - if (bul->flag & 8) - bul->ym = -0x400; - else if (bul->flag & 1) - bul->xm = 0x400; - else if (bul->flag & 4) - bul->xm = -0x400; - - bul->ym += 85; - if (bul->ym >= 0x400) - bul->ym = 0x400; - - bul->x += bul->xm; - bul->y += bul->ym; - - if (bul->flag & 0xD) - PlaySoundObject(34, 1); - } - else + if (bul->act_no == 0) { bul->act_no = 1; @@ -552,15 +533,15 @@ void ActBullet_FireBall(BULLET *bul, int level) case 1: bul->xm = gMC.xm; - if (gMC.xm >= 0) - bul->direct = 2; - else + if (gMC.xm < 0) bul->direct = 0; - - if (gMC.direct) - bul->xm += 0x80; else + bul->direct = 2; + + if (gMC.direct == 0) bul->xm -= 0x80; + else + bul->xm += 0x80; bul->ym = -0x5FF; break; @@ -569,40 +550,54 @@ void ActBullet_FireBall(BULLET *bul, int level) break; case 3: bul->xm = gMC.xm; - if (gMC.xm >= 0) - bul->direct = 2; - else + + if (gMC.xm < 0) bul->direct = 0; + else + bul->direct = 2; + bul->ym = 0x5FF; + break; } } + else + { + if (bul->flag & 8) + bul->ym = -0x400; + else if (bul->flag & 1) + bul->xm = 0x400; + else if (bul->flag & 4) + bul->xm = -0x400; + + bul->ym += 85; + if (bul->ym > 0x3FF) + bul->ym = 0x3FF; + + bul->x += bul->xm; + bul->y += bul->ym; + + if (bul->flag & 0xD) + PlaySoundObject(34, 1); + } - RECT rect_left1[4] = { - {128, 0, 144, 16}, - {144, 0, 160, 16}, - {160, 0, 176, 16}, - {176, 0, 192, 16}, - }; + SET_RECT(rect_left1[0], 128, 0, 144, 16) + SET_RECT(rect_left1[1], 144, 0, 160, 16) + SET_RECT(rect_left1[2], 160, 0, 176, 16) + SET_RECT(rect_left1[3], 176, 0, 192, 16) - RECT rect_right1[4] = { - {128, 16, 144, 32}, - {144, 16, 160, 32}, - {160, 16, 176, 32}, - {176, 16, 192, 32}, - }; + SET_RECT(rect_right1[0], 128, 16, 144, 32) + SET_RECT(rect_right1[1], 144, 16, 160, 32) + SET_RECT(rect_right1[2], 160, 16, 176, 32) + SET_RECT(rect_right1[3], 176, 16, 192, 32) - RECT rect_left2[3] = { - {192, 16, 208, 32}, - {208, 16, 224, 32}, - {224, 16, 240, 32}, - }; + SET_RECT(rect_left2[0], 192, 16, 208, 32) + SET_RECT(rect_left2[1], 208, 16, 224, 32) + SET_RECT(rect_left2[2], 224, 16, 240, 32) - RECT rect_right2[3] = { - {224, 16, 240, 32}, - {208, 16, 224, 32}, - {192, 16, 208, 32}, - }; + SET_RECT(rect_right2[0], 224, 16, 240, 32) + SET_RECT(rect_right2[1], 208, 16, 224, 32) + SET_RECT(rect_right2[2], 192, 16, 208, 32) bul->ani_no++; @@ -611,20 +606,20 @@ void ActBullet_FireBall(BULLET *bul, int level) if (bul->ani_no > 3) bul->ani_no = 0; - if (bul->direct) - bul->rect = rect_right1[bul->ani_no]; - else + if (bul->direct == 0) bul->rect = rect_left1[bul->ani_no]; + else + bul->rect = rect_right1[bul->ani_no]; } else { if (bul->ani_no > 2) bul->ani_no = 0; - if (bul->direct) - bul->rect = rect_right2[bul->ani_no]; - else + if (bul->direct == 0) bul->rect = rect_left2[bul->ani_no]; + else + bul->rect = rect_right2[bul->ani_no]; if (level == 2) SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, 0, 0x100); @@ -633,15 +628,12 @@ void ActBullet_FireBall(BULLET *bul, int level) } } } - else - { - bul->cond = 0; - SetCaret(bul->x, bul->y, 3, 0); - } } void ActBullet_MachineGun(BULLET *bul, int level) { + int move; + RECT rect1[4] = { {64, 0, 80, 16}, {80, 0, 96, 16}, @@ -670,32 +662,8 @@ void ActBullet_MachineGun(BULLET *bul, int level) } else { - if (bul->act_no) + if (bul->act_no == 0) { - bul->x += bul->xm; - bul->y += bul->ym; - - switch ( level ) - { - case 1: - bul->rect = rect1[bul->direct]; - break; - case 2: - bul->rect = rect2[bul->direct]; - if (bul->direct != 1 && bul->direct != 3) - SetNpChar(127, bul->x, bul->y, 0, 0, 0, 0, 256); - else - SetNpChar(127, bul->x, bul->y, 0, 0, 1, 0, 256); - break; - case 3: - bul->rect = rect3[bul->direct]; - SetNpChar(128, bul->x, bul->y, 0, 0, bul->direct, 0, 256); - break; - } - } - else - { - int move; switch (level) { case 1: @@ -718,16 +686,41 @@ void ActBullet_MachineGun(BULLET *bul, int level) bul->ym = Random(-0xAA, 0xAA); break; case 1: - bul->xm = Random(-0xAA, 0xAA); bul->ym = -move; + bul->xm = Random(-0xAA, 0xAA); break; case 2: bul->xm = move; bul->ym = Random(-0xAA, 0xAA); break; case 3: - bul->xm = Random(-0xAA, 0xAA); bul->ym = move; + bul->xm = Random(-0xAA, 0xAA); + break; + } + } + else + { + bul->x += bul->xm; + bul->y += bul->ym; + + switch (level) + { + case 1: + bul->rect = rect1[bul->direct]; + break; + case 2: + bul->rect = rect2[bul->direct]; + + if (bul->direct == 1 || bul->direct == 3) + SetNpChar(127, bul->x, bul->y, 0, 0, 1, 0, 256); + else + SetNpChar(127, bul->x, bul->y, 0, 0, 0, 0, 256); + + break; + case 3: + bul->rect = rect3[bul->direct]; + SetNpChar(128, bul->x, bul->y, 0, 0, bul->direct, 0, 256); break; } } @@ -736,6 +729,8 @@ void ActBullet_MachineGun(BULLET *bul, int level) void ActBullet_Missile(BULLET *bul, int level) { + BOOL bHit; + if (++bul->count1 > bul->life_count) { bul->cond = 0; @@ -743,26 +738,26 @@ void ActBullet_Missile(BULLET *bul, int level) return; } - bool bHit = false; + bHit = FALSE; if (bul->life != 10) - bHit = true; + bHit = TRUE; if (bul->direct == 0 && bul->flag & 1) - bHit = true; + bHit = TRUE; if (bul->direct == 2 && bul->flag & 4) - bHit = true; + bHit = TRUE; if (bul->direct == 1 && bul->flag & 2) - bHit = true; + bHit = TRUE; if (bul->direct == 3 && bul->flag & 8) - bHit = true; + bHit = TRUE; if (bul->direct == 0 && bul->flag & 0x80) - bHit = true; + bHit = TRUE; if (bul->direct == 0 && bul->flag & 0x20) - bHit = true; + bHit = TRUE; if (bul->direct == 2 && bul->flag & 0x40) - bHit = true; + bHit = TRUE; if (bul->direct == 2 && bul->flag & 0x10) - bHit = true; + bHit = TRUE; if (bHit) { @@ -793,7 +788,7 @@ void ActBullet_Missile(BULLET *bul, int level) { case 0: case 2: - if (gMC.y < bul->y) + if (bul->y > gMC.y) bul->ym = 0x100; else bul->ym = -0x100; @@ -803,7 +798,7 @@ void ActBullet_Missile(BULLET *bul, int level) case 1: case 3: - if (gMC.x < bul->x) + if (bul->x > gMC.x) bul->xm = 0x100; else bul->xm = -0x100; @@ -836,10 +831,10 @@ void ActBullet_Missile(BULLET *bul, int level) switch (bul->direct) { case 0: - bul->xm -= bul->ani_no; + bul->xm += -bul->ani_no; break; case 1: - bul->ym -= bul->ani_no; + bul->ym += -bul->ani_no; break; case 2: bul->xm += bul->ani_no; @@ -855,7 +850,7 @@ void ActBullet_Missile(BULLET *bul, int level) { case 0: case 2: - if (bul->tgt_y > bul->y) + if (bul->y < bul->tgt_y) bul->ym += 0x20; else bul->ym -= 0x20; @@ -864,7 +859,7 @@ void ActBullet_Missile(BULLET *bul, int level) case 1: case 3: - if (bul->tgt_x > bul->x) + if (bul->x < bul->tgt_x) bul->xm += 0x20; else bul->xm -= 0x20; @@ -951,65 +946,50 @@ void ActBullet_Bom(BULLET *bul, int level) case 0: bul->act_no = 1; - switch ( level ) + switch (level) { + case 1: + bul->act_wait = 10; + break; case 2: bul->act_wait = 15; break; case 3: bul->act_wait = 5; break; - case 1: - bul->act_wait = 10; - break; } PlaySoundObject(44, 1); // Fallthrough case 1: - if (level == 1) + switch (level) { - if (!(bul->act_wait % 3)) - SetDestroyNpCharUp(bul->x + (Random(-16, 16) << 9), bul->y + (Random(-16, 16) << 9), bul->enemyXL, 2); - } - else if (level == 2) - { - if (!(bul->act_wait % 3)) - SetDestroyNpCharUp(bul->x + (Random(-32, 32) << 9), bul->y + (Random(-32, 32) << 9), bul->enemyXL, 2); - } - else if (level == 3) - { - if (!(bul->act_wait % 3)) - SetDestroyNpCharUp(bul->x + (Random(-40, 40) << 9), bul->y + (Random(-40, 40) << 9), bul->enemyXL, 2); + case 1: + if (bul->act_wait % 3 == 0) + SetDestroyNpCharUp(bul->x + (Random(-16, 16) << 9), bul->y + (Random(-16, 16) << 9), bul->enemyXL, 2); + break; + + case 2: + if (bul->act_wait % 3 == 0) + SetDestroyNpCharUp(bul->x + (Random(-32, 32) << 9), bul->y + (Random(-32, 32) << 9), bul->enemyXL, 2); + break; + + case 3: + if (bul->act_wait % 3 == 0) + SetDestroyNpCharUp(bul->x + (Random(-40, 40) << 9), bul->y + (Random(-40, 40) << 9), bul->enemyXL, 2); + break; } if (--bul->act_wait < 0) bul->cond = 0; break; } - - if (level == 1) - { - if (bul->act_wait % 3 == 0) - SetDestroyNpCharUp(bul->x + (Random(-16, 16) * 0x200), bul->y + (Random(-16, 16) * 0x200), bul->enemyXL, 2); - } - else if (level == 2) - { - if (bul->act_wait % 3 == 0) - SetDestroyNpCharUp(bul->x + (Random(-32, 32) * 0x200), bul->y + (Random(-32, 32) * 0x200), bul->enemyXL, 2); - } - else if (level == 3) - { - if (bul->act_wait % 3 == 0) - SetDestroyNpCharUp(bul->x + (Random(-40, 40) * 0x200), bul->y + (Random(-40, 40) * 0x200), bul->enemyXL, 2); - } - - if (--bul->act_wait < 0) - bul->cond = 0; } void ActBullet_Bubblin1(BULLET *bul) { + RECT rect[4]; + if (bul->flag & 0x2FF) { bul->cond = 0; @@ -1017,25 +997,28 @@ void ActBullet_Bubblin1(BULLET *bul) } else { - if (bul->act_no == 0) + switch (bul->act_no) { - bul->act_no = 1; + case 0: + bul->act_no = 1; - switch (bul->direct) - { - case 0: - bul->xm = -0x600; - break; - case 2: - bul->xm = 0x600; - break; - case 1: - bul->ym = -0x600; - break; - case 3: - bul->ym = 0x600; - break; - } + switch (bul->direct) + { + case 0: + bul->xm = -0x600; + break; + case 2: + bul->xm = 0x600; + break; + case 1: + bul->ym = -0x600; + break; + case 3: + bul->ym = 0x600; + break; + } + + break; } switch (bul->direct) @@ -1063,12 +1046,10 @@ void ActBullet_Bubblin1(BULLET *bul) SetCaret(bul->x, bul->y, 15, 0); } - RECT rect[4] = { - {192, 0, 200, 8}, - {200, 0, 208, 8}, - {208, 0, 216, 8}, - {216, 0, 224, 8}, - }; + SET_RECT(rect[0], 192, 0, 200, 8) + SET_RECT(rect[1], 200, 0, 208, 8) + SET_RECT(rect[2], 208, 0, 216, 8) + SET_RECT(rect[3], 216, 0, 224, 8) if (++bul->ani_wait > 3) { @@ -1085,16 +1066,19 @@ void ActBullet_Bubblin1(BULLET *bul) void ActBullet_Bubblin2(BULLET *bul) { - bool bDelete = false; + BOOL bDelete; + RECT rect[4]; + + bDelete = FALSE; if (bul->direct == 0 && bul->flag & 1) - bDelete = true; + bDelete = TRUE; if (bul->direct == 2 && bul->flag & 4) - bDelete = true; + bDelete = TRUE; if (bul->direct == 1 && bul->flag & 2) - bDelete = true; + bDelete = TRUE; if (bul->direct == 3 && bul->flag & 8) - bDelete = true; + bDelete = TRUE; if (bDelete) { @@ -1103,29 +1087,32 @@ void ActBullet_Bubblin2(BULLET *bul) } else { - if (bul->act_no == 0) + switch (bul->act_no) { - bul->act_no = 1; + case 0: + bul->act_no = 1; - switch (bul->direct) - { - case 0: - bul->xm = -0x600; - bul->ym = Random(-0x100, 0x100); - break; - case 2: - bul->xm = 0x600; - bul->ym = Random(-0x100, 0x100); - break; - case 1: - bul->ym = -0x600; - bul->xm = Random(-0x100, 0x100); - break; - case 3: - bul->ym = 0x600; - bul->xm = Random(-0x100, 0x100); - break; - } + switch (bul->direct) + { + case 0: + bul->xm = -0x600; + bul->ym = Random(-0x100, 0x100); + break; + case 2: + bul->xm = 0x600; + bul->ym = Random(-0x100, 0x100); + break; + case 1: + bul->ym = -0x600; + bul->xm = Random(-0x100, 0x100); + break; + case 3: + bul->ym = 0x600; + bul->xm = Random(-0x100, 0x100); + break; + } + + break; } switch (bul->direct) @@ -1153,12 +1140,10 @@ void ActBullet_Bubblin2(BULLET *bul) SetCaret(bul->x, bul->y, 15, 0); } - RECT rect[4] = { - {192, 8, 200, 16}, - {200, 8, 208, 16}, - {208, 8, 216, 16}, - {216, 8, 224, 16}, - }; + SET_RECT(rect[0], 192, 8, 200, 16) + SET_RECT(rect[1], 200, 8, 208, 16) + SET_RECT(rect[2], 208, 8, 216, 16) + SET_RECT(rect[3], 216, 8, 224, 16) if (++bul->ani_wait > 3) { @@ -1175,41 +1160,57 @@ void ActBullet_Bubblin2(BULLET *bul) void ActBullet_Bubblin3(BULLET *bul) { - if (++bul->act_wait <= 100 && gKey & gKeyShot) + if (++bul->act_wait > 100 || !(gKey & gKeyShot)) { - if (bul->act_no == 0) - { - bul->act_no = 1; + bul->cond = 0; + SetCaret(bul->x, bul->y, 2, 0); + PlaySoundObject(100, 1); - switch (bul->direct) - { - case 0: - bul->xm = Random(-0x400, -0x200); - bul->ym = (Random(-4, 4) * 0x200) / 2; - break; - case 2u: - bul->xm = Random(0x200, 0x400); - bul->ym = (Random(-4, 4) * 0x200) / 2; - break; - case 1u: - bul->ym = Random(-0x400, -0x200); - bul->xm = (Random(-4, 4) * 0x200) / 2; - break; - case 3u: - bul->ym = Random(0x80, 0x100); - bul->xm = (Random(-4, 4) * 0x200) / 2; - break; - } + if (gMC.up) + SetBullet(22, bul->x, bul->y, 1); + else if (gMC.down) + SetBullet(22, bul->x, bul->y, 3); + else + SetBullet(22, bul->x, bul->y, gMC.direct); + } + else + { + switch (bul->act_no) + { + case 0: + bul->act_no = 1; + + switch (bul->direct) + { + case 0: + bul->xm = Random(-0x400, -0x200); + bul->ym = (Random(-4, 4) * 0x200) / 2; + break; + case 2: + bul->xm = Random(0x200, 0x400); + bul->ym = (Random(-4, 4) * 0x200) / 2; + break; + case 1: + bul->ym = Random(-0x400, -0x200); + bul->xm = (Random(-4, 4) * 0x200) / 2; + break; + case 3: + bul->ym = Random(0x80, 0x100); + bul->xm = (Random(-4, 4) * 0x200) / 2; + break; + } + + break; } - if (gMC.x > bul->x) + if (bul->x < gMC.x) bul->xm += 0x20; - if (gMC.x < bul->x) + if (bul->x > gMC.x) bul->xm -= 0x20; - if (gMC.y > bul->y) + if (bul->y < gMC.y) bul->ym += 0x20; - if (gMC.y < bul->y) + if (bul->y > gMC.y) bul->ym -= 0x20; if (bul->xm < 0 && bul->flag & 1) @@ -1243,19 +1244,6 @@ void ActBullet_Bubblin3(BULLET *bul) bul->rect = rect[bul->ani_no]; } - else - { - bul->cond = 0; - SetCaret(bul->x, bul->y, 2, 0); - PlaySoundObject(100, 1); - - if (gMC.up) - SetBullet(22, bul->x, bul->y, 1); - else if (gMC.down) - SetBullet(22, bul->x, bul->y, 3); - else - SetBullet(22, bul->x, bul->y, gMC.direct); - } } void ActBullet_Spine(BULLET *bul) @@ -1267,22 +1255,17 @@ void ActBullet_Spine(BULLET *bul) } else { - if (bul->act_no) - { - bul->x += bul->xm; - bul->y += bul->ym; - } - else + if (bul->act_no == 0) { bul->act_no = 1; switch (bul->direct) { case 0: - bul->xm = (-0x200 * Random(10, 16)) / 2; + bul->xm = (-Random(10, 16) * 0x200) / 2; break; case 1: - bul->ym = (-0x200 * Random(10, 16)) / 2; + bul->ym = (-Random(10, 16) * 0x200) / 2; break; case 2: bul->xm = (Random(10, 16) * 0x200) / 2; @@ -1292,6 +1275,11 @@ void ActBullet_Spine(BULLET *bul) break; } } + else + { + bul->x += bul->xm; + bul->y += bul->ym; + } if (++bul->ani_wait > 1) { @@ -1350,12 +1338,7 @@ void ActBullet_Sword1(BULLET *bul) if (bul->count1 % 5 == 1) PlaySoundObject(34, 1); - if (bul->act_no) - { - bul->x += bul->xm; - bul->y += bul->ym; - } - else + if (bul->act_no == 0) { bul->act_no = 1; @@ -1375,6 +1358,11 @@ void ActBullet_Sword1(BULLET *bul) break; } } + else + { + bul->x += bul->xm; + bul->y += bul->ym; + } RECT rcLeft[4] = { {0, 48, 16, 64}, @@ -1421,12 +1409,7 @@ void ActBullet_Sword2(BULLET *bul) if (bul->count1 % 7 == 1) PlaySoundObject(106, 1); - if (bul->act_no) - { - bul->x += bul->xm; - bul->y += bul->ym; - } - else + if (bul->act_no == 0) { bul->act_no = 1; @@ -1446,6 +1429,11 @@ void ActBullet_Sword2(BULLET *bul) break; } } + else + { + bul->x += bul->xm; + bul->y += bul->ym; + } RECT rcLeft[4] = { {160, 48, 184, 72}, @@ -1541,8 +1529,8 @@ void ActBullet_Sword3(BULLET *bul) SetBullet(23, bul->x, bul->y, 2); } - if ( ++bul->count1 == 5 ) - bul->bbits &= ~4u; + if (++bul->count1 == 5) + bul->bbits &= ~4; if (bul->count1 > bul->life_count) { @@ -1657,16 +1645,18 @@ void ActBullet_Edge(BULLET *bul) void ActBullet_Drop(BULLET *bul) { - RECT rc[1] = {0, 0, 0, 0}; + RECT rc = {0, 0, 0, 0}; if (++bul->act_wait > 2) bul->cond = 0; - bul->rect = rc[0]; + bul->rect = rc; } void ActBullet_SuperMissile(BULLET *bul, int level) { + BOOL bHit; + if (++bul->count1 > bul->life_count) { bul->cond = 0; @@ -1674,26 +1664,26 @@ void ActBullet_SuperMissile(BULLET *bul, int level) return; } - bool bHit = false; + bHit = FALSE; if (bul->life != 10) - bHit = true; + bHit = TRUE; if (bul->direct == 0 && bul->flag & 1) - bHit = true; + bHit = TRUE; if (bul->direct == 2 && bul->flag & 4) - bHit = true; + bHit = TRUE; if (bul->direct == 1 && bul->flag & 2) - bHit = true; + bHit = TRUE; if (bul->direct == 3 && bul->flag & 8) - bHit = true; + bHit = TRUE; if (bul->direct == 0 && bul->flag & 0x80) - bHit = true; + bHit = TRUE; if (bul->direct == 0 && bul->flag & 0x20) - bHit = true; + bHit = TRUE; if (bul->direct == 2 && bul->flag & 0x40) - bHit = true; + bHit = TRUE; if (bul->direct == 2 && bul->flag & 0x10) - bHit = true; + bHit = TRUE; if (bHit) { @@ -1729,7 +1719,7 @@ void ActBullet_SuperMissile(BULLET *bul, int level) { case 0: case 2: - if (gMC.y < bul->y) + if (bul->y > gMC.y) bul->ym = 0x100; else bul->ym = -0x100; @@ -1739,7 +1729,7 @@ void ActBullet_SuperMissile(BULLET *bul, int level) case 1: case 3: - if (gMC.x < bul->x) + if (bul->x > gMC.x) bul->xm = 0x100; else bul->xm = -0x100; @@ -1772,10 +1762,10 @@ void ActBullet_SuperMissile(BULLET *bul, int level) switch (bul->direct) { case 0: - bul->xm -= bul->ani_no; + bul->xm += -bul->ani_no; break; case 1: - bul->ym -= bul->ani_no; + bul->ym += -bul->ani_no; break; case 2: bul->xm += bul->ani_no; @@ -1791,7 +1781,7 @@ void ActBullet_SuperMissile(BULLET *bul, int level) { case 0: case 2: - if (bul->tgt_y > bul->y) + if (bul->y < bul->tgt_y) bul->ym += 0x40; else bul->ym -= 0x40; @@ -1799,7 +1789,7 @@ void ActBullet_SuperMissile(BULLET *bul, int level) break; case 1: case 3: - if (bul->tgt_x > bul->x) + if (bul->x < bul->tgt_x) bul->xm += 0x40; else bul->xm -= 0x40; @@ -1896,20 +1886,20 @@ void ActBullet_SuperBom(BULLET *bul, int level) PlaySoundObject(44, 1); // Fallthrough case 1: - if (level == 1) + switch (level) { - if (bul->act_wait % 3 == 0) - SetDestroyNpCharUp(bul->x + (Random(-16, 16) * 0x200), bul->y + (Random(-16, 16) * 0x200), bul->enemyXL, 2); - } - else if (level == 2) - { - if (bul->act_wait % 3 == 0) - SetDestroyNpCharUp(bul->x + (Random(-32, 32) * 0x200), bul->y + (Random(-32, 32) * 0x200), bul->enemyXL, 2); - } - else if (level == 3) - { - if (bul->act_wait % 3 == 0) - SetDestroyNpCharUp(bul->x + (Random(-40, 40) * 0x200), bul->y + (Random(-40, 40) * 0x200), bul->enemyXL, 2); + case 1: + if (bul->act_wait % 3 == 0) + SetDestroyNpCharUp(bul->x + (Random(-16, 16) * 0x200), bul->y + (Random(-16, 16) * 0x200), bul->enemyXL, 2); + break; + case 2: + if (bul->act_wait % 3 == 0) + SetDestroyNpCharUp(bul->x + (Random(-32, 32) * 0x200), bul->y + (Random(-32, 32) * 0x200), bul->enemyXL, 2); + break; + case 3: + if (bul->act_wait % 3 == 0) + SetDestroyNpCharUp(bul->x + (Random(-40, 40) * 0x200), bul->y + (Random(-40, 40) * 0x200), bul->enemyXL, 2); + break; } if (--bul->act_wait < 0) @@ -1928,7 +1918,36 @@ void ActBullet_Nemesis(BULLET *bul, int level) } else { - if (bul->act_no) + if (bul->act_no == 0) + { + bul->act_no = 1; + bul->count1 = 0; + + switch (bul->direct) + { + case 0: + bul->xm = -0x1000; + break; + case 1: + bul->ym = -0x1000; + break; + case 2: + bul->xm = 0x1000; + break; + case 3: + bul->ym = 0x1000; + break; + } + + switch (level) + { + case 3: + bul->xm /= 3; + bul->ym /= 3; + break; + } + } + else { if (level == 1 && bul->count1 % 4 == 1) { @@ -1952,33 +1971,6 @@ void ActBullet_Nemesis(BULLET *bul, int level) bul->x += bul->xm; bul->y += bul->ym; } - else - { - bul->act_no = 1; - bul->count1 = 0; - - switch (bul->direct) - { - case 0: - bul->xm = -0x1000; - break; - case 1: - bul->ym = -0x1000; - break; - case 2: - bul->xm = 0x1000; - break; - case 3: - bul->ym = 0x1000; - break; - } - - if (level == 3) - { - bul->xm /= 3; - bul->ym /= 3; - } - } if (++bul->ani_no > 1) bul->ani_no = 0; @@ -2038,12 +2030,7 @@ void ActBullet_Spur(BULLET *bul, int level) if (bul->damage && bul->life != 100) bul->damage = 0; - if (bul->act_no) - { - bul->x += bul->xm; - bul->y += bul->ym; - } - else + if (bul->act_no == 0) { bul->act_no = 1; @@ -2063,43 +2050,52 @@ void ActBullet_Spur(BULLET *bul, int level) break; } - if (level == 1) + switch (level) { - switch (bul->direct) - { - case 0: - bul->enemyYL = 0x400; - break; - case 1: - bul->enemyXL = 0x400; - break; - case 2: - bul->enemyYL = 0x400; - break; - case 3: - bul->enemyXL = 0x400; - break; - } - } - else if (level == 2) - { - switch (bul->direct) - { - case 0: - bul->enemyYL = 0x800; - break; - case 1: - bul->enemyXL = 0x800; - break; - case 2: - bul->enemyYL = 0x800; - break; - case 3: - bul->enemyXL = 0x800; - break; - } + case 1: + switch (bul->direct) + { + case 0: + bul->enemyYL = 0x400; + break; + case 1: + bul->enemyXL = 0x400; + break; + case 2: + bul->enemyYL = 0x400; + break; + case 3: + bul->enemyXL = 0x400; + break; + } + + break; + + case 2: + switch (bul->direct) + { + case 0: + bul->enemyYL = 0x800; + break; + case 1: + bul->enemyXL = 0x800; + break; + case 2: + bul->enemyYL = 0x800; + break; + case 3: + bul->enemyXL = 0x800; + break; + } + + break; } } + else + { + bul->x += bul->xm; + bul->y += bul->ym; + } RECT rect1[2] = { {128, 32, 144, 48}, @@ -2248,7 +2244,12 @@ void ActBullet() { if (gBul[i].cond & 0x80) { - if (gBul[i].life > 0) + if (gBul[i].life < 1) + { + gBul[i].cond = 0; + continue; + } + else { switch (gBul[i].code_bullet) { @@ -2387,14 +2388,8 @@ void ActBullet() case 45: ActBullet_Star(&gBul[i]); break; - default: - continue; } } - else - { - gBul[i].cond = 0; - } } } } diff --git a/src/Caret.cpp b/src/Caret.cpp index 8ddce54b..a143eed6 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -34,7 +34,7 @@ void ActCaret01(CARET *crt) {64, 24, 72, 32}, {72, 24, 80, 32}, {80, 24, 88, 32}, - {88, 24, 92, 32}, + {88, 24, 96, 32}, }; if (!crt->act_no) @@ -55,10 +55,10 @@ void ActCaret01(CARET *crt) crt->cond = 0; } - if (crt->direct) - crt->rect = rcRight[crt->ani_no]; - else + if (crt->direct == 0) crt->rect = rcLeft[crt->ani_no]; + else + crt->rect = rcRight[crt->ani_no]; } void ActCaret02(CARET *crt) @@ -88,32 +88,39 @@ void ActCaret02(CARET *crt) case 0: crt->ym -= 0x10; crt->y += crt->ym; + if (++crt->ani_wait > 5) { crt->ani_wait = 0; ++crt->ani_no; } - if ( crt->ani_no > 3 ) + + if (crt->ani_no > 3) crt->cond = 0; + crt->rect = rect_left[crt->ani_no]; break; - case 1: - crt->rect = rect_up[++crt->ani_wait / 2 % 3]; - if (crt->ani_wait > 24) - crt->cond = 0; - break; - case 2: - if ( ++crt->ani_wait > 2 ) + if (++crt->ani_wait > 2) { crt->ani_wait = 0; ++crt->ani_no; } - if ( crt->ani_no > 3 ) + + if (crt->ani_no > 3) crt->cond = 0; + crt->rect = rect_right[crt->ani_no]; break; + + case 1: + crt->rect = rect_up[++crt->ani_wait / 2 % 3]; + + if (crt->ani_wait > 24) + crt->cond = 0; + + break; } } @@ -158,7 +165,7 @@ void ActCaret04(CARET *crt) crt->cond = 0; } - crt->rect = rect[crt->ani_no + 3 * crt->direct]; + crt->rect = rect[3 * crt->direct + crt->ani_no]; } void ActCaret05(CARET *crt) @@ -243,9 +250,10 @@ void ActCaret09(CARET *crt) RECT rcLeft = {0, 80, 16, 96}; RECT rcRight = {48, 64, 64, 80}; - if (++crt->ani_wait <= 4) + if (++crt->ani_wait < 5) crt->y -= 0x800; - if (crt->ani_wait == 32 ) + + if (crt->ani_wait == 32) crt->cond = 0; if (crt->direct == 0) @@ -268,33 +276,37 @@ void ActCaret10(CARET *crt) ++crt->ani_wait; - if (crt->direct) + if (crt->direct == 0) { if (crt->ani_wait < 20) - crt->y -= 0x200; + crt->y -= 0x400; + if (crt->ani_wait == 80) - crt->cond = 0; + crt->cond = 0; } else { if (crt->ani_wait < 20) - crt->y -= 0x400; + crt->y -= 0x200; + if (crt->ani_wait == 80) crt->cond = 0; } - if (crt->direct) - crt->rect = rcRight[crt->ani_wait / 2 % 2]; - else + if (crt->direct == 0) crt->rect = rcLeft[crt->ani_wait / 2 % 2]; + else + crt->rect = rcRight[crt->ani_wait / 2 % 2]; } void ActCaret11(CARET *crt) { + unsigned char deg; + if (!crt->act_no) { crt->act_no = 1; - uint8_t deg = Random(0, 0xFF); + deg = Random(0, 0xFF); crt->xm = 2 * GetCos(deg); crt->ym = 2 * GetSin(deg); } @@ -346,7 +358,7 @@ void ActCaret13(CARET *crt) {0, 0, 0, 0}, }; - if (!crt->act_no) + if (crt->act_no == 0) { crt->act_no = 1; @@ -363,10 +375,12 @@ void ActCaret13(CARET *crt) } } - if (!crt->direct) + switch (crt->direct) { - crt->xm = 4 * crt->xm / 5; - crt->ym = 4 * crt->ym / 5; + case 0: + crt->xm = 4 * crt->xm / 5; + crt->ym = 4 * crt->ym / 5; + break; } crt->x += crt->xm; @@ -502,10 +516,16 @@ CARETFUNCTION gpCaretFuncTbl[] = void ActCaret() { - for (int i = 0; i < CARET_MAX; i++) + int i; + int code; + + for (i = 0; i < CARET_MAX; i++) { if (gCrt[i].cond & 0x80) - gpCaretFuncTbl[gCrt[i].code](&gCrt[i]); + { + code = gCrt[i].code; + gpCaretFuncTbl[code](&gCrt[i]); + } } } @@ -527,19 +547,20 @@ void PutCaret(int fx, int fy) void SetCaret(int x, int y, int code, int dir) { - for (int c = 0; c < CARET_MAX; c++) - { - if (!gCrt[c].cond) - { - memset(&gCrt[c], 0, sizeof(CARET)); - gCrt[c].cond = 0x80; - gCrt[c].code = code; - gCrt[c].x = x; - gCrt[c].y = y; - gCrt[c].view_left = gCaretTable[code].view_left; - gCrt[c].view_top = gCaretTable[code].view_top; - gCrt[c].direct = dir; + int c; + for (c = 0; c < CARET_MAX; c++) + if (gCrt[c].cond == 0) break; - } - } + + if (c == CARET_MAX) + return; + + memset(&gCrt[c], 0, sizeof(CARET)); + gCrt[c].cond = 0x80; + gCrt[c].code = code; + gCrt[c].x = x; + gCrt[c].y = y; + gCrt[c].view_left = gCaretTable[code].view_left; + gCrt[c].view_top = gCaretTable[code].view_top; + gCrt[c].direct = dir; } diff --git a/src/Ending.cpp b/src/Ending.cpp index f9a13118..37612a6f 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -59,7 +59,7 @@ void PutStripper() } //Create a cast object -void SetStripper(int x, int y, char *text, int cast) +void SetStripper(int x, int y, const char *text, int cast) { for (int s = 0; s < MAX_STRIP; s++) { diff --git a/src/Ending.h b/src/Ending.h index b9bdfeb9..b5a4d693 100644 --- a/src/Ending.h +++ b/src/Ending.h @@ -37,7 +37,7 @@ struct ISLAND_SPRITE void ActionStripper(); void PutStripper(); -void SetStripper(int x, int y, char *text, int cast); +void SetStripper(int x, int y, const char *text, int cast); void RestoreStripper(); void ActionIllust(); void PutIllust(); diff --git a/src/Fade.cpp b/src/Fade.cpp index 096629ff..aabaa236 100644 --- a/src/Fade.cpp +++ b/src/Fade.cpp @@ -16,9 +16,9 @@ struct FADE int mode; BOOL bMask; int count; - char ani_no[FADE_HEIGHT][FADE_WIDTH]; - char flag[FADE_HEIGHT][FADE_WIDTH]; // Not a BOOLEAN (those are unsigned) - char dir; + signed char ani_no[FADE_HEIGHT][FADE_WIDTH]; + signed char flag[FADE_HEIGHT][FADE_WIDTH]; // Not a BOOLEAN (those are unsigned) + signed char dir; }; static FADE gFade; @@ -41,7 +41,7 @@ void ClearFade() gFade.mode = 0; } -void StartFadeOut(char dir) +void StartFadeOut(signed char dir) { gFade.mode = 2; gFade.count = 0; @@ -58,7 +58,7 @@ void StartFadeOut(char dir) } } -void StartFadeIn(char dir) +void StartFadeIn(signed char dir) { int x; int y; diff --git a/src/Fade.h b/src/Fade.h index 793372e7..c6f6dbb1 100644 --- a/src/Fade.h +++ b/src/Fade.h @@ -5,8 +5,8 @@ void InitFade(); void SetFadeMask(); void ClearFade(); -void StartFadeOut(char dir); -void StartFadeIn(char dir); +void StartFadeOut(signed char dir); +void StartFadeIn(signed char dir); void ProcFade(); void PutFade(); BOOL GetFadeActive(); diff --git a/src/MycParam.cpp b/src/MycParam.cpp index b3b89760..caf52f3a 100644 --- a/src/MycParam.cpp +++ b/src/MycParam.cpp @@ -2,6 +2,8 @@ #include "SDL.h" +#include "WindowsWrapper.h" + #include "ArmsItem.h" #include "CommonDefines.h" #include "Caret.h" @@ -92,7 +94,7 @@ void ZeroExpMyChar() gArmsData[gSelectedArms].exp = 0; } -bool IsMaxExpMyChar() +BOOL IsMaxExpMyChar() { return gArmsData[gSelectedArms].level == 3 && gArmsData[gSelectedArms].exp >= gArmsLevelTable[gArmsData[gSelectedArms].code].exp[2]; diff --git a/src/MycParam.h b/src/MycParam.h index de66ce9e..599268f2 100644 --- a/src/MycParam.h +++ b/src/MycParam.h @@ -2,6 +2,8 @@ #include +#include "WindowsWrapper.h" + struct ARMS_LEVEL { int exp[3]; @@ -17,7 +19,7 @@ extern ARMS_LEVEL gArmsLevelTable[14]; void AddExpMyChar(int x); void ZeroExpMyChar(); -bool IsMaxExpMyChar(); +BOOL IsMaxExpMyChar(); void DamageMyChar(int damage); void ZeroArmsEnergy_All(); void AddBulletMyChar(int no, int val); diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 2522b10f..062773ca 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -53,7 +53,7 @@ void SetUniqueParameter(NPCHAR *npc) npc->view.bottom = gNpcTable[code].view.bottom << 9; } -bool LoadEvent(char *path_event) +bool LoadEvent(const char *path_event) { char path[PATH_LENGTH]; sprintf(path, "%s/%s", gDataPath, path_event); diff --git a/src/NpChar.h b/src/NpChar.h index 2a39f345..ac3e0886 100644 --- a/src/NpChar.h +++ b/src/NpChar.h @@ -83,7 +83,7 @@ extern int gSuperXpos; extern int gSuperYpos; void InitNpChar(); -bool LoadEvent(char *path_event); +bool LoadEvent(const char *path_event); void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index); void SetDestroyNpChar(int x, int y, int w, int num); void SetDestroyNpCharUp(int x, int y, int w, int num); diff --git a/src/Organya.cpp b/src/Organya.cpp index 28d4a76b..1b6c769f 100644 --- a/src/Organya.cpp +++ b/src/Organya.cpp @@ -303,7 +303,7 @@ void ChangeDramVolume(int32_t volume, int8_t track) lpDRAMBUFFER[track]->SetVolume((volume - 0xFF) * 8); } -void PlayDramObject(unsigned char key, int mode,char track) +void PlayDramObject(unsigned char key, int mode, signed char track) { switch(mode) { diff --git a/src/PixTone.cpp b/src/PixTone.cpp index 4e37e515..02b3da2a 100644 --- a/src/PixTone.cpp +++ b/src/PixTone.cpp @@ -56,7 +56,7 @@ void MakeWaveTables(void) // White noise wave rep_srand(0); for (i = 0; i < 256; ++i) - gWaveModelTable[5][i] = (char)(rep_rand() & 0xFF) / 2; + gWaveModelTable[5][i] = (signed char)(rep_rand() & 0xFF) / 2; } BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData) diff --git a/src/Profile.cpp b/src/Profile.cpp index 597219da..73e419e4 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -40,7 +40,7 @@ bool IsProfile() return true; } -bool SaveProfile(char *name) +bool SaveProfile(const char *name) { //Get path char path[PATH_LENGTH]; @@ -119,7 +119,7 @@ bool SaveProfile(char *name) return true; } -bool LoadProfile(char *name) +bool LoadProfile(const char *name) { //Get path char path[PATH_LENGTH]; diff --git a/src/Profile.h b/src/Profile.h index d9f527a1..cdd0ec90 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -25,12 +25,12 @@ struct PROFILE ARMS arms[8]; ITEM items[32]; PERMIT_STAGE permitstage[8]; - char permit_mapping[0x80]; + signed char permit_mapping[0x80]; char FLAG[4]; uint8_t flags[1000]; }; bool IsProfile(); -bool SaveProfile(char *name); -bool LoadProfile(char *name); +bool SaveProfile(const char *name); +bool LoadProfile(const char *name); bool InitializeGame(); diff --git a/src/Shoot.cpp b/src/Shoot.cpp index 228652ea..168b2602 100644 --- a/src/Shoot.cpp +++ b/src/Shoot.cpp @@ -28,7 +28,10 @@ void ShootBullet_Frontia1(int level) break; } - if (CountArmsBullet(1) <= 3 && gKeyTrg & gKeyShot) + if (CountArmsBullet(1) > 3) + return; + + if (gKeyTrg & gKeyShot) { if (!UseArmsEnergy(1)) { @@ -86,18 +89,21 @@ void ShootBullet_PoleStar(int level) int bul_no; switch (level) { - case 2: - bul_no = 5; - break; - case 3: - bul_no = 6; - break; - case 1: - bul_no = 4; - break; + case 1: + bul_no = 4; + break; + case 2: + bul_no = 5; + break; + case 3: + bul_no = 6; + break; } - if (CountArmsBullet(2) < 2 && gKeyTrg & gKeyShot) + if (CountArmsBullet(2) > 1) + return; + + if (gKeyTrg & gKeyShot) { if (!UseArmsEnergy(1)) { @@ -107,42 +113,42 @@ void ShootBullet_PoleStar(int level) { if (gMC.up) { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1000, 1); - SetCaret(gMC.x + 0x200, gMC.y - 0x1000, 3, 0); - } - else + if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0x1000, 1); SetCaret(gMC.x - 0x200, gMC.y - 0x1000, 3, 0); } + else + { + SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1000, 1); + SetCaret(gMC.x + 0x200, gMC.y - 0x1000, 3, 0); + } } else if (gMC.down) { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1000, 3); - SetCaret(gMC.x + 0x200, gMC.y + 0x1000, 3, 0); - } - else + if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x1000, 3); SetCaret(gMC.x - 0x200, gMC.y + 0x1000, 3, 0); } + else + { + SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1000, 3); + SetCaret(gMC.x + 0x200, gMC.y + 0x1000, 3, 0); + } } else { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x600, 2); - SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0); - } - else + if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - 0xC00, gMC.y + 0x600, 0); SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0); } + else + { + SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x600, 2); + SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0); + } } if (level == 3) @@ -160,17 +166,17 @@ void ShootBullet_FireBall(int level) switch (level) { case 1: - if (CountArmsBullet(3) >= 2) + if (CountArmsBullet(3) > 1) return; bul_no = 7; break; case 2: - if (CountArmsBullet(3) >= 3) + if (CountArmsBullet(3) > 2) return; bul_no = 8; break; case 3: - if (CountArmsBullet(3) >= 4) + if (CountArmsBullet(3) > 3) return; bul_no = 9; break; @@ -186,42 +192,42 @@ void ShootBullet_FireBall(int level) { if (gMC.up) { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0x800, gMC.y - 0x1000, 1); - SetCaret(gMC.x + 0x800, gMC.y - 0x1000, 3, 0); - } - else + if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - 0x800, gMC.y - 0x1000, 1); SetCaret(gMC.x - 0x800, gMC.y - 0x1000, 3, 0); } + else + { + SetBullet(bul_no, gMC.x + 0x800, gMC.y - 0x1000, 1); + SetCaret(gMC.x + 0x800, gMC.y - 0x1000, 3, 0); + } } else if (gMC.down) { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0x800, gMC.y + 0x1000, 3); - SetCaret(gMC.x + 0x800, gMC.y + 0x1000, 3, 0); - } - else + if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - 0x800, gMC.y + 0x1000, 3); SetCaret(gMC.x - 0x800, gMC.y + 0x1000, 3, 0); } + else + { + SetBullet(bul_no, gMC.x + 0x800, gMC.y + 0x1000, 3); + SetCaret(gMC.x + 0x800, gMC.y + 0x1000, 3, 0); + } } else { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x400, 2); - SetCaret(gMC.x + 0x1800, gMC.y + 0x400, 3, 0); - } - else + if (gMC.direct == 0) { SetBullet(bul_no, gMC.x - 0xC00, gMC.y + 0x400, 0); SetCaret(gMC.x - 0x1800, gMC.y + 0x400, 3, 0); } + else + { + SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x400, 2); + SetCaret(gMC.x + 0x1800, gMC.y + 0x400, 3, 0); + } } PlaySoundObject(34, 1); @@ -231,132 +237,135 @@ void ShootBullet_FireBall(int level) void ShootBullet_Machinegun1(int level) { - if (CountArmsBullet(4) < 5) - { - int bul_no; + if (CountArmsBullet(4) > 4) + return; - switch (level) + int bul_no; + + switch (level) + { + case 1: + bul_no = 10; + break; + case 2: + bul_no = 11; + break; + case 3: + bul_no = 12; + break; + } + + if (!(gKey & gKeyShot)) + gMC.rensha = 6; + + if (gKey & gKeyShot) + { + if (++gMC.rensha < 6) + return; + + gMC.rensha = 0; + + if (!UseArmsEnergy(1)) { - case 1: - bul_no = 10; - break; - case 2: - bul_no = 11; - break; - case 3: - bul_no = 12; - break; - } - - if (!(gKey & gKeyShot)) - gMC.rensha = 6; - - if (gKey & gKeyShot) - { - if (++gMC.rensha > 6) + PlaySoundObject(37, 1); + + if (empty == 0) { - gMC.rensha = 0; - if (!UseArmsEnergy(1)) - { - PlaySoundObject(37, 1); - - if (!empty) - { - SetCaret(gMC.x, gMC.y, 16, 0); - empty = 50; - } - } - else - { - if (gMC.up) - { - if (level == 3) - gMC.ym += 0x100; - - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0x600, gMC.y - 0x1000, 1); - SetCaret(gMC.x + 0x600, gMC.y - 0x1000, 3, 0); - } - else - { - SetBullet(bul_no, gMC.x - 0x600, gMC.y - 0x1000, 1); - SetCaret(gMC.x - 0x600, gMC.y - 0x1000, 3, 0); - } - } - else if (gMC.down) - { - if (level == 3) - { - if (gMC.ym > 0) - gMC.ym /= 2; - - if (gMC.ym > -0x400) - { - gMC.ym -= 0x200; - if (gMC.ym < -0x400) - gMC.ym = -0x400; - } - } - - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0x600, gMC.y + 0x1000, 3); - SetCaret(gMC.x + 0x600, gMC.y + 0x1000, 3, 0); - } - else - { - SetBullet(bul_no, gMC.x - 0x600, gMC.y + 0x1000, 3); - SetCaret(gMC.x - 0x600, gMC.y + 0x1000, 3, 0); - } - } - else - { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0x1800, gMC.y + 0x600, 2); - SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0); - } - else - { - SetBullet(bul_no, gMC.x - 0x1800, gMC.y + 0x600, 0); - SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0); - } - } - - if (level == 3) - PlaySoundObject(49, 1); - else - PlaySoundObject(32, 1); - } + SetCaret(gMC.x, gMC.y, 16, 0); + empty = 50; } + + return; } else { - static int wait = 0; - - ++wait; - if (gMC.equip & 8) + if (gMC.up) { - if (wait > 1) + if (level == 3) + gMC.ym += 0x100; + + if (gMC.direct == 0) { - wait = 0; - ChargeArmsEnergy(1); + SetBullet(bul_no, gMC.x - 0x600, gMC.y - 0x1000, 1); + SetCaret(gMC.x - 0x600, gMC.y - 0x1000, 3, 0); + } + else + { + SetBullet(bul_no, gMC.x + 0x600, gMC.y - 0x1000, 1); + SetCaret(gMC.x + 0x600, gMC.y - 0x1000, 3, 0); } } - else + else if (gMC.down) { - if (wait > 4) + if (level == 3) { - wait = 0; - ChargeArmsEnergy(1); + if (gMC.ym > 0) + gMC.ym /= 2; + + if (gMC.ym > -0x400) + { + gMC.ym -= 0x200; + if (gMC.ym < -0x400) + gMC.ym = -0x400; + } } + + if (gMC.direct == 0) + { + SetBullet(bul_no, gMC.x - 0x600, gMC.y + 0x1000, 3); + SetCaret(gMC.x - 0x600, gMC.y + 0x1000, 3, 0); + } + else + { + SetBullet(bul_no, gMC.x + 0x600, gMC.y + 0x1000, 3); + SetCaret(gMC.x + 0x600, gMC.y + 0x1000, 3, 0); + } + } + else + { + if (gMC.direct == 0) + { + SetBullet(bul_no, gMC.x - 0x1800, gMC.y + 0x600, 0); + SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0); + } + else + { + SetBullet(bul_no, gMC.x + 0x1800, gMC.y + 0x600, 2); + SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0); + } + } + + if (level == 3) + PlaySoundObject(49, 1); + else + PlaySoundObject(32, 1); + } + } + else + { + static int wait = 0; + + ++wait; + if (gMC.equip & 8) + { + if (wait > 1) + { + wait = 0; + ChargeArmsEnergy(1); + } + } + else + { + if (wait > 4) + { + wait = 0; + ChargeArmsEnergy(1); } } } } -void ShootBullet_Missile(int level, bool bSuper) +void ShootBullet_Missile(int level, BOOL bSuper) { int bul_no; @@ -375,20 +384,34 @@ void ShootBullet_Missile(int level, bool bSuper) break; } - if (level == 1) + switch (level) { - if (CountArmsBullet(10) >= 1 || CountArmsBullet(11) >= 1) - return; - } - else if (level == 2) - { - if (CountArmsBullet(10) >= 2 || CountArmsBullet(11) >= 2) - return; - } - else if (level == 3) - { - if (CountArmsBullet(10) >= 4 || CountArmsBullet(11) >= 4) - return; + case 1: + if (CountArmsBullet(10) > 0) + return; + + if (CountArmsBullet(11) > 0) + return; + + break; + + case 2: + if (CountArmsBullet(10) > 1) + return; + + if (CountArmsBullet(11) > 1) + return; + + break; + + case 3: + if (CountArmsBullet(10) > 3) + return; + + if (CountArmsBullet(11) > 3) + return; + + break; } } @@ -407,216 +430,236 @@ void ShootBullet_Missile(int level, bool bSuper) break; } - if (level == 1) + switch (level) { - if (CountArmsBullet(5) >= 1 || CountArmsBullet(6) >= 1) - return; - } - else if (level == 2) - { - if (CountArmsBullet(5) >= 2 || CountArmsBullet(6) >= 2) - return; - } - else if ( level == 3 ) - { - if (CountArmsBullet(5) >= 4 || CountArmsBullet(6) >= 4) - return; + case 1: + if (CountArmsBullet(5) > 0) + return; + + if (CountArmsBullet(6) > 0) + return; + + break; + + case 2: + if (CountArmsBullet(5) > 1) + return; + + if (CountArmsBullet(6) > 1) + return; + + break; + + case 3: + if (CountArmsBullet(5) > 3) + return; + + if (CountArmsBullet(6) > 3) + return; + + break; } } - if (!(gKeyTrg & gKeyShot)) - return; - - if (level < 3) + if (gKeyTrg & gKeyShot) { - if (!UseArmsEnergy(1)) + if (level < 3) { - PlaySoundObject(37, 1); - - if (!empty) + if (!UseArmsEnergy(1)) { - SetCaret(gMC.x, gMC.y, 16, 0); - empty = 50; + PlaySoundObject(37, 1); + + if (empty == 0) + { + SetCaret(gMC.x, gMC.y, 16, 0); + empty = 50; + } + + return; } - return; - } - - if (gMC.up) - { - if (gMC.direct) + if (gMC.up) { - SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1000, 1); - SetCaret(gMC.x + 0x200, gMC.y - 0x1000, 3, 0); + if (gMC.direct == 0) + { + SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0x1000, 1); + SetCaret(gMC.x - 0x200, gMC.y - 0x1000, 3, 0); + } + else + { + SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1000, 1); + SetCaret(gMC.x + 0x200, gMC.y - 0x1000, 3, 0); + } + } + else if (gMC.down) + { + if (gMC.direct == 0) + { + SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x1000, 3); + SetCaret(gMC.x - 0x200, gMC.y + 0x1000, 3, 0); + } + else + { + SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1000, 3); + SetCaret(gMC.x + 0x200, gMC.y + 0x1000, 3, 0); + } } else { - SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0x1000, 1); - SetCaret(gMC.x - 0x200, gMC.y - 0x1000, 3, 0); - } - } - else if (gMC.down) - { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1000, 3); - SetCaret(gMC.x + 0x200, gMC.y + 0x1000, 3, 0); - } - else - { - SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x1000, 3); - SetCaret(gMC.x - 0x200, gMC.y + 0x1000, 3, 0); + if (gMC.direct == 0) + { + SetBullet(bul_no, gMC.x - 0xC00, gMC.y, 0); + SetCaret(gMC.x - 0x1800, gMC.y, 3, 0); + } + else + { + SetBullet(bul_no, gMC.x + 0xC00, gMC.y, 2); + SetCaret(gMC.x + 0x1800, gMC.y, 3, 0); + } } } else { - if (gMC.direct) + if (!UseArmsEnergy(1)) { - SetBullet(bul_no, gMC.x + 0xC00, gMC.y, 2); - SetCaret(gMC.x + 0x1800, gMC.y, 3, 0); + PlaySoundObject(37, 1); + + if (empty == 0) + { + SetCaret(gMC.x, gMC.y, 16, 0); + empty = 50; + } + + return; + } + + if (gMC.up) + { + if (gMC.direct == 0) + { + SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0x1000, 1); + SetCaret(gMC.x - 0x200, gMC.y - 0x1000, 3, 0); + SetBullet(bul_no, gMC.x + 0x600, gMC.y, 1); + SetBullet(bul_no, gMC.x - 0x600, gMC.y, 1); + } + else + { + SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1000, 1); + SetCaret(gMC.x + 0x200, gMC.y - 0x1000, 3, 0); + SetBullet(bul_no, gMC.x + 0x600, gMC.y, 1); + SetBullet(bul_no, gMC.x - 0x600, gMC.y, 1); + } + } + else if (gMC.down) + { + if (gMC.direct == 0) + { + SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x1000, 3); + SetCaret(gMC.x - 0x200, gMC.y + 0x1000, 3, 0); + SetBullet(bul_no, gMC.x + 0x600, gMC.y, 3); + SetBullet(bul_no, gMC.x - 0x600, gMC.y, 3); + } + else + { + SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1000, 3); + SetCaret(gMC.x + 0x200, gMC.y + 0x1000, 3, 0); + SetBullet(bul_no, gMC.x - 0x600, gMC.y, 3); + SetBullet(bul_no, gMC.x + 0x600, gMC.y, 3); + } } else { - SetBullet(bul_no, gMC.x - 0xC00, gMC.y, 0); - SetCaret(gMC.x - 0x1800, gMC.y, 3, 0); + if (gMC.direct == 0) + { + SetBullet(bul_no, gMC.x - 0xC00, gMC.y + 0x200, 0); + SetCaret(gMC.x - 0x1800, gMC.y + 0x200, 3, 0); + SetBullet(bul_no, gMC.x, gMC.y - 0x1000, 0); + SetBullet(bul_no, gMC.x + 0x800, gMC.y - 0x200, 0); + } + else + { + SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x200, 2); + SetCaret(gMC.x + 0x1800, gMC.y + 0x200, 3, 0); + SetBullet(bul_no, gMC.x, gMC.y - 0x1000, 2); + SetBullet(bul_no, gMC.x - 0x800, gMC.y - 0x200, 2); + } } } + + PlaySoundObject(32, 1); } - else - { - if (!UseArmsEnergy(1)) - { - PlaySoundObject(37, 1); - - if (!empty) - { - SetCaret(gMC.x, gMC.y, 16, 0); - empty = 50; - } - - return; - } - - if (gMC.up) - { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0x1000, 1); - SetCaret(gMC.x + 0x200, gMC.y - 0x1000, 3, 0); - SetBullet(bul_no, gMC.x + 0x600, gMC.y, 1); - SetBullet(bul_no, gMC.x - 0x600, gMC.y, 1); - } - else - { - SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0x1000, 1); - SetCaret(gMC.x - 0x200, gMC.y - 0x1000, 3, 0); - SetBullet(bul_no, gMC.x + 0x600, gMC.y, 1); - SetBullet(bul_no, gMC.x - 0x600, gMC.y, 1); - } - } - else if (gMC.down) - { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x1000, 3); - SetCaret(gMC.x + 0x200, gMC.y + 0x1000, 3, 0); - SetBullet(bul_no, gMC.x - 0x600, gMC.y, 3); - SetBullet(bul_no, gMC.x + 0x600, gMC.y, 3); - } - else - { - SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x1000, 3); - SetCaret(gMC.x - 0x200, gMC.y + 0x1000, 3, 0); - SetBullet(bul_no, gMC.x + 0x600, gMC.y, 3); - SetBullet(bul_no, gMC.x - 0x600, gMC.y, 3); - } - } - else - { - if (gMC.direct) - { - SetBullet(bul_no, gMC.x + 0xC00, gMC.y + 0x200, 2); - SetCaret(gMC.x + 0x1800, gMC.y + 0x200, 3, 0); - SetBullet(bul_no, gMC.x, gMC.y - 0x1000, 2); - SetBullet(bul_no, gMC.x - 0x800, gMC.y - 0x200, 2); - } - else - { - SetBullet(bul_no, gMC.x - 0xC00, gMC.y + 0x200, 0); - SetCaret(gMC.x - 0x1800, gMC.y + 0x200, 3, 0); - SetBullet(bul_no, gMC.x, gMC.y - 0x1000, 0); - SetBullet(bul_no, gMC.x + 0x800, gMC.y - 0x200, 0); - } - } - } - - PlaySoundObject(32, 1); } void ShootBullet_Bubblin1(void) { static int wait; - if (CountArmsBullet(7) <= 3) + if (CountArmsBullet(7) > 3) + return; + + if (gKeyTrg & gKeyShot) { - if (gKeyTrg & gKeyShot) + if (!UseArmsEnergy(1)) { - if (!UseArmsEnergy(1)) + PlaySoundObject(37, 1); + + if (empty == 0) { - PlaySoundObject(37, 1); - if (!empty) + SetCaret(gMC.x, gMC.y, 16, 0); + empty = 50; + } + + return; + } + else + { + if (gMC.up) + { + if (gMC.direct == 0) { - SetCaret(gMC.x, gMC.y, 16, 0); - empty = 50; + SetBullet(19, gMC.x - 0x200, gMC.y - 0x400, 1); + SetCaret(gMC.x - 0x200, gMC.y - 0x400, 3, 0); + } + else + { + SetBullet(19, gMC.x + 0x200, gMC.y - 0x400, 1); + SetCaret(gMC.x + 0x200, gMC.y - 0x400, 3, 0); + } + } + else if (gMC.down) + { + if (gMC.direct == 0) + { + SetBullet(19, gMC.x - 0x200, gMC.y + 0x400, 3); + SetCaret(gMC.x - 0x200, gMC.y + 0x400, 3, 0); + } + else + { + SetBullet(19, gMC.x + 0x200, gMC.y + 0x400, 3); + SetCaret(gMC.x + 0x200, gMC.y + 0x400, 3, 0); } } else { - if (gMC.up) - { - if (gMC.direct) - { - SetBullet(19, gMC.x + 0x200, gMC.y - 0x400, 1); - SetCaret(gMC.x + 0x200, gMC.y - 0x400, 3, 0); - } - else - { - SetBullet(19, gMC.x - 0x200, gMC.y - 0x400, 1); - SetCaret(gMC.x - 0x200, gMC.y - 0x400, 3, 0); - } - } - else if (gMC.down) - { - if (gMC.direct) - { - SetBullet(19, gMC.x + 0x200, gMC.y + 0x400, 3); - SetCaret(gMC.x + 0x200, gMC.y + 0x400, 3, 0); - } - else - { - SetBullet(19, gMC.x - 0x200, gMC.y + 0x400, 3); - SetCaret(gMC.x - 0x200, gMC.y + 0x400, 3, 0); - } - } - else if (gMC.direct) - { - SetBullet(19, gMC.x + 0xC00, gMC.y + 0x600, 2); - SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0); - } - else + if (gMC.direct == 0) { SetBullet(19, gMC.x - 0xC00, gMC.y + 0x600, 0); SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0); } - - PlaySoundObject(48, 1); + else + { + SetBullet(19, gMC.x + 0xC00, gMC.y + 0x600, 2); + SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0); + } } + + PlaySoundObject(48, 1); } - else if (++wait > 20) - { - wait = 0; - ChargeArmsEnergy(1); - } + } + else if (++wait > 20) + { + wait = 0; + ChargeArmsEnergy(1); } } @@ -624,124 +667,130 @@ void ShootBullet_Bubblin2(int level) { static int wait; - if (CountArmsBullet(7) <= 15) + if (CountArmsBullet(7) > 15) + return; + + level += 18; + + if (!(gKey & gKeyShot)) + gMC.rensha = 6; + + if (gKey & gKeyShot) { - level += 18; + if (++gMC.rensha < 7) + return; - if (!(gKey & gKeyShot)) - gMC.rensha = 6; + gMC.rensha = 0; - if (gKey & gKeyShot) + if (!UseArmsEnergy(1)) { - if (++gMC.rensha >= 7) - { - gMC.rensha = 0; + PlaySoundObject(37, 1); - if (!UseArmsEnergy(1)) + if (empty == 0) + { + SetCaret(gMC.x, gMC.y, 16, 0); + empty = 50; + } + + return; + } + else + { + if (gMC.up) + { + if (gMC.direct == 0) { - PlaySoundObject(37, 1); - if (!empty) - { - SetCaret(gMC.x, gMC.y, 16, 0); - empty = 50; - } + SetBullet(level, gMC.x - 0x600, gMC.y - 0x1000, 1); + SetCaret(gMC.x - 0x600, gMC.y - 0x2000, 3, 0); } else { - if (gMC.up) - { - if (gMC.direct) - { - SetBullet(level, gMC.x + 0x600, gMC.y - 0x1000, 1); - SetCaret(gMC.x + 0x600, gMC.y - 0x2000, 3, 0); - } - else - { - SetBullet(level, gMC.x - 0x600, gMC.y - 0x1000, 1); - SetCaret(gMC.x - 0x600, gMC.y - 0x2000, 3, 0); - } - } - else if (gMC.down) - { - if (gMC.direct) - { - SetBullet(level, gMC.x + 0x600, gMC.y + 0x1000, 3); - SetCaret(gMC.x + 0x600, gMC.y + 0x2000, 3, 0); - } - else - { - SetBullet(level, gMC.x - 0x600, gMC.y + 0x1000, 3); - SetCaret(gMC.x - 0x600, gMC.y + 0x2000, 3, 0); - } - } - else if (gMC.direct) - { - SetBullet(level, gMC.x + 0xC00, gMC.y + 0x600, 2); - SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0); - } - else - { - SetBullet(level, gMC.x - 0xC00, gMC.y + 0x600, 0); - SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0); - } - - PlaySoundObject(48, 1); + SetBullet(level, gMC.x + 0x600, gMC.y - 0x1000, 1); + SetCaret(gMC.x + 0x600, gMC.y - 0x2000, 3, 0); } } + else if (gMC.down) + { + if (gMC.direct == 0) + { + SetBullet(level, gMC.x - 0x600, gMC.y + 0x1000, 3); + SetCaret(gMC.x - 0x600, gMC.y + 0x2000, 3, 0); + } + else + { + SetBullet(level, gMC.x + 0x600, gMC.y + 0x1000, 3); + SetCaret(gMC.x + 0x600, gMC.y + 0x2000, 3, 0); + } + } + else + { + if (gMC.direct == 0) + { + SetBullet(level, gMC.x - 0xC00, gMC.y + 0x600, 0); + SetCaret(gMC.x - 0x1800, gMC.y + 0x600, 3, 0); + } + else + { + SetBullet(level, gMC.x + 0xC00, gMC.y + 0x600, 2); + SetCaret(gMC.x + 0x1800, gMC.y + 0x600, 3, 0); + } + } + + PlaySoundObject(48, 1); } - else if (++wait > 1) - { - wait = 0; - ChargeArmsEnergy(1); - } + } + else if (++wait > 1) + { + wait = 0; + ChargeArmsEnergy(1); } } void ShootBullet_Sword(int level) { - if (CountArmsBullet(9) <= 0) + if (CountArmsBullet(9) > 0) + return; + + int bul_no; + + switch (level) { - int bul_no; + case 1: + bul_no = 25; + break; + case 2: + bul_no = 26; + break; + case 3: + bul_no = 27; + break; + } - switch (level) + if (gKeyTrg & gKeyShot) + { + if (gMC.up) { - case 1: - bul_no = 25; - break; - case 2: - bul_no = 26; - break; - case 3: - bul_no = 27; - break; - } - - if (gKeyTrg & gKeyShot) - { - if (gMC.up) - { - if (gMC.direct == 0) - SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x800, 1); - else - SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x800, 1); - } - else if (gMC.down) - { - if (gMC.direct == 0) - SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0xC00, 3); - else - SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0xC00, 3); - } + if (gMC.direct == 0) + SetBullet(bul_no, gMC.x - 0x200, gMC.y + 0x800, 1); else - { - if (gMC.direct == 0) - SetBullet(bul_no, gMC.x + 0xC00, gMC.y - 0x600, 0); - else - SetBullet(bul_no, gMC.x - 0xC00, gMC.y - 0x600, 2); - } - - PlaySoundObject(34, 1); + SetBullet(bul_no, gMC.x + 0x200, gMC.y + 0x800, 1); } + else if (gMC.down) + { + if (gMC.direct == 0) + SetBullet(bul_no, gMC.x - 0x200, gMC.y - 0xC00, 3); + else + SetBullet(bul_no, gMC.x + 0x200, gMC.y - 0xC00, 3); + } + else + { + if (gMC.direct == 0) + SetBullet(bul_no, gMC.x + 0xC00, gMC.y - 0x600, 0); + else + SetBullet(bul_no, gMC.x - 0xC00, gMC.y - 0x600, 2); + } + + PlaySoundObject(34, 1); } } @@ -762,7 +811,10 @@ void ShootBullet_Nemesis(int level) break; } - if (CountArmsBullet(12) <= 1 && gKeyTrg & gKeyShot) + if (CountArmsBullet(12) > 1) + return; + + if (gKeyTrg & gKeyShot) { if (!UseArmsEnergy(1)) { @@ -836,9 +888,11 @@ void ResetSpurCharge(void) void ShootBullet_Spur(int level) { + static BOOL bMax; + BOOL bShot; int bul_no; - bool bShot = false; + bShot = FALSE; if (gKey & gKeyShot) { @@ -849,42 +903,43 @@ void ShootBullet_Spur(int level) if (++spur_charge / 2 % 2) { - if (level == 1) + switch (level) { - PlaySoundObject(59, 1); - } - else if (level == 2) - { - PlaySoundObject(60, 1); - } - else if (level == 3) - { - if (!IsMaxExpMyChar()) - PlaySoundObject(61, 1); + case 1: + PlaySoundObject(59, 1); + break; + + case 2: + PlaySoundObject(60, 1); + break; + + case 3: + if (!IsMaxExpMyChar()) + PlaySoundObject(61, 1); + + break; } } } else { if (spur_charge) - bShot = true; + bShot = TRUE; spur_charge = 0; } - static bool bMax; - if (IsMaxExpMyChar()) { - if (bMax == false) + if (bMax == FALSE) { - bMax = true; + bMax = TRUE; PlaySoundObject(65, 1); } } else { - bMax = false; + bMax = FALSE; } if (!(gKey & gKeyShot)) @@ -894,7 +949,7 @@ void ShootBullet_Spur(int level) { case 1: bul_no = 6; - bShot = false; + bShot = FALSE; break; case 2: bul_no = 37; @@ -904,10 +959,14 @@ void ShootBullet_Spur(int level) bul_no = 39; else bul_no = 38; + break; } - if (CountArmsBullet(13) <= 0 && CountArmsBullet(14) <= 0 && (gKeyTrg & gKeyShot || bShot)) + if (CountArmsBullet(13) > 0 || CountArmsBullet(14) > 0) + return; + + if (gKeyTrg & gKeyShot || bShot) { if (!UseArmsEnergy(1)) { @@ -992,64 +1051,64 @@ void ShootBullet() } //Run functions - if (!(gMC.cond & 2)) + if (gMC.cond & 2) + return; + + switch (gArmsData[gSelectedArms].code) { - switch (gArmsData[gSelectedArms].code) - { - case 1: - ShootBullet_Frontia1(gArmsData[gSelectedArms].level); - break; - case 2: - ShootBullet_PoleStar(gArmsData[gSelectedArms].level); - break; - case 3: - ShootBullet_FireBall(gArmsData[gSelectedArms].level); - break; - case 4: - ShootBullet_Machinegun1(gArmsData[gSelectedArms].level); - break; - case 5: - ShootBullet_Missile(gArmsData[gSelectedArms].level, false); - break; - case 7: - switch (gArmsData[gSelectedArms].level) - { - case 1: - ShootBullet_Bubblin1(); - break; - case 2: - ShootBullet_Bubblin2(2); - break; - case 3: - ShootBullet_Bubblin2(3); - break; - } + case 1: + ShootBullet_Frontia1(gArmsData[gSelectedArms].level); + break; + case 2: + ShootBullet_PoleStar(gArmsData[gSelectedArms].level); + break; + case 3: + ShootBullet_FireBall(gArmsData[gSelectedArms].level); + break; + case 4: + ShootBullet_Machinegun1(gArmsData[gSelectedArms].level); + break; + case 5: + ShootBullet_Missile(gArmsData[gSelectedArms].level, FALSE); + break; + case 7: + switch (gArmsData[gSelectedArms].level) + { + case 1: + ShootBullet_Bubblin1(); + break; + case 2: + ShootBullet_Bubblin2(2); + break; + case 3: + ShootBullet_Bubblin2(3); + break; + } - break; - case 9: - switch (gArmsData[gSelectedArms].level) - { - case 1: - ShootBullet_Sword(1); - break; - case 2: - ShootBullet_Sword(2); - break; - case 3: - ShootBullet_Sword(3); - break; - } + break; + case 9: + switch (gArmsData[gSelectedArms].level) + { + case 1: + ShootBullet_Sword(1); + break; + case 2: + ShootBullet_Sword(2); + break; + case 3: + ShootBullet_Sword(3); + break; + } - break; - case 10: - ShootBullet_Missile(gArmsData[gSelectedArms].level, true); - break; - case 12: - ShootBullet_Nemesis(gArmsData[gSelectedArms].level); - break; - case 13: - ShootBullet_Spur(gArmsData[gSelectedArms].level); - break; - } + break; + case 10: + ShootBullet_Missile(gArmsData[gSelectedArms].level, TRUE); + break; + case 12: + ShootBullet_Nemesis(gArmsData[gSelectedArms].level); + break; + case 13: + ShootBullet_Spur(gArmsData[gSelectedArms].level); + break; } } diff --git a/src/Stage.h b/src/Stage.h index d0ef23cb..f1324a53 100644 --- a/src/Stage.h +++ b/src/Stage.h @@ -10,7 +10,7 @@ struct STAGE_TABLE char back[0x20]; char npc[0x20]; char boss[0x20]; - char boss_no; + signed char boss_no; char name[0x20]; }; diff --git a/src/TextScr.cpp b/src/TextScr.cpp index f502cfd3..8d90f8bf 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -141,7 +141,7 @@ bool LoadTextScript2(const char *name) } //Load stage .tsc -bool LoadTextScript_Stage(char *name) +bool LoadTextScript_Stage(const char *name) { //Open Head.tsc char path[PATH_LENGTH]; diff --git a/src/TextScr.h b/src/TextScr.h index ca575e96..1b47b67d 100644 --- a/src/TextScr.h +++ b/src/TextScr.h @@ -16,10 +16,10 @@ struct TEXT_SCRIPT char *data; //Mode (ex. NOD, WAI) - char mode; + signed char mode; //Flags - char flags; + signed char flags; //Current positions (read position in buffer, x position in line) unsigned int p_read; @@ -37,7 +37,7 @@ struct TEXT_SCRIPT int next_event; //Yes/no selected - char select; + signed char select; //Current face int face; @@ -61,7 +61,7 @@ BOOL InitTextScript2(); void EndTextScript(); void EncryptionBinaryData2(uint8_t *pData, int size); bool LoadTextScript2(const char *name); -bool LoadTextScript_Stage(char *name); +bool LoadTextScript_Stage(const char *name); void GetTextScriptPath(char *path); BOOL StartTextScript(int no); void StopTextScript(); diff --git a/src/WindowsWrapper.h b/src/WindowsWrapper.h index d00898e9..09ee401c 100644 --- a/src/WindowsWrapper.h +++ b/src/WindowsWrapper.h @@ -13,6 +13,12 @@ typedef int BOOL; #define TRUE 1 #endif +#define SET_RECT(rect, l, t, r, b) \ + rect.left = l; \ + rect.top = t; \ + rect.right = r; \ + rect.bottom = b; + struct RECT { union