libsidplayfp  1.8.7
flags.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2011-2014 Leandro Nini <drfiemost@users.sourceforge.net>
5  * Copyright 2007-2010 Antti Lankila
6  * Copyright 2000 Simon White
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program 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
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef FLAGS_H
24 #define FLAGS_H
25 
26 #include <stdint.h>
27 
31 class Flags
32 {
33 public:
34  bool C;
35  bool Z;
36  bool I;
37  bool D;
38  bool B;
39  bool V;
40  bool N;
41 
42 public:
43  void reset()
44  {
45  C = Z = I = D = V = N = false;
46  B = true;
47  }
48 
54  void setNZ(uint8_t value)
55  {
56  Z = value == 0;
57  N = value & 0x80;
58  }
59 
63  uint8_t get()
64  {
65  uint8_t sr = 0x20;
66 
67  if (C) sr |= 0x01;
68  if (Z) sr |= 0x02;
69  if (I) sr |= 0x04;
70  if (D) sr |= 0x08;
71  if (B) sr |= 0x10;
72  if (V) sr |= 0x40;
73  if (N) sr |= 0x80;
74 
75  return sr;
76  }
77 
81  void set(uint8_t sr)
82  {
83  C = sr & 0x01;
84  Z = sr & 0x02;
85  I = sr & 0x04;
86  D = sr & 0x08;
87  B = sr & 0x10;
88  V = sr & 0x40;
89  N = sr & 0x80;
90  }
91 };
92 
93 #endif
bool B
Break.
Definition: flags.h:38
bool Z
Zero.
Definition: flags.h:35
bool N
Negative.
Definition: flags.h:40
Definition: flags.h:31
bool V
Overflow.
Definition: flags.h:39
bool C
Carry.
Definition: flags.h:34
bool I
Interrupt disabled.
Definition: flags.h:36
void setNZ(uint8_t value)
Definition: flags.h:54
bool D
Decimal.
Definition: flags.h:37