DREAMWEB: Pathfind routines go to pathfind.cpp
This commit is contained in:
parent
3f6a277819
commit
d4be53c5c0
3 changed files with 107 additions and 75 deletions
|
@ -6,6 +6,7 @@ MODULE_OBJS := \
|
||||||
detection.o \
|
detection.o \
|
||||||
dreamweb.o \
|
dreamweb.o \
|
||||||
dreamgen.o \
|
dreamgen.o \
|
||||||
|
pathfind.o \
|
||||||
print.o \
|
print.o \
|
||||||
saveload.o \
|
saveload.o \
|
||||||
sprite.o \
|
sprite.o \
|
||||||
|
|
106
engines/dreamweb/pathfind.cpp
Normal file
106
engines/dreamweb/pathfind.cpp
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
/* ScummVM - Graphic Adventure Engine
|
||||||
|
*
|
||||||
|
* ScummVM is the legal property of its developers, whose names
|
||||||
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||||
|
* file distributed with this source distribution.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dreamweb/dreamweb.h"
|
||||||
|
#include "engines/util.h"
|
||||||
|
#include "graphics/surface.h"
|
||||||
|
#include "common/config-manager.h"
|
||||||
|
|
||||||
|
namespace DreamGen {
|
||||||
|
|
||||||
|
void DreamGenContext::turnpathonCPP(uint8 param) {
|
||||||
|
al = param;
|
||||||
|
push(es);
|
||||||
|
push(bx);
|
||||||
|
turnpathon();
|
||||||
|
bx = pop();
|
||||||
|
es = pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DreamGenContext::turnpathoffCPP(uint8 param) {
|
||||||
|
al = param;
|
||||||
|
push(es);
|
||||||
|
push(bx);
|
||||||
|
turnpathoff();
|
||||||
|
bx = pop();
|
||||||
|
es = pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DreamGenContext::getroomspaths() {
|
||||||
|
es = data.word(kReels);
|
||||||
|
bx = data.byte(kRoomnum) * 144;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 *DreamGenContext::getroomspathsCPP() {
|
||||||
|
void *result = segRef(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144);
|
||||||
|
return (uint8 *)result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DreamGenContext::autosetwalk() {
|
||||||
|
al = data.byte(kManspath);
|
||||||
|
if (data.byte(kFinaldest) == al)
|
||||||
|
return;
|
||||||
|
const uint8 *roomsPaths = getroomspathsCPP();
|
||||||
|
checkdest(roomsPaths);
|
||||||
|
data.word(kLinestartx) = roomsPaths[data.byte(kManspath) * 8 + 0] - 12;
|
||||||
|
data.word(kLinestarty) = roomsPaths[data.byte(kManspath) * 8 + 1] - 12;
|
||||||
|
data.word(kLineendx) = roomsPaths[data.byte(kDestination) * 8 + 0] - 12;
|
||||||
|
data.word(kLineendy) = roomsPaths[data.byte(kDestination) * 8 + 1] - 12;
|
||||||
|
bresenhams();
|
||||||
|
if (data.byte(kLinedirection) != 0) {
|
||||||
|
data.byte(kLinepointer) = data.byte(kLinelength) - 1;
|
||||||
|
data.byte(kLinedirection) = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data.byte(kLinepointer) = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DreamGenContext::checkdest(const uint8 *roomsPaths) {
|
||||||
|
const uint8 *p = roomsPaths + 12 * 8;
|
||||||
|
ah = data.byte(kManspath) << 4;
|
||||||
|
al = data.byte(kDestination);
|
||||||
|
uint8 destination = data.byte(kDestination);
|
||||||
|
for (size_t i = 0; i < 24; ++i) {
|
||||||
|
dh = p[0] & 0xf0;
|
||||||
|
dl = p[0] & 0x0f;
|
||||||
|
if (ax == dx) {
|
||||||
|
data.byte(kDestination) = p[1] & 0x0f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dl = (p[0] & 0xf0) >> 4;
|
||||||
|
dh = (p[0] & 0x0f) << 4;
|
||||||
|
if (ax == dx) {
|
||||||
|
destination = p[1] & 0x0f;
|
||||||
|
}
|
||||||
|
p += 2;
|
||||||
|
}
|
||||||
|
data.byte(kDestination) = destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DreamGenContext::findxyfrompath() {
|
||||||
|
const uint8 *roomsPaths = getroomspathsCPP();
|
||||||
|
data.byte(kRyanx) = roomsPaths[data.byte(kManspath) * 8 + 0] - 12;
|
||||||
|
data.byte(kRyany) = roomsPaths[data.byte(kManspath) * 8 + 1] - 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /*namespace dreamgen */
|
||||||
|
|
|
@ -624,24 +624,6 @@ void DreamGenContext::eraseoldobs() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::turnpathonCPP(uint8 param) {
|
|
||||||
al = param;
|
|
||||||
push(es);
|
|
||||||
push(bx);
|
|
||||||
turnpathon();
|
|
||||||
bx = pop();
|
|
||||||
es = pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DreamGenContext::turnpathoffCPP(uint8 param) {
|
|
||||||
al = param;
|
|
||||||
push(es);
|
|
||||||
push(bx);
|
|
||||||
turnpathoff();
|
|
||||||
bx = pop();
|
|
||||||
es = pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DreamGenContext::modifychar() {
|
void DreamGenContext::modifychar() {
|
||||||
al = engine->modifyChar(al);
|
al = engine->modifyChar(al);
|
||||||
}
|
}
|
||||||
|
@ -685,16 +667,6 @@ void DreamGenContext::cancelch1() {
|
||||||
engine->stopSound(1);
|
engine->stopSound(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::getroomspaths() {
|
|
||||||
es = data.word(kReels);
|
|
||||||
bx = data.byte(kRoomnum) * 144;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8 *DreamGenContext::getroomspathsCPP() {
|
|
||||||
void *result = segRef(data.word(kReels)).ptr(data.byte(kRoomnum) * 144, 144);
|
|
||||||
return (uint8 *)result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DreamGenContext::makebackob(ObjData *objData) {
|
void DreamGenContext::makebackob(ObjData *objData) {
|
||||||
if (data.byte(kNewobs) == 0)
|
if (data.byte(kNewobs) == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -950,47 +922,6 @@ void DreamGenContext::commandonly(uint8 command) {
|
||||||
data.byte(kNewtextline) = 1;
|
data.byte(kNewtextline) = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::autosetwalk() {
|
|
||||||
al = data.byte(kManspath);
|
|
||||||
if (data.byte(kFinaldest) == al)
|
|
||||||
return;
|
|
||||||
const uint8 *roomsPaths = getroomspathsCPP();
|
|
||||||
checkdest(roomsPaths);
|
|
||||||
data.word(kLinestartx) = roomsPaths[data.byte(kManspath) * 8 + 0] - 12;
|
|
||||||
data.word(kLinestarty) = roomsPaths[data.byte(kManspath) * 8 + 1] - 12;
|
|
||||||
data.word(kLineendx) = roomsPaths[data.byte(kDestination) * 8 + 0] - 12;
|
|
||||||
data.word(kLineendy) = roomsPaths[data.byte(kDestination) * 8 + 1] - 12;
|
|
||||||
bresenhams();
|
|
||||||
if (data.byte(kLinedirection) != 0) {
|
|
||||||
data.byte(kLinepointer) = data.byte(kLinelength) - 1;
|
|
||||||
data.byte(kLinedirection) = 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
data.byte(kLinepointer) = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DreamGenContext::checkdest(const uint8 *roomsPaths) {
|
|
||||||
const uint8 *p = roomsPaths + 12 * 8;
|
|
||||||
ah = data.byte(kManspath) << 4;
|
|
||||||
al = data.byte(kDestination);
|
|
||||||
uint8 destination = data.byte(kDestination);
|
|
||||||
for (size_t i = 0; i < 24; ++i) {
|
|
||||||
dh = p[0] & 0xf0;
|
|
||||||
dl = p[0] & 0x0f;
|
|
||||||
if (ax == dx) {
|
|
||||||
data.byte(kDestination) = p[1] & 0x0f;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
dl = (p[0] & 0xf0) >> 4;
|
|
||||||
dh = (p[0] & 0x0f) << 4;
|
|
||||||
if (ax == dx) {
|
|
||||||
destination = p[1] & 0x0f;
|
|
||||||
}
|
|
||||||
p += 2;
|
|
||||||
}
|
|
||||||
data.byte(kDestination) = destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DreamGenContext::checkifperson() {
|
void DreamGenContext::checkifperson() {
|
||||||
flags._z = not checkifperson(al, ah);
|
flags._z = not checkifperson(al, ah);
|
||||||
}
|
}
|
||||||
|
@ -1110,12 +1041,6 @@ void DreamGenContext::walktotext() {
|
||||||
commandwithob(3, data.byte(kCommandtype), data.byte(kCommand));
|
commandwithob(3, data.byte(kCommandtype), data.byte(kCommand));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DreamGenContext::findxyfrompath() {
|
|
||||||
const uint8 *roomsPaths = getroomspathsCPP();
|
|
||||||
data.byte(kRyanx) = roomsPaths[data.byte(kManspath) * 8 + 0] - 12;
|
|
||||||
data.byte(kRyany) = roomsPaths[data.byte(kManspath) * 8 + 1] - 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DreamGenContext::isCD() {
|
bool DreamGenContext::isCD() {
|
||||||
// The original sources has two codepaths depending if the game is 'if cd' or not
|
// The original sources has two codepaths depending if the game is 'if cd' or not
|
||||||
// This is a hack to guess which version to use with the assumption that if we have a cd version
|
// This is a hack to guess which version to use with the assumption that if we have a cd version
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue