IMMORTAL: Fix formatting for switch statements

This commit is contained in:
Quote58 2023-01-22 16:25:55 -05:00 committed by Eugene Sandulenko
parent 9cbe97d557
commit 4103ebe600
4 changed files with 260 additions and 239 deletions

View File

@ -133,16 +133,16 @@ int Room::flameGetCyc(Flame *f, int first) {
// Why is this not indexed further? ie. LDA patternTable,x : STA $00 : LDA ($00),y instead of a branch tree?
// Pretty sure CPX 3 times is more than a single LDA (dp),y
switch (f->_p) {
case 0:
return cycleNew(flamePatA[r]);
case 1:
return cycleNew(flamePatB[r]);
case 2:
return cycleNew(flamePatC[r]);
case 3:
return cycleNew(flamePatD[r]);
default:
return 0;
case 0:
return cycleNew(flamePatA[r]);
case 1:
return cycleNew(flamePatB[r]);
case 2:
return cycleNew(flamePatC[r]);
case 3:
return cycleNew(flamePatD[r]);
default:
return 0;
}
}

View File

@ -389,13 +389,14 @@ void ImmortalEngine::printChr(char c) {
}
switch (c) {
case 'm':
case 'w':
case 'M':
case 'W':
_penX += 8;
default:
break;
case 'm':
case 'w':
case 'M':
case 'W':
_penX += 8;
// fall through
default:
break;
}
if ((((c >= 'A') && (c <= 'Z'))) || ((c == kGaugeOn) || (c == kGaugeOff))) {
@ -403,17 +404,19 @@ void ImmortalEngine::printChr(char c) {
}
switch (c) {
case 'i':
_penX -= 3;
break;
case 'j':
case 't':
_penX -= 2;
break;
case 'l':
_penX -= 4;
default:
break;
case 'i':
_penX -= 3;
break;
case 'j':
// fall through
case 't':
_penX -= 2;
break;
case 'l':
_penX -= 4;
// fall through
default:
break;
}
uint16 x = _penX + kScreenLeft;
@ -1003,27 +1006,30 @@ void ImmortalEngine::fixPause() {
// This is a nasty bit of code isn't it? It's accurate to the source though :D
switch (_playing) {
case kSongText:
case kSongMaze:
if (_themePaused) {
musicUnPause(_themeID);
break;
}
default:
musicPause(_themeID);
case kSongText:
// fall through
case kSongMaze:
if (_themePaused) {
musicUnPause(_themeID);
break;
}
// fall through
default:
musicPause(_themeID);
break;
}
// Strictly speaking this should probably be a single function called twice, but the source writes out both so I will too
switch (_playing) {
case kSongCombat:
if (_themePaused) {
musicUnPause(_combatID);
break;
}
default:
musicPause(_combatID);
case kSongCombat:
if (_themePaused) {
musicUnPause(_combatID);
break;
}
// fall through
default:
musicPause(_combatID);
break;
}
}

View File

@ -150,16 +150,17 @@ void ImmortalEngine::trapKeys() {
*/
getInput();
switch (_pressedAction) {
case kActionDBGStep:
_singleStep = true;
break;
case kActionRestart:
gameOver();
break;
case kActionSound:
toggleSound();
default:
break;
case kActionDBGStep:
_singleStep = true;
break;
case kActionRestart:
gameOver();
break;
case kActionSound:
toggleSound();
// fall through
default:
break;
}
}
@ -170,13 +171,16 @@ int ImmortalEngine::keyOrButton() {
while (button == 0) {
getInput();
switch (_pressedAction) {
case kActionKey:
button = _pressedAction;
case kActionFire:
case kActionButton:
button = 13;
default:
break;
case kActionKey:
button = _pressedAction;
break;
case kActionFire:
// fall through
case kActionButton:
button = 13;
// fall through
default:
break;
}
}
return button;
@ -348,43 +352,43 @@ bool ImmortalEngine::fromOldGame() {
// This would have been much more clean as a set of tables instead of a long branching tree
switch (_certificate[kCertLevel]) {
case 1:
if ((certInv & 2) != 0) {
//room.makeObject(3, 0, kSporesFrame, sporesType);
}
case 1:
if ((certInv & 2) != 0) {
//room.makeObject(3, 0, kSporesFrame, sporesType);
}
if ((certInv & 4) != 0) {
//room.makeObject(3, 0, kSporesFrame, wowCharmType);
}
if ((certInv & 4) != 0) {
//room.makeObject(3, 0, kSporesFrame, wowCharmType);
}
break;
case 4:
if ((certInv & 2) != 0) {
//room.makeObject(3, kIsInvisible, kSporesFrame, coffeeType);
}
break;
case 4:
if ((certInv & 2) != 0) {
//room.makeObject(3, kIsInvisible, kSporesFrame, coffeeType);
}
break;
case 3:
if ((certInv & 1) != 0) {
//room.makeObject(3, kIsRunning, kRingFrame, faceRingType);
}
break;
case 3:
if ((certInv & 1) != 0) {
//room.makeObject(3, kIsRunning, kRingFrame, faceRingType);
}
break;
case 7:
if ((certInv & 1) != 0) {
//room.makeObject(6, kUsesFireButton, kSporesFrame, bronzeType);
}
break;
case 7:
if ((certInv & 1) != 0) {
//room.makeObject(6, kUsesFireButton, kSporesFrame, bronzeType);
}
if ((certInv & 2) != 0) {
//room.makeObject(3, 0, kSporesFrame, tractorType);
}
if ((certInv & 2) != 0) {
//room.makeObject(3, 0, kSporesFrame, tractorType);
}
if ((certInv & 4) != 0) {
//room.makeObject(3, 0, kSporesFrame, antiType);
}
default:
break;
if ((certInv & 4) != 0) {
//room.makeObject(3, 0, kSporesFrame, antiType);
}
// fall through
default:
break;
}
levelNew(_level);
return true;
@ -434,46 +438,46 @@ void ImmortalEngine::makeCertificate() {
// The lo byte of the inventory is used for items that only exist on a specific level, and are removed after
switch (_certificate[kCertLevel]) {
case 1:
if (true/*room.monster[kPlayerID].hasObject(sporesType)*/) {
_certificate[kCertInvLo] |= 2;
}
case 1:
if (true/*room.monster[kPlayerID].hasObject(sporesType)*/) {
_certificate[kCertInvLo] |= 2;
}
if (true/*room.monster[kPlayerID].hasObject(wowCharmType)*/) {
_certificate[kCertInvLo] |= 4;
}
if (true/*room.monster[kPlayerID].hasObject(wowCharmType)*/) {
_certificate[kCertInvLo] |= 4;
}
// fall through
case 3:
if (true/*room.monster[kPlayerID].hasObject(faceRingType)*/) {
_certificate[kCertInvLo] |= 1;
}
// fall through
case 4:
if (true/*room.monster[kPlayerID].hasObject(coffeeType)*/) {
_certificate[kCertInvLo] |= 2;
}
// fall through
case 7:
if (true/*room.monster[kPlayerID].hasObject(bronzeType)*/) {
_certificate[kCertInvLo] |= 1;
}
case 3:
if (true/*room.monster[kPlayerID].hasObject(faceRingType)*/) {
_certificate[kCertInvLo] |= 1;
}
if (true/*room.monster[kPlayerID].hasObject(tractorType)*/) {
_certificate[kCertInvLo] |= 2;
}
case 4:
if (true/*room.monster[kPlayerID].hasObject(coffeeType)*/) {
_certificate[kCertInvLo] |= 2;
}
case 7:
if (true/*room.monster[kPlayerID].hasObject(bronzeType)*/) {
_certificate[kCertInvLo] |= 1;
}
if (true/*room.monster[kPlayerID].hasObject(tractorType)*/) {
_certificate[kCertInvLo] |= 2;
}
if (true/*room.monster[kPlayerID].hasObject(antiType)*/) {
_certificate[kCertInvLo] |= 4;
}
default:
_lastCertLen = 13;
uint8 checksum[4];
calcCheckSum(_lastCertLen, checksum);
_certificate[0] = checksum[0];
_certificate[1] = checksum[1];
_certificate[2] = checksum[2];
_certificate[3] = checksum[3];
if (true/*room.monster[kPlayerID].hasObject(antiType)*/) {
_certificate[kCertInvLo] |= 4;
}
// fall through
default:
_lastCertLen = 13;
uint8 checksum[4];
calcCheckSum(_lastCertLen, checksum);
_certificate[0] = checksum[0];
_certificate[1] = checksum[1];
_certificate[2] = checksum[2];
_certificate[3] = checksum[3];
}
}

View File

@ -93,104 +93,108 @@ bool ImmortalEngine::textSub(Str s, FadeType f, int n) {
while (done == false) {
switch (text[index]) {
case '@':
case '=':
case char(0):
done = true;
// This is so the while loop can be a little cleaner
index--;
break;
case '&':
textCR();
break;
case '$':
printByte(n);
case '@':
case '=':
case char(0):
done = true;
// This is so the while loop can be a little cleaner
index--;
break;
case '&':
textCR();
break;
case '$':
printByte(n);
copyToScreen();
break;
case '_':
myFadeIn();
_slowText = 1;
break;
case '<':
_slowText = 0;
break;
case '>':
_formatted = 0;
break;
case '\\':
normalFadeOut();
break;
case '/':
slowFadeOut();
break;
case '|':
normalFadeIn();
break;
case '}':
_formatted = 1;
break;
case ']':
myDelay(40);
break;
case '{':
index++;
myDelay(text[index]);
break;
case '*':
textPageBreak(text, index);
break;
case '[':
textAutoPageBreak();
break;
case '#':
index++;
drawIcon(text[index]);
break;
case '~':
text = _strPtrs[(int)text[index + 1]];
index = -1;
break;
case '^':
center();
break;
case '%':
return yesNo();
case '+':
chr = 0x27;
break;
case '(':
chr = 0x60;
break;
default:
chr = text[index];
_collumn++;
if (chr == ' ') {
if (text[index + 1] == '~') {
text = _strPtrs[(int)text[index + 2]];
index = -1;
}
textDoSpace(text, index);
} else {
printChr(chr);
// We need this to show up now, not when the frame ends, so we have to update the screen here
copyToScreen();
break;
case '_':
myFadeIn();
_slowText = 1;
break;
case '<':
_slowText = 0;
break;
case '>':
_formatted = 0;
break;
case '\\':
normalFadeOut();
break;
case '/':
slowFadeOut();
break;
case '|':
normalFadeIn();
break;
case '}':
_formatted = 1;
break;
case ']':
myDelay(40);
break;
case '{':
index++;
myDelay(text[index]);
break;
case '*':
textPageBreak(text, index);
break;
case '[':
textAutoPageBreak();
break;
case '#':
index++;
drawIcon(text[index]);
break;
case '~':
text = _strPtrs[(int)text[index + 1]];
index = -1;
break;
case '^':
center();
break;
case '%':
return yesNo();
case '+':
chr = 0x27;
break;
case '(':
chr = 0x60;
break;
default:
chr = text[index];
_collumn++;
if (chr == ' ') {
if (text[index + 1] == '~') {
text = _strPtrs[(int)text[index + 2]];
index = -1;
}
textDoSpace(text, index);
} else {
printChr(chr);
// We need this to show up now, not when the frame ends, so we have to update the screen here
copyToScreen();
if (_slowText != 0) {
myDelay(5);
switch (chr) {
case '?':
case ':':
myDelay(13);
case '.':
myDelay(13);
case ',':
myDelay(13);
default:
break;
}
if (_slowText != 0) {
myDelay(5);
switch (chr) {
case '?':
// fall through
case ':':
myDelay(13);
// fall through
case '.':
myDelay(13);
// fall through
case ',':
myDelay(13);
// fall through
default:
break;
}
}
break;
}
break;
}
if (index == 0xFF) {
debug("String too long!");
@ -272,14 +276,19 @@ void ImmortalEngine::textDoSpace(Common::String s, int index) {
while (foundEnd == false) {
index++;
switch (s[index]) {
case '=':
case '@':
case '%':
case '[':
case ' ':
foundEnd = true;
default:
break;
case '=':
// fall through
case '@':
// fall through
case '%':
// fall through
case '[':
// fall through
case ' ':
foundEnd = true;
// fall through
default:
break;
}
}
if (((index - start) + _collumn) >= kMaxCollumns) {
@ -383,14 +392,16 @@ void ImmortalEngine::myDelay(int j) {
// Otherwise, we delay by different amounts based on what's held down
switch (type) {
case 1:
Utilities::delay4(1);
break;
case 0:
Utilities::delay(1);
case 2:
default:
break;
case 1:
Utilities::delay4(1);
break;
case 0:
Utilities::delay(1);
// fall through
case 2:
// fall through
default:
break;
}
j--;