Commit c7e721f4 authored by Steven Fuller's avatar Steven Fuller

Minor changes (particularly no longer does id_vh use graph_mem), added

files for future vi_glx and vi_xlib code and updated the Makefile
parent aa4e3713
......@@ -3,30 +3,38 @@ CC = gcc
#CFLAGS = -g -Wall -pedantic
CFLAGS = -g
#CFLAGS = -Os
OBJS = objs.o misc.o id_ca.o id_sd.o id_vh.o id_us.o vi_svga.o \
OBJS = objs.o misc.o id_ca.o id_sd.o id_vh.o id_us.o \
wl_scale.o wl_draw.o wl_act1.o wl_act2.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_debug.o
SOBJS = $(OBJS) vi_svga.o
XOBJS = $(OBJS) vi_xlib.o
LFLAGS = -lm -lvga
LFLAGS = -lm
#LFLAGS = -lm -lvga ElectricFence-2.2.2/libefence.a -lpthread
SLFLAGS = $(LFLAGS) -lvga
XLFLAGS = $(LFLAGS) -L/usr/X11R6/lib -lX11
NASM = nasm
.SUFFIXES: .asm
all: wolf3d
all: swolf3d xwolf3d
$(OBJS): version.h id_heads.h
$(SOBJS): version.h id_heads.h
$(XOBJS): version.h id_heads.h
.asm.o:
$(NASM) -f elf -o $@ $<
wolf3d: $(OBJS)
gcc -o wolf3d $(OBJS) $(LFLAGS)
swolf3d: $(SOBJS)
gcc -o swolf3d $(SOBJS) $(SLFLAGS)
xwolf3d: $(XOBJS)
gcc -o xwolf3d $(XOBJS) $(XLFLAGS)
clean:
rm -rf wolf3d *.o
rm -rf swolf3d xwolf3d *.o
distclean: clean
rm -rf *~ DEADJOE
......
......@@ -242,7 +242,9 @@ boolean FizzleFade(unsigned xx, unsigned yy, unsigned width,unsigned height, uns
if ((x>width) || (y>height))
continue;
*(graph_mem + (xx+x) + (yy+y) * 320) = *(gfxbuf + (xx+x) + (yy+y) * 320);
VL_DirectPlot(xx+x, yy+y, xx+x, yy+y);
//*(graph_mem + (xx+x) + (yy+y) * 320) = *(gfxbuf + (xx+x) + (yy+y) * 320);
if (rndval == 1) /* entire sequence has been completed */
return false;
......
#ifndef __VI_SVGA_H__
#define __VI_SVGA_H__
#ifndef __VI_COMM_H__
#define __VI_COMM_H__
//===========================================================================
......@@ -36,6 +36,8 @@ void VL_MemToScreen(byte *source, int width, int height, int x, int y);
void VL_DeModeXize(byte *buf, int width, int height);
void VL_DirectPlot(int x1, int y1, int x2, int y2);
#define MaxPlayers 4
#define MaxJoys 2
#define NumCodes 128
......
/* id_vl.c */
#include "id_heads.h"
#include <X11/Xlib.h>
#include <X11/keysym.h>
boolean screenfaded;
byte palette1[256][3], palette2[256][3];
byte *gfxbuf = NULL;
void VL_WaitVBL(int vbls)
{
}
void VW_UpdateScreen()
{
}
/*
=======================
=
= 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_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)
{
int i;
}
//===========================================================================
/*
=================
=
= VL_SetColor
=
=================
*/
void VL_SetColor(int color, int red, int green, int blue)
{
}
//===========================================================================
/*
=================
=
= VL_GetColor
=
=================
*/
void VL_GetColor(int color, int *red, int *green, int *blue)
{
}
//===========================================================================
/*
=================
=
= VL_SetPalette
=
=================
*/
void VL_SetPalette(byte *palette)
{
}
//===========================================================================
/*
=================
=
= VL_GetPalette
=
=================
*/
void VL_GetPalette(byte *palette)
{
int i, r, g, b;
for (i = 0; i < 256; i++) {
palette[i*3+0] = r;
palette[i*3+1] = g;
palette[i*3+2] = b;
}
}
//===========================================================================
/*
=================
=
= VL_FadeOut
=
= Fades the current palette to the given color in the given number of steps
=
=================
*/
void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
{
int i,j,orig,delta;
byte *origptr, *newptr;
VL_WaitVBL(1);
VL_GetPalette (&palette1[0][0]);
memcpy (palette2,palette1,768);
//
// fade through intermediate frames
//
for (i=0;i<steps;i++)
{
origptr = &palette1[start][0];
newptr = &palette2[start][0];
for (j=start;j<=end;j++)
{
orig = *origptr++;
delta = red-orig;
*newptr++ = orig + delta * i / steps;
orig = *origptr++;
delta = green-orig;
*newptr++ = orig + delta * i / steps;
orig = *origptr++;
delta = blue-orig;
*newptr++ = orig + delta * i / steps;
}
VL_WaitVBL(1);
VL_SetPalette (&palette2[0][0]);
}
//
// final color
//
VL_FillPalette (red,green,blue);
screenfaded = true;
}
/*
=================
=
= VL_FadeIn
=
=================
*/
void VL_FadeIn(int start, int end, byte *palette, int steps)
{
int i,j,delta;
VL_WaitVBL(1);
VL_GetPalette (&palette1[0][0]);
memcpy (&palette2[0][0],&palette1[0][0],sizeof(palette1));
start *= 3;
end = end*3+2;
//
// fade through intermediate frames
//
for (i=0;i<steps;i++)
{
for (j=start;j<=end;j++)
{
delta = palette[j]-palette1[0][j];
palette2[0][j] = palette1[0][j] + delta * i / steps;
}
VL_WaitVBL(1);
VL_SetPalette (&palette2[0][0]);
}
//
// final color
//
VL_SetPalette (palette);
screenfaded = false;
}
/*
==================
=
= VL_ColorBorder
=
==================
*/
void VL_ColorBorder (int color)
{
}
/*
=============================================================================
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(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_DeModeXize(byte *buf, int width, int height)
{
byte *mem, *ptr, *destline;
int plane, x, y;
if (width & 3) {
printf("Not divisible by 4?\n");
return;
}
mem = malloc(width * height);
ptr = buf;
for (plane = 0; plane < 4; plane++) {
destline = mem;
for (y = 0; y < height; y++) {
for (x = 0; x < width / 4; x++)
*(destline + x*4 + plane) = *ptr++;
destline += width;
}
}
memcpy(buf, mem, width * height);
free(mem);
}
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 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
0 ,0 ,0 ,0 ,0 ,'/',0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 3
0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4
0 ,0 ,0 ,0 ,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
};
static char *ParmStrings[] = {"nojoys","nomouse",nil};
// Internal routines
void keyboard_handler(int code, int press)
{
static boolean special;
byte k, c, temp;
int i;
/* k = inportb(0x60); // Get the scan code */
k = code;
if (k == 0xe0) // Special key prefix
special = true;
else if (k == 0xe1) // Handle Pause key
Paused = true;
else
{
if (press == 0)
{
// DEBUG - handle special keys: ctl-alt-delete, print scrn
Keyboard[k] = false;
}
else // Make code
{
LastCode = CurCode;
CurCode = LastScan = k;
Keyboard[k] = true;
if (special)
c = SpecialNames[k];
else
{
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;
}
special = false;
}
}
///////////////////////////////////////////////////////////////////////////
//
// 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;
for (i = 1;i < _argc;i++)
{
switch (US_CheckParm(_argv[i],ParmStrings))
{
case 0:
checkjoys = false;
break;
case 1:
checkmouse = false;
break;
}
}
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;
word buttons;
int dx,dy;
Motion mx,my;
ControlType type;
KeyboardDef *def;
dx = dy = 0;
mx = my = motion_None;
buttons = 0;
//keyboard_update();
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;
}
int flipz;
boolean IN_CheckAck (void)
{
unsigned i,buttons;
if (flipz == 1) {
flipz = 0;
return false;
}
flipz++;
//while (keyboard_update()) ; /* 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;
}
int main(int argc, char *argv[])
{
return WolfMain(argc, argv);
}
......@@ -15,6 +15,7 @@ void VL_WaitVBL(int vbls)
void VW_UpdateScreen()
{
/* VL_WaitVBL(1); */
memcpy(graph_mem, gfxbuf, 64000);
}
......@@ -283,10 +284,6 @@ void VL_ColorBorder (int color)
=============================================================================
*/
byte pixmasks[4] = {1,2,4,8};
byte leftmasks[4] = {15,14,12,8};
byte rightmasks[4] = {1,3,7,15};
/*
=================
=
......@@ -399,6 +396,11 @@ void VL_DeModeXize(byte *buf, int width, int height)
free(mem);
}
void VL_DirectPlot(int x1, int y1, int x2, int y2)
{
*(graph_mem + x1 + y1 * 320) = *(gfxbuf + x2 + y2 * 320);
}
/*
=============================================================================
......@@ -822,7 +824,8 @@ void IN_ReadControl(int player,ControlInfo *info)
mx = my = motion_None;
buttons = 0;
keyboard_update();
//keyboard_update();
IN_CheckAck();
switch (type = Controls[player])
{
......@@ -918,17 +921,9 @@ void IN_StartAck(void)
btnstate[i] = true;
}
int flipz;
boolean IN_CheckAck (void)
{
unsigned i,buttons;
if (flipz == 1) {
flipz = 0;
return false;
}
flipz++;
while (keyboard_update()) ; /* get all events */
......
/* id_vl.c */
#include "id_heads.h"
#include <X11/Xlib.h>
#include <X11/keysym.h>
boolean screenfaded;
byte palette1[256][3], palette2[256][3];
byte *gfxbuf = NULL;
void VL_WaitVBL(int vbls)
{
}
void VW_UpdateScreen()
{
}
/*
=======================
=
= 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_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)
{
int i;
}
//===========================================================================
/*
=================
=
= VL_SetColor
=
=================
*/
void VL_SetColor(int color, int red, int green, int blue)
{
}
//===========================================================================
/*
=================
=
= VL_GetColor
=
=================
*/
void VL_GetColor(int color, int *red, int *green, int *blue)
{
}
//===========================================================================
/*
=================
=
= VL_SetPalette
=
=================
*/
void VL_SetPalette(byte *palette)
{
}
//===========================================================================
/*
=================
=
= VL_GetPalette
=
=================
*/
void VL_GetPalette(byte *palette)
{
int i, r, g, b;
for (i = 0; i < 256; i++) {
palette[i*3+0] = r;
palette[i*3+1] = g;
palette[i*3+2] = b;
}
}
//===========================================================================
/*
=================
=
= VL_FadeOut
=
= Fades the current palette to the given color in the given number of steps
=
=================
*/
void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
{
int i,j,orig,delta;
byte *origptr, *newptr;
VL_WaitVBL(1);
VL_GetPalette (&palette1[0][0]);
memcpy (palette2,palette1,768);
//
// fade through intermediate frames
//
for (i=0;i<steps;i++)
{
origptr = &palette1[start][0];
newptr = &palette2[start][0];
for (j=start;j<=end;j++)
{
orig = *origptr++;
delta = red-orig;
*newptr++ = orig + delta * i / steps;
orig = *origptr++;
delta = green-orig;
*newptr++ = orig + delta * i / steps;
orig = *origptr++;
delta = blue-orig;
*newptr++ = orig + delta * i / steps;
}
VL_WaitVBL(1);
VL_SetPalette (&palette2[0][0]);
}
//
// final color
//
VL_FillPalette (red,green,blue);
screenfaded = true;
}
/*
=================
=
= VL_FadeIn
=
=================
*/
void VL_FadeIn(int start, int end, byte *palette, int steps)
{
int i,j,delta;
VL_WaitVBL(1);
VL_GetPalette (&palette1[0][0]);
memcpy (&palette2[0][0],&palette1[0][0],sizeof(palette1));
start *= 3;
end = end*3+2;
//
// fade through intermediate frames
//
for (i=0;i<steps;i++)
{
for (j=start;j<=end;j++)
{
delta = palette[j]-palette1[0][j];
palette2[0][j] = palette1[0][j] + delta * i / steps;
}
VL_WaitVBL(1);
VL_SetPalette (&palette2[0][0]);
}
//
// final color
//
VL_SetPalette (palette);
screenfaded = false;
}
/*
==================
=
= VL_ColorBorder
=
==================
*/
void VL_ColorBorder (int color)
{
}
/*
=============================================================================
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(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_DeModeXize(byte *buf, int width, int height)
{
byte *mem, *ptr, *destline;
int plane, x, y;
if (width & 3) {
printf("Not divisible by 4?\n");
return;
}
mem = malloc(width * height);
ptr = buf;
for (plane = 0; plane < 4; plane++) {
destline = mem;
for (y = 0; y < height; y++) {
for (x = 0; x < width / 4; x++)
*(destline + x*4 + plane) = *ptr++;
destline += width;
}
}
memcpy(buf, mem, width * height);
free(mem);
}
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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,0 ,0 ,0 ,0 ,0 ,0 ,0 , // 4
0 ,0 ,0 ,0 ,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
};
static char *ParmStrings[] = {"nojoys","nomouse",nil};
// Internal routines
void keyboard_handler(int code, int press)
{
static boolean special;
byte k, c, temp;
int i;
/* k = inportb(0x60); // Get the scan code */
k = code;
if (k == 0xe0) // Special key prefix
special = true;
else if (k == 0xe1) // Handle Pause key
Paused = true;
else
{
if (press == 0)
{
// DEBUG - handle special keys: ctl-alt-delete, print scrn
Keyboard[k] = false;
}
else // Make code
{
LastCode = CurCode;
CurCode = LastScan = k;
Keyboard[k] = true;
if (special)
c = SpecialNames[k];
else
{
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;
}
special = false;
}
}
///////////////////////////////////////////////////////////////////////////
//
// 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;
for (i = 1;i < _argc;i++)
{
switch (US_CheckParm(_argv[i],ParmStrings))
{
case 0:
checkjoys = false;
break;
case 1:
checkmouse = false;
break;
}
}
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;
word buttons;
int dx,dy;
Motion mx,my;
ControlType type;
KeyboardDef *def;
dx = dy = 0;
mx = my = motion_None;
buttons = 0;
//keyboard_update();
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;
}
int flipz;
boolean IN_CheckAck (void)
{
unsigned i,buttons;
if (flipz == 1) {
flipz = 0;
return false;
}
flipz++;
//while (keyboard_update()) ; /* 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;
}
int main(int argc, char *argv[])
{
return WolfMain(argc, argv);
}
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