Commit 0f7a8ddd authored by Steven Fuller's avatar Steven Fuller

Nothing major, but I didn't intend to have such a large delay between

updates...

gfxsave.c, vi_wdx.c: removed since they were no longer needed.

sd_oal.c: currently doesn't do anything (yet)

rest: cleanups and things of this nature
parent 2492518c
...@@ -3,13 +3,14 @@ CC = gcc ...@@ -3,13 +3,14 @@ CC = gcc
#CFLAGS = -g -O2 -Wall -pedantic #CFLAGS = -g -O2 -Wall -pedantic
#CFLAGS = -Wall -pedantic -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro #CFLAGS = -Wall -pedantic -O6 -fomit-frame-pointer -ffast-math -funroll-loops -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
CFLAGS = -g -Wall -pedantic CFLAGS = -g -Wall -pedantic
#CFLAGS = -Wall -pedantic -std=c99
#CFLAGS = -Os -Wall -peantic #CFLAGS = -Os -Wall -peantic
#CFLAGS = -Os -Wall -peantic -fomit-frame-pointer -ffast-math -mpentiumpro -mcpu=pentiumpro -march=pentiumpro #CFLAGS = -Os -Wall -peantic -fomit-frame-pointer -ffast-math -mpentiumpro -mcpu=pentiumpro -march=pentiumpro
OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \ OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
wl_act1.o wl_act2.o wl_act3.o wl_agent.o wl_game.o \ wl_act1.o wl_act2.o wl_act3.o wl_agent.o wl_game.o \
wl_inter.o wl_menu.o wl_play.o wl_state.o wl_text.o wl_main.o \ wl_inter.o wl_menu.o wl_play.o wl_state.o wl_text.o wl_main.o \
wl_debug.o gfxsave.o wl_debug.o
ROBJS = wl_draw.o ROBJS = wl_draw.o
SOBJS = $(OBJS) $(ROBJS) vi_svga.o SOBJS = $(OBJS) $(ROBJS) vi_svga.o
XOBJS = $(OBJS) $(ROBJS) vi_xlib.o XOBJS = $(OBJS) $(ROBJS) vi_xlib.o
...@@ -21,7 +22,9 @@ OBJS += sd_null.o ...@@ -21,7 +22,9 @@ OBJS += sd_null.o
#OBJS += sd_oss.o fmopl.o #OBJS += sd_oss.o fmopl.o
#CFLAGS += -D_REENTRANT #CFLAGS += -D_REENTRANT
#LFLAGS += -lpthread #LFLAGS += -lpthread
#OBJS += sd_oal.o
#CFLAGS += -D_REENTRANT
#LFLAGS += -lpthread #-lopenal
CFLAGS += `sdl-config --cflags` CFLAGS += `sdl-config --cflags`
......
...@@ -2,11 +2,11 @@ Just some random facts/thoughts/ideas/musings: ...@@ -2,11 +2,11 @@ Just some random facts/thoughts/ideas/musings:
* Wolfenstein 3D for: * Wolfenstein 3D for:
- PC (released, of course) [May 5, 1992] - PC (released, of course) [May 5, 1992]
- PC (Spear of Destiny) [Late (September?) 1992] - PC (Spear of Destiny) [September 18, 1992]
- SNES - SNES
- Macintosh - Macintosh
- Jaguar - Jaguar
- Apple IIGS - Apple IIGS [http://www.sheppyware.com/products/a2/wolf3d/]
- 3DO - 3DO
* Rumored/Never Released? * Rumored/Never Released?
...@@ -51,12 +51,21 @@ How to get Wolfenstein 3D: ...@@ -51,12 +51,21 @@ How to get Wolfenstein 3D:
http://www.3drealms.com/downloads.html http://www.3drealms.com/downloads.html
- Spear of Destiny Demo: - Spear of Destiny Demo:
ftp://ftp.gamers.org/pub/3daction/00archives/speardestiny/releases/soddemo2.zip ftp://ftp.gamers.org/pub/3daction/00archives/speardestiny/releases/soddemo2.zip
- Macintosh versions: TODO - Macintosh versions:
- Where to Buy: TODO - Search for the shareware version (First Encounter) on Macintosh Shareware
websites.
- The commercial Macintosh version (Second Encounter, not Third) is out of
print, but you may find someone selling it on websites such as
http://www.ebay.com.
- Where to Buy:
http://www.3drealms.com
http://www.idsoftware.com (look for how to order direct, etc)
http://www.activison.com
Wolfenstein 3D was originally planned to be a much more complex game. ... Wolfenstein 3D was originally planned to be a much more complex game. ...
... lots of unused code ... possibly from previous projects and incarnations ... lots of unused code ... possibly from previous projects and incarnations
of wolf3d. of Wolf3D. In fact, Commander Keen 4 shares a lot of code with Wolf3D!
Version 1.4 of Wolfenstein 3D (full) did not had a Read Me! option, but the Version 1.4 of Wolfenstein 3D (full) did not had a Read Me! option, but the
text still exists in the data files, but all the graphics are incorrect text still exists in the data files, but all the graphics are incorrect
......
#include "wl_def.h"
#define PACKED __attribute__((packed))
typedef struct pcx_header_type
{
char manufacturer;
char version;
char encoding;
char bits_per_pixel;
short int x, y;
short int width, height;
short int horz_res;
short int virt_res;
char ega_palette[48];
char reserved;
char num_color_planes;
short int byte_per_line;
short int palette_type;
short int hscreen_size;
short int vscreen_size;
char padding[54];
} PACKED pcx_header, *pcx_header_ptr;
void SavePCX256ToFile(unsigned char *buf, int width, int height, unsigned char *pal, char *name)
{
FILE *fp;
pcx_header ph;
unsigned char *dat, *ptr, *ptrd, ch;
int x, y, z;
ph.manufacturer = 10;
ph.version = 5;
ph.encoding = 1;
ph.bits_per_pixel = 8;
ph.x = ph.y = 0;
ph.width = width - 1;
ph.height = height - 1;
ph.horz_res = ph.virt_res = 0;
for (x = 0; x < sizeof(ph.ega_palette); x++)
ph.ega_palette[x] = 0;
ph.reserved = 0;
ph.num_color_planes = 1;
ph.byte_per_line = width;
ph.palette_type = 1;
ph.hscreen_size = width;
ph.vscreen_size = height;
for (x = 0; x < sizeof(ph.padding); x++)
ph.padding[x] = 0;
#if 0
dat = malloc(width * height * 2);
for (x = 0; x < width * height; x++) {
*(dat + x*2) = 0xC1;
*(dat + x*2+1) = *(buf + x);
}
z = width * height * 2;
#else
dat = malloc(width * height * 2);
ptr = buf; ptrd = dat;
x = 0; z = 0;
while (x < width * height) {
ch = *ptr;
ptr++;
x++;
y = 0xC1;
while((x < width * height) && (*ptr == ch) && (y < 0xFF)) {
x++; y++; ptr++;
}
*ptrd = y;
ptrd++;
*ptrd = ch;
ptrd++;
z += 2;
}
#endif
fp = fopen(name, "wb");
fwrite(&ph, sizeof(ph), 1, fp);
fwrite(dat, 1, z, fp);
fputc(12, fp);
fwrite(pal, 1, 768, fp);
fclose(fp);
free(dat);
}
void SavePCXRGBToFile(unsigned char *buf, int width, int height, char *name)
{
FILE *fp;
pcx_header ph;
unsigned char *dat;
int x, y, s;
memset(&ph, 0, sizeof(ph));
ph.manufacturer = 10;
ph.version = 5;
ph.encoding = 1;
ph.bits_per_pixel = 8;
ph.x = ph.y = 0;
ph.width = width - 1;
ph.height = height - 1;
ph.horz_res = ph.virt_res = 0;
ph.num_color_planes = 3;
ph.byte_per_line = width;
ph.palette_type = 1;
ph.hscreen_size = width;
ph.vscreen_size = height;
dat = malloc(width * height * 2 * 3);
for (y = 0; y < height; y++) {
for (s = 0; s < 3; s++) {
for (x = 0; x < width; x++) {
*(dat + (y*(width*3) + (width*s) + x)*2) = 0xC1;
*(dat + (y*(width*3) + (width*s) + x)*2+1) = *(buf + y*(width*3) + x*3 + s);
}
}
}
fp = fopen(name, "wb");
fwrite(&ph, sizeof(ph), 1, fp);
fwrite(dat, 1, width * height * 2 * 3, fp);
fclose(fp);
free(dat);
}
...@@ -218,12 +218,6 @@ typedef enum { ...@@ -218,12 +218,6 @@ typedef enum {
#define TITLESCREEN_LUMP_START 79 #define TITLESCREEN_LUMP_START 79
#define TITLESCREEN_LUMP_END 80 #define TITLESCREEN_LUMP_END 80
#define ENDGAME1_LUMP_START 81
#define ENDGAME1_LUMP_END 81
#define ENDGAME2_LUMP_START 82
#define ENDGAME2_LUMP_END 82
#define EASTEREGG_LUMP_START 93 #define EASTEREGG_LUMP_START 93
#define EASTEREGG_LUMP_END 94 #define EASTEREGG_LUMP_END 94
...@@ -242,6 +236,7 @@ typedef enum { ...@@ -242,6 +236,7 @@ typedef enum {
#define NUMPICS 147 #define NUMPICS 147
#define NUMTILE8 35 #define NUMTILE8 35
#define NUMEXTERNS 18 #define NUMEXTERNS 18
// //
// File offsets for data items // File offsets for data items
// //
......
...@@ -301,8 +301,6 @@ static void CAL_SetupGrFile() ...@@ -301,8 +301,6 @@ static void CAL_SetupGrFile()
{ {
char fname[13]; char fname[13];
int handle; int handle;
memptr compseg;
long chunkcomplen;
byte *grtemp; byte *grtemp;
int i; int i;
...@@ -350,24 +348,15 @@ static void CAL_SetupGrFile() ...@@ -350,24 +348,15 @@ static void CAL_SetupGrFile()
CA_CannotOpen(fname); CA_CannotOpen(fname);
/* load the pic headers into pictable */ /* load the pic headers into pictable */
chunkcomplen = grstarts[STRUCTPIC+1] - grstarts[STRUCTPIC]; CA_CacheGrChunk(STRUCTPIC);
ReadSeek(grhandle, grstarts[STRUCTPIC], SEEK_SET);
MM_GetPtr(&compseg, chunkcomplen);
ReadBytes(grhandle, compseg, chunkcomplen);
/* pictable is word width, height */
MM_GetPtr((memptr)&grtemp, NUMPICS*4);
CAL_HuffExpand((byte *)compseg+4, (byte *)grtemp, NUMPICS*4, grhuffman);
MM_FreePtr(&compseg);
grtemp = grsegs[STRUCTPIC];
for (i = 0; i < NUMPICS; i++) { for (i = 0; i < NUMPICS; i++) {
pictable[i].width = grtemp[i*4+0] | (grtemp[i*4+1] << 8); pictable[i].width = grtemp[i*4+0] | (grtemp[i*4+1] << 8);
pictable[i].height = grtemp[i*4+2] | (grtemp[i*4+3] << 8); pictable[i].height = grtemp[i*4+2] | (grtemp[i*4+3] << 8);
} }
MM_FreePtr((memptr)&grtemp); CA_UnCacheGrChunk(STRUCTPIC);
} }
/* ======================================================================== */ /* ======================================================================== */
......
...@@ -14,28 +14,6 @@ int xfrac, yfrac; ...@@ -14,28 +14,6 @@ int xfrac, yfrac;
/* ======================================================================== */ /* ======================================================================== */
/*
===================
=
= LoadLatchMem
=
===================
*/
void LoadLatchMem()
{
int i;
CA_CacheGrChunk(STARTTILE8);
for (i = LATCHPICS_LUMP_START; i <= LATCHPICS_LUMP_END; i++) {
CA_CacheGrChunk(i);
}
}
/* ======================================================================== */
/* /*
=================== ===================
= =
...@@ -61,7 +39,7 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width, unsigned height, un ...@@ -61,7 +39,7 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width, unsigned height, un
frame = 0; frame = 0;
set_TimeCount(0); set_TimeCount(0);
if (vwidth != 320) if (vwidth != 320) /* TODO */
return false; return false;
retr = -1; retr = -1;
...@@ -221,7 +199,7 @@ void VL_DeModeXize(byte *buf, int width, int height) ...@@ -221,7 +199,7 @@ void VL_DeModeXize(byte *buf, int width, int height)
return; return;
} }
MM_GetPtr((memptr)&mem, width *height); MM_GetPtr((memptr)&mem, width * height);
ptr = buf; ptr = buf;
......
...@@ -36,8 +36,6 @@ boolean FizzleFade(unsigned xoffset, unsigned yoffset, unsigned width,unsigned h ...@@ -36,8 +36,6 @@ boolean FizzleFade(unsigned xoffset, unsigned yoffset, unsigned width,unsigned h
void VL_FadeOut(int start, int end, int red, int green, int blue, int steps); void VL_FadeOut(int start, int end, int red, int green, int blue, int steps);
void VL_FadeIn(int start, int end, const byte *palette, int steps); void VL_FadeIn(int start, int end, const byte *palette, int steps);
void LoadLatchMem();
void VL_CacheScreen(int chunk); void VL_CacheScreen(int chunk);
void VW_Bar(int x, int y, int width, int height, int color); void VW_Bar(int x, int y, int width, int height, int color);
......
...@@ -201,7 +201,7 @@ void DisplayTextSplash(byte *text, int l) ...@@ -201,7 +201,7 @@ void DisplayTextSplash(byte *text, int l)
uint16_t SwapInt16L(uint16_t i) uint16_t SwapInt16L(uint16_t i)
{ {
#if __BYTE_ORDER == __BIG_ENDIAN #if BYTE_ORDER == BIG_ENDIAN
return ((uint16_t)i >> 8) | ((uint16_t)i << 8); return ((uint16_t)i >> 8) | ((uint16_t)i << 8);
#else #else
return i; return i;
...@@ -210,7 +210,7 @@ uint16_t SwapInt16L(uint16_t i) ...@@ -210,7 +210,7 @@ uint16_t SwapInt16L(uint16_t i)
uint32_t SwapInt32L(uint32_t i) uint32_t SwapInt32L(uint32_t i)
{ {
#if __BYTE_ORDER == __BIG_ENDIAN #if BYTE_ORDER == BIG_ENDIAN
return ((uint32_t)(i & 0xFF000000) >> 24) | return ((uint32_t)(i & 0xFF000000) >> 24) |
((uint32_t)(i & 0x00FF0000) >> 8) | ((uint32_t)(i & 0x00FF0000) >> 8) |
((uint32_t)(i & 0x0000FF00) << 8) | ((uint32_t)(i & 0x0000FF00) << 8) |
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#define PACKED __attribute__((packed)) #define PACKED __attribute__((packed))
#define TickBase 70 // 70Hz per tick #define TickBase 70 /* 70Hz per tick */
typedef enum { typedef enum {
sdm_Off, sdm_Off,
...@@ -13,7 +13,7 @@ typedef enum { ...@@ -13,7 +13,7 @@ typedef enum {
smm_Off,smm_AdLib smm_Off,smm_AdLib
} SMMode; } SMMode;
typedef enum { typedef enum {
sds_Off,sds_PC,sds_SoundSource,sds_SoundBlaster sds_Off,sds_PC,sds_SoundBlaster
} SDSMode; } SDSMode;
typedef struct { typedef struct {
longword length; longword length;
...@@ -40,19 +40,18 @@ typedef struct { ...@@ -40,19 +40,18 @@ typedef struct {
word length, values[1]; word length, values[1];
} PACKED MusicGroup; } PACKED MusicGroup;
// Global variables extern boolean AdLibPresent, SoundBlasterPresent;
extern boolean AdLibPresent, SoundSourcePresent, SoundBlasterPresent;
extern SDMode SoundMode; extern SDMode SoundMode;
extern SDSMode DigiMode; extern SDSMode DigiMode;
extern SMMode MusicMode; extern SMMode MusicMode;
extern int DigiMap[]; extern int DigiMap[];
// Function prototypes extern void SD_Startup();
extern void SD_Startup(), SD_Shutdown(); extern void SD_Shutdown();
extern boolean SD_PlaySound(soundnames sound); extern boolean SD_PlaySound(soundnames sound);
extern void SD_StopSound(), extern void SD_StopSound(),
SD_WaitSoundDone(), SD_WaitSoundDone(),
SD_StartMusic(MusicGroup *music), SD_StartMusic(MusicGroup *music),
SD_MusicOn(), SD_MusicOn(),
...@@ -67,7 +66,7 @@ extern word SD_SoundPlaying(); ...@@ -67,7 +66,7 @@ extern word SD_SoundPlaying();
extern void SD_SetDigiDevice(SDSMode); extern void SD_SetDigiDevice(SDSMode);
extern void SD_Poll(); extern void SD_Poll();
void PlaySoundLocGlobal(word s, fixed gx, fixed gy); void PlaySoundLocGlobal(word s, int id, fixed gx, fixed gy);
void UpdateSoundLoc(fixed x, fixed y, int angle); void UpdateSoundLoc(fixed x, fixed y, int angle);
#endif #endif
#include "wl_def.h" #include "wl_def.h"
boolean SoundSourcePresent, AdLibPresent, SoundBlasterPresent; boolean AdLibPresent, SoundBlasterPresent;
SDMode SoundMode, MusicMode; SDMode SoundMode, MusicMode;
SDSMode DigiMode; SDSMode DigiMode;
...@@ -157,7 +157,7 @@ boolean SD_MusicPlaying() ...@@ -157,7 +157,7 @@ boolean SD_MusicPlaying()
return false; return false;
} }
void PlaySoundLocGlobal(word s,fixed gx,fixed gy) void PlaySoundLocGlobal(word s, int id, fixed gx,fixed gy)
{ {
SD_PlaySound(s); SD_PlaySound(s);
} }
......
#include "wl_def.h"
boolean AdLibPresent, SoundBlasterPresent;
SDMode SoundMode, MusicMode;
SDSMode DigiMode;
int DigiMap[LASTSOUND];
static boolean SD_Started;
static boolean sqActive;
#error "please ignore me for now, thanks"
void SD_Poll()
{
}
void SD_SetDigiDevice(SDSMode mode)
{
}
///////////////////////////////////////////////////////////////////////////
//
// SD_SetSoundMode() - Sets which sound hardware to use for sound effects
//
///////////////////////////////////////////////////////////////////////////
boolean SD_SetSoundMode(SDMode mode)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_SetMusicMode() - sets the device to use for background music
//
///////////////////////////////////////////////////////////////////////////
boolean SD_SetMusicMode(SMMode mode)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_Startup() - starts up the Sound Mgr
//
///////////////////////////////////////////////////////////////////////////
void SD_Startup()
{
if (SD_Started)
return;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_Shutdown() - shuts down the Sound Mgr
//
///////////////////////////////////////////////////////////////////////////
void SD_Shutdown()
{
if (!SD_Started)
return;
SD_Started = false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_PlaySound() - plays the specified sound on the appropriate hardware
//
///////////////////////////////////////////////////////////////////////////
boolean SD_PlaySound(soundnames sound)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_SoundPlaying() - returns the sound number that's playing, or 0 if
// no sound is playing
//
///////////////////////////////////////////////////////////////////////////
word SD_SoundPlaying()
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_StopSound() - if a sound is playing, stops it
//
///////////////////////////////////////////////////////////////////////////
void SD_StopSound()
{
}
///////////////////////////////////////////////////////////////////////////
//
// SD_WaitSoundDone() - waits until the current sound is done playing
//
///////////////////////////////////////////////////////////////////////////
void SD_WaitSoundDone()
{
/* TODO: should also "work" when sound is disabled... */
while (SD_SoundPlaying())
;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_MusicOn() - turns on the sequencer
//
///////////////////////////////////////////////////////////////////////////
void SD_MusicOn()
{
sqActive = true;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_MusicOff() - turns off the sequencer and any playing notes
//
///////////////////////////////////////////////////////////////////////////
void SD_MusicOff()
{
sqActive = false;
}
///////////////////////////////////////////////////////////////////////////
//
// SD_StartMusic() - starts playing the music pointed to
//
///////////////////////////////////////////////////////////////////////////
void SD_StartMusic(MusicGroup *music)
{
SD_MusicOff();
}
///////////////////////////////////////////////////////////////////////////
//
// SD_FadeOutMusic() - starts fading out the music. Call SD_MusicPlaying()
// to see if the fadeout is complete
//
///////////////////////////////////////////////////////////////////////////
void SD_FadeOutMusic()
{
}
///////////////////////////////////////////////////////////////////////////
//
// SD_MusicPlaying() - returns true if music is currently playing, false if
// not
//
///////////////////////////////////////////////////////////////////////////
boolean SD_MusicPlaying()
{
return false;
}
void PlaySoundLocGlobal(word s, int id, fixed gx, fixed gy)
{
SD_PlaySound(s);
}
void UpdateSoundLoc(fixed x, fixed y, int angle)
{
}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "fmopl.h" #include "fmopl.h"
boolean SoundSourcePresent, AdLibPresent, SoundBlasterPresent; boolean AdLibPresent, SoundBlasterPresent;
SDMode SoundMode, MusicMode; SDMode SoundMode, MusicMode;
SDSMode DigiMode; SDSMode DigiMode;
...@@ -522,7 +522,7 @@ static void SetSoundLoc(fixed gx, fixed gy) ...@@ -522,7 +522,7 @@ static void SetSoundLoc(fixed gx, fixed gy)
========================== ==========================
*/ */
void PlaySoundLocGlobal(word s, fixed gx, fixed gy) void PlaySoundLocGlobal(word s, int id, fixed gx, fixed gy)
{ {
SetSoundLoc(gx, gy); SetSoundLoc(gx, gy);
......
#include "wl_def.h"
#include <windows.h>
#include <ddraw.h>
#include <dinput.h>
#include <direct.h>
#error "This code is out of date/broken"
byte *gfxbuf = NULL;
HWND win;
IDirectInput *lpDI;
IDirectInputDevice *lpDIKeyboard;
int hCrt;
FILE *hf;
IDirectDraw *lpDD;
IDirectDrawSurface *lpDDSPrimary;
IDirectDrawSurface *lpDDSBuffer;
IDirectDrawClipper *lpDDC;
LPDDSCAPS lpDDSCaps;
DDSURFACEDESC ddsd;
byte mypal[768];
void WolfDirectDrawPaint();
HRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam);
void CheckEvents();
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
static char szAppName[] = "Wolf3D";
HWND hwnd;
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wndclass);
hwnd = CreateWindow(szAppName, GAMENAME, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 320, 200, NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
if (DirectDrawCreate(NULL, &lpDD, NULL) != DD_OK) {
MessageBox(hwnd, "ugh", "ugh", MB_OK);
return 0;
}
if (IDirectDraw_SetCooperativeLevel(lpDD, hwnd, DDSCL_NORMAL) != DD_OK) {
MessageBox(hwnd, "hi", "hi", MB_OK);
}
// if (IDirectDraw_SetDisplayMode(lpDD, 320, 200, 8) != DD_OK) {
// MessageBox(hwnd, "hi2", "hi", MB_OK);
// }
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
if (IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL) != DD_OK) {
MessageBox(hwnd, "hi3", "hi", MB_OK);
}
if (IDirectDraw_CreateClipper(lpDD, 0, &lpDDC, NULL) != DD_OK) {
MessageBox(hwnd, "hi4", "hi", MB_OK);
}
if (IDirectDrawClipper_SetHWnd(lpDDC, 0, hwnd) != DD_OK) {
MessageBox(hwnd, "hi5", "hi", MB_OK);
}
if (IDirectDrawSurface_SetClipper(lpDDSPrimary, lpDDC) != DD_OK) {
MessageBox(hwnd, "hi6", "hi", MB_OK);
}
ddsd.dwFlags = DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
ddsd.dwWidth = 320;
ddsd.dwHeight = 200;
if (IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSBuffer, NULL) != DD_OK) {
MessageBox(hwnd, "hi7", "hi", MB_OK);
}
if(DirectInputCreate(hInstance, DIRECTINPUT_VERSION, &lpDI, NULL) != DI_OK) {
MessageBox(hwnd, "hi8", "hi", MB_OK);
}
if (IDirectInput_CreateDevice(lpDI, &GUID_SysKeyboard, &lpDIKeyboard, NULL) != DD_OK) {
MessageBox(hwnd, "hi9", "hi", MB_OK);
}
IDirectInputDevice_SetDataFormat(lpDIKeyboard, &c_dfDIKeyboard);
if (IDirectInputDevice_SetCooperativeLevel(lpDIKeyboard, hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND) != DD_OK) {
MessageBox(hwnd, "hi10", "hi", MB_OK);
}
win = hwnd;
return WolfMain(0, NULL); /* TODO ... need to parse commandline */
}
/*
==========================
=
= Quit
=
==========================
*/
void Quit(char *error)
{
/* TODO: blah blah blah */
memptr screen = NULL;
if (!error || !*error) {
CA_CacheGrChunk(ORDERSCREEN);
screen = grsegs[ORDERSCREEN];
WriteConfig();
} else if (error) {
CA_CacheGrChunk(ERRORSCREEN);
screen = grsegs[ERRORSCREEN];
}
ShutdownId();
if (screen) {
printf("TODO: spiffy ansi screen goes here..\n");
}
if (error && *error) {
MessageBox(win, error, "Error!", MB_ICONEXCLAMATION | MB_OK);
}
SendMessage(win, WM_CLOSE, 0, 0);
for (;;) CheckEvents(); /* We sent our death wish, now we wait */
}
void WolfDirectDrawPaint()
{
int x;
unsigned short int *ptr;
HWND hwnd;
if (!lpDD)
return;
if (!gfxbuf)
return;
if (IDirectDrawSurface_Lock(lpDDSBuffer, NULL,&ddsd,DDLOCK_SURFACEMEMORYPTR,NULL) != DD_OK) {
MessageBox(win, "eh?", "hrm", MB_OK);
return;
}
IDirectDrawClipper_GetHWnd(lpDDC, &hwnd);
ptr = ddsd.lpSurface;
for (x = 0; x < 64000; x++) {
*ptr = (mypal[gfxbuf[x]*3+0]>>3) << 13 |
(mypal[gfxbuf[x]*3+1]>>3) << 8 |
(mypal[gfxbuf[x]*3+2]>>3) << 2;
ptr++;
}
//memcpy(ddsd.lpSurface, gfxbuf, 64000);
IDirectDrawSurface_Unlock(lpDDSBuffer, ddsd.lpSurface);
if (IDirectDrawSurface_IsLost(lpDDSPrimary)) {
printf("eh2?\n");
exit(1);
}
/*
{
RECT srcrect={0,0,320, 200};
RECT dstrect;
GetWindowRect(hwnd,&dstrect);
dstrect.top+=42;
dstrect.bottom-=4;
dstrect.left+=4;
dstrect.right-=4;
IDirectDrawSurface_Blt(lpDDSPrimary, &dstrect, lpDDSBuffer, &srcrect, 0, NULL);
}
*/
{
/* TODO: need to get and save window border sizes (setting default size needs this too) */
RECT srcrect={0,0,320, 200};
RECT dstrect;
GetWindowRect(hwnd,&dstrect);
IDirectDrawSurface_Blt(lpDDSPrimary, &dstrect, lpDDSBuffer, &srcrect, 0, NULL);
}
}
byte keys[256];
byte oldk[256];
void keyboard_handler(int, int);
int DIKToScancode(int i)
{
switch(i) {
case DIK_LEFT:
return sc_LeftArrow;
case DIK_RIGHT:
return sc_RightArrow;
case DIK_UP:
return sc_UpArrow;
case DIK_DOWN:
return sc_DownArrow;
default:
return i;
}
}
void WolfDirectInputUpdateKeys()
{
int i;
if (IDirectInputDevice_GetDeviceState(lpDIKeyboard, 256, keys) != DI_OK) {
if (IDirectInputDevice_Acquire(lpDIKeyboard) != DI_OK)
return;
if (IDirectInputDevice_GetDeviceState(lpDIKeyboard, 256, keys) != DI_OK)
return;
}
for (i = 0; i < 256; i++)
if (keys[i] != oldk[i])
keyboard_handler(DIKToScancode(i), keys[i] ? 1 : 0);
memcpy(oldk, keys, sizeof(oldk));
}
void CheckEvents()
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT)
break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
WolfDirectInputUpdateKeys();
if (msg.message == WM_QUIT)
exit(msg.wParam);
}
HRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
switch (iMsg) {
case WM_CREATE:
#ifdef _DEBUG
AllocConsole();
hCrt = _open_osfhandle((long) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
hf = _fdopen( hCrt, "w" );
*stdout = *hf;
setvbuf(stdout, NULL, _IONBF, 0 );
*stderr = *hf;
setvbuf(stderr, NULL, _IONBF, 0);
#endif
/* TODO */
_chdir("C:\\wolfsrc\\src\\test\\");
/* - oh well, if path is not found, CWD will still be the same (for end user use) */
return 0;
case WM_COMMAND:
break;
case WM_ERASEBKGND:
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
WolfDirectDrawPaint(hwnd);
EndPaint(hwnd, &ps);
break;
case WM_CLOSE:
IDirectDrawSurface_Release(lpDDSBuffer);
IDirectDrawClipper_Release(lpDDC);
IDirectDrawSurface_Release(lpDDSPrimary);
IDirectDraw_Release(lpDD);
#ifdef _DEBUG
FreeConsole();
fclose(hf);
close(hCrt);
#endif
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
void VL_WaitVBL(int vbls)
{
}
void VW_UpdateScreen()
{
/* VL_WaitVBL(1); */
WolfDirectDrawPaint();
}
/*
=======================
=
= VL_Startup
=
=======================
*/
void VL_Startup (void)
{
if (gfxbuf == NULL)
gfxbuf = malloc(320 * 200 * 1);
}
/*
=======================
=
= VL_Shutdown
=
=======================
*/
void VL_Shutdown (void)
{
if (gfxbuf != NULL) {
free(gfxbuf);
gfxbuf = NULL;
}
}
//===========================================================================
/*
=================
=
= VL_SetPalette
=
=================
*/
void VL_SetPalette(const byte *palette)
{
memcpy(mypal, palette, 768);
VW_UpdateScreen();
}
/*
=================
=
= VL_GetPalette
=
=================
*/
void VL_GetPalette(byte *palette)
{
memcpy(palette, mypal, 768);
}
void VL_DirectPlot(int x1, int y1, int x2, int y2)
{
}
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
//
// configuration variables
//
boolean MousePresent;
boolean JoysPresent[MaxJoys];
// Global variables
boolean Keyboard[NumCodes];
boolean Paused;
char LastASCII;
ScanCode LastScan;
KeyboardDef KbdDefs = {sc_Control, sc_Alt, sc_Home, sc_UpArrow, sc_PgUp, sc_LeftArrow, sc_RightArrow, sc_End, sc_DownArrow, sc_PgDn};
ControlType Controls[MaxPlayers];
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
static byte ASCIINames[] = // Unshifted ASCII for scan codes
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0 ,27 ,'1','2','3','4','5','6','7','8','9','0','-','=',8 ,9 , // 0
'q','w','e','r','t','y','u','i','o','p','[',']',13 ,0 ,'a','s', // 1
'd','f','g','h','j','k','l',';',39 ,'`',0 ,92 ,'z','x','c','v', // 2
'b','n','m',',','.','/',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3
0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4
'2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
},
ShiftNames[] = // Shifted ASCII for scan codes
{
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
0 ,27 ,'!','@','#','$','%','^','&','*','(',')','_','+',8 ,9 , // 0
'Q','W','E','R','T','Y','U','I','O','P','{','}',13 ,0 ,'A','S', // 1
'D','F','G','H','J','K','L',':',34 ,'~',0 ,'|','Z','X','C','V', // 2
'B','N','M','<','>','?',0 ,'*',0 ,' ',0 ,0 ,0 ,0 ,0 ,0 , // 3
0 ,0 ,0 ,0 ,0 ,0 ,0 ,'7','8','9','-','4','5','6','+','1', // 4
'2','3','0',127,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 5
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 6
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 // 7
};
static boolean IN_Started;
static boolean CapsLock;
static ScanCode CurCode,LastCode;
static Direction DirTable[] = // Quick lookup for total direction
{
dir_NorthWest, dir_North, dir_NorthEast,
dir_West, dir_None, dir_East,
dir_SouthWest, dir_South, dir_SouthEast
};
// Internal routines
void keyboard_handler(int code, int press)
{
byte k, c = 0;
k = code;
if ( k == 0xE1 ) // Handle Pause key
Paused = true;
else
{
if (press == 0)
{
Keyboard[k] = false;
}
else // Make code
{
LastCode = CurCode;
CurCode = LastScan = k;
Keyboard[k] = true;
if (k == sc_CapsLock)
{
CapsLock ^= true;
}
if (Keyboard[sc_LShift] || Keyboard[sc_RShift]) // If shifted
{
c = ShiftNames[k];
if ((c >= 'A') && (c <= 'Z') && CapsLock)
c += 'a' - 'A';
}
else
{
c = ASCIINames[k];
if ((c >= 'a') && (c <= 'z') && CapsLock)
c -= 'a' - 'A';
}
if (c)
LastASCII = c;
}
}
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseDelta() - Gets the amount that the mouse has moved from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static void INL_GetMouseDelta(int *x,int *y)
{
*x = 0;
*y = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetMouseButtons() - Gets the status of the mouse buttons from the
// mouse driver
//
///////////////////////////////////////////////////////////////////////////
static word INL_GetMouseButtons(void)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_GetJoyAbs() - Reads the absolute position of the specified joystick
//
///////////////////////////////////////////////////////////////////////////
void IN_GetJoyAbs(word joy,word *xp,word *yp)
{
*xp = 0;
*yp = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyDelta() - Returns the relative movement of the specified
// joystick (from +/-127)
//
///////////////////////////////////////////////////////////////////////////
void INL_GetJoyDelta(word joy,int *dx,int *dy)
{
*dx = 0;
*dy = 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_GetJoyButtons() - Returns the button status of the specified
// joystick
//
///////////////////////////////////////////////////////////////////////////
static word INL_GetJoyButtons(word joy)
{
return 0;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartKbd() - Sets up my keyboard stuff for use
//
///////////////////////////////////////////////////////////////////////////
static void INL_StartKbd(void)
{
IN_ClearKeysDown();
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutKbd() - Restores keyboard control to the BIOS
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutKbd(void)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartMouse() - Detects and sets up the mouse
//
///////////////////////////////////////////////////////////////////////////
static boolean INL_StartMouse(void)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutMouse() - Cleans up after the mouse
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutMouse(void)
{
}
///////////////////////////////////////////////////////////////////////////
//
// IN_SetupJoy() - Sets up thresholding values and calls INL_SetJoyScale()
// to set up scaling values
//
///////////////////////////////////////////////////////////////////////////
void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy)
{
}
///////////////////////////////////////////////////////////////////////////
//
// INL_StartJoy() - Detects & auto-configures the specified joystick
// The auto-config assumes the joystick is centered
//
///////////////////////////////////////////////////////////////////////////
static boolean INL_StartJoy(word joy)
{
return false;
}
///////////////////////////////////////////////////////////////////////////
//
// INL_ShutJoy() - Cleans up the joystick stuff
//
///////////////////////////////////////////////////////////////////////////
static void INL_ShutJoy(word joy)
{
JoysPresent[joy] = false;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_Startup() - Starts up the Input Mgr
//
///////////////////////////////////////////////////////////////////////////
void IN_Startup(void)
{
boolean checkjoys,checkmouse;
word i;
if (IN_Started)
return;
checkjoys = true;
checkmouse = true;
if (MS_CheckParm("nojoy"))
checkjoys = false;
if (MS_CheckParm("nomouse"))
checkmouse = false;
INL_StartKbd();
MousePresent = checkmouse ? INL_StartMouse() : false;
for (i = 0;i < MaxJoys;i++)
JoysPresent[i] = checkjoys ? INL_StartJoy(i) : false;
IN_Started = true;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_Shutdown() - Shuts down the Input Mgr
//
///////////////////////////////////////////////////////////////////////////
void IN_Shutdown(void)
{
word i;
if (!IN_Started)
return;
INL_ShutMouse();
for (i = 0;i < MaxJoys;i++)
INL_ShutJoy(i);
INL_ShutKbd();
IN_Started = false;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_ClearKeysDown() - Clears the keyboard array
//
///////////////////////////////////////////////////////////////////////////
void IN_ClearKeysDown(void)
{
LastScan = sc_None;
LastASCII = key_None;
memset(Keyboard, 0, sizeof(Keyboard));
}
///////////////////////////////////////////////////////////////////////////
//
// IN_ReadControl() - Reads the device associated with the specified
// player and fills in the control info struct
//
///////////////////////////////////////////////////////////////////////////
void IN_ReadControl(int player,ControlInfo *info)
{
boolean realdelta = false;
word buttons;
int dx,dy;
Motion mx,my;
ControlType type;
KeyboardDef *def;
dx = dy = 0;
mx = my = motion_None;
buttons = 0;
IN_CheckAck();
switch (type = Controls[player])
{
case ctrl_Keyboard:
def = &KbdDefs;
if (Keyboard[def->upleft])
mx = motion_Left,my = motion_Up;
else if (Keyboard[def->upright])
mx = motion_Right,my = motion_Up;
else if (Keyboard[def->downleft])
mx = motion_Left,my = motion_Down;
else if (Keyboard[def->downright])
mx = motion_Right,my = motion_Down;
if (Keyboard[def->up])
my = motion_Up;
else if (Keyboard[def->down])
my = motion_Down;
if (Keyboard[def->left])
mx = motion_Left;
else if (Keyboard[def->right])
mx = motion_Right;
if (Keyboard[def->button0])
buttons += 1 << 0;
if (Keyboard[def->button1])
buttons += 1 << 1;
realdelta = false;
break;
case ctrl_Joystick1:
case ctrl_Joystick2:
INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy);
buttons = INL_GetJoyButtons(type - ctrl_Joystick);
realdelta = true;
break;
case ctrl_Mouse:
INL_GetMouseDelta(&dx,&dy);
buttons = INL_GetMouseButtons();
realdelta = true;
break;
}
if (realdelta)
{
mx = (dx < 0)? motion_Left : ((dx > 0)? motion_Right : motion_None);
my = (dy < 0)? motion_Up : ((dy > 0)? motion_Down : motion_None);
}
else
{
dx = mx * 127;
dy = my * 127;
}
info->x = dx;
info->xaxis = mx;
info->y = dy;
info->yaxis = my;
info->button0 = buttons & (1 << 0);
info->button1 = buttons & (1 << 1);
info->button2 = buttons & (1 << 2);
info->button3 = buttons & (1 << 3);
info->dir = DirTable[((my + 1) * 3) + (mx + 1)];
}
///////////////////////////////////////////////////////////////////////////
//
// IN_Ack() - waits for a button or key press. If a button is down, upon
// calling, it must be released for it to be recognized
//
///////////////////////////////////////////////////////////////////////////
boolean btnstate[8];
void IN_StartAck(void)
{
unsigned i,buttons;
//
// get initial state of everything
//
IN_ClearKeysDown();
memset (btnstate,0,sizeof(btnstate));
buttons = IN_JoyButtons () << 4;
if (MousePresent)
buttons |= IN_MouseButtons ();
for (i=0;i<8;i++,buttons>>=1)
if (buttons&1)
btnstate[i] = true;
}
boolean IN_CheckAck (void)
{
unsigned i,buttons;
CheckEvents(); /* get all events */
if (LastScan)
return true;
buttons = IN_JoyButtons () << 4;
if (MousePresent)
buttons |= IN_MouseButtons ();
for (i=0;i<8;i++,buttons>>=1)
if ( buttons&1 )
{
if (!btnstate[i])
return true;
}
else
btnstate[i]=false;
return false;
}
void IN_Ack (void)
{
IN_StartAck ();
// return; /* TODO: fix when keyboard implemented */
while (!IN_CheckAck ()) ;
}
///////////////////////////////////////////////////////////////////////////
//
// IN_UserInput() - Waits for the specified delay time (in ticks) or the
// user pressing a key or a mouse button. If the clear flag is set, it
// then either clears the key or waits for the user to let the mouse
// button up.
//
///////////////////////////////////////////////////////////////////////////
boolean IN_UserInput(longword delay)
{
longword lasttime;
lasttime = get_TimeCount();
IN_StartAck ();
do {
if (IN_CheckAck())
return true;
} while ( (get_TimeCount() - lasttime) < delay );
return false;
}
//===========================================================================
/*
===================
=
= IN_MouseButtons
=
===================
*/
byte IN_MouseButtons (void)
{
return 0;
}
/*
===================
=
= IN_JoyButtons
=
===================
*/
byte IN_JoyButtons (void)
{
return 0;
}
...@@ -435,7 +435,7 @@ void GiveExtraMan() ...@@ -435,7 +435,7 @@ void GiveExtraMan()
void DrawScore() void DrawScore()
{ {
LatchNumber (6,16,6,gamestate.score); LatchNumber(6, 16, 6, gamestate.score);
} }
/* /*
...@@ -472,7 +472,6 @@ void DrawWeapon() ...@@ -472,7 +472,6 @@ void DrawWeapon()
StatusDrawPic(32,8,KNIFEPIC+gamestate.weapon); StatusDrawPic(32,8,KNIFEPIC+gamestate.weapon);
} }
/* /*
================== ==================
= =
...@@ -494,8 +493,6 @@ void DrawKeys() ...@@ -494,8 +493,6 @@ void DrawKeys()
StatusDrawPic(30,20,NOKEYPIC); StatusDrawPic(30,20,NOKEYPIC);
} }
/* /*
================== ==================
= =
...@@ -515,7 +512,6 @@ void GiveWeapon(int weapon) ...@@ -515,7 +512,6 @@ void GiveWeapon(int weapon)
DrawWeapon(); DrawWeapon();
} }
//=========================================================================== //===========================================================================
/* /*
...@@ -531,7 +527,6 @@ void DrawAmmo() ...@@ -531,7 +527,6 @@ void DrawAmmo()
LatchNumber(27,16,2,gamestate.ammo); LatchNumber(27,16,2,gamestate.ammo);
} }
/* /*
=============== ===============
= =
...@@ -572,8 +567,6 @@ void GiveKey(int key) ...@@ -572,8 +567,6 @@ void GiveKey(int key)
DrawKeys(); DrawKeys();
} }
/* /*
============================================================================= =============================================================================
...@@ -582,7 +575,6 @@ void GiveKey(int key) ...@@ -582,7 +575,6 @@ void GiveKey(int key)
============================================================================= =============================================================================
*/ */
/* /*
=================== ===================
= =
...@@ -713,7 +705,6 @@ void GetBonus (statobj_t *check) ...@@ -713,7 +705,6 @@ void GetBonus (statobj_t *check)
check->shapenum = -1; // remove from list check->shapenum = -1; // remove from list
} }
/* /*
=================== ===================
= =
...@@ -781,7 +772,6 @@ boolean TryMove(objtype *ob) ...@@ -781,7 +772,6 @@ boolean TryMove(objtype *ob)
return true; return true;
} }
/* /*
=================== ===================
= =
...@@ -842,7 +832,6 @@ void VictoryTile() ...@@ -842,7 +832,6 @@ void VictoryTile()
gamestate.victoryflag = true; gamestate.victoryflag = true;
} }
/* /*
=================== ===================
= =
......
...@@ -677,7 +677,6 @@ typedef enum { ...@@ -677,7 +677,6 @@ typedef enum {
extern char str[80], str2[20]; extern char str[80], str2[20];
extern fixed focallength; extern fixed focallength;
extern unsigned viewangles;
extern int viewwidth, viewheight; extern int viewwidth, viewheight;
extern int viewwidthwin, viewheightwin; extern int viewwidthwin, viewheightwin;
...@@ -743,8 +742,8 @@ void DrawPlayBorder(); ...@@ -743,8 +742,8 @@ void DrawPlayBorder();
void DrawPlayBorderSides(); void DrawPlayBorderSides();
void DrawStatusBar(); void DrawStatusBar();
#define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(((long)(tx) << TILESHIFT) + (1L << (TILESHIFT - 1))),(((long)ty << TILESHIFT) + (1L << (TILESHIFT - 1)))) #define PlaySoundLocTile(s,tx,ty) PlaySoundLocGlobal(s,(int)((tx<<6)|(ty)),(((long)(tx) << TILESHIFT) + (1L << (TILESHIFT - 1))),(((long)ty << TILESHIFT) + (1L << (TILESHIFT - 1))))
#define PlaySoundLocActor(s,ob) PlaySoundLocGlobal(s,(ob)->x,(ob)->y) #define PlaySoundLocActor(s,ob) PlaySoundLocGlobal(s,(int)ob,(ob)->x,(ob)->y)
/* /*
============================================================================= =============================================================================
...@@ -860,7 +859,6 @@ extern long heightnumerator; ...@@ -860,7 +859,6 @@ extern long heightnumerator;
// refresh variables // refresh variables
// //
extern fixed viewx,viewy; // the focal point extern fixed viewx,viewy; // the focal point
extern int viewangle;
extern fixed viewsin,viewcos; extern fixed viewsin,viewcos;
extern int horizwall[],vertwall[]; extern int horizwall[],vertwall[];
......
#include "wl_def.h" #include "wl_def.h"
/* C AsmRefresh() originally from David Haslam -- dch@sirius.demon.co.uk */ /* C AsmRefresh() and related code
originally from David Haslam -- dch@sirius.demon.co.uk */
// the door is the last picture before the sprites /* the door is the last picture before the sprites */
#define DOORWALL (PMSpriteStart-8) #define DOORWALL (PMSpriteStart-8)
#define ACTORSIZE 0x4000 #define ACTORSIZE 0x4000
static unsigned wallheight[MAXVIEWWIDTH]; static unsigned wallheight[MAXVIEWWIDTH];
// /* refresh variables */
// refresh variables fixed viewx,viewy; /* the focal point */
//
fixed viewx,viewy; // the focal point
int viewangle;
// /* ray casting variables */
// ray casting variables
//
static int focaltx, focalty; static int focaltx, focalty;
static int midangle;
static unsigned xpartial, ypartial; static unsigned xpartial, ypartial;
static unsigned xpartialup, xpartialdown, ypartialup, ypartialdown; static int viewangle;
static unsigned tilehit; static unsigned tilehit;
...@@ -257,7 +252,7 @@ static void DrawScaleds() ...@@ -257,7 +252,7 @@ static void DrawScaleds()
// //
// place static objects // place static objects
// //
for (statptr = &statobjlist[0] ; statptr !=laststatobj ; statptr++) for (statptr = &statobjlist[0]; statptr != laststatobj; statptr++)
{ {
if ((visptr->shapenum = statptr->shapenum) == -1) if ((visptr->shapenum = statptr->shapenum) == -1)
continue; // object has been deleted continue; // object has been deleted
...@@ -268,7 +263,7 @@ static void DrawScaleds() ...@@ -268,7 +263,7 @@ static void DrawScaleds()
if (TransformTile(statptr->tilex, statptr->tiley if (TransformTile(statptr->tilex, statptr->tiley
,&visptr->viewx,&visptr->viewheight) && statptr->flags & FL_BONUS) ,&visptr->viewx,&visptr->viewheight) && statptr->flags & FL_BONUS)
{ {
GetBonus (statptr); GetBonus(statptr);
continue; continue;
} }
...@@ -406,7 +401,7 @@ static void WallRefresh() ...@@ -406,7 +401,7 @@ static void WallRefresh()
set up variables for this view set up variables for this view
*/ */
viewangle = player->angle; viewangle = player->angle;
midangle = viewangle*(FINEANGLES/ANGLES);
viewsin = sintable[viewangle]; viewsin = sintable[viewangle];
viewcos = costable[viewangle]; viewcos = costable[viewangle];
viewx = player->x - FixedByFrac(focallength,viewcos); viewx = player->x - FixedByFrac(focallength,viewcos);
...@@ -415,11 +410,6 @@ static void WallRefresh() ...@@ -415,11 +410,6 @@ static void WallRefresh()
focaltx = viewx>>TILESHIFT; focaltx = viewx>>TILESHIFT;
focalty = viewy>>TILESHIFT; focalty = viewy>>TILESHIFT;
xpartialdown = viewx&(TILEGLOBAL-1);
xpartialup = TILEGLOBAL-xpartialdown;
ypartialdown = viewy&(TILEGLOBAL-1);
ypartialup = TILEGLOBAL-ypartialdown;
AsmRefresh(); AsmRefresh();
} }
...@@ -1068,14 +1058,21 @@ static int samey(int intercept, int tile) ...@@ -1068,14 +1058,21 @@ static int samey(int intercept, int tile)
else else
return 1; return 1;
} }
} }
static void AsmRefresh() static void AsmRefresh()
{ {
fixed doorxhit, dooryhit; fixed doorxhit, dooryhit;
long xtemp, ytemp; long xtemp, ytemp;
unsigned xpartialup, xpartialdown, ypartialup, ypartialdown;
int angle; /* ray angle through postx */ int angle; /* ray angle through postx */
int midangle;
midangle = viewangle*(FINEANGLES/ANGLES);
xpartialdown = viewx&(TILEGLOBAL-1);
xpartialup = TILEGLOBAL-xpartialdown;
ypartialdown = viewy&(TILEGLOBAL-1);
ypartialup = TILEGLOBAL-ypartialdown;
for (postx = 0; postx < viewwidth; postx++) { for (postx = 0; postx < viewwidth; postx++) {
angle = midangle + pixelangle[postx]; angle = midangle + pixelangle[postx];
......
...@@ -1288,13 +1288,13 @@ void InitGame() ...@@ -1288,13 +1288,13 @@ void InitGame()
ReadConfig(); ReadConfig();
// /* load in and lock down some basic chunks */
// load in and lock down some basic chunks
//
CA_CacheGrChunk(STARTFONT); CA_CacheGrChunk(STARTFONT);
CA_CacheGrChunk(STARTTILE8);
LoadLatchMem(); for (i = LATCHPICS_LUMP_START; i <= LATCHPICS_LUMP_END; i++)
CA_CacheGrChunk(i);
BuildTables(); BuildTables();
SetupWalls(); SetupWalls();
......
...@@ -931,7 +931,7 @@ void DrawNewGameDiff(int w) ...@@ -931,7 +931,7 @@ void DrawNewGameDiff(int w)
// HANDLE SOUND MENU // HANDLE SOUND MENU
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void CP_Sound(void) void CP_Sound()
{ {
int which; int which;
...@@ -995,12 +995,6 @@ void CP_Sound(void) ...@@ -995,12 +995,6 @@ void CP_Sound(void)
} }
break; break;
case 6: case 6:
if (DigiMode!=sds_SoundSource)
{
SD_SetDigiDevice(sds_SoundSource);
DrawSoundMenu();
ShootSnd();
}
break; break;
case 7: case 7:
if (DigiMode!=sds_SoundBlaster) if (DigiMode!=sds_SoundBlaster)
...@@ -1069,13 +1063,12 @@ void DrawSoundMenu(void) ...@@ -1069,13 +1063,12 @@ void DrawSoundMenu(void)
SndMenu[2].active=SndMenu[10].active=SndMenu[11].active=0; SndMenu[2].active=SndMenu[10].active=SndMenu[11].active=0;
} }
if (!SoundSourcePresent) SndMenu[6].active = 0;
SndMenu[6].active=0;
if (!SoundBlasterPresent) if (!SoundBlasterPresent)
SndMenu[7].active=0; SndMenu[7].active=0;
if (!SoundSourcePresent && !SoundBlasterPresent) if (!SoundBlasterPresent)
SndMenu[5].active=0; SndMenu[5].active=0;
DrawMenu(&SndItems,&SndMenu[0]); DrawMenu(&SndItems,&SndMenu[0]);
...@@ -1103,7 +1096,7 @@ void DrawSoundMenu(void) ...@@ -1103,7 +1096,7 @@ void DrawSoundMenu(void)
// DIGITIZED SOUND // DIGITIZED SOUND
// //
case 5: if (DigiMode==sds_Off) on=1; break; case 5: if (DigiMode==sds_Off) on=1; break;
case 6: if (DigiMode==sds_SoundSource) on=1; break; case 6: break;
case 7: if (DigiMode==sds_SoundBlaster) on=1; break; case 7: if (DigiMode==sds_SoundBlaster) on=1; break;
// //
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment