Previous 15994 Revisions Next

r3377 Friday 3rd October, 2008 at 17:03:16 UTC by Wilbert Pol
[SB2M600] Added more proper cassette handling.
[src/mess/drivers]osi.c

src/mess/drivers/osi.c
r3376r3377
1212*/
1313
1414#include "driver.h"
15#include "image.h"
1615#include "machine/6850acia.h"
1716#include "sound/discrete.h"
17#include "devices/cassette.h"
1818
1919/* Video */
2020
r3376r3377
308308
309309/* Machine Start */
310310
311static UINT8 rx_cassette;
311312static UINT8 rx, tx;
312313
313314static const struct acia6850_interface sb2m600_acia_intf =
314315{
315316   500000, //
316317   500000, //
317   &rx,
318   &rx_cassette,
318319   &tx,
319320   NULL,
320321   NULL,
r3376r3377
338339{
339340   500000, //
340341   500000, //
341   &rx,
342   &rx_cassette,
342343   &tx,
343344   NULL,
344345   NULL,
r3376r3377
346347   NULL
347348};
348349
350
351static TIMER_CALLBACK( sb2m600_cassette_callback )
352{
353   rx_cassette = (cassette_input(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" )) > 0.0) ? 1 : 0;
354}
355
356
349357static MACHINE_START( sb2m600 )
350358{
351359   // TODO: save states
352360   acia6850_config(0, &sb2m600_acia_intf);
353361   acia6850_config(1, &osi470_acia_intf);
362   timer_pulse( ATTOTIME_IN_HZ(4800), NULL, 0, sb2m600_cassette_callback );
354363}
355364
356365static MACHINE_START( uk101 )
357366{
358367   // TODO: save states
359368   acia6850_config(0, &uk101_acia_intf);
369   timer_pulse( ATTOTIME_IN_HZ(4800), NULL, 0, sb2m600_cassette_callback );
360370}
361371
362372/* Machine Drivers */
r3376r3377
388398   MDRV_SOUND_ADD("discrete", DISCRETE, 0)
389399   MDRV_SOUND_CONFIG_DISCRETE(sb2m600_discrete_interface)
390400   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
401
402   MDRV_CASSETTE_ADD( "cassette", default_cassette_config )
391403MACHINE_DRIVER_END
392404
393405#define UK101_X1 XTAL_8MHz
r3376r3377
411423   MDRV_PALETTE_INIT(black_and_white)
412424   MDRV_VIDEO_START(uk101)
413425   MDRV_VIDEO_UPDATE(sb2m600)
426
427   MDRV_CASSETTE_ADD( "cassette", default_cassette_config )
414428MACHINE_DRIVER_END
415429
416430/* ROMs */
r3376r3377
441455
442456/* System Configuration */
443457
444static UINT8 *sb2m600_tape_image;
445static int sb2m600_tape_size;
446static int sb2m600_tape_index;
447
448static DEVICE_IMAGE_LOAD( sb2m600_cassette )
449{
450   sb2m600_tape_image = (UINT8 *)image_malloc(image, sb2m600_tape_size);
451   sb2m600_tape_size = image_length(image);
452
453   if (!sb2m600_tape_image || (image_fread(image, sb2m600_tape_image, sb2m600_tape_size) != sb2m600_tape_size))
454   {
455      return INIT_FAIL;
456   }
457
458   sb2m600_tape_index = 0;
459
460   return INIT_PASS;
461}
462
463static DEVICE_IMAGE_UNLOAD( sb2m600_cassette )
464{
465   sb2m600_tape_image = NULL;
466   sb2m600_tape_size = 0;
467   sb2m600_tape_index = 0;
468}
469
470static void sb2m600_cassette_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
471{
472   switch(state)
473   {
474      /* --- the following bits of info are returned as 64-bit signed integers --- */
475      case MESS_DEVINFO_INT_TYPE:                     info->i = IO_CASSETTE; break;
476      case MESS_DEVINFO_INT_READABLE:                  info->i = 1; break;
477      case MESS_DEVINFO_INT_WRITEABLE:                  info->i = 0; break;
478      case MESS_DEVINFO_INT_CREATABLE:                  info->i = 0; break;
479      case MESS_DEVINFO_INT_COUNT:                     info->i = 1; break;
480
481      /* --- the following bits of info are returned as pointers to data or functions --- */
482      case MESS_DEVINFO_PTR_LOAD:                     info->load = DEVICE_IMAGE_LOAD_NAME(sb2m600_cassette); break;
483      case MESS_DEVINFO_PTR_UNLOAD:                  info->unload = DEVICE_IMAGE_UNLOAD_NAME(sb2m600_cassette); break;
484
485      /* --- the following bits of info are returned as NULL-terminated strings --- */
486      case MESS_DEVINFO_STR_FILE_EXTENSIONS:            strcpy(info->s = device_temp_str(), "bas"); break;
487   }
488}
489
490458static SYSTEM_CONFIG_START(sb2m600)
491   CONFIG_DEVICE(sb2m600_cassette_getinfo)
492459   CONFIG_RAM_DEFAULT(4 * 1024)
493460   CONFIG_RAM(8 * 1024)
494461SYSTEM_CONFIG_END

Previous 15994 Revisions Next


© 1998-2018 The MESS Team