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