1 /* 2 memvdp.c -- 3 Memory handlers for when the VDP reads the V-bus during DMA. 4 */ 5 6 #include "shared.h" 7 #include "cart/cart.h" 8 9 namespace MDFN_IEN_MD 10 { 11 vdp_dma_r(unsigned int address)12unsigned int vdp_dma_r(unsigned int address) 13 { 14 switch((address >> 21) & 7) 15 { 16 case 0: /* Cartridge ROM */ 17 case 1: 18 case 2: /* Unused */ 19 case 3: 20 return(MD_ExtRead16(address)); 21 //return READ_WORD_MSB(cart_rom, address); 22 //return 0xFF00; 23 24 case 4: /* Work RAM */ 25 case 6: 26 case 7: 27 return READ_WORD_MSB(work_ram, address & 0xFFFF); 28 29 case 5: /* Z80 area and I/O chip */ 30 31 /* Z80 area always returns $FFFF */ 32 if(address <= 0xA0FFFF) 33 { 34 /* Return $FFFF only when the Z80 isn't hogging the Z-bus. 35 (e.g. Z80 isn't reset and 68000 has the bus) */ 36 return (zbusack == 0) 37 ? 0xFFFF 38 : READ_WORD_MSB(work_ram, address & 0xFFFF); 39 } 40 else 41 42 /* The I/O chip and work RAM try to drive the data bus which 43 results in both values being combined in random ways when read. 44 We return the I/O chip values which seem to have precedence, */ 45 if(address <= 0xA1001F) 46 { 47 uint8 temp = gen_io_r((address >> 1) & 0x0F); 48 return (temp << 8 | temp); 49 } 50 else 51 52 /* All remaining locations access work RAM */ 53 return READ_WORD_MSB(work_ram, address & 0xFFFF); 54 } 55 56 return -1; 57 } 58 59 } 60