Previous 15994 Revisions Next

r13981 Wednesday 11th January, 2012 at 17:52:44 UTC by Robbbert
i8279 improvements. Hooked up to sdk85, sdk86, selz80.
[src/mess/drivers]sdk85.c sdk86.c selz80.c
[src/mess/layout]sdk86.lay selz80.lay
[src/mess/machine]i8279.c

src/mess/machine/i8279.c
r13980r13981
112112   m_read_flag = 0;
113113   m_scanner = 0;
114114   m_ctrl_key = 1;
115   m_key_down = 0xff;
115   m_key_down = 0xffff;
116116
117117   // from here is confirmed
118118   m_ctrls[0] = 8;
r13980r13981
123123
124124void i8279_device::timer_adjust()
125125{
126   UINT8 divider = (m_ctrls[1]) ? m_ctrls[1] : 1;
127   m_clock = clock() / divider;
126// Real device runs at about 100kHz internally, clock divider is chosen so that
127// this is the case. We do not need such speed, 200Hz is enough.
128
129   //UINT8 divider = (m_ctrls[1]) ? m_ctrls[1] : 1;
130   //m_clock = clock() / divider;
131
132   m_clock = 200;
128133   m_timer->adjust(attotime::from_hz(m_clock), 0, attotime::from_hz(m_clock));
129134}
130135
r13980r13981
179184
180185void i8279_device::new_fifo(UINT8 data)
181186{
182   // see if key still down from last time
183   UINT16 key_down = (m_scanner << 8) | data;
184   if (key_down == m_key_down)
185      return;
186   m_key_down = key_down;
187
188187   // see if already overrun
189188   if (BIT(m_status, 5))
190189      return;
r13980r13981
224223   // bit 3 - number of digits to display
225224   // bit 4 - left or right entry
226225
227   UINT8 scanner_mask = 15; //BIT(m_ctrls[0], 0) ? 15 : BIT(m_ctrls[0], 3) ? 15 : 7;
226   UINT8 scanner_mask = BIT(m_ctrls[0], 0) ? 15 : BIT(m_ctrls[0], 3) ? 15 : 7;
228227   bool decoded = BIT(m_ctrls[0], 0);
229228   UINT8 kbd_type = (m_ctrls[0] & 6) >> 1;
230229   bool shift_key = 1;
r13980r13981
254253   if ( !m_in_rl_func.isnull() )
255254   {
256255      UINT8 rl = m_in_rl_func(0);
256
257      // see if key still down from last time
258      UINT16 key_down = (m_scanner << 8) | rl;
259      if (key_down == m_key_down)
260         rl = 0xff;
261      else
262      if ((rl == 0xff) && (m_scanner == m_key_down >> 8))
263         m_key_down = 0xffff;
264
265      // now process new key
257266      if (rl < 0xff)
258267      {
268         m_key_down = key_down;
259269         switch (kbd_type)
260270         {
261271            case 0:
r13980r13981
270280               break;
271281         }
272282      }
273      else
274         m_key_down = 0xff;
275283   }
276284
277285   // Increment scanline
r13980r13981
399407
400408void i8279_device::data_w( UINT8 data )
401409{//printf("Data: %X ",data);
402   if (BIT(m_ctrls[0], 4))
410   if (BIT(m_ctrls[0], 4) & m_autoinc)
403411   {
412   // right-entry autoincrement not implemented yet
404413   }
405414   else
406415   {
src/mess/layout/sdk86.lay
r13980r13981
2121
2222      <!-- Background -->
2323      <backdrop element="background">
24         <bounds left="0" top="0" right="406" bottom="69" />
24         <bounds left="0" top="0" right="362" bottom="69" />
2525      </backdrop>
2626
2727      <!-- LEDs -->
src/mess/layout/selz80.lay
r13980r13981
22<mamelayout version="2">
33   <element name="digit" defstate="0">
44      <led7seg>
5         <color red="0.75" green="0.0" blue="0.0" />
5         <color red="1.0" green="0.0" blue="0.0" />
66      </led7seg>
77   </element>
88   <element name="background">
src/mess/drivers/selz80.c
r13980r13981
99Another trainer that looks almost identical has been seen. It is called
1010the DAG-Z80. Bios dump is needed.
1111
12It seems that the keyboard controller has certain similarities to the 8279.
13Therefore copied a bunch of code from sdk86 - and it worked.
14
1512Test sequence: Press -, enter an address, press = to show contents, press
1613               up/down-arrow to cycle through addresses.
1714
r13980r13981
2623
2724#include "emu.h"
2825#include "cpu/z80/z80.h"
26#include "machine/i8279.h"
2927#include "selz80.lh"
3028
3129#define MACHINE_RESET_MEMBER(name) void name::machine_reset()
r13980r13981
3634   selz80_state(const machine_config &mconfig, device_type type, const char *tag)
3735      : driver_device(mconfig, type, tag) { }
3836
39   DECLARE_READ8_MEMBER(selz80_00_r);
40   DECLARE_READ8_MEMBER(selz80_01_r);
41   DECLARE_WRITE8_MEMBER(selz80_01_w);
42   DECLARE_WRITE8_MEMBER(selz80_00_w);
37   DECLARE_WRITE8_MEMBER(scanlines_w);
38   DECLARE_WRITE8_MEMBER(digit_w);
39   DECLARE_READ8_MEMBER(kbd_r);
4340   UINT8 m_digit;
44   UINT8 m_segment;
45   UINT8 m_kbd;
46   UINT8 m_keytemp; // to see when key gets released
4741   virtual void machine_reset();
4842};
4943
50
51
52READ8_MEMBER( selz80_state::selz80_00_r )
53{
54      UINT8 ret = m_kbd;
55      m_kbd = 0xff;
56      return ret;
57}
58
59READ8_MEMBER( selz80_state::selz80_01_r )
60{
61   return (m_kbd==0xff) ? 0 : 7;
62}
63
64WRITE8_MEMBER( selz80_state::selz80_01_w )
65{
66   if ((data & 0xc0)==0x80)
67   {
68      m_digit = data & 7;
69      output_set_digit_value(m_digit, m_segment);
70   }
71}
72
73WRITE8_MEMBER( selz80_state::selz80_00_w )
74{
75   m_segment = BITSWAP8(data, 3, 2, 1, 0, 7, 6, 5, 4);
76   output_set_digit_value(m_digit, m_segment);
77}
78
7944static ADDRESS_MAP_START(selz80_mem, AS_PROGRAM, 8, selz80_state)
8045   ADDRESS_MAP_UNMAP_HIGH
8146   AM_RANGE(0x0000, 0x0fff) AM_ROM
r13980r13981
8651static ADDRESS_MAP_START(selz80_io, AS_IO, 8, selz80_state)
8752   ADDRESS_MAP_UNMAP_HIGH
8853   ADDRESS_MAP_GLOBAL_MASK(0xff)
89   AM_RANGE(0x00, 0x00) AM_READWRITE(selz80_00_r,selz80_00_w)
90   AM_RANGE(0x01, 0x01) AM_READWRITE(selz80_01_r,selz80_01_w)
54   AM_RANGE(0x00, 0x00) AM_DEVREADWRITE("i8279", i8279_device, i8279_data_r, i8279_data_w )
55   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE("i8279", i8279_device, i8279_status_r, i8279_ctrl_w)
9156ADDRESS_MAP_END
9257
9358/* Input ports */
r13980r13981
139104   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("RG") PORT_CODE(KEYCODE_L)
140105INPUT_PORTS_END
141106
142static TIMER_DEVICE_CALLBACK( selz80_keyscan )
107MACHINE_RESET_MEMBER( selz80_state )
143108{
144   selz80_state *state = timer.machine().driver_data<selz80_state>();
145   UINT8 keyscan, keytemp = 0xff,i;
146   keyscan = input_port_read(timer.machine(), "X0");
147   if (keyscan < 0xff)
148   {
149      for (i = 0; i < 8; i++)
150      {
151         if (!BIT(keyscan, i))
152         {
153            keytemp = i;
154            i = 9;
155         }
156      }
157   }
158   else
159   {
160      keyscan = input_port_read(timer.machine(), "X1");
161      if (keyscan < 0xff)
162      {
163         for (i = 0; i < 8; i++)
164         {
165            if (!BIT(keyscan, i))
166            {
167               keytemp = i+8;
168               i = 9;
169            }
170         }
171      }
172      else
173      {
174         keyscan = input_port_read(timer.machine(), "X2");
175         if (keyscan < 0xff)
176         {
177            for (i = 0; i < 8; i++)
178            {
179               if (!BIT(keyscan, i))
180               {
181                  keytemp = i+16;
182                  i = 9;
183               }
184            }
185         }
186         else
187         {
188            keyscan = input_port_read(timer.machine(), "X3");
189            if (keyscan < 0xff)
190            {
191               for (i = 0; i < 8; i++)
192               {
193                  if (!BIT(keyscan, i))
194                  {
195                     keytemp = i+24;
196                     i = 9;
197                  }
198               }
199            }
200         }
201      }
202   }
109}
203110
204   if ((state->m_kbd == 0xff) && (keytemp < 0xff) && (keytemp != state->m_keytemp))
111WRITE8_MEMBER( selz80_state::scanlines_w )
112{
113   m_digit = data;
114}
115
116WRITE8_MEMBER( selz80_state::digit_w )
117{
118   output_set_digit_value(m_digit, BITSWAP8(data, 3, 2, 1, 0, 7, 6, 5, 4));
119}
120
121READ8_MEMBER( selz80_state::kbd_r )
122{
123   UINT8 data = 0xff;
124
125   if (m_digit < 4)
205126   {
206      state->m_kbd = keytemp;
207      state->m_keytemp = keytemp;
127      char kbdrow[6];
128      sprintf(kbdrow,"X%X",m_digit);
129      data = input_port_read(machine(), kbdrow);
208130   }
209   else
210   if (keytemp==0xff)
211   {
212      state->m_keytemp = 0xfe;
213   }
131   return data;
214132}
215133
216MACHINE_RESET_MEMBER( selz80_state )
134static I8279_INTERFACE( selz80_intf )
217135{
218}
136   DEVCB_NULL,   // irq
137   DEVCB_DRIVER_MEMBER(selz80_state, scanlines_w),   // scan SL lines
138   DEVCB_DRIVER_MEMBER(selz80_state, digit_w),      // display A&B
139   DEVCB_NULL,                  // BD
140   DEVCB_DRIVER_MEMBER(selz80_state, kbd_r),      // kbd RL lines
141   DEVCB_LINE_VCC,                  // Shift key
142   DEVCB_LINE_VCC
143};
219144
220145static MACHINE_CONFIG_START( selz80, selz80_state )
221146   /* basic machine hardware */
r13980r13981
226151   /* video hardware */
227152   MCFG_DEFAULT_LAYOUT(layout_selz80)
228153
229   MCFG_TIMER_ADD_PERIODIC("keyscan", selz80_keyscan, attotime::from_hz(15))
154   /* Devices */
155   MCFG_I8279_ADD("i8279", 3500, selz80_intf)
230156MACHINE_CONFIG_END
231157
232158/* ROM definition */
src/mess/drivers/sdk85.c
r13980r13981
1717
1818ToDo:
1919- Artwork
20- Proper emulation of the 8279 chip (there's only just enough to get this
21  driver to work atm)
2220
2321****************************************************************************/
2422#define ADDRESS_MAP_MODERN
2523
2624#include "emu.h"
2725#include "cpu/i8085/i8085.h"
26#include "machine/i8279.h"
2827#include "sdk85.lh"
2928
3029#define MACHINE_RESET_MEMBER(name) void name::machine_reset()
r13980r13981
3534   sdk85_state(const machine_config &mconfig, device_type type, const char *tag)
3635      : driver_device(mconfig, type, tag) { }
3736
38   DECLARE_READ8_MEMBER(keyboard_r);
39   DECLARE_READ8_MEMBER(status_r);
40   DECLARE_WRITE8_MEMBER(command_w);
41   DECLARE_WRITE8_MEMBER(data_w);
42   UINT8 m_digit; // next digit to display
43   UINT8 m_kbd; // keyscan code being returned
44   UINT8 m_keytemp; // to see when key gets released
45   bool m_kbd_ready; // get ready to return keyscan code
37   DECLARE_WRITE8_MEMBER(scanlines_w);
38   DECLARE_WRITE8_MEMBER(digit_w);
39   DECLARE_READ8_MEMBER(kbd_r);
40   UINT8 m_digit;
4641   virtual void machine_reset();
4742};
4843
49READ8_MEMBER( sdk85_state::keyboard_r )
50{
51   if (m_kbd_ready)
52   {
53      UINT8 ret = m_kbd;
54      m_kbd_ready = FALSE;
55      m_kbd = 0xff;
56      return ret;
57   }
58   else
59      return 0;
60}
61
62READ8_MEMBER( sdk85_state::status_r )
63{
64   return 0;
65}
66
67WRITE8_MEMBER( sdk85_state::command_w )
68{
69   if ((data & 0x90)==0x90)
70      m_digit = data & 7;
71   else
72   if (data==0x40)
73      m_kbd_ready = TRUE;
74}
75
76WRITE8_MEMBER( sdk85_state::data_w )
77{
78   if (m_digit < 6)
79   {
80      output_set_digit_value(m_digit, BITSWAP8(data, 3, 2, 1, 0, 7, 6, 5, 4)^0xff);
81      m_digit++;
82   }
83   else
84      m_digit = 15;
85}
86
87
8844static ADDRESS_MAP_START(sdk85_mem, AS_PROGRAM, 8, sdk85_state)
8945   ADDRESS_MAP_UNMAP_HIGH
9046   AM_RANGE(0x0000, 0x07ff) AM_ROM // Monitor rom (A14)
9147   AM_RANGE(0x0800, 0x0fff) AM_ROM // Expansion rom (A15)
92   AM_RANGE(0x1800, 0x1800) AM_READWRITE(keyboard_r,data_w)
93   AM_RANGE(0x1900, 0x1900) AM_READWRITE(status_r,command_w)
48   AM_RANGE(0x1800, 0x1800) AM_DEVREADWRITE("i8279", i8279_device, i8279_data_r, i8279_data_w )
49   AM_RANGE(0x1900, 0x1900) AM_DEVREADWRITE("i8279", i8279_device, i8279_status_r, i8279_ctrl_w)
9450   //AM_RANGE(0x1800, 0x1fff) AM_RAM // i8279 (A13)
9551   AM_RANGE(0x2000, 0x27ff) AM_RAM // i8155 (A16)
9652   AM_RANGE(0x2800, 0x2fff) AM_RAM // i8155 (A17)
r13980r13981
12480
12581   PORT_START("X2")
12682   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("EXEC") PORT_CODE(KEYCODE_Q)
127   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NEXT") PORT_CODE(KEYCODE_W)
83   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("NEXT") PORT_CODE(KEYCODE_UP)
12884   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("GO") PORT_CODE(KEYCODE_R)
12985   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SUBST") PORT_CODE(KEYCODE_T)
13086   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("EXAM") PORT_CODE(KEYCODE_Y)
r13980r13981
13591
13692MACHINE_RESET_MEMBER( sdk85_state )
13793{
138   m_digit = 15;
139   m_kbd_ready = FALSE;
140   m_kbd = 0xff;
141   m_keytemp = 0xfe;
14294}
14395
144// This is an internal function of the 8279 chip
145static TIMER_DEVICE_CALLBACK( sdk85_keyscan )
96WRITE8_MEMBER( sdk85_state::scanlines_w )
14697{
147   sdk85_state *state = timer.machine().driver_data<sdk85_state>();
148   UINT8 keyscan, keytemp = 0xff,i;
149   keyscan = input_port_read(timer.machine(), "X0");
150   if (keyscan < 0xff)
151   {
152      for (i = 0; i < 8; i++)
153      {
154         if (!BIT(keyscan, i))
155         {
156            keytemp = i;
157            i = 9;
158         }
159      }
160   }
161   else
162   {
163      keyscan = input_port_read(timer.machine(), "X1");
164      if (keyscan < 0xff)
165      {
166         for (i = 0; i < 8; i++)
167         {
168            if (!BIT(keyscan, i))
169            {
170               keytemp = i+8;
171               i = 9;
172            }
173         }
174      }
175      else
176      {
177         keyscan = input_port_read(timer.machine(), "X2");
178         if (keyscan < 0xff)
179         {
180            for (i = 0; i < 6; i++)
181            {
182               if (!BIT(keyscan, i))
183               {
184                  keytemp = i+16;
185                  i = 9;
186               }
187            }
188         }
189      }
190   }
98   m_digit = data;
99}
191100
192   device_t *cpu = timer.machine().device( "maincpu" );
101WRITE8_MEMBER( sdk85_state::digit_w )
102{
103   if (m_digit < 6)
104      output_set_digit_value(m_digit, BITSWAP8(data, 3, 2, 1, 0, 7, 6, 5, 4)^0xff);
105}
193106
194   if ((state->m_kbd == 0xff) && (keytemp < 0xff) && (keytemp != state->m_keytemp))
107READ8_MEMBER( sdk85_state::kbd_r )
108{
109   UINT8 data = 0xff;
110
111   if (m_digit < 3)
195112   {
196      state->m_kbd = keytemp;
197      state->m_keytemp = keytemp;
198      device_set_input_line(cpu, I8085_RST55_LINE, HOLD_LINE);
113      char kbdrow[6];
114      sprintf(kbdrow,"X%X",m_digit);
115      data = input_port_read(machine(), kbdrow);
199116   }
200   else
201   if (keytemp==0xff)
202   {
203      state->m_keytemp = 0xfe;
204      device_set_input_line(cpu, I8085_RST55_LINE, CLEAR_LINE);
205   }
117   return data;
206118}
207119
120static I8279_INTERFACE( sdk85_intf )
121{
122   DEVCB_CPU_INPUT_LINE("maincpu", I8085_RST55_LINE),   // irq
123   DEVCB_DRIVER_MEMBER(sdk85_state, scanlines_w),   // scan SL lines
124   DEVCB_DRIVER_MEMBER(sdk85_state, digit_w),      // display A&B
125   DEVCB_NULL,                  // BD
126   DEVCB_DRIVER_MEMBER(sdk85_state, kbd_r),      // kbd RL lines
127   DEVCB_LINE_VCC,                  // Shift key
128   DEVCB_LINE_VCC
129};
208130
209131static MACHINE_CONFIG_START( sdk85, sdk85_state )
210132   /* basic machine hardware */
r13980r13981
215137   /* video hardware */
216138   MCFG_DEFAULT_LAYOUT(layout_sdk85)
217139
218   MCFG_TIMER_ADD_PERIODIC("keyscan", sdk85_keyscan, attotime::from_hz(15))
140   /* Devices */
141   MCFG_I8279_ADD("i8279", 3500, sdk85_intf)
219142MACHINE_CONFIG_END
220143
221144/* ROM definition */
src/mess/drivers/sdk86.c
r13980r13981
88
99    TODO:
1010    Add 8251A for serial
11    Add 8279 for keypad reading and led display handling
1211    Add optional 2x 8255A
1312
1413
r13980r13981
2120
2221ToDo:
2322- Artwork
24- Proper emulation of the 8279 chip (there's only just enough to get this
25  driver to work atm)
2623- Add INTR and RESET keys
2724- Add terminal interface and option to enable it.
2825
r13980r13981
3128
3229#include "emu.h"
3330#include "cpu/i86/i86.h"
31#include "machine/i8279.h"
3432#include "sdk86.lh"
3533
3634#define MACHINE_RESET_MEMBER(name) void name::machine_reset()
r13980r13981
3937{
4038public:
4139   sdk86_state(const machine_config &mconfig, device_type type, const char *tag)
42      : driver_device(mconfig, type, tag) { }
40      : driver_device(mconfig, type, tag),
41   m_i8279(*this, "i8279") { }
4342
43   required_device<i8279_device> m_i8279;
4444   DECLARE_READ16_MEMBER(keyboard_r);
4545   DECLARE_READ16_MEMBER(status_r);
4646   DECLARE_WRITE16_MEMBER(command_w);
4747   DECLARE_WRITE16_MEMBER(data_w);
48   DECLARE_WRITE8_MEMBER(scanlines_w);
49   DECLARE_WRITE8_MEMBER(digit_w);
50   DECLARE_READ8_MEMBER(kbd_r);
4851   UINT8 m_digit; // next digit to display
49   UINT8 m_kbd; // keyscan code being returned
50   UINT8 m_keytemp; // to see when key gets released
51   bool m_kbd_ready; // get ready to return keyscan code
5252   virtual void machine_reset();
5353};
5454
5555READ16_MEMBER( sdk86_state::keyboard_r )
5656{
57   if (m_kbd_ready)
58   {
59      UINT16 ret = m_kbd;
60      m_kbd_ready = FALSE;
61      m_kbd = 0xff;
62      return ret;
63   }
64   else
65      return 0;
57   return m_i8279->i8279_data_r(space, offset);
6658}
6759
6860READ16_MEMBER( sdk86_state::status_r )
6961{
70   return (m_kbd==0xff) ? 0 : 7;
62   return m_i8279->i8279_status_r(space, offset);
7163}
7264
7365WRITE16_MEMBER( sdk86_state::command_w )
7466{
75   if ((data & 0x90)==0x90)
76      m_digit = data & 7;
77   else
78   if (data==0x40)
79      m_kbd_ready = TRUE;
67   m_i8279->i8279_ctrl_w(space, offset, data);
8068}
8169
8270WRITE16_MEMBER( sdk86_state::data_w )
8371{
84   if (m_digit < 8)
85   {
86      output_set_digit_value(m_digit, data);
87      m_digit++;
88   }
89   else
90      m_digit = 15;
72   m_i8279->i8279_data_w(space, offset, data);
9173}
9274
9375static ADDRESS_MAP_START(sdk86_mem, AS_PROGRAM, 16, sdk86_state)
r13980r13981
131113   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) PORT_CHAR('F')
132114
133115   PORT_START("X2")
134   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_Q)
135   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_W)
136   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_R)
137   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("+") PORT_CODE(KEYCODE_T)
138   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(":") PORT_CODE(KEYCODE_Y)
139   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("REG") PORT_CODE(KEYCODE_U)
116   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) PORT_CODE(KEYCODE_X)
117   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) PORT_CODE(KEYCODE_UP)
118   PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS)
119   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("+") PORT_CODE(KEYCODE_EQUALS)
120   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(":") PORT_CODE(KEYCODE_COLON)
121   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("REG") PORT_CODE(KEYCODE_R)
140122   PORT_BIT(0xC0, IP_ACTIVE_LOW, IPT_UNUSED)
141123INPUT_PORTS_END
142124
143125
144126MACHINE_RESET_MEMBER( sdk86_state )
145127{
146   m_digit = 15;
147   m_kbd_ready = FALSE;
148   m_kbd = 0xff;
149   m_keytemp = 0xfe;
150128}
151129
152// This is an internal function of the 8279 chip
153static TIMER_DEVICE_CALLBACK( sdk86_keyscan )
130
131WRITE8_MEMBER( sdk86_state::scanlines_w )
154132{
155   sdk86_state *state = timer.machine().driver_data<sdk86_state>();
156   UINT8 keyscan, keytemp = 0xff,i;
157   keyscan = input_port_read(timer.machine(), "X0");
158   if (keyscan < 0xff)
159   {
160      for (i = 0; i < 8; i++)
161      {
162         if (!BIT(keyscan, i))
163         {
164            keytemp = i;
165            i = 9;
166         }
167      }
168   }
169   else
170   {
171      keyscan = input_port_read(timer.machine(), "X1");
172      if (keyscan < 0xff)
173      {
174         for (i = 0; i < 8; i++)
175         {
176            if (!BIT(keyscan, i))
177            {
178               keytemp = i+8;
179               i = 9;
180            }
181         }
182      }
183      else
184      {
185         keyscan = input_port_read(timer.machine(), "X2");
186         if (keyscan < 0xff)
187         {
188            for (i = 0; i < 6; i++)
189            {
190               if (!BIT(keyscan, i))
191               {
192                  keytemp = i+16;
193                  i = 9;
194               }
195            }
196         }
197      }
198   }
133   m_digit = data;
134}
199135
200   if ((state->m_kbd == 0xff) && (keytemp < 0xff) && (keytemp != state->m_keytemp))
136WRITE8_MEMBER( sdk86_state::digit_w )
137{
138   if (m_digit < 8)
139      output_set_digit_value(m_digit, data);
140}
141
142READ8_MEMBER( sdk86_state::kbd_r )
143{
144   UINT8 data = 0xff;
145
146   if (m_digit < 3)
201147   {
202      state->m_kbd = keytemp;
203      state->m_keytemp = keytemp;
148      char kbdrow[6];
149      sprintf(kbdrow,"X%X",m_digit);
150      data = input_port_read(machine(), kbdrow);
204151   }
205   else
206   if (keytemp==0xff)
207   {
208      state->m_keytemp = 0xfe;
209   }
152   return data;
210153}
211154
155static I8279_INTERFACE( sdk86_intf )
156{
157   DEVCB_NULL,   // irq
158   DEVCB_DRIVER_MEMBER(sdk86_state, scanlines_w),   // scan SL lines
159   DEVCB_DRIVER_MEMBER(sdk86_state, digit_w),      // display A&B
160   DEVCB_NULL,                  // BD
161   DEVCB_DRIVER_MEMBER(sdk86_state, kbd_r),      // kbd RL lines
162   DEVCB_LINE_GND,                  // Shift key
163   DEVCB_LINE_GND
164};
165
212166static MACHINE_CONFIG_START( sdk86, sdk86_state )
213167   /* basic machine hardware */
214168   MCFG_CPU_ADD("maincpu", I8086, XTAL_14_7456MHz/3) /* divided down by i8284 clock generator; jumper selection allows it to be slowed to 2.5MHz, hence changing divider from 3 to 6 */
r13980r13981
219173   /* video hardware */
220174   MCFG_DEFAULT_LAYOUT(layout_sdk86)
221175
222   MCFG_TIMER_ADD_PERIODIC("keyscan", sdk86_keyscan, attotime::from_hz(15))
176   /* Devices */
177   MCFG_I8279_ADD("i8279", 3500, sdk86_intf)
223178MACHINE_CONFIG_END
224179
225180/* ROM definition */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team