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

  1. /* Flags.c: Z80 flags --  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. #include "env.h"
  21.  
  22. #undef build_F
  23. #undef read_F
  24.  
  25. /*=========================================================================*
  26.  *                            build_flags                                  *
  27.  *=========================================================================*/
  28. void build_F()
  29. {
  30.    /* defined as macro in z80.h */
  31.    /* Build F from interpreter flags only we need them */
  32.    F = (flags._C != 0) | ((flags._N != 0) << 1) | ((flags._P != 0) << 2) |
  33.    ((flags._Y != 0) << 3) | ((flags._H != 0) << 4) | ((flags._X != 0) << 5) |
  34.    ((flags._Z != 0) << 6) | ((flags._S != 0) << 7);
  35. }
  36.  
  37. /*=========================================================================*
  38.  *                            read_flags                                   *
  39.  *=========================================================================*/
  40. void read_F()
  41. {
  42.    /* defined as macro in z80.h */
  43.    /* Build interpreter flags with F */
  44.    flags._S = (F & (UCHAR)BIT_7);
  45.    flags._Z = (F & (UCHAR)BIT_6);
  46.    flags._X = (F & (UCHAR)BIT_5);
  47.    flags._H = (F & (UCHAR)BIT_4);
  48.    flags._Y = (F & (UCHAR)BIT_3);
  49.    flags._P = (F & (UCHAR)BIT_2);
  50.    flags._N = (F & (UCHAR)BIT_1);
  51.    flags._C = (F & (UCHAR)BIT_0);
  52. }
  53.  
  54. /* EOF: Flags.c */
  55.