Previous 199869 Revisions Next

r20484 Saturday 26th January, 2013 at 12:45:37 UTC by Wilbert Pol
(MESS) poly88.c: Cleanups (nw)
[src/mess/includes]poly88.h
[src/mess/machine]poly88.c

trunk/src/mess/machine/poly88.c
r20483r20484
1515TIMER_CALLBACK_MEMBER(poly88_state::poly88_usart_timer_callback)
1616{
1717   m_int_vector = 0xe7;
18   machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE);
18   m_maincpu->set_input_line(0, HOLD_LINE);
1919}
2020
2121WRITE8_MEMBER(poly88_state::poly88_baud_rate_w)
r20483r20484
4040
4141TIMER_CALLBACK_MEMBER(poly88_state::keyboard_callback)
4242{
43   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6" };
44
4543   int i;
4644   UINT8 code;
4745   UINT8 key_code = 0;
48   UINT8 shift = machine().root_device().ioport("LINEC")->read() & 0x02 ? 1 : 0;
49   UINT8 ctrl =  machine().root_device().ioport("LINEC")->read() & 0x01 ? 1 : 0;
46   UINT8 shift = m_linec->read() & 0x02 ? 1 : 0;
47   UINT8 ctrl =  m_linec->read() & 0x01 ? 1 : 0;
5048
5149   for(i = 0; i < 7; i++)
5250   {
53      code =  machine().root_device().ioport(keynames[i])->read();
51      switch ( i )
52      {
53         case 0: code = m_line0->read(); break;
54         case 1: code = m_line1->read(); break;
55         case 2: code = m_line2->read(); break;
56         case 3: code = m_line3->read(); break;
57         case 4: code = m_line4->read(); break;
58         case 5: code = m_line5->read(); break;
59         case 6: code = m_line6->read(); break;
60         default: code = 0;
61      }
5462      if (code != 0)
5563      {
5664         if (i==0 && shift==0) {
r20483r20484
116124   }
117125   if (key_code==0 && m_last_code !=0){
118126      m_int_vector = 0xef;
119      machine().device("maincpu")->execute().set_input_line(0, HOLD_LINE);
127      m_maincpu->set_input_line(0, HOLD_LINE);
120128   } else {
121129      m_last_code = key_code;
122130   }
r20483r20484
132140{
133141   int data;
134142   int current_level;
135   i8251_device *uart = machine().device<i8251_device>("uart");
136   serial_source_device *ser = machine().device<serial_source_device>("sercas");
137143
138144//  if (!(machine().root_device().ioport("DSW0")->read() & 0x02)) /* V.24 / Tape Switch */
139145   //{
140146      /* tape reading */
141      if (machine().device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_PLAY)
147      if (m_cassette->get_state()&CASSETTE_PLAY)
142148      {
143149               if (m_clk_level_tape)
144150               {
145                  m_previous_level = ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0;
151                  m_previous_level = (m_cassette->input() > 0.038) ? 1 : 0;
146152                  m_clk_level_tape = 0;
147153               }
148154               else
149155               {
150                  current_level = ((machine().device<cassette_image_device>(CASSETTE_TAG))->input() > 0.038) ? 1 : 0;
156                  current_level = (m_cassette->input() > 0.038) ? 1 : 0;
151157
152158                  if (m_previous_level!=current_level)
153159                  {
154160                     data = (!m_previous_level && current_level) ? 1 : 0;
155161//data = current_level;
156                     ser->send_bit(data);
157                     uart->receive_clock();
162                     m_sercas->send_bit(data);
163                     m_uart->receive_clock();
158164
159165                     m_clk_level_tape = 1;
160166                  }
r20483r20484
162168      }
163169
164170      /* tape writing */
165      if (machine().device<cassette_image_device>(CASSETTE_TAG)->get_state()&CASSETTE_RECORD)
171      if (m_cassette->get_state()&CASSETTE_RECORD)
166172      {
167         data = ser->get_in_data_bit();
173         data = m_sercas->get_in_data_bit();
168174         data ^= m_clk_level_tape;
169         machine().device<cassette_image_device>(CASSETTE_TAG)->output(data&0x01 ? 1 : -1);
175         m_cassette->output(data&0x01 ? 1 : -1);
170176
171177         if (!m_clk_level_tape)
172            uart->transmit_clock();
178            m_uart->transmit_clock();
173179
174180         m_clk_level_tape = m_clk_level_tape ? 0 : 1;
175181
r20483r20484
179185      m_clk_level_tape = 1;
180186
181187      if (!m_clk_level)
182         uart->transmit_clock();
188         m_uart->transmit_clock();
183189      m_clk_level = m_clk_level ? 0 : 1;
184190//  }
185191}
r20483r20484
187193
188194TIMER_CALLBACK_MEMBER(poly88_state::setup_machine_state)
189195{
190   i8251_device *uart = machine().device<i8251_device>("uart");
191   serial_source_device *ser = machine().device<serial_source_device>("sercas");
192   uart->connect(ser);
196   m_uart->connect(m_sercas);
193197}
194198
195199DRIVER_INIT_MEMBER(poly88_state,poly88)
r20483r20484
204208
205209void poly88_state::machine_reset()
206210{
207   machine().device("maincpu")->execute().set_irq_acknowledge_callback(poly88_irq_callback);
211   m_maincpu->set_irq_acknowledge_callback(poly88_irq_callback);
208212   m_intr = 0;
209213   m_last_code = 0;
210214
r20483r20484
239243READ8_MEMBER(poly88_state::poly88_keyboard_r)
240244{
241245   UINT8 retVal = m_last_code;
242   machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
246   m_maincpu->set_input_line(0, CLEAR_LINE);
243247   m_last_code = 0x00;
244248   return retVal;
245249}
246250
247251WRITE8_MEMBER(poly88_state::poly88_intr_w)
248252{
249   machine().device("maincpu")->execute().set_input_line(0, CLEAR_LINE);
253   m_maincpu->set_input_line(0, CLEAR_LINE);
250254}
251255
252256SNAPSHOT_LOAD( poly88 )
trunk/src/mess/includes/poly88.h
r20483r20484
88#define POLY88_H_
99
1010#include "machine/i8251.h"
11#include "imagedev/cassette.h"
1112#include "imagedev/snapquik.h"
1213
1314class poly88_state : public driver_device
1415{
1516public:
1617   poly88_state(const machine_config &mconfig, device_type type, const char *tag)
17      : driver_device(mconfig, type, tag) ,
18      m_video_ram(*this, "video_ram"){ }
18      : driver_device(mconfig, type, tag)
19      , m_video_ram(*this, "video_ram")
20      , m_maincpu(*this, "maincpu")
21      , m_uart(*this, "uart")
22      , m_sercas(*this, "sercas")
23      , m_cassette(*this, CASSETTE_TAG)
24      , m_linec(*this, "LINEC")
25      , m_line0(*this, "LINE0")
26      , m_line1(*this, "LINE1")
27      , m_line2(*this, "LINE2")
28      , m_line3(*this, "LINE3")
29      , m_line4(*this, "LINE4")
30      , m_line5(*this, "LINE5")
31      , m_line6(*this, "LINE6")
32   { }
1933
2034   required_shared_ptr<UINT8> m_video_ram;
2135   UINT8 *m_FNT;
r20483r20484
4054   TIMER_CALLBACK_MEMBER(poly88_cassette_timer_callback);
4155   TIMER_CALLBACK_MEMBER(setup_machine_state);
4256   DECLARE_WRITE_LINE_MEMBER(poly88_usart_rxready);
57
58protected:
59   required_device<cpu_device> m_maincpu;
60   required_device<i8251_device> m_uart;
61   required_device<serial_source_device> m_sercas;
62   required_device<cassette_image_device> m_cassette;
63   required_ioport m_linec;
64   required_ioport m_line0;
65   required_ioport m_line1;
66   required_ioport m_line2;
67   required_ioport m_line3;
68   required_ioport m_line4;
69   required_ioport m_line5;
70   required_ioport m_line6;
4371};
4472
4573

Previous 199869 Revisions Next


© 1997-2024 The MAME Team