~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to mess/src/mess/drivers/mekd2.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/******************************************************************************
2
 
    Motorola Evaluation Kit 6800 D2
3
 
    MEK6800D2
4
 
 
5
 
    system driver
6
 
 
7
 
    Juergen Buchmueller <pullmoll@t-online.de>, Jan 2000
8
 
 
9
 
    memory map
10
 
 
11
 
    range       short   description
12
 
    0000-00ff   RAM     256 bytes RAM
13
 
    0100-01ff   RAM     optional 256 bytes RAM
14
 
    6000-63ff   PROM    optional PROM
15
 
    or
16
 
    6000-67ff   ROM     optional ROM
17
 
    8004-8007   PIA     expansion port
18
 
    8008-8009   ACIA    cassette interface
19
 
    8020-8023   PIA     keyboard interface
20
 
    a000-a07f   RAM     128 bytes RAM (JBUG scratch)
21
 
    c000-c3ff   PROM    optional PROM
22
 
    or
23
 
    c000-c7ff   ROM     optional ROM
24
 
    e000-e3ff   ROM     JBUG monitor program
25
 
    e400-ffff   -/-     mirrors of monitor rom
26
 
 
27
 
 
28
 
    TODO
29
 
    - Cassette (it is extremely complex, with approx 10 chips)
30
 
    - Proper artwork
31
 
 
32
 
******************************************************************************/
33
 
#define ADDRESS_MAP_MODERN
34
 
 
35
 
#include "emu.h"
36
 
#include "cpu/m6800/m6800.h"
37
 
#include "machine/6821pia.h"
38
 
#include "machine/6850acia.h"
39
 
#include "imagedev/cassette.h"
40
 
#include "sound/wave.h"
41
 
#include "imagedev/cartslot.h"
42
 
#include "mekd2.lh"
43
 
 
44
 
#define XTAL_MEKD2 1228800
45
 
 
46
 
class mekd2_state : public driver_device
47
 
{
48
 
public:
49
 
        mekd2_state(const machine_config &mconfig, device_type type, const char *tag)
50
 
                : driver_device(mconfig, type, tag),
51
 
        m_maincpu(*this, "maincpu"),
52
 
        m_pia_s(*this, "pia_s"),
53
 
        m_pia_u(*this, "pia_u"),
54
 
        m_acia(*this, "acia")
55
 
        { }
56
 
 
57
 
        required_device<cpu_device> m_maincpu;
58
 
        required_device<device_t> m_pia_s;
59
 
        required_device<device_t> m_pia_u;
60
 
        required_device<device_t> m_acia;
61
 
        DECLARE_READ_LINE_MEMBER( mekd2_key40_r );
62
 
        DECLARE_READ8_MEMBER( mekd2_key_r );
63
 
        DECLARE_WRITE_LINE_MEMBER( mekd2_nmi_w );
64
 
        DECLARE_WRITE8_MEMBER( mekd2_digit_w );
65
 
        DECLARE_WRITE8_MEMBER( mekd2_segment_w );
66
 
        UINT8 m_segment;
67
 
        UINT8 m_digit;
68
 
        UINT8 m_keydata;
69
 
};
70
 
 
71
 
 
72
 
 
73
 
/***********************************************************
74
 
 
75
 
    Address Map
76
 
 
77
 
************************************************************/
78
 
 
79
 
static ADDRESS_MAP_START( mekd2_mem , AS_PROGRAM, 8, mekd2_state)
80
 
        AM_RANGE(0x0000, 0x00ff) AM_RAM // user ram
81
 
        AM_RANGE(0x8004, 0x8007) AM_DEVREADWRITE("pia_u", pia6821_device, read, write)
82
 
        AM_RANGE(0x8008, 0x8008) AM_DEVREADWRITE("acia", acia6850_device, status_read, control_write)
83
 
        AM_RANGE(0x8009, 0x8009) AM_DEVREADWRITE("acia", acia6850_device, data_read, data_write)
84
 
        AM_RANGE(0x8020, 0x8023) AM_DEVREADWRITE("pia_s", pia6821_device, read, write)
85
 
        AM_RANGE(0xa000, 0xa07f) AM_RAM // system ram
86
 
        AM_RANGE(0xe000, 0xe3ff) AM_ROM AM_MIRROR(0x1c00)       /* JBUG ROM */
87
 
ADDRESS_MAP_END
88
 
 
89
 
/***********************************************************
90
 
 
91
 
    Keys
92
 
 
93
 
************************************************************/
94
 
 
95
 
/*
96
 
 
97
 
Enter the 4 digit address then the command key:
98
 
 
99
 
  - M : Examine and Change Memory (example: E000M, then G to skip to next, H to exit)
100
 
  - E : Escape (abort) operation (H key in our emulation)
101
 
  - R : Examine Registers
102
 
  - G : Begin execution at specified address
103
 
  - P : Punch data from memory to magnetic tape
104
 
  - L : Load memory from magnetic tape
105
 
  - N : Trace one instruction
106
 
  - V : Set (and remove) breakpoints
107
 
 
108
 
The keys are laid out as:
109
 
 
110
 
  P L N V
111
 
 
112
 
  7 8 9 A  M
113
 
  4 5 6 B  E
114
 
  1 2 3 C  R
115
 
  0 F E D  G
116
 
 
117
 
 */
118
 
static INPUT_PORTS_START( mekd2 )
119
 
        PORT_START("X0")
120
 
        PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0)
121
 
        PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F)
122
 
        PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E (hex)") PORT_CODE(KEYCODE_E)
123
 
        PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D)
124
 
 
125
 
        PORT_START("X1")
126
 
        PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1)
127
 
        PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2)
128
 
        PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3)
129
 
        PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C)
130
 
 
131
 
        PORT_START("X2")
132
 
        PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4)
133
 
        PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5)
134
 
        PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6)
135
 
        PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B)
136
 
 
137
 
        PORT_START("X3")
138
 
        PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7)
139
 
        PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8)
140
 
        PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9)
141
 
        PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A)
142
 
 
143
 
        PORT_START("X4")
144
 
        PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P)
145
 
        PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L)
146
 
        PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N)
147
 
        PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V)
148
 
 
149
 
        PORT_START("X5")
150
 
        PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M)
151
 
        PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E (escape)") PORT_CODE(KEYCODE_H)
152
 
        PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R)
153
 
        PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G)
154
 
INPUT_PORTS_END
155
 
 
156
 
 
157
 
/***********************************************************
158
 
 
159
 
    Trace hardware (what happens when N is pressed)
160
 
 
161
 
************************************************************/
162
 
 
163
 
static TIMER_CALLBACK( mekd2_trace )
164
 
{
165
 
        cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
166
 
}
167
 
 
168
 
WRITE_LINE_MEMBER( mekd2_state::mekd2_nmi_w )
169
 
{
170
 
        if (state)
171
 
                cputag_set_input_line(machine(), "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
172
 
        else
173
 
                machine().scheduler().timer_set(attotime::from_usec(18), FUNC(mekd2_trace));
174
 
}
175
 
 
176
 
 
177
 
 
178
 
/***********************************************************
179
 
 
180
 
    Keyboard
181
 
 
182
 
************************************************************/
183
 
 
184
 
READ_LINE_MEMBER( mekd2_state::mekd2_key40_r )
185
 
{
186
 
        return BIT(m_keydata, 6);
187
 
}
188
 
 
189
 
READ8_MEMBER( mekd2_state::mekd2_key_r )
190
 
{
191
 
        char kbdrow[4];
192
 
        UINT8 i;
193
 
        m_keydata = 0xff;
194
 
 
195
 
        for (i = 0; i < 6; i++)
196
 
        {
197
 
                if (BIT(m_digit, i))
198
 
                {
199
 
                        sprintf(kbdrow,"X%d",i);
200
 
                        m_keydata &= input_port_read(machine(), kbdrow);
201
 
                }
202
 
        }
203
 
 
204
 
        i = 0x80;
205
 
        if (m_digit < 0x40)
206
 
                i = BIT(m_keydata, 0) ? 0x80 : 0;
207
 
        else
208
 
        if (m_digit < 0x80)
209
 
                i = BIT(m_keydata, 1) ? 0x80 : 0;
210
 
        else
211
 
        if (m_digit < 0xc0)
212
 
                i = BIT(m_keydata, 2) ? 0x80 : 0;
213
 
        else
214
 
                i = BIT(m_keydata, 3) ? 0x80 : 0;
215
 
 
216
 
        return i | m_segment;
217
 
}
218
 
 
219
 
 
220
 
 
221
 
/***********************************************************
222
 
 
223
 
    LED display
224
 
 
225
 
************************************************************/
226
 
 
227
 
WRITE8_MEMBER( mekd2_state::mekd2_segment_w )
228
 
{
229
 
        m_segment = data & 0x7f;
230
 
}
231
 
 
232
 
WRITE8_MEMBER( mekd2_state::mekd2_digit_w )
233
 
{
234
 
        UINT8 i;
235
 
        if (data < 0x3f)
236
 
        {
237
 
                for (i = 0; i < 6; i++)
238
 
                {
239
 
                        if (BIT(data, i))
240
 
                                output_set_digit_value(i, ~m_segment & 0x7f);
241
 
                }
242
 
        }
243
 
        m_digit = data;
244
 
}
245
 
 
246
 
 
247
 
 
248
 
/***********************************************************
249
 
 
250
 
    Interfaces
251
 
 
252
 
************************************************************/
253
 
 
254
 
static const pia6821_interface mekd2_s_mc6821_intf =
255
 
{
256
 
        DEVCB_DRIVER_MEMBER(mekd2_state, mekd2_key_r),          /* port A input */
257
 
        DEVCB_NULL,                                             /* port B input */
258
 
        DEVCB_NULL,                                             /* CA1 input */
259
 
        DEVCB_DRIVER_LINE_MEMBER(mekd2_state, mekd2_key40_r),   /* CB1 input */
260
 
        DEVCB_NULL,                                             /* CA2 input */
261
 
        DEVCB_NULL,                                             /* CB2 input */
262
 
        DEVCB_DRIVER_MEMBER(mekd2_state, mekd2_segment_w),      /* port A output */
263
 
        DEVCB_DRIVER_MEMBER(mekd2_state, mekd2_digit_w),        /* port B output */
264
 
        DEVCB_DRIVER_LINE_MEMBER(mekd2_state, mekd2_nmi_w),     /* CA2 output */
265
 
        DEVCB_NULL,                                             /* CB2 output */
266
 
        DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_NMI),        /* IRQA output */
267
 
        DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_NMI)         /* IRQB output */
268
 
};
269
 
 
270
 
static const pia6821_interface mekd2_u_mc6821_intf =
271
 
{
272
 
        DEVCB_NULL,                                             /* port A input */
273
 
        DEVCB_NULL,                                             /* port B input */
274
 
        DEVCB_NULL,                                             /* CA1 input */
275
 
        DEVCB_NULL,                                             /* CB1 input */
276
 
        DEVCB_NULL,                                             /* CA2 input */
277
 
        DEVCB_NULL,                                             /* CB2 input */
278
 
        DEVCB_NULL,                                             /* port A output */
279
 
        DEVCB_NULL,                                             /* port B output */
280
 
        DEVCB_NULL,                                             /* CA2 output */
281
 
        DEVCB_NULL,                                             /* CB2 output */
282
 
        DEVCB_CPU_INPUT_LINE("maincpu", M6800_IRQ_LINE),        /* IRQA output */
283
 
        DEVCB_CPU_INPUT_LINE("maincpu", M6800_IRQ_LINE)         /* IRQB output */
284
 
};
285
 
 
286
 
static ACIA6850_INTERFACE( mekd2_acia_intf )
287
 
{
288
 
        XTAL_MEKD2 / 256,       //connected to cassette circuit /* tx clock 4800Hz */
289
 
        XTAL_MEKD2 / 256,       //connected to cassette circuit /* rx clock varies, controlled by cassette circuit */
290
 
        DEVCB_NULL,//LINE(cass),//connected to cassette circuit /* in rxd func */
291
 
        DEVCB_NULL,//LINE(cass),//connected to cassette circuit /* out txd func */
292
 
        DEVCB_NULL,                                             /* in cts func */
293
 
        DEVCB_NULL,             //connected to cassette circuit /* out rts func */
294
 
        DEVCB_NULL,                                             /* in dcd func */
295
 
        DEVCB_NULL                                              /* out irq func */
296
 
};
297
 
 
298
 
static DEVICE_IMAGE_LOAD( mekd2_cart )
299
 
{
300
 
        static const char magic[] = "MEK6800D2";
301
 
        char buff[9];
302
 
        UINT16 addr, size;
303
 
        UINT8 ident, *RAM = image.device().machine().region("maincpu")->base();
304
 
 
305
 
        image.fread( buff, sizeof (buff));
306
 
        if (memcmp(buff, magic, sizeof (buff)))
307
 
        {
308
 
                logerror( "mekd2_rom_load: magic '%s' not found\n", magic);
309
 
                return IMAGE_INIT_FAIL;
310
 
        }
311
 
        image.fread( &addr, 2);
312
 
        addr = LITTLE_ENDIANIZE_INT16(addr);
313
 
        image.fread( &size, 2);
314
 
        size = LITTLE_ENDIANIZE_INT16(size);
315
 
        image.fread( &ident, 1);
316
 
        logerror("mekd2_rom_load: $%04X $%04X $%02X\n", addr, size, ident);
317
 
        while (size-- > 0)
318
 
                image.fread( &RAM[addr++], 1);
319
 
 
320
 
        return IMAGE_INIT_PASS;
321
 
}
322
 
 
323
 
/***********************************************************
324
 
 
325
 
    Machine
326
 
 
327
 
************************************************************/
328
 
 
329
 
static MACHINE_CONFIG_START( mekd2, mekd2_state )
330
 
        /* basic machine hardware */
331
 
        MCFG_CPU_ADD("maincpu", M6800, XTAL_MEKD2 / 2)        /* 614.4 kHz */
332
 
        MCFG_CPU_PROGRAM_MAP(mekd2_mem)
333
 
 
334
 
        MCFG_DEFAULT_LAYOUT(layout_mekd2)
335
 
 
336
 
        /* sound hardware */
337
 
        MCFG_SPEAKER_STANDARD_MONO("mono")
338
 
        MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG)
339
 
        MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
340
 
 
341
 
        MCFG_CASSETTE_ADD( CASSETTE_TAG, default_cassette_interface )
342
 
 
343
 
        /* Cartslot ?? does not come with one.. */
344
 
        MCFG_CARTSLOT_ADD("cart")
345
 
        MCFG_CARTSLOT_EXTENSION_LIST("d2")
346
 
        MCFG_CARTSLOT_NOT_MANDATORY
347
 
        MCFG_CARTSLOT_LOAD(mekd2_cart)
348
 
 
349
 
        /* Devices */
350
 
        MCFG_PIA6821_ADD("pia_s", mekd2_s_mc6821_intf)
351
 
        MCFG_PIA6821_ADD("pia_u", mekd2_u_mc6821_intf)
352
 
        MCFG_ACIA6850_ADD("acia", mekd2_acia_intf)
353
 
MACHINE_CONFIG_END
354
 
 
355
 
/***********************************************************
356
 
 
357
 
    ROMS
358
 
 
359
 
************************************************************/
360
 
 
361
 
ROM_START(mekd2)
362
 
        ROM_REGION(0x10000,"maincpu",0)
363
 
        ROM_LOAD("jbug.rom", 0xe000, 0x0400, CRC(5ed08792) SHA1(b06e74652a4c4e67c4a12ddc191ffb8c07f3332e) )
364
 
ROM_END
365
 
 
366
 
/***************************************************************************
367
 
 
368
 
  Game driver(s)
369
 
 
370
 
***************************************************************************/
371
 
 
372
 
/*    YEAR  NAME    PARENT  COMPAT  MACHINE   INPUT     INIT    COMPANY     FULLNAME */
373
 
CONS( 1977, mekd2,      0,      0,  mekd2,    mekd2,    0,      "Motorola", "MEK6800D2" , GAME_NOT_WORKING )