DREAMWEB: 'compare' ported to C++

This commit is contained in:
Bertrand Augereau 2011-09-01 00:06:30 +02:00
parent 0534b70b6d
commit 6ab4a0ceee
5 changed files with 20 additions and 21 deletions

View File

@ -174,6 +174,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'delthisone',
'transferinv',
'obicons',
'compare',
], skip_output = [
# These functions are processed but not output
'dreamweb',

View File

@ -10535,23 +10535,6 @@ doselob:
useroutine();
}
void DreamGenContext::compare() {
STACK_CHECK;
_sub(dl, 'A');
_sub(dh, 'A');
_sub(cl, 'A');
_sub(ch, 'A');
push(cx);
push(dx);
getanyaddir();
dx = pop();
cx = pop();
_cmp(es.word(bx+12), cx);
if (!flags.z())
return /* (comparefin) */;
_cmp(es.word(bx+14), dx);
}
void DreamGenContext::findsetobject() {
STACK_CHECK;
_sub(al, 'A');
@ -17893,7 +17876,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_useelvdoor: useelvdoor(); break;
case addr_withwhat: withwhat(); break;
case addr_selectob: selectob(); break;
case addr_compare: compare(); break;
case addr_findsetobject: findsetobject(); break;
case addr_findexobject: findexobject(); break;
case addr_isryanholding: isryanholding(); break;

View File

@ -297,7 +297,6 @@ public:
static const uint16 addr_isryanholding = 0xc6cc;
static const uint16 addr_findexobject = 0xc6c8;
static const uint16 addr_findsetobject = 0xc6c4;
static const uint16 addr_compare = 0xc6c0;
static const uint16 addr_selectob = 0xc6bc;
static const uint16 addr_withwhat = 0xc6b8;
static const uint16 addr_useelvdoor = 0xc6b4;
@ -1359,7 +1358,7 @@ public:
void showdiscops();
void advisor();
void additionaltext();
//void kernchars();
//void compare();
void othersmoker();
void dofade();
//void setuptimedtemp();
@ -1406,7 +1405,7 @@ public:
//void addtopeoplelist();
void hangoncurs();
void sparkydrip();
void compare();
//void kernchars();
void printcurs();
//void convertkey();
void outofopen();

View File

@ -1717,6 +1717,21 @@ void DreamGenContext::obicons() {
}
}
void DreamGenContext::compare() {
char id[4] = { cl, ch, dl, dh };
flags._z = compare(al, ah, id);
}
bool DreamGenContext::compare(uint8 index, uint8 flag, const char id[4]) {
void *ptr = getanyaddir(index, flag);
const char *objId = (const char *)(((const uint8 *)ptr) + 12); // whether it is a DynObject or a SetObject
for (size_t i = 0; i < 4; ++i) {
if(id[i] != objId[i] + 'A')
return false;
}
return true;
}
bool DreamGenContext::isCD() {
// 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

View File

@ -208,4 +208,6 @@
void obpicture();
void transferinv();
void obicons();
void compare();
bool compare(uint8 index, uint8 flag, const char id[4]);