Previous 15994 Revisions Next

r5966 Sunday 4th October, 2009 at 21:47:19 UTC by Angelo Salese
[PC6001]: Added a bare bones support for the cassette interface, doesn't work mainly because the MCU directly controls the tape handling thus needing some kind of tight synch
[src/mess]mess.mak
[src/mess/drivers]pc6001.c
[src/mess/formats]p6001_cas.c* p6001_cas.h*

src/mess/mess.mak
r5965r5966
10191019   $(MESS_MACHINE)/pce.o      \
10201020   $(MESS_DRIVERS)/pce.o      \
10211021   $(MESS_DRIVERS)/pcfx.o      \
1022   $(MESS_FORMATS)/p6001_cas.o   \
10221023   $(MESS_DRIVERS)/pc6001.o   \
10231024   $(MESS_DRIVERS)/pc8401a.o   \
10241025   $(MESS_VIDEO)/pc8401a.o      \
src/mess/formats/p6001_cas.c
r0r5966
1/*
2 * Nec PC-6001 cassette format handling
3 */
4
5#include "driver.h"
6#include "p6001_cas.h"
7
8#define WAVE_HIGH       0x5a9e
9#define WAVE_LOW      -0x5a9e
10
11static int cas_size;
12
13static int pc6001_fill_wave(INT16* buffer, UINT8 data, int sample_pos)
14{
15   int x;
16   int sample_count = 0;
17
18   // one byte = 8 samples
19   for(x=0;x<8;x++)
20   {
21      if(buffer)
22         buffer[sample_pos+x] = ((data >> (7-x)) & 1) ? WAVE_HIGH : WAVE_LOW;
23   }
24
25   sample_count+=8;
26   return sample_count;
27}
28
29static int pc6001_handle_cas(INT16* buffer, const UINT8* casdata)
30{
31   int sample_count = 0;
32   int data_pos = 0;
33
34   while(sample_count < cas_size)
35   {
36      sample_count += pc6001_fill_wave(buffer,casdata[data_pos],sample_count);
37      data_pos++;
38   }
39
40   return sample_count;
41}
42
43/*******************************************************************
44   Calculate the number of samples needed for this tape image
45********************************************************************/
46static int pc6001_cas_to_wav_size (const UINT8 *casdata, int caslen)
47{
48   cas_size = caslen*8;
49
50   return pc6001_handle_cas(NULL,casdata);
51}
52
53/*******************************************************************
54   Generate samples for the tape image
55********************************************************************/
56static int pc6001_cas_fill_wave(INT16 *buffer, int sample_count, UINT8 *bytes)
57{
58   return pc6001_handle_cas(buffer,bytes);
59}
60
61static const struct CassetteLegacyWaveFiller pc6001_legacy_fill_wave =
62{
63   pc6001_cas_fill_wave,               /* fill_wave */
64   -1,                              /* chunk_size */
65   0,                              /* chunk_samples */
66   pc6001_cas_to_wav_size,               /* chunk_sample_calc */
67   8000,                           /* sample_frequency */
68   0,                              /* header_samples */
69   0                              /* trailer_samples */
70};
71
72static casserr_t pc6001_cas_identify(cassette_image *cassette, struct CassetteOptions *opts)
73{
74   return cassette_legacy_identify(cassette, opts, &pc6001_legacy_fill_wave);
75}
76
77
78
79static casserr_t pc6001_cas_load(cassette_image *cassette)
80{
81   return cassette_legacy_construct(cassette, &pc6001_legacy_fill_wave);
82}
83
84
85static const struct CassetteFormat pc6001_cassette_format = {
86   "cas",
87   pc6001_cas_identify,
88   pc6001_cas_load,
89   NULL
90};
91
92CASSETTE_FORMATLIST_START(pc6001_cassette_formats)
93   CASSETTE_FORMAT(pc6001_cassette_format)
94CASSETTE_FORMATLIST_END
src/mess/formats/p6001_cas.h
r0r5966
1/*
2 * Nec PC-6001 cassette format handling
3 */
4
5#ifndef PC6001_CAS_H_
6#define PC6001_CAS_H_
7
8#include "formats/cassimg.h"
9
10CASSETTE_FORMATLIST_EXTERN( pc6001_cassette_formats );
11
12#endif /*PC6001_CAS_H_*/
src/mess/drivers/pc6001.c
r5965r5966
1313         so this implementation will be used in the end.
1414      B) It's easier to me to see what the attribute vram does since I don't
1515         have any docs atm.
16   - cassette handling requires a decap of the MCU. It could be possible to
17     do some tight synch between the master CPU and a code simulation...
1618
1719==================================================================================
1820
r5965r5966
9193#include "machine/msm8251.h"
9294#include "video/m6847.h"
9395#include "sound/ay8910.h"
96#include "sound/wave.h"
97
98#include "devices/cassette.h"
9499#include "devices/cartslot.h"
100#include "formats/p6001_cas.h"
95101
96102static UINT8 *pc6001_ram;
97103static UINT8 *pc6001_video_ram;
r5965r5966
246252   pc6001_video_ram =  pc6001_ram + startaddr[(data >> 1) & 0x03] - 0x8000;
247253
248254   if((!(sys_latch & 8)) && data & 0x8) //PLAY tape cmd
255   {
249256      cas_switch = 1;
257      cassette_change_state(devtag_get_device(space->machine, "cass" ),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR);
258      cassette_change_state(devtag_get_device(space->machine, "cass" ),CASSETTE_PLAY,CASSETTE_MASK_UISTATE);
259   }
250260   if((sys_latch & 8) && ((data & 0x8) == 0)) //STOP tape cmd
251261   {
252262      cas_switch = 0;
253      irq_vector = 0x00;
254      cputag_set_input_line(space->machine,"maincpu", 0, ASSERT_LINE);
263      cassette_change_state(devtag_get_device(space->machine, "cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR);
264      cassette_change_state(devtag_get_device(space->machine, "cass" ),CASSETTE_STOPPED,CASSETTE_MASK_UISTATE);
265      //irq_vector = 0x00;
266      //cputag_set_input_line(space->machine,"maincpu", 0, ASSERT_LINE);
255267   }
256268
257269   sys_latch = data;
r5965r5966
483495   AM_RANGE(0xb0, 0xb0) AM_WRITE(pc6001_system_latch_w)
484496   AM_RANGE(0xf0, 0xf0) AM_WRITE(pc6001m2_bank_r0_w)
485497   AM_RANGE(0xf1, 0xf1) AM_WRITE(pc6001m2_bank_r1_w)
498   //0xf2 w bank
486499ADDRESS_MAP_END
487500
488501/* Input ports */
r5965r5966
726739
727740static TIMER_CALLBACK(cassette_callback)
728741{
729   UINT8 *gfx_data = memory_region(machine, "cas");
742   //UINT8 *gfx_data = memory_region(machine, "cas");
730743
731744   if(cas_switch == 1)
732745   {
733      cur_keycode = gfx_data[cas_offset++];
746      static UINT8 cas_data_i = 0x80,cas_data_poll;
747      //cur_keycode = gfx_data[cas_offset++];
748      if(cassette_input(devtag_get_device(machine,"cass")) > 0.03)
749         cas_data_poll|= cas_data_i;
750      else
751         cas_data_poll&=~cas_data_i;
752      if(cas_data_i == 1)
753      {
754         cur_keycode = cas_data_poll;
755         cas_data_i = 0x80;
756         /* data ready, poll irq */
757         irq_vector = 0x08;
758         cputag_set_input_line(machine,"maincpu", 0, ASSERT_LINE);
759      }
760      else
761         cas_data_i>>=1;
762
734763      //popmessage("%04x %02x",cas_offset,cas_switch);
764      #if 0
735765      if(cas_offset >= CAS_LENGTH)
736766      {
737767         cas_offset = 0;
r5965r5966
739769         irq_vector = 0x12;
740770         cputag_set_input_line(machine,"maincpu", 0, ASSERT_LINE);
741771      }
742      else
743      {
744         irq_vector = 0x08;
745         cputag_set_input_line(machine,"maincpu", 0, ASSERT_LINE);
746      }
772      #endif
747773   }
748774}
749775
r5965r5966
837863      palette_set_color(machine, i+8,defcolors[i]);
838864}
839865
866static const cassette_config pc6001_cassette_config =
867{
868   pc6001_cassette_formats,
869   NULL,
870   CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED
871};
840872
841873static MACHINE_DRIVER_START( pc6001 )
842874   /* basic machine hardware */
r5965r5966
871903   MDRV_CARTSLOT_EXTENSION_LIST("bin")
872904   MDRV_CARTSLOT_NOT_MANDATORY
873905
906   MDRV_CASSETTE_ADD("cass",pc6001_cassette_config)
907
874908   MDRV_SPEAKER_STANDARD_MONO("mono")
875909   MDRV_SOUND_ADD("ay8910", AY8910, XTAL_4MHz/2)
876910   MDRV_SOUND_CONFIG(pc6001_ay_interface)
877911   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
912   MDRV_SOUND_WAVE_ADD("wave","cass")
913   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.05)
878914MACHINE_DRIVER_END
879915
880916static MACHINE_DRIVER_START( pc6001m2 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team