Previous 15994 Revisions Next

r10641 Tuesday 1st March, 2011 at 20:03:52 UTC by Jonathan Gevaryahu
more progress on PES VPU-1 aka 'PES Box' driver, still doesn't work right, problems with 80c31/mcs51 serial comms [Lord Nightmare]
[src/mess/drivers]pes.c
[src/mess/includes]pes.h

src/mess/includes/pes.h
r10640r10641
99#ifndef _PES_H_
1010#define _PES_H_
1111
12#include "machine/terminal.h"
13
1214class pes_state : public driver_device
1315{
1416public:
1517   pes_state(running_machine &machine, const driver_device_config_base &config)
1618      : driver_device(machine, config),
1719        m_maincpu(*this, "maincpu"),
20        m_terminal(*this, TERMINAL_TAG),
1821        m_speech(*this, "tms5220")
1922      { }
2023     
2124   required_device<cpu_device> m_maincpu;
25   required_device<device_t> m_terminal;
2226   required_device<device_t> m_speech;
2327
2428   UINT8 m_wsstate;         // /WS
2529   UINT8 m_rsstate;         // /RS
26   UINT8 m_serial_rts;         // RTS (input)
27   UINT8 m_serial_cts;         // CTS (output)
30   UINT8 m_port3_state;      // Port3 state as last written
31   UINT8 infifo[32];         // input fifo
32   UINT8 infifo_tail_ptr;      // " tail
33   UINT8 infifo_head_ptr;      // " head
2834
2935   virtual void machine_reset();
3036   DECLARE_WRITE8_MEMBER(rsws_w);
src/mess/drivers/pes.c
r10640r10641
4444  port 3.2: read, from /INT on tms5220c
4545  port 3.3: read, from /READY on tms5220c
4646  port 3.4: read, from the serial RTS line
47  port 3.5: write, to the serial CTS line
47  port 3.5: read/write, to the serial CTS line, inverted (effectively /CTS)
4848  port 3.6: write, /WR (general) and /WE (pin 27) for unpopulated 6164 SRAM
4949  port 3.7: write, /RD (general) and /OE (pin 22) for unpopulated 6164 SRAM
5050
5151*/
52
5352#define ADDRESS_MAP_MODERN
5453#define CPU_CLOCK      XTAL_10_245MHz
5554
55#define DEBUG_PORT3 1
56
5657/* Core includes */
5758#include "emu.h"
5859#include "includes/pes.h"
r10640r10641
6162#include "machine/terminal.h"
6263
6364/* Devices */
64static WRITE8_DEVICE_HANDLER( pes_kbd_put )
65static WRITE8_DEVICE_HANDLER( pes_kbd_input )
6566{
66   //duart68681_rx_data(device->machine->device("duart68681"), 1, data);
67   // nothing, yet
68   // todo: attach to serial
67   pes_state *state = device->machine->driver_data<pes_state>();
68   fprintf(stderr,"keyboard input: %c, ", data);
69   // if fifo is full (head ptr = tail ptr-1), do not increment the head ptr and do not store the data
70   if (((state->infifo_tail_ptr-1)&0x1F) == state->infifo_head_ptr)
71   {
72      logerror("infifo was full, write ignored!\n");
73      fprintf(stderr,"infifo was full, write ignored!\n");
74      return;
75   }
76   state->infifo[state->infifo_head_ptr] = data;
77   state->infifo_head_ptr++;
78   state->infifo_head_ptr&=0x1F;
79   fprintf(stderr,"kb input fifo fullness: %d\n",(state->infifo_head_ptr-state->infifo_tail_ptr)&0x1F);
80   cputag_set_input_line(device->machine, "maincpu", MCS51_RX_LINE, HOLD_LINE); // this doesn't do what it should :(
6981}
7082
7183static GENERIC_TERMINAL_INTERFACE( pes_terminal_intf )
7284{
73   DEVCB_HANDLER(pes_kbd_put)
85   DEVCB_HANDLER(pes_kbd_input)
7486};
7587
76/* Handlers */
88/* Helper Functions */
89static int data_to_i8031(device_t *device)
90{
91   pes_state *state = device->machine->driver_data<pes_state>();
92   UINT8 data;
93   data = state->infifo[state->infifo_tail_ptr];
94   // if fifo is empty (tail ptr == head ptr), do not increment the tail ptr, otherwise do.
95   if (state->infifo_tail_ptr != state->infifo_head_ptr) state->infifo_tail_ptr++;
96   state->infifo_tail_ptr&=0x1F;
97   fprintf(stderr,"callback: input to i8031/pes from pc/terminal: %02X\n",data);
98   return data;
99}
100
101static void data_from_i8031(device_t *device, int data)
102{
103   pes_state *state = device->machine->driver_data<pes_state>();
104   terminal_write(state->m_terminal,0,data);
105   fprintf(stderr,"callback: output from i8031/pes to pc/terminal: %02X\n",data);
106}
107
108/* Port Handlers */
77109WRITE8_MEMBER( pes_state::rsws_w )
78110{
79111   pes_state *state = machine->driver_data<pes_state>();
r10640r10641
92124   
93125}
94126
95WRITE8_MEMBER( pes_state::port3_w )
127READ8_MEMBER( pes_state::port1_r )
96128{
97   m_serial_cts = (data&0x20)>>5;
98   logerror("port3 write: control data written: %02X; CTS: %d\n", data, m_serial_cts);
99   // todo: poke serial handler
129   UINT8 data = 0xFF;
130   pes_state *state = machine->driver_data<pes_state>();
131   data = tms5220_status_r(state->m_speech, 0);
132   logerror("port1 read: tms5220 data read: 0x%02X\n", data);
133   return data;
100134}
101135
102
103READ8_MEMBER( pes_state::port1_r )
136#define P3_RXD (((state->m_port3_data)&(1<<0))>>0)
137#define P3_TXD (((state->m_port3_data)&(1<<1))>>1)
138#define P3_INT (((state->m_port3_data)&(1<<2))>>2)
139#define P3_RDY (((state->m_port3_data)&(1<<3))>>3)
140#define P3_RTS (((state->m_port3_data)&(1<<4))>>4)
141#define P3_CTS (((state->m_port3_data)&(1<<5))>>5)
142#define P3_WR (((state->m_port3_data)&(1<<6))>>6)
143#define P3_RD (((state->m_port3_data)&(1<<7))>>7)
144WRITE8_MEMBER( pes_state::port3_w )
104145{
105   UINT8 temp = 0xFF;
106   pes_state *state = machine->driver_data<pes_state>();
107   temp = tms5220_status_r(state->m_speech, 0);
108   logerror("port1 read: tms5220 data read: 0x%02X\n", temp);
109   return temp;
146   m_port3_state = data;
147   logerror("port3 write: control data written: %02X; ", data);
148   logerror("RXD: %d; ", (data&1));
149   logerror("TXD: %d; ", ((data&2)>>1));
150   logerror("/INT: %d; ", ((data&4)>>2));
151   logerror("/RDY: %d; ", ((data&8)>>3));
152   logerror("RTS: %d; ", ((data&0x10)>>4));
153   logerror("CTS: %d; ", ((data&0x20)>>5));
154   logerror("WR: %d; ", ((data&0x40)>>6));
155   logerror("RD: %d;\n", ((data&0x80)>>7));
156   // todo: poke serial handler here somehow?
110157}
111158
112159READ8_MEMBER( pes_state::port3_r )
113160{
114   UINT8 temp = 0xE3; // todo: actually return last written state?
161   UINT8 data = m_port3_state & 0xE3; // return last written state with rts, /rdy and /int masked out
115162   pes_state *state = machine->driver_data<pes_state>();
116   temp |= (m_serial_rts<<4);
117   temp |= (tms5220_readyq_r(state->m_speech)<<3);
118   temp |= (tms5220_intq_r(state->m_speech)<<2);
119   logerror("port3 read: returning 0x%02X\n", temp);
120   return temp;
163   // check rts state; if virtual fifo is nonzero, rts is set, otherwise it is cleared
164   if (state->infifo_tail_ptr != state->infifo_head_ptr)
165   {
166      data |= 0x10; // set RTS bit
167   }
168   data |= (tms5220_intq_r(state->m_speech)<<2);
169   data |= (tms5220_readyq_r(state->m_speech)<<3);
170   logerror("port3 read: returning 0x%02X: ", data);
171   logerror("RXD: %d; ", (data&1));
172   logerror("TXD: %d; ", ((data&2)>>1));
173   logerror("/INT: %d; ", ((data&4)>>2));
174   logerror("/RDY: %d; ", ((data&8)>>3));
175   logerror("RTS: %d; ", ((data&0x10)>>4));
176   logerror("CTS: %d; ", ((data&0x20)>>5));
177   logerror("WR: %d; ", ((data&0x40)>>6));
178   logerror("RD: %d;\n", ((data&0x80)>>7));
179   return data;
121180}
122181
123182
124183/* Reset */
125184void pes_state::machine_reset()
126185{
186   // clear fifos (TODO: memset would work better here...)
187   int i;
188   for (i=0; i<32; i++) infifo[i] = 0;
189   infifo_tail_ptr = infifo_head_ptr = 0;
127190   m_wsstate = 1;
128191   m_rsstate = 1;
129   m_serial_rts = 1;
130   m_serial_cts = 1;
131   devtag_reset(machine, "tms5220");
192
193   m_port3_state = 0; // reset the openbus state of port 3
194   
195   devtag_reset(machine, "tms5220"); // reset the 5220
196   fprintf(stderr,"machine_reset called\n");
132197}
133198
134199/******************************************************************************
200 Driver Init
201******************************************************************************/
202DRIVER_INIT( pes )
203{
204   i8051_set_serial_tx_callback(machine->device("maincpu"), data_from_i8031);
205   i8051_set_serial_rx_callback(machine->device("maincpu"), data_to_i8031);
206   fprintf(stderr,"driver_init called\n");
207}
208
209/******************************************************************************
135210 Address Maps
136211******************************************************************************/
137212
r10640r10641
165240   
166241    /* sound hardware */
167242    MCFG_SPEAKER_STANDARD_MONO("mono")
168    MCFG_SOUND_ADD("tms5220", TMS5220C, 640000) /* 720Khz clock, 10khz output */
243    MCFG_SOUND_ADD("tms5220", TMS5220C, 720000) /* 720Khz clock, 10khz output */
169244    MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
170245
171246   MCFG_FRAGMENT_ADD( generic_terminal )
r10640r10641
189264******************************************************************************/
190265
191266/*    YEAR  NAME   PARENT   COMPAT   MACHINE      INPUT   INIT   COMPANY     FULLNAME            FLAGS */
192COMP( 1987, pes,   0,      0,      pes,      pes,   0,      "Pacific Educational Systems",   "VPU-01 Speech box",   GAME_NOT_WORKING )
267COMP( 1987, pes,   0,      0,      pes,      pes,   pes,   "Pacific Educational Systems",   "VPU-01 Speech box",   GAME_NOT_WORKING )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team