2019-06-18 11:00:44 -06:00
|
|
|
/*
|
2024-06-15 09:01:19 -06:00
|
|
|
Copyright 2016-2024 melonDS team
|
2019-06-18 11:00:44 -06:00
|
|
|
|
|
|
|
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 DSI_NDMA_H
|
|
|
|
#define DSI_NDMA_H
|
|
|
|
|
2019-06-18 14:54:07 -06:00
|
|
|
#include "types.h"
|
2022-07-27 10:20:31 -06:00
|
|
|
#include "Savestate.h"
|
2019-06-18 14:54:07 -06:00
|
|
|
|
2023-11-25 10:32:09 -07:00
|
|
|
namespace melonDS
|
2023-11-09 13:54:51 -07:00
|
|
|
{
|
2023-11-28 15:16:41 -07:00
|
|
|
class DSi;
|
2023-11-09 13:54:51 -07:00
|
|
|
|
2019-06-18 14:54:07 -06:00
|
|
|
class DSi_NDMA
|
|
|
|
{
|
|
|
|
public:
|
2023-11-28 15:16:41 -07:00
|
|
|
DSi_NDMA(u32 cpu, u32 num, melonDS::DSi& dsi);
|
2019-06-18 14:54:07 -06:00
|
|
|
~DSi_NDMA();
|
|
|
|
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
void DoSavestate(Savestate* file);
|
|
|
|
|
|
|
|
void WriteCnt(u32 val);
|
|
|
|
void Start();
|
|
|
|
|
|
|
|
void Run();
|
|
|
|
|
|
|
|
void Run9();
|
|
|
|
void Run7();
|
|
|
|
|
2023-12-12 03:07:22 -07:00
|
|
|
bool IsInMode(u32 mode) const
|
2019-06-18 14:54:07 -06:00
|
|
|
{
|
|
|
|
return ((mode == StartMode) && (Cnt & 0x80000000));
|
|
|
|
}
|
|
|
|
|
2023-12-12 03:07:22 -07:00
|
|
|
bool IsRunning() const { return Running!=0; }
|
2019-06-18 14:54:07 -06:00
|
|
|
|
|
|
|
void StartIfNeeded(u32 mode)
|
|
|
|
{
|
|
|
|
if ((mode == StartMode) && (Cnt & 0x80000000))
|
|
|
|
Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StopIfNeeded(u32 mode)
|
|
|
|
{
|
|
|
|
if (mode == StartMode)
|
|
|
|
Cnt &= ~0x80000000;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StallIfRunning()
|
|
|
|
{
|
|
|
|
if (Executing) Stall = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 SrcAddr;
|
|
|
|
u32 DstAddr;
|
|
|
|
u32 TotalLength; // total length, when transferring multiple blocks
|
|
|
|
u32 BlockLength; // length of one transfer
|
|
|
|
u32 SubblockTimer; // optional delay between subblocks (only in round-robin mode)
|
|
|
|
u32 FillData;
|
|
|
|
u32 Cnt;
|
|
|
|
|
|
|
|
private:
|
2023-11-28 15:16:41 -07:00
|
|
|
melonDS::DSi& DSi;
|
2019-06-18 14:54:07 -06:00
|
|
|
u32 CPU, Num;
|
|
|
|
|
|
|
|
u32 StartMode;
|
|
|
|
u32 CurSrcAddr;
|
|
|
|
u32 CurDstAddr;
|
|
|
|
u32 SubblockLength; // length transferred per run when delay is used
|
|
|
|
u32 RemCount;
|
|
|
|
u32 IterCount;
|
|
|
|
u32 TotalRemCount;
|
|
|
|
u32 SrcAddrInc;
|
|
|
|
u32 DstAddrInc;
|
|
|
|
|
|
|
|
u32 Running;
|
|
|
|
bool InProgress;
|
|
|
|
|
|
|
|
bool Executing;
|
|
|
|
bool Stall;
|
|
|
|
|
|
|
|
bool IsGXFIFODMA;
|
|
|
|
};
|
2019-06-18 11:00:44 -06:00
|
|
|
|
2023-11-25 10:32:09 -07:00
|
|
|
}
|
2019-06-18 11:00:44 -06:00
|
|
|
#endif // DSI_NDMA_H
|