X-Git-Url: https://deadsoftware.ru/gitweb?p=flatwaifu.git;a=blobdiff_plain;f=src%2Fmemory.c;h=4abb35a167304b672ea36876c0929b28dcd262f4;hp=5c7953cc813ee93a99753ff327c2618352bd54da;hb=ef16dea09f87b15fc6d58fae0aa0832e0648c00e;hpb=8fb3d3f767b8e5d094e8bcbee350f4d16ab17c5a diff --git a/src/memory.c b/src/memory.c index 5c7953c..4abb35a 100644 --- a/src/memory.c +++ b/src/memory.c @@ -1,23 +1,19 @@ -/* - Copyright (C) Prikol Software 1996-1997 - Copyright (C) Aleksey Volynskov 1996-1997 - - This file is part of the Doom2D:Rembo project. - - Doom2D:Rembo is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. - - Doom2D:Rembo is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see or - write to the Free Software Foundation, Inc., - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ +/* Copyright (C) 1996-1997 Aleksey Volynskov + * Copyright (C) 2011 Rambo + * Copyright (C) 2020 SovietPony + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License ONLY. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "glob.h" #include @@ -27,18 +23,11 @@ #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)); @@ -47,13 +36,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: странный номер ресурса"); if(!resl[h]) if(!resp[h]) allocres(h); ++resl[h]; return resp[h]; } -void M_unlock(void *p) { +void M_unlock (void *p) { int h; if(!p) return; @@ -90,3 +77,11 @@ void M_unlock(void *p) { if(!resl[h]) return; --resl[h]; } + +int M_locked (int h) { + return (h != -1) && (h != 0xFFFF) && (resl[h] != 0); +} + +int M_was_locked (int h) { + return (h != -1) && (h != 0xFFFF) && (resp[h] != NULL); +}