forked from badman12345/osmose-rpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SmsEnvironment.cpp
85 lines (70 loc) · 1.65 KB
/
SmsEnvironment.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <iostream>
#include <iomanip> // for trace in hexa in rw port
#include "./cpu/Z80.h"
#include "SmsEnvironment.h"
using namespace std;
/** Constructor. */
SmsEnvironment::SmsEnvironment() {
// dasm = new Z80Dasm(*this);
}
/** Destructor. */
SmsEnvironment::~SmsEnvironment() {
}
void SmsEnvironment::disasm(u16 IP) {
// This is done to avoid multiple disassembly of LDIR OTIR... instructions.
static unsigned int last_pc = 0x10000; // impossible value in IP.
//if (last_pc != IP)
{
//dasm->disasm(IP);
last_pc = IP;
}
}
/**
Called immediately after a RETI is executed.
*/
void SmsEnvironment::onReturnFromInterrupt()
{
}
void SmsEnvironment::onInterruptsEnabled()
{
if (v->irqAsserted())
{
cpu->interrupt(0xff);
}
}
void SmsEnvironment::setMemoryMapper(MemoryMapper *m) {
mmapper = m;
}
void SmsEnvironment::setIOMapper(IOMapper *m) {
iomapper = m;
}
void SmsEnvironment::setVDP(VDP *vdp) {
v = vdp;
}
void SmsEnvironment::setCPU(Z80 *c) {
cpu = c;
}
/* 8 bits read operation. */
u8 SmsEnvironment::rd8( u16 addr )
{
//printf("r%.4x\n", addr);
return mmapper->rd8(addr & 0xFFFF);
}
/* 8 bits write operation. */
void SmsEnvironment::wr8( u16 addr, u8 value )
{
//printf("w%.4x, %.2x\n", addr, value);
mmapper->wr8(addr & 0xFFFF, value);
}
/* 8 bits read IO operation. */
u8 SmsEnvironment::in( u16 port )
{
//printf("i%.4x\n", port & 0xff);
return iomapper->in8(port & 0xff);
}
/* 8 bits write IO operation. */
void SmsEnvironment::out( u16 port, u8 value )
{
//printf("o%.2x, %.2x\n", port & 0xff, value);
iomapper->out8(port & 0xff,value);
}