X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fmemory.c;h=4abb35a167304b672ea36876c0929b28dcd262f4;hb=HEAD;hp=f1187462d2a047ffe760ae283ee3d33bc634ad36;hpb=5ffa796498caf6ade53096515965d5eec272799e;p=flatwaifu.git diff --git a/src/memory.c b/src/memory.c index f118746..9019586 100644 --- a/src/memory.c +++ b/src/memory.c @@ -15,73 +15,21 @@ * along with this program. If not, see . */ -#include "glob.h" -#include -#include -#include -#include "error.h" -#include "files.h" #include "memory.h" +#include "common/wadres.h" -static byte m_active; -static void *resp[MAX_WAD]; -static short resl[MAX_WAD]; - -void M_startup (void) { - if(m_active) return; - logo("M_startup: setup memory\n"); - memset(resp,0,sizeof(resp)); - memset(resl,0,sizeof(resl)); - // logo(" free DPMI-memory: %uK\n",dpmi_memavl()>>10); - m_active=TRUE; -} - -void M_shutdown (void) { - if(!m_active) return; - m_active=FALSE; -} - -static void allocres (int h) { - int *p,s; - - if(h>d_start && h=MAX_WAD) ERR_fatal("M_lock: invalid resource id"); - if(!resl[h]) if(!resp[h]) allocres(h); - ++resl[h]; - return resp[h]; +void *M_lock (int id) { + return WADRES_lock(id); } void M_unlock (void *p) { - int h; - - if(!p) return; - h=((int*)p)[-1]; - if(h>=MAX_WAD) ERR_fatal("M_unlock: invalid resource id"); - if(!resl[h]) return; - --resl[h]; + WADRES_unlock(p); } -int M_locked (int h) { - return (h != -1) && (h != 0xFFFF) && (resl[h] != 0); +int M_locked (int id) { + return WADRES_locked(id); } -int M_was_locked (int h) { - return (h != -1) && (h != 0xFFFF) && (resp[h] != NULL); +int M_was_locked (int id) { + return WADRES_was_locked(id); }