Skip to content

Commit

Permalink
Merge 0.2.5 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
usineur committed Jan 10, 2020
2 parents d99f8e3 + 5662148 commit 2f32df3
Show file tree
Hide file tree
Showing 18 changed files with 328 additions and 229 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* release 0.2.5
- fixed spiders and worms movement
- several fixes for big endian platforms

* release 0.2.4
- fixed Amigo walk path in 'pwr2' screen 7
- fixed glowing stone puzzle in 'lar2'
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if(SWITCH_LIBNX)
add_definitions(-D__SWITCH__)
add_custom_target(${CMAKE_PROJECT_NAME}.nro
DEPENDS ${CMAKE_PROJECT_NAME}
COMMAND nacptool --create "Heart of Darkness" "cyx, usineur" "0.2.4" ${CMAKE_PROJECT_NAME}.nacp
COMMAND nacptool --create "Heart of Darkness" "cyx, usineur" "0.2.5" ${CMAKE_PROJECT_NAME}.nacp
COMMAND elf2nro ${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME}.nro --icon=${CMAKE_SOURCE_DIR}/res/icon.jpg --nacp=${CMAKE_PROJECT_NAME}.nacp
)
add_custom_target(nxlink
Expand Down
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

hode README
Release version: 0.2.4
Release version: 0.2.5
-------------------------------------------------------------------------------


Expand Down
46 changes: 46 additions & 0 deletions RELEASES.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,52 @@
- rock_hod.mst: 5b49637348f6c6a2737a64cacf01f9bcef8e83f6
- rock_hod.sss: 55c841f6c091c2ae68f0636c075c66405d00cc6a
- setup.dat: 1d476d896cafd3d4af00b15eb2eb695a804a0662
- name: Heart of Darkness Japanese (Win32)
files:
- dark_hod.lvl: e7c188e5c47632d512d96d9da89fc8c060528d45
- dark_hod.mst: 6c2d93b2e31c299215d0fdf05ac1e8e8e95e9042
- dark_hod.sss: 8d5b19842e551b8ec73bda411c210cc96e08569a
- fort_hod.lvl: 82456ed6e29780b5b8031a67ba3dddb8da813c19
- fort_hod.mst: ce55095902ade9f1d8a198f271d0946d6228b90d
- fort_hod.sss: 6ff572b553d93040c9cad74891db05b2cc8267c6
- hod.paf: fe75aff52c879aa5cc84a87babbca2ce0affec23
- hodwin32.exe: eb0f032f343e2c27d60291c79ae667034a0c7389
securom: false
version_info:
- Comments: Release Candidate 0
- CompanyName: Amazing Studio - 9 rue d' Enhgien - 75010 Paris FRANCE - Email: [email protected]
- FileDescription: Heart Of Darkness
- FileVersion: 1, 1, 0, 0
- InternalName: Heart Of Darkness
- LegalCopyright: (c) 1998 by Amazing Studio & Infogrames
- LegalTrademarks: by Amazing Studio - All rights reserved
- OriginalFilename: Heart Of Darkness
- PrivateBuild: HEARTMM5511
- ProductName: Heart Of Darkness - Windows 95 / 98 & NT - DirectX 3.x or greater
- ProductVersion: 1, 1, 0, 0
- SpecialBuild: VC5.0 Sp3
- isld_hod.lvl: f78e9316f2187c0ca9e42abe8a2242b3d3e6feaf
- isld_hod.mst: 448e5dd5bbe59621279562d8695c9a864cb4c286
- isld_hod.sss: 61c5da6dfcf80684c56baebddb04125ca0c1f209
- lar1_hod.lvl: 84f7b33a9b57f2afa68063e0128512991f86dfa0
- lar1_hod.mst: 9db53a4a75327eeca45ffa5b761a9f04af5e5204
- lar1_hod.sss: 72667991fde3caf36978da1fa929695de80abe4b
- lar2_hod.lvl: 999b2548490f586f955c9f5c6db95f88d49102f3
- lar2_hod.mst: 333ea4e6be6ca9aad735fafe59177546aab41c4e
- lar2_hod.sss: c5c655b718ead1d2eb460a058df7eb3b795dea9e
- lava_hod.lvl: 2921eb2f78354e79c1257ef55543bb1a1492e914
- lava_hod.mst: c05ce42c0abdbb2dbfc109cbb4ea7eee1937445d
- lava_hod.sss: 8fc8d2c86f67e13ca840d604c603249b20723f85
- pwr1_hod.lvl: cd6489e11914770d95034aa6afaa2fc67f035ce8
- pwr1_hod.mst: f821e5686ae27b2ed5000ea4b38a464ecebe44a7
- pwr1_hod.sss: cbb39e1bfd24dcbd5bf65f9e0b92faaa9b6b02a6
- pwr2_hod.lvl: 7263ecf8d51d45c2c62dc11701eac03b67738fd8
- pwr2_hod.mst: 132b29e758a28529009e979ef31a29a42d0a5c4b
- pwr2_hod.sss: 24342241b4353777cc22696be8a684d635f9c809
- rock_hod.lvl: cdb3d7ad1ae13f2234380f79bc8ec57e1e505cef
- rock_hod.mst: 5b49637348f6c6a2737a64cacf01f9bcef8e83f6
- rock_hod.sss: 55c841f6c091c2ae68f0636c075c66405d00cc6a
- setup.dat: 5cb36223a3fc5561d9c9d945fe3261cd188b5665
- name: Heart of Darkness Demo V1.2 (Win32)
files:
- hod_demo.paf: 50a0942256b17ed26f3b0f59f4cf7570a6eb8688
Expand Down
8 changes: 5 additions & 3 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ struct LvlSprMoveData {
uint8_t op2;
uint16_t op3;
uint16_t op4;
uint16_t unk0x6;
uint16_t unk0x6; // padding to 8 bytes
} PACKED; // sizeof == 8

struct LvlSprHotspotData {
Expand Down Expand Up @@ -384,9 +384,11 @@ struct MonsterObject1 {
int levelPosBounds_y1; // 0xA0
uint8_t o_flags0; // 0xA4
uint8_t flagsA5; // 0xA5
uint8_t flagsA6; // 0xA6
uint8_t flagsA6; // 0xA6 |1:turning |2:idle |4:colliding
uint8_t targetDirectionMask; // 0xA7
uint8_t bboxNum[4]; // 0xA8, 0xA9, 0xAA, 0xAB
uint8_t bboxNum[2]; // 0xA8, 0xA9
uint8_t walkBoxNum; // 0xAA
uint8_t unkAB; // 0xAB
int32_t targetLevelPos_x; // 0xAC
int32_t targetLevelPos_y; // 0xB0
int32_t previousDxPos; // 0xB4 _xMstPos2
Expand Down
1 change: 1 addition & 0 deletions fs_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <dirent.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/unistd.h>
#include "fs.h"
#include "util.h"

Expand Down
8 changes: 5 additions & 3 deletions game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1833,13 +1833,13 @@ int Game::clipLvlObjectsBoundingBox(LvlObject *o, LvlObject *ptr, int type) {
case 0:
obj1.x2 = obj1.x1 + o->width - 1;
obj1.y2 += o->height - 1;
obj2.x2 += ptr->width - 1;
obj2.x2 = obj2.x1 + ptr->width - 1;
obj2.y2 += ptr->height - 1;
return clipBoundingBox(&obj1, &obj2);
case 48:
obj1.x2 += o->width - 1;
obj1.x2 = obj1.x1 + o->width - 1;
obj1.y2 += o->height - 1;
obj2.x2 += ptr->width - 1;
obj2.x2 = obj2.x1 + ptr->width - 1;
obj2.y2 += ptr->height - 1;
if (clipBoundingBox(&obj1, &obj2)) {
return updateBoundingBoxClippingOffset(&obj1, &obj2, _res->getLvlSpriteCoordPtr(ptr->levelData0x2988, ptr->currentSprite), (ptr->flags1 >> 4) & 3);
Expand Down Expand Up @@ -4817,6 +4817,8 @@ void Game::saveSetupCfg() {
if (count != kSetupCfgSize) {
warning("Failed to write %d bytes to '%s', ret %d", kSetupCfgSize, _setupCfg, count);
}
} else {
warning("Failed to save '%s'", kSetupCfgSize);
}
}

Expand Down
4 changes: 2 additions & 2 deletions game.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum {
kCheatOneHitPlasmaCannon = 1 << 1,
kCheatOneHitSpecialPowers = 1 << 2,
kCheatWalkOnLava = 1 << 3,
kCheatGateNoCrush = 1 << 4,
kCheatGateNoCrush = 1 << 4
};

struct Game {
Expand Down Expand Up @@ -404,7 +404,7 @@ struct Game {
void mstBoundingBoxClear(MonsterObject1 *m, int dir);
int mstBoundingBoxCollides1(int num, int x1, int y1, int x2, int y2) const;
int mstBoundingBoxUpdate(int num, int monster1Index, int x1, int y1, int x2, int y2);
int mstBoundingBoxCollides2(int num, int x1, int y1, int x2, int y2) const;
int mstBoundingBoxCollides2(int monster1Index, int x1, int y1, int x2, int y2) const;

void mstTaskSetMonster2ScreenPosition(Task *t);
int getMstDistance(int y, const AndyShootData *p) const;
Expand Down
2 changes: 2 additions & 0 deletions intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
#define le32toh(x) x
#define htole16(x) x
#define htole32(x) x
static const bool kByteSwapData = false; // no byteswap needed on little endian
#else
#include <endian.h>
static const bool kByteSwapData = (__BYTE_ORDER == __BIG_ENDIAN);
#endif

#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
Expand Down
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ int main(int argc, char *argv[]) {
}
g->_res->loadSetupDat();
if (_runMenu) {
Menu *m = new Menu(g->_paf, g->_res, g->_video);
Menu *m = new Menu(g, g->_paf, g->_res, g->_video);
m->mainLoop();
delete m;
} else {
Expand Down
137 changes: 114 additions & 23 deletions menu.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#include "game.h"
#include "menu.h"
#include "lzw.h"
#include "paf.h"
Expand All @@ -7,22 +8,72 @@
#include "util.h"
#include "video.h"

Menu::Menu(PafPlayer *paf, Resource *res, Video *video)
: _paf(paf), _res(res), _video(video) {
Menu::Menu(Game *g, PafPlayer *paf, Resource *res, Video *video)
: _g(g), _paf(paf), _res(res), _video(video) {
_titleSprites = 0;
_playerSprites = 0;
_titleBitmap = 0;
_playerBitmap = 0;
_titleBitmapData = 0;
_titleBitmapSize = 0;
_playerBitmapData = 0;
_playerBitmapSize = 0;
_soundData = 0;
_currentOption = 0;
}

void Menu::loadData() {
_res->loadDatMenuBuffers();

if (_res->_datHdr.version == 10) {
const int version = _res->_datHdr.version;
const int options = 19;

const uint8_t *ptr = _res->_menuBuffer1;
uint32_t ptrOffset = 0;
const uint8_t *ptr = _res->_menuBuffer1;
uint32_t ptrOffset = 0;

if (version == 10) {

_titleSprites = (DatSpritesGroup *)(ptr + ptrOffset);
_titleSprites->size = le32toh(_titleSprites->size);
ptrOffset += sizeof(DatSpritesGroup) + _titleSprites->size;

_playerSprites = (DatSpritesGroup *)(ptr + ptrOffset);
_playerSprites->size = le32toh(_playerSprites->size);
ptrOffset += sizeof(DatSpritesGroup) + _playerSprites->size;

_titleBitmapSize = READ_LE_UINT32(ptr + ptrOffset);
_titleBitmapData = ptr + ptrOffset + 8;
ptrOffset += 8 + _titleBitmapSize + 768;

_playerBitmapSize = READ_LE_UINT32(ptr + ptrOffset);
_playerBitmapData = ptr + ptrOffset + 8;
ptrOffset += 8 + _playerBitmapSize + 768;

} else if (version == 11) {

ptr = _res->_menuBuffer1;
uint32_t hdrOffset = 4;

ptrOffset = 4 + (2 + options) * 8; // pointers to bitmaps
ptrOffset += _res->_datHdr.cutscenesCount * 12;
for (int i = 0; i < 8; ++i) {
ptrOffset += _res->_datHdr.levelCheckpointsCount[i] * 12;
}
ptrOffset += _res->_datHdr.levelsCount * 12;

_titleBitmapSize = READ_LE_UINT32(ptr + hdrOffset);
hdrOffset += 8;
_titleBitmapData = ptr + ptrOffset;
ptrOffset += _titleBitmapSize + 768;

_playerBitmapSize = READ_LE_UINT32(ptr + hdrOffset);
hdrOffset += 8;
_playerBitmapData = ptr + ptrOffset;
ptrOffset += _playerBitmapSize + 768;
}

ptr = _res->_menuBuffer0;
ptrOffset = 0;

if (version == 11) {

_titleSprites = (DatSpritesGroup *)(ptr + ptrOffset);
_titleSprites->size = le32toh(_titleSprites->size);
Expand All @@ -32,15 +83,40 @@ void Menu::loadData() {
_playerSprites->size = le32toh(_playerSprites->size);
ptrOffset += sizeof(DatSpritesGroup) + _playerSprites->size;

_titleBitmap = (DatBitmap *)(ptr + ptrOffset);
_titleBitmap->size = le32toh(_titleBitmap->size);
ptrOffset += sizeof(DatBitmap) + _titleBitmap->size;
ptrOffset += _res->_datHdr.menusCount * 8;

_playerBitmap = (DatBitmap *)(ptr + ptrOffset);
_playerBitmap->size = le32toh(_playerBitmap->size);
ptrOffset += sizeof(DatBitmap) + _playerBitmap->size;
} else {
warning("Unhandled .dat version %d", _res->_datHdr.version);
const int size = READ_LE_UINT32(ptr + ptrOffset); ptrOffset += 4;
assert((size % (16 * 10)) == 0);
ptrOffset += size;

_soundData = ptr + ptrOffset;
ptrOffset += _res->_datHdr.soundDataSize;
}
}

int Menu::getSoundNum(int num) const {
assert((num & 7) == 0);
num /= 8;
if (_soundData) {
const int count = READ_LE_UINT32(_soundData + 4);
const uint8_t *p = _soundData + 8 + count * 8;
for (int i = 0; i < count; ++i) {
const int count2 = READ_LE_UINT32(_soundData + 8 + i * 8 + 4);
if (i == num) {
assert(count2 != 0);
return (int16_t)READ_LE_UINT16(p);
}
p += count2 * 2;
}
assert((p - _soundData) == _res->_datHdr.soundDataSize);
}
return -1;
}

void Menu::playSound(int num) {
num = getSoundNum(num);
if (num != -1) {
_g->playSound(num, 0, 0, 5);
}
}

Expand All @@ -56,33 +132,48 @@ void Menu::drawSprite(const DatSpritesGroup *spriteGroup, uint32_t num) {
}
}

void Menu::drawBitmap(const DatBitmap *bitmap) {
const uint8_t *data = (const uint8_t *)&bitmap[1];
const uint32_t uncompressedSize = decodeLZW(data, _video->_frontLayer);
void Menu::drawBitmap(const uint8_t *bitmapData, uint32_t bitmapSize, const DatSpritesGroup *spritesGroup) {
const uint32_t uncompressedSize = decodeLZW(bitmapData, _video->_frontLayer);
assert(uncompressedSize == Video::W * Video::H);
const uint8_t *palette = data + bitmap->size;
const uint8_t *palette = bitmapData + bitmapSize;
g_system->setPalette(palette, 256, 6);
if (bitmap == _titleBitmap) {
drawSprite(_titleSprites, _currentOption);
}
drawSprite(spritesGroup, _currentOption);
g_system->copyRect(0, 0, Video::W, Video::H, _video->_frontLayer, Video::W);
g_system->updateScreen(false);
}

void Menu::mainLoop() {
loadData();
handleTitleScreen();
}

void Menu::handleTitleScreen() {
while (!g_system->inp.quit) {
if (g_system->inp.keyReleased(SYS_INP_UP)) {
if (_currentOption > 0) {
--_currentOption;
}
playSound(0x70);
}
if (g_system->inp.keyReleased(SYS_INP_DOWN)) {
if (_currentOption < 3) {
++_currentOption;
}
playSound(0x70);
}
if (g_system->inp.keyReleased(SYS_INP_SHOOT) || g_system->inp.keyReleased(SYS_INP_JUMP)) {
if (_currentOption == 0) {
// assign player
} else if (_currentOption == 1) {
// play
} else if (_currentOption == 2) {
// options
} else if (_currentOption == 3) {
break;
}
playSound(0x78);
}
drawBitmap(_titleBitmap);
drawBitmap(_titleBitmapData, _titleBitmapSize, _titleSprites);
g_system->processEvents();
g_system->sleep(15);
}
Expand Down
Loading

0 comments on commit 2f32df3

Please sign in to comment.