From 8e6276da584b332d81e79cf2cc01303e38ee5735 Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Sat, 16 Mar 2019 23:11:18 +0100 Subject: [PATCH] Update documentation and build script --- .circleci/config.yml | 31 +++++- 3rdParty/Storm/Source/storm.cpp | 10 +- 3rdParty/Storm/Source/storm.h | 8 +- CMake/mingwcc.cmake | 2 + CMakeLists.txt | 3 +- README-devilution.md | 172 -------------------------------- README.md | 57 +++++------ Source/effects.cpp | 28 ++---- SourceX/storm.cpp | 20 ++-- 9 files changed, 83 insertions(+), 248 deletions(-) delete mode 100644 README-devilution.md diff --git a/.circleci/config.yml b/.circleci/config.yml index ffe65e336..d73295908 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,10 +21,32 @@ jobs: - run: dpkg --add-architecture i386 - run: apt-get update -y - run: apt-get install -y -t stretch-backports cmake g++-multilib libsdl2-dev:i386 libsdl2-mixer-dev:i386 libsdl2-ttf-dev:i386 libsodium-dev libsodium-dev:i386 - - run: mkdir build32 - - run: cd build32 && cmake -DCMAKE_TOOLCHAIN_FILE=../CMake/32bit.cmake .. - - run: cd build32 && make -j$(nproc) - - store_artifacts: {path: ./build32/devilutionx, destination: devilutionx_linux_x86} + - run: mkdir build + - run: cd build && cmake -DCMAKE_TOOLCHAIN_FILE=../CMake/32bit.cmake .. + - run: cd build && make -j$(nproc) + - store_artifacts: {path: ./build/devilutionx, destination: devilutionx_linux_x86} + windows_x86: + docker: + - image: debian:stretch-backports + working_directory: ~/repo + steps: + - checkout + - run: apt-get update -y + - run: apt-get install -y -t stretch-backports cmake gcc-mingw-w64-i686 g++-mingw-w64-i686 wget + - run: wget https://www.libsdl.org/release/SDL2-devel-2.0.9-mingw.tar.gz + - run: tar -xzf SDL2-devel-2.0.9-mingw.tar.gz + - run: wget https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-2.0.15-mingw.tar.gz + - run: tar -xzf SDL2_ttf-devel-2.0.15-mingw.tar.gz + - run: wget https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-devel-2.0.4-mingw.tar.gz + - run: tar -xzf SDL2_mixer-devel-2.0.4-mingw.tar.gz + - run: wget https://github.com/jedisct1/libsodium/releases/download/1.0.17/libsodium-1.0.17-mingw.tar.gz + - run: tar -xzf libsodium-1.0.17-mingw.tar.gz --no-same-owner + - run: cp -r libsodium-win32/* /usr/i686-w64-mingw32 + - run: cp -r SDL2*/i686-w64-mingw32 /usr + - run: mkdir build + - run: cd build && cmake -DASAN=OFF -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc.cmake .. + - run: cd build && make -j$(nproc) + - store_artifacts: {path: ./build/devilutionx.exe, destination: devilutionx_x86.exe} workflows: version: 2 @@ -32,3 +54,4 @@ workflows: jobs: - linux_x86_64 - linux_x86 + - windows_x86 diff --git a/3rdParty/Storm/Source/storm.cpp b/3rdParty/Storm/Source/storm.cpp index e08960ad0..85222a4f5 100644 --- a/3rdParty/Storm/Source/storm.cpp +++ b/3rdParty/Storm/Source/storm.cpp @@ -64,13 +64,13 @@ int STORMAPI Ordinal224(int a1) rInt; BOOL STORMAPI SFileCloseArchive(HANDLE hArchive) rBool; BOOL STORMAPI SFileCloseFile(HANDLE hFile) rBool; -BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int a6, int a7) rBool; +BOOL STORMAPI SFileDdaBeginEx(HANDLE hFile, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int a6, int a7) rBool; BOOL STORMAPI SFileDdaDestroy() rBool; -BOOL STORMAPI SFileDdaEnd(HANDLE directsound) rBool; -BOOL STORMAPI SFileDdaGetPos(HANDLE directsound, int a2, int a3) rBool; +BOOL STORMAPI SFileDdaEnd(HANDLE hFile) rBool; +BOOL STORMAPI SFileDdaGetPos(HANDLE hFile, int *current, int *end) rBool; BOOL STORMAPI SFileDdaInitialize(HANDLE directsound) rBool; -BOOL STORMAPI SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume) rBool; +BOOL STORMAPI SFileDdaSetVolume(HANDLE hFile, signed int bigvolume, signed int volume) rBool; BOOL STORMAPI SFileDestroy() rBool; BOOL STORMAPI SFileGetFileArchive(HANDLE hFile, HANDLE *archive) rBool; @@ -169,7 +169,7 @@ BOOL STORMAPI STransCreateI(void *pBuffer, int width, int height, int bpp, int a BOOL STORMAPI SVidDestroy() rBool; BOOL STORMAPI SVidGetSize(HANDLE video, int width, int height, int zero) rBool; BOOL STORMAPI SVidInitialize(HANDLE video) rBool; -BOOL STORMAPI SVidPlayBegin(char *filename, int arg4, int a3, int a4, int a5, int a6, HANDLE* video) rBool; +BOOL STORMAPI SVidPlayBegin(char *filename, int a2, int a3, int a4, int a5, int flags, HANDLE *video) rBool; BOOL STORMAPI SVidPlayContinueSingle(HANDLE video, int a2, int a3) rBool; BOOL STORMAPI SVidPlayEnd(HANDLE video) rBool; diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h index 01bca119a..d782ec620 100644 --- a/3rdParty/Storm/Source/storm.h +++ b/3rdParty/Storm/Source/storm.h @@ -479,13 +479,13 @@ int STORMAPI Ordinal224(int a1); BOOL STORMAPI SFileCloseArchive(HANDLE hArchive); BOOL STORMAPI SFileCloseFile(HANDLE hFile); -BOOL STORMAPI SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int pan, int a7); +BOOL STORMAPI SFileDdaBeginEx(HANDLE hFile, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int pan, int a7); BOOL STORMAPI SFileDdaDestroy(); -BOOL STORMAPI SFileDdaEnd(HANDLE directsound); -BOOL STORMAPI SFileDdaGetPos(HANDLE directsound, int *current, int *end); +BOOL STORMAPI SFileDdaEnd(HANDLE hFile); +BOOL STORMAPI SFileDdaGetPos(HANDLE hFile, int *current, int *end); BOOL STORMAPI SFileDdaInitialize(HANDLE directsound); -BOOL STORMAPI SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume); +BOOL STORMAPI SFileDdaSetVolume(HANDLE hFile, signed int bigvolume, signed int volume); BOOL STORMAPI SFileDestroy(); BOOL STORMAPI SFileGetFileArchive(HANDLE hFile, HANDLE *archive); diff --git a/CMake/mingwcc.cmake b/CMake/mingwcc.cmake index 3e592e994..9e512f2fd 100644 --- a/CMake/mingwcc.cmake +++ b/CMake/mingwcc.cmake @@ -1,3 +1,5 @@ +cmake_minimum_required(VERSION 3.13) + SET(CROSS_PREFIX "/usr" CACHE STRING "crosstool-NG prefix") SET(CMAKE_SYSTEM_NAME Windows) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca069e1b2..74adde140 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.7) include(CMake/out_of_tree.cmake) @@ -217,6 +217,7 @@ if(DIST) endif() if(WIN32) + cmake_minimum_required(VERSION 3.13) target_link_libraries(devilutionx PRIVATE wsock32 ws2_32 wininet) target_compile_options(devilution PUBLIC $<$:-gstabs>) endif() diff --git a/README-devilution.md b/README-devilution.md deleted file mode 100644 index 96fb50c5f..000000000 --- a/README-devilution.md +++ /dev/null @@ -1,172 +0,0 @@ -[![Build Status](https://travis-ci.org/diasurgical/devilution.svg?branch=master)](https://travis-ci.org/diasurgical/devilution) -[![Build status](https://ci.appveyor.com/api/projects/status/ssk0xjhoka1uu940?svg=true)](https://ci.appveyor.com/project/galaxyhaxz/devilution) -[![Build status](https://img.shields.io/github/downloads/diasurgical/devilutionX/total.svg)](https://github.com/diasurgical/devilutionX/releases) - -[Discord Channel](https://discord.gg/aQBQdDe) - -# Devilution -Diablo devolved - magic behind the 1996 computer game - -Reverse engineered by GalaXyHaXz in 2018 - -# Introduction -While most titles from Blizzard receive years of love and support, Diablo stayed in the shadows. Abandoned in favour of a sequel, it remained full of bugs and unfinished potential. The game was last patched in 2001 before being discontinued altogether, a problem I wanted to fix. I played Diablo extensively as a teenager, but as time passed it became difficult to run the game on newer hardware. The lack of many improvements found in the sequel also kept it from ageing well. At first the game appeared to be a lost cause, but thankfully a little oversight in 1997 made it not so. - -With Diablo's development team moving on the source code was given to **Synergistic Software** to handle the expansion. Less known however is that it was also given to **Climax Studios** to create a PlayStation port. Now Sony has long been known for letting things slide; _especially_ in Japan. Anything from leaking prototypes to full source code and Diablo was no exception. Symbolic information was accidentally left on the Japanese port. Normally used for debugging, a symbol file contains a map of everything generated during compile time. This includes file names, functions, structures, variables, and more! To top it all off a special build is hidden on the PC release in `DIABDAT.MPQ -> D1221A.MPQ -> DIABLO.EXE`! This build contains debug tools and assert strings further giving away code information. - -After months of piecing these mistakes together, Devilution was born. I present to you a reconstructed form of Diablo's original source code! Once more shall the heroes of Sanctuary return to the depths below! - -# Purpose -Having the source code makes Diablo much easier to update and maintain. For years mod-makers had to rely on tedious code editing and memory injection. A few even went further and reversed most or all of the game. The problem is that they rarely shared their work. Usually being a one-person job, they move on with their lives due to the amount of time required or lack of interest. This brings us back to square one having to do countless hours of work all over again. Devilution aims to fix this by finally making the source code open to the community. - -In order to ensure that everything is preserved, Devilution keeps everything as it was originally designed. This goes as far as bugs and badly written code in the original game. With that it serves as a base for developers to work with making it much easier than before to update, fix, and port the game to other platforms. - -As a side goal Devilution tries to document the unused and cut content from the final game. Development of Diablo was rushed near the end--many ideas were scrapped and multiplayer was quickly hacked in. By examining the source, we can see various quirks of planned development. - - -# How To Play: - - Install Diablo - - copy diabdat.mpq to Diablo game directory ; Make sure it is all lowercase. - - [Download Devilution](https://github.com/diasurgical/devilutionX/blob/master/build/devilution) - - -# Compiling -Diablo was developed on Windows 95 using Visual C++ 4.20 and later 5.10 and 6 for newer patches. Devilution is optimized for the same tools originally used but is also compatible with modern setups. - -### Building with Visual C++ 6 -- Open the project workspace `Diablo.dsw`, choose `Debug` or `Release`, and then `Build Diablo.exe`. - -To build a binary with functions compiled as close as possible to the original, use [Visual C++ 6](https://winworldpc.com/product/visual-c/6x) with Service Pack 5 and the [Processor Pack](https://download.microsoft.com/download/vb60ent/update/6/w9x2kxp/en-us/vcpp5.exe) (**important for proper code generation!**) - -If you aim to build a binary as close as possible to the original one you will also need [Visual C++ 5](https://winworldpc.com/product/visual-c/5x) with [Service Pack 3](http://www.mediafire.com/file/jw4j4sd5dnzze4p/VS97SP3.zip), since the original binary as linked with the older linker from that. Sadly, you cannot use the old linker right out of VC6, so you'll need to link manually or via the `MakefileVC` in the project root. - -### Building with Visual Studio 2010-2017 -- Open the project solution `Diablo.sln`, choose `Debug` or `Release`, and then `Build Solution`. - -Make sure to disable Data Execution Prevention. `Storm.dll` uses dynamic compilation to improve rendering performance but fails to mark the resulting memory page as executable, leading to a protection fault when trying to draw. -- Configuration options -> Linker -> Advanced -> Data Execution Prevention (DEP). -- Set this value to: No (/NXCOMPAT: NO). - -You will also need the following dependencies installed if you are using Visual Studio 2017. -Make sure to enable these when installing (or modify your installation): -- Requires "Windows 8.1 SDK" (Target Platform) -- Requires "Visual C++ MFC for x86 and x64" (For afxres.h) -- Requires "Windows Universal CRT SDK" (For ctype.h) - -### Building devilutionX (native Linux build) -Note: Since 64-bit builds are currently not in a playable state, it is advised to build in a 32-bit environment. Another possibility is a 32-bit build on a multilib system (see below). - -Install the dependencies on your machine: -``` -sudo apt-get install cmake libsdl2-dev libsdl2-mixer-dev libsdl2-ttf-dev libsodium-dev -``` - -Now run the following commands: -``` -mkdir build -cd build -cmake .. -make -j$(nproc) -``` - -*Arguments to cmake:* - -The default build type is `Debug`. This can be changed with `-DCMAKE_BUILD_TYPE=Release`. Independently of this, the debug mode of the Diablo engine is always enabled by default. It can be disabled with `-DDEBUG=OFF`. Finally, in debug builds the address sanitizer is enabled by default. This can be disabled with `-DASAN=OFF`. - -*To run the game:* - -Copy the compiled devilution executable to your Diablo directory. -Copy the "diablodat.mpq" from your Diablo CD to the Diablo directory and make sure it is LOWERCASE. -Run `./devilution` - -Please keep in mind that this is still being worked on and is missing parts of UI and SoundEffects are not properly playing now. - -### Building deviltuionX 32-bit on 64-bit (multilib) platforms -``` -sudo apt-get install cmake g++-multilib libsdl2-dev:i386 libsdl2-mixer-dev:i386 libsdl2-ttf-dev:i386 libsodium-dev libsodium-dev:i386 -``` - -Now run the following commands: -``` -mkdir build32 -cd build32 -linux32 cmake -DCMAKE_TOOLCHAIN_FILE=../CMake/32bit.cmake .. -linux32 make -j$(nproc) -``` - -### Building with MinGW -- Execute `make MINGW32=1` for **MinGW32** or `make` for **MinGW64**. Optionally add `debug` to build with debug features. - -To compile with MinGW64 on different platforms, refer to the respective documentation: [Linux](docs/INSTALL_linux.md) | [Windows](docs/INSTALL_windows.md) | [Mac](docs/INSTALL_mac.md). - -[Debug Build Features](docs/debug.md) -| [Compatibility Matrix](docs/compatibility_matrix.md) -| [Troubleshooting](docs/troubleshooting.md) - -# Installing -Once compiled, the Devilution binary will serve as a replacement for `Diablo.exe`. The following files from the original game patched to 1.09(b) need to be present: `DIABDAT.MPQ`, `DiabloUI.dll`, `SmackW32.dll`, `Standard.snp`, and `Storm.dll`. If `COPYPROT` was defined when compiling, the Diablo CD will also be required. - -Additionally, Strange Bytes' [DirectDraw patch](http://www.strangebytes.com/index.php/projects/1-diablo-1-windows-7-vista-patch) is recommended to help fix compatibility issues and run the game in windowed mode. - -# Multiplayer -TODO - -# Contributing -[Guidelines](docs/CONTRIBUTING.md) - -# Modding -Here are some screenshots of a few things I tinkered around with, to demonstrate the relative ease of improving the game: - -![Screenshot 1: Monster lifebar+items](https://s33.postimg.cc/6xnnhhlmn/diabuimon.png "Monster lifebar+items") - -![Screenshot 2: New trade screen](https://s22.postimg.cc/5i5k91vht/diabstore.png "New trade screen, items that couldn't spawn") - -# F.A.Q. -> Wow, does this mean I can download and play Diablo for free now? - -No, you'll need access to the data from the original game. Blizzard has discontinued Diablo, but there's plenty of used copies floating around. (I'm still using an original 1996-disc in 2018 without problems) -> Cool, so I fired your mod up, but there's no 1080p or new features? - -Devilution aims to keep the original code unaltered, for documentation purposes. -> So will you ever add cross-platform support or new features in the future? - -Yes! However, this will be a **_side project_** based on Devilution. I have yet to announce the project. -> When and what can I expect from the upcoming project? - -Honestly I have no idea. More than 1,200 hours went into creating Devilution, and I have other things going on right now. Maybe in 6-12 months? The goal is to create a native Linux port, convert to OpenGL, modernize the UI, etc. you get the drill. There has to be some surprises. ;) -> Ok, so I'm playing Devilution now and all the sudden it crashed. NOW WHAT?? - -Open an issue and provide as much information as possible (OS version, etc.) including any crash logs. -> I thought I'd fix the crash myself, but after looking at the code its a disaster. Do you speak v2-34-v8? - -That is the result of decompiled code. Whenever a program is compiled, much of the source is optimized and stripped away, so it's nearly impossible to decompile it back. Have patience. Everything will be cleaned up eventually. :) -> Will you be reverse engineering Diablo II next? Ooooh please! - -Absolutely not. Diablo II would require far more work and is still supported by Blizzard. Setting that aside, there are rumours that the game will be remastered which takes the point out of it. -> Are you interested in working for me? I have this game I want you to reverse... - -Sorry, but no. This project is time consuming enough as it is, and it's just a hobby. -> I think that's about all, but is Devilution even legal? - -That's a tricky question. Under the DMCA, reverse-engineering has exceptions for the purpose of documentation and interoperability. Devilution provides the necessary documentation needed to achieve the latter. However, it falls into an entirely grey area. The real question is whether or not Blizzard deems it necessary to take action. - -# Credits -- [sanctuary](https://github.com/sanctuary) - extensively documenting Diablo's game engine -- [BWAPI Team](https://github.com/bwapi) - providing library API to work with Storm -- [Ladislav Zezula](https://github.com/ladislav-zezula) - reversing PKWARE library, further documenting Storm -- [fearedbliss](https://github.com/fearedbliss) - being awe-inspiring -- Climax Studios & Sony - secretly helping with their undercover QA :P -- Blizzard North - wait, this was a typo! -- Depression - reason to waste four months of my life doing this ;) - -# Changelog -[From the beginning until release](docs/CHANGELOG.md) - -# Legal -This software is being released to the Public Domain. No assets of Diablo are being provided. You must own a copy of Diablo and have access to the assets beforehand in order to use this software. - -Battle.net(R) - Copyright (C) 1996 Blizzard Entertainment, Inc. All rights reserved. Battle.net and Blizzard Entertainment are trademarks or registered trademarks of Blizzard Entertainment, Inc. in the U.S. and/or other countries. - -Diablo(R) - Copyright (C) 1996 Blizzard Entertainment, Inc. All rights reserved. Diablo and Blizzard Entertainment are trademarks or registered trademarks of Blizzard Entertainment, Inc. in the U.S. and/or other countries. - -This software is in no way associated with or endorsed by Blizzard Entertainment(R). diff --git a/README.md b/README.md index 6ae5becfb..a051f6b64 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ # DevilutionX Diablo build for modern operating systems -**Note**, DevilutionX requires an original copy of `diabdat.mpq`. None of the Diablo 1 game assets are provided by this project. To get a legitimate copy of the game assets, please refer to the [GoG release of Diablo 1](https://www.gog.com/game/diablo). - # How To Play: - Copy diabdat.mpq from your CD, or GoG install folder, to the DevilutionX game directory ; Make sure it is all lowercase. - [Download DevilutionX](https://github.com/diasurgical/devilutionX/releases), or build from source @@ -44,18 +42,37 @@ The default build type is `Debug`. This can be changed with `-DCMAKE_BUILD_TYPE= Please keep in mind that this is still being worked on and is missing parts of UI and SoundEffects are not properly playing now. ### Building deviltuionX 32-bit on 64-bit Linux (multilib) platforms +Install the dependencies on your machine: ``` sudo apt-get install cmake g++-multilib libsdl2-dev:i386 libsdl2-mixer-dev:i386 libsdl2-ttf-dev:i386 libsodium-dev libsodium-dev:i386 ``` Now run the following commands: ``` -mkdir build32 -cd build32 +mkdir build +cd build linux32 cmake -DCMAKE_TOOLCHAIN_FILE=../CMake/32bit.cmake .. linux32 make -j$(nproc) ``` +### Cross-compiling for Windows via MinGW +Install the dependencies on your machine: + +Download and place the 32bit MinGW Development Libraries of [SDL2](https://www.libsdl.org/download-2.0.php), [SDL2_mixer](https://www.libsdl.org/projects/SDL_mixer/), [SDL2_ttf](https://www.libsdl.org/projects/SDL_ttf/) and [Libsodium](https://github.com/jedisct1/libsodium/releases) in `/user/i686-w64-mingw32`. + +``` +sudo apt-get install cmake gcc-mingw-w64-i686 g++-mingw-w64-i686 +``` +Use `-DCROSS_PREFIX=/path/to/prefix` if the `i686-w64-mingw32` directory is not in `/usr`. + +Now run the following commands: +``` +mkdir build +cd build +cmake -DASAN=OFF -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc.cmake .. +make -j$(nproc) +``` + ### Building devilutionX on macOS Note: macOS is 64-bit only so this is not fully playable at this point. @@ -64,13 +81,6 @@ Install the dependencies using [Homebrew](https://brew.sh/): brew install cmake sdl2_mixer sdl2_ttf libsodium pkg-config ``` -### Cross-compiling using MinGW -You `PATH` must contain `i686-w64-mingw32-gcc` and `i686-w64-mingw32-gcc`. Use the following cmake invocation: -``` -cmake -DCMAKE_TOOLCHAIN_FILE=../CMake/mingwcc.cmake .. -``` -Use `-DCROSS_PREFIX=/path/to/prefix` if the `i686-w64-mingw32` directory is not in `/usr`. - Now run the following commands: ``` mkdir build @@ -101,31 +111,13 @@ Here are some screenshots of a few things I tinkered around with, to demonstrate # F.A.Q. > Wow, does this mean I can download and play Diablo for free now? -No, you'll need access to the data from the original game. Blizzard has discontinued Diablo, but there's plenty of used copies floating around. (I'm still using an original 1996-disc in 2018 without problems) -> Cool, so I fired your mod up, but there's no 1080p or new features? - -Devilution aims to keep the original code unaltered, for documentation purposes. -> So will you ever add cross-platform support or new features in the future? - -Yes! However, this will be a **_side project_** based on Devilution. I have yet to announce the project. -> When and what can I expect from the upcoming project? - -Honestly I have no idea. More than 1,200 hours went into creating Devilution, and I have other things going on right now. Maybe in 6-12 months? The goal is to create a native Linux port, convert to OpenGL, modernize the UI, etc. you get the drill. There has to be some surprises. ;) -> Ok, so I'm playing Devilution now and all the sudden it crashed. NOW WHAT?? +No, you'll need access to the data from the original game. To get a legitimate copy of the game assets, please refer to the [GoG release of Diablo 1](https://www.gog.com/game/diablo). +> Ok, so I'm playing DevilutionX now and all the sudden it crashed. NOW WHAT?? Open an issue and provide as much information as possible (OS version, etc.) including any crash logs. > I thought I'd fix the crash myself, but after looking at the code its a disaster. Do you speak v2-34-v8? That is the result of decompiled code. Whenever a program is compiled, much of the source is optimized and stripped away, so it's nearly impossible to decompile it back. Have patience. Everything will be cleaned up eventually. :) -> Will you be reverse engineering Diablo II next? Ooooh please! - -Absolutely not. Diablo II would require far more work and is still supported by Blizzard. Setting that aside, there are rumours that the game will be remastered which takes the point out of it. -> Are you interested in working for me? I have this game I want you to reverse... - -Sorry, but no. This project is time consuming enough as it is, and it's just a hobby. -> I think that's about all, but is Devilution even legal? - -That's a tricky question. Under the DMCA, reverse-engineering has exceptions for the purpose of documentation and interoperability. Devilution provides the necessary documentation needed to achieve the latter. However, it falls into an entirely grey area. The real question is whether or not Blizzard deems it necessary to take action. # Credits - [sanctuary](https://github.com/sanctuary) - extensively documenting Diablo's game engine @@ -136,9 +128,6 @@ That's a tricky question. Under the DMCA, reverse-engineering has exceptions for - Blizzard North - wait, this was a typo! - Depression - reason to waste four months of my life doing this ;) -# Changelog -[From the beginning until release](docs/CHANGELOG.md) - # Legal This software is being released to the Public Domain. No assets of Diablo are being provided. You must own a copy of Diablo and have access to the assets beforehand in order to use this software. diff --git a/Source/effects.cpp b/Source/effects.cpp index 00517c143..6cd68febf 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1147,25 +1147,15 @@ void __cdecl sound_stop() void __cdecl sound_update() { - //int v0; // ebp - //unsigned int v1; // ecx - // int v2; // eax - unsigned int v3; // [esp-Ch] [ebp-Ch] - unsigned int v4; // [esp-8h] [ebp-8h] - //int v5; // [esp-4h] [ebp-4h] - - if (gbSndInited) { - snd_update(0); - //v5 = v0; - //v4 = v1; - //v3 = v1; - if (sfx_stream) { - //_LOBYTE(v2) = SFileDdaGetPos(sfx_stream, (int)&v4, (int)&v3); - if (SFileDdaGetPos(sfx_stream, &v4, &v3)) { - if (v4 >= v3) - sfx_stop(); - } - } + int current, end; + + if (!gbSndInited) { + return; + } + + snd_update(FALSE); + if (sfx_stream != NULL && SFileDdaGetPos(sfx_stream, ¤t, &end) && current >= end) { + sfx_stop(); } } // 415DBA: could not find valid save-restore pair for ebp diff --git a/SourceX/storm.cpp b/SourceX/storm.cpp index b1b38edb6..652e55f1c 100644 --- a/SourceX/storm.cpp +++ b/SourceX/storm.cpp @@ -31,12 +31,12 @@ radon::File ini(getIniPath()); // } Mix_Chunk *SFileChunk; -BOOL SFileDdaBeginEx(HANDLE directsound, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, +BOOL SFileDdaBeginEx(HANDLE hFile, DWORD flags, DWORD mask, unsigned __int32 lDistanceToMove, signed __int32 volume, signed int pan, int a7) { - DWORD bytestoread = SFileGetFileSize(directsound, 0); - char *SFXbuffer = (char*)malloc(bytestoread); - SFileReadFile(directsound, SFXbuffer, bytestoread, NULL, 0); + DWORD bytestoread = SFileGetFileSize(hFile, 0); + char *SFXbuffer = (char *)malloc(bytestoread); + SFileReadFile(hFile, SFXbuffer, bytestoread, NULL, 0); SDL_RWops *rw = SDL_RWFromConstMem(SFXbuffer, bytestoread); SFileChunk = Mix_LoadWAV_RW(rw, 1); @@ -54,12 +54,14 @@ BOOL SFileDdaDestroy() return true; } -BOOL SFileDdaEnd(HANDLE directsound) +BOOL SFileDdaEnd(HANDLE hFile) { Mix_HaltChannel(0); + + return true; } -BOOL SFileDdaGetPos(HANDLE directsound, int *current, int *end) +BOOL SFileDdaGetPos(HANDLE hFile, int *current, int *end) { *current = 0; *end = 1; @@ -73,11 +75,10 @@ BOOL SFileDdaGetPos(HANDLE directsound, int *current, int *end) BOOL SFileDdaInitialize(HANDLE directsound) { - DUMMY(); - return 0; + return true; } -BOOL SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volume) +BOOL SFileDdaSetVolume(HANDLE hFile, signed int bigvolume, signed int volume) { Mix_VolumeMusic(MIX_MAX_VOLUME - MIX_MAX_VOLUME * bigvolume / VOLUME_MIN); @@ -87,6 +88,7 @@ BOOL SFileDdaSetVolume(HANDLE directsound, signed int bigvolume, signed int volu BOOL SFileGetFileArchive(HANDLE hFile, HANDLE *archive) { UNIMPLEMENTED(); + return true; } // LONG SFileGetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)