Previous 15994 Revisions Next

r4923 Wednesday 3rd June, 2009 at 08:47:54 UTC by Barry Rodewald
[FM7] Added cassette support (.T77 handling not perfect), made Sub-CPU busy flag active when sub-CPU is halted.
[src/mess]mess.mak
[src/mess/drivers]fm7.c
[src/mess/formats]fm7_cas.c* fm7_cas.h*

src/mess/mess.mak
r4922r4923
13981398   $(MESS_DRIVERS)/qx10.o \
13991399   $(MESS_DRIVERS)/fk1.o \
14001400   $(MESS_DRIVERS)/fm7.o \
1401   $(MESS_FORMATS)/fm7_cas.o \
14011402   $(MESS_DRIVERS)/fmtowns.o \
14021403   $(MESS_DRIVERS)/huebler.o \
14031404   $(MESS_DRIVERS)/interact.o \
src/mess/formats/fm7_cas.c
r0r4923
1/*
2 * Fujitsu FM-7 series cassette handling
3 */
4
5#include "driver.h"
6#include "fm7_cas.h"
7
8#define WAVE_HIGH       0x5a9e
9#define WAVE_LOW      -0x5a9e
10
11static int cas_size;
12
13static int fm7_fill_wave(INT16* buffer, UINT8 high, UINT8 low, int sample_pos)
14{
15   UINT16 data = (high << 8) + low;
16   int sample_count = 0;
17   int x = 0;
18   int count = (data & 0x7fff);
19   
20   if(data & 0x8000)
21   {
22      for(x=0;x<count;x++)
23      {
24         if(buffer)
25            buffer[sample_pos+x] = WAVE_HIGH;
26      }
27   }
28   else
29   {
30      for(x=0;x<count;x++)
31      {
32         if(buffer)
33            buffer[sample_pos+x] = WAVE_LOW;
34      }
35   }
36
37   sample_count += count;   
38   return sample_count;
39}
40
41static int fm7_handle_t77(INT16* buffer, const UINT8* casdata)
42{
43   int sample_count = 0;
44   int data_pos = 16;
45   
46   if(memcmp(casdata, "XM7 TAPE IMAGE 0",16))  // header check
47      return -1;
48   
49   while(data_pos < cas_size)
50   {
51      sample_count += fm7_fill_wave(buffer,casdata[data_pos],casdata[data_pos+1],sample_count);
52      data_pos+=2;
53   }
54   
55   return sample_count;
56}
57
58/*******************************************************************
59   Calculate the number of samples needed for this tape image
60********************************************************************/
61static int fm7_cas_to_wav_size (const UINT8 *casdata, int caslen)
62{
63   cas_size = caslen;
64   
65   return fm7_handle_t77(NULL,casdata);
66}
67
68/*******************************************************************
69   Generate samples for the tape image
70********************************************************************/
71static int fm7_cas_fill_wave(INT16 *buffer, int sample_count, UINT8 *bytes)
72{
73   return fm7_handle_t77(buffer,bytes);
74}
75
76static const struct CassetteLegacyWaveFiller fm7_legacy_fill_wave =
77{
78   fm7_cas_fill_wave,                  /* fill_wave */
79   -1,                              /* chunk_size */
80   0,                              /* chunk_samples */
81   fm7_cas_to_wav_size,               /* chunk_sample_calc */
82   125000,                           /* sample_frequency */
83   0,                              /* header_samples */
84   0                              /* trailer_samples */
85};
86
87static casserr_t fm7_cas_identify(cassette_image *cassette, struct CassetteOptions *opts)
88{
89   return cassette_legacy_identify(cassette, opts, &fm7_legacy_fill_wave);
90}
91
92
93
94static casserr_t fm7_cas_load(cassette_image *cassette)
95{
96   return cassette_legacy_construct(cassette, &fm7_legacy_fill_wave);
97}
98
99
100static const struct CassetteFormat fm7_cassette_format = {
101   "t77",
102   fm7_cas_identify,
103   fm7_cas_load,
104   NULL
105};
106
107CASSETTE_FORMATLIST_START(fm7_cassette_formats)
108   CASSETTE_FORMAT(fm7_cassette_format)
109CASSETTE_FORMATLIST_END
src/mess/formats/fm7_cas.h
r0r4923
1/*
2 * Fujitsu FM-7 cassette format handling
3 */
4
5#ifndef FM7_CAS_H_
6#define FM7_CAS_H_
7
8#include "formats/cassimg.h"
9
10CASSETTE_FORMATLIST_EXTERN( fm7_cassette_formats );
11
12#endif /*FM7_CAS_H_*/
src/mess/drivers/fm7.c
r4922r4923
3030#include "driver.h"
3131#include "cpu/m6809/m6809.h"
3232#include "sound/ay8910.h"
33#include "sound/wave.h"
3334
35#include "devices/cassette.h"
36#include "formats/fm7_cas.h"
37
3438// Interrupt flags
3539#define IRQ_FLAG_KEY      0x01
3640#define IRQ_FLAG_PRINTER  0x02
r4922r4923
283287WRITE8_HANDLER( fm7_subintf_w )
284288{
285289   cputag_set_input_line(space->machine,"sub",INPUT_LINE_HALT,(data & 0x80) ? ASSERT_LINE : CLEAR_LINE);
290   sub_busy = data & 0x80;
286291   if(data & 0x40)
287292      cputag_set_input_line(space->machine,"sub",M6809_IRQ_LINE,ASSERT_LINE);
293   //popmessage("Sub CPU Interface write: %02x\n",data);
288294}
289295
290296READ8_HANDLER( fm7_sub_busyflag_r )
r4922r4923
416422
417423READ8_HANDLER( fm7_keyboard_r)
418424{
425   UINT8 ret;
419426   switch(offset)
420427   {
421428      case 0:
422         return (current_scancode >> 1) & 0x80;
429         ret = (current_scancode >> 1) & 0x80;
430         ret |= 0x01; // 1 = 2MHz, 0 = 1.2MHz
431         return ret;
423432      case 1:
424433         return current_scancode & 0xff;
425434      default:
r4922r4923
427436   }
428437}
429438
439READ8_HANDLER( fm7_cassette_printer_r )
440{
441   // bit 7: cassette input
442   // bit 3: printer PE
443   // bit 2: printer acknowledge
444   // bit 1: printer error
445   // bit 0: printer busy
446   UINT8 ret = 0x00;
447   double data = cassette_input(devtag_get_device(space->machine,"cass"));
448   
449   if(data > 0.03)
450      ret |= 0x80;
451   
452   ret |= 0x40;
453
454   return ret;
455}
456
457WRITE8_HANDLER( fm7_cassette_printer_w )
458{
459   static UINT8 prev;
460   switch(offset)
461   {
462      case 0:
463      // bit 7: printer online
464      // bit 6: printer strobe
465      // bit 1: cassette motor
466      // bit 0: cassette output
467         if((data & 0x01) != (prev & 0x01))
468            cassette_output(devtag_get_device(space->machine,"cass"),(data & 0x01) ? +1.0 : -1.0);
469         if((data & 0x02) != (prev & 0x02))
470            cassette_change_state(devtag_get_device(space->machine, "cass" ),(data & 0x02) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR);
471         prev = data;
472         break;
473      case 1:
474      // Printer data
475         break;
476   }
477}
478
430479static TIMER_CALLBACK( fm7_timer_irq )
431480{
432   if(~irq_mask & IRQ_FLAG_TIMER)
481   if(irq_mask & IRQ_FLAG_TIMER)
433482   {
434483      irq_flags |= IRQ_FLAG_TIMER;
435484      cputag_set_input_line(machine,"maincpu",M6809_IRQ_LINE,ASSERT_LINE);
r4922r4923
451500   if(scancode == 0)
452501      return;
453502   
454   if(~irq_mask & IRQ_FLAG_KEY)
503   if(irq_mask & IRQ_FLAG_KEY)
455504   {
456505      irq_flags |= IRQ_FLAG_KEY;
457      cputag_set_input_line(machine,"maincpu",M6809_IRQ_LINE,ASSERT_LINE);
506//      cputag_set_input_line(machine,"maincpu",M6809_IRQ_LINE,ASSERT_LINE);
458507   }
459508   cputag_set_input_line(machine,"sub",M6809_FIRQ_LINE,ASSERT_LINE);
460509   logerror("KEY: sent scancode 0x%03x\n",scancode);
r4922r4923
519568   AM_RANGE(0xfc00,0xfc7f) AM_RAM
520569   AM_RANGE(0xfc80,0xfcff) AM_READWRITE(shared_r,shared_w) // shared RAM with sub-CPU
521570   // I/O space (FD00-FDFF)
522   AM_RANGE(0xfd00,0xfd01) AM_READ(fm7_keyboard_r)
523   AM_RANGE(0xfd02,0xfd02) AM_WRITE(fm7_irq_mask_w)  // IRQ mask
571   AM_RANGE(0xfd00,0xfd01) AM_READWRITE(fm7_keyboard_r,fm7_cassette_printer_w)
572   AM_RANGE(0xfd02,0xfd02) AM_READWRITE(fm7_cassette_printer_r,fm7_irq_mask_w)  // IRQ mask
524573   AM_RANGE(0xfd03,0xfd03) AM_READ(fm7_irq_cause_r)  // IRQ flags
525574   AM_RANGE(0xfd04,0xfd04) AM_READ(fm7_fd04_r)
526575   AM_RANGE(0xfd05,0xfd05) AM_READWRITE(fm7_subintf_r,fm7_subintf_w)
r4922r4923
781830   DEVCB_NULL               /* portB write */
782831};
783832
833static const cassette_config fm7_cassette_config =
834{
835   fm7_cassette_formats,
836   NULL,
837   CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED
838};
839
784840static MACHINE_DRIVER_START( fm7 )
785841   /* basic machine hardware */
786842   MDRV_CPU_ADD("maincpu", M6809, XTAL_2MHz)
r4922r4923
795851   MDRV_SOUND_ADD("psg", AY8910, 1000000)  // clock speed unknown
796852   MDRV_SOUND_CONFIG(fm7_psg_intf)
797853   MDRV_SOUND_ROUTE(ALL_OUTPUTS,"mono",1.0)
854   MDRV_SOUND_WAVE_ADD("wave","cass")
855   MDRV_SOUND_ROUTE(ALL_OUTPUTS,"mono",0.20)
798856
799857   MDRV_MACHINE_START(fm7)
800858   MDRV_MACHINE_RESET(fm7)
r4922r4923
812870
813871   MDRV_VIDEO_START(fm7)
814872   MDRV_VIDEO_UPDATE(fm7)
873   
874   MDRV_CASSETTE_ADD("cass",fm7_cassette_config)
815875MACHINE_DRIVER_END
816876
817877static MACHINE_DRIVER_START( fm77av )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team