Skip to content

Commit

Permalink
Merge pull request #38 from diasurgical/amiga
Browse files Browse the repository at this point in the history
Remove more diff
  • Loading branch information
MBeijer committed Sep 27, 2019
2 parents 655ade9 + cca17df commit a9aacbf
Show file tree
Hide file tree
Showing 16 changed files with 2,146 additions and 2,190 deletions.
140 changes: 60 additions & 80 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ if(AMIGA)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNONET")
set(ASAN "Enable address sanitizer" OFF)
set(USE_SDL1 "Use SDL1.2 instead of SDL2" ON)
find_package(Freetype REQUIRED)
find_package(PNG REQUIRED)
endif()

if(DIST)
Expand All @@ -70,13 +72,9 @@ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)

find_package(Threads REQUIRED)
find_package(Freetype REQUIRED)
find_package(PNG REQUIRED)


if(NONET)
else()
find_package(sodium REQUIRED)
if(NOT NONET)
find_package(sodium REQUIRED)
endif()

if(USE_SDL1)
Expand All @@ -93,7 +91,6 @@ else()
find_package(SDL2_mixer REQUIRED)
endif()


add_library(smacker STATIC
3rdParty/libsmacker/smk_bitstream.c
3rdParty/libsmacker/smk_hufftree.c
Expand Down Expand Up @@ -180,7 +177,6 @@ add_library(devilution STATIC
Source/scrollrt.cpp
Source/setmaps.cpp
Source/sha.cpp

Source/spells.cpp
Source/stores.cpp
Source/sync.cpp
Expand Down Expand Up @@ -211,7 +207,6 @@ add_executable(devilutionx MACOSX_BUNDLE
SourceX/dvlnet/packet.cpp
SourceX/dvlnet/base.cpp
SourceX/dvlnet/frame_queue.cpp

SourceX/DiabloUI/credits.cpp
SourceX/DiabloUI/diabloui.cpp
SourceX/DiabloUI/dialogs.cpp
Expand All @@ -229,58 +224,45 @@ add_executable(devilutionx MACOSX_BUNDLE
configure_file(SourceS/config.h.in config.h @ONLY)
target_include_directories(devilution PUBLIC Source SourceS ${CMAKE_CURRENT_BINARY_DIR})

if(NONET)
list(
APPEND
SOURCES
)
else()
list(
APPEND
SOURCES
if(NOT NONET)
list(APPEND SOURCES
SourceX/dvlnet/tcp_client.cpp
SourceX/dvlnet/tcp_server.cpp
SourceX/dvlnet/udp_p2p.cpp
)
SourceX/dvlnet/udp_p2p.cpp)
endif()

target_include_directories(devilution PUBLIC Source SourceS)
if(USE_SDL1)
target_include_directories(devilution PRIVATE
${SDL_INCLUDE_DIR}
${SDL_INCLUDE_DIRS})
target_include_directories(devilutionx PRIVATE
SourceX
3rdParty/asio/include
3rdParty/Radon/Radon/include
3rdParty/libsmacker
target_include_directories(devilution PRIVATE
${SDL_INCLUDE_DIR}
${SDL_INCLUDE_DIRS}
${SDL_TTF_INCLUDE_DIRS}
${SDL_MIXER_INCLUDE_DIRS}
${SDL_INCLUDE_DIRS}/..
${SDL_INCLUDE_DIR}/..
${SDL_TTF_INCLUDE_DIRS}/..
${SDL_MIXER_INCLUDE_DIRS}/..
)
${SDL_INCLUDE_DIRS})

if(USE_SDL1)
target_include_directories(devilutionx PRIVATE
SourceX
3rdParty/asio/include
3rdParty/Radon/Radon/include
3rdParty/libsmacker
${SDL_INCLUDE_DIR}
${SDL_INCLUDE_DIRS}
${SDL_TTF_INCLUDE_DIRS}
${SDL_MIXER_INCLUDE_DIRS}
${SDL_INCLUDE_DIRS}/..
${SDL_INCLUDE_DIR}/..
${SDL_TTF_INCLUDE_DIRS}/..
${SDL_MIXER_INCLUDE_DIRS}/..)
else()
target_include_directories(devilution PRIVATE
${SDL2_INCLUDE_DIR}
${SDL2_INCLUDE_DIRS})
target_include_directories(devilutionx PRIVATE
SourceX
3rdParty/asio/include
3rdParty/Radon/Radon/include
3rdParty/libsmacker
${SDL2_INCLUDE_DIR}
${SDL2_INCLUDE_DIRS}
${SDL2_TTF_INCLUDE_DIRS}
${SDL2_MIXER_INCLUDE_DIRS}
${SDL2_INCLUDE_DIRS}/..
${SDL2_INCLUDE_DIR}/..
${SDL2_TTF_INCLUDE_DIRS}/..
${SDL2_MIXER_INCLUDE_DIRS}/..
)
target_include_directories(devilutionx PRIVATE
SourceX
3rdParty/asio/include
3rdParty/Radon/Radon/include
3rdParty/libsmacker
${SDL2_INCLUDE_DIR}
${SDL2_INCLUDE_DIRS}
${SDL2_TTF_INCLUDE_DIRS}
${SDL2_MIXER_INCLUDE_DIRS}
${SDL2_INCLUDE_DIRS}/..
${SDL2_INCLUDE_DIR}/..
${SDL2_TTF_INCLUDE_DIRS}/..
${SDL2_MIXER_INCLUDE_DIRS}/..)
set(SDL_INCLUDE_DIR ${SDL2_INCLUDE_DIR})
endif()

Expand All @@ -289,42 +271,40 @@ message("SDL_mixer include dir: " ${SDL_MIXER_INCLUDE_DIRS})
message("SDL_ttf include dir: " ${SDL_TTF_INCLUDE_DIRS})

target_link_libraries(devilution PUBLIC Threads::Threads)

target_link_libraries(devilutionx PRIVATE
devilution
PKWare
StormLib
smacker
Radon
)
Radon)

if(USE_SDL1)
target_link_libraries(devilutionx PRIVATE
${SDL_TTF_LIBRARY}
${SDL_MIXER_LIBRARY}
${SDL_MIXER_LIBRARIES}
${SDL_LIBRARY}
${FREETYPE_LIBRARIES}
${PNG_LIBRARIES}
${LIBMAD_LIBRARIES})
${SDL_TTF_LIBRARY}
${SDL_MIXER_LIBRARY}
${SDL_MIXER_LIBRARIES}
${SDL_LIBRARY}
${FREETYPE_LIBRARIES}
${PNG_LIBRARIES}
${LIBMAD_LIBRARIES})
if(WARPOS)
target_link_libraries(devilutionx PRIVATE
-lmikmod
-lvorbisfile
-lvorbisenc
-lvorbis
-logg
-lFLAC
-lbz2)
target_link_libraries(devilutionx PRIVATE
-lmikmod
-lvorbisfile
-lvorbisenc
-lvorbis
-logg
-lFLAC
-lbz2)
endif()
else()
target_link_libraries(devilutionx PRIVATE
SDL2::SDL2main
${SDL2_ttf_LIBRARY}
${SDL2_mixer_LIBRARY}
${FREETYPE_LIBRARIES}
${PNG_LIBRARIES}
sodium)
SDL2::SDL2main
${SDL2_ttf_LIBRARY}
${SDL2_mixer_LIBRARY}
${FREETYPE_LIBRARIES}
${PNG_LIBRARIES}
sodium)

message("SDL library: " ${SDL2_LIBRARY} ${SDL2_LIBRARIES})
message("SDL_mixer library : " ${SDL2_mixer_LIBRARY} )
Expand Down Expand Up @@ -400,7 +380,7 @@ endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_definitions(-D_GNU_SOURCE )
add_definitions(-D_GNU_SOURCE)
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down
4 changes: 2 additions & 2 deletions Source/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,15 +738,15 @@ void Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int n
dst = pDecodeTo;
tbl = &pLightTbl[light_table_index * 256];
w = nWidth;
shift = (BYTE)dst & 1;
shift = (BYTE)(size_t)dst & 1;

for (; src != &pRLEBytes[nDataSize]; dst -= BUFFER_WIDTH + w, shift = (shift + 1) & 1) {
for (i = w; i;) {
width = *src++;
if (!(width & 0x80)) {
i -= width;
if (dst < gpBufEnd) {
if (((BYTE)dst & 1) == shift) {
if (((BYTE)(size_t)dst & 1) == shift) {
if (!(width & 1)) {
goto L_ODD;
} else {
Expand Down
5 changes: 1 addition & 4 deletions Source/gendung.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void MakeSpeedCels()
if (mt) {
level_frame_count[BSWAP_INT32_UNSIGNED(pMap->mt[i] & 0xFFF)]++;
level_frame_types[BSWAP_INT32_UNSIGNED(pMap->mt[i] & 0xFFF)] = mt & 0x7000;
}
}
}
}
}
Expand All @@ -179,15 +179,13 @@ void MakeSpeedCels()
blood_flag = TRUE;
if (level_frame_count[i] != 0) {
if (level_frame_types[i] != 0x1000) {

src = &pDungeonCels[BSWAP_INT32_UNSIGNED(pFrameTable[i])];
for (j = level_frame_sizes[i]; j; j--) {
pix = *src++;
if (pix && pix < 32)
blood_flag = FALSE;
}
} else {

src = &pDungeonCels[BSWAP_INT32_UNSIGNED(pFrameTable[i])];
for (k = 32; k; k--) {
for (l = 32; l;) {
Expand Down Expand Up @@ -350,7 +348,6 @@ int IsometricCoord(int x, int y)
void SetSpeedCels()
{
int x, y;
MICROS *pMap;

for (x = 0; x < MAXDUNX; x++) {
for (y = 0; y < MAXDUNY; y++) {
Expand Down
12 changes: 3 additions & 9 deletions Source/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ void init_create_window(int nCmdShow)
void init_archives()
{
HANDLE fh;
#ifdef COPYPROT
int result;
#endif

memset(&fileinfo, 0, sizeof(fileinfo));
fileinfo.size = sizeof(fileinfo);
fileinfo.versionstring = gszVersionNumber;
Expand All @@ -91,7 +89,7 @@ void init_archives()
#ifdef SPAWN
diabdat_mpq = init_test_access(diabdat_mpq_path, "spawn.mpq", "DiabloSpawn", MPQ_FLAG_READ_ONLY, FS_PC);
#else
diabdat_mpq = init_test_access(diabdat_mpq_path, "diabdat.mpq", "DiabloCD", 2000, FS_PC);
diabdat_mpq = init_test_access(diabdat_mpq_path, "diabdat.mpq", "DiabloCD", MPQ_FLAG_READ_ONLY, FS_PC);
#endif
if (!WOpenFile("ui_art\\title.pcx", &fh, TRUE))
#ifdef SPAWN
Expand All @@ -118,11 +116,7 @@ HANDLE init_test_access(char *mpq_path, char *mpq_name, char *reg_loc, int flags

for (int i = 0; i < 2; i++) {
snprintf(mpq_path, MAX_PATH, "%s%s", Buffer[i], mpq_name);
#ifdef __BIG_ENDIAN__
if (SFileOpenArchive(mpq_path, flags, FS_PC, &archive)) {
#else
if (SFileOpenArchive(mpq_path, 0, flags, &archive)) {
#endif
if (SFileOpenArchive(mpq_path, 0, MPQ_FLAG_READ_ONLY, &archive)) {
SFileSetBasePath(Buffer[i]);
return archive;
}
Expand Down
3 changes: 1 addition & 2 deletions Source/objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,6 @@ void objects_set_door_piece(int x, int y)

v1 = *((WORD *)pLevelPieces + 10 * pn + 8);
v2 = *((WORD *)pLevelPieces + 10 * pn + 9);

dpiece_defs_map_1[IsometricCoord(x, y)].mt[0] = BSWAP_INT16_UNSIGNED(v1);
dpiece_defs_map_1[IsometricCoord(x, y)].mt[1] = BSWAP_INT16_UNSIGNED(v2);
}
Expand All @@ -1850,8 +1849,8 @@ void ObjSetMini(int x, int y, int v)
{
int xx, yy;
long v1, v2, v3, v4;

WORD *MegaTiles;

MegaTiles = (WORD *)&pMegaTiles[((WORD)v - 1) * 8];

v1 = BSWAP_INT16_UNSIGNED(*(MegaTiles)) + 1;
Expand Down
2 changes: 0 additions & 2 deletions Source/pfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,7 @@ BOOL __stdcall pfile_ui_save_create(_uiheroinfo *heroinfo)
mpqapi_remove_hash_entries(pfile_get_file_name);
strncpy(hero_names[save_num], heroinfo->name, PLR_NAME_LEN);
hero_names[save_num][PLR_NAME_LEN - 1] = '\0';

cl = pfile_get_player_class(heroinfo->heroclass);

CreatePlayer(0, cl);
strncpy(plr[0]._pName, heroinfo->name, PLR_NAME_LEN);
plr[0]._pName[PLR_NAME_LEN - 1] = '\0';
Expand Down
20 changes: 4 additions & 16 deletions Source/town.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,27 +1035,17 @@ void T_FillSector(BYTE *P3Tiles, BYTE *pSector, int xi, int yi, int w, int h)
{
int i, j, xx, yy;
long v1, v2, v3, v4, ii;
int nMap;

ii = 4;
yy = yi;
for (j = 0; j < h; j++) {
xx = xi;
for (i = 0; i < w; i++) {
WORD *Map;
Map = ((WORD *)&pSector[ii]);



nMap = BSWAP_INT16_UNSIGNED(*Map);


Map = (WORD *)&pSector[ii];
int nMap = BSWAP_INT16_UNSIGNED(*Map);
if (nMap) {

WORD *Sector;

Sector = (((WORD *)&P3Tiles[(nMap - 1) * 8]));

WORD *Sector = (((WORD *)&P3Tiles[(nMap - 1) * 8]));
v1 = BSWAP_INT16_UNSIGNED(*(Sector)) + 1;
v2 = BSWAP_INT16_UNSIGNED(*(Sector + 1)) + 1;
v3 = BSWAP_INT16_UNSIGNED(*(Sector + 2)) + 1;
Expand All @@ -1082,9 +1072,7 @@ void T_FillTile(BYTE *P3Tiles, int xx, int yy, int t)
{
long v1, v2, v3, v4;

WORD *Tiles;
Tiles = ((WORD *)&P3Tiles[(t - 1) * 8]);

WORD *Tiles = ((WORD *)&P3Tiles[(t - 1) * 8]);
v1 = BSWAP_INT16_UNSIGNED(*(Tiles)) + 1;
v2 = BSWAP_INT16_UNSIGNED(*(Tiles + 1)) + 1;
v3 = BSWAP_INT16_UNSIGNED(*(Tiles + 2)) + 1;
Expand Down

0 comments on commit a9aacbf

Please sign in to comment.