libsidplayfp 2.15.0
flags.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2019 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
28namespace libsidplayfp
29{
30
34class Flags
35{
36private:
37 bool C;
38 bool Z;
39 bool I;
40 bool D;
41 bool V;
42 bool N;
43
44public:
45 inline void reset()
46 {
47 C = Z = I = D = V = N = false;
48 }
49
55 inline void setNZ(uint8_t value)
56 {
57 Z = value == 0;
58 N = value & 0x80;
59 }
60
64 inline uint8_t get()
65 {
66 uint8_t sr = 0;
67
68 if (C) sr |= 0x01;
69 if (Z) sr |= 0x02;
70 if (I) sr |= 0x04;
71 if (D) sr |= 0x08;
72 if (V) sr |= 0x40;
73 if (N) sr |= 0x80;
74
75 return sr;
76 }
77
81 inline void set(uint8_t sr)
82 {
83 C = sr & 0x01;
84 Z = sr & 0x02;
85 I = sr & 0x04;
86 D = sr & 0x08;
87 V = sr & 0x40;
88 N = sr & 0x80;
89 }
90
91 inline bool getN() const { return N; }
92 inline bool getC() const { return C; }
93 inline bool getD() const { return D; }
94 inline bool getZ() const { return Z; }
95 inline bool getV() const { return V; }
96 inline bool getI() const { return I; }
97
98 inline void setN(bool f) { N = f; }
99 inline void setC(bool f) { C = f; }
100 inline void setD(bool f) { D = f; }
101 inline void setZ(bool f) { Z = f; }
102 inline void setV(bool f) { V = f; }
103 inline void setI(bool f) { I = f; }
104};
105
106}
107
108#endif
Definition flags.h:35
uint8_t get()
Definition flags.h:64
void set(uint8_t sr)
Definition flags.h:81
void setNZ(uint8_t value)
Definition flags.h:55