Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wolf3d
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
wolf3d
Commits
9fe175e9
Commit
9fe175e9
authored
Dec 20, 2000
by
Steven Fuller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vi_sdl.c, Makefile: Added vi_sdl.c (SDL target) from Dan Olson
parent
250feebc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
905 additions
and
27 deletions
+905
-27
Makefile
src/Makefile
+9
-1
TODO
src/TODO
+1
-0
vi_sdl.c
src/vi_sdl.c
+884
-0
wl_inter.c
src/wl_inter.c
+0
-2
wl_main.c
src/wl_main.c
+11
-24
No files found.
src/Makefile
View file @
9fe175e9
...
...
@@ -13,6 +13,7 @@ OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
ROBJS
=
wl_draw.o
SOBJS
=
$(OBJS)
$(ROBJS)
vi_svga.o
XOBJS
=
$(OBJS)
$(ROBJS)
vi_xlib.o
DOBJS
=
$(OBJS)
$(ROBJS)
vi_sdl.o
LFLAGS
=
-lm
...
...
@@ -22,17 +23,21 @@ OBJS += sd_null.o
#LFLAGS += -lpthread
CFLAGS
+=
`
sdl-config
--cflags
`
SLFLAGS
=
$(LFLAGS)
-lvga
XLFLAGS
=
$(LFLAGS)
-L
/usr/X11R6/lib
-lX11
-lXext
-lXxf86vm
-lXxf86dga
DLFLAGS
=
$(LFLAGS)
`
sdl-config
--libs
`
-L
/usr/X11R6/lib
-lX11
-lXext
NASM
=
nasm
.SUFFIXES
:
.asm
all
:
swolf3d xwolf3d
all
:
swolf3d xwolf3d
sdlwolf3d
$(SOBJS)
:
version.h id_heads.h wl_def.h
$(XOBJS)
:
version.h id_heads.h wl_def.h
$(DOBJS)
:
version.h id_heads.h wl_def.h
.asm.o
:
$(NASM)
-f
elf
-o
$@
$<
...
...
@@ -43,6 +48,9 @@ swolf3d: $(SOBJS)
xwolf3d
:
$(XOBJS)
gcc
-o
xwolf3d
$(XOBJS)
$(XLFLAGS)
sdlwolf3d
:
$(DOBJS)
gcc
-o
sdlwolf3d
$(DOBJS)
$(DLFLAGS)
clean
:
rm
-rf
swolf3d xwolf3d
*
.o
...
...
src/TODO
View file @
9fe175e9
...
...
@@ -65,6 +65,7 @@ SD_StartMusic((MusicGroup *)audiosegs[STARTMUSIC + chunk]);
=>
SD_StartMusic(chunk);
------------------------------------------------------------------------------
* remove farmapylookup?
* would be nice if Quit() used vsnprintf, etc
* actor walking through door is drawn in front of door: near end of E1M1 for
example
...
...
src/vi_sdl.c
0 → 100644
View file @
9fe175e9
/* id_vl.c */
#include "wl_def.h"
#include "SDL.h"
byte
*
gfxbuf
=
NULL
;
SDL_Surface
*
surface
;
/*
==========================
=
= Quit
=
==========================
*/
int
main
(
int
argc
,
char
*
argv
[])
{
return
WolfMain
(
argc
,
argv
);
}
void
DisplayTextSplash
(
byte
*
text
);
void
Quit
(
char
*
error
)
{
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
"
);
/* doesn't look too good on console at the moment ...*/
//DisplayTextSplash(screen);
}
if
(
error
&&
*
error
)
{
fprintf
(
stderr
,
"Quit: %s
\n
"
,
error
);
exit
(
EXIT_FAILURE
);
}
exit
(
EXIT_SUCCESS
);
}
void
VL_WaitVBL
(
int
vbls
)
{
}
void
VW_UpdateScreen
()
{
VL_WaitVBL
(
1
);
memcpy
(
surface
->
pixels
,
gfxbuf
,
64000
);
SDL_UpdateRect
(
surface
,
0
,
0
,
0
,
0
);
}
/*
=======================
=
= VL_Startup
=
=======================
*/
void
VL_Startup
(
void
)
{
if
(
gfxbuf
==
NULL
)
gfxbuf
=
malloc
(
320
*
200
*
1
);
if
(
SDL_Init
(
SDL_INIT_VIDEO
)
<
0
)
{
Quit
(
"Couldn't init SDL"
);
}
surface
=
SDL_SetVideoMode
(
320
,
200
,
8
,
SDL_SWSURFACE
|
SDL_HWPALETTE
);
if
(
surface
==
NULL
)
{
SDL_Quit
();
Quit
(
"Couldn't set 320x200 mode"
);
}
}
/*
=======================
=
= VL_Shutdown
=
=======================
*/
void
VL_Shutdown
(
void
)
{
if
(
gfxbuf
!=
NULL
)
{
free
(
gfxbuf
);
gfxbuf
=
NULL
;
}
SDL_Quit
();
}
//===========================================================================
/*
=================
=
= VL_ClearVideo
=
= Fill the entire video buffer with a given color
=
=================
*/
void
VL_ClearVideo
(
byte
color
)
{
memset
(
gfxbuf
,
color
,
64000
);
}
/*
=============================================================================
PALETTE OPS
To avoid snow, do a WaitVBL BEFORE calling these
=============================================================================
*/
/*
=================
=
= VL_FillPalette
=
=================
*/
void
VL_FillPalette
(
int
red
,
int
green
,
int
blue
)
{
SDL_Color
colors
[
256
];
int
i
;
for
(
i
=
0
;
i
<
256
;
i
++
)
{
colors
[
i
].
r
=
red
<<
2
;
colors
[
i
].
g
=
green
<<
2
;
colors
[
i
].
b
=
blue
<<
2
;
}
SDL_SetColors
(
surface
,
colors
,
0
,
256
);
}
//===========================================================================
/*
=================
=
= VL_SetPalette
=
=================
*/
void
VL_SetPalette
(
const
byte
*
palette
)
{
SDL_Color
colors
[
256
];
int
i
;
for
(
i
=
0
;
i
<
256
;
i
++
)
{
colors
[
i
].
r
=
palette
[
i
*
3
+
0
]
<<
2
;
colors
[
i
].
g
=
palette
[
i
*
3
+
1
]
<<
2
;
colors
[
i
].
b
=
palette
[
i
*
3
+
2
]
<<
2
;
}
SDL_SetColors
(
surface
,
colors
,
0
,
256
);
}
//===========================================================================
/*
=================
=
= VL_GetPalette
=
=================
*/
void
VL_GetPalette
(
byte
*
palette
)
{
int
i
;
for
(
i
=
0
;
i
<
256
;
i
++
)
{
palette
[
i
*
3
+
0
]
=
surface
->
format
->
palette
->
colors
[
i
].
r
>>
2
;
palette
[
i
*
3
+
1
]
=
surface
->
format
->
palette
->
colors
[
i
].
g
>>
2
;
palette
[
i
*
3
+
2
]
=
surface
->
format
->
palette
->
colors
[
i
].
b
>>
2
;
}
}
/*
=============================================================================
PIXEL OPS
=============================================================================
*/
/*
=================
=
= VL_Plot
=
=================
*/
void
VL_Plot
(
int
x
,
int
y
,
int
color
)
{
*
(
gfxbuf
+
320
*
y
+
x
)
=
color
;
}
/*
=================
=
= VL_Hlin
=
=================
*/
void
VL_Hlin
(
unsigned
x
,
unsigned
y
,
unsigned
width
,
unsigned
color
)
{
memset
(
gfxbuf
+
320
*
y
+
x
,
color
,
width
);
}
/*
=================
=
= VL_Vlin
=
=================
*/
void
VL_Vlin
(
int
x
,
int
y
,
int
height
,
int
color
)
{
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
while
(
height
--
)
{
*
ptr
=
color
;
ptr
+=
320
;
}
}
/*
=================
=
= VL_Bar
=
=================
*/
void
VL_Bar
(
int
x
,
int
y
,
int
width
,
int
height
,
int
color
)
{
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
while
(
height
--
)
{
memset
(
ptr
,
color
,
width
);
ptr
+=
320
;
}
}
/*
============================================================================
MEMORY OPS
============================================================================
*/
/*
=================
=
= VL_MemToScreen
=
= Draws a block of data to the screen.
=
=================
*/
void
VL_MemToScreen
(
const
byte
*
source
,
int
width
,
int
height
,
int
x
,
int
y
)
{
byte
*
ptr
=
gfxbuf
+
320
*
y
+
x
;
while
(
height
--
)
{
memcpy
(
ptr
,
source
,
width
);
source
+=
width
;
ptr
+=
320
;
}
}
void
VL_DirectPlot
(
int
x1
,
int
y1
,
int
x2
,
int
y2
)
{
*
(((
Uint8
*
)
surface
->
pixels
)
+
x1
+
y1
*
320
)
=
*
(
gfxbuf
+
x2
+
y2
*
320
);
//SDL_UpdateRect(surface, x1,y1,x1,y1);
}
/*
=============================================================================
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
};
int
XKeysymToScancode
(
unsigned
int
keysym
)
{
switch
(
keysym
)
{
case
SDLK_1
:
return
sc_1
;
case
SDLK_2
:
return
sc_2
;
case
SDLK_3
:
return
sc_3
;
case
SDLK_4
:
return
sc_4
;
case
SDLK_a
:
return
sc_A
;
case
SDLK_b
:
return
sc_B
;
case
SDLK_c
:
return
sc_C
;
case
SDLK_h
:
return
sc_H
;
case
SDLK_i
:
return
sc_I
;
case
SDLK_l
:
return
sc_L
;
case
SDLK_m
:
return
sc_M
;
case
SDLK_n
:
return
sc_N
;
case
SDLK_t
:
return
sc_T
;
case
SDLK_y
:
return
sc_Y
;
case
SDLK_LEFT
:
case
SDLK_KP4
:
return
sc_LeftArrow
;
case
SDLK_RIGHT
:
case
SDLK_KP6
:
return
sc_RightArrow
;
case
SDLK_UP
:
case
SDLK_KP8
:
return
sc_UpArrow
;
case
SDLK_DOWN
:
case
SDLK_KP2
:
return
sc_DownArrow
;
case
SDLK_LCTRL
:
return
sc_Control
;
case
SDLK_LALT
:
return
sc_Alt
;
case
SDLK_LSHIFT
:
return
sc_LShift
;
case
SDLK_RSHIFT
:
return
sc_RShift
;
case
SDLK_ESCAPE
:
return
sc_Escape
;
case
SDLK_SPACE
:
return
sc_Space
;
case
SDLK_KP_ENTER
:
case
SDLK_RETURN
:
return
sc_Enter
;
case
SDLK_TAB
:
return
sc_Tab
;
case
SDLK_BACKSPACE
:
return
sc_BackSpace
;
case
SDLK_PAUSE
:
return
0xE1
;
default:
//printf("unknown: %s\n", XKeysymToString(keysym));
return
sc_None
;
}
}
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
()
{
SDL_Event
event
;
unsigned
i
,
buttons
;
if
(
SDL_PollEvent
(
&
event
))
{
do
{
switch
(
event
.
type
)
{
case
SDL_KEYDOWN
:
keyboard_handler
(
XKeysymToScancode
(
event
.
key
.
keysym
.
sym
),
1
);
break
;
case
SDL_KEYUP
:
keyboard_handler
(
XKeysymToScancode
(
event
.
key
.
keysym
.
sym
),
0
);
break
;
default:
break
;
}
}
while
(
SDL_PollEvent
(
&
event
));
}
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
()
{
IN_StartAck
();
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
;
}
src/wl_inter.c
View file @
9fe175e9
#include "wl_def.h"
//==========================================================================
/*
==================
=
...
...
src/wl_main.c
View file @
9fe175e9
...
...
@@ -69,10 +69,9 @@ char **_argv;
/*
========================
=
= FixedByFrac
= FixedByFrac
(FixedMul)
=
= multiply a 16/16 bit, 2's complement fixed point number by a 16 bit
= fraction
= multiply two 16/16 bit, 2's complement fixed point numbers
=
========================
*/
...
...
@@ -280,19 +279,19 @@ void NewGame(int difficulty, int episode)
gamestate
.
ammo
=
STARTAMMO
;
gamestate
.
lives
=
3
;
gamestate
.
nextextra
=
EXTRAPOINTS
;
gamestate
.
episode
=
episode
;
gamestate
.
episode
=
episode
;
startgame
=
true
;
}
void
DiskFlopAnim
(
int
x
,
int
y
)
{
static
char
which
=
0
;
static
char
which
=
0
;
if
(
!
x
&&
!
y
)
return
;
VWB_DrawPic
(
x
,
y
,
C_DISKLOADING1PIC
+
which
);
VWB_DrawPic
(
x
,
y
,
C_DISKLOADING1PIC
+
which
);
VW_UpdateScreen
();
which
^=
1
;
...
...
@@ -427,14 +426,14 @@ boolean LoadTheGame(int file,int x,int y)
CA_FarRead
(
file
,(
void
*
)
tilemap
,
sizeof
(
tilemap
));
checksum
=
DoChecksum
((
byte
*
)
tilemap
,
sizeof
(
tilemap
),
checksum
);
DiskFlopAnim
(
x
,
y
);
CA_FarRead
(
file
,(
void
*
)
actorat
,
sizeof
(
actorat
));
CA_FarRead
(
file
,(
void
*
)
actorat
,
sizeof
(
actorat
));
checksum
=
DoChecksum
((
byte
*
)
actorat
,
sizeof
(
actorat
),
checksum
);
CA_FarRead
(
file
,(
void
*
)
areaconnect
,
sizeof
(
areaconnect
));
CA_FarRead
(
file
,(
void
*
)
areabyplayer
,
sizeof
(
areabyplayer
));
CA_FarRead
(
file
,(
void
*
)
areaconnect
,
sizeof
(
areaconnect
));
CA_FarRead
(
file
,(
void
*
)
areabyplayer
,
sizeof
(
areabyplayer
));
InitActorList
();
InitActorList
();
DiskFlopAnim
(
x
,
y
);
CA_FarRead
(
file
,(
void
*
)
player
,
sizeof
(
*
player
));
...
...
@@ -540,7 +539,7 @@ void ShutdownId()
==================
*/
const
float
radtoint
=
(
float
)
FINEANGLES
/
2
.
0
f
/
PI
;
static
const
float
radtoint
=
(
float
)
FINEANGLES
/
2
.
0
f
/
PI
;
void
BuildTables
()
{
...
...
@@ -564,9 +563,6 @@ void BuildTables()
//
// costable overlays sintable with a quarter phase shift
// ANGLES is assumed to be divisable by four
//
// The low word of the value is the fraction, the high bit is the sign bit,
// bits 16-30 should be 0
//
angle
=
0
;
...
...
@@ -584,9 +580,6 @@ void BuildTables()
}
//===========================================================================
/*
====================
=
...
...
@@ -637,10 +630,6 @@ void CalcProjection(long focal)
}
}
//===========================================================================
/*
===================
=
...
...
@@ -964,7 +953,7 @@ void DoJukebox()
MenuFadeOut
();
#if !defined(SPEAR) || !defined(UPLOAD)
start
=
(
rand
()
%
3
)
*
6
;
start
=
(
US_RndT
()
%
3
)
*
6
;
#else
start
=
0
;
#endif
...
...
@@ -1287,8 +1276,6 @@ int WolfMain(int argc, char *argv[])
printf
(
"Now Loading %s
\n
"
,
GAMENAME
);
srand
(
time
(
NULL
));
CheckForEpisodes
();
InitGame
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment