DREAMWEB: Ported 'sparky' to C++

This commit is contained in:
Bertrand Augereau 2011-12-01 16:21:16 +01:00
parent ba12c02a75
commit 24c355e04f
6 changed files with 27 additions and 42 deletions

View File

@ -340,6 +340,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'barwoman',
'gamer',
'eden',
'sparky',
], skip_output = [
# These functions are processed but not output
'dreamweb',

View File

@ -1742,44 +1742,6 @@ nocopper:
addtopeoplelist();
}
void DreamGenContext::sparky() {
STACK_CHECK;
_cmp(data.word(kCard1money), 0);
if (flags.z())
goto animsparky;
es.byte(bx+7) = 3;
goto animsparky;
animsparky:
checkspeed();
if (!flags.z())
goto finishsparky;
_cmp(es.word(bx+3), 34);
if (!flags.z())
goto notsparky1;
randomnumber();
_cmp(al, 30);
if (flags.c())
goto dosparky;
es.word(bx+3) = 27;
goto finishsparky;
notsparky1:
_cmp(es.word(bx+3), 48);
if (!flags.z())
goto dosparky;
es.word(bx+3) = 27;
goto finishsparky;
dosparky:
_inc(es.word(bx+3));
finishsparky:
showgamereel();
addtopeoplelist();
al = es.byte(bx+7);
_and(al, 128);
if (flags.z())
return /* (nottalkedsparky) */;
data.byte(kTalkedtosparky) = 1;
}
void DreamGenContext::train() {
STACK_CHECK;
return;

View File

@ -429,7 +429,6 @@ public:
static const uint16 addr_checkforexit = 0xc148;
static const uint16 addr_mainman = 0xc138;
static const uint16 addr_train = 0xc104;
static const uint16 addr_sparky = 0xc100;
static const uint16 addr_copper = 0xc0fc;
static const uint16 addr_advisor = 0xc0f8;
static const uint16 addr_drunk = 0xc0f4;
@ -1309,7 +1308,6 @@ public:
void showmonk();
void diarykeyn();
void set16colpalette();
void sparky();
void interviewer();
void purgeanitem();
void madman();

View File

@ -570,7 +570,7 @@ void DreamGenContext::showrain() {
static void (DreamGenContext::*reelCallbacks[57])() = {
NULL, NULL,
NULL, &DreamGenContext::edeninbath,
&DreamGenContext::sparky, &DreamGenContext::smokebloke,
NULL, &DreamGenContext::smokebloke,
&DreamGenContext::manasleep, &DreamGenContext::drunk,
&DreamGenContext::receptionist, &DreamGenContext::malefan,
&DreamGenContext::femalefan, &DreamGenContext::louis,
@ -602,7 +602,7 @@ static void (DreamGenContext::*reelCallbacks[57])() = {
static void (DreamGenContext::*reelCallbacksCPP[57])(ReelRoutine &) = {
&DreamGenContext::gamer, &DreamGenContext::sparkydrip,
&DreamGenContext::eden, /*&DreamGenContext::edeninbath*/NULL,
/*&DreamGenContext::sparky*/NULL, /*&DreamGenContext::smokebloke*/NULL,
&DreamGenContext::sparky, /*&DreamGenContext::smokebloke*/NULL,
/*&DreamGenContext::manasleep*/NULL, /*&DreamGenContext::drunk*/NULL,
/*&DreamGenContext::receptionist*/NULL, /*&DreamGenContext::malefan*/NULL,
/*&DreamGenContext::femalefan*/NULL, /*&DreamGenContext::louis*/NULL,
@ -1107,5 +1107,27 @@ void DreamGenContext::eden(ReelRoutine &routine) {
addtopeoplelist(&routine);
}
void DreamGenContext::sparky(ReelRoutine &routine) {
if (data.word(kCard1money))
routine.b7 = 3;
if (checkspeed(&routine)) {
if (routine.reelPointer() != 34) {
if (engine->randomNumber() < 30)
routine.incReelPointer();
else
routine.setReelPointer(27);
} else {
if (routine.reelPointer() != 48)
routine.incReelPointer();
else
routine.setReelPointer(27);
}
}
showgamereel(&routine);
addtopeoplelist(&routine);
if (routine.b7 & 128)
data.byte(kTalkedtosparky) = 1;
}
} /*namespace dreamgen */

View File

@ -167,6 +167,7 @@ struct ReelRoutine {
uint8 b4;
uint16 reelPointer() const { return READ_LE_UINT16(&b3); }
void setReelPointer(uint16 v) { WRITE_LE_UINT16(&b3, v); }
void incReelPointer() { setReelPointer(reelPointer() + 1); }
uint8 period;
uint8 counter;
uint8 b7;

View File

@ -381,4 +381,5 @@
void othersmoker(ReelRoutine &routine);
void gamer(ReelRoutine &routine);
void eden(ReelRoutine &routine);
void sparky(ReelRoutine &routine);