foxygit / doom Log in
commit f8b216522bb4a2f2a8279412ff949955706d727e
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Wed Oct 1 18:00:13 2008 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Wed Oct 1 18:00:13 2008 +0000

    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
---
 src/hexen/am_map.c   |   9 +++--
 src/hexen/d_net.c    |  14 +++++--
 src/hexen/f_finale.c |   6 ++-
 src/hexen/g_game.c   |   3 ++
 src/hexen/h2_main.c  |  31 +++++----------
 src/hexen/h2def.h    | 110 ++++-----------------------------------------------
 src/hexen/i_ibm.c    |   1 +
 src/hexen/i_sound.c  |   1 +
 src/hexen/in_lude.c  |   4 +-
 src/hexen/m_misc.c   |   1 +
 src/hexen/mn_menu.c  |   4 +-
 src/hexen/p_acs.c    |   1 +
 src/hexen/p_anim.c   |   1 +
 src/hexen/p_enemy.c  |   1 +
 src/hexen/p_floor.c  |   1 +
 src/hexen/p_inter.c  |   1 +
 src/hexen/p_map.c    |   1 +
 src/hexen/p_maputl.c |   1 +
 src/hexen/p_mobj.c   |   1 +
 src/hexen/p_plats.c  |   1 +
 src/hexen/p_setup.c  |   1 +
 src/hexen/p_spec.c   |   1 +
 src/hexen/p_switch.c |   1 +
 src/hexen/p_telept.c |   1 +
 src/hexen/p_user.c   |   1 +
 src/hexen/po_man.c   |   1 +
 src/hexen/r_bsp.c    |   1 +
 src/hexen/r_data.c   |   1 +
 src/hexen/r_draw.c   |   8 ++--
 src/hexen/r_local.h  |   2 +
 src/hexen/r_plane.c  |   1 +
 src/hexen/r_segs.c   |   1 +
 src/hexen/r_things.c |   1 +
 src/hexen/sb_bar.c   |  22 +++++------
 src/hexen/sc_man.c   |   1 +
 src/hexen/sn_sonix.c |   1 +
 src/hexen/st_start.c |   1 +
 src/hexen/sv_save.c  |   1 +
 src/hexen/v_video.c  |   2 +
 39 files changed, 94 insertions(+), 148 deletions(-)

diff --git a/src/hexen/am_map.c b/src/hexen/am_map.c
index a0a1703e..06fc9490 100644
--- 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 @@ void AM_initVariables(void)
     //static event_t st_notify = { ev_keyup, AM_MSGENTERED };

     automapactive = true;
-    fb = screen;
+    fb = I_VideoBuffer;

     f_oldloc.x = INT_MAX;
     amclock = 0;
@@ -683,16 +684,16 @@ void AM_clearFB(int color)
     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)
             j = 0;
     }

-//       memcpy(screen, maplump, finit_width*finit_height);
+//       memcpy(I_VideoBuffer, maplump, finit_width*finit_height);
 //  memset(fb, color, f_w*f_h);
 }

diff --git a/src/hexen/d_net.c b/src/hexen/d_net.c
index 25819f02..086b685f 100644
--- 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 @@ void CheckAbort(void)
         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.");
     }
diff --git a/src/hexen/f_finale.c b/src/hexen/f_finale.c
index 644efb5d..691c0683 100644
--- 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 @@ static void TextWrite(void)
     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 FadePic(void)

 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
diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c
index 1fcceee3..d86f7d93 100644
--- 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"
diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c
index 603b2f47..c3d42c5a 100644
--- 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 @@ int startmap;
 boolean autostart;
 boolean advancedemo;
 FILE *debugfile;
-event_t events[MAXEVENTS];
-int eventhead;
-int eventtail;

 // PRIVATE DATA DEFINITIONS ------------------------------------------------

@@ -536,10 +534,15 @@ void H2_ProcessEvents(void)
 {
     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;
@@ -552,20 +555,6 @@ void H2_ProcessEvents(void)
     }
 }

-//==========================================================================
-//
-// 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 @@ static void DrawAndBlit(void)
     NetUpdate();

     // Flush buffered stuff to screen
-    I_Update();
+    I_FinishUpdate();
 }

 //==========================================================================
diff --git a/src/hexen/h2def.h b/src/hexen/h2def.h
index c688519e..cdd1c0a8 100644
--- 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 @@ typedef enum
     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 @@ void NET_SendFrags(player_t * player);

 #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 @@ void H2_GameLoop(void);
 // 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 @@ void TryRunTics(void);
 //---------
 //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

diff --git a/src/hexen/i_ibm.c b/src/hexen/i_ibm.c
index e5fda74b..a4f2ce9b 100644
--- 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
diff --git a/src/hexen/i_sound.c b/src/hexen/i_sound.c
index 1f89c932..cca8765a 100644
--- 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"
diff --git a/src/hexen/in_lude.c b/src/hexen/in_lude.c
index 8de5acbb..b22c4c3e 100644
--- 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 @@ void IN_Drawer(void)
         return;
     }
     UpdateState |= I_FULLSCRN;
-    memcpy(screen, (byte *) patchINTERPIC, SCREENWIDTH * SCREENHEIGHT);
+    memcpy(I_VideoBuffer, (byte *) patchINTERPIC, SCREENWIDTH * SCREENHEIGHT);

     if (gametype == SINGLE)
     {
diff --git a/src/hexen/m_misc.c b/src/hexen/m_misc.c
index 0d38941a..02287cd2 100644
--- 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"
diff --git a/src/hexen/mn_menu.c b/src/hexen/mn_menu.c
index aa5decd8..b6c45526 100644
--- 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_DeactivateMenu(void)
 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,
diff --git a/src/hexen/p_acs.c b/src/hexen/p_acs.c
index bf79e261..ae52cb2d 100644
--- 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 ------------------------------------------------------------------
diff --git a/src/hexen/p_anim.c b/src/hexen/p_anim.c
index 57cdf099..298a0fc8 100644
--- 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 ------------------------------------------------------------------
diff --git a/src/hexen/p_enemy.c b/src/hexen/p_enemy.c
index 24cbefaf..58954aae 100644
--- 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"
diff --git a/src/hexen/p_floor.c b/src/hexen/p_floor.c
index ba72336a..1ea3cba9 100644
--- 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"

diff --git a/src/hexen/p_inter.c b/src/hexen/p_inter.c
index ab6b9501..a539eb64 100644
--- 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"

diff --git a/src/hexen/p_map.c b/src/hexen/p_map.c
index e573ef07..410355a2 100644
--- 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"
diff --git a/src/hexen/p_maputl.c b/src/hexen/p_maputl.c
index e15fe3a0..854c67c0 100644
--- 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"

diff --git a/src/hexen/p_mobj.c b/src/hexen/p_mobj.c
index 4a840dfd..51eddce1 100644
--- 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"
diff --git a/src/hexen/p_plats.c b/src/hexen/p_plats.c
index ced14141..af950315 100644
--- 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"

diff --git a/src/hexen/p_setup.c b/src/hexen/p_setup.c
index 0863226a..45c85625 100644
--- 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"
diff --git a/src/hexen/p_spec.c b/src/hexen/p_spec.c
index eb221438..40ad8126 100644
--- 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"

diff --git a/src/hexen/p_switch.c b/src/hexen/p_switch.c
index c534d516..cad47d55 100644
--- 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"

diff --git a/src/hexen/p_telept.c b/src/hexen/p_telept.c
index 746938ce..506dba1e 100644
--- 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"

diff --git a/src/hexen/p_user.c b/src/hexen/p_user.c
index 2086bdd2..2d360e47 100644
--- 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"

diff --git a/src/hexen/po_man.c b/src/hexen/po_man.c
index ff06b198..4214e785 100644
--- 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"
diff --git a/src/hexen/r_bsp.c b/src/hexen/r_bsp.c
index 0e140a1c..624c8c13 100644
--- 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"

diff --git a/src/hexen/r_data.c b/src/hexen/r_data.c
index 61c3f1cd..927b6419 100644
--- 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"
diff --git a/src/hexen/r_draw.c b/src/hexen/r_draw.c
index 9cf3f45a..9a3264f6 100644
--- 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 @@ void R_InitBuffer(int width, int height)
     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 @@ void R_DrawViewBorder(void)
         return;

     src = W_CacheLumpName("F_022", PU_CACHE);
-    dest = screen;
+    dest = I_VideoBuffer;

     for (y = 0; y < SCREENHEIGHT - SBARHEIGHT; y++)
     {
@@ -560,7 +562,7 @@ void R_DrawTopBorder(void)
 	}
 */
     src = W_CacheLumpName("F_022", PU_CACHE);
-    dest = screen;
+    dest = I_VideoBuffer;

     for (y = 0; y < 34; y++)
     {
diff --git a/src/hexen/r_local.h b/src/hexen/r_local.h
index ee66196c..8e04af32 100644
--- 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
diff --git a/src/hexen/r_plane.c b/src/hexen/r_plane.c
index dbdc2b43..deebdf80 100644
--- 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 ------------------------------------------------------------------
diff --git a/src/hexen/r_segs.c b/src/hexen/r_segs.c
index 4eef6040..353aaa21 100644
--- 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
diff --git a/src/hexen/r_things.c b/src/hexen/r_things.c
index 09cde03c..956c8a96 100644
--- 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"

diff --git a/src/hexen/sb_bar.c b/src/hexen/sb_bar.c
index 343a04c8..bc9c63cd 100644
--- 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 @@ static void CheatTrackFunc2(player_t * player, Cheat_t * cheat);

 // EXTERNAL DATA DECLARATIONS ----------------------------------------------

-extern byte *screen;
 extern int ArmorIncrement[NUMCLASSES][NUMARMOR];
 extern int AutoArmorSave[NUMCLASSES];

@@ -838,7 +838,7 @@ static void ShadeLine(int x, int y, int height, int shade)
 	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 @@ void DrawMainBar(void)
         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 @@ void Draw_TeleportIcon(void)
     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 @@ void Draw_SaveIcon(void)
     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 @@ void Draw_LoadIcon(void)
     patch = W_CacheLumpNum(W_GetNumForName("loadicon"), PU_CACHE);
     V_DrawPatch(100, 68, patch);
     UpdateState |= I_FULLSCRN;
-    I_Update();
+    I_FinishUpdate();
     UpdateState |= I_FULLSCRN;
 }

diff --git a/src/hexen/sc_man.c b/src/hexen/sc_man.c
index 63afb3cb..a0156095 100644
--- 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 ------------------------------------------------------------------
diff --git a/src/hexen/sn_sonix.c b/src/hexen/sn_sonix.c
index 625176dd..b1d02fe5 100644
--- 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 ------------------------------------------------------------------
diff --git a/src/hexen/st_start.c b/src/hexen/st_start.c
index 54ab9006..317bf7bd 100644
--- 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"


diff --git a/src/hexen/sv_save.c b/src/hexen/sv_save.c
index 132b28c9..a69cdd71 100644
--- 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"
diff --git a/src/hexen/v_video.c b/src/hexen/v_video.c
index 11cca066..a763a639 100644
--- 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