Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmeteor/include/ameteor/interpreter.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 __INTERPRETER_H__
18
#define __INTERPRETER_H__
19
20
#include <stdint.h>
21
#include <istream>
22
#include <ostream>
23
#include "cpu.hpp"
24
25
#define ARM(name) \
26
inline void a##name ()
27
#define NIARM(name) \
28
void a##name ()
29
#define THUMB(name) \
30
inline void t##name ()
31
#define NITHUMB(name) \
32
void t##name ()
33
34
namespace AMeteor
35
{
36
class Interpreter : public Cpu
37
{
38
public :
39
Interpreter();
40
41
void Reset ()
42
{
43
m_interrupt = m_interrupt_ = false;
44
m_run = false;
45
Cpu::Reset();
46
}
47
void SoftReset ()
48
{
49
m_interrupt_ = m_interrupt = false;
50
Cpu::SoftReset();
51
}
52
53
void SendInterrupt (uint16_t interrupt);
54
void CheckInterrupt ();
55
56
void Run (unsigned int cycles);
57
void Stop ()
58
{
59
m_run = false;
60
}
61
bool IsRunning ()
62
{
63
return m_run;
64
}
65
66
bool SaveState (std::ostream& stream);
67
bool LoadState (std::istream& stream);
68
69
protected :
70
void SetInterrupt (bool interrupt)
71
{
72
m_interrupt = interrupt;
73
}
74
75
private :
76
bool m_run;
77
78
bool m_interrupt;
79
bool m_interrupt_;
80
uint32_t code;
81
uint8_t& m_haltcnt;
82
// only for use in halt mode, in normal mode we use m_interrupt
83
uint16_t& m_if;
84
uint16_t& m_ie;
85
86
NIARM(_Code);
87
inline bool a_CheckCondition (uint8_t cond);
88
inline void a_DataProcCore(uint8_t rd, uint32_t op1, uint32_t op2,
89
bool shiftcarry);
90
91
ARM(BXBLX);
92
ARM(BBL);
93
NIARM(_DataProcShiftImm);
94
NIARM(_DataProcShiftReg);
95
NIARM(_DataProcImm);
96
ARM(PSR);
97
ARM(_Multiply);
98
ARM(LDRSTR);
99
ARM(STRLDR_HD);
100
ARM(LDMSTM);
101
ARM(SWP);
102
ARM(SWI);
103
104
NITHUMB(_Code);
105
106
THUMB(_Shift);
107
THUMB(ADDSUB);
108
THUMB(_Imm);
109
THUMB(_ALU);
110
THUMB(_HiRegOp);
111
THUMB(LDRimm);
112
THUMB(STRLDRreg);
113
THUMB(STRLDRoff);
114
THUMB(LDRHSTRHoff);
115
THUMB(STRLDRsp);
116
THUMB(ADDpcsp);
117
THUMB(ADDsp);
118
THUMB(PUSHPOP);
119
THUMB(STMLDM);
120
THUMB(_CondBranch);
121
THUMB(SWI);
122
THUMB(B);
123
THUMB(_BL1);
124
THUMB(_BL2);
125
};
126
}
127
128
#undef ARM
129
#undef NIARM
130
#undef THUMB
131
#undef NITHUMB
132
133
#endif
134
135