DREAMWEB: Convert findAllOpen, fillOpen

This commit is contained in:
Willem Jan Palenstijn 2011-12-26 15:23:15 +01:00 committed by Filippos Karapetis
parent 4a30fa8845
commit 1fef9d1f75
6 changed files with 61 additions and 127 deletions

View file

@ -468,9 +468,11 @@ generator = cpp(context, "DreamGen", blacklist = [
'fadeupmonfirst', 'fadeupmonfirst',
'fadeupyellows', 'fadeupyellows',
'femalefan', 'femalefan',
'fillopen',
'fillryan', 'fillryan',
'fillspace', 'fillspace',
'finalframe', 'finalframe',
'findallopen',
'findallryan', 'findallryan',
'findexobject', 'findexobject',
'findfirstpath', 'findfirstpath',

View file

@ -212,6 +212,11 @@ public:
void makeWorn(DynObject *object); void makeWorn(DynObject *object);
void dropObject(); void dropObject();
uint16 findOpenPos(); uint16 findOpenPos();
byte getOpenedSlotSize();
byte getOpenedSlotCount();
void openOb();
void findAllOpen();
void fillOpen();
// from pathfind.cpp // from pathfind.cpp
void turnPathOn(uint8 param); void turnPathOn(uint8 param);

View file

@ -73,123 +73,6 @@ void DreamGenContext::transferMap() {
_add(data.word(kExframepos), cx); _add(data.word(kExframepos), cx);
} }
void DreamGenContext::fillOpen() {
STACK_CHECK;
delTextLine();
getOpenedSize();
_cmp(ah, 4);
if (flags.c())
goto lessthanapage;
ah = 4;
lessthanapage:
al = 1;
push(ax);
es = data.word(kBuffers);
di = (0+(228*13));
findAllOpen();
si = (0+(228*13));
di = (80);
bx = (58)+96;
cx = pop();
openloop1:
push(cx);
push(di);
push(bx);
ax = es.word(si);
_add(si, 2);
push(si);
push(es);
_cmp(ch, cl);
if (flags.c())
goto nextopenslot;
obToInv();
nextopenslot:
es = pop();
si = pop();
bx = pop();
di = pop();
cx = pop();
_add(di, (44));
_inc(cl);
_cmp(cl, 5);
if (!flags.z())
goto openloop1;
underTextLine();
}
void DreamGenContext::findAllOpen() {
STACK_CHECK;
push(di);
cx = 16;
ax = 0x0ffff;
_stosw(cx, true);
di = pop();
cl = data.byte(kOpenedob);
dl = data.byte(kOpenedtype);
ds = data.word(kExtras);
bx = (0+2080+30000);
ch = 0;
findopen1:
_cmp(ds.byte(bx+3), cl);
if (!flags.z())
goto findopen2;
_cmp(ds.byte(bx+2), dl);
if (!flags.z())
goto findopen2;
_cmp(data.byte(kOpenedtype), 4);
if (flags.z())
goto noloccheck;
al = ds.byte(bx+5);
_cmp(al, data.byte(kReallocation));
if (!flags.z())
goto findopen2;
noloccheck:
al = ds.byte(bx+4);
ah = 0;
push(di);
_add(di, ax);
_add(di, ax);
al = ch;
ah = 4;
_stosw();
di = pop();
findopen2:
_add(bx, 16);
_inc(ch);
_cmp(ch, (114));
if (!flags.z())
goto findopen1;
cl = data.byte(kOpenedob);
dl = data.byte(kOpenedtype);
push(dx);
ds = data.word(kFreedat);
dx = pop();
bx = 0;
ch = 0;
findopen1a:
_cmp(ds.byte(bx+3), cl);
if (!flags.z())
goto findopen2a;
_cmp(ds.byte(bx+2), dl);
if (!flags.z())
goto findopen2a;
al = ds.byte(bx+4);
ah = 0;
push(di);
_add(di, ax);
_add(di, ax);
al = ch;
ah = 2;
_stosw();
di = pop();
findopen2a:
_add(bx, 16);
_inc(ch);
_cmp(ch, 80);
if (!flags.z())
goto findopen1a;
}
void DreamGenContext::getFreeAd() { void DreamGenContext::getFreeAd() {
STACK_CHECK; STACK_CHECK;
ah = 0; ah = 0;

View file

@ -434,8 +434,6 @@ public:
void pickupConts(); void pickupConts();
void transferMap(); void transferMap();
void getSetAd(); void getSetAd();
void findAllOpen();
void fillOpen();
void dreamweb(); void dreamweb();
void read(); void read();
void searchForString(); void searchForString();

View file

@ -277,7 +277,8 @@ void DreamBase::getBackFromOb() {
} }
void DreamGenContext::getOpenedSize() { void DreamGenContext::getOpenedSize() {
//ax = getOpenedSlotCount(); //ah = getOpenedSlotSize();
//ah = getOpenedSlotCount();
// We need to call the ASM-style versions of get*Ad, as these also set // We need to call the ASM-style versions of get*Ad, as these also set
// bx and es // bx and es
@ -300,7 +301,7 @@ void DreamGenContext::getOpenedSize() {
} }
} }
byte DreamGenContext::getOpenedSlotCount() { byte DreamBase::getOpenedSlotCount() {
byte obj = data.byte(kOpenedob); byte obj = data.byte(kOpenedob);
switch (data.byte(kOpenedtype)) { switch (data.byte(kOpenedtype)) {
case 4: case 4:
@ -312,7 +313,7 @@ byte DreamGenContext::getOpenedSlotCount() {
} }
} }
byte DreamGenContext::getOpenedSlotSize() { byte DreamBase::getOpenedSlotSize() {
byte obj = data.byte(kOpenedob); byte obj = data.byte(kOpenedob);
switch (data.byte(kOpenedtype)) { switch (data.byte(kOpenedtype)) {
case 4: case 4:
@ -324,14 +325,14 @@ byte DreamGenContext::getOpenedSlotSize() {
} }
} }
void DreamGenContext::openOb() { void DreamBase::openOb() {
uint8 commandLine[64] = "OBJECT NAME ONE "; uint8 commandLine[64] = "OBJECT NAME ONE ";
copyName(data.byte(kOpenedtype), data.byte(kOpenedob), commandLine); copyName(data.byte(kOpenedtype), data.byte(kOpenedob), commandLine);
printMessage(kInventx, kInventy+86, 62, 240, false); printMessage(kInventx, kInventy+86, 62, 240, false);
al = printDirect(commandLine, data.word(kLastxpos) + 5, kInventy+86, 220, false); printDirect(commandLine, data.word(kLastxpos) + 5, kInventy+86, 220, false);
fillOpen(); fillOpen();
_openChangeSize = getOpenedSlotCount() * kItempicsize + kInventx; _openChangeSize = getOpenedSlotCount() * kItempicsize + kInventx;
@ -1081,4 +1082,52 @@ byte DreamGenContext::transferToEx() {
return pos; return pos;
} }
void DreamBase::fillOpen() {
delTextLine();
uint8 size = getOpenedSlotCount();
if (size > 4)
size = 4;
findAllOpen();
uint8 *openInvList = getSegment(data.word(kBuffers)).ptr(kOpeninvlist, 32);
for (uint8 i = 0; i < size; ++i) {
uint8 index = openInvList[2*i];
uint8 type = openInvList[2*i + 1];
obToInv(index, type, kInventx + (i-1)*kItempicsize, kInventy + 96);
}
underTextLine();
}
void DreamBase::findAllOpen() {
uint8 *openInvList = getSegment(data.word(kBuffers)).ptr(kOpeninvlist, 32);
memset(openInvList, 0xFF, 32);
const DynObject *obj;
obj = (const DynObject *)getSegment(data.word(kExtras)).ptr(kExdata, 0);
for (uint8 i = 0; i < kNumexobjects; ++i, ++obj) {
if (obj->mapad[1] != data.byte(kOpenedob))
continue;
if (obj->mapad[0] != data.byte(kOpenedtype))
continue;
if (data.byte(kOpenedtype) != kExObjectType && obj->mapad[3] != data.byte(kReallocation))
continue;
uint8 slot = obj->mapad[2];
assert(slot < 16);
openInvList[2*slot] = i;
openInvList[2*slot + 1] = kExObjectType;
}
obj = (const DynObject *)getSegment(data.word(kFreedat)).ptr(0, 0);
for (uint8 i = 0; i < 80; ++i, ++obj) {
if (obj->mapad[1] != data.byte(kOpenedob))
continue;
if (obj->mapad[0] != data.byte(kOpenedtype))
continue;
uint8 index = obj->mapad[2];
openInvList[2*index] = i;
openInvList[2*index + 1] = kFreeObjectType;
}
}
} // End of namespace DreamGen } // End of namespace DreamGen

View file

@ -119,10 +119,7 @@
void processTrigger(); void processTrigger();
bool execCommand(); bool execCommand();
void getOpenedSize(); void getOpenedSize();
byte getOpenedSlotSize();
byte getOpenedSlotCount();
bool checkObjectSizeCPP(); bool checkObjectSizeCPP();
void openOb();
void identifyOb(); void identifyOb();
void selectOb(); void selectOb();
void findInvPos(); void findInvPos();