DREAMWEB: 'enterCode' ported to C++

This commit is contained in:
Bertrand Augereau 2011-12-02 13:18:00 +01:00
parent 3ac815a236
commit 7211a790b2
6 changed files with 84 additions and 105 deletions

View File

@ -344,6 +344,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'singlekey',
'showkeypad',
'credits',
'entercode',
], skip_output = [
# These functions are processed but not output
'dreamweb',

View File

@ -9142,89 +9142,6 @@ nowinch:
putBackObStuff();
}
void DreamGenContext::enterCode() {
STACK_CHECK;
data.word(kKeypadax) = ax;
data.word(kKeypadcx) = cx;
getRidOfReels();
loadKeypad();
createPanel();
showIcon();
showOuterPad();
showKeypad();
readMouse();
showPointer();
workToScreen();
delPointer();
data.word(kPresspointer) = 0;
data.byte(kGetback) = 0;
keypadloop:
_cmp(data.byte(kQuitrequested), 0);
if (!flags.z())
goto numberright;
delPointer();
readMouse();
showKeypad();
showPointer();
vSync();
_cmp(data.byte(kPresscount), 0);
if (flags.z())
goto nopresses;
_dec(data.byte(kPresscount));
goto afterpress;
nopresses:
data.byte(kPressed) = 255;
data.byte(kGraphicpress) = 255;
vSync();
afterpress:
dumpPointer();
dumpKeypad();
dumpTextLine();
bx = offset_keypadlist;
checkCoords();
_cmp(data.byte(kGetback), 1);
if (flags.z())
goto numberright;
_cmp(data.byte(kLightcount), 1);
if (!flags.z())
goto notendkey;
_cmp(data.byte(kLockstatus), 0);
if (flags.z())
goto numberright;
goto keypadloop;
notendkey:
_cmp(data.byte(kPresscount), 40);
if (!flags.z())
goto keypadloop;
addToPressList();
_cmp(data.byte(kPressed), 11);
if (!flags.z())
goto keypadloop;
ax = data.word(kKeypadax);
cx = data.word(kKeypadcx);
isItRight();
if (!flags.z())
goto incorrect;
data.byte(kLockstatus) = 0;
al = 11;
playChannel1();
data.byte(kLightcount) = 120;
data.word(kPresspointer) = 0;
goto keypadloop;
incorrect:
al = 11;
playChannel1();
data.byte(kLightcount) = 120;
data.word(kPresspointer) = 0;
goto keypadloop;
numberright:
data.byte(kManisoffscreen) = 0;
getRidOfTemp();
restoreReels();
redrawMainScrn();
workToScreenM();
}
void DreamGenContext::loadKeypad() {
STACK_CHECK;
dx = 1948;

View File

@ -77,7 +77,6 @@ public:
static const uint16 offset_decidelist = 0x13c1;
static const uint16 offset_symbollist = 0x0e5e;
static const uint16 offset_operand1 = 0x0b7e;
static const uint16 offset_keypadlist = 0x0d9a;
static const uint16 kStartvars = 0;
static const uint16 kProgresspoints = 1;
static const uint16 kWatchon = 2;
@ -705,7 +704,6 @@ public:
void useElevator2();
void buttonOne();
void keyboardRead();
void enterCode();
void getOpenedSize();
void doShake();
void resetKeyboard();

View File

@ -71,5 +71,86 @@ void DreamGenContext::showKeypad() {
}
}
void DreamGenContext::enterCode() {
enterCode(ax, cx);
}
void DreamGenContext::enterCode(uint16 keypadAx, uint16 keypadCx) {
RectWithCallback keypadList[] = {
{ kKeypadx+9,kKeypadx+30,kKeypady+9,kKeypady+22,&DreamGenContext::buttonOne },
{ kKeypadx+31,kKeypadx+52,kKeypady+9,kKeypady+22,&DreamGenContext::buttonTwo },
{ kKeypadx+53,kKeypadx+74,kKeypady+9,kKeypady+22,&DreamGenContext::buttonThree },
{ kKeypadx+9,kKeypadx+30,kKeypady+23,kKeypady+40,&DreamGenContext::buttonFour },
{ kKeypadx+31,kKeypadx+52,kKeypady+23,kKeypady+40,&DreamGenContext::buttonFive },
{ kKeypadx+53,kKeypadx+74,kKeypady+23,kKeypady+40,&DreamGenContext::buttonSix },
{ kKeypadx+9,kKeypadx+30,kKeypady+41,kKeypady+58,&DreamGenContext::buttonSeven },
{ kKeypadx+31,kKeypadx+52,kKeypady+41,kKeypady+58,&DreamGenContext::buttonEight },
{ kKeypadx+53,kKeypadx+74,kKeypady+41,kKeypady+58,&DreamGenContext::buttonNine },
{ kKeypadx+9,kKeypadx+30,kKeypady+59,kKeypady+73,&DreamGenContext::buttonNought },
{ kKeypadx+31,kKeypadx+74,kKeypady+59,kKeypady+73,&DreamGenContext::buttonEnter },
{ kKeypadx+72,kKeypadx+86,kKeypady+80,kKeypady+94,&DreamGenContext::quitKey },
{ 0,320,0,200,&DreamGenContext::blank },
{ 0xFFFF,0,0,0,0 }
};
data.word(kKeypadax) = keypadAx;
data.word(kKeypadcx) = keypadCx;
getRidOfReels();
loadKeypad();
createPanel();
showIcon();
showOuterPad();
showKeypad();
readMouse();
showPointer();
workToScreen();
delPointer();
data.word(kPresspointer) = 0;
data.byte(kGetback) = 0;
while (true) {
delPointer();
readMouse();
showKeypad();
showPointer();
vSync();
if (data.byte(kPresscount) == 0) {
data.byte(kPressed) = 255;
data.byte(kGraphicpress) = 255;
vSync();
} else
--data.byte(kPresscount);
dumpPointer();
dumpKeypad();
dumpTextLine();
checkCoords(keypadList);
if (quitRequested() || (data.byte(kGetback) == 1))
break;
if (data.byte(kLightcount) == 1) {
if (data.byte(kLockstatus) == 0)
break;
} else {
if (data.byte(kPresscount) == 40) {
addToPressList();
if (data.byte(kPressed) == 11) {
ax = data.word(kKeypadax);
cx = data.word(kKeypadcx);
isItRight();
if (flags.z())
data.byte(kLockstatus) = 0;
playChannel1(11);
data.byte(kLightcount) = 120;
data.word(kPresspointer) = 0;
}
}
}
}
data.byte(kManisoffscreen) = 0;
getRidOfTemp();
restoreReels();
redrawMainScrn();
workToScreenM();
}
} /*namespace dreamgen */

View File

@ -1444,26 +1444,6 @@ void DreamGenContext::checkCoords() {
checkCoords(destList);
break;
}
case offset_keypadlist: {
RectWithCallback keypadList[] = {
{ kKeypadx+9,kKeypadx+30,kKeypady+9,kKeypady+22,&DreamGenContext::buttonOne },
{ kKeypadx+31,kKeypadx+52,kKeypady+9,kKeypady+22,&DreamGenContext::buttonTwo },
{ kKeypadx+53,kKeypadx+74,kKeypady+9,kKeypady+22,&DreamGenContext::buttonThree },
{ kKeypadx+9,kKeypadx+30,kKeypady+23,kKeypady+40,&DreamGenContext::buttonFour },
{ kKeypadx+31,kKeypadx+52,kKeypady+23,kKeypady+40,&DreamGenContext::buttonFive },
{ kKeypadx+53,kKeypadx+74,kKeypady+23,kKeypady+40,&DreamGenContext::buttonSix },
{ kKeypadx+9,kKeypadx+30,kKeypady+41,kKeypady+58,&DreamGenContext::buttonSeven },
{ kKeypadx+31,kKeypadx+52,kKeypady+41,kKeypady+58,&DreamGenContext::buttonEight },
{ kKeypadx+53,kKeypadx+74,kKeypady+41,kKeypady+58,&DreamGenContext::buttonNine },
{ kKeypadx+9,kKeypadx+30,kKeypady+59,kKeypady+73,&DreamGenContext::buttonNought },
{ kKeypadx+31,kKeypadx+74,kKeypady+59,kKeypady+73,&DreamGenContext::buttonEnter },
{ kKeypadx+72,kKeypadx+86,kKeypady+80,kKeypady+94,&DreamGenContext::quitKey },
{ 0,320,0,200,&DreamGenContext::blank },
{ 0xFFFF,0,0,0,0 }
};
checkCoords(keypadList);
break;
}
case offset_menulist: {
RectWithCallback menuList[] = {
{ kMenux+54,kMenux+68,kMenuy+72,kMenuy+88,&DreamGenContext::quitKey },

View File

@ -384,4 +384,6 @@
void sparky(ReelRoutine &routine);
void singleKey(uint8 key, uint16 x, uint16 y);
void showKeypad();
void enterCode(uint16 keypadAx, uint16 keypadCx);
void enterCode();