src/memory.c

changeset 121
15ae2788e848
parent 119
101fe02456ce
child 128
3246b74d96bc
child 129
8b24770dea79
     1.1 diff -r df40e6668a46 -r 15ae2788e848 src/memory.c
     1.2 --- a/src/memory.c	Mon Jan 14 09:50:37 2013 +0000
     1.3 +++ b/src/memory.c	Tue Jan 15 17:02:56 2013 +0000
     1.4 @@ -111,7 +111,6 @@
     1.5  	return MEM_ALLOWED;
     1.6  }/*}}}*/
     1.7  
     1.8 -#undef MAPRAM
     1.9  
    1.10  
    1.11  /********************************************************
    1.12 @@ -1011,7 +1010,72 @@
    1.13  
    1.14  
    1.15  // for the disassembler
    1.16 -uint32_t m68k_read_disassembler_32(uint32_t addr) { return m68k_read_memory_32(addr); }
    1.17 -uint32_t m68k_read_disassembler_16(uint32_t addr) { return m68k_read_memory_16(addr); }
    1.18 -uint32_t m68k_read_disassembler_8 (uint32_t addr) { return m68k_read_memory_8 (addr); }
    1.19 +uint32_t m68k_read_disassembler_32(uint32_t addr)
    1.20 +{
    1.21 +	if (addr < 0x400000) {
    1.22 +		uint16_t page = (addr >> 12) & 0x3FF;
    1.23 +		uint32_t new_page_addr = MAPRAM(page) & 0x3FF;
    1.24 +		uint32_t newAddr = (new_page_addr << 12) + (addr & 0xFFF);
    1.25 +		if (newAddr <= 0x1fffff) {
    1.26 +			if (newAddr >= state.base_ram_size)
    1.27 +				return EMPTY;
    1.28 +			else
    1.29 +				return RD32(state.base_ram, newAddr, state.base_ram_size - 1);
    1.30 +		} else {
    1.31 +			if ((newAddr <= (state.exp_ram_size + 0x200000 - 1)) && (newAddr >= 0x200000))
    1.32 +				return RD32(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1);
    1.33 +			else
    1.34 +				return EMPTY;
    1.35 +		}
    1.36 +	} else {
    1.37 +		printf(">>> WARNING Disassembler RD32 out of range 0x%08X\n", addr);
    1.38 +		return EMPTY;
    1.39 +	}
    1.40 +}
    1.41  
    1.42 +uint32_t m68k_read_disassembler_16(uint32_t addr)
    1.43 +{
    1.44 +	if (addr < 0x400000) {
    1.45 +		uint16_t page = (addr >> 12) & 0x3FF;
    1.46 +		uint32_t new_page_addr = MAPRAM(page) & 0x3FF;
    1.47 +		uint32_t newAddr = (new_page_addr << 12) + (addr & 0xFFF);
    1.48 +		if (newAddr <= 0x1fffff) {
    1.49 +			if (newAddr >= state.base_ram_size)
    1.50 +				return EMPTY & 0xffff;
    1.51 +			else
    1.52 +				return RD16(state.base_ram, newAddr, state.base_ram_size - 1);
    1.53 +		} else {
    1.54 +			if ((newAddr <= (state.exp_ram_size + 0x200000 - 1)) && (newAddr >= 0x200000))
    1.55 +				return RD16(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1);
    1.56 +			else
    1.57 +				return EMPTY & 0xffff;
    1.58 +		}
    1.59 +	} else {
    1.60 +		printf(">>> WARNING Disassembler RD16 out of range 0x%08X\n", addr);
    1.61 +		return EMPTY & 0xffff;
    1.62 +	}
    1.63 +}
    1.64 +
    1.65 +uint32_t m68k_read_disassembler_8 (uint32_t addr)
    1.66 +{
    1.67 +	if (addr < 0x400000) {
    1.68 +		uint16_t page = (addr >> 12) & 0x3FF;
    1.69 +		uint32_t new_page_addr = MAPRAM(page) & 0x3FF;
    1.70 +		uint32_t newAddr = (new_page_addr << 12) + (addr & 0xFFF);
    1.71 +		if (newAddr <= 0x1fffff) {
    1.72 +			if (newAddr >= state.base_ram_size)
    1.73 +				return EMPTY & 0xff;
    1.74 +			else
    1.75 +				return RD8(state.base_ram, newAddr, state.base_ram_size - 1);
    1.76 +		} else {
    1.77 +			if ((newAddr <= (state.exp_ram_size + 0x200000 - 1)) && (newAddr >= 0x200000))
    1.78 +				return RD8(state.exp_ram, newAddr - 0x200000, state.exp_ram_size - 1);
    1.79 +			else
    1.80 +				return EMPTY & 0xff;
    1.81 +		}
    1.82 +	} else {
    1.83 +		printf(">>> WARNING Disassembler RD8 out of range 0x%08X\n", addr);
    1.84 +		return EMPTY & 0xff;
    1.85 +	}
    1.86 +}
    1.87 +