Previous 15994 Revisions Next

r13896 Friday 6th January, 2012 at 15:28:12 UTC by Angelo Salese
Basic device hook-ups
[src/mess/drivers]bml3.c

src/mess/drivers/bml3.c
r13895r13896
3232#include "emu.h"
3333#include "cpu/m6809/m6809.h"
3434#include "video/mc6845.h"
35#include "machine/mc6843.h"
3536#include "sound/beep.h"
37#include "machine/6821pia.h"
38#include "machine/6850acia.h"
39#include "sound/2203intf.h"
3640
41//#include "imagedev/cassette.h"
42#include "imagedev/flopdrv.h"
43#include "formats/basicdsk.h"
3744
3845class bml3_state : public driver_device
3946{
r13895r13896
5259   required_device<device_t> m_beep;
5360   DECLARE_WRITE8_MEMBER(bml3_6845_w);
5461   DECLARE_READ8_MEMBER(bml3_keyboard_r);
55   DECLARE_READ8_MEMBER(bml3_io_r);
5662   DECLARE_WRITE8_MEMBER(bml3_hres_reg_w);
5763   DECLARE_WRITE8_MEMBER(bml3_vres_reg_w);
58   DECLARE_WRITE8_MEMBER(bml3_io_w);
5964   DECLARE_READ8_MEMBER(bml3_vram_r);
6065   DECLARE_WRITE8_MEMBER(bml3_vram_w);
66   DECLARE_READ8_MEMBER(bml3_fdd_r);
67   DECLARE_WRITE8_MEMBER(bml3_fdd_w);
68   DECLARE_READ8_MEMBER(bml3_kanji_r);
69   DECLARE_WRITE8_MEMBER(bml3_kanji_w);
70   DECLARE_READ8_MEMBER(bml3_psg_latch_r);
71   DECLARE_WRITE8_MEMBER(bml3_psg_latch_w);
72   DECLARE_READ8_MEMBER(bml3_vram_attr_r);
73   DECLARE_WRITE8_MEMBER(bml3_vram_attr_w);
74   DECLARE_WRITE8_MEMBER(bml3_beep_w);
6175   UINT16 m_cursor_addr;
6276   UINT16 m_cursor_raster;
6377   UINT8 m_attr_latch;
r13895r13896
6882   UINT8 m_keyb_press_flag;
6983   int m_addr_latch;
7084   UINT8 *m_p_chargen;
85   UINT8 m_psg_latch;
7186   void m6845_change_clock(UINT8 setting);
7287};
7388
r13895r13896
190205   return 0x00;
191206}
192207
193/* Note: this custom code is there just for simplicity, it'll be nuked in the end */
194READ8_MEMBER( bml3_state::bml3_io_r )
195{
196   UINT8 *rom = machine().region("maincpu")->base();
197
198   if(offset == 0x19) return m_io_latch;
199   if(offset == 0xc4) return 0xff; //some video modes wants this to be high
200//  if(offset == 0xc5 || offset == 0xca) return machine().rand(); //tape related
201   if(offset == 0xc8) return 0; //??? checks bit 7, scrolls vertically if active high
202   if(offset == 0xc9) return 0x11; //0x01 put 320 x 200 mode, 0x07 = 640 x 375
203
204   /* one of these sets something, apparently available RAM space is smaller if one of these bits is zero (?) */
205//  if(offset == 0x40) return 0 ? 0xff : 0x00;
206//  if(offset == 0x42) return 0 ? 0xff : 0x00;
207//  if(offset == 0x44) return 0 ? 0xff : 0x00;
208//  if(offset == 0x46) return 0 ? 0xff : 0x00;
209
210   if(offset == 0xd8) return m_attr_latch;
211   if(offset == 0xe0) return bml3_keyboard_r(space,0);
212
213//  if(offset == 0xcb)
214
215//  if(offset == 0x40 || offset == 0x42 || offset == 0x44 || offset == 0x46)
216
217   if(offset < 0xf0)
218   {
219      //if(cpu_get_pc(m_maincpu) != 0xf838 && cpu_get_pc(m_maincpu) != 0xfac4 && cpu_get_pc(m_maincpu) != 0xf83c)
220      if(offset >= 0xd0 && offset < 0xe0)
221         logerror("I/O read [%02x] at PC=%04x\n",offset,cpu_get_pc(m_maincpu));
222      return 0;//machine().rand();
223   }
224
225   /* TODO: pretty sure that there's a bankswitch for this */
226   return rom[offset+0xff00];
227}
228
229208void bml3_state::m6845_change_clock(UINT8 setting)
230209{
231210   int m6845_clock = XTAL_3_579545MHz;
r13895r13896
264243   m6845_change_clock((m_hres_reg & 0x80) | (m_vres_reg & 0x08));
265244}
266245
267WRITE8_MEMBER( bml3_state::bml3_io_w )
268{
269   if(offset == 0x19)
270      m_io_latch = data; //???
271//  else
272   if(offset == 0xc4)
273      {/* system latch, writes 0x53 -> 0x51 when a tape is loaded */}
274   else
275   if(offset == 0xc6 || offset == 0xc7)
276      bml3_6845_w(space,offset-0xc6,data);
277   else
278   if(offset == 0xd0)
279      bml3_hres_reg_w(space,0,data);
280   else
281   if(offset == 0xd3)
282      beep_set_state(m_beep,!BIT(data, 7));
283   else
284   if(offset == 0xd6)
285      bml3_vres_reg_w(space,0,data);
286   else
287   if(offset == 0xd8)
288      m_attr_latch = data;
289   else
290      logerror("I/O write %02x -> [%02x] at PC=%04x\n",data,offset,cpu_get_pc(m_maincpu));
291}
292246
293247READ8_MEMBER( bml3_state::bml3_vram_r )
294248{
r13895r13896
308262   vram[offset+0x4000] = m_attr_latch;
309263}
310264
265READ8_MEMBER( bml3_state::bml3_fdd_r )
266{
267   printf("FDD 0xff20 R\n");
268   return -1;
269}
270
271WRITE8_MEMBER( bml3_state::bml3_fdd_w )
272{
273   printf("FDD 0xff20 W %02x\n",data);
274}
275
276READ8_MEMBER( bml3_state::bml3_kanji_r )
277{
278   printf("KANJI %04x R\n",offset+0xff75);
279   return -1;
280}
281
282WRITE8_MEMBER( bml3_state::bml3_kanji_w )
283{
284   printf("KANJI %04x W %02x\n",offset+0xff75,data);
285}
286
287READ8_MEMBER( bml3_state::bml3_psg_latch_r)
288{
289   return 0x7f;
290}
291
292WRITE8_MEMBER( bml3_state::bml3_psg_latch_w)
293{
294   m_psg_latch = data;
295}
296
297static READ8_DEVICE_HANDLER( bml3_ym2203_r )
298{
299   bml3_state *state = device->machine().driver_data<bml3_state>();
300   UINT8 dev_offs = ((state->m_psg_latch & 3) != 3);
301
302   return ym2203_r(device,dev_offs);
303}
304
305static WRITE8_DEVICE_HANDLER( bml3_ym2203_w )
306{
307   bml3_state *state = device->machine().driver_data<bml3_state>();
308   UINT8 dev_offs = ((state->m_psg_latch & 3) != 3);
309
310   ym2203_w(device,dev_offs,data);
311}
312
313READ8_MEMBER( bml3_state::bml3_vram_attr_r)
314{
315   return m_attr_latch;
316}
317
318WRITE8_MEMBER( bml3_state::bml3_vram_attr_w)
319{
320   m_attr_latch = data;
321}
322
323WRITE8_MEMBER( bml3_state::bml3_beep_w)
324{
325   beep_set_state(m_beep,!BIT(data, 7));
326}
327
311328static ADDRESS_MAP_START(bml3_mem, AS_PROGRAM, 8, bml3_state)
312329   ADDRESS_MAP_UNMAP_HIGH
313330   AM_RANGE(0x0000, 0x03ff) AM_RAM
314331   AM_RANGE(0x0400, 0x43ff) AM_READWRITE(bml3_vram_r,bml3_vram_w)
315332   AM_RANGE(0x4400, 0x9fff) AM_RAM
316   AM_RANGE(0xff00, 0xffff) AM_READWRITE(bml3_io_r,bml3_io_w)
317//   AM_RANGE(0xff00, 0xff00) PSG data
318//   AM_RANGE(0xff02, 0xff02) PSG address/data select
319//   AM_RANGE(0xff18, 0xff1f) FDC
320//   AM_RANGE(0xff20, 0xff20) FDD drive select
321//   AM_RANGE(0xff75, 0xff76) kanji i/f
322//   AM_RANGE(0xffc0, 0xffc3) pia
323//   AM_RANGE(0xffc4, 0xffc5) ACIA
324//   AM_RANGE(0xffc6, 0xffc7) HD46505
333   AM_RANGE(0xff00, 0xff00) AM_DEVREADWRITE_LEGACY("ym2203",bml3_ym2203_r,bml3_ym2203_w)
334   AM_RANGE(0xff02, 0xff02) AM_READWRITE(bml3_psg_latch_r,bml3_psg_latch_w) // PSG address/data select
335   AM_RANGE(0xff18, 0xff1f) AM_DEVREADWRITE_LEGACY("mc6843",mc6843_r,mc6843_w)
336   AM_RANGE(0xff20, 0xff20) AM_READWRITE(bml3_fdd_r,bml3_fdd_w) // FDD drive select
337   AM_RANGE(0xff75, 0xff76) AM_READWRITE(bml3_kanji_r,bml3_kanji_w)// kanji i/f
338   AM_RANGE(0xffc0, 0xffc3) AM_DEVREADWRITE("pia6821", pia6821_device, read, write)
339   AM_RANGE(0xffc4, 0xffc4) AM_DEVREADWRITE("acia6850", acia6850_device, status_read, control_write)
340   AM_RANGE(0xffc5, 0xffc5) AM_DEVREADWRITE("acia6850", acia6850_device, data_read, data_write)
341   AM_RANGE(0xffc6, 0xffc7) AM_WRITE(bml3_6845_w)
325342//   AM_RANGE(0xffc8, 0xffc8) keyboard nmi
343   AM_RANGE(0xffc9, 0xffc9) AM_READ_PORT("DSW")
326344//   AM_RANGE(0xffca, 0xffca) timer irq
327345//   AM_RANGE(0xffcb, 0xffcb) light pen flag
328//   AM_RANGE(0xffd0, 0xffd0) mode select
346   AM_RANGE(0xffd0, 0xffd0) AM_WRITE(bml3_hres_reg_w) // mode select
329347//   AM_RANGE(0xffd1, 0xffd1) trace counter
330348//   AM_RANGE(0xffd2, 0xffd2) remote switch
331//   AM_RANGE(0xffd3, 0xffd3) music select
349   AM_RANGE(0xffd3, 0xffd3) AM_WRITE(bml3_beep_w) // music select
332350//   AM_RANGE(0xffd4, 0xffd4) time mask
333351//   AM_RANGE(0xffd5, 0xffd5) light pen
334//   AM_RANGE(0xffd6, 0xffd6) interlace select
352   AM_RANGE(0xffd6, 0xffd6) AM_WRITE(bml3_vres_reg_w) // interlace select
335353//   AM_RANGE(0xffd7, 0xffd7) baud select
336//   AM_RANGE(0xffd8, 0xffd8) attribute register
337//   AM_RANGE(0xffe0, 0xffe0) keyboard mode register
354   AM_RANGE(0xffd8, 0xffd8) AM_READWRITE(bml3_vram_attr_r,bml3_vram_attr_w) // attribute register
355   AM_RANGE(0xffe0, 0xffe0) AM_READ(bml3_keyboard_r) // keyboard mode register
338356//   AM_RANGE(0xffe8, 0xffe8) bank register
339357//   AM_RANGE(0xffe9, 0xffe9) IG mode register
340358//   AM_RANGE(0xffea, 0xffea) IG enable register
r13895r13896
345363/* Input ports */
346364
347365static INPUT_PORTS_START( bml3 )
366   PORT_START("DSW")
367   PORT_DIPNAME( 0x01, 0x00, "DSW" )
368   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
369   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
370   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
371   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
372   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
373   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
374   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
375   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
376   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
377   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
378   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
379   PORT_DIPNAME( 0x10, 0x10, "Show F help" )
380   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
381   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
382   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
383   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
384   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
385   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
386   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
387   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
388   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
389   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
390   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
391
348392   PORT_START("key1") //0x00-0x1f
349393   PORT_BIT(0x00000001,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
350394   PORT_BIT(0x00000002,IP_ACTIVE_HIGH,IPT_KEYBOARD) PORT_NAME("Up") PORT_CODE(KEYCODE_UP)
r13895r13896
555599   GFXDECODE_ENTRY( "chargen", 0, bml3_charlayout8x16, 0, 4 )
556600GFXDECODE_END
557601
602const mc6843_interface bml3_6843_if = { NULL };
603
604static const pia6821_interface bml3_pia_config =
605{
606   DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL,
607   DEVCB_NULL, DEVCB_NULL,
608   DEVCB_NULL, DEVCB_NULL, DEVCB_NULL, DEVCB_NULL
609};
610
611static ACIA6850_INTERFACE( bml3_acia_if )
612{
613   0,
614   0,
615   DEVCB_NULL,//LINE(m6809_acia_rx_r),
616   DEVCB_NULL,//LINE(m6809_acia_tx_w),
617   DEVCB_NULL,//LINE(m6809_acia_cts_r),
618   DEVCB_NULL,//LINE(m6809_acia_rts_w),
619   DEVCB_NULL,//LINE(m6809_acia_dcd_r),
620   DEVCB_NULL//LINE(m6809_acia_irq)
621};
622
623static const ym2203_interface ym2203_interface_1 =
624{
625   {
626      AY8910_LEGACY_OUTPUT,
627      AY8910_DEFAULT_LOADS,
628      DEVCB_NULL,   // read A
629      DEVCB_NULL,   // read B
630      DEVCB_NULL,   // write A
631      DEVCB_NULL   // write B
632   },
633   NULL
634};
635
636/* TODO */
637static const floppy_interface bml3_floppy_interface =
638{
639   DEVCB_NULL,
640   DEVCB_NULL,
641   DEVCB_NULL,
642   DEVCB_NULL,
643   DEVCB_NULL,
644   FLOPPY_STANDARD_5_25_DSHD,
645   LEGACY_FLOPPY_OPTIONS_NAME(default),
646   "floppy_3_5",
647   NULL
648};
649
558650static MACHINE_CONFIG_START( bml3, bml3_state )
559651   /* basic machine hardware */
560652   MCFG_CPU_ADD("maincpu",M6809, XTAL_1MHz)
r13895r13896
577669   MCFG_PALETTE_LENGTH(8)
578670   MCFG_PALETTE_INIT(bml3)
579671   MCFG_GFXDECODE(bml3)
672
673   /* Devices */
674   MCFG_MC6845_ADD("crtc", H46505, XTAL_3_579545MHz/4, mc6845_intf)   /* unknown clock, hand tuned to get ~60 fps */
675   MCFG_TIMER_ADD_PERIODIC("keyboard_timer", keyboard_callback, attotime::from_hz(240/8))
676   MCFG_MC6843_ADD( "mc6843", bml3_6843_if )
677   MCFG_PIA6821_ADD("pia6821", bml3_pia_config)
678   MCFG_ACIA6850_ADD("acia6850", bml3_acia_if)
679
680   MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(bml3_floppy_interface)
681
580682   /* Audio */
581683   MCFG_SPEAKER_STANDARD_MONO("mono")
582684   MCFG_SOUND_ADD(BEEPER_TAG, BEEP, 0)
583685   MCFG_SOUND_ROUTE(ALL_OUTPUTS,"mono",0.50)
584686
585   /* Devices */
586   MCFG_MC6845_ADD("crtc", H46505, XTAL_3_579545MHz/4, mc6845_intf)   /* unknown clock, hand tuned to get ~60 fps */
587   MCFG_TIMER_ADD_PERIODIC("keyboard_timer", keyboard_callback, attotime::from_hz(240/8))
687   MCFG_SOUND_ADD("ym2203", YM2203, 2000000) //unknown clock / divider
688   MCFG_SOUND_CONFIG(ym2203_interface_1)
689   MCFG_SOUND_ROUTE(0, "mono", 0.25)
690   MCFG_SOUND_ROUTE(1, "mono", 0.25)
691   MCFG_SOUND_ROUTE(2, "mono", 0.50)
692   MCFG_SOUND_ROUTE(3, "mono", 0.50)
588693MACHINE_CONFIG_END
589694
590695/* ROM definition */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team