2017-04-04 13:32:50 +00:00
|
|
|
/*
|
|
|
|
Copyright 2016-2017 StapleButter
|
|
|
|
|
|
|
|
This file is part of melonDS.
|
|
|
|
|
|
|
|
melonDS 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 3 of the License, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
melonDS 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 melonDS. If not, see http://www.gnu.org/licenses/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SPU_H
|
|
|
|
#define SPU_H
|
|
|
|
|
|
|
|
namespace SPU
|
|
|
|
{
|
|
|
|
|
|
|
|
bool Init();
|
|
|
|
void DeInit();
|
|
|
|
void Reset();
|
|
|
|
|
2017-04-06 17:44:34 +00:00
|
|
|
void Mix(u32 samples);
|
|
|
|
|
|
|
|
void ReadOutput(s16* data, int samples);
|
|
|
|
|
|
|
|
u8 Read8(u32 addr);
|
|
|
|
u16 Read16(u32 addr);
|
|
|
|
u32 Read32(u32 addr);
|
|
|
|
void Write8(u32 addr, u8 val);
|
|
|
|
void Write16(u32 addr, u16 val);
|
|
|
|
void Write32(u32 addr, u32 val);
|
|
|
|
|
|
|
|
class Channel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Channel(u32 num);
|
|
|
|
~Channel();
|
|
|
|
void Reset();
|
|
|
|
|
2017-04-06 20:38:46 +00:00
|
|
|
u32 Num;
|
|
|
|
|
2017-04-06 17:44:34 +00:00
|
|
|
u32 Cnt;
|
|
|
|
u32 SrcAddr;
|
|
|
|
u16 TimerReload;
|
|
|
|
u32 LoopPos;
|
|
|
|
u32 Length;
|
|
|
|
|
2017-04-06 20:38:46 +00:00
|
|
|
u32 Timer;
|
|
|
|
u32 Pos;
|
|
|
|
s16 CurSample;
|
|
|
|
|
2017-04-06 17:44:34 +00:00
|
|
|
void SetCnt(u32 val)
|
|
|
|
{
|
2017-04-06 20:38:46 +00:00
|
|
|
if ((val & (1<<31)) && !(Cnt & (1<<31)))
|
|
|
|
{
|
|
|
|
Start();
|
|
|
|
}
|
|
|
|
|
2017-04-06 17:44:34 +00:00
|
|
|
Cnt = val & 0xFF7F837F;
|
2017-04-06 20:38:46 +00:00
|
|
|
//if(Num==8)printf("chan %d volume: %d\n", Num, val&0x7F);
|
2017-04-06 17:44:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetSrcAddr(u32 val) { SrcAddr = val & 0x07FFFFFF; }
|
2017-04-06 20:38:46 +00:00
|
|
|
void SetTimerReload(u32 val) { TimerReload = val & 0xFFFF;if(Num==8) printf("chan8 timer %04X\n", TimerReload);}
|
2017-04-06 17:44:34 +00:00
|
|
|
void SetLoopPos(u32 val) { LoopPos = (val & 0xFFFF) << 2; }
|
|
|
|
void SetLength(u32 val) { Length = (val & 0x001FFFFF) << 2; }
|
2017-04-06 20:38:46 +00:00
|
|
|
|
|
|
|
void Start();
|
|
|
|
|
|
|
|
void NextSample_PSG();
|
|
|
|
|
|
|
|
void Run(s32* buf, u32 samples);
|
2017-04-06 17:44:34 +00:00
|
|
|
};
|
|
|
|
|
2017-04-04 13:32:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SPU_H
|