File: SmsEnvironment.cpp

package info (click to toggle)
osmose-emulator 1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 1,120 kB
  • sloc: cpp: 18,086; makefile: 4
file content (101 lines) | stat: -rw-r--r-- 2,314 bytes parent folder | download
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * Copyright holder 2001-2011 Vedder Bruno.
 * Work continued by 2016-2020 Carlos Donizete Froes [a.k.a coringao]
 *
 * This file is part of Osmose Emulator, a Sega Master System and Game Gear
 * software emulator.
 *
 * Osmose Emulator is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Osmose Emulator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Osmose Emulator. If not, see <http://www.gnu.org/licenses/>.
 *
 * Many thanks to Vedder Bruno, the original author of Osmose Emulator.
 *
 */

#include <iostream>
#include <iomanip> // for trace in hexa in rw port
#include "Z80.h"
#include "SmsEnvironment.h"

using namespace std;

/** Constructor. */
SmsEnvironment::SmsEnvironment()
{
}

/** Destructor. */
SmsEnvironment::~SmsEnvironment()
{
}

/** 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);
}