Path: blob/master/libmeteor/include/ameteor/interpreter.hpp
2 views
// Meteor - A Nintendo Gameboy Advance emulator1// Copyright (C) 2009-2011 Philippe Daouadi2//3// This program is free software: you can redistribute it and/or modify4// it under the terms of the GNU General Public License as published by5// the Free Software Foundation, either version 3 of the License, or6// (at your option) any later version.7//8// This program is distributed in the hope that it will be useful,9// but WITHOUT ANY WARRANTY; without even the implied warranty of10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11// GNU General Public License for more details.12//13// You should have received a copy of the GNU General Public License14// along with this program. If not, see <http://www.gnu.org/licenses/>.1516#ifndef __INTERPRETER_H__17#define __INTERPRETER_H__1819#include <stdint.h>20#include <istream>21#include <ostream>22#include "cpu.hpp"2324#define ARM(name) \25inline void a##name ()26#define NIARM(name) \27void a##name ()28#define THUMB(name) \29inline void t##name ()30#define NITHUMB(name) \31void t##name ()3233namespace AMeteor34{35class Interpreter : public Cpu36{37public :38Interpreter();3940void Reset ()41{42m_interrupt = m_interrupt_ = false;43m_run = false;44Cpu::Reset();45}46void SoftReset ()47{48m_interrupt_ = m_interrupt = false;49Cpu::SoftReset();50}5152void SendInterrupt (uint16_t interrupt);53void CheckInterrupt ();5455void Run (unsigned int cycles);56void Stop ()57{58m_run = false;59}60bool IsRunning ()61{62return m_run;63}6465bool SaveState (std::ostream& stream);66bool LoadState (std::istream& stream);6768protected :69void SetInterrupt (bool interrupt)70{71m_interrupt = interrupt;72}7374private :75bool m_run;7677bool m_interrupt;78bool m_interrupt_;79uint32_t code;80uint8_t& m_haltcnt;81// only for use in halt mode, in normal mode we use m_interrupt82uint16_t& m_if;83uint16_t& m_ie;8485NIARM(_Code);86inline bool a_CheckCondition (uint8_t cond);87inline void a_DataProcCore(uint8_t rd, uint32_t op1, uint32_t op2,88bool shiftcarry);8990ARM(BXBLX);91ARM(BBL);92NIARM(_DataProcShiftImm);93NIARM(_DataProcShiftReg);94NIARM(_DataProcImm);95ARM(PSR);96ARM(_Multiply);97ARM(LDRSTR);98ARM(STRLDR_HD);99ARM(LDMSTM);100ARM(SWP);101ARM(SWI);102103NITHUMB(_Code);104105THUMB(_Shift);106THUMB(ADDSUB);107THUMB(_Imm);108THUMB(_ALU);109THUMB(_HiRegOp);110THUMB(LDRimm);111THUMB(STRLDRreg);112THUMB(STRLDRoff);113THUMB(LDRHSTRHoff);114THUMB(STRLDRsp);115THUMB(ADDpcsp);116THUMB(ADDsp);117THUMB(PUSHPOP);118THUMB(STMLDM);119THUMB(_CondBranch);120THUMB(SWI);121THUMB(B);122THUMB(_BL1);123THUMB(_BL2);124};125}126127#undef ARM128#undef NIARM129#undef THUMB130#undef NITHUMB131132#endif133134135