diff --git a/src/memory.c b/src/memory.c
index af93fa6f7b00a2af6d1a9d5bacd6d0a028e3ee00..5be719f55d45d1741146a21e3341a5a1d97be3b1 100644 (file)
--- a/src/memory.c
+++ b/src/memory.c
#include "files.h"
#include "memory.h"
#include "files.h"
#include "memory.h"
-dword dpmi_memavl(void);
-
-extern int d_start,d_end;
-
-extern mwad_t wad[];
-
-static byte m_active=FALSE;
-
+static byte m_active;
static void *resp[MAX_WAD];
static short resl[MAX_WAD];
static void *resp[MAX_WAD];
static short resl[MAX_WAD];
-void M_startup(void) {
+void M_startup (void) {
if(m_active) return;
logo("M_startup: настройка памяти\n");
memset(resp,0,sizeof(resp));
if(m_active) return;
logo("M_startup: настройка памяти\n");
memset(resp,0,sizeof(resp));
m_active=TRUE;
}
m_active=TRUE;
}
-void M_shutdown(void) {
-
+void M_shutdown (void) {
if(!m_active) return;
m_active=FALSE;
}
if(!m_active) return;
m_active=FALSE;
}
-static void allocres(int h) {
+static void allocres (int h) {
int *p,s;
if(h>d_start && h<d_end) s=1; else s=0;
int *p,s;
if(h>d_start && h<d_end) s=1; else s=0;
}else F_loadres(h,p,0,wad[h].l);
}
}else F_loadres(h,p,0,wad[h].l);
}
-void *M_lock(int h) {
+void *M_lock (int h) {
if(h==-1 || h==0xFFFF) return NULL;
h&=-1-0x8000;
if(h>=MAX_WAD) ERR_fatal("M_lock: странный номер ресурса");
if(h==-1 || h==0xFFFF) return NULL;
h&=-1-0x8000;
if(h>=MAX_WAD) ERR_fatal("M_lock: странный номер ресурса");
return resp[h];
}
return resp[h];
}
-void M_unlock(void *p) {
+void M_unlock (void *p) {
int h;
if(!p) return;
int h;
if(!p) return;
}
int M_locked (int h) {
}
int M_locked (int h) {
- h&=-1-0x8000;
- return (h != -1) && (h != 0xFFFF) && (resl[h] != 0);
+ return (h != -1) && (h != 0xFFFF) && (resl[h & (-1 - 0x8000)] != 0);
}
int M_was_locked (int h) {
}
int M_was_locked (int h) {
- h&=-1-0x8000;
- return (h != -1) && (h != 0xFFFF) && (resp[h] != NULL);
+ return (h != -1) && (h != 0xFFFF) && (resp[h & (-1 - 0x8000)] != NULL);
}
}