Previous 199869 Revisions Next

r32243 Sunday 21st September, 2014 at 03:56:31 UTC by R. Belmont
(MESS) concept: hooked up actual 6551 for keyboard, added beeper, cleaned up driver. [R. Belmont]
[src/mess/drivers]concept.c
[src/mess/includes]concept.h
[src/mess/machine]concept.c

trunk/src/mess/drivers/concept.c
r32242r32243
201201   /* basic machine hardware */
202202   MCFG_CPU_ADD("maincpu", M68000, 8182000)        /* 16.364 MHz / 2 */
203203   MCFG_CPU_PROGRAM_MAP(concept_memmap)
204   MCFG_CPU_VBLANK_INT_DRIVER("screen", concept_state,  concept_interrupt)
205204
206205   MCFG_QUANTUM_TIME(attotime::from_hz(60))
207206
r32242r32243
217216
218217   MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette")
219218
220   /* no sound? */
219   /* sound */
220   MCFG_SPEAKER_STANDARD_MONO("mono")
221   MCFG_SOUND_ADD(SPEAKER_TAG, SPEAKER_SOUND, 0)
222   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
221223
222224   /* rtc */
223225   MCFG_DEVICE_ADD("mm58274c", MM58274C, 0)
r32242r32243
238240   MCFG_MOS6551_XTAL(XTAL_1_8432MHz)
239241   MCFG_DEVICE_ADD(ACIA_1_TAG, MOS6551, 0)
240242   MCFG_MOS6551_XTAL(XTAL_1_8432MHz)
243   MCFG_DEVICE_ADD(KBD_ACIA_TAG, MOS6551, 0)
244   MCFG_MOS6551_XTAL(XTAL_1_8432MHz)
241245
242246   MCFG_CONCEPT_EXP_PORT_ADD("exp1", concept_exp_devices, NULL)
243247   MCFG_CONCEPT_EXP_PORT_ADD("exp2", concept_exp_devices, "fdc")   // Flat cable Hard Disk Controller in Slot 2
trunk/src/mess/machine/concept.c
r32242r32243
4343   /* initialize clock interface */
4444   m_clock_enable = FALSE /*TRUE*/;
4545
46   /* clear keyboard interface state */
47   m_KeyQueueHead = m_KeyQueueLen = 0;
48   memset(m_KeyStateSave, 0, sizeof(m_KeyStateSave));
49
5046   m_exp[0] = machine().device<concept_exp_port_device>("exp1");
5147   m_exp[1] = machine().device<concept_exp_port_device>("exp2");
5248   m_exp[2] = machine().device<concept_exp_port_device>("exp3");
5349   m_exp[3] = machine().device<concept_exp_port_device>("exp4");
5450
55   for (int i = 0; i < 6; i++)
56   {
57      char str[5];
58      sprintf(str, "KEY%i", i);
59      m_key[i] = ioport(str);
60   }
61
6251   save_item(NAME(m_pending_interrupts));
6352   save_item(NAME(m_clock_enable));
6453   save_item(NAME(m_clock_address));
65   save_item(NAME(m_KeyQueue));
66   save_item(NAME(m_KeyQueueHead));
67   save_item(NAME(m_KeyQueueLen));
68   save_item(NAME(m_KeyStateSave));
6954}
7055
7156
r32242r32243
11095      m_maincpu->set_input_line_and_vector(M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
11196}
11297
113inline void concept_state::post_in_KeyQueue(int keycode)
114{
115//   printf("Post %x (%d) in keyqueue\n", keycode, keycode);
116   m_KeyQueue[(m_KeyQueueHead+m_KeyQueueLen) % KeyQueueSize] = keycode;
117   m_KeyQueueLen++;
118}
119
120void concept_state::poll_keyboard()
121{
122   UINT32 keystate;
123   UINT32 key_transitions;
124   int i, j;
125   int keycode;
126
127   for(i = 0; (i < /*4*/3) && (m_KeyQueueLen <= (KeyQueueSize-MaxKeyMessageLen)); i++)
128   {
129      keystate = m_key[2 * i]->read() | (m_key[2 * i + 1]->read() << 16);
130      key_transitions = keystate ^ m_KeyStateSave[i];
131      if(key_transitions)
132      {
133         for(j = 0; (j < 32) && (m_KeyQueueLen <= (KeyQueueSize-MaxKeyMessageLen)); j++)
134         {
135            if((key_transitions >> j) & 1)
136            {
137               keycode = (i << 5) | j;
138
139               if (((keystate >> j) & 1))
140               {
141                  /* key is pressed */
142                  m_KeyStateSave[i] |= (1 << j);
143                  keycode |= 0x80;
144               }
145               else
146                  /* key is released */
147                  m_KeyStateSave[i] &= ~ (1 << j);
148
149               post_in_KeyQueue(keycode);
150               concept_set_interrupt(KEYINT_level, 1);
151            }
152         }
153      }
154   }
155}
156
157INTERRUPT_GEN_MEMBER(concept_state::concept_interrupt)
158{
159   poll_keyboard();
160}
161
16298/*
16399    VIA port A
164100
r32242r32243
212148/*
213149    VIA CB2: used as sound output
214150*/
151
215152WRITE_LINE_MEMBER(concept_state::via_out_cb2)
216153{
217154//   LOG(("via_out_cb2: Sound control written: data=0x%2.2x\n", state));
155   m_speaker->level_w(state);
218156}
219157
220158/*
r32242r32243
273211      {
274212      case 0:
275213         /* NKBP keyboard */
276         switch (offset & 0xf)
277         {
278            int reply;
214         return m_kbdacia->read(space, (offset & 3));
279215
280         case 0:
281            /* data */
282            reply = 0;
283
284            if (m_KeyQueueLen)
285            {
286               reply = m_KeyQueue[m_KeyQueueHead];
287               m_KeyQueueHead = (m_KeyQueueHead + 1) % KeyQueueSize;
288               m_KeyQueueLen--;
289            }
290
291            if (!m_KeyQueueLen)
292               concept_set_interrupt(KEYINT_level, 0);
293
294            return reply;
295
296         case 1:
297            /* always tell transmit is empty */
298            return m_KeyQueueLen ? 0x98 : 0x10;
299         }
300         break;
301
302216      case 1:
303217         /* NSR0 data comm port 0 */
304218         return m_acia0->read(space, (offset & 3));
r32242r32243
392306      {
393307      case 0:
394308         /* NKBP keyboard */
309         m_kbdacia->write(space, (offset & 3), data);
395310         break;
396311
397312      case 1:
trunk/src/mess/includes/concept.h
r32242r32243
1515#include "machine/mos6551.h"
1616#include "machine/mm58274c.h"   /* mm58274 seems to be compatible with mm58174 */
1717#include "machine/concept_exp.h"
18#include "sound/speaker.h"
1819
1920#define ACIA_0_TAG  "acia0"
2021#define ACIA_1_TAG  "acia1"
22#define KBD_ACIA_TAG "kbacia"
23#define SPEAKER_TAG   "spkr"
2124
2225/* keyboard interface */
2326enum
r32242r32243
3538      m_maincpu(*this, "maincpu"),
3639      m_acia0(*this, ACIA_0_TAG),
3740      m_acia1(*this, ACIA_1_TAG),
41      m_kbdacia(*this, KBD_ACIA_TAG),
42      m_speaker(*this, SPEAKER_TAG),
3843      m_mm58274(*this,"mm58274c"),
3944      m_videoram(*this,"videoram") { }
4045
4146   required_device<cpu_device> m_maincpu;
4247   required_device<mos6551_device> m_acia0;
4348   required_device<mos6551_device> m_acia1;
49   required_device<mos6551_device> m_kbdacia;
50   required_device<speaker_sound_device> m_speaker;
4451   required_device<mm58274c_device> m_mm58274;
4552   required_shared_ptr<UINT16> m_videoram;
4653
4754   concept_exp_port_device *m_exp[4];
48   ioport_port *m_key[6];
4955
5056   UINT8 m_pending_interrupts;
5157   bool m_clock_enable;
5258   UINT8 m_clock_address;
53   UINT8 m_KeyQueue[KeyQueueSize];
54   int m_KeyQueueHead;
55   int m_KeyQueueLen;
56   UINT32 m_KeyStateSave[3];
5759   DECLARE_READ16_MEMBER(concept_io_r);
5860   DECLARE_WRITE16_MEMBER(concept_io_w);
5961   virtual void machine_start();
6062   virtual void video_start();
6163   UINT32 screen_update_concept(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
62   INTERRUPT_GEN_MEMBER(concept_interrupt);
6364
6465   DECLARE_READ8_MEMBER(via_in_a);
6566   DECLARE_WRITE8_MEMBER(via_out_a);
r32242r32243
6869   DECLARE_WRITE_LINE_MEMBER(via_out_cb2);
6970   DECLARE_WRITE_LINE_MEMBER(via_irq_func);
7071   void concept_set_interrupt(int level, int state);
71   inline void post_in_KeyQueue(int keycode);
72   void poll_keyboard();
7372};
7473
7574#endif /* CONCEPT_H_ */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team