summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fuller <relnev@icculus.org>2001-08-08 22:42:43 +0000
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-20 02:22:36 +0200
commit45cf2eb3a194d53ccdd05a75b46e472a01359abf (patch)
tree224ba4ba67816976e987030111e29916f43598b3
parenta113617c026d00770c0a01b292386bd1857f5a6a (diff)
Added simple key event processing.
-rw-r--r--src/avp/bh_snds.c4
-rw-r--r--src/avp/hmodel.h4
-rw-r--r--src/kshape.c13
-rw-r--r--src/main.c48
-rw-r--r--src/mathline.c39
-rw-r--r--src/opengl.c7
-rw-r--r--src/win95/platform.h15
7 files changed, 81 insertions, 49 deletions
diff --git a/src/avp/bh_snds.c b/src/avp/bh_snds.c
index 8a6409a..30128e6 100644
--- a/src/avp/bh_snds.c
+++ b/src/avp/bh_snds.c
@@ -152,8 +152,8 @@ void SoundBehaveFun (STRATEGYBLOCK * sbptr)
}
}
- // hack hack hack fixme fixme fix me
- #pragma message ("Special code to deal with siren.wav!!");
+// // hack hack hack fixme fixme fix me
+// #pragma message ("Special code to deal with siren.wav!!");
if (AvP.DestructTimer != -1)
{
diff --git a/src/avp/hmodel.h b/src/avp/hmodel.h
index bb46b1d..36a9545 100644
--- a/src/avp/hmodel.h
+++ b/src/avp/hmodel.h
@@ -62,7 +62,7 @@ typedef struct quat_short
short quaty;
short quatz;
short quatw;
-}QUAT_SHORT;
+} PACKED QUAT_SHORT;
/*A couple of conversion functions */
extern void CopyShortQuatToInt(QUAT_SHORT* qs_from,QUAT* q_to);
extern void CopyIntQuatToShort(QUAT* q_from,QUAT_SHORT* qs_to);
@@ -398,4 +398,4 @@ extern void SaveHierarchy(HMODELCONTROLLER* controller);
}
#endif
-#endif \ No newline at end of file
+#endif
diff --git a/src/kshape.c b/src/kshape.c
index 0e95c46..5e204f9 100644
--- a/src/kshape.c
+++ b/src/kshape.c
@@ -4500,19 +4500,6 @@ void TranslatePoint(int *source, int *dest, int *matrix)
#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)
{
Source[0] = pointPtr->vx;
diff --git a/src/main.c b/src/main.c
index eeea7d7..19d67a4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -25,6 +25,10 @@ char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load
extern int ScanDrawMode; /* to fix image loading */
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()
{
@@ -65,16 +69,60 @@ int InitialiseWindowsSystem()
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()
{
SDL_Event event;
+ GotAnyKey = 0;
+ DebouncedGotAnyKey = 0;
+ memset(DebouncedKeyboardInput, 0, sizeof(DebouncedKeyboardInput));
+
if (SDL_PollEvent(&event)) {
do {
switch(event.type) {
case SDL_KEYDOWN:
+ handle_keypress(event.key.keysym.sym, 1);
break;
case SDL_KEYUP:
+ handle_keypress(event.key.keysym.sym, 0);
break;
case SDL_QUIT:
SDL_Quit();
diff --git a/src/mathline.c b/src/mathline.c
index 99837b2..98eb676 100644
--- a/src/mathline.c
+++ b/src/mathline.c
@@ -162,12 +162,12 @@ void MUL_I_WIDE(int a, int b, LONGLONGCH *c)
mov [ebx+4],edx
}
*/
-__asm__("imull %2 \n\t"
+__asm__("imull %%edx \n\t"
"movl %%eax, 0(%%ebx) \n\t"
"movl %%edx, 4(%%ebx) \n\t"
:
- : "a" (a), "b" (c), "q" (b)
- : "%edx", "memory", "cc"
+ : "a" (a), "b" (c), "d" (b)
+ : "memory", "cc"
);
}
@@ -208,18 +208,18 @@ __asm__("movl 0(%%ebx), %%eax \n\t"
"movl 4(%%ebx), %%edx \n\t"
"subl 0(%%ecx), %%eax \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"
"jne 0 \n\t" /* llnz */
"andl %%eax, %%eax \n\t"
"je 1 \n" /* llgs */
"0: \n\t" /* llnz */
- "movl $1, %0 \n\t"
+ "movl $1, %%ebx \n\t"
"andl %%edx, %%edx \n\t"
"jge 1 \n\t" /* llgs */
- "negl %0 \n"
+ "negl %%ebx \n"
"1: \n\t" /* llgs */
- : "=r" (retval)
+ : "=b" (retval)
: "b" (a), "c" (b)
: "%eax", "%edx", "memory", "cc"
);
@@ -374,12 +374,11 @@ int MUL_FIXED(int a, int b)
mov retval,eax
}
*/
-/* TODO */
-__asm__("imull %2 \n\t"
+__asm__("imull %%edx \n\t"
"shrdl $16, %%edx, %%eax \n\t"
: "=a" (retval)
- : "a" (a), "q" (b)
- : "%edx", "cc"
+ : "a" (a), "d" (b)
+ : "cc"
);
return retval;
}
@@ -405,14 +404,13 @@ int DIV_FIXED(int a, int b)
mov retval,eax
}
*/
-/* TODO */
__asm__("cdq \n\t"
"roll $16, %%eax \n\t"
"mov %%ax, %%dx \n\t"
"xor %%ax, %%ax \n\t"
- "idivl %2 \n\t"
+ "idivl %%ebx \n\t"
: "=a" (retval)
- : "a" (a), "q" (b)
+ : "a" (a), "b" (b)
: "%edx", "cc"
);
return retval;
@@ -625,3 +623,16 @@ __asm__("fld fti_fptmp \n\t"
return fptmp;
#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)
+ );
+}
diff --git a/src/opengl.c b/src/opengl.c
index d9851b2..7379066 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -96,8 +96,8 @@ switch(RenderPolygon.TranslucencyMode)
// z = vertices->Z*16;
// z = -z/65536;
- zvalue = vertices->Z+HeadUpDisplayZOffset;
- zvalue = 1.0f - ZNear/zvalue;
+ zvalue = 65536 - vertices->Z+HeadUpDisplayZOffset;
+ zvalue = 1.0 - ZNear/zvalue;
z = -zvalue;
// x *= 16.0;
@@ -106,7 +106,8 @@ switch(RenderPolygon.TranslucencyMode)
glColor4ub(vertices->R, vertices->G, vertices->B, vertices->A);
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();
diff --git a/src/win95/platform.h b/src/win95/platform.h
index ec5085b..0c3bcab 100644
--- a/src/win95/platform.h
+++ b/src/win95/platform.h
@@ -596,21 +596,6 @@ typedef enum {
#define gt3poly_vsize 6
-
-/*
-
- Triangle Array Structure
-
-*/
-
-typedef struct trianglearray {
-
- int TA_NumTriangles;
- int *TA_ItemPtr;
- int *TA_TriangleArray[maxarrtriangles];
-
-} TRIANGLEARRAY;
-
/*
Function prototypes
*/