Mercurial > repos > blastem
comparison blastem.c @ 592:4ff7bbb3943b
Get rest of emulator compiling again with Z80 core enabled
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 17 Dec 2014 23:03:19 -0800 |
parents | ea80559c67cb |
children | 5ef3fe516da9 |
comparison
equal
deleted
inserted
replaced
591:966b46c68942 | 592:4ff7bbb3943b |
---|---|
381 m68k_context * vdp_port_write_b(uint32_t vdp_port, m68k_context * context, uint8_t value) | 381 m68k_context * vdp_port_write_b(uint32_t vdp_port, m68k_context * context, uint8_t value) |
382 { | 382 { |
383 return vdp_port_write(vdp_port, context, vdp_port < 0x10 ? value | value << 8 : ((vdp_port & 1) ? value : 0)); | 383 return vdp_port_write(vdp_port, context, vdp_port < 0x10 ? value | value << 8 : ((vdp_port & 1) ? value : 0)); |
384 } | 384 } |
385 | 385 |
386 z80_context * z80_vdp_port_write(uint16_t vdp_port, z80_context * context, uint8_t value) | 386 void * z80_vdp_port_write(uint32_t vdp_port, void * vcontext, uint8_t value) |
387 { | 387 { |
388 z80_context * context = vcontext; | |
388 genesis_context * gen = context->system; | 389 genesis_context * gen = context->system; |
389 if (vdp_port & 0xE0) { | 390 if (vdp_port & 0xE0) { |
390 printf("machine freeze due to write to Z80 address %X\n", 0x7F00 | vdp_port); | 391 printf("machine freeze due to write to Z80 address %X\n", 0x7F00 | vdp_port); |
391 exit(1); | 392 exit(1); |
392 } | 393 } |
449 if (vdp_port & 1) { | 450 if (vdp_port & 1) { |
450 return value; | 451 return value; |
451 } else { | 452 } else { |
452 return value >> 8; | 453 return value >> 8; |
453 } | 454 } |
455 } | |
456 | |
457 uint8_t z80_vdp_port_read(uint32_t vdp_port, void * vcontext) | |
458 { | |
459 z80_context * context = vcontext; | |
460 if (vdp_port & 0xE0) { | |
461 printf("machine freeze due to read from Z80 address %X\n", 0x7F00 | vdp_port); | |
462 exit(1); | |
463 } | |
464 genesis_context * gen = context->system; | |
465 vdp_port &= 0x1F; | |
466 uint16_t ret; | |
467 if (vdp_port < 0x10) { | |
468 //These probably won't currently interact well with the 68K accessing the VDP | |
469 vdp_run_context(gen->vdp, context->current_cycle * MCLKS_PER_Z80); | |
470 if (vdp_port < 4) { | |
471 ret = vdp_data_port_read(gen->vdp); | |
472 } else if (vdp_port < 8) { | |
473 ret = vdp_control_port_read(gen->vdp); | |
474 } else { | |
475 printf("Illegal write to HV Counter port %X\n", vdp_port); | |
476 exit(1); | |
477 } | |
478 } else { | |
479 //TODO: Figure out the correct value today | |
480 ret = 0xFFFF; | |
481 } | |
482 return vdp_port & 1 ? ret : ret >> 8; | |
454 } | 483 } |
455 | 484 |
456 uint32_t zram_counter = 0; | 485 uint32_t zram_counter = 0; |
457 #define Z80_ACK_DELAY 3 | 486 #define Z80_ACK_DELAY 3 |
458 #define Z80_BUSY_DELAY 1//TODO: Find the actual value for this | 487 #define Z80_BUSY_DELAY 1//TODO: Find the actual value for this |
672 value <<= 8; | 701 value <<= 8; |
673 } | 702 } |
674 return value; | 703 return value; |
675 } | 704 } |
676 | 705 |
677 z80_context * z80_write_ym(uint16_t location, z80_context * context, uint8_t value) | 706 void * z80_write_ym(uint32_t location, void * vcontext, uint8_t value) |
678 { | 707 { |
708 z80_context * context = vcontext; | |
679 genesis_context * gen = context->system; | 709 genesis_context * gen = context->system; |
680 sync_sound(gen, context->current_cycle * MCLKS_PER_Z80); | 710 sync_sound(gen, context->current_cycle * MCLKS_PER_Z80); |
681 if (location & 1) { | 711 if (location & 1) { |
682 ym_data_write(gen->ym, value); | 712 ym_data_write(gen->ym, value); |
683 } else if (location & 2) { | 713 } else if (location & 2) { |
686 ym_address_write_part1(gen->ym, value); | 716 ym_address_write_part1(gen->ym, value); |
687 } | 717 } |
688 return context; | 718 return context; |
689 } | 719 } |
690 | 720 |
691 uint8_t z80_read_ym(uint16_t location, z80_context * context) | 721 uint8_t z80_read_ym(uint32_t location, void * vcontext) |
692 { | 722 { |
723 z80_context * context = vcontext; | |
693 genesis_context * gen = context->system; | 724 genesis_context * gen = context->system; |
694 sync_sound(gen, context->current_cycle * MCLKS_PER_Z80); | 725 sync_sound(gen, context->current_cycle * MCLKS_PER_Z80); |
695 return ym_read_status(gen->ym); | 726 return ym_read_status(gen->ym); |
727 } | |
728 | |
729 uint8_t z80_read_bank(uint32_t location, void * vcontext) | |
730 { | |
731 z80_context * context = vcontext; | |
732 //TODO: Implement me | |
733 return 0; | |
734 } | |
735 | |
736 void *z80_write_bank(uint32_t location, void * vcontext, uint8_t value) | |
737 { | |
738 z80_context * context = vcontext; | |
739 //TODO: Implement me | |
740 return context; | |
696 } | 741 } |
697 | 742 |
698 uint16_t read_sram_w(uint32_t address, m68k_context * context) | 743 uint16_t read_sram_w(uint32_t address, m68k_context * context) |
699 { | 744 { |
700 genesis_context * gen = context->system; | 745 genesis_context * gen = context->system; |