/***************************************************************************1* Copyright (C) 2007 by Sindre Aamås *2* [email protected] *3* *4* This program is free software; you can redistribute it and/or modify *5* it under the terms of the GNU General Public License version 2 as *6* published by the Free Software Foundation. *7* *8* This program is distributed in the hope that it will be useful, *9* but WITHOUT ANY WARRANTY; without even the implied warranty of *10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *11* GNU General Public License version 2 for more details. *12* *13* You should have received a copy of the GNU General Public License *14* version 2 along with this program; if not, write to the *15* Free Software Foundation, Inc., *16* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *17***************************************************************************/18#ifndef SOUND_CHANNEL2_H19#define SOUND_CHANNEL2_H2021#include "gbint.h"22#include "length_counter.h"23#include "duty_unit.h"24#include "envelope_unit.h"25#include "static_output_tester.h"26#include "newstate.h"2728namespace gambatte {2930struct SaveState;3132class Channel2 {33friend class StaticOutputTester<Channel2,DutyUnit>;3435StaticOutputTester<Channel2,DutyUnit> staticOutputTest;36DutyMasterDisabler disableMaster;37LengthCounter lengthCounter;38DutyUnit dutyUnit;39EnvelopeUnit envelopeUnit;4041SoundUnit *nextEventUnit;4243unsigned long cycleCounter;44unsigned long soMask;45unsigned long prevOut;4647unsigned char nr4;48bool master;4950void setEvent();5152public:53Channel2();54void setNr1(unsigned data);55void setNr2(unsigned data);56void setNr3(unsigned data);57void setNr4(unsigned data);5859void setSo(unsigned long soMask);60// void deactivate() { disableMaster(); setEvent(); }61bool isActive() const { return master; }6263void update(uint_least32_t *buf, unsigned long soBaseVol, unsigned long cycles);6465void reset();66void init(bool cgb);67void loadState(const SaveState &state);6869template<bool isReader>void SyncState(NewState *ns);70};7172}7374#endif757677