Skip to content

Commit

Permalink
NEVERHOOD: More work on Scene1001/Klayman
Browse files Browse the repository at this point in the history
- Looking through the open window now works (mostly).
  • Loading branch information
johndoe123 authored and wjp committed May 8, 2013
1 parent 6d81ef0 commit c39fb81
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 7 deletions.
60 changes: 60 additions & 0 deletions engines/neverhood/klayman.cpp
Expand Up @@ -1102,4 +1102,64 @@ uint32 Klayman::handleMessage41DF10(int messageNum, const MessageParam &param, E
return messageResult;
}

void Klayman::sub420870() {
_status2 = 0;
_flagE5 = true;
setFileHash(0xD820A114, 0, 10);
SetUpdateHandler(&Klayman::update);
SetMessageHandler(&Klayman::handleMessage41D480);
SetSpriteCallback(NULL);
}

void Klayman::sub4208B0() {
_status2 = 1;
_flagE5 = true;
setFileHash(0xD820A114, 30, -1);
SetUpdateHandler(&Klayman::update);
SetMessageHandler(&Klayman::handleMessage41D480);
SetSpriteCallback(NULL);
}

void Klayman::sub4208F0() {
_status2 = 0;
_flagE5 = true;
setFileHash(0x9B250AD2, 0, 7);
SetUpdateHandler(&Klayman::update);
SetMessageHandler(&Klayman::handleMessage41EEF0);
SetSpriteCallback(NULL);
}

uint32 Klayman::handleMessage41EEF0(int messageNum, const MessageParam &param, Entity *sender) {
debug("Klayman::handleMessage41EEF0(%04X)", messageNum);
uint32 messageResult = handleMessage41D480(messageNum, param, sender);
switch (messageNum) {
case 0x100D:
if (param.asInteger() == 0x32180101) {
_soundResource1.play(0x4924AAC4);
} else if (param.asInteger() == 0x0A2A9098) {
_soundResource1.play(0x0A2AA8E0);
}
break;
}
return messageResult;
}

void Klayman::sub420930() {
_status2 = 1;
_flagE5 = true;
setFileHash(0x98F88391, 4, -1);
SetUpdateHandler(&Klayman::update);
SetMessageHandler(&Klayman::handleMessage41EEF0);
SetSpriteCallback(NULL);
}

void Klayman::sub420830() {
_status2 = 1;
_flagE5 = true;
setFileHash(0xD820A114, 0, -1);
SetUpdateHandler(&Klayman::update);
SetMessageHandler(&Klayman::handleMessage41D480);
SetSpriteCallback(NULL);
}

} // End of namespace Neverhood
7 changes: 7 additions & 0 deletions engines/neverhood/klayman.h
Expand Up @@ -58,6 +58,11 @@ class Klayman : public AnimatedSprite {
void sub420170();
void sub4200D0();
void sub41FBC0();
void sub420870();
void sub4208B0();
void sub4208F0();
void sub420930();
void sub420830();

void spriteUpdate41F250();
void spriteUpdate41F5F0();
Expand Down Expand Up @@ -170,6 +175,8 @@ class Klayman : public AnimatedSprite {

uint32 handleMessage41DF10(int messageNum, const MessageParam &param, Entity *sender);

uint32 handleMessage41EEF0(int messageNum, const MessageParam &param, Entity *sender);

};

} // End of namespace Neverhood
Expand Down
72 changes: 65 additions & 7 deletions engines/neverhood/module1000.cpp
Expand Up @@ -65,7 +65,6 @@ Module1000::~Module1000() {
}

void Module1000::createScene1001(int which) {
debug("createScene1501");
_vm->gameState().sceneNum = 0;
_childObject = new Scene1001(_vm, this, which);
// TODO ResourceTable_multiLoad(&_resourceTable1, &_resourceTable2, &_resourceTable3);
Expand All @@ -77,6 +76,10 @@ void Module1000::createScene1002(int which) {
}

void Module1000::createScene1003(int which) {
_vm->gameState().sceneNum = 2;
_childObject = new Class152(_vm, this, 0xC084110C, 0x41108C00);
SetUpdateHandler(&Module1000::updateScene1003);
// TODO Music18hList_play(0x061880C6, 0, 0);
}

void Module1000::createScene1004(int which) {
Expand All @@ -89,12 +92,15 @@ void Module1000::updateScene1001() {
_childObject->handleUpdate();

if (_done) {

debug("SCENE 1001 DONE; _field20 = %d", _field20);

_done = false;
delete _childObject;
_childObject = NULL;
if (_field20 == 2) {
// TODO createScene1003();
// TODO _childObject->handleUpdate();
createScene1003(0);
_childObject->handleUpdate();
} else {
// TODO createScene1002();
// TODO _childObject->handleUpdate();
Expand Down Expand Up @@ -122,6 +128,14 @@ void Module1000::updateScene1002() {
}

void Module1000::updateScene1003() {
_childObject->handleUpdate();
if (_done) {
_done = false;
delete _childObject;
_childObject = NULL;
createScene1001(2);
_childObject->handleUpdate();
}
}

void Module1000::updateScene1004() {
Expand Down Expand Up @@ -181,6 +195,25 @@ uint32 KmScene1001::xHandleMessage(int messageNum, const MessageParam &param) {
}
break;

case 0x481F:
if (param.asInteger() == 0) {
setCallback2(AnimationCallback(&Klayman::sub420870));
} else if (param.asInteger() == 1) {
setCallback2(AnimationCallback(&Klayman::sub4208B0));
} else if (param.asInteger() == 3) {
setCallback2(AnimationCallback(&Klayman::sub4208F0));
} else if (param.asInteger() == 4) {
setCallback2(AnimationCallback(&Klayman::sub420930));
} else {
setCallback2(AnimationCallback(&Klayman::sub420830));
}
break;

case 0x482D:
setDoDeltaX(_x > (int16)param.asInteger());
sub41C7B0();
break;

case 0x4836:
if (param.asInteger() == 1) {
_parentScene->sendMessage(0x2002, 0, this);
Expand All @@ -197,8 +230,6 @@ uint32 KmScene1001::xHandleMessage(int messageNum, const MessageParam &param) {
break;
}

// TODO

return 0;
}

Expand Down Expand Up @@ -461,9 +492,8 @@ Scene1001::Scene1001(NeverhoodEngine *vm, Module *parentModule, int which)
_background = addBackground(new DirtyBackground(_vm, 0x4086520E, 0, 0));
_palette = new Palette(_vm, 0x4086520E);
_palette->usePalette();
// TODO _mouseCursor = addSprite(new Class433(_vm, 6520A400, 0));

// TODO Mouse

if (which < 0) {
setRectList(0x004B49F0);
_klayman = new KmScene1001(_vm, this, 200, 433);
Expand Down Expand Up @@ -587,4 +617,32 @@ uint32 Scene1001::handleMessage(int messageNum, const MessageParam &param, Entit
return messageResult;
}

// Class152

Class152::Class152(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundFileHash, uint32 cursorFileHash)
: Scene(vm, parentModule, true), _fieldD0(-1), _fieldD2(-1) {

_surfaceFlag = false;

SetMessageHandler(&Class152::handleMessage);

_background = addBackground(new DirtyBackground(_vm, backgroundFileHash, 0, 0));
_palette = new Palette(_vm, backgroundFileHash);
_palette->usePalette();
// TODO _mouseCursor = addSprite(new Class435(_vm, cursorFileHash, 20, 620));

}

uint32 Class152::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
Scene::handleMessage(messageNum, param, sender);
switch (messageNum) {
case 0x0001:
if (param.asPoint().x <= 20 || param.asPoint().x >= 620) {
_parentModule->sendMessage(0x1009, 0, this);
}
break;
}
return 0;
}

} // End of namespace Neverhood
12 changes: 12 additions & 0 deletions engines/neverhood/module1000.h
Expand Up @@ -130,6 +130,18 @@ class Scene1001 : public Scene {
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
};

// TODO: Move this to some common file since it's used several times

class Class152 : public Scene {
public:
Class152(NeverhoodEngine *vm, Module *parentModule, uint32 backgroundFileHash, uint32 cursorFileHash);
protected:
// TODO: Are these used?
int16 _fieldD0;
int16 _fieldD2;
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
};

} // End of namespace Neverhood

#endif /* NEVERHOOD_MODULE1000_H */

0 comments on commit c39fb81

Please sign in to comment.