home *** CD-ROM | disk | FTP | other *** search
/ Emulator Universe CD / emulatoruniversecd1998.iso / Speccy / Emulators / winemu / SOURCES / Z80 / MEM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-21  |  3.1 KB  |  96 lines

  1. /* Mem.c: Z80 memory - basic support routines.
  2.  *
  3.  * Copyright 1996 Rui Fernando Ferreira Ribeiro.
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. /*
  21.  *                        EmuZ80 v1.0
  22.  *            (c) 1996 Rui Fernando Ferreira Ribeiro
  23.  *
  24.  * -------------------------------------------------------
  25.  *
  26.  * MEM.C : Z80's memory - low level routines
  27.  *
  28.  */
  29.  
  30. #include <alloc.h>
  31. #include "env.h"
  32.  
  33. static UCHAR inited = 0;
  34.  
  35.  
  36. #if !defined(NDEBUG)
  37. extern UCHAR running;
  38. #endif
  39.  
  40. /*=========================================================================*
  41.  *                            writebyte                                    *
  42.  *=========================================================================*/
  43.  
  44. /*=========================================================================*
  45.  *                            writeword                                    *
  46.  *=========================================================================*/
  47. void writeword(adress, value)
  48. USHORT adress, value;
  49. {
  50.    /* Remember: Z80 word is in reversed order */
  51.    writebyte(adress    , (UCHAR) (value & 0xff) );
  52.    writebyte(adress + 1, (UCHAR) ( (value >> 8) & 0xff) );
  53. }
  54.  
  55. #undef readbyte
  56.  
  57. /*=========================================================================*
  58.  *                            readbyte                                     *
  59.  *=========================================================================*/
  60. UCHAR readbyte(adress)
  61. USHORT adress;
  62. {
  63.    /* definide as a macro at z80.h */
  64.    return((UCHAR) *(mem+adress) );
  65. }
  66.  
  67. #undef readword
  68.  
  69. /*=========================================================================*
  70.  *                            readword                                     *
  71.  *=========================================================================*/
  72. USHORT readword(adress)
  73. USHORT adress;
  74. {
  75.    /* Remember: Z80 word is in reversed order */
  76.    return( ((USHORT) *(mem+adress) ) |
  77.            ( ( (USHORT) *(mem+adress + 1) ) << 8 ) );
  78. }
  79.  
  80.  
  81. #undef Getnextword
  82.  
  83. /*=========================================================================*
  84.  *                            Getnextword                                  *
  85.  *=========================================================================*/
  86. USHORT Getnextword()
  87. {
  88.    /* Remember: Z80 word is in reversed order */
  89.    PC += 2;
  90.    return(readword((USHORT)PC - 2));
  91. }
  92.  
  93. // see video.c for readbyte, since it supports the video logic
  94.  
  95. /* EOF: Mem.c */
  96.