Skip to content

Commit

Permalink
Add support for OS/2 by Andreas Peters - Merge pull request #128 from…
Browse files Browse the repository at this point in the history
… andreaspeters/os2_support
  • Loading branch information
davidjoffe authored Nov 19, 2022
2 parents 4fce475 + a83db49 commit c885e8c
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
# Temporary local Visual Studio settings and cached stuff eg precompiled headers that should not be committed
/src/vcDave/.vs/

# OS2 (dj2022-11 Merging Andreas Peters OS2 commits)
/**/*.o
/*.exe

# Linux/Mac etc. build products:
davegnukem
src/*.o
src/sdl/*.o
75 changes: 75 additions & 0 deletions Makefile.os2
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
# David Joffe
# Copyright 1998-2002 David Joffe
# 1998/12
# makefile for Dave Gnukem
#

CPP = g++
CC = gcc


#CFLAGS = -O -Wall $(INCLUDEDIRS)

# Un/recomment as needed for removing sound support, optimizations etc
# If you don't -DDATA_DIR to a valid dir, then data files will be assumed
# to be in current directory
#CFLAGS = -Wall -I/@unixroot/usr/include -DHAVE_SOUND -DDEBUG -O -m486
CFLAGS = -DUSESDL $(INCLUDEDIRS) -I/@unixroot/usr/include
#Release version:
#CFLAGS = -O -Wall -I/@unixroot/usr/include -DHAVE_SOUND $(INCLUDEDIRS)

LIBS = -lSDL_mixer -lsdl -Zexe -lpthread
BIN = davegnukem.exe
BINED = ed

OBJFILES = src/main.o src/graph.o src/game.o src/menu.o\
src/block.o src/credits.o src/instructions.o src/djstring.o \
src/djimage.o src/djlog.o src/inventory.o src/mission.o\
src/hiscores.o src/mixins.o src/thing.o src/hero.o \
src/thing_monsters.o src/gameending.o \
src/level.o src/settings.o src/keys.o \
src/djtypes.o src/bullet.o \
src/ed.o src/ed_DrawBoxContents.o src/ed_common.o src/ed_lvled.o \
src/ed_macros.o src/ed_spred.o \
src/sdl/djgraph.o src/sdl/djinput.o src/sdl/djsound.o \
src/sdl/djtime.o \
src/sys_error.o src/sys_log.o src/m_misc.cpp

OBJFILESED = src/graph.o src/ed_standalone_original.o \
src/block.o src/djstring.o \
src/djimage.o src/djlog.o src/mission.o\
src/mixins.o src/level.o \
src/djtypes.o \
src/sdl/djgraph.o src/sdl/djinput.o src/sdl/djsound.o \
src/sdl/djtime.o \
src/sys_error.o src/sys_log.o src/m_misc.o

default: djg

djg: $(OBJFILES)
$(CPP) -o $(BIN) $(OBJFILES) $(LIBS)

ed: $(OBJFILESED)
$(CPP) -o $(BINED) $(OBJFILESED) $(LIBS)

clean:
rm -f $(BIN) $(BINED) *~ core \#*
find src -name '*.o' | xargs rm -f

dist:
rm -f core *~ \#*
find src -name '*.o' | xargs rm -f

linecount:
cat src/*.cpp src/*.h src/linux/*.cpp | wc -l

fixme:
ls src/*.c src/*.cpp src/linux/*.cpp src/*.h | xargs grep -i fixme

%.o: %.c
$(CPP) $(CFLAGS) -c $< -o $@

%.o: %.cpp
$(CPP) $(CFLAGS) -c $< -o $@

4 changes: 4 additions & 0 deletions src/djgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ Copyright (C) 1998-2022 David Joffe
#ifndef _DJGRAPH_H_
#define _DJGRAPH_H_

#ifdef __OS2__
#include <SDL/SDL.h>
#else
#include "SDL.h"
#endif

#include "djimage.h"
#include "djtypes.h"
Expand Down
4 changes: 4 additions & 0 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ using namespace std;
#include "instructions.h"//Slightly don't like this dependency. For ShowInstructions() from in-game menu. [dj2017-08]

#ifndef NOSOUND
#ifdef __OS2__
#include <SDL/SDL_mixer.h>
#else
#include <SDL_mixer.h>//For background music stuff
#endif
Mix_Music* g_pGameMusic=NULL;
#endif

Expand Down
4 changes: 4 additions & 0 deletions src/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Copyright (C) 1998-2019 David Joffe
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef __OS2__
#include <SDL/SDL.h>
#else
#include "SDL.h"
#endif
#include "sys_log.h"//djLog helpers
#include "djstring.h"//djStrPrintf

Expand Down
4 changes: 4 additions & 0 deletions src/keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ Created: 09/2001

#include "keys.h"
#include "settings.h"
#ifdef __OS2__
#include <SDL/SDL.h>
#else
#include "SDL.h"
#endif
#include <vector>
using namespace std;

Expand Down
29 changes: 29 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,19 @@ Copyright (C) 1995-2022 David Joffe
#include <sys/stat.h>//For djFolderExists stuff
#endif

// dj2022-11 Merging Andreas Peters OS2 commits https://github.com/davidjoffe/dave_gnukem/pull/128
#ifdef __OS2__
#define INCL_DOS
#include <os2.h>
#endif

#ifndef NOSOUND
#ifdef __OS2__
#include <SDL/SDL_mixer.h>
#else
#include <SDL_mixer.h>//For background music stuff
#endif
#endif

#include <map>
#include <string>
Expand All @@ -69,6 +79,19 @@ void CheckHighScores( int score ); // check if high score table is beaten,
void InitMainMenu();
void KillMainMenu();

#ifdef __OS2__
void MorphToPM()
{
PPIB pib;
PTIB tib;

DosGetInfoBlocks(&tib, &pib);

// Change flag from VIO to PM:
if (pib->pib_ultype==2) pib->pib_ultype = 3;
}
#endif

/*--------------------------------------------------------------------------*/
// Main menu [NB, warning, the handling code uses indexes :/ .. so if you add/remove items, must update there too - dj2016-10]
struct SMenuItem mainMenuItems[] =
Expand Down Expand Up @@ -101,6 +124,12 @@ CMenu mainMenu ( "main.cpp:mainMenu" );
// This is the 'main' function. The big cheese.
int main ( int argc, char** argv )
{


#ifdef __OS2__
MorphToPM();
#endif

// Check commandline args
bool bfullscreen = false;
bool b640 = false;
Expand Down
4 changes: 4 additions & 0 deletions src/sdl/djgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ Copyright (C) 1997-2022 David Joffe

#include "../djgraph.h"
#include "../sys_log.h"
#ifdef __OS2__
#include <SDL/SDL.h>
#else
#include "SDL.h"
#endif
#include "../config.h"//[For CFG_APPLICATION_RENDER_RES_W etc. dj2019-06 slightly ugly dependency direction, conceptually, but not the biggest thing in the world to worry about now, maybe later.]

#include <string.h>
Expand Down
9 changes: 9 additions & 0 deletions src/sdl/djsound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ Copyright (C) 1999-2018 David Joffe and Kent Mein
#include "../djsound.h"
#include "../djstring.h"
#include "../djlog.h"
#ifdef __OS2__
#include <SDL/SDL_audio.h>
#include <SDL/SDL_error.h>
#else
#include <SDL_audio.h>
#include <SDL_error.h>
#endif
#ifndef NOSOUND
#ifdef __OS2__
#include <SDL/SDL_mixer.h>
#else
#include <SDL_mixer.h>
#endif
#endif

#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <stdlib.h>//Fixing malloc.h 'not found' error compiling on Mac [dj2016-10]
Expand Down
4 changes: 4 additions & 0 deletions src/sdl/djtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ Copyright (C) 1999-2018 David Joffe
*/

#include "../djtime.h"
#ifdef __OS2__
#include <SDL/SDL.h>
#else
#include "SDL.h"
#endif
#ifdef WIN32
#include <windows.h>
#include <mmsystem.h>
Expand Down

0 comments on commit c885e8c

Please sign in to comment.