summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine/ldp1000.cpp
blob: 2c9e8535a348551f24481ea452321fdefa426ab6 (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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// license:BSD-3-Clause
// copyright-holders:Angelo Salese
/***************************************************************************

    Sony LDP-1000 laserdisc emulation.

    TODO:
    - Dump BIOSes (seven of them according to docs);
    - Serial interface, needs BIOS dump;
    - Hookup with Sony SMC-70 / SMC-777;

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

#include "emu.h"
#include "machine/ldp1000.h"

#define DUMP_BCD 1
#define FIFO_MAX 0x10

ROM_START( ldp1000 )
	ROM_REGION( 0x2000, "ldp1000", 0 )
	ROM_LOAD( "ldp1000_bios.bin", 0x0000, 0x2000, NO_DUMP )
ROM_END

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

// device type definition
const device_type SONY_LDP1000 = &device_creator<sony_ldp1000_device>;


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

//-------------------------------------------------
//  ldp1000_device - constructor
//-------------------------------------------------

sony_ldp1000_device::sony_ldp1000_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
	: laserdisc_device(mconfig, SONY_LDP1000, "Sony LDP-1000", tag, owner, clock, "ldp1000", __FILE__)
{
}


//-------------------------------------------------
//  device_validity_check - perform validity checks
//  on this device
//-------------------------------------------------

void sony_ldp1000_device::device_validity_check(validity_checker &valid) const
{
}


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

void sony_ldp1000_device::device_start()
{
	laserdisc_device::device_start();
}


//-------------------------------------------------
//  device_reset - device-specific reset
//-------------------------------------------------

void sony_ldp1000_device::device_reset()
{
	laserdisc_device::device_reset();

	for(int i=0;i<0x10;i++)
		m_internal_bcd[i] = 0;

}

//-------------------------------------------------
//  device_rom_region - return a pointer to our
//  ROM region definitions
//-------------------------------------------------

const tiny_rom_entry *sony_ldp1000_device::device_rom_region() const
{
	return ROM_NAME(ldp1000);
}


//-------------------------------------------------
//  player_vsync - VSYNC callback, called at the
//  start of the blanking period
//-------------------------------------------------

void sony_ldp1000_device::player_vsync(const vbi_metadata &vbi, int fieldnum, const attotime &curtime)
{
	//printf("%d vsync\n",fieldnum);
}


//-------------------------------------------------
//  player_update - update callback, called on
//  the first visible line of the frame
//-------------------------------------------------

int32_t sony_ldp1000_device::player_update(const vbi_metadata &vbi, int fieldnum, const attotime &curtime)
{
	//printf("%d update\n",fieldnum);

	return fieldnum;
}


//**************************************************************************
//  READ/WRITE HANDLERS
//**************************************************************************

READ8_MEMBER( sony_ldp1000_device::status_r )
{
	uint8_t res = m_status;
	m_status = stat_undef;
	return res;
}

void sony_ldp1000_device::set_new_player_state(ldp1000_player_state which)
{
	m_player_state = which;
	m_index_state = 0;
	printf("set new player state\n");
}

// TODO: probably don't even need a size ...
void sony_ldp1000_device::set_new_player_bcd(uint8_t data)
{
	m_internal_bcd[m_index_state] = data;
	m_index_state ++;
	if(m_index_state >= FIFO_MAX)
		throw emu_fatalerror("FIFO MAX reached");

	m_status = stat_ack;
}

uint32_t sony_ldp1000_device::bcd_to_raw()
{
	uint32_t res = 0;
	for(int i=0;i<6;i++)
		res |= (m_internal_bcd[i] & 0xf) << i*4;
	return res;
}

void sony_ldp1000_device::exec_enter_cmd()
{
	//const uint32_t saved_frame = bcd_to_raw();

	switch(m_player_state)
	{
		case player_standby:
			throw emu_fatalerror("Unimplemented standby state detected");

		case player_search:
			// TODO: move to timer
			//advance_slider(1);
			//set_slider_speed(saved_frame);
			break;
	}
	m_player_state = player_standby;
}


// TODO: de-instantize this
WRITE8_MEMBER( sony_ldp1000_device::command_w )
{
	printf("CMD %02x\n",data);
	// 0x30 to 0x69 range causes an ACK, anything else is invalid
	m_command = data;

	if((m_command & 0xf0) == 0x30 && (m_command & 0xf) < 0x0a)
	{
		set_new_player_bcd(data);
		return;
	}

	switch(m_command)
	{
		case 0x40: // enter, process BCD command
			exec_enter_cmd();
			m_status = stat_ack;
			break;

		case 0x43: // search
			set_new_player_state(player_search);
			m_status = stat_ack;
			break;

		/*
		    audio channels absolute enable / disable
		    ---- --x- select channel
		    ---- ---x enable channel (active low)
		*/
		case 0x46:
		case 0x47:
		case 0x48:
		case 0x49:
			m_audio_enable[(m_command & 2) >> 1] = (m_command & 1) == 0;
			m_status = stat_ack;
			break;

		case 0x56: // Clear All
			m_status = stat_ack;
			// reset any pending operation here
			break;

		default:
			m_status = stat_undef;
			break;
	}
}