libsidplayfp 1.8.8
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
31class Flags
32{
33public:
34 bool C;
35 bool Z;
36 bool I;
37 bool D;
38 bool B;
39 bool V;
40 bool N;
41
42public:
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
Definition: flags.h:32
bool C
Carry.
Definition: flags.h:34
void setNZ(uint8_t value)
Definition: flags.h:54
bool Z
Zero.
Definition: flags.h:35
void set(uint8_t sr)
Definition: flags.h:81
bool N
Negative.
Definition: flags.h:40
uint8_t get()
Definition: flags.h:63
bool V
Overflow.
Definition: flags.h:39
bool D
Decimal.
Definition: flags.h:37
bool I
Interrupt disabled.
Definition: flags.h:36
bool B
Break.
Definition: flags.h:38