flags.h
/*
* This file is part of libsidplayfp, a SID player engine.
*
* Copyright 2011-2014 Leandro Nini <drfiemost@users.sourceforge.net>
* Copyright 2007-2010 Antti Lankila
* Copyright 2000 Simon White
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef FLAGS_H
#define FLAGS_H
#include <stdint.h>
class Flags
{
public:
bool C;
bool Z;
bool I;
bool D;
bool B;
bool V;
bool N;
public:
void reset()
{
C = Z = I = D = V = N = false;
B = true;
}
void setNZ(uint8_t value)
{
Z = value == 0;
N = value & 0x80;
}
uint8_t get()
{
uint8_t sr = 0x20;
if (C) sr |= 0x01;
if (Z) sr |= 0x02;
if (I) sr |= 0x04;
if (D) sr |= 0x08;
if (B) sr |= 0x10;
if (V) sr |= 0x40;
if (N) sr |= 0x80;
return sr;
}
void set(uint8_t sr)
{
C = sr & 0x01;
Z = sr & 0x02;
I = sr & 0x04;
D = sr & 0x08;
B = sr & 0x10;
V = sr & 0x40;
N = sr & 0x80;
}
};
#endif
Flags
Definition: flags.h:31
Flags::Z
bool Z
Zero.
Definition: flags.h:35
Flags::get
uint8_t get()
Definition: flags.h:63
Flags::V
bool V
Overflow.
Definition: flags.h:39
Flags::N
bool N
Negative.
Definition: flags.h:40
Flags::C
bool C
Carry.
Definition: flags.h:34
Flags::set
void set(uint8_t sr)
Definition: flags.h:81
Flags::I
bool I
Interrupt disabled.
Definition: flags.h:36
Flags::D
bool D
Decimal.
Definition: flags.h:37
Flags::setNZ
void setNZ(uint8_t value)
Definition: flags.h:54
Flags::B
bool B
Break.
Definition: flags.h:38