summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-05-27 15:16:06 +0000
committercinap_lenrek <cinap_lenrek@localhost>2011-05-27 15:16:06 +0000
commit9bb72cc699a6eaf192df2df56715d2245f4b5118 (patch)
treeee2ed70d00423503d831241f94e56990e583b633
parentddfc34d648ca21ff2c1eeab72cee2a960b8357fc (diff)
ac97: max buffer should be full samples, games/doom: enable/disable mouse grabbing when switching to the menu
-rw-r--r--sys/src/9/pc/audioac97.c2
-rw-r--r--sys/src/games/doom/i_system.c1
-rw-r--r--sys/src/games/doom/i_video.c34
-rw-r--r--sys/src/games/doom/i_video.h2
-rw-r--r--sys/src/games/doom/m_menu.c6
5 files changed, 28 insertions, 17 deletions
diff --git a/sys/src/9/pc/audioac97.c b/sys/src/9/pc/audioac97.c
index ca0028bf8..ba8ff6777 100644
--- a/sys/src/9/pc/audioac97.c
+++ b/sys/src/9/pc/audioac97.c
@@ -139,7 +139,7 @@ available(Ring *r)
{
long m;
- m = (r->nbuf - 1) - buffered(r);
+ m = (r->nbuf - BytesPerSample) - buffered(r);
if(m < 0)
m = 0;
return m;
diff --git a/sys/src/games/doom/i_system.c b/sys/src/games/doom/i_system.c
index a4a03da04..347d13d2f 100644
--- a/sys/src/games/doom/i_system.c
+++ b/sys/src/games/doom/i_system.c
@@ -17,6 +17,7 @@ void I_Init (void)
{
I_InitSound();
I_InitGraphics();
+ I_MouseEnable(1);
}
byte* I_ZoneBase (int *size)
diff --git a/sys/src/games/doom/i_video.c b/sys/src/games/doom/i_video.c
index 5c9b1e1ff..1f68f1389 100644
--- a/sys/src/games/doom/i_video.c
+++ b/sys/src/games/doom/i_video.c
@@ -10,6 +10,7 @@
#include <keyboard.h>
static int resized;
+static int mouseactive;
static Rectangle grabout;
static Point center;
@@ -19,19 +20,6 @@ static void mouseproc(void*);
static uchar cmap[3*256];
-static void
-nocursor(void)
-{
- char curs[2*4+2*2*16];
- int fd;
-
- if((fd = open("/dev/cursor", ORDWR|OCEXEC)) < 0)
- return;
- memset(curs, 0, sizeof curs);
- write(fd, curs, sizeof curs);
-}
-
-
void I_InitGraphics(void)
{
if(initdraw(nil, nil, "doom") < 0)
@@ -41,7 +29,6 @@ void I_InitGraphics(void)
center = addpt(screen->r.min, Pt(Dx(screen->r)/2, Dy(screen->r)/2));
grabout = insetrect(screen->r, Dx(screen->r)/8);
- nocursor();
proccreate(kbdproc, nil, 8*1024);
proccreate(mouseproc, nil, 8*1024);
@@ -131,6 +118,22 @@ void I_FinishUpdate(void)
flushimage(display, 1);
}
+void I_MouseEnable(int on)
+{
+ static char nocurs[2*4+2*2*16];
+ static int fd = -1;
+
+ if(mouseactive == on)
+ return;
+ if(mouseactive = on){
+ if((fd = open("/dev/cursor", ORDWR|OCEXEC)) < 0)
+ return;
+ write(fd, nocurs, sizeof(nocurs));
+ }else if(fd >= 0) {
+ close(fd);
+ fd = -1;
+ }
+}
void I_ReadScreen(byte *scr)
{
@@ -277,6 +280,9 @@ mouseproc(void *)
resized = 1;
/* fall through */
case 'm':
+ if(!mouseactive)
+ break;
+
m.xy.x = atoi(buf+1+0*12);
m.xy.y = atoi(buf+1+1*12);
m.buttons = atoi(buf+1+2*12);
diff --git a/sys/src/games/doom/i_video.h b/sys/src/games/doom/i_video.h
index ba8569b22..b671ce1a5 100644
--- a/sys/src/games/doom/i_video.h
+++ b/sys/src/games/doom/i_video.h
@@ -44,6 +44,7 @@ void I_SetPalette (byte* palette);
void I_UpdateNoBlit (void);
void I_FinishUpdate (void);
+void I_MouseEnable (int);
// Wait for vertical retrace or pause a bit.
void I_WaitVBL(int count);
@@ -54,7 +55,6 @@ void I_BeginRead (void);
void I_EndRead (void);
-
#endif
//-----------------------------------------------------------------------------
//
diff --git a/sys/src/games/doom/m_menu.c b/sys/src/games/doom/m_menu.c
index edcbc3ac5..89b8ceb84 100644
--- a/sys/src/games/doom/m_menu.c
+++ b/sys/src/games/doom/m_menu.c
@@ -1710,10 +1710,12 @@ void M_StartControlPanel (void)
// intro might call this repeatedly
if (menuactive)
return;
-
+
menuactive = 1;
currentMenu = &MainDef; // JDC
itemOn = currentMenu->lastOn; // JDC
+
+ I_MouseEnable(0); // disable mouse grab
}
@@ -1796,6 +1798,8 @@ void M_Drawer (void)
void M_ClearMenus (void)
{
menuactive = 0;
+ I_MouseEnable(1); // enable mouse grabbing
+
// if (!netgame && usergame && paused)
// sendpause = true;
}