Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libgambatte/src/interrupter.cpp
2 views
1
/***************************************************************************
2
* Copyright (C) 2007 by Sindre Aamås *
3
* [email protected] *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License version 2 as *
7
* published by the Free Software Foundation. *
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 version 2 for more details. *
13
* *
14
* You should have received a copy of the GNU General Public License *
15
* version 2 along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18
***************************************************************************/
19
#include "interrupter.h"
20
#include "memory.h"
21
22
namespace gambatte {
23
24
Interrupter::Interrupter(unsigned short &SP_in, unsigned short &PC_in) :
25
SP(SP_in),
26
PC(PC_in)
27
{}
28
29
unsigned long Interrupter::interrupt(const unsigned address, unsigned long cycleCounter, Memory &memory) {
30
cycleCounter += 8;
31
SP = (SP - 1) & 0xFFFF;
32
memory.write(SP, PC >> 8, cycleCounter);
33
cycleCounter += 4;
34
SP = (SP - 1) & 0xFFFF;
35
memory.write(SP, PC & 0xFF, cycleCounter);
36
PC = address;
37
cycleCounter += 8;
38
39
return cycleCounter;
40
}
41
42
}
43
44