summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/psx/gamebooster.cpp
blob: 964168560732a05ebe68339db32ebf4bec44bf00 (plain) (blame)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// license:BSD-3-Clause
// copyright-holders:David Haywood
/**********************************************************************

    Datel Game Booster for Playstation 1

    Gameboy emulator with Gameboy cartridge slot

**********************************************************************/

#include "emu.h"
#include "gamebooster.h"

#include "bus/gameboy/carts.h"
#include "bus/gameboy/gbslot.h"

#include "softlist_dev.h"

#include <utility>

//#define VERBOSE 1
#include "logmacro.h"


//**************************************************************************
//  DEVICE DEFINITIONS
//**************************************************************************

DEFINE_DEVICE_TYPE(PSX_GAMEBOOSTER, psx_gamebooster_device, "psxgboost", "Datel Game Booster for Playstation")

//-------------------------------------------------
//  ROM( psxgboost )
//-------------------------------------------------

ROM_START( psxgboost )
	ROM_REGION16_LE(0x40000, "rom", 0)
	ROM_LOAD("game booster.rom", 0x0000, 0x40000, CRC(c8e459b8) SHA1(c20ab073f61242f37665f12199b95cfa3a83e9fc) )
ROM_END


//**************************************************************************
//  LIVE DEVICE
//**************************************************************************

//-------------------------------------------------
//  psx_gamebooster_device - constructor
//-------------------------------------------------

psx_gamebooster_device::psx_gamebooster_device(const machine_config &mconfig, const char *tag, device_t *owner, const XTAL &clock)
	: device_t(mconfig, PSX_GAMEBOOSTER, tag, owner, clock)
	, psx_parallel_interface(mconfig, *this)
	, device_memory_interface(mconfig, *this)
	, m_rom(*this, "rom")
	, m_cart_config("cart", ENDIANNESS_LITTLE, 8, 16, 0)
{
}


//**************************************************************************
//  DEVICE_T IMPLEMENTATION
//**************************************************************************

const tiny_rom_entry *psx_gamebooster_device::device_rom_region() const
{
	return ROM_NAME( psxgboost );
}

void psx_gamebooster_device::device_add_mconfig(machine_config &config)
{
	GB_CART_SLOT(config, "gbslot", gameboy_cartridges, nullptr).set_space(DEVICE_SELF, 0);

	SOFTWARE_LIST(config, "cart_list").set_original("gameboy");
	SOFTWARE_LIST(config, "gbc_list").set_compatible("gbcolor");
}

void psx_gamebooster_device::device_start()
{
	space(0).specific(m_cart_space);
}

void psx_gamebooster_device::device_reset()
{
}


//**************************************************************************
//  DEVICE_MEMORY_INTERFACE IMPLEMENTATION
//**************************************************************************

device_memory_interface::space_config_vector psx_gamebooster_device::memory_space_config() const
{
	return space_config_vector{ std::make_pair(0, &m_cart_config) };
}


//**************************************************************************
//  PSX_PARALLEL_INTERFACE IMPLEMENTATION
//**************************************************************************

uint16_t psx_gamebooster_device::exp_r(offs_t offset, uint16_t mem_mask)
{
	if (offset < 0x20000)
	{
		return m_rom[offset & 0x1ffff];
	}
	else if (offset < 0x24000)
	{
		offset -= 0x20000;
		uint16_t retval = 0;


		if (mem_mask & 0xff00) retval |= uint16_t(m_cart_space.read_byte((offset << 1) + 1)) << 8;
		if (mem_mask & 0x00ff) retval |= uint16_t(m_cart_space.read_byte((offset << 1) + 0)) << 0;

		return retval;
	}
	else
	{
		logerror("%s: psx_gamebooster_device::exp_r %04x\n", machine().describe_context(), offset << 1);

		return 0x0000;
	}
}

void psx_gamebooster_device::exp_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{

	if (offset < 0x20000)
	{
		logerror("%s: psx_gamebooster_device::exp_w %04x %04x\n", machine().describe_context(), offset << 1, data);
	}
	else if (offset < 0x24000)
	{
		offset -= 0x20000;
		LOG("%s: psx_gamebooster_device::exp_w %04x %04x\n", machine().describe_context(), offset << 1, data);

		if (mem_mask & 0xff00) m_cart_space.write_byte((offset << 1) + 1, data >> 8);
		if (mem_mask & 0x00ff) m_cart_space.write_byte((offset << 1) + 0, data >> 0); // send this 2nd or it erases the bank with the above
	}
	else
	{
		logerror("%s: psx_gamebooster_device::exp_w %04x %04x\n", machine().describe_context(), offset << 1, data);
	}
}