summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/bus/bml3/bml3kanji.cpp
blob: b426dc664dab552f1026f840917f63dcefaff457 (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
// license:GPL-2.0+
// copyright-holders:Jonathan Edwards
/*********************************************************************

    bml3kanji.c

    Hitachi MP-9740 (?) kanji character ROM for the MB-689x

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

#include "emu.h"
#include "bml3kanji.h"


/***************************************************************************
    PARAMETERS
***************************************************************************/

//**************************************************************************
//  GLOBAL VARIABLES
//**************************************************************************

const device_type BML3BUS_KANJI = &device_creator<bml3bus_kanji_device>;

#define KANJI_ROM_REGION  "kanji_rom"

ROM_START( kanji )
	ROM_REGION( 0x20000, KANJI_ROM_REGION, ROMREGION_ERASEFF )
	ROM_LOAD("kanji.rom", 0x00000, 0x20000, BAD_DUMP CRC(de99a726) SHA1(65fead5d0d779b242f6e0ac25fcc9899dc343101))
ROM_END

MACHINE_CONFIG_FRAGMENT( kanji )
	// nothing to add
MACHINE_CONFIG_END

/***************************************************************************
    FUNCTION PROTOTYPES
***************************************************************************/

//-------------------------------------------------
//  machine_config_additions - device-specific
//  machine configurations
//-------------------------------------------------

machine_config_constructor bml3bus_kanji_device::device_mconfig_additions() const
{
	return MACHINE_CONFIG_NAME( kanji );
}

//-------------------------------------------------
//  rom_region - device-specific ROM region
//-------------------------------------------------

const tiny_rom_entry *bml3bus_kanji_device::device_rom_region() const
{
	return ROM_NAME( kanji );
}

READ8_MEMBER( bml3bus_kanji_device::bml3_kanji_r )
{
	return m_rom[((uint32_t)m_kanji_addr << 1) + offset];
}

WRITE8_MEMBER( bml3bus_kanji_device::bml3_kanji_w )
{
	m_kanji_addr &= (0xff << (offset*8));
	m_kanji_addr |= (data << ((offset^1)*8));
}


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

bml3bus_kanji_device::bml3bus_kanji_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
	device_t(mconfig, BML3BUS_KANJI, "Hitachi MP-9740 Kanji Character ROM Card", tag, owner, clock, "bml3kanji", __FILE__),
	device_bml3bus_card_interface(mconfig, *this), m_kanji_addr(0), m_rom(nullptr)
{
}


//-------------------------------------------------
//  device_start - device-specific startup
//-------------------------------------------------

void bml3bus_kanji_device::device_start()
{
	// set_bml3bus_device makes m_slot valid
	set_bml3bus_device();

	m_rom = memregion(KANJI_ROM_REGION)->base();

	// install into memory
	address_space &space_prg = machine().firstcpu->space(AS_PROGRAM);
	space_prg.install_readwrite_handler(0xff75, 0xff76, read8_delegate( FUNC(bml3bus_kanji_device::bml3_kanji_r), this), write8_delegate(FUNC(bml3bus_kanji_device::bml3_kanji_w), this) );
}

void bml3bus_kanji_device::device_reset()
{
	m_kanji_addr = 0;
}