DREAMWEB: 'checkifperson' ported to C++

This commit is contained in:
Bertrand Augereau 2011-08-11 23:13:17 +02:00
parent 01ccadf7c1
commit e78a5a2b08
7 changed files with 62 additions and 79 deletions

View file

@ -105,6 +105,7 @@ generator = cpp(context, "DreamGen", blacklist = [
'parseblaster',
'deltextline',
'doblocks',
'checkifperson',
], skip_output = [
# These functions are processed but not output
'dreamweb',

View file

@ -16339,69 +16339,6 @@ nothingund:
blank();
}
void DreamGenContext::checkifperson() {
STACK_CHECK;
es = data.word(kBuffers);
bx = (0+(228*13)+32+60+(32*32)+(11*10*3)+768+768+768+(32*32)+(128*5)+(80*5)+(100*5));
cx = 12;
identifyreel:
push(cx);
_cmp(es.byte(bx+4), 255);
if (flags.z())
goto notareelid;
push(es);
push(bx);
push(ax);
ax = es.word(bx+0);
data.word(kReelpointer) = ax;
getreelstart();
_cmp(es.word(si+2), 0x0ffff);
if (!flags.z())
goto notblankpers;
_add(si, 5);
notblankpers:
cx = es.word(si+2);
ax = es.word(si+0);
push(cx);
getreelframeax();
cx = pop();
_add(cl, es.byte(bx+4));
_add(ch, es.byte(bx+5));
dx = cx;
_add(dl, es.byte(bx+0));
_add(dh, es.byte(bx+1));
ax = pop();
bx = pop();
es = pop();
_cmp(al, cl);
if (flags.c())
goto notareelid;
_cmp(ah, ch);
if (flags.c())
goto notareelid;
_cmp(al, dl);
if (!flags.c())
goto notareelid;
_cmp(ah, dh);
if (!flags.c())
goto notareelid;
cx = pop();
ax = es.word(bx+2);
data.word(kPersondata) = ax;
al = es.byte(bx+4);
ah = 5;
obname();
al = 0;
_cmp(al, 1);
return;
notareelid:
cx = pop();
_add(bx, 5);
_dec(cx);
if (!flags.z())
goto identifyreel;
}
void DreamGenContext::checkifset() {
STACK_CHECK;
es = data.word(kBuffers);
@ -19949,7 +19886,6 @@ void DreamGenContext::__dispatch_call(uint16 addr) {
case addr_madmanrun: madmanrun(); break;
case addr_checkcoords: checkcoords(); break;
case addr_identifyob: identifyob(); break;
case addr_checkifperson: checkifperson(); break;
case addr_checkifset: checkifset(); break;
case addr_checkifex: checkifex(); break;
case addr_checkiffree: checkiffree(); break;

View file

@ -146,7 +146,6 @@ public:
static const uint16 addr_checkiffree = 0xc9e4;
static const uint16 addr_checkifex = 0xc9e0;
static const uint16 addr_checkifset = 0xc9dc;
static const uint16 addr_checkifperson = 0xc9d8;
static const uint16 addr_identifyob = 0xc9d4;
static const uint16 addr_checkcoords = 0xc9d0;
static const uint16 addr_madmanrun = 0xc9cc;
@ -1362,7 +1361,7 @@ public:
void clearendpal();
void findtext1();
void isryanholding();
void interupttest();
void showslots();
void usecashcard();
void usewall();
void opentomb();
@ -1494,9 +1493,10 @@ public:
void isitdescribed();
void hotelbell();
void loadspeech();
void interupttest();
//void cls();
//void printsprites();
//void dumptimedtext();
//void checkifperson();
void showallobs();
//void getnumber();
void adjustleft();
@ -1564,7 +1564,7 @@ public:
void folderhints();
void openhoteldoor();
void removesetobject();
void checkifperson();
//void dumptimedtext();
//void frameoutfx();
void blank();
void drinker();
@ -1749,10 +1749,9 @@ public:
void loadintotemp2();
void gamer();
void personnametext();
void quitsymbol();
void readfromfile();
void initialinv();
void showslots();
void quitsymbol();
//void modifychar();
void hangon();
void settopright();

View file

@ -570,14 +570,10 @@ void DreamGenContext::showgamereel() {
es.word(bx+3) = data.word(kReelpointer);
}
void DreamGenContext::getreelframeax() {
push(ds);
data.word(kCurrentframe) = ax;
findsource();
es = ds;
ds = pop();
cx = (data.word(kCurrentframe) - data.word(kTakeoff)) * 2;
bx = (data.word(kCurrentframe) - data.word(kTakeoff)) * 6;
const Frame *DreamGenContext::getreelframeax(uint16 frame) {
data.word(kCurrentframe) = frame;
uint16 offset = data.word(kCurrentframe) - data.word(kTakeoff);
return findsourceCPP() + offset;
}
void DreamGenContext::showrain() {

View file

@ -96,6 +96,19 @@ struct Reel {
uint8 b4;
};
struct People {
uint8 b0;
uint8 b1;
uint16 w0() const { return READ_LE_UINT16(&b0); }
void setW0(uint16 v) { WRITE_LE_UINT16(&b0, v); }
uint8 b2;
uint8 b3;
uint16 w2() const { return READ_LE_UINT16(&b2); }
void setW2(uint16 v) { WRITE_LE_UINT16(&b2, v); }
uint8 b4;
};
struct Room {
uint8 name[10];
uint8 b10;

View file

@ -964,4 +964,40 @@ void DreamGenContext::checkdest(const uint8 *roomsPaths) {
data.byte(kDestination) = destination;
}
void DreamGenContext::checkifperson() {
flags._z = not checkifperson(al, ah);
}
bool DreamGenContext::checkifperson(uint8 x, uint8 y) {
People *people = (People *)segRef(data.word(kBuffers)).ptr(kPeoplelist, 0);
for (size_t i = 0; i < 12; ++i, ++people) {
if (people->b4 == 255)
continue;
data.word(kReelpointer) = people->w0();
Reel *reel = getreelstartCPP();
if (reel->frame() == 0xffff)
++reel;
const Frame *frame = getreelframeax(reel->frame());
uint8 xmin = reel->x + frame->x;
uint8 ymin = reel->y + frame->y;
uint8 xmax = xmin + frame->width;
uint8 ymax = ymin + frame->height;
if (x < xmin)
continue;
if (y < ymin)
continue;
if (x >= xmax)
continue;
if (y >= ymax)
continue;
data.word(kPersondata) = people->w2();
al = people->b4;
ah = 5;
obname();
return true;
}
return false;
}
} /*namespace dreamgen */

View file

@ -101,7 +101,7 @@
void showgamereel();
void showreelframe();
void showreelframe(Reel *reel);
void getreelframeax();
const Frame *getreelframeax(uint16 frame);
void turnpathonCPP(uint8 param);
void turnpathoffCPP(uint8 param);
void getroomspaths();
@ -119,4 +119,6 @@
void showrain();
void deltextline();
void doblocks();
void checkifperson();
bool checkifperson(uint8 x, uint8 y);