Previous 15994 Revisions Next

r9630 Monday 22nd November, 2010 at 11:14:47 UTC by Curt Coder
[TANDY2K] Refactored driver to define ADDRESS_MAP_MODERN.
[src/emu/cpu/mcs48]mcs48.c
[src/mess/drivers]tandy2k.c
[src/mess/includes]tandy2k.h

src/emu/cpu/mcs48/mcs48.c
r9629r9630
221221INLINE mcs48_state *get_safe_token(running_device *device)
222222{
223223   assert(device != NULL);
224   assert(device->type() == I8035 ||
224   assert(device->type() == I8021 ||
225         device->type() == I8022 ||
226         device->type() == I8035 ||
225227         device->type() == I8048 ||
226228         device->type() == I8648 ||
227229         device->type() == I8748 ||
src/mess/includes/tandy2k.h
r9629r9630
2020{
2121public:
2222   tandy2k_state(running_machine &machine, const driver_device_config_base &config)
23      : driver_device(machine, config) { }
23      : driver_device(machine, config),
24        m_maincpu(*this, I80186_TAG),
25        m_uart(*this, I8251A_TAG),
26        m_pit(*this, I8253_TAG),
27        m_fdc(*this, I8272A_TAG),
28        m_pic0(*this, I8259A_0_TAG),
29        m_pic1(*this, I8259A_1_TAG),
30        m_vpac(*this, CRT9007_TAG),
31        m_centronics(*this, CENTRONICS_TAG),
32        m_speaker(*this, SPEAKER_TAG),
33        m_ram(*this, "messram"),
34        m_floppy0(*this, FLOPPY_0),
35        m_floppy1(*this, FLOPPY_1)
36   { }
2437
38   required_device<cpu_device> m_maincpu;
39   required_device<running_device> m_uart;
40   required_device<running_device> m_pit;
41   required_device<running_device> m_fdc;
42   required_device<running_device> m_pic0;
43   required_device<running_device> m_pic1;
44   required_device<running_device> m_vpac;
45   required_device<running_device> m_centronics;
46   required_device<running_device> m_speaker;
47   required_device<running_device> m_ram;
48   required_device<running_device> m_floppy0;
49   required_device<running_device> m_floppy1;
50
51   virtual void machine_start();
52
53   virtual bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
54
55   void speaker_update();
56   void dma_request(int line, int state);
57
58   DECLARE_READ8_MEMBER( enable_r );
59   DECLARE_WRITE8_MEMBER( enable_w );
60   DECLARE_WRITE8_MEMBER( dma_mux_w );
61   DECLARE_WRITE8_MEMBER( addr_ctrl_w );
62   DECLARE_READ8_MEMBER( keyboard_x0_r );
63   DECLARE_WRITE8_MEMBER( keyboard_y0_w );
64   DECLARE_WRITE8_MEMBER( keyboard_y8_w );
65   DECLARE_WRITE_LINE_MEMBER( busdmarq0_w );
66   DECLARE_WRITE_LINE_MEMBER( outspkr_w );
67   DECLARE_WRITE_LINE_MEMBER( intbrclk_w );
68   DECLARE_WRITE_LINE_MEMBER( rfrqpulse_w );
69   DECLARE_READ8_MEMBER( ppi_pb_r );
70   DECLARE_WRITE8_MEMBER( ppi_pc_w );
71
2572   /* DMA state */
26   UINT8 dma_mux;
73   UINT8 m_dma_mux;
2774
2875   /* keyboard state */
29   int kben;
30   UINT16 keylatch;
76   int m_kben;
77   UINT16 m_keylatch;
3178
3279   /* serial state */
33   int extclk;
34   int rxrdy;
35   int txrdy;
80   int m_extclk;
81   int m_rxrdy;
82   int m_txrdy;
3683
3784   /* PPI state */
38   int pb_sel;
85   int m_pb_sel;
3986
4087   /* video state */
41   UINT16 *char_ram;
42   UINT16 *hires_ram;
43   UINT16 palette[16];
44   UINT32 vram_base;
45   int vidouts;
88   UINT16 *m_char_ram;
89   UINT16 *m_hires_ram;
90   UINT16 m_palette[16];
91   UINT32 m_vram_base;
92   int m_vidouts;
93   int m_clkspd;
94   int m_clkcnt;
4695
4796   /* sound state */
48   int outspkr;
49   int spkrdata;
50
51   /* devices */
52   running_device *uart;
53   running_device *pit;
54   running_device *fdc;
55   running_device *pic0;
56   running_device *pic1;
57   running_device *vpac;
58   running_device *centronics;
59   running_device *speaker;
97   int m_outspkr;
98   int m_spkrdata;
6099};
61100
62101#endif
src/mess/drivers/tandy2k.c
r9629r9630
1919    - WD1010
2020    - hard disk
2121    - mouse
22    - save state
2322
2423*/
2524
25#define ADDRESS_MAP_MODERN
26
2627#include "emu.h"
27#include "includes/tandy2k.h"
2828#include "cpu/i86/i86.h"
2929#include "cpu/mcs48/mcs48.h"
3030#include "devices/flopdrv.h"
r9629r9630
3737#include "machine/upd765.h"
3838#include "sound/speaker.h"
3939#include "video/crt9007.h"
40#include "includes/tandy2k.h"
4041
4142/* Read/Write Handlers */
4243
43static void speaker_update(tandy2k_state *state)
44void tandy2k_state::dma_request(int line, int state)
4445{
45   int level = !(state->spkrdata & state->outspkr);
4646
47   speaker_level_w(state->speaker, level);
4847}
4948
50static READ8_HANDLER( enable_r )
49void tandy2k_state::speaker_update()
5150{
51   int level = !(m_spkrdata & m_outspkr);
52
53   speaker_level_w(m_speaker, level);
54}
55
56READ8_MEMBER( tandy2k_state::enable_r )
57{
5258   /*
5359
5460        bit     signal      description
r9629r9630
6773   return 0x80;
6874}
6975
70static WRITE8_HANDLER( enable_w )
76WRITE8_MEMBER( tandy2k_state::enable_w )
7177{
7278   /*
7379
r9629r9630
7581
7682        0       KBEN        keyboard enable
7783        1       EXTCLK      external baud rate clock
78        2       SPKRGATE    enable periodic speaker output
79        3       SPKRDATA    direct output to speaker
84        2       SPKRGATE    enable periodic m_speaker output
85        3       SPKRDATA    direct output to m_speaker
8086        4       RFRQGATE    enable refresh and baud rate clocks
8187        5       _FDCRESET   reset 8272
8288        6       TMRIN0      enable 80186 timer 0
r9629r9630
8490
8591    */
8692
87   tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
88
8993   /* keyboard enable */
90   state->kben = BIT(data, 0);
94   m_kben = BIT(data, 0);
9195
9296   /* external baud rate clock */
93   state->extclk = BIT(data, 1);
97   m_extclk = BIT(data, 1);
9498
95   /* speaker gate */
96   pit8253_gate0_w(state->pit, BIT(data, 2));
99   /* m_speaker gate */
100   pit8253_gate0_w(m_pit, BIT(data, 2));
97101
98   /* speaker data */
99   state->spkrdata = BIT(data, 3);
100   speaker_update(state);
102   /* m_speaker data */
103   m_spkrdata = BIT(data, 3);
104   speaker_update();
101105
102106   /* refresh and baud rate clocks */
103   pit8253_gate1_w(state->pit, BIT(data, 4));
104   pit8253_gate2_w(state->pit, BIT(data, 4));
107   pit8253_gate1_w(m_pit, BIT(data, 4));
108   pit8253_gate2_w(m_pit, BIT(data, 4));
105109
106110   /* FDC reset */
107   upd765_reset_w(state->fdc, BIT(data, 5));
111   upd765_reset_w(m_fdc, BIT(data, 5));
108112
109113   /* timer 0 enable */
110   cputag_set_input_line(space->machine, I80186_TAG, INPUT_LINE_TMRIN0, BIT(data, 6));
114   cpu_set_input_line(m_maincpu, INPUT_LINE_TMRIN0, BIT(data, 6));
111115
112116   /* timer 1 enable */
113   cputag_set_input_line(space->machine, I80186_TAG, INPUT_LINE_TMRIN1, BIT(data, 7));
117   cpu_set_input_line(m_maincpu, INPUT_LINE_TMRIN1, BIT(data, 7));
114118}
115119
116static WRITE8_HANDLER( dma_mux_w )
120WRITE8_MEMBER( tandy2k_state::dma_mux_w )
117121{
118122   /*
119123
r9629r9630
130134
131135    */
132136
133   tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
137   m_dma_mux = data;
134138
135   state->dma_mux = data;
136
137139   /* check for DMA error */
138140   int drq0 = 0;
139141   int drq1 = 0;
r9629r9630
144146   }
145147
146148   int dme = (drq0 > 2) || (drq1 > 2);
147   pic8259_ir6_w(state->pic1, dme);
148}
149149
150static void dma_request(running_machine *machine, int line, int state)
151{
152
150   pic8259_ir6_w(m_pic1, dme);
153151}
154152
155153static READ8_DEVICE_HANDLER( fldtc_r )
r9629r9630
166164   upd765_tc_w(device, 0);
167165}
168166
169static WRITE8_HANDLER( addr_ctrl_w )
167WRITE8_MEMBER( tandy2k_state::addr_ctrl_w )
170168{
171169   /*
172170
r9629r9630
183181
184182    */
185183
186   tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
187
188184   /* video access */
189   state->vram_base = data << 15;
185   m_vram_base = data << 15;
190186
191187   /* video clock speed */
192   crt9007_set_clock(state->vpac, BIT(data, 5) ? XTAL_16MHz*28/16 : XTAL_16MHz*28/20);
188   if (m_clkspd != BIT(data, 5))
189   {
190      crt9007_set_clock(m_vpac, BIT(data, 5) ? XTAL_16MHz*28/16 : XTAL_16MHz*28/20);
191      m_clkspd = BIT(data, 5);
192   }
193193
194194   /* dots per char */
195   crt9007_set_hpixels_per_column(state->vpac, BIT(data, 6) ? 8 : 10);
195   if (m_clkcnt != BIT(data, 6))
196   {
197      crt9007_set_hpixels_per_column(m_vpac, BIT(data, 6) ? 8 : 10);
198      m_clkcnt = BIT(data, 6);
199   }
196200
197201   /* video source select */
198   state->vidouts = BIT(data, 7);
202   m_vidouts = BIT(data, 7);
199203
200204   logerror("Address Control %02x\n", data);
201205}
202206
203static READ8_HANDLER( keyboard_x0_r )
207READ8_MEMBER( tandy2k_state::keyboard_x0_r )
204208{
205209  /*
206210
r9629r9630
217221
218222    */
219223
220 tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
224   UINT8 data = 0xff;
221225
222  UINT8 data = 0xff;
226   if (!BIT(m_keylatch, 0)) data &= input_port_read(machine, "Y0");
227   if (!BIT(m_keylatch, 1)) data &= input_port_read(machine, "Y1");
228   if (!BIT(m_keylatch, 2)) data &= input_port_read(machine, "Y2");
229   if (!BIT(m_keylatch, 3)) data &= input_port_read(machine, "Y3");
230   if (!BIT(m_keylatch, 4)) data &= input_port_read(machine, "Y4");
231   if (!BIT(m_keylatch, 5)) data &= input_port_read(machine, "Y5");
232   if (!BIT(m_keylatch, 6)) data &= input_port_read(machine, "Y6");
233   if (!BIT(m_keylatch, 7)) data &= input_port_read(machine, "Y7");
234   if (!BIT(m_keylatch, 8)) data &= input_port_read(machine, "Y8");
235   if (!BIT(m_keylatch, 9)) data &= input_port_read(machine, "Y9");
236   if (!BIT(m_keylatch, 10)) data &= input_port_read(machine, "Y10");
237   if (!BIT(m_keylatch, 11)) data &= input_port_read(machine, "Y11");
223238
224  if (!BIT(state->keylatch,  0)) data &= input_port_read(space->machine,  "Y0");
225  if (!BIT(state->keylatch,  1)) data &= input_port_read(space->machine,  "Y1");
226  if (!BIT(state->keylatch,  2)) data &= input_port_read(space->machine,  "Y2");
227  if (!BIT(state->keylatch,  3)) data &= input_port_read(space->machine,  "Y3");
228  if (!BIT(state->keylatch,  4)) data &= input_port_read(space->machine,  "Y4");
229  if (!BIT(state->keylatch,  5)) data &= input_port_read(space->machine,  "Y5");
230  if (!BIT(state->keylatch,  6)) data &= input_port_read(space->machine,  "Y6");
231  if (!BIT(state->keylatch,  7)) data &= input_port_read(space->machine,  "Y7");
232  if (!BIT(state->keylatch,  8)) data &= input_port_read(space->machine,  "Y8");
233  if (!BIT(state->keylatch,  9)) data &= input_port_read(space->machine,  "Y9");
234  if (!BIT(state->keylatch, 10)) data &= input_port_read(space->machine, "Y10");
235  if (!BIT(state->keylatch, 11)) data &= input_port_read(space->machine, "Y11");
236
237  return ~data;
239   return ~data;
238240}
239241
240static WRITE8_HANDLER( keyboard_y0_w )
242WRITE8_MEMBER( tandy2k_state::keyboard_y0_w )
241243{
242  /*
244   /*
243245
244        bit     description
246      bit     description
245247
246        0       Y0
247        1       Y1
248        2       Y2
249        3       Y3
250        4       Y4
251        5       Y5
252        6       Y6
253        7       Y7
248      0       Y0
249      1       Y1
250      2       Y2
251      3       Y3
252      4       Y4
253      5       Y5
254      6       Y6
255      7       Y7
254256
255    */
257   */
256258
257  tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
258
259  /* keyboard row select */
260  state->keylatch = (state->keylatch & 0xff00) | data;
259   /* keyboard row select */
260   m_keylatch = (m_keylatch & 0xff00) | data;
261261}
262262
263static WRITE8_HANDLER( keyboard_y8_w )
263WRITE8_MEMBER( tandy2k_state::keyboard_y8_w )
264264{
265  /*
265   /*
266266
267        bit     description
267      bit     description
268268
269        0       Y8
270        1       Y9
271        2       Y10
272        3       Y11
273        4       LED 2
274        5       LED 1
275        6
276        7
269      0       Y8
270      1       Y9
271      2       Y10
272      3       Y11
273      4       LED 2
274      5       LED 1
275      6
276      7
277277
278    */
278   */
279279
280  tandy2k_state *state = space->machine->driver_data<tandy2k_state>();
281
282  /* keyboard row select */
283  state->keylatch = ((data & 0x0f) << 8) | (state->keylatch & 0xff);
280   /* keyboard row select */
281   m_keylatch = ((data & 0x0f) << 8) | (m_keylatch & 0xff);
284282}
285283
286284/* Memory Maps */
287285
288static ADDRESS_MAP_START( tandy2k_mem, ADDRESS_SPACE_PROGRAM, 16 )
286static ADDRESS_MAP_START( tandy2k_mem, ADDRESS_SPACE_PROGRAM, 16, tandy2k_state )
289287   ADDRESS_MAP_UNMAP_HIGH
290288//  AM_RANGE(0x00000, 0xdffff) AM_RAM
291//  AM_RANGE(0xe0000, 0xf7fff) AM_RAM // hires graphics
292   AM_RANGE(0xf8000, 0xfbfff) AM_RAM AM_BASE_MEMBER(tandy2k_state, char_ram)
289   AM_RANGE(0xe0000, 0xf7fff) AM_RAM AM_BASE(m_hires_ram)
290   AM_RANGE(0xf8000, 0xfbfff) AM_RAM AM_BASE(m_char_ram)
293291   AM_RANGE(0xfc000, 0xfdfff) AM_MIRROR(0x2000) AM_ROM AM_REGION(I80186_TAG, 0)
294292ADDRESS_MAP_END
295293
296static ADDRESS_MAP_START( tandy2k_io, ADDRESS_SPACE_IO, 16 )
294static ADDRESS_MAP_START( tandy2k_io, ADDRESS_SPACE_IO, 16, tandy2k_state )
297295   ADDRESS_MAP_UNMAP_HIGH
298296   AM_RANGE(0x00000, 0x00001) AM_READWRITE8(enable_r, enable_w, 0x00ff)
299297   AM_RANGE(0x00002, 0x00003) AM_WRITE8(dma_mux_w, 0x00ff)
300   AM_RANGE(0x00004, 0x00005) AM_DEVREADWRITE8(I8272A_TAG, fldtc_r, fldtc_w, 0x00ff)
301   AM_RANGE(0x00010, 0x00013) AM_DEVREADWRITE8(I8251A_TAG, msm8251_data_r, msm8251_data_w, 0x00ff)
302   AM_RANGE(0x00030, 0x00031) AM_DEVREAD8(I8272A_TAG, upd765_status_r, 0x00ff)
303   AM_RANGE(0x00032, 0x00033) AM_DEVREADWRITE8(I8272A_TAG, upd765_data_r, upd765_data_w, 0x00ff)
304   AM_RANGE(0x00040, 0x00047) AM_DEVREADWRITE8(I8253_TAG, pit8253_r, pit8253_w, 0x00ff)
305   AM_RANGE(0x00050, 0x00057) AM_DEVREADWRITE8(I8255A_TAG, i8255a_r, i8255a_w, 0x00ff)
306   AM_RANGE(0x00060, 0x00063) AM_DEVREADWRITE8(I8259A_0_TAG, pic8259_r, pic8259_w, 0x00ff)
307   AM_RANGE(0x00070, 0x00073) AM_DEVREADWRITE8(I8259A_1_TAG, pic8259_r, pic8259_w, 0x00ff)
308   AM_RANGE(0x00080, 0x00081) AM_DEVREADWRITE8(I8272A_TAG, upd765_dack_r, upd765_dack_w, 0x00ff)
309   AM_RANGE(0x00100, 0x0017f) AM_DEVREADWRITE8(CRT9007_TAG, crt9007_r, crt9007_w, 0x00ff)
310   AM_RANGE(0x00100, 0x0017f) AM_WRITE8(addr_ctrl_w, 0xff00)
298   AM_RANGE(0x00004, 0x00005) AM_DEVREADWRITE8_LEGACY(I8272A_TAG, fldtc_r, fldtc_w, 0x00ff)
299   AM_RANGE(0x00010, 0x00013) AM_DEVREADWRITE8_LEGACY(I8251A_TAG, msm8251_data_r, msm8251_data_w, 0x00ff)
300   AM_RANGE(0x00030, 0x00031) AM_DEVREAD8_LEGACY(I8272A_TAG, upd765_status_r, 0x00ff)
301   AM_RANGE(0x00032, 0x00033) AM_DEVREADWRITE8_LEGACY(I8272A_TAG, upd765_data_r, upd765_data_w, 0x00ff)
302   AM_RANGE(0x00040, 0x00047) AM_DEVREADWRITE8_LEGACY(I8253_TAG, pit8253_r, pit8253_w, 0x00ff)
303   AM_RANGE(0x00050, 0x00057) AM_DEVREADWRITE8_LEGACY(I8255A_TAG, i8255a_r, i8255a_w, 0x00ff)
304   AM_RANGE(0x00060, 0x00063) AM_DEVREADWRITE8_LEGACY(I8259A_0_TAG, pic8259_r, pic8259_w, 0x00ff)
305   AM_RANGE(0x00070, 0x00073) AM_DEVREADWRITE8_LEGACY(I8259A_1_TAG, pic8259_r, pic8259_w, 0x00ff)
306   AM_RANGE(0x00080, 0x00081) AM_DEVREADWRITE8_LEGACY(I8272A_TAG, upd765_dack_r, upd765_dack_w, 0x00ff)
307   AM_RANGE(0x00100, 0x0017f) AM_DEVREADWRITE8_LEGACY(CRT9007_TAG, crt9007_r, crt9007_w, 0x00ff) AM_WRITE8(addr_ctrl_w, 0xff00)
311308//  AM_RANGE(0x00180, 0x00180) AM_READ8(hires_status_r, 0x00ff)
312309//  AM_RANGE(0x00180, 0x001bf) AM_WRITE(hires_palette_w)
313310//  AM_RANGE(0x001a0, 0x001a0) AM_READ8(hires_plane_w, 0x00ff)
314311//  AM_RANGE(0x0ff00, 0x0ffff) AM_READWRITE(i186_internal_port_r, i186_internal_port_w)
315312ADDRESS_MAP_END
316313
317static ADDRESS_MAP_START( tandy2k_hd_io, ADDRESS_SPACE_IO, 16 )
314static ADDRESS_MAP_START( tandy2k_hd_io, ADDRESS_SPACE_IO, 16, tandy2k_state )
318315   AM_IMPORT_FROM(tandy2k_io)
319316//  AM_RANGE(0x000e0, 0x000ff) AM_WRITE8(hdc_dack_w, 0x00ff)
320//  AM_RANGE(0x0026c, 0x0026d) AM_DEVREADWRITE8(WD1010_TAG, hdc_reset_r, hdc_reset_w, 0x00ff)
321//  AM_RANGE(0x0026e, 0x0027f) AM_DEVREADWRITE8(WD1010_TAG, wd1010_r, wd1010_w, 0x00ff)
317//  AM_RANGE(0x0026c, 0x0026d) AM_DEVREADWRITE8_LEGACY(WD1010_TAG, hdc_reset_r, hdc_reset_w, 0x00ff)
318//  AM_RANGE(0x0026e, 0x0027f) AM_DEVREADWRITE8_LEGACY(WD1010_TAG, wd1010_r, wd1010_w, 0x00ff)
322319ADDRESS_MAP_END
323320
324static ADDRESS_MAP_START( keyboard_io, ADDRESS_SPACE_IO, 8 )
321static ADDRESS_MAP_START( keyboard_io, ADDRESS_SPACE_IO, 8, tandy2k_state )
325322  AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(keyboard_y0_w)
326323  AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(keyboard_y8_w)
327324  AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_READ(keyboard_x0_r)
r9629r9630
453450
454451/* Video */
455452
456static VIDEO_START( tandy2k )
453bool tandy2k_state::video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
457454{
458   tandy2k_state *state = machine->driver_data<tandy2k_state>();
459
460   /* find devices */
461   state->vpac = machine->device(CRT9007_TAG);
462}
463
464static VIDEO_UPDATE( tandy2k )
465{
466   tandy2k_state *state = screen->machine->driver_data<tandy2k_state>();
467
468   //if (state->vidouts)
455   if (m_vidouts)
469456   {
470      crt9007_update(state->vpac, bitmap, cliprect);
457      crt9007_update(m_vpac, &bitmap, &cliprect);
471458   }
472459
473460   return 0;
r9629r9630
476463static CRT9007_DRAW_SCANLINE( tandy2k_crt9007_display_pixels )
477464{
478465   tandy2k_state *state = device->machine->driver_data<tandy2k_state>();
479   address_space *program = cputag_get_address_space(device->machine, I80186_TAG, ADDRESS_SPACE_PROGRAM);
466   address_space *program = cpu_get_address_space(state->m_maincpu, ADDRESS_SPACE_PROGRAM);
480467
481468   for (int sx = 0; sx < x_count; sx++)
482469   {
483      UINT32 videoram_addr = (state->vram_base | (va << 1)) + sx;
470      UINT32 videoram_addr = (state->m_vram_base | (va << 1)) + sx;
484471      UINT8 videoram_data = program->read_word(videoram_addr);
485472      UINT16 charram_addr = (videoram_data << 4) | sl;
486      UINT8 charram_data = state->char_ram[charram_addr] & 0xff;
473      UINT8 charram_data = state->m_char_ram[charram_addr] & 0xff;
487474
488475      for (int bit = 0; bit < 10; bit++)
489476      {
r9629r9630
516503{
517504   tandy2k_state *driver_state = device->machine->driver_data<tandy2k_state>();
518505
519   driver_state->rxrdy = state;
520   pic8259_ir2_w(driver_state->pic0, driver_state->rxrdy | driver_state->txrdy);
506   driver_state->m_rxrdy = state;
507   pic8259_ir2_w(driver_state->m_pic0, driver_state->m_rxrdy | driver_state->m_txrdy);
521508}
522509
523510static WRITE_LINE_DEVICE_HANDLER( txrdy_w )
524511{
525512   tandy2k_state *driver_state = device->machine->driver_data<tandy2k_state>();
526513
527   driver_state->txrdy = state;
528   pic8259_ir2_w(driver_state->pic0, driver_state->rxrdy | driver_state->txrdy);
514   driver_state->m_txrdy = state;
515   pic8259_ir2_w(driver_state->m_pic0, driver_state->m_rxrdy | driver_state->m_txrdy);
529516}
530517
531518static const msm8251_interface i8251_intf =
r9629r9630
537524
538525/* Intel 8253 Interface */
539526
540static WRITE_LINE_DEVICE_HANDLER( outspkr_w )
527WRITE_LINE_MEMBER( tandy2k_state::outspkr_w )
541528{
542   tandy2k_state *driver_state = device->machine->driver_data<tandy2k_state>();
543
544   driver_state->outspkr = state;
545   speaker_update(driver_state);
529   m_outspkr = state;
530   speaker_update();
546531}
547532
548static WRITE_LINE_DEVICE_HANDLER( intbrclk_w )
533WRITE_LINE_MEMBER( tandy2k_state::intbrclk_w )
549534{
550   tandy2k_state *driver_state = device->machine->driver_data<tandy2k_state>();
551
552   if (!driver_state->extclk && state)
535   if (!m_extclk && state)
553536   {
554      msm8251_transmit_clock(driver_state->uart);
555      msm8251_receive_clock(driver_state->uart);
537      msm8251_transmit_clock(m_uart);
538      msm8251_receive_clock(m_uart);
556539   }
557540}
558541
559static WRITE_LINE_DEVICE_HANDLER( rfrqpulse_w )
542WRITE_LINE_MEMBER( tandy2k_state::rfrqpulse_w )
560543{
561544}
562545
r9629r9630
566549      {
567550         XTAL_16MHz/16,
568551         DEVCB_NULL,
569         DEVCB_LINE(outspkr_w)
552         DEVCB_DRIVER_LINE_MEMBER(tandy2k_state, outspkr_w)
570553      }, {
571554         XTAL_16MHz/8,
572555         DEVCB_NULL,
573         DEVCB_LINE(intbrclk_w)
556         DEVCB_DRIVER_LINE_MEMBER(tandy2k_state, intbrclk_w)
574557      }, {
575558         XTAL_16MHz/8,
576559         DEVCB_NULL,
577         DEVCB_LINE(rfrqpulse_w)
560         DEVCB_DRIVER_LINE_MEMBER(tandy2k_state, rfrqpulse_w)
578561      }
579562   }
580563};
r9629r9630
588571   PORTINEN
589572};
590573
591static READ8_DEVICE_HANDLER( ppi_pb_r )
574READ8_MEMBER( tandy2k_state::ppi_pb_r )
592575{
593576   /*
594577
r9629r9630
605588
606589    */
607590
608   tandy2k_state *state = device->machine->driver_data<tandy2k_state>();
609
610591   UINT8 data = 0;
611592
612   switch (state->pb_sel)
593   switch (m_pb_sel)
613594   {
614595   case LPINEN:
615596      /* printer acknowledge */
616      data |= centronics_ack_r(state->centronics) << 3;
597      data |= centronics_ack_r(m_centronics) << 3;
617598
618599      /* printer fault */
619      data |= centronics_fault_r(state->centronics) << 4;
600      data |= centronics_fault_r(m_centronics) << 4;
620601
621602      /* printer select */
622      data |= centronics_vcc_r(state->centronics) << 5;
603      data |= centronics_vcc_r(m_centronics) << 5;
623604
624605      /* paper empty */
625      data |= centronics_pe_r(state->centronics) << 6;
606      data |= centronics_pe_r(m_centronics) << 6;
626607
627608      /* printer busy */
628      data |= centronics_busy_r(state->centronics) << 7;
609      data |= centronics_busy_r(m_centronics) << 7;
629610      break;
630611
631612   case KBDINEN:
r9629r9630
641622   return data;
642623}
643624
644static WRITE8_DEVICE_HANDLER( ppi_pc_w )
625WRITE8_MEMBER( tandy2k_state::ppi_pc_w )
645626{
646627   /*
647628
r9629r9630
658639
659640    */
660641
661   tandy2k_state *state = device->machine->driver_data<tandy2k_state>();
662
663642   /* input select */
664   state->pb_sel = (data >> 1) & 0x03;
643   m_pb_sel = (data >> 1) & 0x03;
665644
666645   /* interrupt */
667   pic8259_ir3_w(state->pic1, BIT(data, 3));
646   pic8259_ir3_w(m_pic1, BIT(data, 3));
668647
669648   /* printer strobe */
670   centronics_strobe_w(state->centronics, BIT(data, 7));
649   centronics_strobe_w(m_centronics, BIT(data, 7));
671650}
672651
673652static I8255A_INTERFACE( i8255_intf )
674653{
675654   DEVCB_NULL,                     // Port A read
676   DEVCB_HANDLER(ppi_pb_r),         // Port B write
655   DEVCB_DRIVER_MEMBER(tandy2k_state, ppi_pb_r),         // Port B write
677656   DEVCB_NULL,                     // Port C read
678657   DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, centronics_data_w),   /* port A write callback */
679658   DEVCB_NULL,                     // Port B write
680   DEVCB_HANDLER(ppi_pc_w)            // Port C write
659   DEVCB_DRIVER_MEMBER(tandy2k_state, ppi_pc_w)            // Port C write
681660};
682661
683662/* Intel 8259 Interfaces */
r9629r9630
734713
735714/* Intel 8272 Interface */
736715
737static WRITE_LINE_DEVICE_HANDLER( busdmarq0_w )
716WRITE_LINE_MEMBER( tandy2k_state::busdmarq0_w )
738717{
739   dma_request(device->machine, 0, state);
718   dma_request(0, state);
740719}
741720
742721static const struct upd765_interface i8272_intf =
743722{
744723   DEVCB_DEVICE_LINE(I8259A_0_TAG, pic8259_ir4_w),
745   DEVCB_LINE(busdmarq0_w),
724   DEVCB_DRIVER_LINE_MEMBER(tandy2k_state, busdmarq0_w),
746725   NULL,
747726   UPD765_RDY_PIN_CONNECTED,
748727   { FLOPPY_0, FLOPPY_1, NULL, NULL }
r9629r9630
760739
761740/* Machine Initialization */
762741
763static MACHINE_START( tandy2k )
742void tandy2k_state::machine_start()
764743{
765   tandy2k_state *state = machine->driver_data<tandy2k_state>();
766
767   /* find devices */
768   state->uart = machine->device(I8251A_TAG);
769   state->pit = machine->device(I8253_TAG);
770   state->pic0 = machine->device(I8259A_0_TAG);
771   state->pic1 = machine->device(I8259A_1_TAG);
772   state->fdc = machine->device(I8272A_TAG);
773   state->speaker = machine->device(SPEAKER_TAG);
774   state->centronics = machine->device(CENTRONICS_TAG);
775
776744   /* memory banking */
777   address_space *program = cputag_get_address_space(machine, I80186_TAG, ADDRESS_SPACE_PROGRAM);
778   UINT8 *ram = messram_get_ptr(machine->device("messram"));
779   int ram_size = messram_get_size(machine->device("messram"));
745   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
746   UINT8 *ram = messram_get_ptr(m_ram);
747   int ram_size = messram_get_size(m_ram);
780748
781749   memory_install_ram(program, 0x00000, ram_size - 1, 0, 0, ram);
782750
r9629r9630
786754   rom[0x1f17] = 0x90;
787755
788756   /* register for state saving */
789//  state_save_register_global(machine, state->);
757   state_save_register_global(machine, m_dma_mux);
758   state_save_register_global(machine, m_kben);
759   state_save_register_global(machine, m_keylatch);
760   state_save_register_global(machine, m_extclk);
761   state_save_register_global(machine, m_rxrdy);
762   state_save_register_global(machine, m_txrdy);
763   state_save_register_global(machine, m_pb_sel);
764   state_save_register_global(machine, m_vidouts);
765   state_save_register_global(machine, m_clkspd);
766   state_save_register_global(machine, m_clkcnt);
767   state_save_register_global(machine, m_outspkr);
768   state_save_register_global(machine, m_spkrdata);
790769}
791770
792static MACHINE_RESET( tandy2k )
793{
794}
795
796771/* Machine Driver */
797772
798773static MACHINE_CONFIG_START( tandy2k, tandy2k_state )
r9629r9630
803778
804779   MDRV_CPU_ADD(I8048_TAG, I8048, 1000000) // ?
805780   MDRV_CPU_IO_MAP(keyboard_io)
781   MDRV_DEVICE_DISABLE()
806782
807    MDRV_MACHINE_START(tandy2k)
808    MDRV_MACHINE_RESET(tandy2k)
809
810783    /* video hardware */
811784    MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
812785    MDRV_SCREEN_REFRESH_RATE(50)
r9629r9630
817790
818791   MDRV_PALETTE_LENGTH(2)
819792    MDRV_PALETTE_INIT(black_and_white)
820   MDRV_VIDEO_START(tandy2k)
821    MDRV_VIDEO_UPDATE(tandy2k)
793
822794   MDRV_CRT9007_ADD(CRT9007_TAG, XTAL_16MHz*28/16, crt9007_intf)
823795
824796   /* sound hardware */
r9629r9630
843815MACHINE_CONFIG_END
844816
845817static MACHINE_CONFIG_DERIVED( tandy2k_hd, tandy2k )
846
847818    /* basic machine hardware */
848819   MDRV_CPU_MODIFY(I80186_TAG)
849820    MDRV_CPU_IO_MAP(tandy2k_hd_io)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team