summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine/coco12.c
blob: c7239288d5e4daff4f65b4035b6050a260a1c0fa (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
145
/***************************************************************************

    coco12.c

    TRS-80 Radio Shack Color Computer 1/2 Family

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

#include "includes/coco12.h"

//-------------------------------------------------
//  device_start
//-------------------------------------------------

void coco12_state::device_start()
{
	coco_state::device_start();
	configure_sam();
}



//-------------------------------------------------
//  configure_sam
//-------------------------------------------------

void coco12_state::configure_sam()
{
	cococart_slot_device *cart = m_cococart;
	UINT8 *ram = m_ram->pointer();
	UINT32 ram_size = m_ram->size();
	UINT8 *rom = memregion(MAINCPU_TAG)->base();
	UINT8 *cart_rom = cart->get_cart_base();

	m_sam->configure_bank(0, ram, ram_size, false);			// $0000-$7FFF
	m_sam->configure_bank(1, &rom[0x0000], 0x2000, true);	// $8000-$9FFF
	m_sam->configure_bank(2, &rom[0x2000], 0x2000, true);	// $A000-$BFFF
	m_sam->configure_bank(3, cart_rom, 0x4000, true);		// $C000-$FEFF

	// $FF00-$FF1F
	m_sam->configure_bank(4, read8_delegate(FUNC(coco12_state::ff00_read), this), write8_delegate(FUNC(coco12_state::ff00_write), this));

	// $FF20-$FF3F
	m_sam->configure_bank(5, read8_delegate(FUNC(coco12_state::ff20_read), this), write8_delegate(FUNC(coco12_state::ff20_write), this));

	// $FF40-$FF5F
	m_sam->configure_bank(6, read8_delegate(FUNC(coco12_state::ff40_read), this), write8_delegate(FUNC(coco12_state::ff40_write), this));

	// $FF60-$FFBF
	m_sam->configure_bank(7, read8_delegate(FUNC(coco12_state::ff60_read), this), write8_delegate(FUNC(coco12_state::ff60_write), this));
}


//-------------------------------------------------
//  horizontal_sync
//-------------------------------------------------

WRITE_LINE_MEMBER( coco12_state::horizontal_sync )
{
	m_pia_0->ca1_w(state);
	m_sam->hs_w(state);
}



//-------------------------------------------------
//  field_sync
//-------------------------------------------------

WRITE_LINE_MEMBER( coco12_state::field_sync )
{
	m_pia_0->cb1_w(state);
}



//-------------------------------------------------
//  sam_read
//-------------------------------------------------

READ8_MEMBER( coco12_state::sam_read )
{
	UINT8 data = m_sam->mpu_address_space()->read_byte(offset);
	m_vdg->as_w(data & 0x80 ? ASSERT_LINE : CLEAR_LINE);
	m_vdg->inv_w(data & 0x40 ? ASSERT_LINE : CLEAR_LINE);
	return data;
}



//-------------------------------------------------
//  pia1_pb_changed
//-------------------------------------------------

void coco12_state::pia1_pb_changed(void)
{
	/* call inherited function */
	coco_state::pia1_pb_changed();

	UINT8 data = m_pia_1->b_output();
	m_vdg->css_w(data & 0x08);
	m_vdg->intext_w(data & 0x10);
	m_vdg->gm0_w(data & 0x10);
	m_vdg->gm1_w(data & 0x20);
	m_vdg->gm2_w(data & 0x40);
	m_vdg->ag_w(data & 0x80);
}



//-------------------------------------------------
//  update_cart_base
//-------------------------------------------------

void coco12_state::update_cart_base(UINT8 *cart_base)
{
	m_sam->configure_bank(3, cart_base, 0x4000, true);		// $C000-$FEFF
}



//-------------------------------------------------
//  mc6847_config
//-------------------------------------------------

const mc6847_interface coco12_state::mc6847_config =
{
	SCREEN_TAG,
	DEVCB_DEVICE_MEMBER(SAM_TAG, sam6883_device, display_read),
	DEVCB_DRIVER_LINE_MEMBER(coco12_state, horizontal_sync),
	DEVCB_DRIVER_LINE_MEMBER(coco12_state, field_sync)
};



//-------------------------------------------------
//  sam6883_config
//-------------------------------------------------

const sam6883_interface coco12_state::sam6883_config =
{
	MAINCPU_TAG,
	AS_PROGRAM,
	DEVCB_DRIVER_MEMBER(coco12_state, sam_read)
};