Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmeteor/include/ameteor/dma.hpp
2 views
1
// Meteor - A Nintendo Gameboy Advance emulator
2
// Copyright (C) 2009-2011 Philippe Daouadi
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 as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
#ifndef __DMA_H__
18
#define __DMA_H__
19
20
#include <stdint.h>
21
#include <istream>
22
#include <ostream>
23
24
namespace AMeteor
25
{
26
class Dma
27
{
28
public :
29
enum Reason
30
{
31
Immediately = 0,
32
VBlank,
33
HBlank,
34
Special
35
};
36
37
Dma () :
38
m_graphic(false)
39
{ }
40
41
void Reset ();
42
43
bool GraphicDma () const
44
{
45
return false;
46
//return m_graphic;
47
}
48
49
void SetReload(uint8_t channum, uint16_t reload)
50
{
51
m_chans[channum].reload = reload;
52
}
53
54
void UpdateCnt (uint8_t channum);
55
void Check(uint8_t channum, uint8_t reason);
56
inline void CheckAll(uint8_t reason)
57
{
58
Check(0, reason);
59
Check(1, reason);
60
Check(2, reason);
61
Check(3, reason);
62
}
63
64
bool SaveState (std::ostream& stream);
65
bool LoadState (std::istream& stream);
66
67
private :
68
struct Channel
69
{
70
Channel () :
71
reload(0),
72
src(0),
73
dest(0),
74
count(0),
75
control(0)
76
{ }
77
78
uint16_t reload;
79
uint32_t src;
80
uint32_t dest;
81
uint16_t count;
82
union Control
83
{
84
Control(uint16_t v) :
85
w(v)
86
{ }
87
88
uint16_t w;
89
struct
90
{
91
unsigned int unused : 5;
92
unsigned int dest : 2;
93
unsigned int src : 2;
94
unsigned int repeat : 1;
95
unsigned int type : 1;
96
unsigned int drq : 1;
97
unsigned int start : 2;
98
unsigned int irq : 1;
99
unsigned int enable : 1;
100
} b;
101
} control;
102
};
103
104
Channel m_chans[4];
105
bool m_graphic;
106
107
void Process(uint8_t channel);
108
void Copy (uint32_t& src, uint32_t& dest, int8_t s_inc, int8_t d_inc,
109
uint32_t count, bool word);
110
};
111
}
112
113
#endif
114
115