comparison blastem.c @ 672:18ef3b61e70b

Restore emulation of Z80 being locked out of the 68K bus during DMA and the like
author Michael Pavone <pavone@retrodev.com>
date Sat, 03 Jan 2015 20:20:15 -0800
parents 8ad39a2b0bce
children 687c1dd3bcb9
comparison
equal deleted inserted replaced
671:8ad39a2b0bce 672:18ef3b61e70b
664 } 664 }
665 665
666 uint8_t z80_read_bank(uint32_t location, void * vcontext) 666 uint8_t z80_read_bank(uint32_t location, void * vcontext)
667 { 667 {
668 z80_context * context = vcontext; 668 z80_context * context = vcontext;
669 genesis_context *gen = context->system;
670 if (gen->bus_busy) {
671 context->current_cycle = context->sync_cycle;
672 }
669 //typical delay from bus arbitration 673 //typical delay from bus arbitration
670 context->current_cycle += 3 * MCLKS_PER_Z80; 674 context->current_cycle += 3 * MCLKS_PER_Z80;
675 //TODO: add cycle for an access right after a previous one
671 676
672 location &= 0x7FFF; 677 location &= 0x7FFF;
673 //TODO: add cycle for an access right after a previous one
674 //TODO: block Z80 if VDP has the bus or the 68K is blocked on a VDP access
675 if (context->mem_pointers[1]) { 678 if (context->mem_pointers[1]) {
676 return context->mem_pointers[1][location ^ 1]; 679 return context->mem_pointers[1][location ^ 1];
677 } 680 }
678 uint32_t address = context->bank_reg << 15 | location; 681 uint32_t address = context->bank_reg << 15 | location;
679 if (address >= 0xC00000 && address < 0xE00000) { 682 if (address >= 0xC00000 && address < 0xE00000) {
685 } 688 }
686 689
687 void *z80_write_bank(uint32_t location, void * vcontext, uint8_t value) 690 void *z80_write_bank(uint32_t location, void * vcontext, uint8_t value)
688 { 691 {
689 z80_context * context = vcontext; 692 z80_context * context = vcontext;
693 genesis_context *gen = context->system;
694 if (gen->bus_busy) {
695 context->current_cycle = context->sync_cycle;
696 }
690 //typical delay from bus arbitration 697 //typical delay from bus arbitration
691 context->current_cycle += 3 * MCLKS_PER_Z80; 698 context->current_cycle += 3 * MCLKS_PER_Z80;
699 //TODO: add cycle for an access right after a previous one
700
692 location &= 0x7FFF; 701 location &= 0x7FFF;
693 //TODO: add cycle for an access right after a previous one
694 //TODO: block Z80 if VDP has the bus or the 68K is blocked on a VDP access
695 uint32_t address = context->bank_reg << 15 | location; 702 uint32_t address = context->bank_reg << 15 | location;
696 if (address >= 0xE00000) { 703 if (address >= 0xE00000) {
697 address &= 0xFFFF; 704 address &= 0xFFFF;
698 ((uint8_t *)ram)[address ^ 1] = value; 705 ((uint8_t *)ram)[address ^ 1] = value;
699 } else if (address >= 0xC00000) { 706 } else if (address >= 0xC00000) {