comparison segacd.c @ 2058:70260f6051dd segacd

Initial work on CDC emulation
author Michael Pavone <pavone@retrodev.com>
date Fri, 21 Jan 2022 20:24:48 -0800
parents 88deea42caf0
children 7c1760b5b3e5
comparison
equal deleted inserted replaced
2057:88deea42caf0 2058:70260f6051dd
353 } 353 }
354 return value; 354 return value;
355 } 355 }
356 case GA_MEM_MODE: 356 case GA_MEM_MODE:
357 return cd->gate_array[reg] & 0xFF1F; 357 return cd->gate_array[reg] & 0xFF1F;
358 case GA_CDC_CTRL:
359 return cd->gate_array[reg] | cd->cdc.ar;
360 case GA_CDC_REG_DATA:
361 return lc8951_reg_read(&cd->cdc);
358 case GA_STOP_WATCH: 362 case GA_STOP_WATCH:
359 case GA_TIMER: 363 case GA_TIMER:
360 timers_run(cd, m68k->current_cycle); 364 timers_run(cd, m68k->current_cycle);
361 return cd->gate_array[reg]; 365 return cd->gate_array[reg];
362 case GA_FONT_DATA0: 366 case GA_FONT_DATA0:
455 } 459 }
456 cd->gate_array[reg] &= 0xFFC2; 460 cd->gate_array[reg] &= 0xFFC2;
457 cd->gate_array[reg] |= value & (BIT_RET|BIT_MEM_MODE|MASK_PRIORITY); 461 cd->gate_array[reg] |= value & (BIT_RET|BIT_MEM_MODE|MASK_PRIORITY);
458 break; 462 break;
459 } 463 }
464 case GA_CDC_CTRL:
465 lc8951_ar_write(&cd->cdc, value);
466 cd->gate_array[reg] &= 0xC000;
467 cd->gate_array[reg] = value & 0x0700;
468 break;
469 case GA_CDC_REG_DATA:
470 lc8951_reg_write(&cd->cdc, value);
471 break;
460 case GA_STOP_WATCH: 472 case GA_STOP_WATCH:
461 //docs say you should only write zero to reset 473 //docs say you should only write zero to reset
462 //mcd-verificator comments suggest any value will reset 474 //mcd-verificator comments suggest any value will reset
463 timers_run(cd, m68k->current_cycle); 475 timers_run(cd, m68k->current_cycle);
464 cd->gate_array[reg] = 0; 476 cd->gate_array[reg] = 0;
515 case GA_CDD_FADER: 527 case GA_CDD_FADER:
516 case GA_FONT_COLOR: 528 case GA_FONT_COLOR:
517 //these registers treat all writes as word-wide 529 //these registers treat all writes as word-wide
518 value16 = value | (value << 8); 530 value16 = value | (value << 8);
519 break; 531 break;
532 case GA_CDC_CTRL:
533 if (address & 1) {
534 lc8951_ar_write(&cd->cdc, value);
535 } else {
536 cd->gate_array[reg] = value << 8;
537 }
538 return vcontext;
520 default: 539 default:
521 if (address & 1) { 540 if (address & 1) {
522 value16 = cd->gate_array[reg] & 0xFF00 | value; 541 value16 = cd->gate_array[reg] & 0xFF00 | value;
523 } else { 542 } else {
524 value16 = cd->gate_array[reg] & 0xFF | (value << 8); 543 value16 = cd->gate_array[reg] & 0xFF | (value << 8);
827 cd->need_reset = 1; 846 cd->need_reset = 1;
828 cd->reset = 1; //active low, so reset is not active on start 847 cd->reset = 1; //active low, so reset is not active on start
829 cd->memptr_start_index = 0; 848 cd->memptr_start_index = 0;
830 cd->gate_array[1] = 1; 849 cd->gate_array[1] = 1;
831 cd->gate_array[0x1B] = 0x100; 850 cd->gate_array[0x1B] = 0x100;
851 lc8951_init(&cd->cdc);
832 852
833 return cd; 853 return cd;
834 } 854 }
835 855
836 memmap_chunk *segacd_main_cpu_map(segacd_context *cd, uint8_t cart_boot, uint32_t *num_chunks) 856 memmap_chunk *segacd_main_cpu_map(segacd_context *cd, uint8_t cart_boot, uint32_t *num_chunks)