src/mess/video/bbc.c
| r3839 | r3840 | |
| 22 | 22 | static void BBC_draw_RGB_in(running_machine *machine, int offset,int data); |
| 23 | 23 | |
| 24 | 24 | /************************************************************************ |
| 25 | | * video_refresh flag is used in optimising the screen redrawing |
| 26 | | * it is set whenever a 6845 or VideoULA registers are change. |
| 27 | | * This will then cause a full screen refresh. |
| 28 | 25 | * The vidmem array is used to optimise the screen redrawing |
| 29 | 26 | * whenever a memory location is written to the same location is set in the vidmem array |
| 30 | 27 | * if none of the video registers have been changed and a full redraw is not needed |
| 31 | 28 | * the video display emulation will only redraw the video memory locations that have been changed. |
| 32 | 29 | ************************************************************************/ |
| 33 | 30 | |
| 34 | | static int video_refresh; |
| 35 | 31 | unsigned char vidmem[0x10000]; |
| 36 | 32 | |
| 37 | 33 | // this is the real location of the start of the BBC's ram in the emulation |
| r3839 | r3840 | |
| 160 | 156 | if ((c0==1) && (c1==0)) video_ram_lookup=video_ram_lookup1; |
| 161 | 157 | if ((c0==0) && (c1==1)) video_ram_lookup=video_ram_lookup2; |
| 162 | 158 | if ((c0==1) && (c1==1)) video_ram_lookup=video_ram_lookup3; |
| 163 | | |
| 164 | | // emulation refresh optimisation |
| 165 | | video_refresh=1; |
| 166 | 159 | } |
| 167 | 160 | |
| 168 | 161 | |
| r3839 | r3840 | |
| 275 | 268 | |
| 276 | 269 | int tpal,tcol,vpos; |
| 277 | 270 | |
| 278 | | |
| 279 | | // emulation refresh optimisation |
| 280 | | video_refresh=1; |
| 281 | | |
| 282 | 271 | // Make sure vpos is never <0 2008-10-11 PHS. |
| 283 | 272 | vpos=video_screen_get_vpos(space->machine->primary_screen); |
| 284 | 273 | if(vpos==0) |
| r3839 | r3840 | |
| 335 | 324 | videoULA_pallet1[tpal]=tcol<8?tcol^7:tcol; |
| 336 | 325 | break; |
| 337 | 326 | } |
| 338 | | |
| 339 | | // emulation refresh optimisation |
| 340 | | video_refresh=1; |
| 341 | 327 | } |
| 342 | 328 | |
| 343 | 329 | |
| r3839 | r3840 | |
| 355 | 341 | VideoULA_CR_counter-=1; |
| 356 | 342 | if (VideoULA_CR_counter<=0) { |
| 357 | 343 | VideoULA_CR=0; |
| 358 | | video_refresh=video_refresh&0xfb; |
| 359 | 344 | set_cursor(); |
| 360 | 345 | } |
| 361 | 346 | } |
| r3839 | r3840 | |
| 400 | 385 | // this is actually does by the latch IC's not the Video ULA |
| 401 | 386 | meml=video_ram_lookup[m6845_memory_address_r(0)]|(BBC_Character_Row&0x7); |
| 402 | 387 | |
| 403 | | if (vidmem_RAM[meml] || video_refresh ) |
| 388 | if (vidmem_RAM[meml]) |
| 404 | 389 | { |
| 405 | 390 | vidmem_RAM[meml]=0; |
| 406 | 391 | i=BBC_Video_RAM[meml]; |
| r3839 | r3840 | |
| 414 | 399 | BBC_display += emulation_pixels_per_byte; |
| 415 | 400 | } |
| 416 | 401 | } else { |
| 417 | | if (video_refresh) |
| 418 | | { |
| 419 | | // if the display is not enable, just draw a blank area. |
| 420 | | BBC_ula_drawpixel(0, emulation_pixels_per_byte); |
| 421 | | } else { |
| 422 | | BBC_display += emulation_pixels_per_byte; |
| 423 | | } |
| 402 | // if the display is not enable, just draw a blank area. |
| 403 | BBC_ula_drawpixel(0, emulation_pixels_per_byte); |
| 424 | 404 | } |
| 425 | 405 | } |
| 426 | 406 | |
| r3839 | r3840 | |
| 525 | 505 | if (data&2) { |
| 526 | 506 | VideoULA_CR_counter=emulation_cursor_size; |
| 527 | 507 | VideoULA_CR=1; |
| 528 | | // turn on the video refresh for the cursor area |
| 529 | | video_refresh=video_refresh|4; |
| 530 | 508 | // set the pallet on |
| 531 | 509 | if (data&1) set_cursor(); |
| 532 | 510 | } |
| r3839 | r3840 | |
| 563 | 541 | m6845_register_w(0,data); |
| 564 | 542 | break; |
| 565 | 543 | } |
| 566 | | |
| 567 | | // emulation refresh optimisation |
| 568 | | video_refresh=1; |
| 569 | 544 | } |
| 570 | 545 | |
| 571 | 546 | READ8_HANDLER (BBC_6845_r) |
| r3839 | r3840 | |
| 595 | 570 | VIDEO_UPDATE( bbc ) |
| 596 | 571 | { |
| 597 | 572 | long c; |
| 598 | | int full_refresh; |
| 599 | 573 | |
| 600 | 574 | //logerror ("Box %d by %d \n",cliprect->min_y,cliprect->max_y); |
| 601 | 575 | |
| 602 | 576 | c = 0; // this is used to time out the screen redraw, in the case that the 6845 is in some way out state. |
| 603 | | full_refresh = 1; |
| 604 | 577 | |
| 605 | 578 | BBC_bitmap=bitmap; |
| 606 | 579 | |
| r3839 | r3840 | |
| 608 | 581 | BBC_display_right=BBC_display_left; |
| 609 | 582 | BBC_display=BBC_display_left; |
| 610 | 583 | |
| 611 | | // video_refresh is set if any of the 6845 or Video ULA registers are changed |
| 612 | | // this then forces a full screen redraw |
| 613 | | |
| 614 | | if (full_refresh) |
| 615 | | { |
| 616 | | video_refresh=video_refresh|2; |
| 617 | | } |
| 618 | | |
| 619 | 584 | // loop until the end of the Vertical Sync pulse |
| 620 | 585 | // or until a timeout (this catches the 6845 with silly register values that would not give a VSYNC signal) |
| 621 | 586 | while((BBC_VSync)&&(c<60000)) |
| r3839 | r3840 | |
| 640 | 605 | c++; |
| 641 | 606 | } |
| 642 | 607 | |
| 643 | | // redrawn the screen so reset video_refresh |
| 644 | | video_refresh=0; |
| 645 | | |
| 646 | 608 | return 0; |
| 647 | 609 | } |
| 648 | 610 | |
src/mess/machine/mc6850.c
| r3839 | r3840 | |
| 1 | | /********************************************************************** |
| 2 | | |
| 3 | | Motorola 6850 ACIA interface and emulation |
| 4 | | |
| 5 | | This function is a simple emulation of up to 4 MC6850 |
| 6 | | Asynchronous Communications Interface Adapter. |
| 7 | | |
| 8 | | Todo: |
| 9 | | Handle interrupts. |
| 10 | | Handle state changes. |
| 11 | | **********************************************************************/ |
| 12 | | |
| 13 | | #include "driver.h" |
| 14 | | #include "mc6850.h" |
| 15 | | |
| 16 | | struct acia6850 |
| 17 | | { |
| 18 | | const struct acia6850_interface *intf; |
| 19 | | }; |
| 20 | | |
| 21 | | static struct acia6850 acia[ACIA_6850_MAX]; |
| 22 | | |
| 23 | | void acia6850_unconfig (void) |
| 24 | | { |
| 25 | | memset (&acia, 0, sizeof (acia)); |
| 26 | | } |
| 27 | | |
| 28 | | void acia6850_config_old(int which, const struct acia6850_interface *intf) |
| 29 | | { |
| 30 | | if (which >= ACIA_6850_MAX) return; |
| 31 | | acia[which].intf = intf; |
| 32 | | } |
| 33 | | |
| 34 | | void acia6850_reset (void) |
| 35 | | { |
| 36 | | } |
| 37 | | |
| 38 | | int acia6850_read (const address_space *space, int which, int offset) |
| 39 | | { |
| 40 | | struct acia6850 *currptr = acia + which; |
| 41 | | int val = 0; |
| 42 | | |
| 43 | | switch (offset) |
| 44 | | { |
| 45 | | case ACIA_6850_CTRL: |
| 46 | | if ((*(*currptr).intf).in_status_func) |
| 47 | | val = (*(*currptr).intf).in_status_func(space, 0); |
| 48 | | break; |
| 49 | | case ACIA_6850_DATA: |
| 50 | | if ((*(*currptr).intf).in_recv_func) |
| 51 | | val = (*(*currptr).intf).in_recv_func(space, 0); |
| 52 | | break; |
| 53 | | } |
| 54 | | return (val); |
| 55 | | } |
| 56 | | |
| 57 | | void acia6850_write (const address_space *space, int which, int offset, int data) |
| 58 | | { |
| 59 | | struct acia6850 *currptr = acia + which; |
| 60 | | |
| 61 | | switch (offset) |
| 62 | | { |
| 63 | | case ACIA_6850_CTRL: |
| 64 | | if ((*(*currptr).intf).out_status_func) |
| 65 | | (*(*currptr).intf).out_status_func(space, 0, data); |
| 66 | | break; |
| 67 | | case ACIA_6850_DATA: |
| 68 | | if ((*(*currptr).intf).out_tran_func) |
| 69 | | (*(*currptr).intf).out_tran_func(space, 0, data); |
| 70 | | break; |
| 71 | | } |
| 72 | | } |
| 73 | | |
| 74 | | READ8_HANDLER( acia6850_0_r ) { return acia6850_read (space, 0, offset); } |
| 75 | | READ8_HANDLER( acia6850_1_r ) { return acia6850_read (space, 1, offset); } |
| 76 | | READ8_HANDLER( acia6850_2_r ) { return acia6850_read (space, 2, offset); } |
| 77 | | READ8_HANDLER( acia6850_3_r ) { return acia6850_read (space, 3, offset); } |
| 78 | | |
| 79 | | WRITE8_HANDLER( acia6850_0_w ) { acia6850_write (space, 0, offset, data); } |
| 80 | | WRITE8_HANDLER( acia6850_1_w ) { acia6850_write (space, 1, offset, data); } |
| 81 | | WRITE8_HANDLER( acia6850_2_w ) { acia6850_write (space, 2, offset, data); } |
| 82 | | WRITE8_HANDLER( acia6850_3_w ) { acia6850_write (space, 3, offset, data); } |
| 83 | | |
| 84 | | |
| 85 | | |
| 86 | | |
| 87 | | |
| 88 | | |
| 89 | | /************************************************************************ |
| 90 | | MC6850 |
| 91 | | |
| 92 | | MESS Driver By: |
| 93 | | |
| 94 | | Gordon Jefferyes |
| 95 | | mess_bbc@gjeffery.dircon.co.uk |
| 96 | | |
| 97 | | ************************************************************************/ |
| 98 | | |
| 99 | | |
| 100 | | static int TDR=0; // Transmit Data Register |
| 101 | | static int RDR=0; // Recieve Data Register |
| 102 | | static int STR=0; // Status Register |
| 103 | | static int CTR=0; // Control Register |
| 104 | | |
| 105 | | |
| 106 | | static int RSR=0; // Receive Shift Register |
| 107 | | static int RSC=0; // Receive Shift Counter |
| 108 | | |
| 109 | | static int dcd_count=0; |
| 110 | | |
| 111 | | static int IRQ=0; |
| 112 | | |
| 113 | | // Bits 0,1 of control Register |
| 114 | | |
| 115 | | static const int divide_by_lookup[4]={1,16,64,0}; |
| 116 | | static int divide_by; |
| 117 | | |
| 118 | | |
| 119 | | // Bits 2,3,4 of control Register |
| 120 | | |
| 121 | | static const int word_length_lookup[8]={7,7,7,7,8,8,8,8}; |
| 122 | | static int word_length; |
| 123 | | |
| 124 | | // Parity Settings |
| 125 | | // 2 = even |
| 126 | | // 1 = odd |
| 127 | | // 0 = no parity bit |
| 128 | | static const int parity_lookup[8]={2,1,2,1,0,0,2,1}; |
| 129 | | static int parity; |
| 130 | | |
| 131 | | static const int stop_bits_lookup[8]={2,2,1,1,2,1,1,1}; |
| 132 | | static int stop_bits; |
| 133 | | |
| 134 | | // Bits 5,6 of control Register |
| 135 | | |
| 136 | | static const int RTS_lookup[4]={0,0,1,0}; |
| 137 | | static int RTS; |
| 138 | | |
| 139 | | static const int break_level_lookup[4]={0,0,0,1}; |
| 140 | | static int break_level; |
| 141 | | |
| 142 | | // transmitting Interrupt 0 = Disabled 1 = Enabled |
| 143 | | static const int transmit_interrupt_enabled_lookup[4]={0,1,0,0}; |
| 144 | | static int transmit_interrupt_enabled; |
| 145 | | |
| 146 | | // Bit 7 of control Register |
| 147 | | static int receive_interrupt_enabled; |
| 148 | | |
| 149 | | static int bytelength=10; |
| 150 | | |
| 151 | | |
| 152 | | /* ******* call back function stuff ******* */ |
| 153 | | |
| 154 | | |
| 155 | | //Local copy of the MC6850 external procedure calls |
| 156 | | static struct MC6850_interface MC6850_calls = |
| 157 | | { |
| 158 | | 0,// Transmit data ouput |
| 159 | | 0,// Request to Send output |
| 160 | | 0,// Interupt Request output |
| 161 | | }; |
| 162 | | |
| 163 | | void MC6850_config(const struct MC6850_interface *intf) |
| 164 | | { |
| 165 | | MC6850_calls.out_transmit_data_func=*intf->out_transmit_data_func; |
| 166 | | MC6850_calls.out_RTS_func =*intf->out_RTS_func; |
| 167 | | MC6850_calls.out_IRQ_func =*intf->out_IRQ_func; |
| 168 | | } |
| 169 | | |
| 170 | | /* ******* Data bus interface ******* */ |
| 171 | | |
| 172 | | void MC6850_data_w(int offset, int data) |
| 173 | | { |
| 174 | | |
| 175 | | //logerror("MC6850 write to output buffer %02x\n",data); |
| 176 | | STR=STR&0xfd; |
| 177 | | TDR=data; |
| 178 | | } |
| 179 | | |
| 180 | | int MC6850_data_r(int offset) |
| 181 | | { |
| 182 | | //logerror("MC6850 Read from RDR value %02x and clear flags\n",RDR); |
| 183 | | STR=STR&0x7e; |
| 184 | | // clear the IRQ |
| 185 | | if ((MC6850_calls.out_IRQ_func) && (IRQ==1)) |
| 186 | | { |
| 187 | | (MC6850_calls.out_IRQ_func)(0); |
| 188 | | IRQ=0; |
| 189 | | } |
| 190 | | return RDR; |
| 191 | | } |
| 192 | | |
| 193 | | |
| 194 | | void MC6850_control_w(int offset, int data) |
| 195 | | { |
| 196 | | int CTRT; // Temp bits from CTR |
| 197 | | CTR=data; |
| 198 | | |
| 199 | | //logerror("MC6850 set control flags to %02x\n",CTR); |
| 200 | | divide_by=divide_by_lookup[CTR&0x03]; |
| 201 | | |
| 202 | | CTRT=(CTR>>2)&0x07; |
| 203 | | word_length=word_length_lookup[CTRT]; |
| 204 | | parity =parity_lookup[CTRT]; |
| 205 | | stop_bits =stop_bits_lookup[CTRT]; |
| 206 | | |
| 207 | | CTRT=(CTR>>5)&0x03; |
| 208 | | RTS=RTS_lookup[CTRT]; |
| 209 | | /* *** need to call the RTS output function here ***/ |
| 210 | | break_level=break_level_lookup[CTRT]; // Don't know what this does |
| 211 | | transmit_interrupt_enabled=transmit_interrupt_enabled_lookup[CTRT]; |
| 212 | | |
| 213 | | receive_interrupt_enabled=(CTR>>7)&0x01; |
| 214 | | |
| 215 | | |
| 216 | | bytelength=1; // start bit |
| 217 | | bytelength+=word_length; // byte |
| 218 | | if (parity) bytelength+=1; // parity bit |
| 219 | | bytelength+=stop_bits; // stop bit |
| 220 | | } |
| 221 | | |
| 222 | | |
| 223 | | // Bit 0 Receive Data Register Full (RDRF) |
| 224 | | // Bit 1 Transmit Data Register Empty (TDRE) |
| 225 | | // Bit 2 Data Carrier Detect |
| 226 | | // Bit 3 Clear-to-Send |
| 227 | | // Bit 4 Framing Error |
| 228 | | // Bit 5 Receiver Overrun |
| 229 | | // Bit 6 Parity Error |
| 230 | | // Bit 7 Interrupt Request |
| 231 | | |
| 232 | | |
| 233 | | int MC6850_status_r(int offset) |
| 234 | | { |
| 235 | | |
| 236 | | //logerror("MC6850 read status flags %02x\n",STR); |
| 237 | | return STR; |
| 238 | | } |
| 239 | | |
| 240 | | |
| 241 | | |
| 242 | | |
| 243 | | /* ******* other input lines ******* */ |
| 244 | | |
| 245 | | #ifdef UNUSED_FUNCTION |
| 246 | | void MC6850_DCD(int offset, int data) |
| 247 | | { |
| 248 | | STR=(STR&0xfb)|((data&1)<<2); |
| 249 | | // check to see if an interrupt should be made. |
| 250 | | } |
| 251 | | |
| 252 | | void MC6850_CTS(int offset, int data) |
| 253 | | { |
| 254 | | STR=(STR&0xf7)|((data&1)<<3); |
| 255 | | // this also sets the Transmit Controller |
| 256 | | } |
| 257 | | #endif |
| 258 | | |
| 259 | | void MC6850_Receive_Clock(int Receive_Data) |
| 260 | | { |
| 261 | | |
| 262 | | // Only start clocking in the data when a start bit is sent |
| 263 | | if ((RSC>0) || (Receive_Data==0)) |
| 264 | | { |
| 265 | | |
| 266 | | RSR=(RSR>>1)|((Receive_Data&1)<<8); |
| 267 | | RSC+=1; |
| 268 | | // 10 is the default bit size for the cassette input |
| 269 | | if (RSC==bytelength) |
| 270 | | { |
| 271 | | //logerror("MC6850 Full byte recieved $%02x\n",(RSR&0xff)); |
| 272 | | if (~(STR&0x01)) |
| 273 | | { |
| 274 | | RDR=(RSR&0xff); |
| 275 | | STR=STR|0x81; // set the receive Data Register full and set the Interrupt Request |
| 276 | | //logerror("MC6850 OK to pass on byte to RDR\n"); |
| 277 | | // set the IRQ |
| 278 | | // only do interrupt if bit 7 of CTR is high |
| 279 | | if ((MC6850_calls.out_IRQ_func) && (receive_interrupt_enabled) && (IRQ==0)) |
| 280 | | { |
| 281 | | (MC6850_calls.out_IRQ_func)(1); |
| 282 | | IRQ=1; |
| 283 | | }; |
| 284 | | } |
| 285 | | |
| 286 | | RSC=0; |
| 287 | | RSR=0; |
| 288 | | dcd_count=0; |
| 289 | | }; |
| 290 | | } else { |
| 291 | | logerror("Data bit 1 not used\n"); |
| 292 | | dcd_count+=1; |
| 293 | | if (dcd_count==8) |
| 294 | | { |
| 295 | | logerror("MC6850 set DCD"); |
| 296 | | STR=STR|0x84; |
| 297 | | if ((MC6850_calls.out_IRQ_func) && (receive_interrupt_enabled) && (IRQ==0)) |
| 298 | | { |
| 299 | | (MC6850_calls.out_IRQ_func)(1); |
| 300 | | IRQ=1; |
| 301 | | }; |
| 302 | | } else { |
| 303 | | if (dcd_count==20) { |
| 304 | | STR=STR&0xfb; |
| 305 | | logerror("MC6850 clear DCD"); |
| 306 | | } |
| 307 | | } |
| 308 | | } |
| 309 | | |
| 310 | | } |
| 311 | | |
| 312 | | void MC6850_Reset(int clocklength) |
| 313 | | { |
| 314 | | // If a long time has passed and no data has be sent then reset the counters |
| 315 | | // there should be a timer in this code that calls here if no bits are recived after about 1.5 bits of time. |
| 316 | | // but for now I am calling externally. |
| 317 | | RSC=0; |
| 318 | | RSR=0; |
| 319 | | dcd_count=0; |
| 320 | | } |
| 321 | | |
| 322 | | #ifdef UNUSED_FUNCTION |
| 323 | | int MC6850_Transmit_Clock(void) |
| 324 | | { |
| 325 | | // clock out the data and return a Trasmit Data bit |
| 326 | | |
| 327 | | /* lots of stuff to do in here |
| 328 | | if we get to outputing data too */ |
| 329 | | return 0; |
| 330 | | } |
| 331 | | #endif |
| 332 | | |
| 333 | | |
| 334 | | /* ******* other output lines ******* */ |
| 335 | | |
| 336 | | #ifdef UNUSED_FUNCTION |
| 337 | | int MC6850_transmit_data(int offset) |
| 338 | | { |
| 339 | | // return the last transmitted bit |
| 340 | | return 0; |
| 341 | | } |
| 342 | | |
| 343 | | static int MC6850_RTS(int offset) |
| 344 | | { |
| 345 | | // is this correct ???? |
| 346 | | return RTS; |
| 347 | | } |
| 348 | | #endif |
| 349 | | |
| 350 | | /* |
| 351 | | interrupt Request is the only other output |
| 352 | | and this does not need to be read |
| 353 | | */ |
| 354 | | |
| 355 | | |
src/mess/machine/mc6850.h
| r3839 | r3840 | |
| 1 | | /********************************************************************** |
| 2 | | |
| 3 | | Motorola 6850 ACIA interface and emulation |
| 4 | | |
| 5 | | This function is a simple emulation of up to 4 MC6850 |
| 6 | | Asynchronous Communications Interface Adapter. |
| 7 | | |
| 8 | | **********************************************************************/ |
| 9 | | |
| 10 | | #ifndef ACIA_6850 |
| 11 | | #define ACIA_6850 |
| 12 | | |
| 13 | | #define ACIA_6850_MAX 4 |
| 14 | | |
| 15 | | #define ACIA_6850_CTRL 0 |
| 16 | | #define ACIA_6850_DATA 1 |
| 17 | | |
| 18 | | #define ACIA_6850_RDRF 0x01 /* Receive data register full */ |
| 19 | | #define ACIA_6850_TDRE 0x02 /* Transmit data register empty */ |
| 20 | | #define ACIA_6850_dcd 0x04 /* Data carrier detect, active low */ |
| 21 | | #define ACIA_6850_cts 0x08 /* Clear to send, active low */ |
| 22 | | #define ACIA_6850_FE 0x10 /* Framing error */ |
| 23 | | #define ACIA_6850_OVRN 0x20 /* Receiver overrun */ |
| 24 | | #define ACIA_6850_PE 0x40 /* Parity error */ |
| 25 | | #define ACIA_6850_irq 0x80 /* Interrupt request, active low */ |
| 26 | | |
| 27 | | struct acia6850_interface |
| 28 | | { |
| 29 | | read8_space_func in_status_func; |
| 30 | | read8_space_func in_recv_func; |
| 31 | | write8_space_func out_status_func; |
| 32 | | write8_space_func out_tran_func; |
| 33 | | }; |
| 34 | | |
| 35 | | void acia6850_unconfig(void); |
| 36 | | void acia6850_config_old( int which, const struct acia6850_interface *intf); |
| 37 | | void acia6850_reset(void); |
| 38 | | int acia6850_read(const address_space *space, int which, int offset); |
| 39 | | void acia6850_write(const address_space *space, int which, int offset, int data); |
| 40 | | |
| 41 | | READ8_HANDLER( acia6850_0_r ); |
| 42 | | READ8_HANDLER( acia6850_1_r ); |
| 43 | | READ8_HANDLER( acia6850_2_r ); |
| 44 | | READ8_HANDLER( acia6850_3_r ); |
| 45 | | |
| 46 | | WRITE8_HANDLER( acia6850_0_w ); |
| 47 | | WRITE8_HANDLER( acia6850_1_w ); |
| 48 | | WRITE8_HANDLER( acia6850_2_w ); |
| 49 | | WRITE8_HANDLER( acia6850_3_w ); |
| 50 | | |
| 51 | | #endif /* ACIA_6850 */ |
| 52 | | |
| 53 | | |
| 54 | | |
| 55 | | /***** coded added by GJ to emulate the core of a 6850 */ |
| 56 | | |
| 57 | | |
| 58 | | |
| 59 | | struct MC6850_interface |
| 60 | | { |
| 61 | | void (*out_transmit_data_func)(int offset, int data); |
| 62 | | void (*out_RTS_func)(int offset, int data); |
| 63 | | void (*out_IRQ_func)(int level); |
| 64 | | }; |
| 65 | | |
| 66 | | void MC6850_Receive_Clock(int Receive_Data); |
| 67 | | void MC6850_Reset(int clocklength); |
| 68 | | |
| 69 | | void MC6850_data_w(int offset, int data); |
| 70 | | int MC6850_data_r(int offset); |
| 71 | | |
| 72 | | void MC6850_control_w(int offset, int data); |
| 73 | | int MC6850_status_r(int offset); |
| 74 | | |
| 75 | | void MC6850_config(const struct MC6850_interface *intf); |
| 76 | | |
src/mess/machine/bbc.c
| r3839 | r3840 | |
| 18 | 18 | #include "machine/upd7002.h" |
| 19 | 19 | #include "machine/i8271.h" |
| 20 | 20 | #include "machine/mc146818.h" |
| 21 | | #include "machine/mc6850.h" |
| 22 | 21 | #include "devices/basicdsk.h" |
| 23 | 22 | #include "devices/cassette.h" |
| 24 | 23 | #include "sound/sn76496.h" |
| r3839 | r3840 | |
| 1351 | 1350 | |
| 1352 | 1351 | WRITE8_HANDLER ( BBC_6850_w ) |
| 1353 | 1352 | { |
| 1353 | const device_config *acia = device_list_find_by_tag(space->machine->config->devicelist, ACIA6850, "acia6850"); |
| 1354 | |
| 1354 | 1355 | switch (offset&1) |
| 1355 | 1356 | { |
| 1356 | 1357 | case 0: |
| 1357 | | MC6850_control_w(0,data); |
| 1358 | acia6850_ctrl_w(acia, 0, data); |
| 1358 | 1359 | break; |
| 1359 | 1360 | case 1: |
| 1360 | | MC6850_data_w(0,data); |
| 1361 | acia6850_data_w(acia, 0, data); |
| 1361 | 1362 | break; |
| 1362 | 1363 | } |
| 1363 | 1364 | |
| r3839 | r3840 | |
| 1367 | 1368 | |
| 1368 | 1369 | READ8_HANDLER (BBC_6850_r) |
| 1369 | 1370 | { |
| 1370 | | int retval=0; |
| 1371 | const device_config *acia = device_list_find_by_tag(space->machine->config->devicelist, ACIA6850, "acia6850"); |
| 1372 | UINT8 retval=0; |
| 1371 | 1373 | |
| 1372 | 1374 | switch (offset&1) |
| 1373 | 1375 | { |
| 1374 | 1376 | case 0: |
| 1375 | | retval=MC6850_status_r(0); |
| 1377 | retval = acia6850_stat_r(acia, 0); |
| 1376 | 1378 | break; |
| 1377 | 1379 | case 1: |
| 1378 | | retval=MC6850_data_r(0); |
| 1380 | retval = acia6850_data_r(acia, 0); |
| 1379 | 1381 | break; |
| 1380 | 1382 | } |
| 1381 | 1383 | //logerror("6850 read from %02x = %02x\n",offset,retval); |
| r3839 | r3840 | |
| 1384 | 1386 | |
| 1385 | 1387 | |
| 1386 | 1388 | |
| 1387 | | static void Serial_interrupt(int level) |
| 1389 | static void Serial_interrupt(const device_config *device, int level) |
| 1388 | 1390 | { |
| 1389 | 1391 | MC6850_irq=level; |
| 1390 | 1392 | bbc_setirq(Machine); |
| 1391 | 1393 | //logerror("Set SIO irq %01x\n",level); |
| 1392 | 1394 | } |
| 1393 | 1395 | |
| 1394 | | static const struct MC6850_interface BBC_MC6850_calls = |
| 1396 | const acia6850_interface bbc_acia6850_interface = |
| 1395 | 1397 | { |
| 1396 | | 0,// Transmit data ouput |
| 1397 | | 0,// Request to Send output |
| 1398 | | Serial_interrupt,// Interupt Request output |
| 1398 | 0, /* tx_clock */ |
| 1399 | 0, /* rx_clock */ |
| 1400 | NULL, /* rx_pin */ |
| 1401 | NULL, /* tx_pin */ |
| 1402 | NULL, /* cts_pin */ |
| 1403 | NULL, /* rts_pin */ |
| 1404 | NULL, /* dcd_pin */ |
| 1405 | Serial_interrupt, /* int_callback */ |
| 1399 | 1406 | }; |
| 1400 | 1407 | |
| 1401 | 1408 | |
| r3839 | r3840 | |
| 1412 | 1419 | static int len1=0; |
| 1413 | 1420 | static int len2=0; |
| 1414 | 1421 | static int len3=0; |
| 1422 | static int mc6850_clock = 0; |
| 1415 | 1423 | |
| 1416 | 1424 | static emu_timer *bbc_tape_timer; |
| 1417 | 1425 | |
| 1426 | static void MC6850_Receive_Clock(running_machine *machine, int new_clock) |
| 1427 | { |
| 1428 | if (!mc6850_clock && new_clock) |
| 1429 | { |
| 1430 | const device_config *acia = device_list_find_by_tag(machine->config->devicelist, ACIA6850, "acia6850"); |
| 1431 | acia_tx_clock_in(acia); |
| 1432 | } |
| 1433 | mc6850_clock = new_clock; |
| 1434 | } |
| 1435 | |
| 1418 | 1436 | static TIMER_CALLBACK(bbc_tape_timer_cb) |
| 1419 | 1437 | { |
| 1420 | 1438 | |
| r3839 | r3840 | |
| 1428 | 1446 | { |
| 1429 | 1447 | //this is to long to recive anything so reset the serial IC. This is a hack, this should be done as a timer in the MC6850 code. |
| 1430 | 1448 | logerror ("Cassette length %d\n",wav_len); |
| 1431 | | MC6850_Reset(wav_len); |
| 1432 | 1449 | len0=0; |
| 1433 | 1450 | len1=0; |
| 1434 | 1451 | len2=0; |
| r3839 | r3840 | |
| 1449 | 1466 | { |
| 1450 | 1467 | /* Clock a 0 onto the serial line */ |
| 1451 | 1468 | logerror("Serial value 0\n"); |
| 1452 | | MC6850_Receive_Clock(0); |
| 1469 | MC6850_Receive_Clock(machine, 0); |
| 1453 | 1470 | len0=0; |
| 1454 | 1471 | len1=0; |
| 1455 | 1472 | len2=0; |
| r3839 | r3840 | |
| 1460 | 1477 | { |
| 1461 | 1478 | /* Clock a 1 onto the serial line */ |
| 1462 | 1479 | logerror("Serial value 1\n"); |
| 1463 | | MC6850_Receive_Clock(1); |
| 1480 | MC6850_Receive_Clock(machine, 1); |
| 1464 | 1481 | len0=0; |
| 1465 | 1482 | len1=0; |
| 1466 | 1483 | len2=0; |
| r3839 | r3840 | |
| 1484 | 1501 | } else { |
| 1485 | 1502 | cassette_change_state(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 1486 | 1503 | timer_reset(bbc_tape_timer, attotime_never); |
| 1487 | | MC6850_Reset(wav_len); |
| 1488 | 1504 | len0=0; |
| 1489 | 1505 | len1=0; |
| 1490 | 1506 | len2=0; |
| r3839 | r3840 | |
| 2132 | 2148 | |
| 2133 | 2149 | MACHINE_START( bbca ) |
| 2134 | 2150 | { |
| 2151 | mc6850_clock = 0; |
| 2135 | 2152 | via_config(0, &bbcb_system_via); |
| 2136 | 2153 | via_set_clock(0,1000000); |
| 2137 | 2154 | } |
| r3839 | r3840 | |
| 2148 | 2165 | via_reset(); |
| 2149 | 2166 | |
| 2150 | 2167 | bbcb_IC32_initialise(); |
| 2151 | | |
| 2152 | | MC6850_config(&BBC_MC6850_calls); |
| 2153 | 2168 | } |
| 2154 | 2169 | |
| 2155 | 2170 | MACHINE_START( bbcb ) |
| 2156 | 2171 | { |
| 2172 | mc6850_clock = 0; |
| 2157 | 2173 | //removed from here because MACHINE_START can no longer read DIP swiches. |
| 2158 | 2174 | //put in MACHINE_RESET instead. |
| 2159 | 2175 | //bbc_DFSType= (input_port_read(machine, "BBCCONFIG")>>0)&0x07; |
| r3839 | r3840 | |
| 2204 | 2220 | |
| 2205 | 2221 | bbcb_IC32_initialise(); |
| 2206 | 2222 | |
| 2207 | | MC6850_config(&BBC_MC6850_calls); |
| 2208 | 2223 | |
| 2209 | 2224 | opusbank=0; |
| 2210 | 2225 | /*set up the required disc controller*/ |
| r3839 | r3840 | |
| 2220 | 2235 | |
| 2221 | 2236 | MACHINE_START( bbcbp ) |
| 2222 | 2237 | { |
| 2238 | mc6850_clock = 0; |
| 2239 | |
| 2223 | 2240 | memory_set_direct_update_handler( cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM), bbcbp_direct_handler); |
| 2224 | 2241 | |
| 2225 | 2242 | /* bank 6 is the paged ROMs from b000 to bfff */ |
| r3839 | r3840 | |
| 2246 | 2263 | |
| 2247 | 2264 | bbcb_IC32_initialise(); |
| 2248 | 2265 | |
| 2249 | | MC6850_config(&BBC_MC6850_calls); |
| 2250 | 2266 | |
| 2251 | 2267 | previous_wd177x_int_state=1; |
| 2252 | 2268 | wd17xx_reset(machine); |
| r3839 | r3840 | |
| 2256 | 2272 | |
| 2257 | 2273 | MACHINE_START( bbcm ) |
| 2258 | 2274 | { |
| 2275 | mc6850_clock = 0; |
| 2276 | |
| 2259 | 2277 | memory_set_direct_update_handler( cpu_get_address_space( machine->cpu[0], ADDRESS_SPACE_PROGRAM ), bbcm_direct_handler); |
| 2260 | 2278 | |
| 2261 | 2279 | /* bank 5 is the paged ROMs from 9000 to bfff */ |
| r3839 | r3840 | |
| 2286 | 2304 | |
| 2287 | 2305 | bbcb_IC32_initialise(); |
| 2288 | 2306 | |
| 2289 | | MC6850_config(&BBC_MC6850_calls); |
| 2290 | 2307 | |
| 2291 | 2308 | previous_wd177x_int_state=1; |
| 2292 | 2309 | wd17xx_reset(machine); |