Previous 15994 Revisions Next

r11219 Sunday 17th April, 2011 at 14:59:06 UTC by Robbbert
[MYCOM] modernised.
[src/mess/drivers]mycom.c

src/mess/drivers/mycom.c
r11218r11219
4343    - Keyboard autorepeat
4444
4545*******************************************************************************/
46#define ADDRESS_MAP_MODERN
4647
4748#include "emu.h"
4849#include "cpu/z80/z80.h"
r11218r11219
5657#include "imagedev/flopdrv.h"
5758#include "formats/basicdsk.h"
5859
60#define MACHINE_RESET_MEMBER(name) void name::machine_reset()
61#define MACHINE_START_MEMBER(name) void name::machine_start()
62#define VIDEO_START_MEMBER(name) void name::video_start()
63#define SCREEN_UPDATE_MEMBER(name) bool name::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
5964#define MSM5832RS_TAG "rtc"
6065
6166class mycom_state : public driver_device
r11218r11219
6368public:
6469   mycom_state(running_machine &machine, const driver_device_config_base &config)
6570      : driver_device(machine, config),
66        m_rtc(*this, MSM5832RS_TAG)
71   m_maincpu(*this, "maincpu"),
72   m_ppi0(*this, "ppi8255_0"),
73   m_ppi1(*this, "ppi8255_1"),
74   m_ppi2(*this, "ppi8255_2"),
75   m_cass(*this, "cassette"),
76   m_wave(*this, "wave"),
77   m_crtc(*this, "crtc"),
78   m_fdc(*this, "fdc"),
79   m_audio(*this, "sn1"),
80   m_rtc(*this, MSM5832RS_TAG)
6781   { }
6882
83   required_device<cpu_device> m_maincpu;
84   required_device<device_t> m_ppi0;
85   required_device<device_t> m_ppi1;
86   required_device<device_t> m_ppi2;
87   required_device<device_t> m_cass;
88   required_device<device_t> m_wave;
89   required_device<device_t> m_crtc;
90   required_device<device_t> m_fdc;
91   required_device<device_t> m_audio;
6992   required_device<msm5832_device> m_rtc;
70
71   device_t *m_mc6845;
72   device_t *m_audio;
73   device_t *m_cassette;
74   device_t *m_fdc;
75   UINT8 *m_vram;
76   UINT8 *m_gfx_rom;
77   UINT16 m_vram_addr;
93   DECLARE_READ8_MEMBER( mycom_upper_r );
94   DECLARE_WRITE8_MEMBER( mycom_upper_w );
95   DECLARE_READ8_MEMBER( vram_data_r );
96   DECLARE_WRITE8_MEMBER( vram_data_w );
97   DECLARE_WRITE8_MEMBER( mycom_00_w );
98   DECLARE_WRITE8_MEMBER( mycom_04_w );
99   DECLARE_WRITE8_MEMBER( mycom_06_w );
100   DECLARE_WRITE8_MEMBER( mycom_0a_w );
101   DECLARE_READ8_MEMBER( mycom_05_r );
102   DECLARE_READ8_MEMBER( mycom_06_r );
103   DECLARE_READ8_MEMBER( mycom_08_r );
104   UINT8 *m_p_videoram;
105   UINT8 *m_p_chargen;
106   UINT16 m_i_videoram;
78107   UINT8 m_keyb_press;
79108   UINT8 m_keyb_press_flag;
80109   UINT8 m_0a;
81110   UINT8 m_sn_we;
82111   UINT32 m_upper_sw;
83   UINT8 *m_RAM;
112   UINT8 *m_p_ram;
113   virtual void machine_reset();
114   virtual void machine_start();
115   virtual void video_start();
116   virtual bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
84117};
85118
86119
87120
88static VIDEO_START( mycom )
121VIDEO_START_MEMBER( mycom_state )
89122{
90   mycom_state *state = machine.driver_data<mycom_state>();
91   state->m_mc6845 = machine.device("crtc");
92   state->m_vram = machine.region("vram")->base();
93   state->m_gfx_rom = machine.region("gfx")->base();
123   m_p_videoram = m_machine.region("vram")->base();
124   m_p_chargen = m_machine.region("chargen")->base();
94125}
95126
96static SCREEN_UPDATE( mycom )
127SCREEN_UPDATE_MEMBER( mycom_state )
97128{
98   mycom_state *state = screen->machine().driver_data<mycom_state>();
99   mc6845_update(state->m_mc6845, bitmap, cliprect);
129   mc6845_update(m_crtc, &bitmap, &cliprect);
100130   return 0;
101131}
102132
r11218r11219
114144         UINT8 dbit=1;
115145         if (x == cursor_x) dbit=0;
116146         mem = (ma + x) & 0x7ff;
117         chr = state->m_vram[mem];
147         chr = state->m_p_videoram[mem];
118148         z = ra / 3;
119149         *p++ = BIT( chr, z ) ? dbit: dbit^1;
120150         *p++ = BIT( chr, z ) ? dbit: dbit^1;
r11218r11219
138168            gfx = inv;   // some blank spacing lines
139169         else
140170         {
141            chr = state->m_vram[mem];
142            gfx = state->m_gfx_rom[(chr<<3) | ra] ^ inv;
171            chr = state->m_p_videoram[mem];
172            gfx = state->m_p_chargen[(chr<<3) | ra] ^ inv;
143173         }
144174
145175         /* Display a scanline of a character */
146         *p++ = ( gfx & 0x80 ) ? 1 : 0;
147         *p++ = ( gfx & 0x40 ) ? 1 : 0;
148         *p++ = ( gfx & 0x20 ) ? 1 : 0;
149         *p++ = ( gfx & 0x10 ) ? 1 : 0;
150         *p++ = ( gfx & 0x08 ) ? 1 : 0;
151         *p++ = ( gfx & 0x04 ) ? 1 : 0;
152         *p++ = ( gfx & 0x02 ) ? 1 : 0;
153         *p++ = ( gfx & 0x01 ) ? 1 : 0;
176         *p++ = BIT(gfx, 7);
177         *p++ = BIT(gfx, 6);
178         *p++ = BIT(gfx, 5);
179         *p++ = BIT(gfx, 4);
180         *p++ = BIT(gfx, 3);
181         *p++ = BIT(gfx, 2);
182         *p++ = BIT(gfx, 1);
183         *p++ = BIT(gfx, 0);
154184      }
155185   }
156186}
157187
158static WRITE8_HANDLER( mycom_00_w )
188WRITE8_MEMBER( mycom_state::mycom_00_w )
159189{
160   mycom_state *state = space->machine().driver_data<mycom_state>();
161190   switch(data)
162191   {
163      case 0x00: memory_set_bank(space->machine(), "boot", 1); break;
164      case 0x01: memory_set_bank(space->machine(), "boot", 0); break;
165      case 0x02: state->m_upper_sw = 0x10000; break;
166      case 0x03: state->m_upper_sw = 0x0c000; break;
192      case 0x00: memory_set_bank(machine(), "boot", 1); break;
193      case 0x01: memory_set_bank(machine(), "boot", 0); break;
194      case 0x02: m_upper_sw = 0x10000; break;
195      case 0x03: m_upper_sw = 0x0c000; break;
167196   }
168197}
169198
170static READ8_HANDLER( mycom_upper_r )
199READ8_MEMBER( mycom_state::mycom_upper_r )
171200{
172   mycom_state *state = space->machine().driver_data<mycom_state>();
173   return state->m_RAM[offset | state->m_upper_sw];
201   return m_p_ram[offset | m_upper_sw];
174202}
175203
176static WRITE8_HANDLER( mycom_upper_w )
204WRITE8_MEMBER( mycom_state::mycom_upper_w )
177205{
178   mycom_state *state = space->machine().driver_data<mycom_state>();
179   state->m_RAM[offset | 0xc000] = data;
206   m_p_ram[offset | 0xc000] = data;
180207}
181208
182static READ8_HANDLER( vram_data_r )
209READ8_MEMBER( mycom_state::vram_data_r )
183210{
184   mycom_state *state = space->machine().driver_data<mycom_state>();
185   return state->m_vram[state->m_vram_addr];
211   return m_p_videoram[m_i_videoram];
186212}
187213
188static WRITE8_HANDLER( vram_data_w )
214WRITE8_MEMBER( mycom_state::vram_data_w )
189215{
190   mycom_state *state = space->machine().driver_data<mycom_state>();
191   state->m_vram[state->m_vram_addr] = data;
216   m_p_videoram[m_i_videoram] = data;
192217}
193218
194static ADDRESS_MAP_START(mycom_map, AS_PROGRAM, 8)
219static ADDRESS_MAP_START(mycom_map, AS_PROGRAM, 8, mycom_state)
195220   ADDRESS_MAP_UNMAP_HIGH
196221   AM_RANGE(0x0000, 0x0fff) AM_RAMBANK("boot")
197222   AM_RANGE(0x1000, 0xbfff) AM_RAM
198223   AM_RANGE(0xc000, 0xffff) AM_READWRITE(mycom_upper_r,mycom_upper_w)
199224ADDRESS_MAP_END
200225
201static ADDRESS_MAP_START(mycom_io, AS_IO, 8)
226static ADDRESS_MAP_START(mycom_io, AS_IO, 8, mycom_state)
202227   ADDRESS_MAP_GLOBAL_MASK(0xff)
203228   AM_RANGE(0x00, 0x00) AM_WRITE(mycom_00_w)
204229   AM_RANGE(0x01, 0x01) AM_READWRITE(vram_data_r,vram_data_w)
205   AM_RANGE(0x02, 0x02) AM_DEVREADWRITE("crtc", mc6845_status_r,mc6845_address_w)
206   AM_RANGE(0x03, 0x03) AM_DEVREADWRITE("crtc", mc6845_register_r,mc6845_register_w)
207   AM_RANGE(0x04, 0x07) AM_DEVREADWRITE("ppi8255_0", i8255a_r, i8255a_w)
208   AM_RANGE(0x08, 0x0b) AM_DEVREADWRITE("ppi8255_1", i8255a_r, i8255a_w)
209   AM_RANGE(0x0c, 0x0f) AM_DEVREADWRITE("ppi8255_2", i8255a_r, i8255a_w)
210   AM_RANGE(0x10, 0x13) AM_DEVREADWRITE("fdc", wd17xx_r, wd17xx_w)
230   AM_RANGE(0x02, 0x02) AM_DEVREADWRITE_LEGACY("crtc", mc6845_status_r,mc6845_address_w)
231   AM_RANGE(0x03, 0x03) AM_DEVREADWRITE_LEGACY("crtc", mc6845_register_r,mc6845_register_w)
232   AM_RANGE(0x04, 0x07) AM_DEVREADWRITE_LEGACY("ppi8255_0", i8255a_r, i8255a_w)
233   AM_RANGE(0x08, 0x0b) AM_DEVREADWRITE_LEGACY("ppi8255_1", i8255a_r, i8255a_w)
234   AM_RANGE(0x0c, 0x0f) AM_DEVREADWRITE_LEGACY("ppi8255_2", i8255a_r, i8255a_w)
235   AM_RANGE(0x10, 0x13) AM_DEVREADWRITE_LEGACY("fdc", wd17xx_r, wd17xx_w)
211236ADDRESS_MAP_END
212237
213238/* Input ports */
r11218r11219
310335};
311336
312337static GFXDECODE_START( mycom )
313   GFXDECODE_ENTRY( "gfx", 0x0000, mycom_charlayout, 0, 1 )
338   GFXDECODE_ENTRY( "chargen", 0x0000, mycom_charlayout, 0, 1 )
314339GFXDECODE_END
315340
316341static const wd17xx_interface wd1771_intf =
r11218r11219
335360   NULL      /* update address callback */
336361};
337362
338static WRITE8_DEVICE_HANDLER( mycom_04_w )
363WRITE8_MEMBER( mycom_state::mycom_04_w )
339364{
340   mycom_state *state = device->machine().driver_data<mycom_state>();
341   state->m_vram_addr = (state->m_vram_addr & 0x700) | data;
365   m_i_videoram = (m_i_videoram & 0x700) | data;
342366
343   state->m_sn_we = data;
367   m_sn_we = data;
344368   /* doesn't work? */
345369   //printf(":%X ",data);
346   //if(state->m_sn_we)
347     //sn76496_w(state->m_audio, 0, data);
370   //if(m_sn_we)
371     //sn76496_w(m_audio, 0, data);
348372}
349373
350static WRITE8_DEVICE_HANDLER( mycom_06_w )
374WRITE8_MEMBER( mycom_state::mycom_06_w )
351375{
352   mycom_state *state = device->machine().driver_data<mycom_state>();
353   state->m_vram_addr = (state->m_vram_addr & 0x0ff) | ((data & 0x007) << 8);
376   m_i_videoram = (m_i_videoram & 0x0ff) | ((data & 0x007) << 8);
354377}
355378
356static READ8_DEVICE_HANDLER( mycom_08_r )
379READ8_MEMBER( mycom_state::mycom_08_r )
357380{
358   mycom_state *state = device->machine().driver_data<mycom_state>();
359381   /*
360382    x--- ---- display flag
361383    ---- --x- keyboard shift
r11218r11219
363385    */
364386   UINT8 data = 0;
365387
366   data = state->m_keyb_press_flag; //~state->m_keyb_press_flag & 1;
388   data = m_keyb_press_flag; //~m_keyb_press_flag & 1;
367389
368   if (cassette_input(state->m_cassette) > 0.03) // not working
390   if (cassette_input(m_cass) > 0.03) // not working
369391      data+=4;
370392
371393   return data;
372394}
373395
374static READ8_DEVICE_HANDLER( mycom_06_r )
396READ8_MEMBER( mycom_state::mycom_06_r )
375397{
376398   /*
377399    x--- ---- keyboard s5
r11218r11219
382404   return 0xff;
383405}
384406
385static READ8_DEVICE_HANDLER( mycom_05_r )
407READ8_MEMBER( mycom_state::mycom_05_r )
386408{
387   mycom_state *state = device->machine().driver_data<mycom_state>();
388   return state->m_keyb_press;
409   return m_keyb_press;
389410}
390411
391static WRITE8_DEVICE_HANDLER( mycom_0a_w )
412WRITE8_MEMBER( mycom_state::mycom_0a_w )
392413{
393   mycom_state *state = device->machine().driver_data<mycom_state>();
394414   /*
395415    x--- ---- width 80/40 (0 = 80, 1 = 40)
396416    -x-- ---- video mode (0= tile, 1 = bitmap)
r11218r11219
402422    ---- ---x printer strobe
403423    */
404424
405   if ((state->m_0a & 8) != (data & 8))
406      cassette_change_state(state->m_cassette,
407      (data & 8) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
425   if ( (BIT(m_0a, 3)) != (BIT(data, 3)) )
426      cassette_change_state(m_cass,
427      BIT(data, 3) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
408428
409   if (data & 8) // motor on
410      cassette_output(state->m_cassette, (data & 4) ? -1.0 : +1.0);
429   if BIT(data, 3) // motor on
430      cassette_output(m_cass, BIT(data, 2) ? -1.0 : +1.0);
411431
412   if ((data & 0x80) != (state->m_0a & 0x80))
413      mc6845_set_clock(state->m_mc6845, (data & 0x80) ? 1008000 : 2016000);
432   if ( (BIT(data, 7)) != (BIT(m_0a, 7)) )
433      mc6845_set_clock(m_crtc, BIT(data, 7) ? 1008000 : 2016000);
414434
415   state->m_0a = data;
435   m_0a = data;
416436
417437   /* Info about sound
418438    - uses a SN76489N chip at an unknown clock
r11218r11219
424444
425445   // no sound comes out
426446   if ((data & 0x30)==0)
427      sn76496_w(state->m_audio, 0, state->m_sn_we);
447      sn76496_w(m_audio, 0, m_sn_we);
428448}
429449
430450static WRITE8_DEVICE_HANDLER( mycom_rtc_w )
r11218r11219
442462static I8255A_INTERFACE( ppi8255_intf_0 )
443463{
444464   DEVCB_NULL,         /* Port A read */
445   DEVCB_HANDLER(mycom_05_r),   /* Port B read */
446   DEVCB_HANDLER(mycom_06_r),   /* Port C read */
447   DEVCB_HANDLER(mycom_04_w),   /* Port A write */
465   DEVCB_DRIVER_MEMBER(mycom_state, mycom_05_r),   /* Port B read */
466   DEVCB_DRIVER_MEMBER(mycom_state, mycom_06_r),   /* Port C read */
467   DEVCB_DRIVER_MEMBER(mycom_state, mycom_04_w),   /* Port A write */
448468   DEVCB_NULL,         /* Port B write */
449   DEVCB_HANDLER(mycom_06_w)   /* Port C write */
469   DEVCB_DRIVER_MEMBER(mycom_state, mycom_06_w)   /* Port C write */
450470};
451471
452472static I8255A_INTERFACE( ppi8255_intf_1 )
453473{
454   DEVCB_HANDLER(mycom_08_r),   /* Port A read */
474   DEVCB_DRIVER_MEMBER(mycom_state, mycom_08_r),   /* Port A read */
455475   DEVCB_NULL,         /* Port B read */
456476   DEVCB_NULL,         /* Port C read */
457477   DEVCB_NULL,         /* Port A write */
458478   DEVCB_NULL,         /* Port B write */
459   DEVCB_HANDLER(mycom_0a_w)   /* Port C write */
479   DEVCB_DRIVER_MEMBER(mycom_state, mycom_0a_w)   /* Port C write */
460480};
461481
462482static I8255A_INTERFACE( ppi8255_intf_2 )
r11218r11219
523543   }
524544}
525545
526static MACHINE_START(mycom)
546MACHINE_START_MEMBER(mycom_state)
527547{
528   mycom_state *state = machine.driver_data<mycom_state>();
529   state->m_audio = machine.device("sn1");
530   state->m_cassette = machine.device("cassette");
531   state->m_fdc = machine.device("fdc");
532   state->m_RAM = machine.region("maincpu")->base();
548   m_p_ram = m_machine.region("maincpu")->base();
533549}
534550
535static MACHINE_RESET(mycom)
551MACHINE_RESET_MEMBER(mycom_state)
536552{
537   mycom_state *state = machine.driver_data<mycom_state>();
538   memory_set_bank(machine, "boot", 1);
539   state->m_upper_sw = 0x10000;
540   state->m_0a = 0;
553   memory_set_bank(m_machine, "boot", 1);
554   m_upper_sw = 0x10000;
555   m_0a = 0;
541556}
542557
543558static DRIVER_INIT( mycom )
r11218r11219
552567   MCFG_CPU_PROGRAM_MAP(mycom_map)
553568   MCFG_CPU_IO_MAP(mycom_io)
554569
555   MCFG_MACHINE_START(mycom)
556   MCFG_MACHINE_RESET(mycom)
557
558570   MCFG_I8255A_ADD( "ppi8255_0", ppi8255_intf_0 )
559571   MCFG_I8255A_ADD( "ppi8255_1", ppi8255_intf_1 )
560572   MCFG_I8255A_ADD( "ppi8255_2", ppi8255_intf_2 )
r11218r11219
566578   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
567579   MCFG_SCREEN_SIZE(640, 480)
568580   MCFG_SCREEN_VISIBLE_AREA(0, 320-1, 0, 192-1)
569   MCFG_SCREEN_UPDATE(mycom)
570
571581   MCFG_PALETTE_LENGTH(2)
572582   MCFG_PALETTE_INIT(black_and_white)
573583   MCFG_GFXDECODE(mycom)
r11218r11219
576586    The CRTC is a HD46505S - same as a 6845. The start registers need to be readable. */
577587   MCFG_MC6845_ADD("crtc", MC6845, 1008000, mc6845_intf)
578588
579   MCFG_VIDEO_START(mycom)
580
581589   MCFG_SPEAKER_STANDARD_MONO("mono")
582590   MCFG_SOUND_WAVE_ADD("wave", "cassette")
583591   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20)
r11218r11219
608616
609617   ROM_REGION( 0x0800, "vram", ROMREGION_ERASE00 )
610618
611   ROM_REGION( 0x0800, "gfx", 0 )
619   ROM_REGION( 0x0800, "chargen", 0 )
612620   ROM_LOAD( "font.rom", 0x0000, 0x0800, CRC(4039bb6f) SHA1(086ad303bf4bcf983fd6472577acbf744875fea8) )
613621ROM_END
614622

Previous 15994 Revisions Next


© 1998-2018 The MESS Team