Skip to content

Commit a2f2773

Browse files
committed
Imports hode 0.2.8
1 parent 1eab1a4 commit a2f2773

File tree

13 files changed

+219
-121
lines changed

13 files changed

+219
-121
lines changed

3p/inih

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* release 0.2.8
2+
- added PSX background overlays (MDEC)
3+
- fixed crash playing paf animation #3 with Italian PC data files
4+
15
* release 0.2.7
26
- added 'projection' submenu
37
- added PSX backgrounds (MDEC)

README.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
hode README
3-
Release version: 0.2.7
3+
Release version: 0.2.8
44
-------------------------------------------------------------------------------
55

66

@@ -50,8 +50,7 @@ Status:
5050

5151
Settings submenu is not implemented.
5252

53-
PSX version datafiles can be used but background overlays (MDEC) are not
54-
decoded and menu is unavailable.
53+
PSX datafiles can be used, but menu and videos are missing.
5554

5655

5756
Credits:

RELEASES.yaml

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,52 @@
4545
- rock_hod.mst: 5b49637348f6c6a2737a64cacf01f9bcef8e83f6
4646
- rock_hod.sss: 55c841f6c091c2ae68f0636c075c66405d00cc6a
4747
- setup.dat: 1d476d896cafd3d4af00b15eb2eb695a804a0662
48+
- name: Heart of Darkness Italian (Win32)
49+
files:
50+
- dark_hod.lvl: e7c188e5c47632d512d96d9da89fc8c060528d45
51+
- dark_hod.mst: 6c2d93b2e31c299215d0fdf05ac1e8e8e95e9042
52+
- dark_hod.sss: 8d5b19842e551b8ec73bda411c210cc96e08569a
53+
- fort_hod.lvl: 82456ed6e29780b5b8031a67ba3dddb8da813c19
54+
- fort_hod.mst: ce55095902ade9f1d8a198f271d0946d6228b90d
55+
- fort_hod.sss: 6ff572b553d93040c9cad74891db05b2cc8267c6
56+
- hod.paf: 0644a8114392b8e9449f691315dd8cb5a8616ac1
57+
- hodwin32.exe: 9c61df98e15a265bd5719b7e5e2e2af13644b80e
58+
securom: true
59+
version_info:
60+
- Comments: Release Candidate 0
61+
- CompanyName: Amazing Studio - 9 rue d' Enhgien - 75010 Paris FRANCE - Email: hod@amazingstudio.com
62+
- FileDescription: Heart Of Darkness
63+
- FileVersion: 1, 1, 0, 0
64+
- InternalName: Heart Of Darkness
65+
- LegalCopyright: (c) 1998 by Amazing Studio & Infogrames
66+
- LegalTrademarks: by Amazing Studio - All rights reserved
67+
- OriginalFilename: Heart Of Darkness
68+
- PrivateBuild: HEARTMM5511
69+
- ProductName: Heart Of Darkness - Windows 95 / 98 & NT - DirectX 3.x or greater
70+
- ProductVersion: 1, 1, 0, 0
71+
- SpecialBuild: VC5.0 Sp3
72+
- isld_hod.lvl: f78e9316f2187c0ca9e42abe8a2242b3d3e6feaf
73+
- isld_hod.mst: 448e5dd5bbe59621279562d8695c9a864cb4c286
74+
- isld_hod.sss: 61c5da6dfcf80684c56baebddb04125ca0c1f209
75+
- lar1_hod.lvl: 84f7b33a9b57f2afa68063e0128512991f86dfa0
76+
- lar1_hod.mst: 9db53a4a75327eeca45ffa5b761a9f04af5e5204
77+
- lar1_hod.sss: 72667991fde3caf36978da1fa929695de80abe4b
78+
- lar2_hod.lvl: 999b2548490f586f955c9f5c6db95f88d49102f3
79+
- lar2_hod.mst: 333ea4e6be6ca9aad735fafe59177546aab41c4e
80+
- lar2_hod.sss: c5c655b718ead1d2eb460a058df7eb3b795dea9e
81+
- lava_hod.lvl: 2921eb2f78354e79c1257ef55543bb1a1492e914
82+
- lava_hod.mst: c05ce42c0abdbb2dbfc109cbb4ea7eee1937445d
83+
- lava_hod.sss: 8fc8d2c86f67e13ca840d604c603249b20723f85
84+
- pwr1_hod.lvl: cd6489e11914770d95034aa6afaa2fc67f035ce8
85+
- pwr1_hod.mst: f821e5686ae27b2ed5000ea4b38a464ecebe44a7
86+
- pwr1_hod.sss: cbb39e1bfd24dcbd5bf65f9e0b92faaa9b6b02a6
87+
- pwr2_hod.lvl: 7263ecf8d51d45c2c62dc11701eac03b67738fd8
88+
- pwr2_hod.mst: 132b29e758a28529009e979ef31a29a42d0a5c4b
89+
- pwr2_hod.sss: 24342241b4353777cc22696be8a684d635f9c809
90+
- rock_hod.lvl: cdb3d7ad1ae13f2234380f79bc8ec57e1e505cef
91+
- rock_hod.mst: 5b49637348f6c6a2737a64cacf01f9bcef8e83f6
92+
- rock_hod.sss: 55c841f6c091c2ae68f0636c075c66405d00cc6a
93+
- setup.dat: 39f310f3586dc5e2f0ff6f81b8ac7257012e933b
4894
- name: Heart of Darkness Japanese (Win32)
4995
files:
5096
- dark_hod.lvl: e7c188e5c47632d512d96d9da89fc8c060528d45
@@ -162,12 +208,16 @@
162208
- rock_hod.mst: 24dee01526c06b6f003b2c8e22e4d5787df333c8
163209
- rock_hod.sss: ec683718d26bc1e0b4a254215621dd6c6c3e60b0
164210
- setup.dat: e6d1ae87b991d3cf623b8ec9fb33cdd2a3d4a1b4
165-
- name: Heart of Darkness Demo (PSX) SLED_013.51
211+
- name: Heart of Darkness Demo (PSX)
166212
files:
167213
- rock_hod.lvl: 9cbc3bad9efe5f21f66c33d9872e29a1bd7b4c0c
168214
- rock_hod.mst: e7fbfcde10c08aa64ae1398fc95257891863790b
169215
- setup.dax: e091dddd74dc00ccf57a48dc8495ed95cde6a42d
170-
- name: Heart of Darkness (PSX) SLUS_006.96
216+
- sled_013.51: 2b51ec92ff067c6099bfa90cb759adebf7979fb5
217+
- text_addr: 0x80010000
218+
- text_size: 452608
219+
- copyright: Sony Computer Entertainment Inc. for Europe area
220+
- name: Heart of Darkness NTSC-U (PSX)
171221
files:
172222
- dark_hod.lvl: f6482575f1d4d2b6aa8910c709681a714edfba6b
173223
- dark_hod.mst: a97ac13edde17fd33cb06e9907139949c8b79cdb
@@ -188,3 +238,11 @@
188238
- rock_hod.lvl: 9cbc3bad9efe5f21f66c33d9872e29a1bd7b4c0c
189239
- rock_hod.mst: e7fbfcde10c08aa64ae1398fc95257891863790b
190240
- setup.dax: 9d5708b6dedce70a17c76c10ea16f02121826aab
241+
- slus_006.96: da1c0a6284345bd64b828e266ef4d6b2eca81f39
242+
- text_addr: 0x80010000
243+
- text_size: 493568
244+
- copyright: Sony Computer Entertainment Inc. for North America area
245+
- slus_007.41: da1c0a6284345bd64b828e266ef4d6b2eca81f39
246+
- text_addr: 0x80010000
247+
- text_size: 493568
248+
- copyright: Sony Computer Entertainment Inc. for North America area

game.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ void Game::setupBackgroundBitmap() {
316316
playSound(lvl->backgroundBitmapId, 0, 0, 3);
317317
}
318318
if (_res->_isPsx) {
319-
_video->decodeBackgroundPsx(pic + 2);
319+
const int size = Video::W * Video::H * sizeof(uint16_t);
320+
_video->decodeBackgroundPsx(pic + 2, size, Video::W, Video::H);
320321
} else {
321322
decodeLZW(pic, _video->_backgroundLayer);
322323
}
@@ -2257,7 +2258,7 @@ LvlObject *Game::updateAnimatedLvlObjectType0(LvlObject *ptr) {
22572258
ptr->currentSound = 0xFFFF;
22582259
}
22592260
if (isPsx) {
2260-
_video->decodeTilePsx(data);
2261+
_video->decodeBackgroundOverlayPsx(data);
22612262
} else {
22622263
Sprite *spr = _spritesNextPtr;
22632264
if (spr && READ_LE_UINT16(data + 2) > 8) {
@@ -2324,7 +2325,7 @@ LvlObject *Game::updateAnimatedLvlObjectType0(LvlObject *ptr) {
23242325
data = vg->currentSpriteData + soundDataLen;
23252326
if (_res->_currentScreenResourceNum == ptr->screenNum) {
23262327
if (isPsx) {
2327-
_video->decodeTilePsx(data);
2328+
_video->decodeBackgroundOverlayPsx(data);
23282329
} else {
23292330
Sprite *spr = _spritesNextPtr;
23302331
if (spr && READ_LE_UINT16(data + 2) > 8) {

main.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,26 +198,24 @@ int main(int argc, char *argv[]) {
198198
setupAudio(g);
199199
g->loadSetupCfg(resume);
200200
bool runGame = true;
201+
g->_video->init(isPsx);
201202
if (_runMenu && resume && !isPsx) {
202203
Menu *m = new Menu(g, g->_paf, g->_res, g->_video);
203204
runGame = m->mainLoop();
204205
delete m;
205206
}
206-
if (runGame) {
207-
if (isPsx) {
208-
g->_video->initPsx();
209-
}
207+
if (runGame && !g_system->inp.quit) {
210208
bool levelChanged = false;
211209
do {
212210
g->mainLoop(level, checkpoint, levelChanged);
211+
// do not save progress when game is started from a specific level/checkpoint
212+
if (resume) {
213+
g->saveSetupCfg();
214+
}
213215
level += 1;
214216
checkpoint = 0;
215217
levelChanged = true;
216218
} while (!g_system->inp.quit && level < kLvl_test);
217-
// do not save progress when game is started from a specific level/checkpoint
218-
if (resume) {
219-
g->saveSetupCfg();
220-
}
221219
}
222220
g_system->stopAudio();
223221
g->_mix.fini();

mdec.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ struct BitStream { // most significant 16 bits
1414
: _src(src), _bits(0), _len(0), _end(src + size) {
1515
}
1616

17-
bool endOfStream() const {
18-
return _src >= _end && _len == 0;
17+
int bitsAvailable() const {
18+
return (_end - _src) * 8 + _len;
1919
}
2020

2121
int getBits(int count) { // 6 to 16 bits
@@ -32,7 +32,7 @@ struct BitStream { // most significant 16 bits
3232
}
3333
int getSignedBits(int len) {
3434
const int shift = 32 - len;
35-
int32_t value = getBits(len);
35+
const int32_t value = getBits(len);
3636
return (value << shift) >> shift;
3737
}
3838
bool getBit() {
@@ -54,7 +54,7 @@ static int readDC(BitStream *bs, int version) {
5454
static void readAC(BitStream *bs, int *coefficients) {
5555
int count = 0;
5656
int node = 0;
57-
while (!bs->endOfStream()) {
57+
while (bs->bitsAvailable() > 0) {
5858
const uint16_t value = _acHuffTree[node].value;
5959
switch (value) {
6060
case kAcHuff_EscapeCode: {
@@ -176,14 +176,14 @@ static void decodeBlock(BitStream *bs, int x8, int y8, uint8_t *dst, int dstPitc
176176
}
177177
}
178178

179-
int decodeMDEC(const uint8_t *src, int len, const uint8_t *mborder, int w, int h, MdecOutput *out) {
179+
int decodeMDEC(const uint8_t *src, int len, const uint8_t *mborder, int mblen, int w, int h, MdecOutput *out) {
180180
BitStream bs(src, len);
181181
bs.getBits(16);
182182
const uint16_t vlc = bs.getBits(16);
183183
assert(vlc == 0x3800);
184184
const uint16_t qscale = bs.getBits(16);
185185
const uint16_t version = bs.getBits(16);
186-
// fprintf(stdout, "mdec qscale %d version %d\n", qscale, version);
186+
// fprintf(stdout, "mdec qscale %d version %d w %d h %d\n", qscale, version, w, h);
187187
assert(version == 2);
188188

189189
const int blockW = (w + 15) / 16;
@@ -196,24 +196,29 @@ int decodeMDEC(const uint8_t *src, int len, const uint8_t *mborder, int w, int h
196196
const int crPitch = out->planes[kOutputPlaneCr].pitch;
197197
uint8_t *crPtr = out->planes[kOutputPlaneCr].ptr + out->y / 2 * crPitch + out->x / 2;
198198

199+
int z = 0;
199200
for (int x = 0; x < blockW; ++x) {
200201
for (int y = 0; y < blockH; ++y) {
201-
if (mborder) {
202-
const uint8_t xy = *mborder++;
202+
if (z < mblen) {
203+
const uint8_t xy = mborder[z];
203204
if ((xy & 15) != x || (xy >> 4) != y) {
204205
continue;
205206
}
207+
++z;
206208
}
207209
decodeBlock(&bs, x, y, crPtr, crPitch, qscale, version);
208210
decodeBlock(&bs, x, y, cbPtr, cbPitch, qscale, version);
209211
decodeBlock(&bs, 2 * x, 2 * y, yPtr, yPitch, qscale, version);
210212
decodeBlock(&bs, 2 * x + 1, 2 * y, yPtr, yPitch, qscale, version);
211213
decodeBlock(&bs, 2 * x, 2 * y + 1, yPtr, yPitch, qscale, version);
212214
decodeBlock(&bs, 2 * x + 1, 2 * y + 1, yPtr, yPitch, qscale, version);
215+
if (mborder && z == mblen) {
216+
goto end;
217+
}
213218
}
214219
}
215-
216-
if (!mborder) {
220+
end:
221+
if (!mborder && bs.bitsAvailable() >= 11) {
217222
const int eof = bs.getBits(11);
218223
assert(eof == 0x3FE); // v2 frame
219224
}

mdec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ struct MdecOutput {
1919
} planes[3];
2020
};
2121

22-
int decodeMDEC(const uint8_t *src, int len, const uint8_t *mborder, int w, int h, MdecOutput *out);
22+
int decodeMDEC(const uint8_t *src, int len, const uint8_t *mborder, int mblen, int w, int h, MdecOutput *out);
2323

2424
#endif // MDEC_H__

0 commit comments

Comments
 (0)