shithub: choc

Download patch

ref: f8b216522bb4a2f2a8279412ff949955706d727e
parent: bf5e84859e2aca7f543f88a4a93bb971332aa989
author: Simon Howard <[email protected]>
date: Wed Oct 1 14:00:13 EDT 2008

Use common versions of ticcmd_t and event_t for Hexen code. Remove old
i_video definitions and use common i_video.c interface.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1312

--- a/src/hexen/am_map.c
+++ b/src/hexen/am_map.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_video.h"
 #include "i_swap.h"
 #include "p_local.h"
 #include "am_map.h"
@@ -275,7 +276,7 @@
     //static event_t st_notify = { ev_keyup, AM_MSGENTERED };
 
     automapactive = true;
-    fb = screen;
+    fb = I_VideoBuffer;
 
     f_oldloc.x = INT_MAX;
     amclock = 0;
@@ -683,9 +684,9 @@
     j = mapystart * finit_width;
     for (i = 0; i < SCREENHEIGHT - SBARHEIGHT; i++)
     {
-        memcpy(screen + i * finit_width, maplump + j + mapxstart,
+        memcpy(I_VideoBuffer + i * finit_width, maplump + j + mapxstart,
                finit_width - mapxstart);
-        memcpy(screen + i * finit_width + finit_width - mapxstart,
+        memcpy(I_VideoBuffer + i * finit_width + finit_width - mapxstart,
                maplump + j, mapxstart);
         j += finit_width;
         if (j >= finit_height * finit_width)
@@ -692,7 +693,7 @@
             j = 0;
     }
 
-//       memcpy(screen, maplump, finit_width*finit_height);
+//       memcpy(I_VideoBuffer, maplump, finit_width*finit_height);
 //  memset(fb, color, f_w*f_h);
 }
 
--- a/src/hexen/d_net.c
+++ b/src/hexen/d_net.c
@@ -23,6 +23,9 @@
 
 
 #include "h2def.h"
+#include "i_video.h"
+#include "i_system.h"
+#include "i_timer.h"
 #include "m_argv.h"
 #include "p_local.h"
 #include <stdlib.h>             // for atoi()
@@ -517,10 +520,15 @@
         I_StartTic();
 
     I_StartTic();
-    for (; eventtail != eventhead;
-         eventtail = (eventtail + 1) & (MAXEVENTS - 1))
+    for (;;)
     {
-        ev = &events[eventtail];
+        ev = D_PopEvent();
+
+        if (ev == NULL)
+        {
+            break;
+        }
+
         if (ev->type == ev_keydown && ev->data1 == KEY_ESCAPE)
             I_Error("Network game synchronization aborted.");
     }
--- a/src/hexen/f_finale.c
+++ b/src/hexen/f_finale.c
@@ -25,6 +25,8 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "i_system.h"
+#include "i_video.h"
 #include "soundst.h"
 #include "p_local.h"
 #include <ctype.h>
@@ -173,7 +175,7 @@
     int cx, cy;
     patch_t *w;
 
-    memcpy(screen, W_CacheLumpNum(FinaleLumpNum, PU_CACHE),
+    memcpy(I_VideoBuffer, W_CacheLumpNum(FinaleLumpNum, PU_CACHE),
            SCREENWIDTH * SCREENHEIGHT);
     if (FinaleStage == 5)
     {                           // Chess pic, draw the correct character graphic
@@ -314,7 +316,7 @@
 
 static void DrawPic(void)
 {
-    memcpy(screen, W_CacheLumpNum(FinaleLumpNum, PU_CACHE),
+    memcpy(I_VideoBuffer, W_CacheLumpNum(FinaleLumpNum, PU_CACHE),
            SCREENWIDTH * SCREENHEIGHT);
     if (FinaleStage == 4 || FinaleStage == 5)
     {                           // Chess pic, draw the correct character graphic
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -24,6 +24,9 @@
 
 #include <string.h>
 #include "h2def.h"
+#include "i_video.h"
+#include "i_system.h"
+#include "i_timer.h"
 #include "m_misc.h"
 #include "p_local.h"
 #include "soundst.h"
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -33,6 +33,7 @@
 #include <stdlib.h>
 #include <time.h>
 #include "h2def.h"
+#include "i_system.h"
 #include "m_argv.h"
 #include "p_local.h"
 #include "soundst.h"
@@ -118,9 +119,6 @@
 boolean autostart;
 boolean advancedemo;
 FILE *debugfile;
-event_t events[MAXEVENTS];
-int eventhead;
-int eventtail;
 
 // PRIVATE DATA DEFINITIONS ------------------------------------------------
 
@@ -536,10 +534,15 @@
 {
     event_t *ev;
 
-    for (; eventtail != eventhead;
-         eventtail = (eventtail + 1) & (MAXEVENTS - 1))
+    for (;;)
     {
-        ev = &events[eventtail];
+        ev = D_PopEvent();
+
+        if (ev == NULL)
+        {
+            break;
+        }
+
         if (F_Responder(ev))
         {
             continue;
@@ -554,20 +557,6 @@
 
 //==========================================================================
 //
-// H2_PostEvent
-//
-// Called by the I/O functions when input is detected.
-//
-//==========================================================================
-
-void H2_PostEvent(event_t * ev)
-{
-    events[eventhead] = *ev;
-    eventhead = (eventhead + 1) & (MAXEVENTS - 1);
-}
-
-//==========================================================================
-//
 // DrawAndBlit
 //
 //==========================================================================
@@ -634,7 +623,7 @@
     NetUpdate();
 
     // Flush buffered stuff to screen
-    I_Update();
+    I_FinishUpdate();
 }
 
 //==========================================================================
--- a/src/hexen/h2def.h
+++ b/src/hexen/h2def.h
@@ -36,6 +36,14 @@
 #define	strncasecmp strnicmp
 #endif
 
+// ticcmd:
+
+#include "d_ticcmd.h"
+
+// events
+
+#include "d_event.h"
+
 // for fixed_t:
 
 #include "m_fixed.h"
@@ -159,34 +167,6 @@
     sk_nightmare
 } skill_t;
 
-typedef enum
-{
-    ev_keydown,
-    ev_keyup,
-    ev_mouse,
-    ev_joystick
-} evtype_t;
-
-typedef struct
-{
-    evtype_t type;
-    int data1;                  // keys / mouse/joystick buttons
-    int data2;                  // mouse/joystick x move
-    int data3;                  // mouse/joystick y move
-} event_t;
-
-typedef struct
-{
-    char forwardmove;           // *2048 for move
-    char sidemove;              // *2048 for move
-    short angleturn;            // <<16 for angle delta
-    short consistancy;          // checks for net game
-    byte chatchar;
-    byte buttons;
-    byte lookfly;               // look/fly up/down/centering
-    byte arti;                  // artitype_t to use
-} ticcmd_t;
-
 #define	BT_ATTACK		1
 #define	BT_USE			2
 #define	BT_CHANGE		4       // if true, the next 3 bits hold weapon num
@@ -728,12 +708,6 @@
 
 #define TELEFOGHEIGHT (32*FRACUNIT)
 
-#define MAXEVENTS 64
-
-extern event_t events[MAXEVENTS];
-extern int eventhead;
-extern int eventtail;
-
 extern gameaction_t gameaction;
 
 extern boolean paused;
@@ -864,9 +838,6 @@
 // calls all ?_Responder, ?_Ticker, and ?_Drawer functions
 // calls I_GetTime, I_StartFrame, and I_StartTic
 
-void H2_PostEvent(event_t * ev);
-// called by IO functions when input is detected
-
 void NetUpdate(void);
 // create any new ticcmds and broadcast to other players
 
@@ -878,71 +849,6 @@
 //---------
 //SYSTEM IO
 //---------
-#if 1
-#define	SCREENWIDTH		320
-#define	SCREENHEIGHT	200
-#else
-#define	SCREENWIDTH		560
-#define	SCREENHEIGHT	375
-#endif
-
-byte *I_ZoneBase(int *size);
-// called by startup code to get the ammount of memory to malloc
-// for the zone management
-
-int I_GetTime(void);
-// called by H2_GameLoop
-// returns current time in tics
-
-void I_StartFrame(void);
-// called by H2_GameLoop
-// called before processing any tics in a frame (just after displaying a frame)
-// time consuming syncronous operations are performed here (joystick reading)
-// can call H2_PostEvent
-
-void I_StartTic(void);
-// called by H2_GameLoop
-// called before processing each tic in a frame
-// quick syncronous operations are performed here
-// can call H2_PostEvent
-
-// asyncronous interrupt functions should maintain private ques that are
-// read by the syncronous functions to be converted into events
-
-void I_Init(void);
-// called by H2_Main
-// determines the hardware configuration and sets up the video mode
-
-void I_InitGraphics(void);
-
-void I_InitNetwork(void);
-void I_NetCmd(void);
-
-void I_CheckExternDriver(void);
-
-void I_Error(char *error, ...);
-// called by anything that can generate a terminal error
-// bad exit with diagnostic message
-
-void I_Quit(void);
-// called by M_Responder when quit is selected
-// clean exit, displays sell blurb
-
-void I_SetPalette(byte * palette);
-// takes full 8 bit values
-
-void I_Update(void);
-// Copy buffer to video
-
-void I_WipeUpdate(wipe_t wipe);
-// Copy buffer to video with wipe effect
-
-void I_WaitVBL(int count);
-// wait for vertical retrace or pause a bit
-
-void I_BeginRead(void);
-void I_EndRead(void);
-
 byte *I_AllocLow(int length);
 // allocates from low memory under dos, just mallocs under unix
 
--- a/src/hexen/i_ibm.c
+++ b/src/hexen/i_ibm.c
@@ -28,6 +28,7 @@
 #include <stdarg.h>
 #include <graph.h>
 #include "h2def.h"
+#include "i_system.h"
 #include "m_argv.h"
 #include "r_local.h"
 #include "p_local.h"            // for P_AproxDistance
--- a/src/hexen/i_sound.c
+++ b/src/hexen/i_sound.c
@@ -25,6 +25,7 @@
 
 #include <stdio.h>
 #include "h2def.h"
+#include "i_system.h"
 #include "m_argv.h"
 #include "dmx.h"
 #include "sounds.h"
--- a/src/hexen/in_lude.c
+++ b/src/hexen/in_lude.c
@@ -23,6 +23,8 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
+#include "i_video.h"
 #include <ctype.h>
 
 // MACROS ------------------------------------------------------------------
@@ -404,7 +406,7 @@
         return;
     }
     UpdateState |= I_FULLSCRN;
-    memcpy(screen, (byte *) patchINTERPIC, SCREENWIDTH * SCREENHEIGHT);
+    memcpy(I_VideoBuffer, (byte *) patchINTERPIC, SCREENWIDTH * SCREENHEIGHT);
 
     if (gametype == SINGLE)
     {
--- a/src/hexen/m_misc.c
+++ b/src/hexen/m_misc.c
@@ -34,6 +34,7 @@
 #endif
 #include <ctype.h>
 #include "h2def.h"
+#include "i_system.h"
 #include "m_argv.h"
 #include "p_local.h"
 #include "soundst.h"
--- a/src/hexen/mn_menu.c
+++ b/src/hexen/mn_menu.c
@@ -26,6 +26,8 @@
 
 #include <ctype.h>
 #include "h2def.h"
+#include "i_system.h"
+#include "i_video.h"
 #include "p_local.h"
 #include "r_local.h"
 #include "soundst.h"
@@ -1688,7 +1690,7 @@
 void MN_DrawInfo(void)
 {
     I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE));
-    memcpy(screen,
+    memcpy(I_VideoBuffer,
            (byte *) W_CacheLumpNum(W_GetNumForName("TITLE") + InfoType,
                                    PU_CACHE), SCREENWIDTH * SCREENHEIGHT);
 //      V_DrawPatch(0, 0, W_CacheLumpNum(W_GetNumForName("TITLE")+InfoType,
--- a/src/hexen/p_acs.c
+++ b/src/hexen/p_acs.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "i_system.h"
 #include "p_local.h"
 
 // MACROS ------------------------------------------------------------------
--- a/src/hexen/p_anim.c
+++ b/src/hexen/p_anim.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "i_system.h"
 #include "p_local.h"
 
 // MACROS ------------------------------------------------------------------
--- a/src/hexen/p_enemy.c
+++ b/src/hexen/p_enemy.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "i_swap.h"
 #include "p_local.h"
 #include "soundst.h"
--- a/src/hexen/p_floor.c
+++ b/src/hexen/p_floor.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "p_local.h"
 #include "soundst.h"
 
--- a/src/hexen/p_inter.c
+++ b/src/hexen/p_inter.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "p_local.h"
 #include "soundst.h"
 
--- a/src/hexen/p_map.c
+++ b/src/hexen/p_map.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "m_bbox.h"
 #include "p_local.h"
 #include "soundst.h"
--- a/src/hexen/p_maputl.c
+++ b/src/hexen/p_maputl.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "m_bbox.h"
 #include "p_local.h"
 
--- a/src/hexen/p_mobj.c
+++ b/src/hexen/p_mobj.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "i_system.h"
 #include "p_local.h"
 #include "sounds.h"
 #include "soundst.h"
--- a/src/hexen/p_plats.c
+++ b/src/hexen/p_plats.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "p_local.h"
 #include "soundst.h"
 
--- a/src/hexen/p_setup.c
+++ b/src/hexen/p_setup.c
@@ -27,6 +27,7 @@
 #include <math.h>
 #include <stdlib.h>
 #include "h2def.h"
+#include "i_system.h"
 #include "m_argv.h"
 #include "m_bbox.h"
 #include "i_swap.h"
--- a/src/hexen/p_spec.c
+++ b/src/hexen/p_spec.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "i_system.h"
 #include "p_local.h"
 #include "soundst.h"
 
--- a/src/hexen/p_switch.c
+++ b/src/hexen/p_switch.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "p_local.h"
 #include "soundst.h"
 
--- a/src/hexen/p_telept.c
+++ b/src/hexen/p_telept.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "i_system.h"
 #include "p_local.h"
 #include "soundst.h"
 
--- a/src/hexen/p_user.c
+++ b/src/hexen/p_user.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "p_local.h"
 #include "soundst.h"
 
--- a/src/hexen/po_man.c
+++ b/src/hexen/po_man.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "i_system.h"
 #include "m_bbox.h"
 #include "i_swap.h"
 #include "p_local.h"
--- a/src/hexen/r_bsp.c
+++ b/src/hexen/r_bsp.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "m_bbox.h"
 #include "r_local.h"
 
--- a/src/hexen/r_data.c
+++ b/src/hexen/r_data.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "i_swap.h"
 #include "r_local.h"
 #include "p_local.h"
--- a/src/hexen/r_draw.c
+++ b/src/hexen/r_draw.c
@@ -23,6 +23,8 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
+#include "i_video.h"
 #include "r_local.h"
 
 /*
@@ -470,7 +472,7 @@
     else
         viewwindowy = (SCREENHEIGHT - SBARHEIGHT - height) >> 1;
     for (i = 0; i < height; i++)
-        ylookup[i] = screen + (i + viewwindowy) * SCREENWIDTH;
+        ylookup[i] = I_VideoBuffer + (i + viewwindowy) * SCREENWIDTH;
 }
 
 
@@ -494,7 +496,7 @@
         return;
 
     src = W_CacheLumpName("F_022", PU_CACHE);
-    dest = screen;
+    dest = I_VideoBuffer;
 
     for (y = 0; y < SCREENHEIGHT - SBARHEIGHT; y++)
     {
@@ -560,7 +562,7 @@
 	}
 */
     src = W_CacheLumpName("F_022", PU_CACHE);
-    dest = screen;
+    dest = I_VideoBuffer;
 
     for (y = 0; y < 34; y++)
     {
--- a/src/hexen/r_local.h
+++ b/src/hexen/r_local.h
@@ -25,6 +25,8 @@
 #ifndef __R_LOCAL__
 #define __R_LOCAL__
 
+#include "i_video.h"
+
 #define ANGLETOSKYSHIFT         22      // sky map is 256*128*4 maps
 
 #define BASEYCENTER                     100
--- a/src/hexen/r_plane.c
+++ b/src/hexen/r_plane.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "i_system.h"
 #include "r_local.h"
 
 // MACROS ------------------------------------------------------------------
--- a/src/hexen/r_segs.c
+++ b/src/hexen/r_segs.c
@@ -23,6 +23,7 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
 #include "r_local.h"
 
 // OPTIMIZE: closed two sided lines as single sided
--- a/src/hexen/r_things.c
+++ b/src/hexen/r_things.c
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "h2def.h"
+#include "i_system.h"
 #include "i_swap.h"
 #include "r_local.h"
 
--- a/src/hexen/sb_bar.c
+++ b/src/hexen/sb_bar.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "i_video.h"
 #include "m_bbox.h"
 #include "p_local.h"
 #include "soundst.h"
@@ -108,7 +109,6 @@
 
 // EXTERNAL DATA DECLARATIONS ----------------------------------------------
 
-extern byte *screen;
 extern int ArmorIncrement[NUMCLASSES][NUMARMOR];
 extern int AutoArmorSave[NUMCLASSES];
 
@@ -838,7 +838,7 @@
 	byte *shades;
 
 	shades = colormaps+9*256+shade*2*256;
-	dest = screen+y*SCREENWIDTH+x;
+	dest = I_VideoBuffer+y*SCREENWIDTH+x;
 	while(height--)
 	{
 		*(dest) = *(shades+*dest);
@@ -1421,16 +1421,16 @@
         V_DrawPatch(94, 164, manaVialPatch1);
         for (i = 165; i < 187 - (22 * CPlayer->mana[0]) / MAX_MANA; i++)
         {
-            screen[i * SCREENWIDTH + 95] = 0;
-            screen[i * SCREENWIDTH + 96] = 0;
-            screen[i * SCREENWIDTH + 97] = 0;
+            I_VideoBuffer[i * SCREENWIDTH + 95] = 0;
+            I_VideoBuffer[i * SCREENWIDTH + 96] = 0;
+            I_VideoBuffer[i * SCREENWIDTH + 97] = 0;
         }
         V_DrawPatch(102, 164, manaVialPatch2);
         for (i = 165; i < 187 - (22 * CPlayer->mana[1]) / MAX_MANA; i++)
         {
-            screen[i * SCREENWIDTH + 103] = 0;
-            screen[i * SCREENWIDTH + 104] = 0;
-            screen[i * SCREENWIDTH + 105] = 0;
+            I_VideoBuffer[i * SCREENWIDTH + 103] = 0;
+            I_VideoBuffer[i * SCREENWIDTH + 104] = 0;
+            I_VideoBuffer[i * SCREENWIDTH + 105] = 0;
         }
         oldweapon = CPlayer->readyweapon;
         UpdateState |= I_STATBAR;
@@ -1697,7 +1697,7 @@
     patch = W_CacheLumpNum(W_GetNumForName("teleicon"), PU_CACHE);
     V_DrawPatch(100, 68, patch);
     UpdateState |= I_FULLSCRN;
-    I_Update();
+    I_FinishUpdate();
     UpdateState |= I_FULLSCRN;
 }
 
@@ -1712,7 +1712,7 @@
     patch = W_CacheLumpNum(W_GetNumForName("saveicon"), PU_CACHE);
     V_DrawPatch(100, 68, patch);
     UpdateState |= I_FULLSCRN;
-    I_Update();
+    I_FinishUpdate();
     UpdateState |= I_FULLSCRN;
 }
 
@@ -1727,7 +1727,7 @@
     patch = W_CacheLumpNum(W_GetNumForName("loadicon"), PU_CACHE);
     V_DrawPatch(100, 68, patch);
     UpdateState |= I_FULLSCRN;
-    I_Update();
+    I_FinishUpdate();
     UpdateState |= I_FULLSCRN;
 }
 
--- a/src/hexen/sc_man.c
+++ b/src/hexen/sc_man.c
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include "h2def.h"
+#include "i_system.h"
 #include "m_misc.h"
 
 // MACROS ------------------------------------------------------------------
--- a/src/hexen/sn_sonix.c
+++ b/src/hexen/sn_sonix.c
@@ -26,6 +26,7 @@
 
 #include <string.h>
 #include "h2def.h"
+#include "i_system.h"
 #include "soundst.h"
 
 // MACROS ------------------------------------------------------------------
--- a/src/hexen/st_start.c
+++ b/src/hexen/st_start.c
@@ -33,6 +33,7 @@
 #endif
 
 #include "h2def.h"
+#include "i_system.h"
 #include "st_start.h"
 
 
--- a/src/hexen/sv_save.c
+++ b/src/hexen/sv_save.c
@@ -25,6 +25,7 @@
 // HEADER FILES ------------------------------------------------------------
 
 #include "h2def.h"
+#include "i_system.h"
 #include "m_misc.h"
 #include "i_swap.h"
 #include "p_local.h"
--- a/src/hexen/v_video.c
+++ b/src/hexen/v_video.c
@@ -23,6 +23,8 @@
 
 
 #include "h2def.h"
+#include "i_system.h"
+#include "i_video.h"
 #include "i_swap.h"
 
 #define SC_INDEX 0x3c4