Previous 15994 Revisions Next

r6627 Monday 14th December, 2009 at 13:57:29 UTC by Curt Coder
[C1541] Almost working now, just need to figure out why the job flag is never cleared by DOS...
[src/emu/machine]6522via.c
[src/mess/drivers]c64.c
[src/mess/formats]g64_dsk.c g64_dsk.h
[src/mess/machine]c1541.c

src/emu/machine/6522via.c
r6626r6627
263263   /* Default clock is from CPU1 */
264264   if (device->clock == 0)
265265      device_set_clock(device, device->machine->firstcpu->clock);
266
267   /* save state register */
268   state_save_register_device_item(device, 0, v->in_a);
269   state_save_register_device_item(device, 0, v->in_ca1);
270   state_save_register_device_item(device, 0, v->in_ca2);
271   state_save_register_device_item(device, 0, v->out_a);
272   state_save_register_device_item(device, 0, v->out_ca2);
273   state_save_register_device_item(device, 0, v->ddr_a);
274   state_save_register_device_item(device, 0, v->in_b);
275   state_save_register_device_item(device, 0, v->in_cb1);
276   state_save_register_device_item(device, 0, v->in_cb2);
277   state_save_register_device_item(device, 0, v->out_b);
278   state_save_register_device_item(device, 0, v->out_cb2);
279   state_save_register_device_item(device, 0, v->ddr_b);
280   state_save_register_device_item(device, 0, v->t1cl);
281   state_save_register_device_item(device, 0, v->t1ch);
282   state_save_register_device_item(device, 0, v->t1ll);
283   state_save_register_device_item(device, 0, v->t1lh);
284   state_save_register_device_item(device, 0, v->t2cl);
285   state_save_register_device_item(device, 0, v->t2ch);
286   state_save_register_device_item(device, 0, v->t2ll);
287   state_save_register_device_item(device, 0, v->t2lh);
288   state_save_register_device_item(device, 0, v->sr);
289   state_save_register_device_item(device, 0, v->pcr);
290   state_save_register_device_item(device, 0, v->acr);
291   state_save_register_device_item(device, 0, v->ier);
292   state_save_register_device_item(device, 0, v->ifr);
293   state_save_register_device_item(device, 0, v->t1_active);
294   state_save_register_device_item(device, 0, v->t2_active);
295   state_save_register_device_item(device, 0, v->shift_counter);
266296}
267297
268298
src/mess/machine/c1541.c
r6626r6627
118118
119119   TODO:
120120
121   - read data fails
122   - detect sync from 10 consecutive 1-bits
123   - get track length from image
121   - job flag never gets cleared
124122   - activity led
125123   - write G64
126124   - D64 to G64 conversion
r6626r6627
154152   XTAL_16MHz/13.0, XTAL_16MHz/14.0, XTAL_16MHz/15.0, XTAL_16MHz/16.0
155153};
156154
155#define SYNC_MARK      0x3ff
156
157157/***************************************************************************
158158    TYPE DEFINITIONS
159159***************************************************************************/
r6626r6627
165165   int address;                  /* serial bus address - 8 */
166166   UINT8 track_buffer[8192];         /* track data buffer */
167167   int track_len;                  /* track length */
168   int track : 1;                  /* current position of the actuator (half track) */
169168   int buffer_pos;                  /* current byte position within track buffer */
170169   int bit_pos;                  /* current bit position within track buffer byte */
170   int bit_count;                  /*  */
171   UINT16 data;
171172
172173   /* signals */
173174   UINT8 yb;                     /* GCR data byte */
r6626r6627
177178   int stp;                     /* stepping motor */
178179   int soe;                     /* s? output enable */
179180   int mode;                     /* mode (0 = write, 1 = read) */
180   int sync;
181181
182182   /* serial bus */
183183   int data_out;                  /* serial bus data output */
r6626r6627
226226   c1541_t *c1541 = get_safe_token(device);
227227   int byte = 0;
228228
229   if (c1541->bit_pos == 0x07)
229   /* shift in data from the read head */
230   c1541->data <<= 1;
231   c1541->data |= BIT(c1541->track_buffer[c1541->buffer_pos], c1541->bit_pos);
232   c1541->bit_pos--;
233   c1541->bit_count++;
234
235   if (c1541->bit_pos < 0)
230236   {
231      UINT8 data = c1541->track_buffer[c1541->buffer_pos];
232
233      if (data != 0xff)
234      {
235         c1541->yb = data;
236         byte = 1;
237      }
238
239      c1541->sync = !(c1541->mode && (data == 0xff));
240
237      c1541->bit_pos = 7;
241238      c1541->buffer_pos++;
242239
243      if (c1541->buffer_pos > c1541->track_len)
240      if (c1541->buffer_pos > c1541->track_len + 1)
244241      {
245         c1541->buffer_pos = 0;
242         /* loop to the start of the track */
243         c1541->buffer_pos = 2;
246244      }
245   }
247246
248//      logerror("YB %02x pos %u\n", c1541->yb, c1541->buffer_pos-1);
247   if ((c1541->data & SYNC_MARK) == SYNC_MARK)
248   {
249      /* SYNC detected */
250      c1541->bit_count = 0;
251   }
249252
250      c1541->bit_pos = 0;
251   }
252   else
253   if (c1541->bit_count > 7)
253254   {
254      c1541->bit_pos++;
255      /* byte ready */
256      c1541->bit_count = 0;
257      byte = 1;
255258   }
256259
257260   if (c1541->byte != byte)
r6626r6627
418421
419422   c1541_t *c1541 = get_safe_token(device->owner);
420423
421   return c1541->yb;
424   return c1541->data & 0xff;
422425}
423426
424427static WRITE8_DEVICE_HANDLER( yb_w )
r6626r6627
467470   data |= (floppy_drive_get_flag_state(c1541->image, FLOPPY_DRIVE_DISK_WRITE_PROTECTED) == FLOPPY_DRIVE_DISK_WRITE_PROTECTED) << 4;
468471
469472   /* SYNC detect */
470   //logerror("SYNC %u\n", !(c1541->mode && (c1541->yb == 0xff)));
471   data |= c1541->sync << 7;
473   data |= !(c1541->mode && ((c1541->data & SYNC_MARK) == SYNC_MARK)) << 7;
472474
473475   return data;
474476}
r6626r6627
511513
512514      if (tracks != 0)
513515      {
514         c1541->track_len = 8192; // TODO get track length from image
515         c1541->buffer_pos = 0;
516         c1541->bit_pos = 0;
516         c1541->track_len = 8192;
517         c1541->buffer_pos = 2;
518         c1541->bit_pos = 7;
519         c1541->bit_count = 0;
517520
518521         floppy_drive_seek(c1541->image, tracks);
519522         floppy_drive_read_track_data_info_buffer(c1541->image, 0, c1541->track_buffer, &c1541->track_len);
523
524         c1541->track_len = (c1541->track_buffer[1] << 8) | c1541->track_buffer[0];
520525      }
521526
522527      c1541->stp = stp;
r6626r6627
531536   /* density select */
532537   if (c1541->ds != ds)
533538   {
534      //logerror("DS %u\n", ds);
535539      timer_adjust_periodic(c1541->bit_timer, attotime_zero, 0, ATTOTIME_IN_HZ(C1541_BITRATE[ds]/4));
536540      c1541->ds = ds;
537541   }
src/mess/formats/g64_dsk.c
r6626r6627
9292   return FLOPPY_ERROR_SUCCESS;
9393}
9494
95floperr_t g64_get_track_length(floppy_image *floppy, int track, UINT64 *length)
96{
97   floperr_t err;
98   UINT64 track_offset;
99   UINT16 track_length = 0;
100   UINT8 header[2];
101
102   /* get track offset */
103   err = get_track_offset(floppy, track, &track_offset);
104   
105   if (err)
106      return err;
107
108   if (track_offset)
109   {
110      /* get track length */
111      floppy_image_read(floppy, header, track_offset, 2);
112      track_length = (header[1] << 8) | header[0];
113   }
114
115   if (length)
116      *length = track_length;
117
118   return FLOPPY_ERROR_SUCCESS;
119}
120
12195static floperr_t g64_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen)
12296{
12397   floperr_t err;
src/mess/formats/g64_dsk.h
r6626r6627
1111
1212#include "formats/flopimg.h"
1313
14floperr_t g64_get_track_length(floppy_image *floppy, int track, UINT64 *length);
15
1614FLOPPY_IDENTIFY( g64_dsk_identify );
1715FLOPPY_CONSTRUCT( g64_dsk_construct );
1816
src/mess/drivers/c64.c
r6626r6627
587587   MDRV_SOUND_CONFIG(c64_sound_interface)
588588   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
589589
590   MDRV_DEVICE_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
590   MDRV_DEVICE_REMOVE("serial_bus")
591   MDRV_DEVICE_REMOVE("c1541")
591592   MDRV_DEVICE_REMOVE("cart1")
592593   MDRV_DEVICE_REMOVE("cart2")
593594
r6626r6627
605606   MDRV_DEVICE_REMOVE( "dac" )
606607   MDRV_DEVICE_REMOVE( "cassette" )
607608   MDRV_DEVICE_REMOVE( "quickload" )
609   MDRV_DEVICE_REMOVE("serial_bus")
610   MDRV_DEVICE_REMOVE("c1541")
608611MACHINE_DRIVER_END
609612
610613
611614static MACHINE_DRIVER_START( sx64 )
612615   MDRV_IMPORT_FROM( c64pal )
613616
614   MDRV_DEVICE_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
615   MDRV_IMPORT_FROM( cpu_vc1541 )         // so we need to remove the one from MDRV_IMPORT_FROM(simulated_drive)!
616
617617   MDRV_DEVICE_REMOVE( "dac" )
618618   MDRV_DEVICE_REMOVE( "cassette" )
619619#ifdef CPU_SYNC
r6626r6627
743743   ROM_REGION( 0x80000, "cart", ROMREGION_ERASE00 )
744744ROM_END
745745
746
747
748/*************************************
749 *
750 *  System configuration(s)
751 *
752 *************************************/
753
754
755static SYSTEM_CONFIG_START(c64)
756   CONFIG_DEVICE(cbmfloppy_device_getinfo)
757SYSTEM_CONFIG_END
758
759static SYSTEM_CONFIG_START(sx64)
760   CONFIG_DEVICE(vc1541_device_getinfo)
761SYSTEM_CONFIG_END
762
763746/***************************************************************************
764747
765748  Game driver(s)
r6626r6627
768751
769752/*   YEAR  NAME   PARENT COMPAT MACHINE  INPUT    INIT    CONFIG    COMPANY                            FULLNAME */
770753
771COMP(1982, max,     0,    0,    ultimax, c64,     ultimax, 0,       "Commodore Business Machines Co.", "Commodore Max Machine", 0)
754COMP(1982, max,       0,    0,    ultimax, c64,     ultimax, 0,       "Commodore Business Machines Co.", "Commodore Max Machine", 0)
772755
773COMP(1982, c64,     0,    0,    c64,     c64,     c64,     c64,     "Commodore Business Machines Co.", "Commodore 64 (NTSC)", 0)
774COMP(1982, c64pal,  c64,  0,    c64pal,  c64,     c64pal,  c64,     "Commodore Business Machines Co.", "Commodore 64 (PAL)", 0)
775COMP(1982, c64jpn,  c64,  0,    c64,     c64,     c64,     c64,     "Commodore Business Machines Co.", "Commodore 64 (Japan)", 0)
776COMP(1982, vic64s,  c64,  0,    c64pal,  vic64s,  c64pal,  c64,     "Commodore Business Machines Co.", "VIC 64S", 0)
777COMP(1982, c64swe,  c64,  0,    c64pal,  vic64s,  c64pal,  c64,     "Commodore Business Machines Co.", "Commodore 64 (Sweden)", 0)
756COMP(1982, c64,     0,    0,    c64,     c64,     c64,     0,       "Commodore Business Machines Co.", "Commodore 64 (NTSC)", 0)
757COMP(1982, c64pal,  c64,  0,    c64pal,  c64,     c64pal,  0,       "Commodore Business Machines Co.", "Commodore 64 (PAL)", 0)
758COMP(1982, c64jpn,  c64,  0,    c64,     c64,     c64,     0,       "Commodore Business Machines Co.", "Commodore 64 (Japan)", 0)
759COMP(1982, vic64s,  c64,  0,    c64pal,  vic64s,  c64pal,  0,       "Commodore Business Machines Co.", "VIC 64S", 0)
760COMP(1982, c64swe,  c64,  0,    c64pal,  vic64s,  c64pal,  0,       "Commodore Business Machines Co.", "Commodore 64 (Sweden/Finland)", 0)
778761
779COMP(1983, pet64,     c64,  0,    pet64,   c64,     c64,     c64,     "Commodore Business Machines Co.", "PET 64 (NTSC)", 0)
780COMP(1983, cbm4064, c64,  0,    pet64,   c64,     c64,     c64,     "Commodore Business Machines Co.", "CBM 4064 (NTSC)", 0)
781COMP(1983, edu64,   c64,  0,    pet64,   c64,     c64,     c64,     "Commodore Business Machines Co.", "Educator 64 (NTSC)", 0) // maybe different palette?
762COMP(1983, pet64,   c64,  0,    pet64,   c64,     c64,     0,       "Commodore Business Machines Co.", "PET 64 (NTSC)", 0)
763COMP(1983, cbm4064, c64,  0,    pet64,   c64,     c64,     0,       "Commodore Business Machines Co.", "CBM 4064 (NTSC)", 0)
764COMP(1983, edu64,   c64,  0,    pet64,   c64,     c64,     0,       "Commodore Business Machines Co.", "Educator 64 (NTSC)", 0) // maybe different palette?
782765
783// missing floppy emulation, among other things
784COMP(1984, sx64,    c64,  0,    sx64,    c64,     sx64,    sx64,    "Commodore Business Machines Co.", "SX-64 Executive Computer (PAL)", GAME_NOT_WORKING)
785COMP(1984, vip64,   c64,  0,    sx64,    vip64,   sx64,    sx64,    "Commodore Business Machines Co.", "VIP64 (SX64 PAL), Swedish Expansion Kit", GAME_NOT_WORKING)
786COMP(198?, dx64,    c64,  0,    sx64,    c64,     sx64,    sx64,    "Commodore Business Machines Co.", "DX-64 (Prototype, PAL)", GAME_NOT_WORKING)
766COMP(1984, sx64,    c64,  0,    sx64,    c64,     sx64,    0,       "Commodore Business Machines Co.", "SX-64 Executive Computer (PAL)", GAME_NOT_WORKING)
767COMP(1984, vip64,   c64,  0,    sx64,    vip64,   sx64,    0,       "Commodore Business Machines Co.", "VIP64 (SX64 PAL), Swedish Expansion Kit", GAME_NOT_WORKING)
768COMP(198?, dx64,    c64,  0,    sx64,    c64,     sx64,    0,       "Commodore Business Machines Co.", "DX-64 (Prototype, PAL)", GAME_NOT_WORKING)
787769
788COMP(1986, c64c,    c64,  0,    c64,     c64,     c64,     c64,     "Commodore Business Machines Co.", "Commodore 64C (NTSC)", 0)
789COMP(1986, c64cpal, c64,  0,    c64pal,  c64,     c64pal,  c64,     "Commodore Business Machines Co.", "Commodore 64C (PAL)", 0)
790COMP(1986, c64g,    c64,  0,    c64pal,  c64,     c64pal,  c64,     "Commodore Business Machines Co.", "Commodore 64G (PAL)", 0)
770COMP(1986, c64c,    c64,  0,    c64,     c64,     c64,     0,       "Commodore Business Machines Co.", "Commodore 64C (NTSC)", 0)
771COMP(1986, c64cpal, c64,  0,    c64pal,  c64,     c64pal,  0,       "Commodore Business Machines Co.", "Commodore 64C (PAL)", 0)
772COMP(1986, c64g,    c64,  0,    c64pal,  c64,     c64pal,  0,       "Commodore Business Machines Co.", "Commodore 64G (PAL)", 0)
791773
792774CONS(1990, c64gs,   c64,  0,    c64gs,   c64gs,   c64gs,   0,       "Commodore Business Machines Co.", "Commodore 64 Games System (PAL)", 0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team