1 | --- Original object.cpp Mon Nov 26 14:54:00 2001
|
---|
2 | +++ object.cpp Mon Nov 26 14:57:25 2001
|
---|
3 | @@ -753,10 +753,10 @@
|
---|
4 | uint32 size;
|
---|
5 |
|
---|
6 | if (getObjectIndex(img)!=-1) {
|
---|
7 | - obim = getObjectAddress(img);
|
---|
8 | - ptr = obim + READ_BE_UINT32(&((ImageHeader*)obim)->size);
|
---|
9 | - cdhd = (CodeHeader*)findResource(MKID('CDHD'), obim, 0);
|
---|
10 | - imhd = (ImageHeader*)findResource(MKID('IMHD'), ptr, 0);
|
---|
11 | + obcd = getObjectAddress(img);
|
---|
12 | + obim = obcd + READ_BE_UINT32(&((ImageHeader*)obcd)->size);
|
---|
13 | + cdhd = (CodeHeader*)findResource(MKID('CDHD'), obcd, 0);
|
---|
14 | + imhd = (ImageHeader*)findResource(MKID('IMHD'), obim, 0);
|
---|
15 | } else {
|
---|
16 | ensureResourceLoaded(1, room);
|
---|
17 | roomptr = getResourceAddress(1, room);
|
---|
18 |
|
---|
19 | --- Original scumm.h Thu Nov 15 07:09:39 2001
|
---|
20 | +++ scumm.h Mon Nov 26 11:35:56 2001
|
---|
21 | @@ -55,6 +55,10 @@
|
---|
22 | uint16 scale;
|
---|
23 | } GCC_PACK;
|
---|
24 |
|
---|
25 | +struct FlObjectHeader {
|
---|
26 | + uint32 tag, size;
|
---|
27 | +} GCC_PACK;
|
---|
28 | +
|
---|
29 | struct ResHeader {
|
---|
30 | uint32 size;
|
---|
31 | } GCC_PACK;
|
---|
32 | @@ -1495,6 +1499,7 @@
|
---|
33 | void unlock(int type, int i);
|
---|
34 | void heapClear(int mode);
|
---|
35 | void unkHeapProc2(int a, int b);
|
---|
36 | + int getFlObjectSlot();
|
---|
37 | void loadFlObject(int a, int b);
|
---|
38 | void setPalColor(int index, int r, int g, int b);
|
---|
39 | void darkenPalette(int a, int b, int c, int d, int e);
|
---|
40 |
|
---|
41 | --- Original resource.cpp Thu Nov 15 07:09:39 2001
|
---|
42 | +++ resource.cpp Mon Nov 26 18:57:05 2001
|
---|
43 | @@ -817,8 +817,116 @@
|
---|
44 | warning("unkHeapProc2: not implemented");
|
---|
45 | }
|
---|
46 |
|
---|
47 | -void Scumm::loadFlObject(int a, int b) {
|
---|
48 | - warning("loadFlObject(%d,%d):not implemented", a, b);
|
---|
49 | +int Scumm::getFlObjectSlot() {
|
---|
50 | + int i;
|
---|
51 | + for (i=1; i<_maxFLObject; i++) {
|
---|
52 | + if (_baseFLObject[i] == NULL) {
|
---|
53 | + return i;
|
---|
54 | + }
|
---|
55 | + }
|
---|
56 | + error("Flobject table full, %d max items", _maxFLObject);
|
---|
57 | +}
|
---|
58 | +
|
---|
59 | +
|
---|
60 | +
|
---|
61 | +void Scumm::loadFlObject(int object, int room) {
|
---|
62 | + byte *ptr;
|
---|
63 | + int index;
|
---|
64 | + CodeHeader *cdhd;
|
---|
65 | + ImageHeader *imhd;
|
---|
66 | + int w,h;
|
---|
67 | + byte *roomptr,*obcd,*obim,*dataptr,*bomp, *flobptr, *codeptr, *curptr, *imptr;
|
---|
68 | + RoomHeader *rmhd;
|
---|
69 | + int i,numobj;
|
---|
70 | + uint32 size;
|
---|
71 | + int slot;
|
---|
72 | + int cdoffs, imoffs, cursize;
|
---|
73 | + FlObjectHeader *flobhd;
|
---|
74 | + CodeHeader* codehdr;
|
---|
75 | +
|
---|
76 | + debug(1,"Loading FlObject %d from room %d", object, room);
|
---|
77 | +
|
---|
78 | + ensureResourceLoaded(rtRoom, room);
|
---|
79 | + roomptr = getResourceAddress(rtRoom, room);
|
---|
80 | + rmhd = (RoomHeader*)findResource(MKID('RMHD'), roomptr, 0);
|
---|
81 | +
|
---|
82 | + numobj = READ_LE_UINT16(&rmhd->numObjects);
|
---|
83 | + for(i=0; ;i++) {
|
---|
84 | + if (i>=numobj)
|
---|
85 | + error("loadFlobject: object %d code not found in room %d", object, room);
|
---|
86 | +
|
---|
87 | + obcd = findResource(MKID('OBCD'), roomptr, i);
|
---|
88 | + if (obcd==NULL)
|
---|
89 | + error("loadFlobject: not enough code blocks in room %d", room);
|
---|
90 | + cdhd = (CodeHeader*)findResource(MKID('CDHD'), obcd, 0);
|
---|
91 | + if (READ_LE_UINT16(&cdhd->obj_id) == object) {
|
---|
92 | + cdoffs = obcd - roomptr;
|
---|
93 | + cursize = READ_BE_UINT32_UNALIGNED(obcd+4);
|
---|
94 | + break;
|
---|
95 | + }
|
---|
96 | + }
|
---|
97 | +
|
---|
98 | + for(i=0; ;i++) {
|
---|
99 | + if (i>=numobj)
|
---|
100 | + error("loadFlobject: object %d image not found in room %d", object, room);
|
---|
101 | + obim = findResource(MKID('OBIM'), roomptr, i);
|
---|
102 | + if (obim==NULL)
|
---|
103 | + error("loadFlobject: not enough image blocks in room %d", room);
|
---|
104 | + imhd = (ImageHeader*)findResource(MKID('IMHD'), obim, 0);
|
---|
105 | + if (READ_LE_UINT16(&imhd->obj_id) == object) {
|
---|
106 | + imoffs = obim - roomptr;
|
---|
107 | + cursize += READ_BE_UINT32_UNALIGNED(obim+4);
|
---|
108 | + break;
|
---|
109 | + }
|
---|
110 | + }
|
---|
111 | +
|
---|
112 | + ++_numObjectsInRoom;
|
---|
113 | + if (_numObjectsInRoom >= _numLocalObjects) {
|
---|
114 | + error("Too many objects in current room");
|
---|
115 | + }
|
---|
116 | +
|
---|
117 | + ObjectData *od = &_objs[_numObjectsInRoom];
|
---|
118 | +
|
---|
119 | + slot = getFlObjectSlot();
|
---|
120 | + cursize += sizeof(FlObjectHeader);
|
---|
121 | +
|
---|
122 | + od->fl_object_index = slot;
|
---|
123 | + od->unk_3 = room;
|
---|
124 | + createResource(rtFlObject, slot, cursize);
|
---|
125 | +
|
---|
126 | + flobhd = (FlObjectHeader*)getResourceAddress(rtFlObject, slot);
|
---|
127 | + flobhd->tag = MKID('FLOB');
|
---|
128 | + flobhd->size = TO_BE_32(cursize); //swapped
|
---|
129 | +
|
---|
130 | + codeptr = getResourceAddress(rtRoom, room) + cdoffs;
|
---|
131 | + size = READ_BE_UINT32_UNALIGNED(codeptr+4);
|
---|
132 | +
|
---|
133 | + flobptr = getResourceAddress(rtFlObject, slot);
|
---|
134 | + curptr = flobptr + sizeof(FlObjectHeader);
|
---|
135 | + memcpy(curptr, codeptr, size);
|
---|
136 | + curptr += size;
|
---|
137 | +
|
---|
138 | + imptr = getResourceAddress(rtRoom, room) + imoffs;
|
---|
139 | + size = READ_BE_UINT32_UNALIGNED(imptr+4);
|
---|
140 | + memcpy(curptr, imptr, size);
|
---|
141 | +
|
---|
142 | + codeptr = getResourceAddress(rtRoom, room) + cdoffs;
|
---|
143 | + codehdr = (CodeHeader*)findResource(MKID('CDHD'), codeptr, 0);
|
---|
144 | +
|
---|
145 | + od->obj_nr = READ_LE_UINT16(&codehdr->obj_id);
|
---|
146 | + od->numstrips = READ_LE_UINT16(&codehdr->v6.w)>>3;
|
---|
147 | + od->height = READ_LE_UINT16(&codehdr->v6.h)>>3;
|
---|
148 | + od->x_pos = ((int16)READ_LE_UINT16(&codehdr->v6.x))>>3;
|
---|
149 | + od->y_pos = ((int16)READ_LE_UINT16(&codehdr->v6.y))>>3;
|
---|
150 | + if (codehdr->v6.flags == 0x80) {
|
---|
151 | + od->parentstate = 1<<4;
|
---|
152 | + } else {
|
---|
153 | + od->parentstate = (codehdr->v6.flags&0xF)<<OF_STATE_SHL;
|
---|
154 | + }
|
---|
155 | + od->parent = codehdr->v6.parent;
|
---|
156 | + od->actordir = codehdr->v6.actordir;
|
---|
157 | + od->offs_obcd_to_room = 0;
|
---|
158 | + od->offs_obim_to_room = 0;
|
---|
159 | }
|
---|
160 |
|
---|
161 | void Scumm::readMAXS() {
|
---|