home *** CD-ROM | disk | FTP | other *** search
- /* Mem.c: Z80 memory - basic support routines.
- *
- * Copyright 1996 Rui Fernando Ferreira Ribeiro.
- *
- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
- /*
- * EmuZ80 v1.0
- * (c) 1996 Rui Fernando Ferreira Ribeiro
- *
- * -------------------------------------------------------
- *
- * MEM.C : Z80's memory - low level routines
- *
- */
-
- #include <alloc.h>
- #include "env.h"
-
- static UCHAR inited = 0;
-
-
- #if !defined(NDEBUG)
- extern UCHAR running;
- #endif
-
- /*=========================================================================*
- * writebyte *
- *=========================================================================*/
-
- /*=========================================================================*
- * writeword *
- *=========================================================================*/
- void writeword(adress, value)
- USHORT adress, value;
- {
- /* Remember: Z80 word is in reversed order */
- writebyte(adress , (UCHAR) (value & 0xff) );
- writebyte(adress + 1, (UCHAR) ( (value >> 8) & 0xff) );
- }
-
- #undef readbyte
-
- /*=========================================================================*
- * readbyte *
- *=========================================================================*/
- UCHAR readbyte(adress)
- USHORT adress;
- {
- /* definide as a macro at z80.h */
- return((UCHAR) *(mem+adress) );
- }
-
- #undef readword
-
- /*=========================================================================*
- * readword *
- *=========================================================================*/
- USHORT readword(adress)
- USHORT adress;
- {
- /* Remember: Z80 word is in reversed order */
- return( ((USHORT) *(mem+adress) ) |
- ( ( (USHORT) *(mem+adress + 1) ) << 8 ) );
- }
-
-
- #undef Getnextword
-
- /*=========================================================================*
- * Getnextword *
- *=========================================================================*/
- USHORT Getnextword()
- {
- /* Remember: Z80 word is in reversed order */
- PC += 2;
- return(readword((USHORT)PC - 2));
- }
-
- // see video.c for readbyte, since it supports the video logic
-
- /* EOF: Mem.c */
-