src/mess/drivers/pes.c
| r10640 | r10641 | |
| 44 | 44 | port 3.2: read, from /INT on tms5220c |
| 45 | 45 | port 3.3: read, from /READY on tms5220c |
| 46 | 46 | 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) |
| 48 | 48 | port 3.6: write, /WR (general) and /WE (pin 27) for unpopulated 6164 SRAM |
| 49 | 49 | port 3.7: write, /RD (general) and /OE (pin 22) for unpopulated 6164 SRAM |
| 50 | 50 | |
| 51 | 51 | */ |
| 52 | | |
| 53 | 52 | #define ADDRESS_MAP_MODERN |
| 54 | 53 | #define CPU_CLOCK XTAL_10_245MHz |
| 55 | 54 | |
| 55 | #define DEBUG_PORT3 1 |
| 56 | |
| 56 | 57 | /* Core includes */ |
| 57 | 58 | #include "emu.h" |
| 58 | 59 | #include "includes/pes.h" |
| r10640 | r10641 | |
| 61 | 62 | #include "machine/terminal.h" |
| 62 | 63 | |
| 63 | 64 | /* Devices */ |
| 64 | | static WRITE8_DEVICE_HANDLER( pes_kbd_put ) |
| 65 | static WRITE8_DEVICE_HANDLER( pes_kbd_input ) |
| 65 | 66 | { |
| 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 :( |
| 69 | 81 | } |
| 70 | 82 | |
| 71 | 83 | static GENERIC_TERMINAL_INTERFACE( pes_terminal_intf ) |
| 72 | 84 | { |
| 73 | | DEVCB_HANDLER(pes_kbd_put) |
| 85 | DEVCB_HANDLER(pes_kbd_input) |
| 74 | 86 | }; |
| 75 | 87 | |
| 76 | | /* Handlers */ |
| 88 | /* Helper Functions */ |
| 89 | static 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 | |
| 101 | static 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 */ |
| 77 | 109 | WRITE8_MEMBER( pes_state::rsws_w ) |
| 78 | 110 | { |
| 79 | 111 | pes_state *state = machine->driver_data<pes_state>(); |
| r10640 | r10641 | |
| 92 | 124 | |
| 93 | 125 | } |
| 94 | 126 | |
| 95 | | WRITE8_MEMBER( pes_state::port3_w ) |
| 127 | READ8_MEMBER( pes_state::port1_r ) |
| 96 | 128 | { |
| 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; |
| 100 | 134 | } |
| 101 | 135 | |
| 102 | | |
| 103 | | READ8_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) |
| 144 | WRITE8_MEMBER( pes_state::port3_w ) |
| 104 | 145 | { |
| 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? |
| 110 | 157 | } |
| 111 | 158 | |
| 112 | 159 | READ8_MEMBER( pes_state::port3_r ) |
| 113 | 160 | { |
| 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 |
| 115 | 162 | 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; |
| 121 | 180 | } |
| 122 | 181 | |
| 123 | 182 | |
| 124 | 183 | /* Reset */ |
| 125 | 184 | void pes_state::machine_reset() |
| 126 | 185 | { |
| 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; |
| 127 | 190 | m_wsstate = 1; |
| 128 | 191 | 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"); |
| 132 | 197 | } |
| 133 | 198 | |
| 134 | 199 | /****************************************************************************** |
| 200 | Driver Init |
| 201 | ******************************************************************************/ |
| 202 | DRIVER_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 | /****************************************************************************** |
| 135 | 210 | Address Maps |
| 136 | 211 | ******************************************************************************/ |
| 137 | 212 | |
| r10640 | r10641 | |
| 165 | 240 | |
| 166 | 241 | /* sound hardware */ |
| 167 | 242 | 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 */ |
| 169 | 244 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 170 | 245 | |
| 171 | 246 | MCFG_FRAGMENT_ADD( generic_terminal ) |
| r10640 | r10641 | |
| 189 | 264 | ******************************************************************************/ |
| 190 | 265 | |
| 191 | 266 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 192 | | COMP( 1987, pes, 0, 0, pes, pes, 0, "Pacific Educational Systems", "VPU-01 Speech box", GAME_NOT_WORKING ) |
| 267 | COMP( 1987, pes, 0, 0, pes, pes, pes, "Pacific Educational Systems", "VPU-01 Speech box", GAME_NOT_WORKING ) |