Previous 15994 Revisions Next

r4181 Thursday 22nd January, 2009 at 11:33:57 UTC by Dirk Best
[MZ700] Use the TTL74145 device to decode the keyboard rows
[src/mess/drivers]mz700.c
[src/mess/machine]74145.c mz700.c

src/mess/machine/74145.c
r4180r4181
5454struct _ttl74145_t
5555{
5656   /* decoded number */
57   UINT16 number;
57   int number;
5858};
5959
6060
r4180r4181
7676   ttl74145_t *ttl74145 = get_safe_token(device);
7777
7878   /* decode number */
79   UINT16 new_number = bcd_2_dec(data & 0x0f);
79   int new_number = bcd_2_dec(data & 0x0f);
8080
8181   /* call output callbacks if the number changed */
8282   if (new_number != ttl74145->number)
r4180r4181
107107{
108108   ttl74145_t *ttl74145 = get_safe_token(device);
109109
110   return ttl74145->number;
110   return (1 << ttl74145->number) & 0x3ff;
111111}
112112
113113
src/mess/machine/mz700.c
r4180r4181
1717#include "machine/pit8253.h"
1818#include "machine/8255ppi.h"
1919#include "sound/speaker.h"
20#include "machine/74145.h"
2021
2122#include "includes/mz700.h"
2223
r4180r4181
8384}
8485
8586
86
8787DRIVER_INIT( mz700 )
8888{
8989   videoram_size = 0x5000;
r4180r4181
132132
133133/************************ PIO ************************************************/
134134
135static READ8_DEVICE_HANDLER ( pio_port_a_r )
135static READ8_DEVICE_HANDLER( pio_port_a_r )
136136{
137137   UINT8 data = pio_port_a_output;
138138   LOG(2,"mz700_pio_port_a_r",("%02X\n", data),device->machine);
139139   return data;
140140}
141141
142/* read keyboard row - indexed by a demux LS145 which is connected to PA0-3 */
143static READ8_DEVICE_HANDLER ( pio_port_b_r )
142
143static READ8_DEVICE_HANDLER( pio_port_b_r )
144144{
145   UINT8 demux_LS145, data = 0xff;
146   static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", "ROW5",
147                              "ROW6", "ROW7", "ROW8", "ROW9", "ROW10" };
145   const device_config *ls145 = devtag_get_device(device->machine, TTL74145, "ls145");
146   int key_line = ttl74145_r(ls145, 0, 0);
147   UINT8 data = 0xff;
148148
149    demux_LS145 = pio_port_a_output & 15;
150    data = input_port_read(device->machine, keynames[demux_LS145]);
151   LOG(2,"mz700_pio_port_b_r",("%02X\n", data),device->machine);
149   if (BIT(key_line, 0)) data = input_port_read(device->machine, "ROW0");
150   if (BIT(key_line, 1)) data = input_port_read(device->machine, "ROW1");
151   if (BIT(key_line, 2)) data = input_port_read(device->machine, "ROW2");
152   if (BIT(key_line, 3)) data = input_port_read(device->machine, "ROW3");
153   if (BIT(key_line, 4)) data = input_port_read(device->machine, "ROW4");
154   if (BIT(key_line, 5)) data = input_port_read(device->machine, "ROW5");
155   if (BIT(key_line, 6)) data = input_port_read(device->machine, "ROW6");
156   if (BIT(key_line, 7)) data = input_port_read(device->machine, "ROW7");
157   if (BIT(key_line, 8)) data = input_port_read(device->machine, "ROW8");
158   if (BIT(key_line, 9)) data = input_port_read(device->machine, "ROW9");
152159
153160    return data;
154161}
r4180r4181
183190
184191static WRITE8_DEVICE_HANDLER (pio_port_a_w )
185192{
193   const device_config *ls145 = devtag_get_device(device->machine, TTL74145, "ls145");
194
186195   LOG(2,"mz700_pio_port_a_w",("%02X\n", data),device->machine);
196
197   /* the ls145 is connected to pa0-pa3 */
198   ttl74145_w(ls145, 0, data & 0x07);
199
187200   pio_port_a_output = data;
188201}
189202
r4180r4181
788801{
789802   UINT8 *mem = memory_region(machine, "main");
790803   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
791   
804
792805   videoram_size = 0x5000;
793806   videoram = auto_malloc(videoram_size);
794807   colorram = auto_malloc(0x800);
src/mess/drivers/mz700.c
r4180r4181
7171#include "machine/8255ppi.h"
7272#include "includes/mz700.h"
7373#include "machine/pit8253.h"
74#include "machine/74145.h"
7475
7576/* Devices */
7677#include "devices/cassette.h"
r4180r4181
130131
131132Small note about natural keyboard support: currently,
132133- "Alpha" is mapped to 'F6'
133- "Graph" is mapped to 'F7'                     
134- "Graph" is mapped to 'F7'
134135- "Break" is mapped to 'F8'                      */
135136
136137static INPUT_PORTS_START( mz700 )
r4180r4181
230231    PORT_BIT(0x40, 0x40, IPT_KEYBOARD) PORT_CODE(KEYCODE_F2)          PORT_CHAR(UCHAR_MAMEKEY(F2))
231232    PORT_BIT(0x80, 0x80, IPT_KEYBOARD) PORT_CODE(KEYCODE_F1)          PORT_CHAR(UCHAR_MAMEKEY(F1))
232233
233   /* 2005-08 FP: why is this here? According to the Service Manual ROW9 is the last one */
234   PORT_START("ROW10") /* KEY ROW 10 */
235
236234   PORT_START("JOY")
237235   PORT_BIT(0x01, 0x00, IPT_UNUSED)
238236   PORT_BIT(0x02, 0x00, IPT_JOYSTICK_UP)      PORT_8WAY
r4180r4181
273271
274272   MDRV_MACHINE_RESET( mz700 )
275273
276   MDRV_PIT8253_ADD( "pit8253", mz700_pit8253_config )
277
278   MDRV_PPI8255_ADD( "ppi8255", mz700_ppi8255_interface )
279
280274   /* video hardware - include overscan */
281275   MDRV_SCREEN_ADD("main", RASTER)
282276   MDRV_SCREEN_REFRESH_RATE(50)
r4180r4181
287281
288282   MDRV_GFXDECODE(mz700)
289283   MDRV_PALETTE_LENGTH(256*2)
284   MDRV_PALETTE_INIT(mz700)
290285
291   MDRV_PALETTE_INIT(mz700)
292286   MDRV_VIDEO_UPDATE(mz700)
293287
288   /* sound hardware */
294289   MDRV_SPEAKER_STANDARD_MONO("mono")
295290   MDRV_SOUND_ADD("cassette", WAVE, 0)
296291   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
297292   MDRV_SOUND_ADD("speaker", SPEAKER, 0)
298293   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
299294
295   /* devices */
296   MDRV_PIT8253_ADD("pit8253", mz700_pit8253_config)
297   MDRV_PPI8255_ADD("ppi8255", mz700_ppi8255_interface)
298   MDRV_TTL74145_ADD("ls145")
299
300300   MDRV_CASSETTE_ADD( "cassette", mz700_cassette_config )
301301MACHINE_DRIVER_END
302302

Previous 15994 Revisions Next


© 1998-2018 The MESS Team