Previous 15994 Revisions Next

r5568 Thursday 3rd September, 2009 at 22:04:12 UTC by Barry Rodewald
[X1] Added framework for CMT (cassette) functionality (not working yet), and added VSync bit on the PPI.
[src/mess/drivers]x1.c

src/mess/drivers/x1.c
r5567r5568
147147#include "sound/ay8910.h"
148148#include "video/mc6845.h"
149149#include "sound/2151intf.h"
150#include "sound/wave.h"
150151
151152#include "machine/wd17xx.h"
152153#include "devices/basicdsk.h"
154#include "devices/cassette.h"
153155#include "includes/d88.h"
154156#include <ctype.h>
155157
r5567r5568
366368}
367369
368370static UINT8 key_irq_vector;
371static UINT8 cmt_current_cmd;
369372
373static void cmt_command( running_machine* machine, UINT8 cmd )
374{
375   // CMT deck control command (E9 xx)
376   // E9 00 - Eject
377   // E9 01 - Stop
378   // E9 02 - Play
379   // E9 03 - Fast Forward
380   // E9 04 - Rewind
381   // E9 05 - APSS(?) Fast Forward
382   // E9 06 - APSS(?) Rewind
383   // E9 0A - Record
384   cmt_current_cmd = cmd;
385   
386   switch(cmd)
387   {
388      case 0x01:  // Stop
389         cassette_change_state(devtag_get_device(machine, "cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR);
390         break;
391      case 0x02:  // Play
392         cassette_change_state(devtag_get_device(machine, "cass" ),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR);
393         break;
394      default:
395         logerror("Unimplemented or invalid CMT command (0x%02x)\n",cmd);
396   }
397   logerror("CMT: Command 0xe9-0x%02x received.\n",cmd);
398}
399
370400static WRITE8_HANDLER( sub_io_w )
371401{
372402   /* TODO: check sub-routine at $10e */
r5567r5568
379409   if(sub_cmd == 0xe4)
380410      key_irq_vector = data;
381411
412   if(sub_cmd == 0xe9)
413      cmt_command(space->machine,data);
414
382415   switch(data)
383416   {
384417      case 0xe3:
r5567r5568
392425         sub_val = sub_cmd;
393426         sub_cmd_length = 1;
394427         break;
395      case 0xea:
428      case 0xea:  // CMT Control status
429         sub_val = cmt_current_cmd;
396430         sub_cmd_length = 1;
431         logerror("CMT: Command 0xEA received, returning 0x%02x.\n",sub_val);
397432         break;
398      case 0xeb:
433      case 0xeb:  // CMT Tape status
434                  // bit 0 = tape end
435               // bit 1 = tape inserted
436               // bit 2 = ???
437         sub_val = 0x02;  // assume a tape is inserted for now
399438         sub_cmd_length = 1;
439         logerror("CMT: Command 0xEB received, returning 0x%02x.\n",sub_val);
400440         break;
401441      case 0xed:
402442         sub_cmd_length = 3;
r5567r5568
419459   sub_cmd = data;
420460
421461   sub_obf = (sub_cmd_length) ? 0x00 : 0x20;
462   logerror("SUB: Command byte 0x%02x\n",data);
422463}
423464
424465/*************************************
r5567r5568
910951   ---- --x- "cmt read"
911952   ---- ---x "cmt test" (active low)
912953   */
913   return (input_port_read(device->machine, "SYSTEM") & ~0x60) | sub_obf;
954   UINT8 dat = 0;
955   dat = (input_port_read(device->machine, "SYSTEM") & ~0x68) | sub_obf;
956   
957   if((dat & 0x80) == 0)
958      dat |= 0x04;  // VSync (todo: proper implementation of vsync)
959   
960   if(cassette_input(devtag_get_device(device->machine,"cass")) > 0.03)
961      dat |= 0x02;
962
963   if(cassette_get_state(devtag_get_device(device->machine,"cass")) & CASSETTE_MOTOR_DISABLED)
964      dat |= 0x02;
965     
966   return dat;
914967}
915968
916969/* I/O system port */
r5567r5568
944997
945998   io_switch = data & 0x20;
946999   io_sys = data & 0xff;
1000   
1001   cassette_output(devtag_get_device(device->machine,"cass"),(data & 0x01) ? +1.0 : -1.0);
9471002}
9481003
9491004static const ppi8255_interface ppi8255_intf =
r5567r5568
14341489
14351490   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), x1_irq_callback);
14361491   timer_pulse(machine, ATTOTIME_IN_HZ(240), NULL, 0, keyboard_callback);
1492   
1493   cmt_current_cmd = 0;
1494   cassette_change_state(devtag_get_device(machine, "cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR);
14371495}
14381496
14391497static PALETTE_INIT(x1)
r5567r5568
15061564   MDRV_SOUND_ADD("ay", AY8910, XTAL_4MHz/4) //unknown clock / divider
15071565   MDRV_SOUND_CONFIG(ay8910_config)
15081566   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
1567   MDRV_SOUND_WAVE_ADD("wave","cass")
1568   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20)
1569
1570   MDRV_CASSETTE_ADD("cass",default_cassette_config)
15091571MACHINE_DRIVER_END
15101572
15111573static MACHINE_DRIVER_START( x1turbo )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team