Added simple key event processing.
This commit is contained in:
parent
a113617c02
commit
45cf2eb3a1
7 changed files with 81 additions and 49 deletions
|
@ -152,8 +152,8 @@ void SoundBehaveFun (STRATEGYBLOCK * sbptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// hack hack hack fixme fixme fix me
|
// // hack hack hack fixme fixme fix me
|
||||||
#pragma message ("Special code to deal with siren.wav!!");
|
// #pragma message ("Special code to deal with siren.wav!!");
|
||||||
|
|
||||||
if (AvP.DestructTimer != -1)
|
if (AvP.DestructTimer != -1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,7 +62,7 @@ typedef struct quat_short
|
||||||
short quaty;
|
short quaty;
|
||||||
short quatz;
|
short quatz;
|
||||||
short quatw;
|
short quatw;
|
||||||
}QUAT_SHORT;
|
} PACKED QUAT_SHORT;
|
||||||
/*A couple of conversion functions */
|
/*A couple of conversion functions */
|
||||||
extern void CopyShortQuatToInt(QUAT_SHORT* qs_from,QUAT* q_to);
|
extern void CopyShortQuatToInt(QUAT_SHORT* qs_from,QUAT* q_to);
|
||||||
extern void CopyIntQuatToShort(QUAT* q_from,QUAT_SHORT* qs_to);
|
extern void CopyIntQuatToShort(QUAT* q_from,QUAT_SHORT* qs_to);
|
||||||
|
|
13
src/kshape.c
13
src/kshape.c
|
@ -4500,19 +4500,6 @@ void TranslatePoint(int *source, int *dest, int *matrix)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void TranslatePoint(float *source, float *dest, float *matrix)
|
|
||||||
{
|
|
||||||
// fprintf(stderr, "TranslatePoint(%f, %f, %f)\n");
|
|
||||||
|
|
||||||
/* TODO - implement the inline assembly here? */
|
|
||||||
/* Moved to a separate file because I can't figure out the damn syntax! */
|
|
||||||
__asm__("call TranslatePoint_Asm \n\t"
|
|
||||||
:
|
|
||||||
: "S" (source), "b" (dest), "D" (matrix)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TranslatePointIntoViewspace(VECTORCH *pointPtr)
|
void TranslatePointIntoViewspace(VECTORCH *pointPtr)
|
||||||
{
|
{
|
||||||
Source[0] = pointPtr->vx;
|
Source[0] = pointPtr->vx;
|
||||||
|
|
48
src/main.c
48
src/main.c
|
@ -25,6 +25,10 @@ char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load
|
||||||
|
|
||||||
extern int ScanDrawMode; /* to fix image loading */
|
extern int ScanDrawMode; /* to fix image loading */
|
||||||
extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock; /* this should be put in a header file */
|
extern SCREENDESCRIPTORBLOCK ScreenDescriptorBlock; /* this should be put in a header file */
|
||||||
|
extern unsigned char DebouncedKeyboardInput[MAX_NUMBER_OF_INPUT_KEYS];
|
||||||
|
extern unsigned char KeyboardInput[MAX_NUMBER_OF_INPUT_KEYS];
|
||||||
|
extern int DebouncedGotAnyKey;
|
||||||
|
extern unsigned char GotAnyKey;
|
||||||
|
|
||||||
PROCESSORTYPES ReadProcessorType()
|
PROCESSORTYPES ReadProcessorType()
|
||||||
{
|
{
|
||||||
|
@ -65,16 +69,60 @@ int InitialiseWindowsSystem()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int KeySymToKey(int keysym)
|
||||||
|
{
|
||||||
|
switch(keysym) {
|
||||||
|
case SDLK_ESCAPE:
|
||||||
|
return KEY_ESCAPE;
|
||||||
|
case SDLK_RETURN:
|
||||||
|
return KEY_CR;
|
||||||
|
|
||||||
|
case SDLK_LEFT:
|
||||||
|
return KEY_LEFT;
|
||||||
|
case SDLK_RIGHT:
|
||||||
|
return KEY_RIGHT;
|
||||||
|
case SDLK_UP:
|
||||||
|
return KEY_UP;
|
||||||
|
case SDLK_DOWN:
|
||||||
|
return KEY_DOWN;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_keypress(int keysym, int press)
|
||||||
|
{
|
||||||
|
int key = KeySymToKey(keysym);
|
||||||
|
|
||||||
|
if (key == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (press && !KeyboardInput[key]) {
|
||||||
|
DebouncedKeyboardInput[key] = 1;
|
||||||
|
DebouncedGotAnyKey = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
GotAnyKey = 1;
|
||||||
|
KeyboardInput[key] = press;
|
||||||
|
}
|
||||||
|
|
||||||
void CheckForWindowsMessages()
|
void CheckForWindowsMessages()
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
|
GotAnyKey = 0;
|
||||||
|
DebouncedGotAnyKey = 0;
|
||||||
|
memset(DebouncedKeyboardInput, 0, sizeof(DebouncedKeyboardInput));
|
||||||
|
|
||||||
if (SDL_PollEvent(&event)) {
|
if (SDL_PollEvent(&event)) {
|
||||||
do {
|
do {
|
||||||
switch(event.type) {
|
switch(event.type) {
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
handle_keypress(event.key.keysym.sym, 1);
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
|
handle_keypress(event.key.keysym.sym, 0);
|
||||||
break;
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
|
@ -162,12 +162,12 @@ void MUL_I_WIDE(int a, int b, LONGLONGCH *c)
|
||||||
mov [ebx+4],edx
|
mov [ebx+4],edx
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
__asm__("imull %2 \n\t"
|
__asm__("imull %%edx \n\t"
|
||||||
"movl %%eax, 0(%%ebx) \n\t"
|
"movl %%eax, 0(%%ebx) \n\t"
|
||||||
"movl %%edx, 4(%%ebx) \n\t"
|
"movl %%edx, 4(%%ebx) \n\t"
|
||||||
:
|
:
|
||||||
: "a" (a), "b" (c), "q" (b)
|
: "a" (a), "b" (c), "d" (b)
|
||||||
: "%edx", "memory", "cc"
|
: "memory", "cc"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,18 +208,18 @@ __asm__("movl 0(%%ebx), %%eax \n\t"
|
||||||
"movl 4(%%ebx), %%edx \n\t"
|
"movl 4(%%ebx), %%edx \n\t"
|
||||||
"subl 0(%%ecx), %%eax \n\t"
|
"subl 0(%%ecx), %%eax \n\t"
|
||||||
"sbbl 4(%%ecx), %%edx \n\t"
|
"sbbl 4(%%ecx), %%edx \n\t"
|
||||||
"xorl %0, %0 \n\t" /* hopefully it doesn't pick %eax or %edx */
|
"xorl %%ebx, %%ebx \n\t"
|
||||||
"andl %%edx, %%edx \n\t"
|
"andl %%edx, %%edx \n\t"
|
||||||
"jne 0 \n\t" /* llnz */
|
"jne 0 \n\t" /* llnz */
|
||||||
"andl %%eax, %%eax \n\t"
|
"andl %%eax, %%eax \n\t"
|
||||||
"je 1 \n" /* llgs */
|
"je 1 \n" /* llgs */
|
||||||
"0: \n\t" /* llnz */
|
"0: \n\t" /* llnz */
|
||||||
"movl $1, %0 \n\t"
|
"movl $1, %%ebx \n\t"
|
||||||
"andl %%edx, %%edx \n\t"
|
"andl %%edx, %%edx \n\t"
|
||||||
"jge 1 \n\t" /* llgs */
|
"jge 1 \n\t" /* llgs */
|
||||||
"negl %0 \n"
|
"negl %%ebx \n"
|
||||||
"1: \n\t" /* llgs */
|
"1: \n\t" /* llgs */
|
||||||
: "=r" (retval)
|
: "=b" (retval)
|
||||||
: "b" (a), "c" (b)
|
: "b" (a), "c" (b)
|
||||||
: "%eax", "%edx", "memory", "cc"
|
: "%eax", "%edx", "memory", "cc"
|
||||||
);
|
);
|
||||||
|
@ -374,12 +374,11 @@ int MUL_FIXED(int a, int b)
|
||||||
mov retval,eax
|
mov retval,eax
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* TODO */
|
__asm__("imull %%edx \n\t"
|
||||||
__asm__("imull %2 \n\t"
|
|
||||||
"shrdl $16, %%edx, %%eax \n\t"
|
"shrdl $16, %%edx, %%eax \n\t"
|
||||||
: "=a" (retval)
|
: "=a" (retval)
|
||||||
: "a" (a), "q" (b)
|
: "a" (a), "d" (b)
|
||||||
: "%edx", "cc"
|
: "cc"
|
||||||
);
|
);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -405,14 +404,13 @@ int DIV_FIXED(int a, int b)
|
||||||
mov retval,eax
|
mov retval,eax
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
/* TODO */
|
|
||||||
__asm__("cdq \n\t"
|
__asm__("cdq \n\t"
|
||||||
"roll $16, %%eax \n\t"
|
"roll $16, %%eax \n\t"
|
||||||
"mov %%ax, %%dx \n\t"
|
"mov %%ax, %%dx \n\t"
|
||||||
"xor %%ax, %%ax \n\t"
|
"xor %%ax, %%ax \n\t"
|
||||||
"idivl %2 \n\t"
|
"idivl %%ebx \n\t"
|
||||||
: "=a" (retval)
|
: "=a" (retval)
|
||||||
: "a" (a), "q" (b)
|
: "a" (a), "b" (b)
|
||||||
: "%edx", "cc"
|
: "%edx", "cc"
|
||||||
);
|
);
|
||||||
return retval;
|
return retval;
|
||||||
|
@ -625,3 +623,16 @@ __asm__("fld fti_fptmp \n\t"
|
||||||
return fptmp;
|
return fptmp;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TranslatePoint(float *source, float *dest, float *matrix)
|
||||||
|
{
|
||||||
|
// fprintf(stderr, "TranslatePoint(%f, %f, %f)\n");
|
||||||
|
|
||||||
|
/* TODO - implement the inline assembly here? */
|
||||||
|
/* Moved it to a separate file because I can't figure out the damn syntax! */
|
||||||
|
/* This is currently not inlined for testing */
|
||||||
|
__asm__("call TranslatePoint_Asm \n\t"
|
||||||
|
:
|
||||||
|
: "S" (source), "b" (dest), "D" (matrix)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -96,8 +96,8 @@ switch(RenderPolygon.TranslucencyMode)
|
||||||
// z = vertices->Z*16;
|
// z = vertices->Z*16;
|
||||||
// z = -z/65536;
|
// z = -z/65536;
|
||||||
|
|
||||||
zvalue = vertices->Z+HeadUpDisplayZOffset;
|
zvalue = 65536 - vertices->Z+HeadUpDisplayZOffset;
|
||||||
zvalue = 1.0f - ZNear/zvalue;
|
zvalue = 1.0 - ZNear/zvalue;
|
||||||
z = -zvalue;
|
z = -zvalue;
|
||||||
|
|
||||||
// x *= 16.0;
|
// x *= 16.0;
|
||||||
|
@ -106,7 +106,8 @@ switch(RenderPolygon.TranslucencyMode)
|
||||||
|
|
||||||
glColor4ub(vertices->R, vertices->G, vertices->B, vertices->A);
|
glColor4ub(vertices->R, vertices->G, vertices->B, vertices->A);
|
||||||
glVertex3f(x, y, z);
|
glVertex3f(x, y, z);
|
||||||
fprintf(stderr, "Vertex %d: (%f, %f, %f) [%d, %d, %d] (%d, %d, %d, %d)\n", i, x, y, z, vertices->X, vertices->Y, vertices->Z, vertices->R, vertices->G, vertices->B, vertices->A);
|
fprintf(stderr, "Vertex %d: (%f, %f, %f)\n\t[%d, %d, %d]->[%d, %d] (%d, %d, %d, %d)\n", i, x, y, z, vertices->X, vertices->Y, vertices->Z, x1, y1, vertices->R, vertices->G, vertices->B, vertices->A);
|
||||||
|
fprintf(stderr, "znear = %f, zvalue = %f, z = %f\n", ZNear, zvalue, z);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
|
|
@ -596,21 +596,6 @@ typedef enum {
|
||||||
#define gt3poly_vsize 6
|
#define gt3poly_vsize 6
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Triangle Array Structure
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct trianglearray {
|
|
||||||
|
|
||||||
int TA_NumTriangles;
|
|
||||||
int *TA_ItemPtr;
|
|
||||||
int *TA_TriangleArray[maxarrtriangles];
|
|
||||||
|
|
||||||
} TRIANGLEARRAY;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function prototypes
|
Function prototypes
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue