Previous 15994 Revisions Next

r3133 Monday 1st September, 2008 at 12:04:52 UTC by Fabio Priuli
[COMMODORE] Added preliminary tape support to C16, C128 and VIC20 through cassette core functions. Removed dependences on old vc20tape.c abandoned and broken code. Removed fake cassette controls from inputs.
[docs]messnew.txt
[src/mess/drivers]c128.c c16.c c64.c vc20.c
[src/mess/includes]c64.h cbm.h
[src/mess/machine]c128.c c16.c c64.c cbm.c cbmipt.c vc20.c

src/mess/includes/cbm.h
r3132r3133
99
1010#include "devices/snapquik.h"
1111
12#ifdef __cplusplus
13extern "C" {
14#endif
1512
13/* global header file for c16, c64, c65, c128, vc20 */
1614
17/* must be defined until some driver init problems are solved */
18#define NEW_GAMEDRIVER
19
20
21/*----------- defined in machine/cbm.c -----------*/
22
23/* global header file for
24 * vc20
25 * c16
26 * c64
27 * c128
28 * c65*/
29
30void cbmcartslot_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
31
3215/**************************************************************************
3316 * Logging
3417 * call the XXX_LOG with XXX_LOG("info",("%fmt\n",args));
3518 * where "info" can also be 0 to append .."%fmt",args to a line.
3619 **************************************************************************/
20
3721#define LOG(LEVEL,N,M,A)  \
3822        { \
3923     if(LEVEL>=N) { \
r3132r3133
5741
5842#define DBG_LOG(n,m,a) LOG(VERBOSE_DBG,n,m,a)
5943
44
45/***********************************************
46
47   CBM Quickloads
48
49***********************************************/
50
6051QUICKLOAD_LOAD( cbm_pet1 );
6152QUICKLOAD_LOAD( cbm_pet );
6253QUICKLOAD_LOAD( cbm_c16 );
r3132r3133
7768} CBM_ROM;
7869
7970
71
72/***********************************************
73
74   CBM Cartridges
75
76***********************************************/
77
78
8079extern INT8 cbm_c64_game;
8180extern INT8 cbm_c64_exrom;
8281extern CBM_ROM cbm_rom[0x20];
r3132r3133
9594 * 0x001a lsb 16bit address
9695 * 0x001c data */
9796
97void cbmcartslot_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
9898
99#ifdef __cplusplus
100}
101#endif
10299
100
101/***********************************************
102
103   CBM Datasette Tapes
104
105***********************************************/
106
107void datasette_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
108
109
103110#endif /* CBM_H_ */
src/mess/includes/c64.h
r3132r3133
4545
4646MACHINE_START( c64 );
4747INTERRUPT_GEN( c64_frame_interrupt );
48TIMER_CALLBACK( c64_tape_timer );
4849
4950void c64_rom_load(running_machine *machine);
5051void c64_rom_recognition (void);
src/mess/machine/c128.c
r3132r3133
2020#include "includes/cbm.h"
2121#include "includes/cbmserb.h"
2222#include "includes/vc1541.h"
23#include "includes/vc20tape.h"
2423#include "video/vic6567.h"
2524#include "video/vdc8563.h"
2625
2726#include "includes/c128.h"
2827#include "includes/c64.h"
2928
29#include "devices/cassette.h"
3030
31
3132/*
3233 two cpus share 1 memory system, only 1 cpu can run
3334 controller is the mmu
r3132r3133
796797      return c64_colorram[(offset & 0x3ff)|((c64_port6510&0x3)<<10)] & 0xf;
797798}
798799
799/* 2008-08-31
800   We need here the old m6510 port handlers from c64, until we update this driver
801   to the new tape code */
800/* 2008-09-01
801   We need here the m6510 port handlers from c64, otherwise c128_common_driver_init
802   seems unable to use correctly the timer.
803   This will be probably fixed in a future clean up.
804*/
802805
803static WRITE8_HANDLER(c64_tape_read)
804{
805   cia_issue_index(machine, 0);
806}
806static emu_timer *datasette_timer;
807807
808808static void c128_m6510_port_write(UINT8 direction, UINT8 data)
809809{
810810   /* if line is marked as input then keep current value */
811   data = ( c64_port_data & ~direction ) | ( data & direction );
811   data = (c64_port_data & ~direction) | (data & direction);
812812
813   /* resistor makes cassette sense go high when P4 changes to input */
814   if ( ! ( direction & 0x10 ) ) {
815      data |= 0x10;
816   }
817813   /* resistors make P0,P1,P2 go high when respective line is changed to input */
818   if ( ! ( direction & 0x04 ) ) {
814   if (!(direction & 0x04))
819815      data |= 0x04;
820   }
821   if ( ! ( direction & 0x02 ) ) {
816
817   if (!(direction & 0x02))
822818      data |= 0x02;
823   }
824   if ( ! ( direction & 0x01 ) ) {
819
820   if (!(direction & 0x01))
825821      data |= 0x01;
826   }
822
827823   c64_port_data = data;
828824
829825   if (c64_tape_on)
830826   {
831      if ( direction & 0x08 ) {
832         vc20_tape_write (!(data & 8));
827      if (direction & 0x08)
828      {
829      /* CASSETTE_RECORD is not implemented yet */
833830      }
834      if ( direction & 0x20 ) {
835         vc20_tape_motor (data & 0x20);
831
832      if (direction & 0x20)
833      {
834         if(!(data & 0x20))
835         {
836            cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR);
837            timer_adjust_periodic(datasette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(44100));
838         }
839         else
840         {
841            cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_DISABLED ,CASSETTE_MASK_MOTOR);
842            timer_reset(datasette_timer, attotime_never);
843         }
836844      }
837845   }
838846
r3132r3133
847855   running_machine *machine = Machine;
848856   UINT8 data = c64_port_data;
849857
850   if (c64_tape_on && !vc20_tape_switch())
858   if ((cassette_get_state(image_from_devtype_and_index(IO_CASSETTE, 0)) & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY)
851859      data &= ~0x10;
852   /* WP: motor is always marked as on??? */
853   data &= ~0x20;
860   else
861      data |=  0x10;
854862
855863   if (input_port_read(machine, "SPECIAL") & 0x20)      /* Check Caps Lock */
856864   {
r3132r3133
868876   UINT8 *ram = memory_region(machine, "main");
869877   int i;
870878
879   cia6526_interface cia_intf[2];
880
871881   /* configure the M6510 port */
872882   cpunum_set_info_fct(1, CPUINFO_PTR_M6510_PORTREAD, (genf *) c128_m6510_port_read);
873883   cpunum_set_info_fct(1, CPUINFO_PTR_M6510_PORTWRITE, (genf *) c128_m6510_port_write);
r3132r3133
890900   for (i=0; i<0x100; i++)
891901      gfx[i]=i;
892902
893   vc20_tape_open (c64_tape_read);
903   if (c64_tape_on)
904      datasette_timer = timer_alloc(c64_tape_timer, NULL);
894905
895   {
896      cia6526_interface cia_intf[2];
897      cia_intf[0] = c64_cia0;
898      cia_intf[1] = c64_cia1;
899      cia_intf[0].tod_clock = c64_pal ? 50 : 60;
900      cia_intf[1].tod_clock = c64_pal ? 50 : 60;
906   /* CIA initialization */
907   cia_intf[0] = c64_cia0;
908   cia_intf[1] = c64_cia1;
909   cia_intf[0].tod_clock = c64_pal ? 50 : 60;
910   cia_intf[1].tod_clock = c64_pal ? 50 : 60;
901911
902      cia_config(machine, 0, &cia_intf[0]);
903      cia_config(machine, 1, &cia_intf[1]);
904   }
912   cia_config(machine, 0, &cia_intf[0]);
913   cia_config(machine, 1, &cia_intf[1]);
905914}
906915
907916DRIVER_INIT( c128 )
908917{
918   c64_tape_on = 1;
909919   c128_common_driver_init(machine);
910920   vic6567_init (1, c64_pal,
911921              c128_dma_read, c128_dma_read_color, c64_vic_interrupt);
r3132r3133
916926
917927DRIVER_INIT( c128pal )
918928{
929   c64_tape_on = 1;
919930   c64_pal = 1;
920931   c128_common_driver_init(machine);
921932   vic6567_init (1, c64_pal,
src/mess/machine/c16.c
r3132r3133
1717#include "includes/cbm.h"
1818#include "includes/cbmserb.h"
1919#include "includes/vc1541.h"
20#include "includes/vc20tape.h"
2120#include "machine/tpi6525.h"
2221#include "video/ted7360.h"
2322
2423#include "includes/c16.h"
2524
25#include "devices/cassette.h"
26
2627static UINT8 keyline[10] =
2728{
2829   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
r3132r3133
121122   cbm_serial_atn_write (atn = !(data & 4));
122123   cbm_serial_clock_write (clk = !(data & 2));
123124   cbm_serial_data_write (dat = !(data & 1));
124   vc20_tape_write (!(data & 2));
125   vc20_tape_motor (data & 8);
125//   vc20_tape_write (!(data & 2));      // CASSETTE_RECORD not implemented yet
126
127//   Fix Me!
128//   HACK! we need to set the motor always ON, because !(data & 0x08) seems always 0
129//   cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0), !(data & 0x08) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
130   cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0), CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR);
126131}
127132
128133UINT8 c16_m7501_port_read(void)
r3132r3133
136141   if ((c16_port7501 & 0x02) || !cbm_serial_clock_read())
137142      data &= ~0x40;
138143
139   if (!vc20_tape_read())
144/*   data &= ~0x20; //port bit not in pinout */
145
146   if (cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0)) > +0.0)
147      data |=  0x10;
148   else
140149      data &= ~0x10;
141150
142/*   data &= ~0x20; //port bit not in pinout */
143151   return data;
144152}
145153
r3132r3133
293301{
294302   int data = 0;
295303
296   if (vc20_tape_switch ())
304   if (!((cassette_get_state(image_from_devtype_and_index(IO_CASSETTE, 0)) & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY))
297305      data |= 4;
298306   return data;
299307}
r3132r3133
302310{
303311   int data = 0;
304312
305   if (vc20_tape_switch ())
313   if (!((cassette_get_state(image_from_devtype_and_index(IO_CASSETTE, 0)) & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY))
306314      data |= 4;
307315   return data;
308316}
r3132r3133
468476
469477   memset(mess_ram + (0xfd40 % mess_ram_size), 0xff, 0x20);
470478
471   c16_tape_open ();
472
473479   if ((read_cfg0(machine) & 0xc0 ) == 0x40)      /* C1551 */
474480      c1551_config (0, 0, &config);
475481
r3132r3133
707713
708714   ted7360_frame_interrupt (machine, cpunum);
709715
710   vc20_tape_config (input_port_read(machine, "DSW0") & 0x20, input_port_read(machine, "DSW0") & 0x10);   /* DATASSETTE, DATASSETTE_TONE */
711   vc20_tape_buttons (input_port_read(machine, "DSW0") & 0x04, input_port_read(machine, "DSW0") & 0x02, input_port_read(machine, "DSW0") & 0x01);   /* DATASETTE_PLAY, DATASETTE_RECORD, DATASETTE_STOP */
712
713716   set_led_status (1, input_port_read(machine, "SPECIAL") & 0x80 ? 1 : 0);      /*KB_CAPSLOCK_FLAG */
714717   set_led_status (0, input_port_read(machine, "SPECIAL") & 0x40 ? 1 : 0);      /*KB_NUMLOCK_FLAG */
715718}
src/mess/machine/cbmipt.c
r3132r3133
225225
226226INPUT_PORTS_START( c64_config )
227227   PORT_START( "CFG" )
228   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Quickload")  PORT_CODE(KEYCODE_SLASH_PAD)
229228   PORT_DIPNAME( 0x4000, 0x4000, "Tape Drive/Device 1")                           
230229   PORT_DIPSETTING(   0x0000, DEF_STR( Off ) )                                 
231230   PORT_DIPSETTING(   0x4000, DEF_STR( On ) )                                   
232231   PORT_DIPNAME( 0x2000, 0x0000, "Tape Sound")                                 
233232   PORT_DIPSETTING(   0x0000, DEF_STR( Off ) )                                 
234233   PORT_DIPSETTING(   0x2000, DEF_STR( On ) )                                   
235   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Play")           
236   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Record")         
237   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Stop")           
238234   PORT_DIPNAME( 0x80, 0x00, "Sid Chip Type")                                 
239235   PORT_DIPSETTING(   0x00, "MOS6581" )                                       
240236   PORT_DIPSETTING(   0x80, "MOS8580" )                                       
r3132r3133
366362   PORT_DIPNAME( 0x10, 0x00, "Tape Sound")         
367363   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )     
368364   PORT_DIPSETTING(   0x10, DEF_STR( On ) )     
369   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Quickload")  PORT_CODE(KEYCODE_SLASH_PAD)     
370   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Play")
371   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Record")
372   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Stop")
373365
374366   PORT_START("CFG0")
375367   PORT_BIT( 0xc0, 0x00, IPT_UNUSED )                       
r3132r3133
448440
449441INPUT_PORTS_START( c128_config )
450442   PORT_START("CFG")
451   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Quickload") PORT_CODE(KEYCODE_SLASH_PAD)
452443   PORT_DIPNAME( 0x4000, 0x4000, "Tape Drive / Device 1")                           
453444   PORT_DIPSETTING(   0x0000, DEF_STR( Off ) )                                 
454445   PORT_DIPSETTING(   0x4000, DEF_STR( On ) )                                   
455446   PORT_DIPNAME( 0x2000, 0x00, "Tape Sound")                                   
456447   PORT_DIPSETTING(   0x0000, DEF_STR( Off ) )                                 
457448   PORT_DIPSETTING(   0x2000, DEF_STR( On ) )                                   
458   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Play")           
459   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Record")         
460   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Stop")           
461449   PORT_DIPNAME( 0x0300, 0x0000, "Main Memory / MMU Version")                       
462450   PORT_DIPSETTING(   0x0000, "128 KByte" )                                   
463451   PORT_DIPSETTING(   0x0100, "256 KByte" )                                   
r3132r3133
1008996 *   - vic_keyboard: basic Vic 20 keyboard
1009997 *  - vic_special: input port for the Shift Lock Switch
1010998 *   - vic_controls: joypads and paddles
1011 *   - vic_devices: quickload and tapes (to be removed when fixed vc20tape.c)
1012999 *   - vic_expansion: RAM expansions
10131000 *   - vic_config: controllers, tape and serial configurations
10141001 *   - VIC20 also has 2 lightpen ports, vic_lightpen_6560 & vic_lightpen_6561
r3132r3133
11351122INPUT_PORTS_END
11361123
11371124
1125/* Paddle buttons are read in the same bits as some joystick inputs */
1126static CUSTOM_INPUT( vic_custom_inputs )
1127{
1128   int bit_mask = (FPTR)param;
1129   UINT8 port = 0;
1130   
1131   if (input_port_read(field->port->machine, "CFG") & 0x40)
1132      port |= (input_port_read(field->port->machine, "FAKE0") & bit_mask) ? 1 : 0;
1133
1134   if (input_port_read(field->port->machine, "CFG") & 0x80)
1135      port |= (input_port_read(field->port->machine, "FAKE1") & bit_mask) ? 1 : 0;
1136
1137   return port;
1138}
1139   
11381140INPUT_PORTS_START( vic_controls )
11391141   PORT_START( "JOY" )
1140   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP)   PORT_NAME("Joystick Up")      PORT_8WAY           
1141   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN)   PORT_NAME("Joystick Down")      PORT_8WAY         
1142   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT)   PORT_NAME("Joystick Left")      PORT_8WAY         
1143   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT)   PORT_NAME("Joystick Right")      PORT_8WAY         
1144   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1)      PORT_NAME("Joystick Button")                     
1145   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1)      PORT_NAME("Paddle 1 Button")   PORT_CODE(KEYCODE_INSERT)   
1146   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON2)      PORT_NAME("Paddle 2 Button")   PORT_CODE(KEYCODE_DEL)   
1147   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1)      PORT_NAME("Lightpen Signal")   PORT_CODE(KEYCODE_LALT)   
1142   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(vic_custom_inputs, (void *)0x02)
1143   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Lightpen Signal") PORT_CODE(KEYCODE_LALT)   
1144   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(vic_custom_inputs, (void *)0x01)
1145   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY         
1146   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY         
1147   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY           
11481148
1149   PORT_START( "FAKE0" )
1150   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Paddle 2 Button") PORT_CODE(KEYCODE_DEL)   
1151   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Paddle 1 Button") PORT_CODE(KEYCODE_INSERT)   
1152
1153   PORT_START( "FAKE1" )
1154   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY         
1155   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 )
1156
11491157   PORT_START( "PADDLE0" )
11501158   PORT_BIT( 0xff,128,IPT_PADDLE) PORT_SENSITIVITY(30) PORT_KEYDELTA(20) PORT_MINMAX(0,255) PORT_CODE_DEC(KEYCODE_HOME) PORT_CODE_INC(KEYCODE_PGUP) PORT_REVERSE
11511159
r3132r3133
11541162INPUT_PORTS_END
11551163
11561164
1157INPUT_PORTS_START( vic_devices )
1158   PORT_START( "DEVS" )
1159   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Quickload") PORT_CODE(KEYCODE_SLASH_PAD)
1160   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Play")                 
1161   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Record")                 
1162   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Tape Drive Stop")
1163INPUT_PORTS_END
1164
1165
11661165INPUT_PORTS_START( vic_expansion )
11671166   PORT_START( "EXP" )
11681167   PORT_DIPNAME( 0x07, 0x00, "RAM Cartridge")
src/mess/machine/cbm.c
r3132r3133
44#include "driver.h"
55#include "includes/cbm.h"
66#include "devices/cartslot.h"
7#include "devices/cassette.h"
78
89
10/***********************************************
11
12   CBM Quickloads
13
14***********************************************/
15
16
917static int general_cbm_loadsnap(const device_config *image, const char *file_type, int snapshot_size,
1018   offs_t offset, void (*cbm_sethiaddress)(UINT16 hiaddress))
1119{
r3132r3133
156164   return general_cbm_loadsnap(image, file_type, quickload_size, 0, cbm_c65_quick_sethiaddress);
157165}
158166
159/* ----------------------------------------------------------------------- */
160167
168/***********************************************
169
170   CBM Cartridges
171
172***********************************************/
173
174
161175INT8 cbm_c64_game;
162176INT8 cbm_c64_exrom;
163177CBM_ROM cbm_rom[0x20]= { {0} };
r3132r3133
333347   }
334348}
335349
350
351/***********************************************
352
353   CBM Datasette Tapes
354
355***********************************************/
356
357void datasette_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
358{
359   /* cassette */
360   switch(state)
361   {
362   case MESS_DEVINFO_INT_COUNT:               info->i = 1; break;
363
364   case MESS_DEVINFO_INT_CASSETTE_DEFAULT_STATE:   info->i = CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED; break;
365
366   default:                              cassette_device_getinfo( devclass, state, info ); break;
367   }
368}
src/mess/machine/vc20.c
r3132r3133
2121#include "includes/cbm.h"
2222#include "machine/6522via.h"
2323#include "includes/vc1541.h"
24#include "includes/vc20tape.h"
2524#include "includes/cbmserb.h"
2625#include "includes/cbmieeeb.h"
2726#include "video/vic6560.h"
2827
2928#include "includes/vc20.h"
3029
30#include "devices/cassette.h"
31
32
3133static UINT8 keyboard[8] =
3234{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3335
r3132r3133
4042static UINT8 *vc20_rom_6000;
4143static UINT8 *vc20_rom_a000;
4244
45static emu_timer *datasette_timer;
46
4347UINT8 *vc20_memory_9400;
4448
49
4550/** via 0 addr 0x9110
4651 ca1 restore key (low)
4752 ca2 cassette motor on
r3132r3133
7479
7580static WRITE8_HANDLER( vc20_via0_write_ca2 )
7681{
77   via0_ca2 = data ? 1 : 0;
78   vc20_tape_motor (via0_ca2);
82   via0_ca2 = data ? 0 : 1;
83
84   if(via0_ca2)
85   {
86      cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR);
87      timer_adjust_periodic(datasette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(44100));
88   }
89   else
90   {
91      cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_DISABLED ,CASSETTE_MASK_MOTOR);
92      timer_reset(datasette_timer, attotime_never);
93   }
7994}
8095
8196static  READ8_HANDLER( vc20_via0_read_porta )
8297{
8398   UINT8 value = 0xff;
8499
85   if (input_port_read(machine, "CFG") & 0x80)      /* JOYSTICK */
86   {
87      if (input_port_read(machine, "JOY") & 0x10) /* JOY_BUTTON */
88         value&=~0x20;
89      if (input_port_read(machine, "JOY") & 4)   /* JOY_LEFT */
90         value&=~0x10;
91      if (input_port_read(machine, "JOY") & 2)   /* JOY_DOWN */
92         value&=~0x8;
93      if (input_port_read(machine, "JOY") & 1)   /* JOY_UP */
94         value&=~0x4;
95   }
96   if (input_port_read(machine, "CFG") & 0x40)       /* PADDLE */
97   {
98      if (input_port_read(machine, "JOY") & 0x20)  /* PUDDLE1_BUTTON */
99         value&=~0x10;
100   }
100   value &= ~(input_port_read(machine, "JOY") & 0x3c);
101
101102   /* to short to be recognized normally */
102103   /* should be reduced to about 1 or 2 microseconds */
103   /*  if ((input_port_read(machine, "CFG") & 0x20 ) && (input_port_read(machine, "JOY") & 0x80) )  // i.e. LIGHTPEN_BUTTON
104   /*  if ((input_port_read(machine, "CFG") & 0x20 ) && (input_port_read(machine, "JOY") & 0x40) )  // i.e. LIGHTPEN_BUTTON
104105      value&=~0x20; */
105106   if (!serial_clock || !cbm_serial_clock_read ())
106107      value &= ~1;
107108   if (!serial_data || !cbm_serial_data_read ())
108109      value &= ~2;
109   if (!vc20_tape_switch ())
110
111   if ((cassette_get_state(image_from_devtype_and_index(IO_CASSETTE, 0)) & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY)
110112      value &= ~0x40;
113   else
114      value |=  0x40;
115
111116   return value;
112117}
113118
r3132r3133
166171
167172static  READ8_HANDLER( vc20_via1_read_ca1 )
168173{
169   return vc20_tape_read ();
174   UINT8 data = (cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0)) > +0.0) ? 1 : 0;
175   return data;
170176}
171177
172178static WRITE8_HANDLER( vc20_via1_write_ca2 )
r3132r3133
275281   value &=t;
276282    }
277283
278   if (input_port_read(machine, "CFG") & 0x80)      /* JOYSTICK */
279   {
280      if (input_port_read(machine, "JOY") & 8)    /* JOY_RIGHT */
281         value &= ~0x80;
282   }
283   
284   if (input_port_read(machine, "CFG") & 0x40)    /* PADDLE */
285   {
286      if (input_port_read(machine, "JOY") & 0x40)  /* PUDDLE2_BUTTON */
287         value &= ~0x80;
288   }
284   value &= ~(input_port_read(machine, "JOY") & 0x80);
289285
290286   return value;
291287}
r3132r3133
299295static WRITE8_HANDLER( vc20_via1_write_portb )
300296{
301297/*  logerror("via1_write_portb: $%02X\n", data); */
302   vc20_tape_write (data & 8 ? 1 : 0);
298//   vc20_tape_write (data & 8 ? 1 : 0);      // CASSETTE_RECORD not implemeted yet!
303299   via1_portb = data;
304300}
305301
r3132r3133
480476   }
481477}
482478
479
483480static void vc20_memory_init(running_machine *machine)
484481{
485482   static int inited=0;
r3132r3133
516513   inited=1;
517514}
518515
516
517TIMER_CALLBACK( vc20_tape_timer )
518{
519   UINT8 data = (cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0)) > +0.0) ? 1 : 0;
520   via_1_ca1_w(machine, 0, data);
521}
522
519523static void vc20_common_driver_init (running_machine *machine)
520524{
521525#ifdef VC1541
r3132r3133
523527#endif
524528   vc20_memory_init(machine);
525529
526   vc20_tape_open (via_1_ca1_w);
530   datasette_timer = timer_alloc(vc20_tape_timer, NULL);
527531
528532#ifdef VC1541
529533   vc1541_config (0, 0, &vc1541);
r3132r3133
539543   memory_set_bankptr( 5, vc20_rom_a000 ? vc20_rom_a000 : ( memory_region(machine, "main") + 0xa000 ) );
540544}
541545
542/* currently not used, but when time comes */
543void vc20_driver_shutdown (void)
544{
545   vc20_tape_close ();
546}
547546
548547DRIVER_INIT( vc20 )
549548{
r3132r3133
734733   keyboard[6] = input_port_read(machine, "ROW6");
735734   keyboard[7] = input_port_read(machine, "ROW7");
736735
737   vc20_tape_config (input_port_read(machine, "CFG") & 0x08, input_port_read(machine, "CFG") & 0x04);   /* DATASSETTE, DATASSETTE_TONE */
738   vc20_tape_buttons (input_port_read(machine, "DEVS") & 4, input_port_read(machine, "DEVS") & 2, input_port_read(machine, "DEVS") & 1);   /* DATASSETTE_PLAY, DATASSETTE_RECORD, DATASSETTE_STOP */
739   
740736   set_led_status (1, input_port_read(machine, "SPECIAL") & 0x01 ? 1 : 0);      /*KB_CAPSLOCK_FLAG */
741737}
src/mess/machine/c64.c
r3132r3133
3535#include "includes/cbm.h"
3636#include "includes/cbmserb.h"
3737#include "includes/vc1541.h"
38#include "includes/vc20tape.h"
3938#include "video/vic6567.h"
4039#include "video/vdc8563.h"
4140
r3132r3133
684683      else if (loram && !hiram && !c64_game)   // remember we cannot be in ultimax_mode, no need of !c64_exrom
685684      {
686685         c64_io_enabled = 0;
687         c64_io_ram_w_ptr = c64_memory + 0xd000;
688686         c64_io_ram_r_ptr = (!charen) ? c64_chargen : c64_memory + 0xd000;
687         c64_io_ram_w_ptr = c64_memory + 0xd000;
689688      }
690689      // IO/C
691690      else
r3132r3133
694693
695694         if (!charen)
696695         {
697         c64_io_ram_w_ptr = c64_memory + 0xd000;
698696         c64_io_ram_r_ptr = c64_chargen;
697         c64_io_ram_w_ptr = c64_memory + 0xd000;
699698         }
700699      }
701700
r3132r3133
756755      {
757756         if(!(data & 0x20))
758757         {
759            cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR);
758            cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0), CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR);
760759            timer_adjust_periodic(datasette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(44100));
761760         }
762761         else
763762         {
764            cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_DISABLED ,CASSETTE_MASK_MOTOR);
763            cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0), CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
765764            timer_reset(datasette_timer, attotime_never);
766765         }
767766      }
r3132r3133
905904
906905double last = 0;
907906
908static TIMER_CALLBACK( c64_tape_timer )
907TIMER_CALLBACK( c64_tape_timer )
909908{
910909   double tmp = cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0));
911910
src/mess/drivers/c128.c
r3132r3133
294294*/
295295
296296#include "driver.h"
297#include "includes/c128.h"
298#include "includes/c64.h"
299
300297#include "sound/sid6581.h"
301298#include "machine/6526cia.h"
302299
r3132r3133
307304#include "video/vdc8563.h"
308305#include "includes/cbmserb.h"
309306#include "includes/vc1541.h"
310#include "includes/vc20tape.h"
311307
308#include "includes/c128.h"
309#include "includes/c64.h"
312310
311
313312/* shares ram with m8502
314313 * how to bankswitch ?
315314 * bank 0
r3132r3133
916915static SYSTEM_CONFIG_START(c128)
917916   CONFIG_DEVICE(c128_cbmcartslot_getinfo)
918917   CONFIG_DEVICE(cbmfloppy_device_getinfo)
918   CONFIG_DEVICE(datasette_device_getinfo)
919919SYSTEM_CONFIG_END
920920
921921static SYSTEM_CONFIG_START(c128d)
922922   CONFIG_DEVICE(c1571_device_getinfo)
923   CONFIG_DEVICE(datasette_device_getinfo)
923924SYSTEM_CONFIG_END
924925
925926/*    YEAR  NAME        PARENT  COMPAT  MACHINE     INPUT       INIT        CONFIG  COMPANY   FULLNAME */
src/mess/drivers/c16.c
r3132r3133
158158
159159#define VERBOSE_DBG 0
160160#include "includes/cbm.h"
161#include "includes/c16.h"
162161#include "includes/cbmserb.h"
163162#include "includes/vc1541.h"
164#include "includes/vc20tape.h"
165163#include "machine/cbmipt.h"
166164#include "video/ted7360.h"
167165#include "devices/cartslot.h"
168166
167#include "includes/c16.h"
168
169
169170/*
170171 * commodore c16/c116/plus 4
171172 * 16 KByte (C16/C116) or 32 KByte or 64 KByte (plus4) RAM
r3132r3133
702703   }
703704}
704705
706
705707static SYSTEM_CONFIG_START(c16)
706708   CONFIG_DEVICE(c16cart_device_getinfo)
707709   CONFIG_DEVICE(cbmfloppy_device_getinfo)
708   CONFIG_DEVICE(vc20tape_device_getinfo)
710   CONFIG_DEVICE(datasette_device_getinfo)
709711   CONFIG_RAM(16 * 1024)
710712   CONFIG_RAM(32 * 1024)
711713   CONFIG_RAM_DEFAULT(64 * 1024)
r3132r3133
713715
714716static SYSTEM_CONFIG_START(c16c)
715717   CONFIG_DEVICE(c16cart_device_getinfo)
716   CONFIG_DEVICE(vc20tape_device_getinfo)
718   CONFIG_DEVICE(datasette_device_getinfo)
717719   CONFIG_DEVICE(c1551_device_getinfo)
718720   CONFIG_RAM(16 * 1024)
719721   CONFIG_RAM(32 * 1024)
r3132r3133
722724
723725static SYSTEM_CONFIG_START(c16v)
724726   CONFIG_DEVICE(c16cart_device_getinfo)
725   CONFIG_DEVICE(vc20tape_device_getinfo)
727   CONFIG_DEVICE(datasette_device_getinfo)
726728   CONFIG_DEVICE(vc1541_device_getinfo)
727729   CONFIG_RAM(16 * 1024)
728730   CONFIG_RAM(32 * 1024)
r3132r3133
732734static SYSTEM_CONFIG_START(plus)
733735   CONFIG_DEVICE(c16cart_device_getinfo)
734736   CONFIG_DEVICE(cbmfloppy_device_getinfo)
735   CONFIG_DEVICE(vc20tape_device_getinfo)
737   CONFIG_DEVICE(datasette_device_getinfo)
736738   CONFIG_RAM_DEFAULT(64 * 1024)
737739SYSTEM_CONFIG_END
738740
739741static SYSTEM_CONFIG_START(plusc)
740742   CONFIG_DEVICE(c16cart_device_getinfo)
741   CONFIG_DEVICE(vc20tape_device_getinfo)
743   CONFIG_DEVICE(datasette_device_getinfo)
742744   CONFIG_DEVICE(c1551_device_getinfo)
743745   CONFIG_RAM_DEFAULT(64 * 1024)
744746SYSTEM_CONFIG_END
745747
746748static SYSTEM_CONFIG_START(plusv)
747749   CONFIG_DEVICE(c16cart_device_getinfo)
748   CONFIG_DEVICE(vc20tape_device_getinfo)
750   CONFIG_DEVICE(datasette_device_getinfo)
749751   CONFIG_DEVICE(vc1541_device_getinfo)
750752   CONFIG_RAM_DEFAULT(64 * 1024)
751753SYSTEM_CONFIG_END
src/mess/drivers/vc20.c
r3132r3133
155155
156156#define VERBOSE_DBG 0
157157#include "includes/cbm.h"
158#include "includes/vc20.h"
159158#include "machine/6522via.h"
160159#include "includes/cbmserb.h"
161160#include "includes/vc1541.h"
162#include "includes/vc20tape.h"
163161#include "machine/cbmipt.h"
164162#include "video/vic6560.h"
165163#include "devices/cartslot.h"
166164
165#include "includes/vc20.h"
166
167
167168static ADDRESS_MAP_START( vc20_mem , ADDRESS_SPACE_PROGRAM, 8)
168169   AM_RANGE(0x0000, 0x03ff) AM_RAM
169170   AM_RANGE(0x0400, 0x0fff) AM_ROMBANK(1) AM_WRITE( vc20_0400_w )   /* ram, rom or nothing */
r3132r3133
241242   /* Lightpen 6560 */
242243   PORT_INCLUDE( vic_lightpen_6560 )   /* LIGHTX, LIGHTY */
243244
244   PORT_INCLUDE( vic_devices )         /* DEVS */
245
246245   PORT_INCLUDE( vic_expansion )      /* EXP */
247246
248247   PORT_INCLUDE( vic_config )         /* CFG */
r3132r3133
285284   /* Lightpen 6561 */
286285   PORT_INCLUDE( vic_lightpen_6561 )   /* LIGHTX, LIGHTY */
287286
288   PORT_INCLUDE( vic_devices )         /* DEVS */
289
290287   PORT_INCLUDE( vic_expansion )      /* EXP */
291288
292289   PORT_INCLUDE( vic_config )         /* CFG */
r3132r3133
514511   }
515512}
516513
514
517515static SYSTEM_CONFIG_START(vc20)
518516   CONFIG_DEVICE(cbmvc20_cartslot_getinfo)
519517   CONFIG_DEVICE(cbmfloppy_device_getinfo)
520   CONFIG_DEVICE(vc20tape_device_getinfo)
518   CONFIG_DEVICE(datasette_device_getinfo)
521519   CONFIG_RAM_DEFAULT(5 * 1024)
522520   CONFIG_RAM(8 * 1024)
523521   CONFIG_RAM(16 * 1024)
r3132r3133
527525
528526static SYSTEM_CONFIG_START(vc20v)
529527   CONFIG_DEVICE(cbmvc20_cartslot_getinfo)
530   CONFIG_DEVICE(vc20tape_device_getinfo)
528   CONFIG_DEVICE(datasette_device_getinfo)
531529   CONFIG_DEVICE(vc1541_device_getinfo)
532530   CONFIG_RAM_DEFAULT(5 * 1024)
533531   CONFIG_RAM(8 * 1024)
src/mess/drivers/c64.c
r3132r3133
193193#include "driver.h"
194194#include "sound/sid6581.h"
195195#include "machine/6526cia.h"
196#include "devices/cassette.h"
197196
198197#define VERBOSE_DBG 0
199198#include "includes/cbm.h"
r3132r3133
595594   }
596595}
597596
598static void datasette_device_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
599{
600   /* cassette */
601   switch(state)
602   {
603   case MESS_DEVINFO_INT_COUNT:               info->i = 1; break;
604597
605   case MESS_DEVINFO_INT_CASSETTE_DEFAULT_STATE:   info->i = CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED; break;
606598
607   default:                              cassette_device_getinfo( devclass, state, info ); break;
608   }
609}
610
611599static SYSTEM_CONFIG_START(c64)
612600   CONFIG_DEVICE(c64_cbmcartslot_getinfo)
613601   CONFIG_DEVICE(cbmfloppy_device_getinfo)
docs/messnew.txt
r3132r3133
99System Driver Changes:
1010----------------------
1111
12- [C64] added partial support to tape emulation (only loading and only .wav) [Fabio Priuli, Roberto Zandona']
12- [C16] added preliminary support for tape emulation using MESS core
13  functions (only loading and only .wav) [Fabio Priuli]
1314
15- [C128] added preliminary support for tape emulation using MESS core
16  functions (only loading and only .wav) [Fabio Priuli]
17
18- [C64] added partial support for tape emulation using MESS core
19  functions (only loading and only .wav) [Fabio Priuli, Roberto Zandona']
20
1421- [C64] fixed border color during tape loading [Roberto Zandona']
1522
1623- [C64] partial cleanup of memory bankswitch, based on docs [Fabio Priuli]
r3132r3133
2128
2229- [TMC2000] Fixed quickloading. [Curt Coder]
2330
31- [VC20] added preliminary support for tape emulation using MESS core
32  functions (only loading and only .wav) [Fabio Priuli]
33
2434- [VIP] Fixed memory banking, added discrete sound, added tape support,
2535  and improved quickloading so that the CHIP-8 interpreter is automatically
2636  loaded alongside .c8 files. [Curt Coder]

Previous 15994 Revisions Next


© 1998-2018 The MESS Team