summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/machine/vtech2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mess/machine/vtech2.c')
-rw-r--r--src/mess/machine/vtech2.c400
1 files changed, 199 insertions, 201 deletions
diff --git a/src/mess/machine/vtech2.c b/src/mess/machine/vtech2.c
index ab23737e721..ecc8aa5b50b 100644
--- a/src/mess/machine/vtech2.c
+++ b/src/mess/machine/vtech2.c
@@ -23,7 +23,7 @@
/* static */
-#define TRKSIZE_VZ 0x9a0 /* arbitrary (actually from analyzing format) */
+#define TRKSIZE_VZ 0x9a0 /* arbitrary (actually from analyzing format) */
static const UINT8 laser_fdc_wrprot[2] = {0x80, 0x80};
@@ -42,19 +42,19 @@ READ8_MEMBER(vtech2_state::mra_bank4 ) { return mra_bank(3,offset); }
/* read banked memory (plain ROM/RAM) */
static const char *const mra_bank_hard[4] =
{
- "bank1", /* mapped in 0000-3fff */
- "bank2", /* mapped in 4000-7fff */
- "bank3", /* mapped in 8000-bfff */
- "bank4" /* mapped in c000-ffff */
+ "bank1", /* mapped in 0000-3fff */
+ "bank2", /* mapped in 4000-7fff */
+ "bank3", /* mapped in 8000-bfff */
+ "bank4" /* mapped in c000-ffff */
};
/* write banked memory (plain ROM/RAM) */
static const char *const mwa_bank_hard[4] =
{
- "bank1", /* mapped in 0000-3fff */
- "bank2", /* mapped in 4000-7fff */
- "bank3", /* mapped in 8000-bfff */
- "bank4" /* mapped in c000-ffff */
+ "bank1", /* mapped in 0000-3fff */
+ "bank2", /* mapped in 4000-7fff */
+ "bank3", /* mapped in 8000-bfff */
+ "bank4" /* mapped in c000-ffff */
};
DRIVER_INIT_MEMBER(vtech2_state,laser)
@@ -81,10 +81,10 @@ DRIVER_INIT_MEMBER(vtech2_state,laser)
static void laser_machine_init(running_machine &machine, int bank_mask, int video_mask)
{
vtech2_state *state = machine.driver_data<vtech2_state>();
- int i;
+ int i;
state->m_laser_bank_mask = bank_mask;
- state->m_laser_video_bank = video_mask;
+ state->m_laser_video_bank = video_mask;
state->m_videoram = state->m_mem + state->m_laser_video_bank * 0x04000;
logerror("laser_machine_init(): bank mask $%04X, video %d [$%05X]\n", state->m_laser_bank_mask, state->m_laser_video_bank, state->m_laser_video_bank * 0x04000);
@@ -113,22 +113,22 @@ MACHINE_RESET_MEMBER(vtech2_state,laser700)
WRITE8_MEMBER(vtech2_state::laser_bank_select_w)
{
- static const char *const bank_name[16] = {
- "ROM lo","ROM hi","MM I/O","Video RAM lo",
- "RAM #0","RAM #1","RAM #2","RAM #3",
- "RAM #4","RAM #5","RAM #6","RAM #7/Video RAM hi",
- "ext ROM #0","ext ROM #1","ext ROM #2","ext ROM #3"
- };
+ static const char *const bank_name[16] = {
+ "ROM lo","ROM hi","MM I/O","Video RAM lo",
+ "RAM #0","RAM #1","RAM #2","RAM #3",
+ "RAM #4","RAM #5","RAM #6","RAM #7/Video RAM hi",
+ "ext ROM #0","ext ROM #1","ext ROM #2","ext ROM #3"
+ };
char bank[10];
offset %= 4;
- data &= 15;
+ data &= 15;
if( data != m_laser_bank[offset] )
- {
- m_laser_bank[offset] = data;
+ {
+ m_laser_bank[offset] = data;
logerror("select bank #%d $%02X [$%05X] %s\n", offset+1, data, 0x4000 * (data & 15), bank_name[data]);
- /* memory mapped I/O bank selected? */
+ /* memory mapped I/O bank selected? */
if (data == 2)
{
static read8_delegate mra_bank_soft[] =
@@ -171,7 +171,7 @@ WRITE8_MEMBER(vtech2_state::laser_bank_select_w)
}
}
- }
+ }
}
static cassette_image_device *vtech2_cassette_image(running_machine &machine)
@@ -193,9 +193,9 @@ static cassette_image_device *vtech2_cassette_image(running_machine &machine)
************************************************/
int vtech2_state::mra_bank(int bank, int offs)
{
- int level, data = 0xff;
+ int level, data = 0xff;
- /* Laser 500/700 only: keyboard rows A through D */
+ /* Laser 500/700 only: keyboard rows A through D */
if( (offs & 0x00ff) == 0x00ff )
{
if( (offs & 0x0300) == 0x0000 ) /* keyboard row A */
@@ -234,7 +234,7 @@ int vtech2_state::mra_bank(int bank, int offs)
else
{
/* All Lasers keyboard rows 0 through 7 */
- if( !(offs & 0x01) )
+ if( !(offs & 0x01) )
data &= machine().root_device().ioport("ROW0")->read();
if( !(offs & 0x02) )
data &= machine().root_device().ioport("ROW1")->read();
@@ -252,7 +252,7 @@ int vtech2_state::mra_bank(int bank, int offs)
data &= machine().root_device().ioport("ROW7")->read();
}
- /* what's bit 7 good for? tape input maybe? */
+ /* what's bit 7 good for? tape input maybe? */
level = (vtech2_cassette_image(machine()))->input() * 65536.0;
if( level < m_level_old - 511 )
m_cassette_bit = 0x00;
@@ -261,9 +261,9 @@ int vtech2_state::mra_bank(int bank, int offs)
m_level_old = level;
data &= ~m_cassette_bit;
- // logerror("bank #%d keyboard_r [$%04X] $%02X\n", bank, offs, data);
+ // logerror("bank #%d keyboard_r [$%04X] $%02X\n", bank, offs, data);
- return data;
+ return data;
}
/*************************************************
@@ -281,36 +281,36 @@ void vtech2_state::mwa_bank(int bank, int offs, int data)
{
device_t *speaker = machine().device(SPEAKER_TAG);
offs += 0x4000 * m_laser_bank[bank];
- switch (m_laser_bank[bank])
- {
- case 0: /* ROM lower 16K */
- case 1: /* ROM upper 16K */
+ switch (m_laser_bank[bank])
+ {
+ case 0: /* ROM lower 16K */
+ case 1: /* ROM upper 16K */
logerror("bank #%d write to ROM [$%05X] $%02X\n", bank+1, offs, data);
- break;
- case 2: /* memory mapped output */
- if (data != m_laser_latch)
- {
- logerror("bank #%d write to I/O [$%05X] $%02X\n", bank+1, offs, data);
- /* Toggle between graphics and text modes? */
+ break;
+ case 2: /* memory mapped output */
+ if (data != m_laser_latch)
+ {
+ logerror("bank #%d write to I/O [$%05X] $%02X\n", bank+1, offs, data);
+ /* Toggle between graphics and text modes? */
if ((data ^ m_laser_latch) & 0x01)
speaker_level_w(speaker, data & 1);
- m_laser_latch = data;
- }
- break;
- case 12: /* ext. ROM #1 */
- case 13: /* ext. ROM #2 */
- case 14: /* ext. ROM #3 */
- case 15: /* ext. ROM #4 */
+ m_laser_latch = data;
+ }
+ break;
+ case 12: /* ext. ROM #1 */
+ case 13: /* ext. ROM #2 */
+ case 14: /* ext. ROM #3 */
+ case 15: /* ext. ROM #4 */
logerror("bank #%d write to ROM [$%05X] $%02X\n", bank+1, offs, data);
- break;
- default: /* RAM */
- if( m_laser_bank[bank] == m_laser_video_bank && m_mem[offs] != data )
+ break;
+ default: /* RAM */
+ if( m_laser_bank[bank] == m_laser_video_bank && m_mem[offs] != data )
{
logerror("bank #%d write to videoram [$%05X] $%02X\n", bank+1, offs, data);
}
- m_mem[offs] = data;
- break;
- }
+ m_mem[offs] = data;
+ break;
+ }
}
DEVICE_IMAGE_LOAD( laser_cart )
@@ -349,36 +349,36 @@ static device_t *laser_file(running_machine &machine)
static void laser_get_track(running_machine &machine)
{
vtech2_state *state = machine.driver_data<vtech2_state>();
- sprintf(state->m_laser_frame_message, "#%d get track %02d", state->m_laser_drive, state->m_laser_track_x2[state->m_laser_drive]/2);
- state->m_laser_frame_time = 30;
- /* drive selected or and image file ok? */
- if( state->m_laser_drive >= 0 && laser_file(machine) != NULL )
- {
- int size, offs;
+ sprintf(state->m_laser_frame_message, "#%d get track %02d", state->m_laser_drive, state->m_laser_track_x2[state->m_laser_drive]/2);
+ state->m_laser_frame_time = 30;
+ /* drive selected or and image file ok? */
+ if( state->m_laser_drive >= 0 && laser_file(machine) != NULL )
+ {
+ int size, offs;
device_image_interface *image = dynamic_cast<device_image_interface *>(laser_file(machine));
- size = TRKSIZE_VZ;
- offs = TRKSIZE_VZ * state->m_laser_track_x2[state->m_laser_drive]/2;
- image->fseek(offs, SEEK_SET);
- size = image->fread(state->m_laser_fdc_data, size);
- logerror("get track @$%05x $%04x bytes\n", offs, size);
- }
- state->m_laser_fdc_offs = 0;
- state->m_laser_fdc_write = 0;
+ size = TRKSIZE_VZ;
+ offs = TRKSIZE_VZ * state->m_laser_track_x2[state->m_laser_drive]/2;
+ image->fseek(offs, SEEK_SET);
+ size = image->fread(state->m_laser_fdc_data, size);
+ logerror("get track @$%05x $%04x bytes\n", offs, size);
+ }
+ state->m_laser_fdc_offs = 0;
+ state->m_laser_fdc_write = 0;
}
static void laser_put_track(running_machine &machine)
{
vtech2_state *state = machine.driver_data<vtech2_state>();
device_image_interface *image = dynamic_cast<device_image_interface *>(laser_file(machine));
- /* drive selected and image file ok? */
- if( state->m_laser_drive >= 0 && laser_file(machine) != NULL )
- {
- int size, offs;
- offs = TRKSIZE_VZ * state->m_laser_track_x2[state->m_laser_drive]/2;
- image->fseek(offs + state->m_laser_fdc_start, SEEK_SET);
- size = image->fwrite(&state->m_laser_fdc_data[state->m_laser_fdc_start], state->m_laser_fdc_write);
- logerror("put track @$%05X+$%X $%04X/$%04X bytes\n", offs, state->m_laser_fdc_start, size, state->m_laser_fdc_write);
- }
+ /* drive selected and image file ok? */
+ if( state->m_laser_drive >= 0 && laser_file(machine) != NULL )
+ {
+ int size, offs;
+ offs = TRKSIZE_VZ * state->m_laser_track_x2[state->m_laser_drive]/2;
+ image->fseek(offs + state->m_laser_fdc_start, SEEK_SET);
+ size = image->fwrite(&state->m_laser_fdc_data[state->m_laser_fdc_start], state->m_laser_fdc_write);
+ logerror("put track @$%05X+$%X $%04X/$%04X bytes\n", offs, state->m_laser_fdc_start, size, state->m_laser_fdc_write);
+ }
}
#define PHI0(n) (((n)>>0)&1)
@@ -388,138 +388,136 @@ static void laser_put_track(running_machine &machine)
READ8_MEMBER(vtech2_state::laser_fdc_r)
{
- int data = 0xff;
- switch( offset )
- {
- case 1: /* data (read-only) */
- if( m_laser_fdc_bits > 0 )
- {
- if( m_laser_fdc_status & 0x80 )
- m_laser_fdc_bits--;
- data = (m_laser_data >> m_laser_fdc_bits) & 0xff;
+ int data = 0xff;
+ switch( offset )
+ {
+ case 1: /* data (read-only) */
+ if( m_laser_fdc_bits > 0 )
+ {
+ if( m_laser_fdc_status & 0x80 )
+ m_laser_fdc_bits--;
+ data = (m_laser_data >> m_laser_fdc_bits) & 0xff;
#if 0
- logerror("laser_fdc_r bits %d%d%d%d%d%d%d%d\n",
- (data>>7)&1,(data>>6)&1,(data>>5)&1,(data>>4)&1,
- (data>>3)&1,(data>>2)&1,(data>>1)&1,(data>>0)&1 );
+ logerror("laser_fdc_r bits %d%d%d%d%d%d%d%d\n",
+ (data>>7)&1,(data>>6)&1,(data>>5)&1,(data>>4)&1,
+ (data>>3)&1,(data>>2)&1,(data>>1)&1,(data>>0)&1 );
#endif
- }
- if( m_laser_fdc_bits == 0 )
- {
- m_laser_data = m_laser_fdc_data[m_laser_fdc_offs];
- logerror("laser_fdc_r %d : data ($%04X) $%02X\n", offset, m_laser_fdc_offs, m_laser_data);
- if( m_laser_fdc_status & 0x80 )
- {
- m_laser_fdc_bits = 8;
- m_laser_fdc_offs = (m_laser_fdc_offs + 1) % TRKSIZE_FM;
- }
- m_laser_fdc_status &= ~0x80;
- }
- break;
- case 2: /* polling (read-only) */
- /* fake */
- if( m_laser_drive >= 0 )
- m_laser_fdc_status |= 0x80;
- data = m_laser_fdc_status;
- break;
- case 3: /* write protect status (read-only) */
- if( m_laser_drive >= 0 )
- data = laser_fdc_wrprot[m_laser_drive];
- logerror("laser_fdc_r %d : write_protect $%02X\n", offset, data);
- break;
- }
- return data;
+ }
+ if( m_laser_fdc_bits == 0 )
+ {
+ m_laser_data = m_laser_fdc_data[m_laser_fdc_offs];
+ logerror("laser_fdc_r %d : data ($%04X) $%02X\n", offset, m_laser_fdc_offs, m_laser_data);
+ if( m_laser_fdc_status & 0x80 )
+ {
+ m_laser_fdc_bits = 8;
+ m_laser_fdc_offs = (m_laser_fdc_offs + 1) % TRKSIZE_FM;
+ }
+ m_laser_fdc_status &= ~0x80;
+ }
+ break;
+ case 2: /* polling (read-only) */
+ /* fake */
+ if( m_laser_drive >= 0 )
+ m_laser_fdc_status |= 0x80;
+ data = m_laser_fdc_status;
+ break;
+ case 3: /* write protect status (read-only) */
+ if( m_laser_drive >= 0 )
+ data = laser_fdc_wrprot[m_laser_drive];
+ logerror("laser_fdc_r %d : write_protect $%02X\n", offset, data);
+ break;
+ }
+ return data;
}
WRITE8_MEMBER(vtech2_state::laser_fdc_w)
{
- int drive;
-
- switch( offset )
- {
- case 0: /* latch (write-only) */
- drive = (data & 0x10) ? 0 : (data & 0x80) ? 1 : -1;
- if( drive != m_laser_drive )
- {
- m_laser_drive = drive;
- if( m_laser_drive >= 0 )
- laser_get_track(machine());
- }
- if( m_laser_drive >= 0 )
- {
- if( (PHI0(data) && !(PHI1(data) || PHI2(data) || PHI3(data)) && PHI1(m_laser_fdc_latch)) ||
- (PHI1(data) && !(PHI0(data) || PHI2(data) || PHI3(data)) && PHI2(m_laser_fdc_latch)) ||
- (PHI2(data) && !(PHI0(data) || PHI1(data) || PHI3(data)) && PHI3(m_laser_fdc_latch)) ||
- (PHI3(data) && !(PHI0(data) || PHI1(data) || PHI2(data)) && PHI0(m_laser_fdc_latch)) )
- {
- if( m_laser_track_x2[m_laser_drive] > 0 )
- m_laser_track_x2[m_laser_drive]--;
- logerror("laser_fdc_w(%d) $%02X drive %d: stepout track #%2d.%d\n", offset, data, m_laser_drive, m_laser_track_x2[m_laser_drive]/2,5*(m_laser_track_x2[m_laser_drive]&1));
- if( (m_laser_track_x2[m_laser_drive] & 1) == 0 )
- laser_get_track(machine());
- }
- else
- if( (PHI0(data) && !(PHI1(data) || PHI2(data) || PHI3(data)) && PHI3(m_laser_fdc_latch)) ||
- (PHI1(data) && !(PHI0(data) || PHI2(data) || PHI3(data)) && PHI0(m_laser_fdc_latch)) ||
- (PHI2(data) && !(PHI0(data) || PHI1(data) || PHI3(data)) && PHI1(m_laser_fdc_latch)) ||
- (PHI3(data) && !(PHI0(data) || PHI1(data) || PHI2(data)) && PHI2(m_laser_fdc_latch)) )
- {
- if( m_laser_track_x2[m_laser_drive] < 2*40 )
- m_laser_track_x2[m_laser_drive]++;
- logerror("laser_fdc_w(%d) $%02X drive %d: stepin track #%2d.%d\n", offset, data, m_laser_drive, m_laser_track_x2[m_laser_drive]/2,5*(m_laser_track_x2[m_laser_drive]&1));
- if( (m_laser_track_x2[m_laser_drive] & 1) == 0 )
- laser_get_track(machine());
- }
- if( (data & 0x40) == 0 )
- {
- m_laser_data <<= 1;
- if( (m_laser_fdc_latch ^ data) & 0x20 )
- m_laser_data |= 1;
- if( (m_laser_fdc_edge ^= 1) == 0 )
- {
- if( --m_laser_fdc_bits == 0 )
- {
- UINT8 value = 0;
- m_laser_data &= 0xffff;
- if( m_laser_data & 0x4000 ) value |= 0x80;
- if( m_laser_data & 0x1000 ) value |= 0x40;
- if( m_laser_data & 0x0400 ) value |= 0x20;
- if( m_laser_data & 0x0100 ) value |= 0x10;
- if( m_laser_data & 0x0040 ) value |= 0x08;
- if( m_laser_data & 0x0010 ) value |= 0x04;
- if( m_laser_data & 0x0004 ) value |= 0x02;
- if( m_laser_data & 0x0001 ) value |= 0x01;
- logerror("laser_fdc_w(%d) data($%04X) $%02X <- $%02X ($%04X)\n", offset, m_laser_fdc_offs, m_laser_fdc_data[m_laser_fdc_offs], value, m_laser_data);
- m_laser_fdc_data[m_laser_fdc_offs] = value;
- m_laser_fdc_offs = (m_laser_fdc_offs + 1) % TRKSIZE_FM;
- m_laser_fdc_write++;
- m_laser_fdc_bits = 8;
- }
- }
- }
- /* change of write signal? */
- if( (m_laser_fdc_latch ^ data) & 0x40 )
- {
- /* falling edge? */
- if ( m_laser_fdc_latch & 0x40 )
- {
- sprintf(m_laser_frame_message, "#%d put track %02d", m_laser_drive, m_laser_track_x2[m_laser_drive]/2);
- m_laser_frame_time = 30;
- m_laser_fdc_start = m_laser_fdc_offs;
+ int drive;
+
+ switch( offset )
+ {
+ case 0: /* latch (write-only) */
+ drive = (data & 0x10) ? 0 : (data & 0x80) ? 1 : -1;
+ if( drive != m_laser_drive )
+ {
+ m_laser_drive = drive;
+ if( m_laser_drive >= 0 )
+ laser_get_track(machine());
+ }
+ if( m_laser_drive >= 0 )
+ {
+ if( (PHI0(data) && !(PHI1(data) || PHI2(data) || PHI3(data)) && PHI1(m_laser_fdc_latch)) ||
+ (PHI1(data) && !(PHI0(data) || PHI2(data) || PHI3(data)) && PHI2(m_laser_fdc_latch)) ||
+ (PHI2(data) && !(PHI0(data) || PHI1(data) || PHI3(data)) && PHI3(m_laser_fdc_latch)) ||
+ (PHI3(data) && !(PHI0(data) || PHI1(data) || PHI2(data)) && PHI0(m_laser_fdc_latch)) )
+ {
+ if( m_laser_track_x2[m_laser_drive] > 0 )
+ m_laser_track_x2[m_laser_drive]--;
+ logerror("laser_fdc_w(%d) $%02X drive %d: stepout track #%2d.%d\n", offset, data, m_laser_drive, m_laser_track_x2[m_laser_drive]/2,5*(m_laser_track_x2[m_laser_drive]&1));
+ if( (m_laser_track_x2[m_laser_drive] & 1) == 0 )
+ laser_get_track(machine());
+ }
+ else
+ if( (PHI0(data) && !(PHI1(data) || PHI2(data) || PHI3(data)) && PHI3(m_laser_fdc_latch)) ||
+ (PHI1(data) && !(PHI0(data) || PHI2(data) || PHI3(data)) && PHI0(m_laser_fdc_latch)) ||
+ (PHI2(data) && !(PHI0(data) || PHI1(data) || PHI3(data)) && PHI1(m_laser_fdc_latch)) ||
+ (PHI3(data) && !(PHI0(data) || PHI1(data) || PHI2(data)) && PHI2(m_laser_fdc_latch)) )
+ {
+ if( m_laser_track_x2[m_laser_drive] < 2*40 )
+ m_laser_track_x2[m_laser_drive]++;
+ logerror("laser_fdc_w(%d) $%02X drive %d: stepin track #%2d.%d\n", offset, data, m_laser_drive, m_laser_track_x2[m_laser_drive]/2,5*(m_laser_track_x2[m_laser_drive]&1));
+ if( (m_laser_track_x2[m_laser_drive] & 1) == 0 )
+ laser_get_track(machine());
+ }
+ if( (data & 0x40) == 0 )
+ {
+ m_laser_data <<= 1;
+ if( (m_laser_fdc_latch ^ data) & 0x20 )
+ m_laser_data |= 1;
+ if( (m_laser_fdc_edge ^= 1) == 0 )
+ {
+ if( --m_laser_fdc_bits == 0 )
+ {
+ UINT8 value = 0;
+ m_laser_data &= 0xffff;
+ if( m_laser_data & 0x4000 ) value |= 0x80;
+ if( m_laser_data & 0x1000 ) value |= 0x40;
+ if( m_laser_data & 0x0400 ) value |= 0x20;
+ if( m_laser_data & 0x0100 ) value |= 0x10;
+ if( m_laser_data & 0x0040 ) value |= 0x08;
+ if( m_laser_data & 0x0010 ) value |= 0x04;
+ if( m_laser_data & 0x0004 ) value |= 0x02;
+ if( m_laser_data & 0x0001 ) value |= 0x01;
+ logerror("laser_fdc_w(%d) data($%04X) $%02X <- $%02X ($%04X)\n", offset, m_laser_fdc_offs, m_laser_fdc_data[m_laser_fdc_offs], value, m_laser_data);
+ m_laser_fdc_data[m_laser_fdc_offs] = value;
+ m_laser_fdc_offs = (m_laser_fdc_offs + 1) % TRKSIZE_FM;
+ m_laser_fdc_write++;
+ m_laser_fdc_bits = 8;
+ }
+ }
+ }
+ /* change of write signal? */
+ if( (m_laser_fdc_latch ^ data) & 0x40 )
+ {
+ /* falling edge? */
+ if ( m_laser_fdc_latch & 0x40 )
+ {
+ sprintf(m_laser_frame_message, "#%d put track %02d", m_laser_drive, m_laser_track_x2[m_laser_drive]/2);
+ m_laser_frame_time = 30;
+ m_laser_fdc_start = m_laser_fdc_offs;
m_laser_fdc_edge = 0;
- }
- else
- {
- /* data written to track before? */
- if( m_laser_fdc_write )
- laser_put_track(machine());
- }
- m_laser_fdc_bits = 8;
- m_laser_fdc_write = 0;
- }
- }
- m_laser_fdc_latch = data;
- break;
- }
+ }
+ else
+ {
+ /* data written to track before? */
+ if( m_laser_fdc_write )
+ laser_put_track(machine());
+ }
+ m_laser_fdc_bits = 8;
+ m_laser_fdc_write = 0;
+ }
+ }
+ m_laser_fdc_latch = data;
+ break;
+ }
}
-
-