Path: blob/a-new-beginning/Cherry/Core/include/SixteenBitRegister.h
2 views
/*1* Gearcoleco - ColecoVision Emulator2* Copyright (C) 2021 Ignacio Sanchez34* This program is free software: you can redistribute it and/or modify5* it under the terms of the GNU General Public License as published by6* the Free Software Foundation, either version 3 of the License, or7* any later version.89* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.1314* You should have received a copy of the GNU General Public License15* along with this program. If not, see http://www.gnu.org/licenses/16*17*/1819#ifndef SIXTEENBITREGISTER_H20#define SIXTEENBITREGISTER_H2122#include "definitions.h"2324class SixteenBitRegister25{26public:27SixteenBitRegister() { }28void SetLow(u8 low);29u8 GetLow() const;30void SetHigh(u8 high);31u8 GetHigh() const;32u8* GetHighRegister();33u8* GetLowRegister();34void SetValue(u16 value);35u16 GetValue() const;36void Increment();37void Decrement();3839private:40union sixteenBit41{42u16 v;43struct44{45#ifdef IS_LITTLE_ENDIAN46uint8_t low;47uint8_t high;48#else49uint8_t high;50uint8_t low;51#endif52};53} m_Value;54};555657inline void SixteenBitRegister::SetLow(u8 low)58{59m_Value.low = low;60}6162inline u8 SixteenBitRegister::GetLow() const63{64return m_Value.low;65}6667inline void SixteenBitRegister::SetHigh(u8 high)68{69m_Value.high = high;70}7172inline u8 SixteenBitRegister::GetHigh() const73{74return m_Value.high;75}7677inline u8* SixteenBitRegister::GetHighRegister()78{79return &m_Value.high;80}8182inline u8* SixteenBitRegister::GetLowRegister()83{84return &m_Value.low;85}8687inline void SixteenBitRegister::SetValue(u16 value)88{89m_Value.v = value;90}9192inline u16 SixteenBitRegister::GetValue() const93{94return m_Value.v;95}9697inline void SixteenBitRegister::Increment()98{99m_Value.v++;100}101102inline void SixteenBitRegister::Decrement()103{104m_Value.v--;105}106107#endif /* SIXTEENBITREGISTER_H */108109110111