1 // This may look like C code, but it is really -*- C++ -*-
2
3 // ------------------------------------------------------------------
4 // The Goldware Library
5 // Copyright (C) 1990-1999 Odinn Sorensen
6 // Copyright (C) 1999-2000 Alexander S. Aganichev
7 // ------------------------------------------------------------------
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this program; if not, write to the Free
20 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 // MA 02111-1307, USA
22 // ------------------------------------------------------------------
23 // $Id: gmemall.h,v 1.2 2009/04/04 09:51:04 grsf Exp $
24 // ------------------------------------------------------------------
25 // Memory handling.
26 // ------------------------------------------------------------------
27
28 #ifndef __gmemall_h
29 #define __gmemall_h
30
31
32 // ------------------------------------------------------------------
33
34 #include <stdlib.h>
35 #include <gdefs.h>
36 #if defined(__MSDOS__)
37 #include <gmemi86.h>
38 #endif
39
40
41 // ------------------------------------------------------------------
42
43 #if defined(__MSDOS__)
44 #if defined(__WATCOMC__)
45
peek(unsigned segment,unsigned offset)46 inline short peek(unsigned segment, unsigned offset) { return *((short *)MK_FP(segment,offset)); }
peekb(unsigned segment,unsigned offset)47 inline char peekb(unsigned segment, unsigned offset) { return *((char *)MK_FP(segment,offset)); }
poke(unsigned segment,unsigned offset,short value)48 inline void poke(unsigned segment, unsigned offset, short value) { *((short *)MK_FP(segment,offset)) = value; }
pokeb(unsigned segment,unsigned offset,char value)49 inline void pokeb(unsigned segment, unsigned offset, char value) { *((char *)MK_FP(segment,offset)) = value; }
50
51 #elif defined(__DJGPP__)
52
53 #include <go32.h>
54 #include <sys/farptr.h>
55
peek(unsigned segment,unsigned offset)56 inline short peek (unsigned segment, unsigned offset) { return _farpeekw(_dos_ds, segment*16 + offset); }
peekb(unsigned segment,unsigned offset)57 inline char peekb(unsigned segment, unsigned offset) { return _farpeekb(_dos_ds, segment*16 + offset); }
poke(unsigned segment,unsigned offset,short value)58 inline void poke (unsigned segment, unsigned offset, short value) { _farpokew(_dos_ds, segment*16 + offset, value); }
pokeb(unsigned segment,unsigned offset,char value)59 inline void pokeb(unsigned segment, unsigned offset, char value) { _farpokeb(_dos_ds, segment*16 + offset, value); }
60
61 #endif
62 #endif
63
64
65 // ------------------------------------------------------------------
66
67 #define HEX_DUMP1 1
68 #define HEX_DUMP2 2
69
70 char* HexDump16(char* strbuf, const char* memptr, int limit, const char* fmt, int fmtno=0);
HexDump16(char * strbuf,const char * memptr,int limit,int fmtno)71 inline char* HexDump16(char* strbuf, const char* memptr, int limit, int fmtno) { return HexDump16(strbuf, memptr, limit, NULL, fmtno); }
72
73
74 // ------------------------------------------------------------------
75
76 #endif
77
78 // ------------------------------------------------------------------
79