X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fmemory.c;h=5be719f55d45d1741146a21e3341a5a1d97be3b1;hb=cedb3138dd71d6e297c9b82af7cf2053ab73ea09;hp=23e5cbd3634f7541950dfcd6ce9834496cf8dc6a;hpb=a2115940e7643dcb1b87286f3d19fe95f7b79bd3;p=flatwaifu.git diff --git a/src/memory.c b/src/memory.c index 23e5cbd..5be719f 100644 --- a/src/memory.c +++ b/src/memory.c @@ -1,7 +1,6 @@ /* Copyright (C) Prikol Software 1996-1997 Copyright (C) Aleksey Volynskov 1996-1997 - Copyright (C) 2011 This file is part of the Doom2D:Rembo project. @@ -23,24 +22,16 @@ #include "glob.h" #include #include -#include #include #include "error.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]; -void M_startup(void) { +void M_startup (void) { if(m_active) return; logo("M_startup: настройка памяти\n"); memset(resp,0,sizeof(resp)); @@ -49,13 +40,12 @@ void M_startup(void) { m_active=TRUE; } -void M_shutdown(void) { - +void M_shutdown (void) { 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=MAX_WAD) ERR_fatal("M_lock: странный номер ресурса"); @@ -83,7 +73,7 @@ void *M_lock(int h) { return resp[h]; } -void M_unlock(void *p) { +void M_unlock (void *p) { int h; if(!p) return; @@ -92,3 +82,11 @@ void M_unlock(void *p) { if(!resl[h]) return; --resl[h]; } + +int M_locked (int h) { + return (h != -1) && (h != 0xFFFF) && (resl[h & (-1 - 0x8000)] != 0); +} + +int M_was_locked (int h) { + return (h != -1) && (h != 0xFFFF) && (resp[h & (-1 - 0x8000)] != NULL); +}